📄 gc_priv.h
字号:
/* dynamic library registration. */ /* Machine dependent startup routines */ptr_t GC_get_stack_base GC_PROTO((void)); /* Cold end of stack */#ifdef IA64 ptr_t GC_get_register_stack_base GC_PROTO((void)); /* Cold end of register stack. */#endifvoid GC_register_data_segments GC_PROTO((void)); /* Black listing: */void GC_bl_init GC_PROTO((void));# ifdef PRINT_BLACK_LIST void GC_add_to_black_list_normal GC_PROTO((word p, ptr_t source)); /* Register bits as a possible future false */ /* reference from the heap or static data */# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \ if (GC_all_interior_pointers) { \ GC_add_to_black_list_stack(bits, (ptr_t)(source)); \ } else { \ GC_add_to_black_list_normal(bits, (ptr_t)(source)); \ }# else void GC_add_to_black_list_normal GC_PROTO((word p));# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \ if (GC_all_interior_pointers) { \ GC_add_to_black_list_stack(bits); \ } else { \ GC_add_to_black_list_normal(bits); \ }# endif# ifdef PRINT_BLACK_LIST void GC_add_to_black_list_stack GC_PROTO((word p, ptr_t source));# else void GC_add_to_black_list_stack GC_PROTO((word p));# endifstruct hblk * GC_is_black_listed GC_PROTO((struct hblk * h, word len)); /* If there are likely to be false references */ /* to a block starting at h of the indicated */ /* length, then return the next plausible */ /* starting location for h that might avoid */ /* these false references. */void GC_promote_black_lists GC_PROTO((void)); /* Declare an end to a black listing phase. */void GC_unpromote_black_lists GC_PROTO((void)); /* Approximately undo the effect of the above. */ /* This actually loses some information, but */ /* only in a reasonably safe way. */word GC_number_stack_black_listed GC_PROTO(( \ struct hblk *start, struct hblk *endp1)); /* Return the number of (stack) blacklisted */ /* blocks in the range for statistical */ /* purposes. */ ptr_t GC_scratch_alloc GC_PROTO((word bytes)); /* GC internal memory allocation for */ /* small objects. Deallocation is not */ /* possible. */ /* Heap block layout maps: */ void GC_invalidate_map GC_PROTO((hdr * hhdr)); /* Remove the object map associated */ /* with the block. This identifies */ /* the block as invalid to the mark */ /* routines. */GC_bool GC_add_map_entry GC_PROTO((word sz)); /* Add a heap block map for objects of */ /* size sz to obj_map. */ /* Return FALSE on failure. */void GC_register_displacement_inner GC_PROTO((word offset)); /* Version of GC_register_displacement */ /* that assumes lock is already held */ /* and signals are already disabled. */ /* hblk allocation: */ void GC_new_hblk GC_PROTO((word size_in_words, int kind)); /* Allocate a new heap block, and build */ /* a free list in it. */ ptr_t GC_build_fl GC_PROTO((struct hblk *h, word sz, GC_bool clear, ptr_t list)); /* Build a free list for objects of */ /* size sz in block h. Append list to */ /* end of the free lists. Possibly */ /* clear objects on the list. Normally */ /* called by GC_new_hblk, but also */ /* called explicitly without GC lock. */struct hblk * GC_allochblk GC_PROTO(( \ word size_in_words, int kind, unsigned flags)); /* Allocate a heap block, inform */ /* the marker that block is valid */ /* for objects of indicated size. */ptr_t GC_alloc_large GC_PROTO((word lw, int k, unsigned flags)); /* Allocate a large block of size lw words. */ /* The block is not cleared. */ /* Flags is 0 or IGNORE_OFF_PAGE. */ /* Calls GC_allchblk to do the actual */ /* allocation, but also triggers GC and/or */ /* heap expansion as appropriate. */ /* Does not update GC_words_allocd, but does */ /* other accounting. */ptr_t GC_alloc_large_and_clear GC_PROTO((word lw, int k, unsigned flags)); /* As above, but clear block if appropriate */ /* for kind k. */void GC_freehblk GC_PROTO((struct hblk * p)); /* Deallocate a heap block and mark it */ /* as invalid. */ /* Misc GC: */void GC_init_inner GC_PROTO((void));GC_bool GC_expand_hp_inner GC_PROTO((word n));void GC_start_reclaim GC_PROTO((int abort_if_found)); /* Restore unmarked objects to free */ /* lists, or (if abort_if_found is */ /* TRUE) report them. */ /* Sweeping of small object pages is */ /* largely deferred. */void GC_continue_reclaim GC_PROTO((word sz, int kind)); /* Sweep pages of the given size and */ /* kind, as long as possible, and */ /* as long as the corr. free list is */ /* empty. */void GC_reclaim_or_delete_all GC_PROTO((void)); /* Arrange for all reclaim lists to be */ /* empty. Judiciously choose between */ /* sweeping and discarding each page. */GC_bool GC_reclaim_all GC_PROTO((GC_stop_func stop_func, GC_bool ignore_old)); /* Reclaim all blocks. Abort (in a */ /* consistent state) if f returns TRUE. */GC_bool GC_block_empty GC_PROTO((hdr * hhdr)); /* Block completely unmarked? */GC_bool GC_never_stop_func GC_PROTO((void)); /* Returns FALSE. */GC_bool GC_try_to_collect_inner GC_PROTO((GC_stop_func f)); /* Collect; caller must have acquired */ /* lock and disabled signals. */ /* Collection is aborted if f returns */ /* TRUE. Returns TRUE if it completes */ /* successfully. */# define GC_gcollect_inner() \ (void) GC_try_to_collect_inner(GC_never_stop_func)void GC_finish_collection GC_PROTO((void)); /* Finish collection. Mark bits are */ /* consistent and lock is still held. */GC_bool GC_collect_or_expand GC_PROTO(( \ word needed_blocks, GC_bool ignore_off_page)); /* Collect or expand heap in an attempt */ /* make the indicated number of free */ /* blocks available. Should be called */ /* until the blocks are available or */ /* until it fails by returning FALSE. */#if defined(MSWIN32) || defined(MSWINCE) void GC_deinit GC_PROTO((void)); /* Free any resources allocated by */ /* GC_init */#endifvoid GC_collect_a_little_inner GC_PROTO((int n)); /* Do n units worth of garbage */ /* collection work, if appropriate. */ /* A unit is an amount appropriate for */ /* HBLKSIZE bytes of allocation. */ptr_t GC_generic_malloc GC_PROTO((word lb, int k)); /* Allocate an object of the given */ /* kind. By default, there are only */ /* a few kinds: composite(pointerfree), */ /* atomic, uncollectable, etc. */ /* We claim it's possible for clever */ /* client code that understands GC */ /* internals to add more, e.g. to */ /* communicate object layout info */ /* to the collector. */ptr_t GC_generic_malloc_ignore_off_page GC_PROTO((size_t b, int k)); /* As above, but pointers past the */ /* first page of the resulting object */ /* are ignored. */ptr_t GC_generic_malloc_inner GC_PROTO((word lb, int k)); /* Ditto, but I already hold lock, etc. */ptr_t GC_generic_malloc_words_small GC_PROTO((size_t lw, int k)); /* As above, but size in units of words */ /* Bypasses MERGE_SIZES. Assumes */ /* words <= MAXOBJSZ. */ptr_t GC_generic_malloc_inner_ignore_off_page GC_PROTO((size_t lb, int k)); /* Allocate an object, where */ /* the client guarantees that there */ /* will always be a pointer to the */ /* beginning of the object while the */ /* object is live. */ptr_t GC_allocobj GC_PROTO((word sz, int kind)); /* Make the indicated */ /* free list nonempty, and return its */ /* head. */ void GC_init_headers GC_PROTO((void));struct hblkhdr * GC_install_header GC_PROTO((struct hblk *h)); /* Install a header for block h. */ /* Return 0 on failure, or the header */ /* otherwise. */GC_bool GC_install_counts GC_PROTO((struct hblk * h, word sz)); /* Set up forwarding counts for block */ /* h of size sz. */ /* Return FALSE on failure. */void GC_remove_header GC_PROTO((struct hblk * h)); /* Remove the header for block h. */void GC_remove_counts GC_PROTO((struct hblk * h, word sz)); /* Remove forwarding counts for h. */hdr * GC_find_header GC_PROTO((ptr_t h)); /* Debugging only. */ void GC_finalize GC_PROTO((void)); /* Perform all indicated finalization actions */ /* on unmarked objects. */ /* Unreachable finalizable objects are enqueued */ /* for processing by GC_invoke_finalizers. */ /* Invoked with lock. */void GC_notify_or_invoke_finalizers GC_PROTO((void)); /* If GC_finalize_on_demand is not set, invoke */ /* eligible finalizers. Otherwise: */ /* Call *GC_finalizer_notifier if there are */ /* finalizers to be run, and we haven't called */ /* this procedure yet this GC cycle. */ void GC_add_to_heap GC_PROTO((struct hblk *p, word bytes)); /* Add a HBLKSIZE aligned chunk to the heap. */ void GC_print_obj GC_PROTO((ptr_t p)); /* P points to somewhere inside an object with */ /* debugging info. Print a human readable */ /* description of the object to stderr. */extern void (*GC_check_heap) GC_PROTO((void)); /* Check that all objects in the heap with */ /* debugging info are intact. Print */ /* descriptions of any that are not. */extern void (*GC_print_heap_obj) GC_PROTO((ptr_t p)); /* If possible print s followed by a more */ /* detailed description of the object */ /* referred to by p. */extern GC_bool GC_print_stats; /* Produce at least some logging output */ /* Set from environment variable. *//* Macros used for collector internal allocation. *//* These assume the collector lock is held. */#ifdef DBG_HDRS_ALL extern GC_PTR GC_debug_generic_malloc_inner(size_t lb, int k); extern GC_PTR GC_debug_generic_malloc_inner_ignore_off_page(size_t lb, int k);# define GC_INTERNAL_MALLOC GC_debug_generic_malloc_inner# define GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE \ GC_debug_generic_malloc_inner_ignore_off_page# ifdef THREADS# define GC_INTERNAL_FREE GC_debug_free_inner# else# define GC_INTERNAL_FREE GC_debug_free# endif#else# define GC_INTERNAL_MALLOC GC_generic_malloc_inner# define GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE \ GC_generic_malloc_inner_ignore_off_page# ifdef THREADS# define GC_INTERNAL_FREE GC_free_inner# else# define GC_INTERNAL_FREE GC_free# endif#endif/* Memory unmapping: */#ifdef USE_MUNMAP void GC_unmap_old(void); void GC_merge_unmapped(void); void GC_unmap(ptr_t start, word bytes); void GC_remap(ptr_t start, word bytes); void GC_unmap_gap(ptr_t start1, word bytes1, ptr_t start2, word bytes2);#endif/* Virtual dirty bit implementation: *//* Each implementation exports the following: */void GC_read_dirty GC_PROTO((void)); /* Retrieve dirty bits. */GC_bool GC_page_was_dirty GC_PROTO((struct hblk *h)); /* Read retrieved dirty bits. */GC_bool GC_page_was_ever_dirty GC_PROTO((struct hblk *h)); /* Could the page contain valid heap pointers? */void GC_is_fresh GC_PROTO((struct hblk *h, word n)); /* Assert the region currently contains no */ /* valid pointers. */void GC_remove_protection GC_PROTO((struct hblk *h, word nblocks, GC_bool pointerfree)); /* h is about to be writteni or allocated. Ensure */ /* that it's not write protected by the virtual */ /* dirty bit implementation. */ void GC_dirty_init GC_PROTO((void)); /* Slow/general mark bit manipulation: */GC_API GC_bool GC_is_marked GC_PROTO((ptr_t p));void GC_clear_mark_bit GC_PROTO((ptr_t p));void GC_set_mark_bit GC_PROTO((ptr_t p)); /* Stubborn objects: */void GC_read_changed GC_PROTO((void)); /* Analogous to GC_read_dirty */GC_bool GC_page_was_changed GC_PROTO((struct hblk * h)); /* Analogous to GC_page_was_dirty */void GC_clean_changing_list GC_PROTO((void)); /* Collect obsolete changing list entries */void GC_stubborn_init GC_PROTO((void)); /* Debugging print routines: */void GC_print_block_list GC_PROTO((void));void GC_print_hblkfreelist GC_PROTO((void));void GC_print_heap_sects GC_PROTO((void));void GC_print_static_roots GC_PROTO((void));void GC_dump GC_PROTO((void));#ifdef KEEP_BACK_PTRS void GC_store_back_pointer(ptr_t source, ptr_t dest); void GC_marked_for_finalization(ptr_t dest);# define GC_STORE_BACK_PTR(source, dest) GC_store_back_pointer(source, dest)# define GC_MARKED_FOR_FINALIZATION(dest) GC_marked_for_finalization(dest)#else# define GC_STORE_BACK_PTR(source, dest) # define GC_MARKED_FOR_FINALIZATION(dest)#endif/* Make arguments appear live to compiler */# ifdef __WATCOMC__ void GC_noop(void*, ...);# else# ifdef __DMC__ GC_API void GC_noop(...);# else GC_API void GC_noop();# endif# endifvoid GC_noop1 GC_PROTO((word));/* Logging and diagnostic output: */GC_API void GC_printf GC_PROTO((GC_CONST char * format, long, long, long, long, long, long)); /* A version of printf that doesn't allocate, */ /* is restricted to long arguments, and */ /* (unfortunately) doesn't use varargs for */ /* portability. Restricted to 6 args and */ /* 1K total output length. */ /* (We use sprintf. Hopefully that doesn't */ /* allocate for long arguments.) */# define GC_printf0(f) GC_printf(f, 0l, 0l, 0l, 0l, 0l, 0l)# define GC_printf1(f,a) GC_printf(f, (long)a, 0l, 0l, 0l, 0l, 0l)# define GC_printf2(f,a,b) GC_printf(f, (long)a, (long)b, 0l, 0l, 0l, 0l)# define GC_printf3(f,a,b,c) GC_printf(f, (long)a, (long)b, (long)c, 0l, 0l, 0l)# define GC_printf4(f,a,b,c,d) GC_printf(f, (long)a, (long)b, (long)c, \ (long)d, 0l, 0l)# define GC_printf5(f,a,b,c,d,e) GC_printf(f, (long)a, (long)b, (long)c, \ (long)d, (long)e, 0l)# define GC_printf6(f,a,b,c,d,e,g) GC_printf(f, (long)a, (long)b, (long)c, \ (long)d, (long)e, (long)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -