📄 gc_priv.h
字号:
# 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. */extern GC_bool GC_is_initialized; /* GC_init() has been run. */#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. */ /* The actual decl is in gc_mark.h. */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_inner GC_PROTO((word lw, int k)); /* Analogous to the above, but assumes */ /* a small object size, and bypasses */ /* MERGE_SIZES mechanism. */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_free_inner(GC_PTR p); 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. */GC_API GC_PTR GC_make_closure GC_PROTO((GC_finalization_proc fn, GC_PTR data));GC_API void GC_debug_invoke_finalizer GC_PROTO((GC_PTR obj, GC_PTR data)); /* Auxiliary fns to make finalization work */ /* correctly with displaced pointers introduced */ /* by the debugging allocators. */ 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. */ /* Add any that are not to GC_smashed list. */extern void (*GC_print_all_smashed) GC_PROTO((void)); /* Print GC_smashed if it's not empty. */ /* Clear GC_smashed list. */extern void GC_print_all_errors GC_PROTO((void)); /* Print smashed and leaked objects, if any. */ /* Clear the lists of such objects. */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. */#if defined(LINUX) && defined(__ELF__) && !defined(SMALL_CONFIG) void GC_print_address_map GC_PROTO((void)); /* Print an address map of the process. */#endifextern GC_bool GC_have_errors; /* We saw a smashed or leaked object. */ /* Call error printing routine */ /* occasionally. */extern GC_bool GC_print_stats; /* Produce at least some logging output */ /* Set from environment variable. */#ifndef NO_DEBUGGING extern GC_bool GC_dump_regularly; /* Generate regular debugging dumps. */# define COND_DUMP if (GC_dump_regularly) GC_dump();#else# define COND_DUMP#endif#ifdef KEEP_BACK_PTRS extern long GC_backtraces; void GC_generate_random_backtrace_no_gc(void);#endifextern GC_bool GC_print_back_height;#ifdef MAKE_BACK_GRAPH void GC_print_back_graph_stats(void);#endif/* 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_print_finalization_stats 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 */ /* (unfo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -