mirror of
https://github.com/encounter/bdwgc.git
synced 2026-03-30 10:57:55 -07:00
68c2498641
* allchblk.c (GC_dump_regions, GC_allochblk_nth): Cast pointers to word type in relational (less-greater) comparisons. * alloc.c (GC_add_to_heap, GC_print_heap_sects, GC_expand_hp_inner): Likewise. * backgraph.c (ensure_struct, add_back_edges): Likewise. * blacklst.c (GC_number_stack_black_listed): Likewise. * checksums.c (GC_checksum, GC_check_dirty): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Likewise. * dbg_mlc.c (GC_get_back_ptr_info, GC_print_smashed_obj, GC_check_heap_block): Likewise. * dyn_load.c (sort_heap_sects, GC_register_map_entries, GC_register_dynlib_callback, GC_register_dynamic_libraries_dl_iterate_phdr, GC_register_dynamic_libraries, GC_cond_add_roots): Likewise. * finalize.c (GC_ignore_self_finalize_mark_proc): Likewise. * headers.c (GC_scratch_alloc, GC_install_counts, GC_remove_counts): Likewise. * include/private/gc_pmark.h (PUSH_OBJ, PUsH_CONTENTS_HDR, GC_PUSH_ONE_STACK, GC_PUSH_ONE_HEAP, GC_mark_stack_empty): Likewise. * include/private/gc_priv.h (MAKE_COOLER, COOLER_THAN): Likewise. * mach_dep.c (GC_with_callee_saves_pushed): Likewise. * malloc.c (calloc, free): Likewise. * mark.c (GC_mark_some_inner, GC_mark_from, GC_steal_mark_stack, GC_return_mark_stack, GC_do_local_mark, GC_mark_local, GC_push_all, GC_push_selected, GC_push_all_eager, GC_push_marked1, GC_push_marked2, GC_push_marked4, GC_push_marked, GC_push_unconditionally): Likewise. * mark_rts.c (GC_is_static_root, GC_add_roots_inner, GC_remove_roots_inner, GC_is_tmp_root, GC_exclude_static_roots_inner, GC_push_conditional_with_exclusions, GC_push_all_register_sections, GC_push_all_stack_sections, GC_push_all_stack_partially_eager, GC_push_all_stack_part_eager_sections, GC_push_current_stack): Likewise. * misc.c (GC_clear_stack_inner, GC_clear_stack, GC_base, GC_call_with_gc_active): Likewise. * new_hblk.c (GC_build_fl_clear2, GC_build_fl_clear4, GC_build_fl2, GC_build_fl4, GC_build_fl): Likewise. * os_dep.c (GC_enclosing_mapping, GC_text_mapping, tiny_sbrk, GC_find_limit_openbsd, GC_skip_hole_openbsd, GC_find_limit_with_bound, GC_get_main_stack_base, GC_get_stack_base, GC_least_described_address, GC_register_root_section, GC_register_data_segments, GC_unmap_start, GC_gww_read_dirty, GC_remove_protection, GC_protect_heap, GC_unprotect_range, GC_read_dirty, GC_page_was_dirty, GC_save_callers, GC_print_callers): Likewise. * pcr_interface.c (GC_enumerate_block): Likewise. * pthread_support.c (GC_is_thread_tsd_valid, GC_segment_is_thread_stack, GC_greatest_stack_base_below, GC_call_with_gc_active): Likewise. * ptr_chck.c (GC_same_obj, GC_is_valid_displacement, GC_on_stack, GC_is_visible): Likewise. * reclaim.c (GC_reclaim_clear, GC_reclaim_uninit, GC_disclaim_and_reclaim, GC_reclaim_check, GC_start_reclaim): Likewise. * tests/test.c (cons): Likewise. * tools/setjmp_t.c (main): Likewise. * typd_mlc.c (GC_typed_mark_proc): Likewise. * win32_threads.c (GC_is_thread_tsd_valid, GC_call_with_gc_active, GC_push_stack_for, GC_get_next_stack): Likewise. * extra/msvc_dbg.c (GetDescriptionFromAddress, GetDescriptionFromStack): Cast pointers to GC_ULONG_PTR in relational comparisons. * include/gc.h (GC_DATASTART, GC_DATAEND): Cast pointers to GC_word in relational comparisons. * misc.c (GC_init): Remove static assertion on ((ptr_t)-1 > 0) since no longer required; add the comment. * pcr_interface.c: Expand tabs to spaces.
180 lines
4.9 KiB
C
180 lines
4.9 KiB
C
/*
|
|
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
|
|
*
|
|
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
|
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
|
*
|
|
* Permission is hereby granted to use or copy this program
|
|
* for any purpose, provided the above notices are retained on all copies.
|
|
* Permission to modify the code and to distribute modified code is granted,
|
|
* provided the above notices are retained, and a notice that the code was
|
|
* modified is included with the above copyright notice.
|
|
*/
|
|
# include "private/gc_priv.h"
|
|
|
|
# ifdef PCR
|
|
/*
|
|
* Note that POSIX PCR requires an ANSI C compiler. Hence we are allowed
|
|
* to make the same assumption here.
|
|
* We wrap all of the allocator functions to avoid questions of
|
|
* compatibility between the prototyped and nonprototyped versions of the f
|
|
*/
|
|
# include "config/PCR_StdTypes.h"
|
|
# include "mm/PCR_MM.h"
|
|
# include <errno.h>
|
|
|
|
# define MY_MAGIC 17L
|
|
# define MY_DEBUGMAGIC 42L
|
|
|
|
void * GC_AllocProc(size_t size, PCR_Bool ptrFree, PCR_Bool clear )
|
|
{
|
|
if (ptrFree) {
|
|
void * result = (void *)GC_malloc_atomic(size);
|
|
if (clear && result != 0) BZERO(result, size);
|
|
return(result);
|
|
} else {
|
|
return((void *)GC_malloc(size));
|
|
}
|
|
}
|
|
|
|
void * GC_DebugAllocProc(size_t size, PCR_Bool ptrFree, PCR_Bool clear )
|
|
{
|
|
if (ptrFree) {
|
|
void * result = (void *)GC_debug_malloc_atomic(size, __FILE__,
|
|
__LINE__);
|
|
if (clear && result != 0) BZERO(result, size);
|
|
return(result);
|
|
} else {
|
|
return((void *)GC_debug_malloc(size, __FILE__, __LINE__));
|
|
}
|
|
}
|
|
|
|
# define GC_ReallocProc GC_realloc
|
|
void * GC_DebugReallocProc(void * old_object, size_t new_size_in_bytes)
|
|
{
|
|
return(GC_debug_realloc(old_object, new_size_in_bytes, __FILE__, __LINE__));
|
|
}
|
|
|
|
# define GC_FreeProc GC_free
|
|
# define GC_DebugFreeProc GC_debug_free
|
|
|
|
typedef struct {
|
|
PCR_ERes (*ed_proc)(void *p, size_t size, PCR_Any data);
|
|
GC_bool ed_pointerfree;
|
|
PCR_ERes ed_fail_code;
|
|
PCR_Any ed_client_data;
|
|
} enumerate_data;
|
|
|
|
void GC_enumerate_block(struct hblk *h; enumerate_data * ed)
|
|
{
|
|
register hdr * hhdr;
|
|
register int sz;
|
|
ptr_t p;
|
|
ptr_t lim;
|
|
word descr;
|
|
# error This code was updated without testing.
|
|
# error and its precursor was clearly broken.
|
|
|
|
hhdr = HDR(h);
|
|
descr = hhdr -> hb_descr;
|
|
sz = hhdr -> hb_sz;
|
|
if (descr != 0 && ed -> ed_pointerfree
|
|
|| descr == 0 && !(ed -> ed_pointerfree)) return;
|
|
lim = (ptr_t)(h+1) - sz;
|
|
p = (ptr_t)h;
|
|
do {
|
|
if (PCR_ERes_IsErr(ed -> ed_fail_code)) return;
|
|
ed -> ed_fail_code =
|
|
(*(ed -> ed_proc))(p, sz, ed -> ed_client_data);
|
|
p+= sz;
|
|
} while ((word)p <= (word)lim);
|
|
}
|
|
|
|
struct PCR_MM_ProcsRep * GC_old_allocator = 0;
|
|
|
|
PCR_ERes GC_EnumerateProc(
|
|
PCR_Bool ptrFree,
|
|
PCR_ERes (*proc)(void *p, size_t size, PCR_Any data),
|
|
PCR_Any data
|
|
)
|
|
{
|
|
enumerate_data ed;
|
|
|
|
ed.ed_proc = proc;
|
|
ed.ed_pointerfree = ptrFree;
|
|
ed.ed_fail_code = PCR_ERes_okay;
|
|
ed.ed_client_data = data;
|
|
GC_apply_to_all_blocks(GC_enumerate_block, &ed);
|
|
if (ed.ed_fail_code != PCR_ERes_okay) {
|
|
return(ed.ed_fail_code);
|
|
} else {
|
|
/* Also enumerate objects allocated by my predecessors */
|
|
return((*(GC_old_allocator->mmp_enumerate))(ptrFree, proc, data));
|
|
}
|
|
}
|
|
|
|
void GC_DummyFreeProc(void *p) {}
|
|
|
|
void GC_DummyShutdownProc(void) {}
|
|
|
|
struct PCR_MM_ProcsRep GC_Rep = {
|
|
MY_MAGIC,
|
|
GC_AllocProc,
|
|
GC_ReallocProc,
|
|
GC_DummyFreeProc, /* mmp_free */
|
|
GC_FreeProc, /* mmp_unsafeFree */
|
|
GC_EnumerateProc,
|
|
GC_DummyShutdownProc /* mmp_shutdown */
|
|
};
|
|
|
|
struct PCR_MM_ProcsRep GC_DebugRep = {
|
|
MY_DEBUGMAGIC,
|
|
GC_DebugAllocProc,
|
|
GC_DebugReallocProc,
|
|
GC_DummyFreeProc, /* mmp_free */
|
|
GC_DebugFreeProc, /* mmp_unsafeFree */
|
|
GC_EnumerateProc,
|
|
GC_DummyShutdownProc /* mmp_shutdown */
|
|
};
|
|
|
|
GC_bool GC_use_debug = 0;
|
|
|
|
void GC_pcr_install()
|
|
{
|
|
PCR_MM_Install((GC_use_debug? &GC_DebugRep : &GC_Rep), &GC_old_allocator);
|
|
}
|
|
|
|
PCR_ERes
|
|
PCR_GC_Setup(void)
|
|
{
|
|
return PCR_ERes_okay;
|
|
}
|
|
|
|
PCR_ERes
|
|
PCR_GC_Run(void)
|
|
{
|
|
|
|
if( !PCR_Base_TestPCRArg("-nogc") ) {
|
|
GC_quiet = ( PCR_Base_TestPCRArg("-gctrace") ? 0 : 1 );
|
|
GC_use_debug = (GC_bool)PCR_Base_TestPCRArg("-debug_alloc");
|
|
GC_init();
|
|
if( !PCR_Base_TestPCRArg("-nogc_incremental") ) {
|
|
/*
|
|
* awful hack to test whether VD is implemented ...
|
|
*/
|
|
if( PCR_VD_Start( 0, NIL, 0) != PCR_ERes_FromErr(ENOSYS) ) {
|
|
GC_enable_incremental();
|
|
}
|
|
}
|
|
}
|
|
return PCR_ERes_okay;
|
|
}
|
|
|
|
void GC_push_thread_structures(void)
|
|
{
|
|
/* PCR doesn't work unless static roots are pushed. Can't get here. */
|
|
ABORT("In GC_push_thread_structures()");
|
|
}
|
|
|
|
# endif
|