summaryrefslogtreecommitdiff
path: root/include/gc.h
Commit message (Collapse)AuthorAgeFilesLines
* Move public header files to include/gc in source treeIvan Maidanski2021-11-251-2172/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, include/extra public header files (for the redirection) are moved to include directory. This is have the same directories structure of public headers in the source tree as that of the installed "include" directory. * doc/finalization.md: Remove "include/" prefix for cord.h. * LICENSE: Rename include/gc_allocator.h to gc/gc_allocator.h. * Makefile.direct (CORD_SRCS, CORD_INCLUDE_FILES): Add "gc/" prefix for cord.h, ec.h, cord_pos.h. * CMakeLists.txt [install_headers]: Likewise. * cord/cord.am (pkginclude_HEADERS): Likewise. * Makefile.direct (SRCS, tests/test.o, dyn_load.o, dyn_load_sunos53.o, mark.o, typd_mlc.o, finalize.o, ptr_chck.o, specific.o, alloc.o, pthread_support.o, thread_local_alloc.o, win32_threads.o): Add "gc/" prefix for gc_typed.h, gc_tiny_fl.h, gc_version.h, gc_inline.h, gc_mark.h, gc_disclaim.h, gc_allocator.h, javaxfc.h, gc_backptr.h, gc_gcj.h, leak_detector.h, gc_pthread_redirects.h, gc_config_macros.h. * NT_MAKEFILE (test.obj): Add gc\ prefix for gc_mark.h, gc_disclaim.h. * NT_MAKEFILE (cord\tests\de.obj, cord\tests\de_win.obj): Add gc\ prefix for cord.h, cord_pos.h. * OS2_MAKEFILE (cord\cordbscs.obj, cord\cordxtra.obj, cord\cordprnt.obj, cordtest.exe): Likewise. * cord/cordbscs.c: Add "gc/" prefix in include for cord.h, ec.h; reorder includes. * cord/cordprnt.c: Likewise. * cord/cordxtra.c: Likewise. * cord/tests/cordtest.c: Likewise. * cord/tests/de.c: Likewise. * cord/tests/de_win.c: Likewise. * extra/gc.c: Add "gc/" prefix in include for gc_inline.h, gc_pthread_redirects.h, javaxfc.h, gc_disclaim.h, gc_gcj.h, gc_backptr.h, gc_mark.h, gc_tiny_fl.h, leak_detector.h., gc_typed.h. * finalize.c: Likewise. * fnlz_mlc.c: Likewise. * gcj_mlc.c: Likewise. * include/private/dbg_mlc.h: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/gc_priv.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * malloc.c: Likewise. * mallocx.c: Likewise. * pthread_stop_world.c: Likewise. * pthread_support.c: Likewise. * reclaim.c: Likewise. * tests/disclaim_bench.c: Likewise. * tests/disclaim_test.c: Likewise. * tests/disclaim_weakmap_test.c: Likewise. * tests/leak_test.c: Likewise. * tests/staticrootstest.c: Likewise. * tests/test.c: Likewise. * tests/thread_leak_test.c: Likewise. * tests/trace_test.c: Likewise. * thread_local_alloc.c: Likewise. * typd_mlc.c: Likewise. * tests/test_cpp.cc: Add "gc/" prefix in include for gc_allocator.h. * include/extra/gc.h: Move to include folder; replace include<> to include "". * include/extra/gc_cpp.h: Likewise. * include/cord.h: Move to include/gc folder. * include/cord_pos.h: Likewise. * include/ec.h: Likewise. * include/gc.h: Likewise. * include/gc_allocator.h: Likewise. * include/gc_backptr.h: Likewise. * include/gc_config_macros.h: Likewise. * include/gc_cpp.h: Likewise. * include/gc_disclaim.h: Likewise. * include/gc_gcj.h: Likewise. * include/gc_inline.h: Likewise. * include/gc_mark.h: Likewise. * include/gc_pthread_redirects.h: Likewise. * include/gc_tiny_fl.h: Likewise. * include/gc_typed.h: Likewise. * include/gc_version.h: Likewise. * include/javaxfc.h: Likewise. * include/leak_detector.h: Likewise. * include/include.am (pkginclude_HEADERS): Add "gc/" prefix for gc.h, gc_backptr.h, gc_config_macros.h, gc_inline.h, gc_mark.h, gc_tiny_fl.h, gc_typed.h, gc_version.h, javaxfc.h, leak_detector.h, gc_disclaim.h, gc_gcj.h, gc_pthread_redirects.h, gc_allocator.h, gc_cpp.h. * CMakeLists.txt [install_headers]: Likewise. * include/include.am (include_HEADERS): Remove "extra/" prefix for gc_cpp.h, gc.h. * CMakeLists.txt [install_headers]: Likewise.
* Synchronize copyright years between README filesIvan Maidanski2021-11-221-4/+4
| | | | | | | | | | | | | | | * README.QUICK: Copy copyright years from README.md. * README.md (Copyright & Warranty): Adjust copyrights (synchronize with that of the source files). * alloc.c: Adjust copyrights in the file head comment and GC_copyright (synchronize with that of updated README.QUICK). * include/gc.h: Likewise. * alloc.c (GC_copyright): Reformat. * dbg_mlc.c: Add trailing dot to a copyright in the file head comment. * finalize.c: Likewise. * include/gc.h: Likewise. * tests/initsecondarythread.c: Reformat copyright in the file head comment (change C to lower case).
* Declare API function and print amount of memory obtained from OSIvan Maidanski2021-09-221-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Public GC_get_obtained_from_os_bytes() is introduced. * alloc.c [USE_MUNMAP] (GC_stopped_mark): Add assertion that GC_heapsize is not less than GC_unmapped_bytes. * alloc.c (GC_stopped_mark): Add assertion that GC_our_mem_bytes is not less than GC_heapsize; print GC_our_mem_bytes-GC_heapsize value (using GC_DBGLOG_PRINTF). * alloc.c [USE_PROC_FOR_LIBRARIES] (GC_add_to_our_memory): Update comment; increment GC_our_mem_bytes value (by bytes). * include/private/gc_priv.h (GC_add_to_our_memory): Likewise. * include/gc.h (GC_get_obtained_from_os_bytes): New API function declaration. * include/gc.h (GC_prof_stats_s.obtained_from_os_bytes): Declare new field. * include/private/gc_priv.h (_GC_arrays._our_mem_bytes): Likewise. * misc.c (GC_get_obtained_from_os_bytes): Implement. * misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (fill_prof_stats): Set obtained_from_os_bytes field. * tests/test.c (check_heap_stats): Print value returned by GC_get_obtained_from_os_bytes(). * tests/test.c [USE_MUNMAP] (check_heap_stats): Print value returned by GC_get_unmapped_bytes().
* Reflect result of VDB selection at runtime in incremental_protection_needsIvan Maidanski2021-09-161-3/+8
| | | | | | | | | | | | | | | | | Now, GC_incremental_protection_needs returns GC_PROTECTS_NONE if GWW_VDB- or SOFT_VDB-based implementation is chosen (over MPROTECT_VDB-based one) during GC_dirty_init. * include/gc.h (GC_incremental_protection_needs): Update comment. * os_dep.c [SOFT_VDB] (clear_refs_fd): Move upper to be close to GC_GWW_AVAILABLE definition. * os_dep.c [MPROTECT_VDB && (GWW_VDB || SOFT_VDB)] (GC_incremental_protection_needs): Return GC_PROTECTS_NONE if GC_GWW_AVAILABLE(); add comment. * tests/test.c [!GC_DISABLE_INCREMENTAL && (TEST_DEFAULT_VDB || !DEFAULT_VDB)] (enable_incremental_mode): Call GC_incremental_protection_needs() and print VDB-related message depending on the result.
* Add GC_get/set_disable_automatic_collection APIJonas Echterhoff2021-07-171-0/+6
| | | | | | | | | | | | | | | | This is to have ability to disable automatic periodic collections. * alloc.c (GC_disable_automatic_collection): New static variable. * alloc.c (GC_set_disable_automatic_collection, GC_get_disable_automatic_collection): Implement API function. * alloc.c (GC_should_collect): Add assertion that GC lock is held. * alloc.c (GC_should_collect): Return false if GC_disable_automatic_collection. * include/gc.h (GC_set_disable_automatic_collection, GC_get_disable_automatic_collection): Declare API function. * tests/test.c [GC_PTHREADS] (main): Call GC_set_disable_automatic_collection(0) and GC_get_disable_automatic_collection().
* Add API function to force start of incremental collectionJonas Echterhoff2021-07-141-0/+4
| | | | | | | | | | | | | (a cherry-pick of commits 7027029, 0480a66 from Unity-Technologies/bdwgc) * alloc.c [!GC_DISABLE_INCREMENTAL] (GC_should_start_incremental_collection): New static variable. * alloc.c (GC_start_incremental_collection): Define API function. * alloc.c [!GC_DISABLE_INCREMENTAL] (GC_should_collect): If GC_should_start_incremental_collection, then reset it and return true. * include/gc.h (GC_start_incremental_collection): Declare function. * tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS] (main): Call GC_start_incremental_collection() once before run_one_test().
* New API (GC_set_markers_count) to control number of parallel markersIvan Maidanski2020-08-131-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #320 (bdwgc). Note that GC_set_markers_count() has effect only if called before GC initialization. For convenience, alternatively the client could define GC_MARKERS macro with the appropriate value before include of gc.h. * doc/README.macros (GC_MARKERS): Document. * include/gc.h [GC_THREADS] (GC_parallel): Update comment. * include/gc.h [GC_THREADS] (GC_set_markers_count): New API function declaration. * include/gc.h (GC_INIT_CONF_MARKERS): New internal macro (defined to GC_set_markers_count(GC_MARKERS) if GC_THREADS and GC_MARKERS are defined). * include/gc.h (GC_INIT): Call GC_INIT_CONF_MARKERS before GC_init. * pthread_support.c [PARALLEL_MARK] (required_markers_cnt): New static variable (initialized to 0). * win32_threads.c [PARALLEL_MARK] (required_markers_cnt): Likewise. * pthread_support.c (GC_set_markers_count): New API function definition (empty unless PARALLEL_MARK). * win32_threads.c [PARALLEL_MARK] (GC_set_markers_count): Likewise. * pthread_support.c [PARALLEL_MARK] (GC_thr_init): Initialize markers local variable to required_markers_cnt; set markers to GC_nprocs only if markers_string is null and required_markers_cnt (markers) value is zero. * tests/test.c [GC_PTHREADS] (main): Call GC_set_markers_count(0) before GC_COND_INIT(). * win32_threads.c [PARALLEL_MARK] (GC_thr_init): Initialize markers local variable to required_markers_cnt; set markers to ncpu only if markers_string is null and required_markers_cnt (markers) value is 0.
* Update copyright information in alloc.c and other modified files (2020)Ivan Maidanski2020-08-011-1/+1
| | | | | | | | | | | | | | | | | * README.QUICK (Copyright): Update year (2019 to 2020). * README.md (Copyright): Likewise. * alloc.c (Copyright, GC_copyright): Likewise. * gc_badalc.cc (Copyright): Likewise. * include/gc.h (Copyright): Likewise. * finalize.c (Copyright): Update (add Ivan Maidanski). * include/gc_config_macros.h (Copyright): Likewise. * include/private/gc_priv.h (Copyright): Likewise. * mark.c (Copyright): Likewise. * misc.c (Copyright): Likewise. * os_dep.c (Copyright): Likewise. * pthread_stop_world.c (Copyright): Likewise. * pthread_support.c (Copyright): Likewise. * win32_threads.c (Copyright): Likewise.
* Do not hard-code finalizable objects limit which triggers GCIvan Maidanski2020-07-311-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #304 (bdwgc). Previously, if more than 500 finalizable objects emerged since the latest collection (and the incremental mode is off), then new collection is started instead heap expansion. This led to frequent collections if most allocated objects were with a registered finalizer. Now, the hard coded limit (500) is replaced roughly with (GC_bytes_allocd / GC_allocd_bytes_per_finalizer), where the latter global variable has the default value of 10000 (or GC_ALLOCD_BYTES_PER_FINALIZER if defined) but could be changed by the client with GC_set_allocd_bytes_per_finalizer(). * alloc.c (GC_allocd_bytes_per_finalizer): New STATIC variable (initialized to GC_ALLOCD_BYTES_PER_FINALIZER if defined otherwise to 10000). * alloc.c (GC_set_allocd_bytes_per_finalizer, GC_get_allocd_bytes_per_finalizer): New API function definition. * alloc.c (GC_collect_or_expand): Replace GC_fo_entries>last_fo_entries+500 condition to GC_fo_entries>last_fo_entries && (GC_fo_entries-last_fo_entries)*GC_allocd_bytes_per_finalizer >GC_bytes_allocd. * doc/README.macros (GC_ALLOCD_BYTES_PER_FINALIZER): Document. * include/gc.h (GC_set_allocd_bytes_per_finalizer, GC_get_allocd_bytes_per_finalizer): New API function declaration. * include/gc.h (GC_INIT_CONF_ALLOCD_BYTES_PER_FINALIZER): New internal macro (call GC_set_allocd_bytes_per_finalizer if GC_ALLOCD_BYTES_PER_FINALIZER is defined by client). * include/gc.h (GC_INIT): Call GC_INIT_CONF_ALLOCD_BYTES_PER_FINALIZER. * tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK] (main): Call UNTESTED() for GC_get_allocd_bytes_per_finalizer and GC_set_allocd_bytes_per_finalizer.
* New API function to clear GC exclusion tableJosh Peterson2020-05-181-0/+3
| | | | | | | | | (part of commit 8b95edbd6 from Unity-Technologies/bdwgc) * include/gc.h (GC_clear_exclusion_table): Declare new API function. * mark_rts.c (GC_clear_exclusion_table): Implement. * tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS] (main): Call GC_clear_exclusion_table.
* Define GC_win32_free_heap API function for all Windows targetsIvan Maidanski2020-01-241-2/+2
| | | | | | | | | | | | | | | | | | Issue #302 (bdwgc). The function now may be no-op on some targets. * include/gc.h (GC_win32_free_heap): Refine comment (specify that it is not always defined). * os_dep.c [(MSWIN32 || MSWINCE || CYGWIN32) && !REDIRECT_MALLOC] (GC_max_root_size): Do not define unless USE_WINALLOC. * os_dep.c [(MSWIN32 || MSWINCE || CYGWIN32) && !REDIRECT_MALLOC] (GC_is_heap_base): Do update GC_max_root_size value unless USE_WINALLOC. * os_dep.c [MSWIN32 || MSWINCE || MSWIN_XBOX1] (GC_win32_free_heap): Define API function (regardless of USE_WINALLOC). * tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && (MSWINCE || CYGWIN32)] (main): Call GC_win32_free_heap() before exit.
* Fix 'ulong undefined' compilation error on AIXPeter Wang2019-06-061-2/+2
| | | | * include/gc.h [_AIX] (GC_DATASTART, GC_DATAEND): Remove cast to ulong.
* New API standalone functions to acquire and release the allocator lockIvan Maidanski2019-05-301-0/+12
| | | | | | | | | | | | | | | | | Issue #282 (bdwgc). Public GC_alloc_lock() and GC_alloc_unlock() are introduced to simplify dealing with the GC lock compared to GC_call_with_alloc_lock(). * include/gc.h [GC_THREADS] (GC_alloc_lock, GC_alloc_unlock): Declare new API function. * include/gc.h [!GC_THREADS] (GC_alloc_lock, GC_alloc_unlock): Define as a no-op macro. * misc.c [THREADS] (GC_alloc_lock, GC_alloc_unlock): Define API function. * tests/test.c (reachable_objs_count_enumerator): Remove function. * tests/test.c (check_heap_stats): Call GC_alloc_lock(); call GC_enumerate_reachable_objects_inner() directly; call GC_alloc_unlock().
* Add API functions to get and set the stack bottom of each threadBrian J. Cardiff2019-05-061-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #277 (bdwgc). This API is useful to support coroutines. * include/gc.h (GC_get_my_stackbottom, GC_set_stackbottom): New API function declaration. * misc.c [!THREADS] (GC_set_stackbottom, GC_get_my_stackbottom): New function definition. * pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS] (GC_set_stackbottom, GC_get_my_stackbottom): Likewise. * win32_threads.c [GC_WIN32_THREADS] (GC_set_stackbottom, GC_get_my_stackbottom): Likewise. * tests/test.c (struct thr_hndl_sb_s): Define. * tests/test.c (set_stackbottom): New function (which calls GC_set_stackbottom). * tests/test.c (run_one_test): Define thr_hndl_sb local variable; call GC_get_my_stackbottom() and set_stackbottom(). * win32_threads.c [GC_WIN32_THREADS && I386] (struct GC_Thread_Rep): Add initial_stack_base field. * win32_threads.c [GC_WIN32_THREADS && I386] (GC_record_stack_base, GC_call_with_gc_active): Set initial_stack_base field. * win32_threads.c [GC_WIN32_THREADS && I386] (GC_push_stack_for): Handle the case when GetThreadContext() might return stale register values, thread stack_base != initial_stack_base but the stack is not inside the TIB stack (use context.Esp but call WARN); add TODO.
* Replace 'stack base' with 'stack bottom' in the documentationIvan Maidanski2019-04-261-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | * README.md (The C Interface to the Allocator): Outline that stack base means its bottom; remove a note that client should set GC_stackbottom on HP PA machines manually. * doc/README.macros (USE_GET_STACKBASE_FOR_MAIN): Rename "stack base" to "stack bottom". * doc/porting.md (Adding Platforms to gcconfig.h): Likewise. * doc/porting.md (Adding Platforms to gcconfig.h): Rename "cool end of the stack" to "cold end of the stack"; refine documentation about STACKBOTTOM. * include/private/gcconfig.h (STACKBOTTOM): Rename "cool end" to "cold end" in comment. * include/gc.h (GC_stackbottom): Likewise. * include/private/gcconfig.h (LINUX_STACKBOTTOM): Rename "stack base" to "stack bottom" in comment. * include/gc.h (GC_stack_base, GC_call_with_stack_base): Likewise. * include/gc.h [GC_THREADS] (GC_register_my_thread): Likewise. * misc.c [!THREADS] (GC_call_with_gc_active): Likewise. * os_dep.c [LINUX_STACKBOTTOM] (GC_linux_main_stack_base): Likewise. * os_dep.c (GC_get_stack_base): Likewise. * pthread_support.c (GC_call_with_gc_active): Likewise. * win32_threads.c (GC_call_with_gc_active): Likewise.
* Refine do_blocking() documentation in gc.hIvan Maidanski2019-04-251-2/+7
| | | | | | | | * include/gc.h (GC_do_blocking): Refine comment (copy part of comment from misc.c, add information that GC should be initialized and the current thread should be registered). * misc.c (GC_do_blocking): Remove title comment (as it duplicates the one in gc.h).
* Enable true incremental collection even if parallel marker is onIvan Maidanski2019-04-171-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #151 (bdwgc). Because of the current limitation of the parallel marker implementation, it is not possible to interrupt the collection when performed by the parallel marker. This change allows to have the true incremental mode at the expense of disabling the parallel marker during most collection phases. By default, the old behavior (a generational collection with the parallel marker enabled) is preserved unless the client sets GC_time_limit to a value other than GC_TIME_UNLIMITED. * alloc.c [(!GC_TIME_LIMIT || CPPCHECK) && PARALLEL_MARK] (GC_time_limit): Set to GC_TIME_UNLIMITED; add comment. * alloc.c [PARALLEL_MARK] (GC_collect_a_little_inner): Temporarily set GC_parallel_mark_disabled to TRUE before GC_mark_some repeated invocation if GC_time_limit is not GC_TIME_UNLIMITED. * alloc.c [PARALLEL_MARK] (GC_stopped_mark): Temporarily set GC_parallel_mark_disabled to TRUE before GC_mark_some repeated invocation if stop_func is not GC_never_stop_func; add verbose logging if parallel marking is disabled temporarily. * doc/README.environment (GC_PAUSE_TIME_TARGET): Update the description (remove the limitation for the case when parallel marking is on). * doc/scale.md (The Parallel Marking Algorithm): Update the documentation regarding incremental mode. * include/gc.h (GC_parallel, GC_enable_incremental): Update the comment (remove the limitation on the incremental mode when parallel marking is on). * include/private/gc_priv.h [PARALLEL_MARK] (GC_parallel_mark_disabled): Declare global variable. * mark.c [PARALLEL_MARK] (GC_parallel_mark_disabled): Define. * mark.c [PARALLEL_MARK] (GC_mark_some_inner): Do not call GC_do_parallel_mark() if GC_parallel_mark_disabled; update comment. * pthread_support.c [PARALLEL_MARK] (GC_thr_init): Do not set GC_time_limit to GC_TIME_UNLIMITED if available_markers_m1 > 0; remove comment. * win32_threads.c [PARALLEL_MARK] (GC_thr_init): Likewise.
* Refine GC_parallel documentation in gc.hIvan Maidanski2019-04-031-5/+6
| | | | | * include/gc.h [GC_THREADS] (GC_parallel): Refine comment about the case when it is non-zero.
* Fix a typo (GC_NPROCS spelling) in a comment in gc.hIvan Maidanski2019-04-031-2/+2
| | | | | * include/gc.h [GC_THREADS] (GC_parallel): Fix a typo in comment ("GC_NPROCS").
* Remove a misleading comment about Solaris in gc.hIvan Maidanski2019-04-031-1/+0
| | | | * include/gc.h: Remove a comment about Solaris.
* Refine GC_INIT documentation about its multiple invocationIvan Maidanski2019-03-251-1/+1
| | | | * include/gc.h (GC_INIT): Add comment about GC_INIT() multiple calls.
* Use KB/MB/GB abbreviations uniformly across entire documentationIvan Maidanski2019-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * README.md (Installation and Portability): Precede MB with a space. * doc/README.amiga (WHATS NEW): Likewise. * doc/debugging.md: Likewise. * README.md (The C Interface to the Allocator): Replace Kbytes to KB. * doc/gc.man: Likewise. * README.Mac: Replace k to KB with a preceding space. * doc/debugging.md: Likewise. * doc/README.amiga: Precede MHz with a space. * doc/debugging.md: Precede KB with a space. * include/gc.h (GC_malloc_ignore_off_page): Replace K to KB with a preceding space in a comment. * tests/test.c (BIG): Likewise. * include/private/gc_priv.h (ALL_INTERIOR_POINTERS, HBLKSIZE, CPP_LOG_HBLKSIZE, LOG_PHT_ENTRIES): Likewise. * include/private/gc_priv.h (LOG_PHT_ENTRIES): Replace M to MB with a preceding space in a comment. * include/private/gc_priv.h (LOG_PHT_ENTRIES): Replace G to GB with a preceding space in a comment. * os_dep.c [GC_USE_MEM_TOP_DOWN && USE_WINALLOC] (GC_mem_top_down): Likewise. * include/gc_priv.h (GC_printf): Replace k to KB with a preceding space in a comment. * include/private/specific.h (quick_thread_id): Likewise. * os_dep.c [MSWINCE] (GC_wince_get_mem): Likewise. * os_dep.c [USE_WINALLOC && !MSWIN_XBOX1 || CYGWIN32] (GC_win32_get_mem): Likewise. * include/private/gcconfig.h [I386 && LINUX] (HEAP_START): Precede GB with a space in a comment.
* Remove documentation specific to particular old BDWGC releasesIvan Maidanski2019-03-221-17/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/README.Mac: Remove mentioning of particular GC versions; adjust the information (if needed) to match the current GC functionality. * doc/README.amiga: Likewise. * doc/README.arm.cross: Likewise. * doc/README.autoconf: Likewise. * doc/README.linux: Likewise. * doc/README.macros (FINALIZE_ON_DEMAND, JAVA_FINALIZATION): Likewise. * doc/README.sgi: Likewise. * doc/README.solaris2 (SOLARIS THREADS): Likewise. * doc/README.symbian: Likewise. * doc/README.win32 (Threads): Likewise. * doc/README.win64: Likewise. * doc/gcdescr.md (Allocation, Thread support, Thread-local allocation): Likewise. * doc/gcinterface.md (GC_INIT): Likewise. * doc/leak.md: Likewise. * doc/porting.md (Additional requirements for a basic port, Thread support): Likewise. * doc/scale.md (Options for enhanced scalability, Performance): Likewise. * doc/simple_example.md (Debugging): Do not mention removed `--enable-full-debug` option of configure. * include/gc.h (GC_parallel, GC_dont_gc, GC_use_entire_heap, GC_set_handle_fork): Remove comment that the behavior has changed in a particular GC version. * include/gc_inline.h (GC_MALLOC_WORDS_KIND): Likewise. * include/gc.h (GC_set_free_space_divisor, GC_warn_proc): Reword comment about ABI incompatible change in some GC version. * include/gc.h (GC_get_heap_usage_safe): Remove comment that the API was introduced in a particular GC version. * include/gc_cpp.h (UseGC): Likewise. * os_dep.c [LINUX_STACKBOTTOM && IA64] (GC_get_register_stack_base): Remove mentioning of a particular GC version (and of an old behavior on an ancient kernel) in a comment. * win32_threads.c [!GC_PTHREADS && !GC_NO_THREADS_DISCOVERY] (GC_DllMain): Likewise. * OS2_MAKEFILE: Likewise.
* Fix 'wrong __data_start/_end pair' error on AndroidIvan Maidanski2019-02-141-27/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (fix of commits b746e637b, 5e73ff184, a25965b5f) Issue #259 (bdwgc). * include/gc.h [(HOST_ANDROID || __ANDROID__) && IGNORE_DYNAMIC_LOADING] (_etext, __data_start, __end__, _end): Do not declare weak symbols. * os_dep.c [SEARCH_FOR_DATA_START && (LINUX || HURD) && HOST_ANDROID] (etext, __dso_handle): Likewise. * include/gc.h [(HOST_ANDROID || __ANDROID__) && IGNORE_DYNAMIC_LOADING] (GC_find_limit): Declare function as public. * include/gc.h [(HOST_ANDROID || __ANDROID__) && IGNORE_DYNAMIC_LOADING] (GC_INIT_CONF_ROOTS): Update comment; do not use _etext, __data_start, __end__, _end symbols; use GC_find_limit(__dso_handle,1) as the end of the added GC data root. * include/private/gc_priv.h [SEARCH_FOR_DATA_START || NETBSD && __ELF__] (GC_find_limit): Change ptr_t type to void*, GC_bool to int. * include/private/gcconfig.h [(SPARC || ALPHA) && FREEBSD] (GC_find_limit): Likewise. * os_dep.c [NEED_FIND_LIMIT || USE_PROC_FOR_LIBRARIES] (GC_find_limit): Likewise. * include/private/gcconfig.h [(SPARC || ALPHA) && FREEBSD] (DATAEND): Cast the result to ptr_t. * include/private/gcconfig.h [AARCH64 && LINUX && HOST_ANDROID] (SEARCH_FOR_DATA_START): Remove outdated comment about __data_start. * os_dep.c [SEARCH_FOR_DATA_START && (LINUX || HURD) && !IGNORE_PROG_DATA_START && HOST_ANDROID && !CPPCHECK] (GC_init_linux_data_start): Do not compare __dso_handle to _etext and do not use __dso_handle as data start. * os_dep.c [SEARCH_FOR_DATA_START] (GC_init_linux_data_start): Cast the result of GC_find_limit() to ptr_t. * os_dep.c [NETBSD && __ELF__] (GC_init_netbsd_elf): Likewise. * os_dep.c [LINUX_STACKBOTTOM && IA64] (GC_get_register_stack_base): Likewise. * os_dep.c [!AMIGA && !HAIKU && !OS2 && !MSWIN32 && !MSWINCE && !CYGWIN32 && !GC_OPENBSD_THREADS && (!GC_SOLARIS_THREADS || _STRICT_STDC)] (GC_get_main_stack_base): Likewise. * os_dep.c [DATASTART_USES_BSDGETDATASTART] (GC_FreeBSDGetDataStart): Likewise.
* Add API for accessing incremental GC time limit with nanosecond precisionIvan Maidanski2019-01-051-4/+28
| | | | | | | | | | | | | | | | | | | | | Issue #258 (bdwgc). This commit only adds the API (GC_set_time_limit_tv, GC_get_time_limit_tv). * alloc.c [!NO_CLOCK] (GC_time_lim_nsec): New STATIC variable. * alloc.c [!NO_CLOCK] (TV_NSEC_LIMIT): New macro. * alloc.c [!NO_CLOCK] (GC_set_time_limit_tv, GC_get_time_limit_tv): New public function definition. * include/gc.h (GC_time_limit, GC_set_time_limit): Update comment. * include/gc.h (GC_timeval_s): New struct definition. * include/gc.h (GC_set_time_limit_tv, GC_get_time_limit_tv): New public function declaration. * include/gc.h [GC_TIME_LIMIT && !CPPCHECK] (GC_INIT_CONF_TIME_LIMIT): Refine comment. * tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK && !NO_CLOCK] (main): Add UNTESTED() for GC_get_time_limit_tv and GC_set_time_limit_tv.
* Refine HIDE_POINTER documentation for the case of the leak-finding modeIvan Maidanski2018-11-291-0/+1
| | | | | * include/gc.h (GC_HIDE_POINTER, GC_REVEAL_POINTER): Refine comment (warn about usage in the leak-finding mode).
* Workaround '*_stubborn function is never used' cppcheck warningsIvan Maidanski2018-11-231-5/+1
| | | | | | | | | | * dbg_mlc.c (GC_debug_malloc_stubborn, GC_debug_change_stubborn): Do not define if CPPCHECK. * mallocx.c (GC_malloc_stubborn, GC_end_stubborn_change): Likewise. * include/gc.h (GC_debug_change_stubborn): Always mark as GC_ATTR_DEPRECATED (regardless of CPPCHECK). * tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK] (main): Remove UNTESTED(GC_debug_change_stubborn).
* Workaround 'local address assignment to a global variable' CSA warningIvan Maidanski2018-11-131-1/+6
| | | | | | | | | | | | | | | * include/gc.h [(!__GNUC__ || __INTEL_COMPILER) && LINT2] (GC_reachable_here): Transform ptr in the same way as COVERT_DATAFLOW() does. * mach_dep.c (GC_with_callee_saves_pushed): Transform the argument of GC_noop1() by COVERT_DATAFLOW(). * misc.c [!ASM_CLEAR_CODE] (GC_clear_stack_inner): Likewise. * misc.c (GC_call_with_stack_base, GC_call_with_gc_active): Likewise. * pthread_support.c (GC_call_with_gc_active): Likewise. * win32_threads.c (GC_call_with_gc_active): Likewise. * misc.c (GC_call_with_gc_active): Transform &stacksect by COVERT_DATAFLOW() when storing to GC_stackbottom. * pthread_support.c (GC_call_with_gc_active): Likewise.
* Replace some FIXME items with TODO onesIvan Maidanski2018-08-311-1/+1
| | | | | | | | | | | | | | | | | | (code refactoring) * alloc.c (GC_maybe_gc, GC_collect_a_little_inner, GC_finish_collection): Replace FIXME item with TODO one. * gcj_mlc.c (maybe_finalize): Likewise. * include/gc.h [!GC_DEBUG || !__GNUC__] (GC_PTR_ADD): Likewise. * include/private/gcconfig.h [X86_64 && LINUX && __GLIBC__ && !__UCLIBC__] (GETCONTEXT_FPU_EXCMASK_BUG): Likewise. * mach_dep.c (GC_with_callee_saves_pushed): Likewise. * mark_rts.c (GC_push_current_stack): Likewise. * misc.c [MSWIN32 || MSWINCE] (WRITE): Likewise. * os_dep.c [ECOS] (ecos_gc_memory): Likewise. * os_dep.c (GC_get_stack_base, GC_page_was_ever_dirty): Likewise. * reclaim.c (GC_reclaim_clear): Likewise. * include/private/gcconfig.h [OPENBSD && m68k]: Remove FIXME item.
* Fix indentation of 'define GC_DATAEND' in gc.hIvan Maidanski2018-08-171-1/+1
| | | | | | | (fix of commit 4e24d219d) * include/gc.h [__CYGWIN__ && !__x86_64__] (GC_DATAEND): Fix indentation.
* New API to turn on manual VDB at runtimeIvan Maidanski2018-08-151-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Manual VDB is now enabled by GC_set_manual_vdb_allowed(1) if called before entering the GC incremental mode. * alloc.c (GC_allocobj): Expand TRUE_INCREMENTAL macro. * darwin_stop_world.c [MPROTECT_VDB] (GC_stop_world, GC_start_world): Use GC_auto_incremental instead of GC_incremental. * mark.c (alloc_mark_stack): Likewise. * mark.c [PROC_VDB] (GC_push_all): Likewise. * mark.c [!NEED_FIXUP_POINTER && THREADS && MPROTECT_VDB] (GC_push_all_stack): Likewise. * pthread_support.c [CAN_HANDLE_FORK && GC_DARWIN_THREADS && MPROTECT_VDB] (GC_atfork_prepare): Likewise. * win32_threads.c [MPROTECT_VDB && !CYGWIN32] (GC_register_my_thread_inner): Likewise. * win32_threads.c [MPROTECT_VDB] (UNPROTECT_THREAD): Likewise. * doc/gcdescr.md (Generational Collection and Dirty Bits): Update documentation for the manual VDB. * include/gc.h (GC_end_stubborn_change): Update comment. * mark_rts.c (GC_push_all_stack_partially_eager): Likewise. * include/gc.h (GC_set_manual_vdb_allowed, GC_get_manual_vdb_allowed): New public function. * include/private/gc_priv.h (GC_grungy_pages, GC_dirty_pages): Define for all VDB modes. * include/private/gc_priv.h (GC_auto_incremental, GC_manual_vdb): Define. * include/private/gc_priv.h [!GC_DISABLE_INCREMENTAL] (GC_dirty): Use GC_manual_vdb instead of GC_incremental. * include/private/gcconfig.h (GWW_VDB, MPROTECT_VDB, PCR_VDB): Do not undefine if MANUAL_VDB. * mallocx.c (GC_generic_malloc_many): Always allocate a single object (and call GC_dirty_inner/REACHABLE_AFTER_DIRTY) if GC_manual_vdb. * misc.c [!CAN_HANDLE_FORK && DARWIN && MPROTECT_VDB && !THREADS && !SMALL_CONFIG] (GC_set_handle_fork): Do not ABORT if GC_manual_vdb. * misc.c [!SMALL_CONFIG] (manual_vdb_allowed): New static variable. * misc.c [!SMALL_CONFIG] (GC_set_manual_vdb_allowed, GC_get_manual_vdb_allowed): Implement. * misc.c [!CHECKSUMS && !SMALL_CONFIG] (GC_init, GC_enable_incremental): Set GC_manual_vdb and GC_incremental to true if manual_vdb_allowed; do not call GC_dirty_init if manual_vdb_allowed. * os_dep.c: Update comment about MANUAL_VDB. * os_dep.c [MANUAL_VDB] (GC_dirty_init, async_set_pht_entry_from_index): Remove. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_manual_vdb): Define global variable. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_dirty_inner): Define regardless of the VDB mode; add FIXME. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_read_dirty, GC_page_was_dirty, GC_remove_protection): Implement for the case of GC_manual_vdb is true; do not depend on MANUAL_VDB. * tests/disclaim_test.c [TEST_MANUAL_VDB] (main): Call GC_set_manual_vdb_allowed(1) before GC_INIT. * tests/staticrootslib.c [TEST_MANUAL_VDB] (libsrl_init): Likewise. * tests/test_cpp.cc [TEST_MANUAL_VDB] (main): Likewise. * tests/test.c (INIT_MANUAL_VDB_ALLOWED): New macro. * tests/test.c (GC_COND_INIT): Invoke INIT_MANUAL_VDB_ALLOWED (before GC_OPT_INIT). * tests/test.c [!SMALL_CONFIG] (main): Call GC_get_manual_vdb_allowed.
* Fix the build for N3DSJosh Peterson2018-08-011-1/+1
| | | | | | | | | | | | | | | | | (part of commit 0f9ef2d from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * include/gc.h [GC_BUILD && NN_PLATFORM_CTR] (GC_on_thread_event_proc): Define type. * include/private/gc_locks.h [NN_PLATFORM_CTR || NINTENDO_SWITCH] (GC_lock, GC_unlock): Declare function. * include/private/gc_locks.h [NN_PLATFORM_CTR || NINTENDO_SWITCH] (UNCOND_LOCK, UNCOND_UNLOCK): Define macro. * include/private/gc_priv.h [THREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2]: Do not include gc_atomic_ops.h if NN_PLATFORM_CTR. * pthread_support.c [USE_SPIN_LOCK || !NO_PTHREAD_TRYLOCK] (GC_pause): Call GC_noop1 instead of AO_compiler_barrier unless AO_CLEAR defined.
* Export stop/start_world_external only for multi-threaded buildsIvan Maidanski2018-07-281-3/+4
| | | | | | | | | | | | | | | | | | | | | | (fix of commit bb91f03) Issue #173 (bdwgc). Also, update GC_world_stopped value in GC_stop_world_external and GC_start_world_external. * include/gc.h (GC_stop_world_external, GC_start_world_external): Do not declare unless GC_THREADS; add comment. * misc.c (GC_stop_world_external, GC_start_world_external): Do not define unless THREADS; add assertion that GC is initialized. * misc.c [THREADS && THREAD_LOCAL_ALLOC] (GC_stop_world_external): Set GC_world_stopped to true after STOP_WORLD; add assertion that the world is not stopped. * misc.c [THREADS && THREAD_LOCAL_ALLOC] (GC_start_world_external): Set GC_world_stopped to false before START_WORLD; add assertion that the world is stopped. * tests/test.c [GC_PTHREADS && CPPCHECK] (main): Add UNTESTED for GC_stop_world_external and GC_start_world_external.
* New API to stop and start the GC world externallyJonas Echterhoff2018-07-271-0/+3
| | | | | | | | | | (part of commits 39e14be, 05e3377 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * include/gc.h (GC_stop_world_external, GC_start_world_external): Declare new API function. * misc.c (GC_stop_world_external, GC_start_world_external): Implement.
* Update copyright information in the documentation and gc.h filesIvan Maidanski2018-07-221-0/+1
| | | | | | | | | | * AUTHORS: Add info about the maintainer. * README.QUICK: Update header copyright (add Ivan Maidanski). * include/gc.h: Likewise. * README.md (Copyright & Warranty): Update copyright (add the missing copyrights from the source code files). * doc/gc.man (.TH): Update modification date. * doc/gc.man (.SH AUTHOR): Update; add reference to AUTHORS file.
* New public API (PTR_STORE_AND_DIRTY) to simplify store-and-dirty operationIvan Maidanski2018-07-011-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | * cord/cordbscs.c (CORD_cat_char_star, CORD_cat, CORD_from_fn_inner, CORD_substr_closure): Replace the last store to the heap-allocated object, GC_END_STUBBORN_CHANGE() and GC_reachable_here() with GC_PTR_STORE_AND_DIRTY() call. * cord/tests/de.c (prune_map, add_map, replace_line): Likewise. * include/gc_inline.h (GC_CONS): Likewise. * tests/disclaim_test.c (pair_dct, pair_new): Likewise. * tests/test.c [!VERY_SMALL_CONFIG] (cons): Likewise. * tests/test.c (small_cons, small_cons_uncollectable, reverse_test_inner, mktree): Likewise. * tests/test.c [GC_GCJ_SUPPORT] (gcj_cons): Likewise. * tests/test.c [GC_PTHREADS && !SMALL_CONFIG && !GC_DEBUG] (alloc8bytes): Likewise. * tests/test.c [!NO_TYPED_TEST] (typed_test): Likewise. * tests/test_cpp.cc (main): Likewise. * dbg_mlc.c (GC_debug_ptr_store_and_dirty): Implement. * mallocx.c (GC_ptr_store_and_dirty): Likewise. * include/gc.h (GC_PTR_STORE_AND_DIRTY): New public macro. * include/gc.h (GC_debug_ptr_store_and_dirty, GC_ptr_store_and_dirty): Declare new public API function; add comment. * tests/test.c (reverse_test_inner): Remove tmp local variable. * tests/test.c (mktree): Remove right_left local variable.
* Eliminate 'language extension used' Clang warning in gc.hIvan Maidanski2018-06-301-4/+4
| | | | | * include/gc.h [GC_DEBUG && __GNUC__] (GC_PTR_ADD, GC_PRE_INCR, GC_POST_INCR, GC_POST_DECR): Replace typeof to __typeof__.
* Same type casts for GC_PTR_STORE arguments regardless of GC_DEBUGIvan Maidanski2018-06-291-2/+3
| | | | | | * include/gc.h [GC_DEBUG] (GC_PTR_STORE): Cast p and q to void*. * include/gc.h [!GC_DEBUG] (GC_PTR_STORE): Cast p to void**, cast q to void*.
* Add GC_reachable_here after GC_dirty in GC sourceIvan Maidanski2018-06-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (fix of commits 73d30d2b4, e5fb574cf) * README.md (Incremental Collection): Add note about bugs caused by a missing GC_reachable_here call. * doc/gcdescr.md (Generational Collection): Mention GC_reachable_here for MANUAL_VDB mode. * finalize.c (GC_register_disappearing_link_inner, GC_register_finalizer_inner): Move GC_dirty(new_dl) call to be before unlocking (so that to ensure no collection occurs between initialization of new_dl and GC_dirty() call). * finalize.c (GC_finalize): Call GC_dirty() immediately after updating GC_fnlz_roots.fo_head (instead of setting needs_barrier) if GC_object_finalized_proc is set. * gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Call REACHABLE_AFTER_DIRTY(ptr_to_struct_containing_descr) after GC_dirty(op). * include/gc.h (GC_end_stubborn_change): Mention GC_reachable_here in comment. * include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call GC_reachable_here(next) after GC_end_stubborn_change(my_fl); remove GC_end_stubborn_change() call when a non-pointer is stored to my_fl; remove GC_end_stubborn_change() after GC_generic_malloc_many() call. * include/gc_inline.h (GC_CONS): Call GC_reachable_here for the stored pointers after GC_end_stubborn_change call. * include/private/gc_priv.h (REACHABLE_AFTER_DIRTY): New macro. * mallocx.c [MANUAL_VDB] (GC_generic_malloc_many): If GC_is_heap_ptr(result) then call GC_dirty(result) and REACHABLE_AFTER_DIRTY(op) after storing op pointer. * typd_mlc.c (GC_make_sequence_descriptor): Call REACHABLE_AFTER_DIRTY for the stored pointers after GC_dirty(result). * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Call REACHABLE_AFTER_DIRTY(d) after GC_dirty(op). * win32_threads.c (GC_CreateThread, GC_beginthreadex, GC_pthread_create): Call REACHABLE_AFTER_DIRTY for the stored pointer after GC_dirty.
* Do not include windows.h when compiling gc_cpp.ccIvan Maidanski2018-06-201-1/+2
| | | | | | | | | | | | (code refactoring) * gc_cpp.cc (GC_DONT_INCL_WINDOWS_H): Define macro before include gc.h. * tests/test_cpp.cc (GC_DONT_INCL_WINDOWS_H): Likewise. * include/gc.h [GC_WIN32_THREADS && (!GC_PTHREADS || GC_BUILD || GC_WINDOWS_H_INCLUDED) && (!GC_NO_THREAD_DECLS || GC_BUILD)]: If GC_DONT_INCL_WINDOWS_H then do not include process.h, windows.h, and do not declare GC_CreateThread, GC_ExitThread, GC_DllMain, GC_beginthreadex, GC_endthreadex.
* Never return null pointer by C++ operator new (gc_cpp)Ivan Maidanski2018-06-011-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now, in case of the allocation failure, new and new[] operators throw bad_alloc (or abort the application if an ancient compiler is used). * gc_cpp.cc (GC_NEW_DELETE_NEED_THROW): Remove. * gc_cpp.cc (GC_DECL_NEW_THROW, GC_DECL_DELETE_THROW): Move macro definition to gc_cpp.h. * gc_cpp.cc [GC_NEW_DELETE_NEED_THROW]: Do not include "new" header. * gc_cpp.cc [!_MSC_VER] (operator new): Call GC_OP_NEW_OOM_CHECK() for the allocation result. * gc_cpp.cc [!_MSC_VER && GC_OPERATOR_NEW_ARRAY && !CPPCHECK] (operator new[]): Likewise. * include/gc.h (GC_abort_on_oom): Declare new API function. * include/gc_cpp.h [!GC_NEW_DELETE_THROW_NOT_NEEDED && (GC_GNUC_PREREQ(4,2) || __BORLANDC__>=0x0550 || _MSC_VER>1020 || __WATCOMC__>=1050)] (GC_NEW_DELETE_NEED_THROW): Define macro. * include/gc_cpp.h [GC_NEW_DELETE_NEED_THROW]: Include "new" header. * include/gc_cpp.h (GC_OP_NEW_OOM_CHECK): New internal macro (throws bad_alloc or cals GC_abort_on_oom). * include/gc_cpp.h (gc::new(size_t), gc::new(size_t,GCPlacement), new): Add GC_DECL_NEW_THROW; call GC_OP_NEW_OOM_CHECK() for the allocation result. * include/gc_cpp.h [GC_OPERATOR_NEW_ARRAY] (gc::new[](size_t), gc::new[](size_t,GCPlacement, new[]): Likewise. * misc.c (GC_abort_on_oom): Implement function. * tests/test.c [CPPCHECK] (main): Call UNTESTED(GC_abort_on_oom).
* Remove stubborn objects allocation code completelyIvan Maidanski2018-05-151-33/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) * README.md (Incremental/Generational Collection): Remove information about stubborn objects; add information about GC_end_stubborn_change usage. * alloc.c [STUBBORN_ALLOC] (GC_finish_collection): Do not call GC_clean_changing_list. * checksums.c (NSUMS, GC_check_dirty): Remove comment related to stubborn objects. * checksums.c [STUBBORN_ALLOC] (GC_on_free_list): Remove. * doc/README.macros (STUBBORN_ALLOC): Likewise. * include/private/gc_priv.h [STUBBORN_ALLOC] (GC_sobjfreelist, GC_arrays._sobjfreelist, GC_changed_pages, GC_arrays._changed_pages, GC_prev_changed_pages, GC_arrays._prev_changed_pages): Likewise. * include/private/gc_priv.h (GC_read_changed, GC_page_was_changed, GC_clean_changing_list, GC_stubborn_init): Likewise. * tests/test.c (stubborn_count): Likewise. * checksums.c (GC_n_changed_errors): Likewise. * checksums.c [STUBBORN_ALLOC] (GC_update_check_page, GC_check_dirty): Do not update GC_n_changed_errors value. * checksums.c (GC_check_dirty): Do not check/print GC_n_changed_errors value. * configure.ac (checksums): Update help message (remove information about stubborn objects). * dbg_mlc.c (GC_print_obj, GC_debug_end_stubborn_change, GC_debug_realloc, GC_debug_generic_or_special_malloc): Do not handle STUBBORN object kind specially. * mallocx.c (GC_generic_or_special_malloc, GC_realloc): Likewise. * mark.c [!GC_DISABLE_INCREMENTAL] (GC_push_next_marked_dirty): Likewise. * dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_malloc_stubborn): Redirect to GC_debug_malloc; remove GC_ATTR_MALLOC. * dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_change_stubborn): Change to no-op. * doc/README.amiga (WHATS NEW): Do not reference GC_malloc_stubborn. * doc/README.macros (CHECKSUMS): Update (remove information about stubborn objects). * doc/gcdescr.md (Allocation, Generational Collection and Dirty Bits): Likewise. * doc/gcinterface.md (C/C++ Interface): Likewise. * doc/leak.md (Using the Garbage Collector as Leak Detector): Likewise. * doc/gcdescr.md (Generational Collection and Dirty Bits): Add information about MANUAL_VDB. * include/gc.h (GC_malloc, GC_free, GC_realloc): Update comment (remove information about stubborn objects). * malloc.c (GC_generic_malloc_inner): Likewise. * tests/test.c (reverse_test_inner): Likewise. * include/gc.h (GC_malloc_stubborn, GC_debug_malloc_stubborn): Add GC_ATTR_DEPRECATED; remove GC_ATTR_MALLOC and GC_ATTR_ALLOC_SIZE. * include/gc.h (GC_MALLOC_STUBBORN, GC_NEW_STUBBORN): Redirect to normal GC_MALLOC/NEW; add comment that stubborn objects allocation is deprecated. * include/gc.h [GC_DEBUG] (GC_CHANGE_STUBBORN): Redirect to GC_change_stubborn (not GC_debug_change_stubborn). * include/gc.h (GC_change_stubborn): Add GC_ATTR_DEPRECATED. * include/gc.h [!CPPCHECK] (GC_debug_change_stubborn): Likewise. * include/gc.h (GC_change_stubborn, GC_debug_change_stubborn): Remove GC_ATTR_NONNULL. * include/gc.h (GC_end_stubborn_change): Add comment related to usage when the library is built with MANUAL_VDB defined. * include/gc.h [_AMIGA && !GC_AMIGA_MAKINGLIB] (GC_malloc_stubborn): Remove macro. * include/private/gc_priv.h (STUBBORN_ALLOC): Remove comment. * include/private/gc_priv.h (STUBBORN): Replace with GC_N_KINDS_INITIAL_VALUE definition. * mark.c (GC_obj_kinds): Remove initialization for STUBBORN_ALLOC element. * mark.c (GC_N_KINDS_INITIAL_VALUE): Move to gc_priv.h. * mark.c (GC_n_rescuing_pages): Define only if GC_DISABLE_INCREMENTAL. * mark.c [STUBBORN_ALLOC] (GC_initiate_gc): Do not call GC_read_changed. * misc.c [STUBBORN_ALLOC] (GC_init): Do not call GC_stubborn_init. * stubborn.c (GC_malloc_stubborn): Remove GC_ATTR_MALLOC. * tests/test.c [!VERY_SMALL_CONFIG] (cons): Replace GC_MALLOC_STUBBORN with GC_MALLOC call; update collectable_count instead of stubborn_count. * tests/test.c (check_heap_stats): Do not print stubborn_count value.
* Expose API to control rate and max prior attempts of collect_a_littleJonathan Chambers2018-04-241-0/+10
| | | | | | | | | | | | | | | | | | (a cherry-pick of commit d897344 from 'unity-release-7_4-incremental') * alloc.c (GC_RATE): Update comment. * alloc.c (GC_rate): New STATIC variable (initialized to GC_RATE). * alloc.c (GC_set_rate, GC_get_rate, GC_set_max_prior_attempts, GC_get_max_prior_attempts): New API function definition. * alloc.c (max_prior_attempts): New static variable (initialized to MAX_PRIOR_ATTEMPTS). * alloc.c (GC_collect_a_little_inner): Replace GC_RATE to GC_rate; declare max_deficit local variable and compute GC_rate*n once (per a function call); replace MAX_PRIOR_ATTEMPTS to max_prior_attempts. * include/gc.h (GC_set_rate, GC_get_rate, GC_set_max_prior_attempts, GC_get_max_prior_attempts): New API function declaration. * tests/test.c [GC_PTHREADS] (main): Call GC_set_rate, GC_get_rate, GC_set_max_prior_attempts, GC_get_max_prior_attempts.
* Expose API to control the minimum bytes allocated before a GC occursJonathan Chambers2018-04-231-0/+6
| | | | | | | | | | | | | | (a cherry-pick of commit 4c0e58d from 'unity-release-7_4-incremental') * alloc.c (min_bytes_allocd_minimum): New static variable. * alloc.c (GC_set_min_bytes_allocd, GC_get_min_bytes_allocd): New API function definition (to set/get min_bytes_allocd_minimum). * alloc.c (min_bytes_allocd): Return min_bytes_allocd_minimum if result is less than min_bytes_allocd_minimum. * include/gc.h (GC_set_min_bytes_allocd, GC_get_min_bytes_allocd): New API function declaration. * tests/test.c [GC_PTHREADS] (main): Call GC_set_min_bytes_allocd() and GC_get_min_bytes_allocd().
* Avoid potential data race during GC_dump executionIvan Maidanski2018-04-101-2/+7
| | | | | | | | | | | | | | * include/gc.h (GC_dump): Separate declaration from GC_dump_named; add comment that it acquires the lock. * include/gc.h (GC_dump_named): Refine comment (add note that the lock is not acquired by this function). * include/private/gc_priv.h (GC_dump): Remove commented out declaration. * include/private/gc_priv.h [!NO_DEBUGGING] (COND_DUMP): Call GC_dump_named(NULL) instead of GC_dump(). * misc.c (GC_init) [GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED]: Call COND_DUMP while holding the allocation lock. * misc.c [!NO_DEBUGGING] (GC_dump): Place LOCK/UNLOCK around GC_dump_named() call.
* Avoid potential race when accessing size_map tableHans Boehm2018-02-261-1/+3
| | | | | | | | | | | | | | | | | | There is again a data race between GC_extend_size_map and GC_size_map[] readers, though it is again not likely to fail in practice. It is feasible to just move all of the GC_size_map accesses under the lock, and this does not look to incur a substantial penalty. * gcj_mlc.c (GC_gcj_malloc, GC_gcj_malloc_ignore_off_page): Move lg=GC_size_map[lb] to be right after LOCK() instead of preceding it. * malloc.c (GC_malloc_kind_global, GC_generic_malloc_uncollectable): Likewise. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Likewise. * include/gc.h (GC_get_size_map_at): Update comment to note that the client should use synchronization when calling the function. * include/private/gc_priv.h (_GC_arrays._size_map): Add comment about synchronization.
* New API function (get_size_map_at) to get content of size_map tableIvan Maidanski2018-02-141-0/+6
| | | | | | | | * include/gc.h (GC_get_size_map_at): Declare public function. * misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (GC_get_size_map_at): Implement function * tests/test.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (check_heap_stats): Add dummy testing of GC_get_size_map_at.
* Put variable/function declarations into extern 'C' in headersJay Krell2018-02-081-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #201 (bdwgc). Extern "C" should be only around declarations, not includes. In particular, do not include 3rd-party headers (as well as our own files as they could include others). * include/gc.h [GC_PTHREADS]: Do not wrap include gc_pthread_redirects.h into extern "C" block. * include/gc_disclaim.h: Wrap variable and function declarations (but not included headers). * include/gc_inline.h: Likewise. * include/gc_pthread_redirects.h [!GC_PTHREAD_REDIRECTS_ONLY]: Likewise. * include/private/darwin_semaphore.h: Likewise. * include/private/darwin_stop_world.h: Likewise. * include/private/dbg_mlc.h: Likewise. * include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC]: Likewise. * include/private/gc_hdrs.h: Likewise. * include/private/gc_locks.h [THREADS]: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * include/private/pthread_support.h [GC_PTHREADS && !GC_WIN32_THREADS]: Likewise. * include/private/specific.h: Likewise. * include/private/thread_local_alloc.h [THREAD_LOCAL_ALLOC]: Likewise.
* Avoid SIGSEGV during GC_INIT on some Android devicesJonathan Chambers2018-02-011-1/+5
| | | | | | | | | | (part of commit 9379c66 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * include/gc.h [(HOST_ANDROID || __ANDROID__) && !GC_NOT_DLL] (GC_INIT_CONF_ROOTS): Define to empty unless IGNORE_DYNAMIC_LOADING; add comment.
* Use HOST_ANDROID define instead of PLATFORM_ANDROIDZoltan Varga2018-01-241-1/+1
| | | | | | | | | | | | | | | | (a cherry-pick of commit 5d819c8 from 'mono_libgc') * doc/README.macros (PLATFORM_ANDROID): Rename to HOST_ANDROID. * dyn_load.c: Rename PLATFORM_ANDROID to HOST_ANDROID. * include/gc.h: Likewise. * include/gc_config_macros.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * os_dep.c: Likewise. * pthread_support.c: Likewise. * tests/initsecondarythread.c: Likewise. * tests/test.c: Likewise. * tools/threadlibs.c: Likewise.