Ivan Maidanski [Wed, 16 May 2018 08:49:33 +0000 (11:49 +0300)]
Remove code duplication in gcj_malloc and malloc_explicitly_typed
(code refactoring)
* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc): Store
ptr_to_struct_containing_descr in a single place of code.
* typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Store d (to
the object) in a single place of code.
Ivan Maidanski [Wed, 16 May 2018 08:33:02 +0000 (11:33 +0300)]
Add assertions to finalize and threads support for MANUAL_VDB needs
(code refactoring)
* finalize.c (GC_unregister_disappearing_link_inner,
GC_enqueue_all_finalizers): Remove redundant comment about held lock.
* finalize.c (GC_unregister_disappearing_link_inner,
GC_move_disappearing_link_inner, ITERATE_DL_HASHTBL_BEGIN,
GC_finalize, GC_enqueue_all_finalizers): Add assertion that the
allocation lock is held.
* pthread_support.c (first_thread): Refine comment.
* pthread_support.c (GC_new_thread): Add assertion that when the first
thread is added then GC_threads[hv] is null (thus "next" field is set
to null).
* win32_threads.c (GC_new_thread): Likewise.
* pthread_support.c (GC_delete_thread, GC_delete_gc_thread): Add
assertion that "next" field of the first thread is not modified.
* win32_threads.c (GC_delete_gc_thread_no_free, GC_delete_thread):
Likewise.
* win32_threads.c (GC_delete_thread): Use EXPECT() when checking that
p is not the first thread.
* win32_threads.c [GC_PTHREADS] (GC_pthread_start_inner): Add assertion
that the current thread is not the first one (thus "status" field of
the first thread is not modified).
Ivan Maidanski [Tue, 8 May 2018 19:21:59 +0000 (22:21 +0300)]
Fix tests for GC compiled with MANUAL_VDB
* tests/disclaim_test.c (pair_dct, pair_new): Call
GC_end_stubborn_change(p) after writing the last pointer field of p.
* tests/test.c [!DBG_HDRS_ALL] (run_one_test): Likewise.
* tests/test.c (small_cons, small_cons_uncollectable, mktree,
typed_test): Call GC_END_STUBBORN_CHANGE(r) after writing the last
pointer field of r.
* tests/test.c [GC_GCJ_SUPPORT] (gcj_cons): Likewise.
* tests/test.c [!SMALL_CONFIG && !GC_DEBUG] (alloc8bytes): Likewise.
Ivan Maidanski [Tue, 8 May 2018 18:36:41 +0000 (21:36 +0300)]
Keep pointer to the start of previous entry in remove_specific_after_fork
(code refactoring)
* specific.c [USE_CUSTOM_SPECIFIC] (GC_remove_specific_after_fork):
Replace tse** link local variable with tse* prev one; replace *link
with either key->hash[hash_val].p or prev->next.
Ivan Maidanski [Tue, 8 May 2018 17:17:48 +0000 (20:17 +0300)]
Fix assertion violation and partial overlapping in remove_roots_subregion
(fix of commit 38d194a)
Issue #218 (bdwgc).
* mark_rts.c [USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion):
Update comment; add assertion that b and e pointers are word-aligned;
handle also cases of partial overlapping with the existing roots;
call GC_rebuild_root_index() only when needed; update existing root
instead of removing old and adding new one (where possible); move
newly static added root to precede dynamic ones (if any); process all
static roots even if an intersection is already found.
Ivan Maidanski [Tue, 8 May 2018 07:33:48 +0000 (10:33 +0300)]
Do not merge dynamic root with the existing static one in add_roots_inner
* mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_add_roots_inner):
If the root already exists and it is static then set the found root
to static (if not yet); if dynamic root with the same r_start but
different r_tmp is found then add a new root starting from r_end of
the found root (instead of extending the found root).
Ivan Maidanski [Mon, 7 May 2018 21:47:48 +0000 (00:47 +0300)]
Fix potential null dereference in GC_CONS
* include/gc_inline.h (GC_CONS): Remove granules local variable; replace
GC_FAST_MALLOC_GRANS(GC_malloc_kind) to GC_MALLOC_WORDS_KIND(n=2);
store second element only if result is non-null; store first element
along with second one.
Ivan Maidanski [Mon, 7 May 2018 08:05:15 +0000 (11:05 +0300)]
Fix infinite restarting of mark_some when a static root disappeared (Linux)
Issue #218 (bdwgc).
* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Call
GC_remove_roots_subregion for each region which has prot starting
with "---"; add comment.
* include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES]
(GC_remove_roots_subregion): Declare function.
* mark_rts.c[USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion):
Implement.
Ivan Maidanski [Mon, 7 May 2018 05:20:57 +0000 (08:20 +0300)]
Turn on incremental collection in gctest also if DEFAULT_VDB or MANUAL_VDB
* tests/test.c [DEFAULT_VDB] (TEST_DEFAULT_VDB): Define (before include
gc.h).
* tests/test.c [!GC_DISABLE_INCREMENTAL] (main): Call
GC_enable_incremental also if MANUAL_VDB or TEST_DEFAULT_VDB; print
message about emulating dirty bits with mprotect only if MPROTECT_VDB.
Ivan Maidanski [Fri, 4 May 2018 20:44:57 +0000 (23:44 +0300)]
Remove unnecessary argument casts in add_roots_inner calls
(code refactoring)
* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Remove
unnecessary casting of arguments in GC_add_roots_inner call.
* dyn_load.c [PCR && !DYNAMIC_LOADING && !MSWIN32]
(GC_register_dynamic_libraries): Likewise.
* dyn_load.c [HAVE_DL_ITERATE_PHDR]
(GC_register_dynamic_libraries_dl_iterate_phdr): Change type of
datastart and dataend local variables from char* to ptr_t.
Ivan Maidanski [Fri, 4 May 2018 20:28:22 +0000 (23:28 +0300)]
Do not rebuild_root_index unless remove_root_at_pos is called
* mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_remove_tmp_roots,
GC_remove_roots_inner): Call GC_rebuild_root_index() only if
GC_remove_root_at_pos() is called at least once.
Naoyuki Sawa [Wed, 2 May 2018 04:10:23 +0000 (13:10 +0900)]
Fix register_dynamic_libraries on Windows 10
Issue #219 (bdwgc).
In the past (Windows XP, Windows 7, and older Windows 10), VirtualQuery
always returned PAGE_READWRITE for the data section.
In the April 2018 Update of Windows 10, it seems that PAGE_WRITECOPY
is returned sometimes (thus causing GC_register_dynamic_libraries not
to call GC_cond_add_roots for the section).
* dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]
(GC_register_dynamic_libraries): Call GC_cond_add_roots()
also for PAGE_EXECUTE_WRITECOPY and PAGE_WRITECOPY pages.
Ivan Maidanski [Thu, 26 Apr 2018 07:54:52 +0000 (10:54 +0300)]
Avoid multiple 'getcontext failed' warnings if getcontext is broken
Issue #133 (bdwgc).
* mach_dep.c [!HAVE_PUSH_REGS && UNIX_LIKE && !NO_GETCONTEXT]
(GC_with_callee_saves_pushed): Define getcontext_works static variable;
do not call getcontext() if getcontext_works < 0; add comment; set
getcontext_works to 1 or -1 (depending whether getcontext is working)
if getcontext_works is zero.
* misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT]
(callee_saves_pushed_dummy_fn): New static function (empty).
* misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT] (GC_init): Call
GC_with_callee_saves_pushed(callee_saves_pushed_dummy_fn) if GC_dont_gc
or GC_dont_precollect (otherwise it is called by GC_gcollect_inner);
add comment.
Expose API to control rate and max prior attempts of collect_a_little
(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 occurs
(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().
Ivan Maidanski [Sat, 14 Apr 2018 06:26:03 +0000 (09:26 +0300)]
Enable memory unmapping by default
Issue #152 (bdwgc).
* CMakeLists.txt (enable_munmap): New OPTION (on by default).
* CMakeLists.txt [enable_munmap] (USE_MMAP, USE_MUNMAP): Define macro.
* CMakeLists.txt [enable_checksums && enable_munmap): Issue MESSAGE
that CHECKSUMS is not compatible with USE_MUNMAP.
* configure.ac (AC_ARG_ENABLE(munmap)): Update the help message.
* configure.ac [$enable_munmap=""]: Treat as enable_munmap="yes".
* configure.ac [$MUNMAP_THRESHOLD=""]: Treat as MUNMAP_THRESHOLD="yes".
* doc/README.win32 (GNU Tools): Note about "--disable-munmap" option.
* doc/debugging.md (Unexpectedly Large Heap): Remove advice about
"--enable-munmap" option.
Ivan Maidanski [Fri, 13 Apr 2018 15:08:40 +0000 (18:08 +0300)]
Turn on atomic uncollectable functionality by default (CMake)
* CMakeLists.txt (enable_atomic_uncollectable): New OPTION (on by
default).
* CMakeLists.txt [enable_atomic_uncollectable]
(GC_ATOMIC_UNCOLLECTABLE): Define macro.
Ivan Maidanski [Wed, 11 Apr 2018 06:19:09 +0000 (09:19 +0300)]
Avoid 'Unexpected heap growth' in 64-bit multi-threaded gctest if n_tests=1
* tests/test.c [!VERY_SMALL_CONFIG && CPP_WORDSZ==64] (check_heap_stats):
Increase max_heap_sz initial value by ~8.7% (so that the ratio of
max_heap_sz initial values between 32-bit and 64-bit targets
is the roughly same as exists for VERY_SMALL_CONFIG).
Ivan Maidanski [Tue, 10 Apr 2018 21:26:09 +0000 (00:26 +0300)]
Allow subthreadcreate_test to be compiled with zero NTHREADS
* tests/subthread_create.c [AO_HAVE_fetch_and_add1] (main): Skip the
test (except for printing the number of created and ended threads) if
NTHREADS is 0.
Ivan Maidanski [Tue, 10 Apr 2018 08:48:51 +0000 (11:48 +0300)]
Avoid potential data race during GC_dump execution
* 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.
Ivan Maidanski [Tue, 10 Apr 2018 08:07:08 +0000 (11:07 +0300)]
Avoid potential data race during apply_to_each_object(reset_back_edge)
* backgraph.c [MAKE_BACK_GRAPH] (GC_print_back_graph_stats): Add
assertion that the allocation lock is held; store GC_deepest_obj to
obj local variable (while holding the lock); place UNLOCK/LOCK around
GC_print_heap_obj() call; pass obj to GC_print_heap_obj().
* finalize.c [MAKE_BACK_GRAPH] (GC_notify_or_invoke_finalizers): Remove
UNLOCK/LOCK around GC_print_back_graph_stats() call.
Ivan Maidanski [Fri, 6 Apr 2018 16:45:23 +0000 (19:45 +0300)]
Add assertions about held lock for apply_to_each_object callers
(code refactoring of commit 5e6cc59b0)
* alloc.c (GC_stopped_mark, GC_finish_collection): Add assertion (at
the beginning of the function) that the allocation lock is held.
* backgraph.c [MAKE_BACK_GRAPH] (GC_build_back_graph,
GC_traverse_back_graph): Likewise.
* mark.c (GC_initiate_gc): Likewise.
* alloc.c (GC_stopped_mark): Remove comment about the held lock
(because there is an assertion about it).
Ivan Maidanski [Fri, 6 Apr 2018 16:07:50 +0000 (19:07 +0300)]
Fix null dereference in print_callers on backtrace_symbols failure
* os_dep.c [NEED_CALLINFO && GC_HAVE_BUILTIN_BACKTRACE
&& !GC_BACKTRACE_SYMBOLS_BROKEN] (GC_print_callers): If sym_name is
NULL then print info[i].ci_pc to buf and set name to buf (instead of
to sym_name[0]).
* os_dep.c [NEED_CALLINFO && GC_HAVE_BUILTIN_BACKTRACE
&& !GC_BACKTRACE_SYMBOLS_BROKEN] (GC_print_callers): Do not call
free(sym_name) if sym_name is NULL.
Ivan Maidanski [Fri, 6 Apr 2018 06:32:12 +0000 (09:32 +0300)]
Fix null pointer dereference in get_private_path_and_zero_file (Symbian)
* extra/symbian.cpp (GC_get_private_path_and_zero_file): Do not call
memcpy() if allocation of copyChar is failed.
* os_dep.c [MMAP_SUPPORTED && !USE_MMAP_ANON] (zero_fd): Initialize
global variable to -1 (instead of 0).
* os_dep.c [MMAP_SUPPORTED && !USE_MMAP_ANON && SYMBIAN]
(GC_unix_mmap_get_mem): Do not call open() and free() if path is NULL.
Ivan Maidanski [Thu, 5 Apr 2018 21:42:29 +0000 (00:42 +0300)]
Eliminate 'there is pointer arithmetic with NULL' cppcheck warning
* extra/msvc_dbg.c (GetDescriptionFromStack): Compare size to 0 instead
of comparing description to NULL; mark format argument as used.
* extra/msvc_dbg.c (backtrace_symbols): Do not call
GetDescriptionFromStack if symbols (description) is NULL but size is
non-zero.
Ivan Maidanski [Wed, 4 Apr 2018 22:40:58 +0000 (01:40 +0300)]
Do not resend the restart signal to threads that are already restarted
(fix of commit 3498427)
Issue #181 (bdwgc).
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_count):
Update comment.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_suspend_handler_inner): Add assertion that my_stop_count is even.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_suspend_handler_inner): Mask lowest bit of last_stop_count when
checking for the duplicate signal.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_suspend_handler_inner): If GC_retry_signals then
set the lowest bit of last_stop_count (by AO_store_release) after the
second sem_post() call; add comment.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_suspend_all): Add comment for last_stop_count check.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world):
Increment GC_stop_count by 2 (instead of by one).
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_restart_all): If GC_retry_signals and last_stop_count has the same
value as GC_stop_count+1 then do not increment n_live_threads and do
not send the restart signal to the thread.
Ivan Maidanski [Mon, 2 Apr 2018 23:21:00 +0000 (02:21 +0300)]
Replace GC_NO_RETRY_SIGNALS environment variable with GC_RETRY_SIGNALS=0
* doc/README.environment (GC_NO_RETRY_SIGNALS): Remove.
* doc/README.environment (GC_RETRY_SIGNALS): Document "0" value.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_init):
Declare str local variable; do not check GC_NO_RETRY_SIGNALS
environment variable; refine comment; set GC_retry_signals to false
if the value of GC_RETRY_SIGNALS environment variable is "0".
Ivan Maidanski [Mon, 2 Apr 2018 22:23:01 +0000 (01:23 +0300)]
Handle pthread restart signals loss if retry_signals
Issue #181 (bdwgc).
* doc/README.environment (GC_RETRY_SIGNALS, GC_NO_RETRY_SIGNALS):
Update documentation (support of restart signals loss, try signals
if compiled with ASan/MSan/TSan).
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_retry_signals): Set true also if ADDRESS_SANITIZER or
MEMORY_SANITIZER.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& !GC_NETBSD_THREADS_WORKAROUND] (GC_suspend_handler_inner): Call
sem_post(GC_suspend_ack_sem) at the function end if GC_retry_signals;
update comment about the RESTART signal loss.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& !GC_OPENBSD_UTHREADS] (GC_start_world): Call
resend_lost_signals(GC_restart_all) and update n_live_threads value.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& !GC_OPENBSD_UTHREADS && !GC_NETBSD_THREADS_WORKAROUND]
(GC_start_world): Call suspend_restart_barrier() if GC_retry_signals.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_init):
Update the message logged if GC_retry_signals.
Ivan Maidanski [Mon, 2 Apr 2018 06:22:51 +0000 (09:22 +0300)]
Define static resend_lost_signals(), restart_all() in pthread_stop_world
(code refactoring)
Issue #181 (bdwgc).
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ASSERTIONS]
(suspend_restart_barrier): Check that the count of GC_suspend_ack_sem
is zero at the end of the function.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(resend_lost_signals): New static function (the code is moved from
GC_stop_world).
* pthread_stop_world.c [DEBUG_THREADS] (GC_suspend_all): Move the
assignment of GC_stopping_thread and GC_stopping_pid to GC_stop_world.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world):
Call resend_lost_signals() if GC_retry_signals.
* pthread_stop_world.c [!NACL] (GC_restart_all): New static function
(the code is moved from GC_start_world).
* pthread_stop_world.c [!NACL] (GC_start_world): Declare n_live_threads
local variable; call GC_restart_all.
Ivan Maidanski [Fri, 30 Mar 2018 17:41:41 +0000 (20:41 +0300)]
Unblock only GC signals in suspend_handler (TSan)
Issue #181 (bdwgc).
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& THREAD_SANITIZER] (GC_suspend_handler_inner): Replace
pthread_sigmask(SIG_SETMASK) to pthread_sigmask(SIG_UNBLOCK) with the
set with GC_sig_suspend and GC_sig_thr_restart signals.
Ivan Maidanski [Thu, 29 Mar 2018 08:50:36 +0000 (11:50 +0300)]
Add assertions about held lock when accessing all_bottom_indices
(code refactoring)
* headers.c (GC_all_bottom_indices, GC_all_bottom_indices_end): Add
comment that the variable should be accessed with the allocation lock
held.
* headers.c (get_index, GC_apply_to_all_blocks, GC_next_used_block,
GC_prev_block): Add assertion (at the beginning of the function) that
the allocation lock is held.
Ivan Maidanski [Thu, 29 Mar 2018 08:40:44 +0000 (11:40 +0300)]
Update top_index entry pointer only when the entry is constructed fully
(code refactoring)
* headers.c [HASH_TL] (get_index): Remove old local variable (use pi
instead).
* headers.c (get_index): Eliminate code duplication; use EXPECT() to
check the result of GC_scratch_alloc().
* headers.c (get_index): Update GC_top_index[i] value only at the end
of the function.
Ivan Maidanski [Thu, 29 Mar 2018 06:54:39 +0000 (09:54 +0300)]
Minimize delay between sem_post and sigsuspend in suspend_handler if TSan
(fix of commit af409e4)
Issue #181 (bdwgc).
This change is to do as less as possible (even in case of TSan usage)
between the sem_post and sigsuspend calls in GC_suspend_handler_inner
(to match the relevant comment after sigsuspend call).
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& THREAD_SANITIZER] (GC_suspend_handler_inner): Move sigemptyset()
and pthread_sigmask() calls to be just before sem_post() call.
Ivan Maidanski [Fri, 23 Mar 2018 18:29:28 +0000 (21:29 +0300)]
Avoid potential race between malloc_kind and mark_thread_local_fls_for
Issue #214 (bdwgc).
* include/gc_inline.h (GC_FAST_M_AO_STORE): New internal macro.
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Use GC_FAST_M_AO_STORE.
* thread_local_alloc.c [THREAD_LOCAL_ALLOC]
(GC_mark_thread_local_fls_for): Use AO_load to get _freelists[i][j]
value; add comment.
* thread_local_alloc.c [THREAD_LOCAL_ALLOC && GC_GCJ_SUPPORT]
(GC_mark_thread_local_fls_for): Use AO_load to get gcj_freelists[j].
Ivan Maidanski [Fri, 23 Mar 2018 08:13:23 +0000 (11:13 +0300)]
Fix thread_suspend fail for threads registered from key destructor (OS X)
Issue #213 (bdwgc).
* pthread_support.c [GC_DARWIN_THREADS] (GC_register_my_thread):
Reinitialize stop_info.mach_thread if the thread is registered from
the client thread key destructor; add comment.
Ivan Maidanski [Thu, 22 Mar 2018 21:41:13 +0000 (00:41 +0300)]
Match GC_FAST_MALLOC_GRANS formal and actual arguments where possible
(code refactoring)
* include/gc_inline.h (GC_MALLOC_WORDS_KIND): Rename k argument to kind.
* include/gc_inline.h (GC_MALLOC_WORDS_KIND, GC_CONS): Rename grans
local variable to granules.
* thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_malloc_kind): Rename
knd to kind.
Ivan Maidanski [Thu, 22 Mar 2018 07:37:00 +0000 (10:37 +0300)]
Check consistency of descr, adjust, clear arguments of GC_new_kind
Issue #83 (bdgwc).
* misc.c (GC_new_kind_inner): Improve assertion about clear argument
to check for the consistency of descr and adjust arguments (in case of
clear is false).
Ivan Maidanski [Wed, 21 Mar 2018 07:26:10 +0000 (10:26 +0300)]
Fix ASSERT_CANCEL_DISABLED violation in try_to_collect_inner
(fix of commit b04b346)
Issue #182 (bdwgc).
* finalize.c (GC_ON_GROW_LOG_SIZE_MIN): Define to CPP_LOG_HBLKSIZE
value by default.
* finalize.c (GC_grow_table): Surround GC_try_to_collect_inner call
with DISABLE/RESTORE_CANCEL.
Ivan Maidanski [Tue, 20 Mar 2018 21:58:24 +0000 (00:58 +0300)]
Fix unbounded heap growth in case of intensive disappearing links usage
Issue #182 (bdwgc).
* finalize.c (GC_ON_GROW_LOG_SIZE_MIN): New macro.
* finalize.c (GC_grow_table): Rename size_ptr to log_size_ptr in
comment; add entries_ptr argument; add comment; call if log_old_size is
GC_ON_GROW_LOG_SIZE_MIN or bigger then call GC_try_to_collect_inner
and, then, return from the function if the number of entries is less
than 75% of the table capacity.
* finalize.c (GC_register_disappearing_link_inner): Pass
dl_hashtbl->entries pointer to GC_grow_table.
* finalize.c (GC_register_finalizer_inner): Pass GC_fo_entries pointer
to GC_grow_table.