summaryrefslogtreecommitdiff
path: root/typd_mlc.c
Commit message (Collapse)AuthorAgeFilesLines
* Make comparisons to the lowest heap boundary strictIvan Maidanski2023-05-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | * alloc.c (GC_expand_hp_inner): Subtract sizeof(word) from new_limit (for the case when comparing to GC_least_plausible_heap_addr). * backgraph.c [MAKE_BACK_GRAPH] (add_back_edges): Compare current to GC_least_real_heap_addr and GC_greatest_real_heap_addr (instead of GC_least_plausible_heap_addr and GC_greatest_plausible_heap_addr). * malloc.c [GC_ASSERTIONS] (GC_malloc_kind_global): Likewise. * include/gc/gc_mark.h (GC_MARK_AND_PUSH): Replace greater-or-equal to strictly greater when comparing to GC_least_plausible_heap_addr. * include/private/gc_pmark.h (GC_PUSH_ONE_STACK, GC_PUSH_ONE_HEAP): Likewise. * include/private/gc_priv.h [MAKE_BACK_GRAPH] (SET_REAL_HEAP_BOUNDS, GC_least_real_heap_addr, GC_greatest_real_heap_addr): Define. * mark.c (GC_mark_from, GC_push_all): Add dummy "| GC_DS_LENGTH" when storing length to mse_descr.w. * mark.c (GC_mark_from): Replace greater-or-equal to strictly greater when comparing to least_ha variable. * typd_mlc.c (GC_typed_mark_proc): Likewise. * mark.c [GC_DS_TAGS>ALIGNMENT-1] (GC_push_all): Simplify code to round up length.
* New API for more optimal usage of GC_calloc_explicitly_typedIvan Maidanski2023-04-261-15/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the client needs to allocate many typed object arrays of same layout and amount of elements, then "calloc" descriptor could be created once (by GC_calloc_prepare_explicitly_typed) followed by multiple allocations (by GC_calloc_do_explicitly_typed) referring to the same descriptor. * include/gc/gc_typed.h (GC_CALLOC_TYPED_DESCR_WORDS): New macro. * include/gc/gc_typed.h (GC_calloc_typed_descr_s): New struct type. * include/gc/gc_typed.h (GC_calloc_prepare_explicitly_typed, GC_calloc_do_explicitly_typed): New function declaration. * tests/gctest.c [!NO_TYPED_TEST && !GC_DEBUG] (typed_test): Define ctd_l local variable; call GC_calloc_prepare_explicitly_typed() before loop; call GC_calloc_do_explicitly_typed() instead of GC_CALLOC_EXPLICITLY_TYPED(1001). * typd_mlc.c (GC_calloc_typed_descr_s.alloc_lb): Change type from size_t to word. * typd_mlc.c (GC_calloc_typed_descr_s.descr_type): Change type from int to signed_word. * typd_mlc.c (GC_calloc_prepare_explicitly_typed, GC_calloc_do_explicitly_typed): Change from STATIC to GC_API; add ctd_sz argument; check ctd_sz in assertion; add casts for alloc_lb field. * typd_mlc.c (GC_calloc_prepare_explicitly_typed): Add static assertion about size of GC_calloc_typed_descr_s and GC_CALLOC_TYPED_DESCR_WORDS; change return type from void to it. * typd_mlc.c (GC_calloc_explicitly_typed): Pass sizeof(ctd) to GC_calloc_prepare_explicitly_typed(), GC_calloc_do_explicitly_typed().
* Decouple descriptor compute from object alloc in calloc_explicitly_typedIvan Maidanski2023-04-261-36/+70
| | | | | | | | | | | | | | | | | | | (refactoring) This is a preparation for providing ability to the client to compute (and allocate) the internal descriptor of GC_calloc_explicitly_typed once (for the given object layout and elements count) and perform the typed allocation multiple times. * typd_mlc.c (GC_calloc_typed_descr_s): New struct type. * typd_mlc.c (GC_calloc_prepare_explicitly_typed, GC_calloc_do_explicitly_typed): New static function (move part of code from GC_calloc_explicitly_typed); use GC_calloc_typed_descr_s to pass leaf, simple_d, complex_d, alloc_lb, descr_type values between two functions; set and use alloc_lb instead of updating lb local variable. * typd_mlc.c (GC_calloc_explicitly_typed): Use GC_calloc_prepare_explicitly_typed and GC_calloc_do_explicitly_typed. * typd_mlc.c (GC_array_mark_proc): Update comment.
* Invoke GC_oom_fn if GC_make_array_descriptor failed because of no memoryIvan Maidanski2023-04-251-1/+1
| | | | | * typd_mlc.c (GC_calloc_explicitly_typed): If descr_type is NO_MEM then return the result of GC_get_oom_fn()(lb).
* Do not add extra byte to large ignore-off-page objectsIvan Maidanski2023-04-121-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For ignore-off-page objects the client should guarantee the pointer within the first heap block of the object, thus no need to add an extra byte for such objects if the object size of at least one heap block. * allchblk.c (setup_header): Add assertion that byte_sz is not less than ALIGNMENT. * allchblk.c [ALIGNMENT>GC_DS_TAGS] (setup_header): Modify descr local variable to make it zero if IGNORE_OFF_PAGE flag is set and kind is NORMAL (and object size is not less than HBLKSIZE); add comment. * mallocx.c [ALIGNMENT>GC_DS_TAGS] (GC_realloc): Likewise. * include/gc/gc.h (GC_all_interior_pointers): Update comment. * include/private/gc_priv.h [MAX_EXTRA_BYTES==0] (ADD_EXTRA_BYTES): Define as no-op. * malloc.c (GC_generic_malloc_inner): Define lb_adjusted local variable; pass lb_adjusted to GC_alloc_large_and_clear(). * malloc.c [MAX_EXTRA_BYTES>0] (GC_generic_malloc_inner): Set lb_adjusted to lb if IGNORE_OFF_PAGE flag is set and lb is not less than HBLKSIZE. * malloc.c [MAX_EXTRA_BYTES>0] (GC_generic_malloc_aligned): Set lb_rounded without EXTRA_BYTES added (and compute lg based on lb_rounded) if IGNORE_OFF_PAGE is set and lb is not less than HBLKSIZE. * mallocx.c (GC_realloc): Define ok local variable. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Remove lb_adjusted local variable; call GC_malloc_explicitly_typed() if lb is smaller than HBLKSIZE-sizeof(word), otherwise pass lb plus sizeof(word) (instead of lb plus TYPD_EXTRA_BYTES) to GC_generic_malloc_aligned; add comment.
* Refine comparisons to GC_greatest_plausible_heap_addrIvan Maidanski2023-04-091-1/+1
| | | | | | | | | | | | | | | | | | GC_greatest_plausible_heap_addr should always be greater (strictly) than any address of a heap object. * backgraph.c (add_back_edges): Check that pointer is strictly less than GC_greatest_plausible_heap_addr (instead of less or equal). * dbg_mlc.c [KEEP_BACK_PTRS && ALIGNMENT==1] (GC_get_back_ptr_info): Likewise. * include/gc/gc_mark.h (GC_MARK_AND_PUSH): Likewise. * malloc.c (GC_malloc_kind_global): Likewise. * typd_mlc.c (GC_typed_mark_proc): Likewise. * include/gc/gc_mark.h (GC_greatest_plausible_heap_addr): Refine comment (that any object address is strictly less). * mark.c (GC_mark_from): Allow descr in assertions to be equal to GC_greatest_plausible_heap_addr-GC_least_plausible_heap_addr; reformat comment.
* Avoid code duplication in IGNORE_OFF_PAGE-specific malloc functionsIvan Maidanski2023-03-241-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * alloc.c: Update comment regarding GC_generic_malloc_inner usage. * alloc.c (GC_collect_or_expand): Replace ignore_off_page argument to flags (check IGNORE_OFF_PAGE bit only in it); update comment. * alloc.c (GC_allocobj): Pass 0 as flags to GC_collect_or_expand. * dbg_mlc.c (GC_debug_generic_malloc, GC_debug_generic_or_special_malloc): Rename knd argument to k. * mallocx.c (GC_generic_or_special_malloc): Likewise. * dbg_mlc.c (GC_debug_generic_malloc): Use GC_generic_malloc_aligned() instead of GC_generic_malloc(). * dbg_mlc.c (GC_debug_generic_malloc_inner): Add flags argument. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_core_gcj_malloc): Likewise. * include/private/gc_priv.h (C_generic_malloc_aligned, GC_generic_malloc_inner): Likewise. * include/private/gc_priv.h [THREAD_LOCAL_ALLOC && GC_GCJ_SUPPORT] (GC_core_gcj_malloc): Likewise. * include/private/gc_priv.h [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner): Likewise. * malloc.c (GC_generic_malloc_inner, GC_generic_malloc_aligned): Likewise. * dbg_mlc.c (GC_debug_generic_malloc_inner): Use GC_generic_malloc_inner() instead of GC_generic_malloc_inner_ignore_off_page(). * dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner_ignore_off_page): Remove GC_INNER function. * include/private/gc_priv.h [DBG_HDRS_ALL || GC_GCJ_SUPPORT || !GC_NO_FINALIZATION] (GC_generic_malloc_inner_ignore_off_page): Likewise. * include/private/gc_priv.h [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner_ignore_off_page): Likewise. * malloc.c [DBG_HDRS_ALL || GC_GCJ_SUPPORT || !GC_NO_FINALIZATION] (GC_generic_malloc_inner_ignore_off_page): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT && !THREAD_LOCAL_ALLOC] (GC_gcj_malloc): Define as STATIC GC_core_gcj_malloc. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_core_gcj_malloc): Reformat comment; pass flags to GC_generic_malloc_inner(). * gcj_mlc.c [GC_GCJ_SUPPORT && !THREAD_LOCAL_ALLOC] (GC_gcj_malloc): Redirect to GC_core_gcj_malloc() passing 0 to flags argument. * thread_local_alloc.c [THREAD_LOCAL_ALLOC && GC_GCJ_SUPPORT] (GC_gcj_malloc): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc_ignore_off_page): Redirect to GC_core_gcj_malloc() passing IGNORE_OFF_PAGE. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_debug_gcj_malloc): Pass 0 as flags to GC_generic_malloc_inner(). * include/private/gc_priv.h (GC_generic_malloc_inner): Update comment. * mallocx.c (GC_generic_malloc_many): Likewise. * include/private/gc_priv.h (GC_collect_or_expand): Replace GC_bool ignore_off_page argument to unsigned flags. * include/private/gc_priv.h (GC_INTERNAL_MALLOC, GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE): Specify macro arguments. * include/private/gc_priv.h (GC_INTERNAL_MALLOC): Pass 0 as flags argument to GC_[debug_]generic_malloc_inner(). * include/private/gc_priv.h (GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE): Pass IGNORE_OFF_PAGE to GC_[debug_]generic_malloc_inner(). * malloc.c (GC_alloc_large): Pass flags (instead of flags!=0) to GC_collect_or_expand(). * malloc.c (GC_generic_malloc_inner_small): New STATIC function (move most of code from GC_generic_malloc_inner). * malloc.c (GC_generic_malloc_inner): Move comment to gc_priv.h; call GC_generic_malloc_inner_small(). * malloc.c (GC_generic_malloc_aligned): Call GC_generic_malloc_inner_small() instead of GC_generic_malloc_inner(); pass flags (instead of 0) to GC_alloc_large(); do not cast result of GC_alloc_large() to ptr_t. * malloc.c (GC_generic_malloc): Pass 0 as flags to GC_generic_malloc_aligned(). * malloc.c (GC_memalign): Likewise. * malloc.c (GC_malloc_kind_global, GC_generic_malloc_uncollectable): Call GC_generic_malloc_aligned() instead of GC_generic_malloc(). * mallocx.c (GC_generic_malloc_many): Likewise. * malloc.c (free_internal): Rename knd local variable to k. * mallocx.c (GC_generic_malloc_ignore_off_page, GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page): Redirect to GC_generic_malloc_aligned() passing IGNORE_OFF_PAGE. * typd_mlc.c (GC_generic_malloc_ignore_off_page): Likewise. * tests/gctest.c (run_one_test): Call GC_generic_malloc_ignore_off_page() (with size larger than HBLKSIZE); increment collectable_count.
* Redirect GC_malloc_explicitly_typed_ignore_off_page for small objectsIvan Maidanski2023-01-301-39/+15
| | | | | | | | | | | | | | (refactoring) * typd_mlc.c (GC_malloc_explicitly_typed): Do not write lb increased by TYPD_EXTRA_BYTES back to lb argument. * typd_mlc.c (GENERAL_MALLOC_IOP): Remove. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Replace lg local variable to nwords; store sum of lb and TYPD_EXTRA_BYTES to lb_adjusted (new local variable); if the object is small (after addition of TYPD_EXTRA_BYTES) then redirect to GC_malloc_explicitly_typed(); replace GENERAL_MALLOC_IOP() call to GC_clear_stack(GC_generic_malloc_ignore_off_page()) one.
* Remove unused DCL_LOCK_STATEIvan Maidanski2023-01-301-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * alloc.c (GC_set_disable_automatic_collection, GC_set_stop_func, GC_get_disable_automatic_collection, GC_get_stop_func, GC_set_start_callback, GC_get_start_callback, GC_set_on_collection_event, GC_get_on_collection_event, GC_collect_a_little, GC_try_to_collect_general, GC_expand_hp): Remove DCL_LOCK_STATE. * alloc.c [!GC_DISABLE_INCREMENTAL] (GC_start_incremental_collection): Likewise. * dbg_mlc.c (GC_generate_random_backtrace, store_debug_info, GC_debug_register_displacement): Likewise. * dyn_load.c [DARWIN_DEBUG && !NO_DEBUGGING] (GC_dyld_image_add, GC_dyld_image_remove): Likewise. * finalize.c (GC_register_disappearing_link_inner, GC_unregister_disappearing_link, GC_complete_ongoing_collection, GC_set_toggleref_func, GC_get_toggleref_func, GC_toggleref_add, GC_set_await_finalize_proc, GC_get_await_finalize_proc, GC_unregister_long_link, GC_move_disappearing_link, GC_move_long_link, GC_register_finalizer_inner, GC_finalize, GC_invoke_finalizers, GC_notify_or_invoke_finalizers): Likewise. * fnlz_mlc.c (GC_init_finalized_malloc): Likewise. * gc_dlopen.c [!USE_PROC_FOR_LIBRARIES] (disable_gc_for_dlopen): Likewise. * gcj_mlc.c (GC_init_gcj_malloc, maybe_finalize, GC_core_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * malloc.c (GC_alloc_large, GC_generic_malloc_inner, GC_generic_malloc_aligned, GC_malloc_kind_global, GC_generic_malloc_uncollectable, GC_free): Likewise. * mallocx.c (GC_realloc, GC_generic_malloc_ignore_off_page, GC_generic_malloc_many): Likewise. * mark.c (GC_print_trace): Likewise. * mark_rts.c (GC_add_roots, GC_clear_roots, GC_remove_roots): Likewise. * misc.c (GC_get_heap_usage_safe, GC_get_heap_usage_safe, GC_is_init_called, GC_init, GC_enable_incremental, GC_start_mark_threads, GC_set_warn_proc, GC_get_warn_proc, GC_set_abort_func, GC_get_abort_func, GC_enable, GC_disable, GC_new_free_list, GC_new_kind, GC_new_proc, GC_call_with_alloc_lock, GC_dump, GC_get_memory_use, GC_alloc_lock, GC_set_on_thread_event, GC_get_on_thread_event, GC_set_oom_fn, GC_get_oom_fn, GC_set_on_heap_resize, GC_get_on_heap_resize, GC_set_finalizer_notifier, GC_get_finalizer_notifier, GC_set_all_interior_pointers): Likewise. * obj_map.c (GC_register_displacement): Likewise. * os_dep.c (GC_get_stack_base, GC_print_callers): Likewise. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread, GC_resume_thread, GC_is_thread_suspended): Likewise. * pthread_support.c (GC_is_thread_tsd_valid, GC_thread_is_registered, GC_register_altstack, GC_wait_for_gc_completion, GC_init_parallel, GC_do_blocking_inner, GC_suspend_self_blocked, GC_get_my_stackbottom, GC_call_with_gc_active, GC_unregister_my_thread, GC_pthread_cancel, GC_pthread_exit, GC_allow_register_threads, GC_register_my_thread, GC_thread_exit_proc, GC_pthread_join, GC_pthread_detach, GC_start_rtn_prepare_thread): Likewise. * ptr_chck.c (GC_set_same_obj_print_proc, GC_get_same_obj_print_proc, GC_set_is_valid_displacement_print_proc, GC_set_is_visible_print_proc, GC_get_is_valid_displacement_print_proc, GC_get_is_visible_print_proc): Likewise. * reclaim.c (GC_print_all_errors): Likewise. * typd_mlc.c (GC_add_ext_descriptor, GC_make_descriptor, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise. * alloc.c (GC_max_retries): Change type from GC_word to word. * include/private/gc_locks.h: Remove DCL_LOCK_STATE from comment, * include/private/gc_locks.h (DCL_LOCK_STATE): Do not define.
* Eliminate 'assigned value is garbage or undefined' CSA warningIvan Maidanski2022-12-051-2/+3
| | | | | | | | (fix of commit 1f45c9a9f) * typd_mlc.c (GC_make_array_descriptor): Do not dereference pcomplex_d after GC_make_array_descriptor() recursive call unless result is COMPLEX.
* Include gc_inline.h from gc_priv.hIvan Maidanski2022-10-111-1/+0
| | | | | | | | | | | | | | | | | | | (refactoring) Also, use EXPECT(FALSE) for GC_ASSERT. * extra/gc.c: Do not include gc_inline.h. * fnlz_mlc.c [ENABLE_DISCLAIM]: Likewise. * include/private/thread_local_alloc.h [THREAD_LOCAL_ALLOC]: Likewise. * malloc.c: Likewise. * mallocx.c: Likewise. * pthread_support.c: Likewise. * reclaim.c: Likewise. * typd_mlc.c: Likewise. * include/private/gc_priv.h: Move GC_ASSERT definition upper; include gc_inline.h (after GC_ASSERT); define PTRFREE and NORMAL to GC_I_PTRFREE and GC_I_NORMAL, respectively. * include/private/gc_priv.h [GC_ASSERTIONS] (GC_ASSERT): Use EXPECT().
* Use cast to void instead of the attribute to indicate unused argumentsIvan Maidanski2022-09-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * CMakeLists.txt [BORLAND] (add_compile_options): Remove "/w-par"; reorder options. * CMakeLists.txt [!BORLAND && MSVC] (add_compile_options): Remove "/wd4100"; update comment. * NT_MAKEFILE (.c.obj): Likewise. * allchblk.c [!NO_DEBUGGING || GC_ASSERTIONS] (add_hb_sz): Use UNUSED_ARG() instead of GC_ATTR_UNUSED. * allchblk.c [USE_MUNMAP] (GC_adjust_num_unmapped): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (pop_in_progress, reset_back_edge, update_max_height): Likewise. * checksums.c [CHECKSUMS] (GC_add_block): Likewise. * darwin_stop_world.c (GC_stack_range_for): Likewise. * dbg_mlc.c (GC_store_debug_info_inner, GC_debug_change_stubborn, GC_check_heap_block): Likewise. * finalize.c [!GC_NO_FINALIZATION] (GC_null_finalize_mark_proc): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_fake_mark_proc): Likewise. * mallocx.c [!CPPCHECK] (GC_change_stubborn): Likewise. * mark.c (GC_noop6, clear_marks_for_block): Likewise. * mark.c [WRAP_MARK_SOME && (MSWIN32 || MSWINCE) && __GNUC__] (mark_ex_handler): Likewise. * mark.c [GC_DISABLE_INCREMENTAL] (GC_push_conditional): Likewise. * mark_rts.c (GC_push_current_stack, GC_push_roots): Likewise. * misc.c (GC_default_oom_fn, GC_set_handle_fork): Likewise. * misc.c [THREADS && !SIGNAL_BASED_STOP_WORLD] (GC_set_suspend_signal, GC_set_thr_restart_signal): Likewise. * misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT] (callee_saves_pushed_dummy_fn): Likewise. * misc.c [!THREADS] (GC_do_blocking_inner): Likewise. * misc.c [!PARALLEL_MARK] (GC_set_markers_count): Likewise. * os_dep.c [OPENBSD] (GC_fault_handler_openbsd): Likewise. * os_dep.c [NEED_FIND_LIMIT || WRAP_MARK_SOME && !MSWIN32 && !MSWINCE || USE_PROC_FOR_LIBRARIES && THREADS] (GC_fault_handler): Likewise. * os_dep.c [!HAVE_GET_STACK_BASE && !NEED_FIND_LIMIT] (GC_get_stack_base): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise_state, catch_exception_raise_state_identity, catch_exception_raise): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS && !SUSPEND_HANDLER_NO_CONTEXT] (GC_suspend_sigaction): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS] (GC_suspend_handler_inner): Likewise. * pthread_support.c (GC_do_blocking_inner): Likewise. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): Likewise. * tests/gctest.c [!DBG_HDRS_ALL] (fail_proc1): Likewise. * tests/gctest.c [(MSWIN32 && !__MINGW32__ || MSWINCE) && !NO_WINMAIN_ENTRY] (WinMain): Likewise. * tests/gctest.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK && RTEMS] (Init): Likewise. * tests/gctest.c [GC_WIN32_THREADS && !GC_PTHREADS] (thr_run_one_test): Likewise. * tests/gctest.c [MSWINCE] (thr_window): Likewise. * tests/gctest.c [GC_PTHREADS] (thr_run_one_test): Likewise. * typd_mlc.c (GC_array_mark_proc): Likewise. * win32_threads.c (GC_register_altstack, GC_do_blocking_inner): Likewise. * win32_threads.c [!GC_PTHREADS && !GC_NO_THREADS_DISCOVERY] (GC_DllMain): Likewise. * cord/cordxtra.c (CORD_ATTR_UNUSED): Remove. * include/private/gc_priv.h [!GC_ATTR_UNUSED] (GC_ATTR_UNUSED): Likewise. * cord/cordxtra.c (CORD_nul_func): Cast unused argument to void instead of using CORD_ATTR_UNUSED. * cord/cordxtra.c [!GC_NO_FINALIZATION] (CORD_lf_close_proc): Likewise. * include/private/gc_priv.h [!UNUSED_ARG] (UNUSED_ARG): Define macro.
* Reduce lock scope in GC_calloc_explicitly_typedIvan Maidanski2022-06-141-9/+9
| | | | | | | | | (fix of commit 8fcba0985) Issue #449 (bdwgc). * typd_mlc.c (GC_calloc_explicitly_typed): If descr_type is LEAF then acquire the allocation lock just before writing to *lp; update comment.
* Fix race between calloc_explicitly_typed/push_complex_descriptor with lockIvan Maidanski2022-06-141-20/+21
| | | | | | | | | | | | | | | | | | | | | | | | | (fix of commits 4e020ef3c, 1e6c80be3) Issue #449 (bdwgc). Hold the allocation lock while writing a complex descriptor to the object to ensure that the descriptor is seen by GC_array_mark_proc as expected. It should be possible to avoid locking by using the atomic operations (with the release barrier in GC_calloc_explicitly_typed) but this would need the acquire barrier in GC_array_mark_proc and its callee (doing without the acquire barrier is tricky as GC_mark_some might be invoked with the world running). * typd_mlc.c [AO_HAVE_store] (GC_calloc_explicitly_typed): Do not use AO_store operations. * typd_mlc.c (GC_calloc_explicitly_typed): Remove volatile for lp local variable; add comment; replace set_obj_descr() calls with direct write to ((word*)op)[nwords-1]; wrap write to *lp and writing to ((word*)op)[nwords-1] into LOCK/UNLOCK. * typd_mlc.c (get_complex_descr): Remove TODO item (but not GC_ATTR_NO_SANITIZE_THREAD attribute).
* Assert that size of element of a typed object is non-zeroIvan Maidanski2022-06-141-1/+6
| | | | | | | | | | (refactoring) * typd_mlc.c (LeafDescriptor.size): Refine comment. * typd_mlc.c (GC_make_leaf_descriptor, GC_make_array_descriptor): Add assertion that size argument is non-zero. * typd_mlc.c (GC_push_complex_descriptor): Add assertion that sz local variable is non-zero (at least if nelements is non-zero).
* Ensure typed objects descriptor is never located in the first wordIvan Maidanski2022-06-141-1/+4
| | | | | | | | | | | | | Free objects are linked in the collector through the first word in the object. This commit prevents placing type descriptor to the first word of the allocated object by ensuring that the size of typed objects (requested by a client) is non-zero. * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page): If lb is zero, then assume lb is 1 (byte). * typd_mlc.c (GC_calloc_explicitly_typed): If lb or n is zero, then assume that lb*n is 1.
* Use consistent variables naming in typd_mlc.cIvan Maidanski2022-06-121-97/+93
| | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * typd_mlc.c (GC_double_descr, GC_make_leaf_descriptor, GC_make_array_descriptor): Rename descriptor argument to d; update comment. * typd_mlc.c (GC_make_descriptor): Rename result local variable to d. * typd_mlc.c (set_complex_descr): Rename to set_obj_descr. * typd_mlc.c (GC_make_array_descriptor): Rename simple_d argument to psimple_d; rename complex_d argument to pcomplex_d; rename leaf argument to pleaf; add comment that no overflow should occur when computing *psimple_d. * typd_mlc.c (GC_calloc_explicitly_typed): Rename simple_descr local variable to simple_d; rename complex_descr local variable to complex_d. * typd_mlc.c (GC_descr_obj_size, GC_push_complex_descriptor): Rename d argument to complex_d; update comment. * typd_mlc.c (GC_push_complex_descriptor): Rename descr local variables to d and element_descr (depending on type); move declaration of d and element_descr local variables to the beginning of function; specify that msp is unlikely to be null. * typd_mlc.c (GC_array_mark_proc): Rename descr local variable to complex_d.
* Group functions related to GC_calloc_explicitly_typedIvan Maidanski2022-06-111-304/+302
| | | | | | | | | | | | | | | | | | (refactoring) * typd_mlc.c (LeafDescriptor, ComplexArrayDescriptor, SequenceDescriptor, complex_descriptor, GC_make_leaf_descriptor, GC_make_sequence_descriptor, SIMPLE, LEAF, COMPLEX, NO_MEM, GC_make_array_descriptor): Move definition down (to be after GC_malloc_explicitly_typed_ignore_off_page); reformat code. * typd_mlc.c (TAG): Remove macro. * typd_mlc.c (GC_init_explicit_typing): Move static assert about LeafDescriptor size to GC_calloc_explicitly_typed; reformat code. * typd_mlc.c (GC_descr_obj_size, GC_push_complex_descriptor, get_complex_descr, GC_array_mark_proc): Move function definition down to be after GC_calloc_explicitly_typed. * typd_mlc.c (set_complex_descr): Move definition down to be after GC_make_descriptor.
* Fix non-atomic write to *lp in GC_calloc_explicitly_typedIvan Maidanski2022-06-091-8/+17
| | | | | | | | | | | | | (fix of commit 4e020ef3c) Issue #449 (bdwgc). * typd_mlc.c (LeafDescriptor.ld_size, LeafDescriptor.ld_nelements, ComplexArrayDescriptor.ad_nelements): Change type from size_t to word. * typd_mlc.c (GC_make_leaf_descriptor): Change type of size and nelements arguments from size_t to word. * typd_mlc.c [AO_HAVE_store] (GC_calloc_explicitly_typed): Use AO_store to set fields of *lp.
* Workaround 'insufficient space for complex_descriptor' sanitizer FP errorIvan Maidanski2022-06-091-5/+8
| | | | | | | | (fix of commit 1f45c9a9f) * typd_mlc.c (GC_make_sequence_descriptor): Change type of result local variable from complex_descriptor* to struct SequenceDescriptor*; cast result variable to complex_descriptor* on return; add comment.
* Fix race between calloc_explicitly_typed and push_complex_descriptorIvan Maidanski2022-06-081-4/+16
| | | | | | | | | | | | | | | | | | Issue #449 (bdwgc). The real problem is that we store the descriptor in the last word of the object, and then read it in get_complex_descr() as ordinary data, but we need to make sure that the data in the descriptor is visible to the GC reading it. These stores need to be atomic release operations. * typd_mlc.c (get_complex_descr): Add comment (TODO). * typd_mlc.c (set_complex_descr): Define macro (using AO_store_release if available). * typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page): Use set_complex_descr() instead of direct write to *op. Co-authored-by: Hans Boehm <boehm@acm.org>
* Define op and nwords local variables consistently across typd_mlc.cIvan Maidanski2022-06-071-30/+26
| | | | | | | | | | | | | | | | (refactoring) * typd_mlc.c (GC_double_descr, get_complex_descr): Change type of nwords argument from word to size_t. * typd_mlc.c (GC_array_mark_proc): Change type of nwords local variable from word to size_t. * typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page): Change type of op local variable to void*; remove unnecessary casts; cast op where needed. * typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed): Replace lg local variable with nwords one. * typd_mlc.c GC_calloc_explicitly_typed): Rename lw to nwords local variable.
* Fix typo in GC_malloc_explicitly_typed commentIvan Maidanski2022-06-071-1/+1
| | | | | | | (fix of commit 59372942a) * typd_mlc.c (GC_malloc_explicitly_typed): Fix typo (remove duplicate "the") in comment.
* Fix GC_dirty() argument in GC_malloc_explicitly_typed_ignore_off_pageIvan Maidanski2022-06-071-1/+1
| | | | | | | (fix of commit 73d30d2b4) * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Cast op local variable to word* in the argument of GC_dirty() call.
* Assert in GC_typed_mark_proc that GC lock is held by some collecting threadIvan Maidanski2022-06-071-1/+5
| | | | | | | | | | (refactoring) This is to ensure that there is no race in accessing GC_ext_descriptors. * typd_mlc.c (GC_typed_mark_proc): Add comment; add assertion (before accessing GC_ext_descriptors) that either the allocation lock is held (by the current thread) or the parallel marker is on.
* Avoid code duplication in GC_make_array_descriptorIvan Maidanski2022-06-071-109/+78
| | | | | | | | | | | | | | (refactoring) * typd_mlc.c (GC_make_sequence_descriptor): Move definition upper and replace its declaration; change type of result local variable from SequenceDescriptor* to complex_descriptor*. * typd_mlc.c (COMPLEX, LEAF): Reorder macro definition. * typd_mlc.c (GC_make_leaf_descriptor): New STATIC function. * typd_mlc.c (GC_make_array_descriptor): Reformat comment and code; use GC_make_leaf_descriptor(); change type of one_element and beginning local variables from LeafDescriptor* to complex_descriptor*; rewrite code to call GC_make_sequence_descriptor only in one place.
* Fix propagation of out-of-memory occurred in GC_make_sequence_descriptorIvan Maidanski2022-06-071-0/+2
| | | | | * typd_mlc.c (GC_make_array_descriptor): If *complex_d (set to the result of GC_make_sequence_descriptor()) is null then return NO_MEM.
* Fix GC_make_descriptor for zero length argumentIvan Maidanski2022-06-071-1/+1
| | | | * typd_mlc.c (GC_make_descriptor): Cast len variable to signed_word.
* Assert that bm_table is already initialized when GC_double_descr usedIvan Maidanski2022-06-071-0/+1
| | | | | | | (refactoring) * typd_mlc.c (GC_double_descr): Add assertion that GC_bm_table[0] is non-zero.
* Specify that internal allocations failure is unlikelyIvan Maidanski2022-06-071-17/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * finalize.c [!GC_NO_FINALIZATION] (GC_register_disappearing_link_inner): Assume failure of allocation (resulting in NULL or GC_oom_fn call) is unlikely. * malloc.c [DBG_HDRS_ALL || GC_GCJ_SUPPORT || !GC_NO_FINALIZATION] (GC_generic_malloc_inner_ignore_off_page): Likewise. * malloc.c (GC_generic_malloc): Likewise. * malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER] (calloc, strdup, strndup): Likewise. * mallocx.c (GC_realloc, GC_memalign, GC_strdup, GC_strndup): Likewise. * mallocx.c [GC_REQUIRE_WCSDUP] (GC_wcsdup): Likewise. * specific.c [USE_CUSTOM_SPECIFIC] (GC_setspecific): Likewise. * typd_mlc.c (GC_make_sequence_descriptor, GC_make_descriptor): Likewise. * malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER] (calloc): Expect that lb and n are not greater than GC_SQRT_SIZE_MAX. * typd_mlc.c (GC_calloc_explicitly_typed): Likewise. * typd_mlc.c (GC_add_ext_descriptor): Assume that resizing of GC_ext_descriptors[] is rare. * typd_mlc.c (GC_calloc_explicitly_typed): Do not call GC_make_array_descriptor() if n * lb > GC_SIZE_MAX. * malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER && !strndup] (strndup): Expect that len is not greater than size. * mallocx.c (GC_strndup): Likewise. * typd_mlc.c (GC_make_sequence_descriptor): Reformat code.
* Update copyright information in alloc.c and other modified files (2022)Ivan Maidanski2022-05-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * CMakeLists.txt: Update year in copyright comment (2021 to 2022). * alloc.c: Likewise. * configure.ac: Likewise. * dyn_load.c: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * os_dep.c: Likewise. * pthread_support.c: Likewise. * reclaim.c: Likewise. * tests/gctest.c: Likewise. * win32_threads.c: Likewise. * LICENSE: Update year (2021 to 2022). * allchblk.c: Add copyright line in header comment. * darwin_stop_world.c: Likewise. * dbg_mlc.c: Likewise. * gcj_mlc.c: Likewise. * headers.c: Likewise. * include/gc/gc_inline.h: Likewise. * include/gc/gc_mark.h: Likewise. * include/private/gc_locks.h: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * include/private/pthread_support.h: Likewise. * mach_dep.c: Likewise. * malloc.c: Likewise. * thread_local_alloc.c: Likewise. * typd_mlc.c: Likewise. * finalize.c: Update year in copyright comment (2020 to 2022). * include/gc/gc.h: Likewise. * pthread_stop_world.c: Likewise.
* Replace comments about GC is held or not with relevant assertionsIvan Maidanski2022-05-111-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * alloc.c (GC_default_stop_func): Refine comment about the allocation lock. * alloc.c (GC_finish_collection): Remove comment that the allocation lock is held because the assertion about it already exists. * finalize.c (GC_grow_table, GC_mark_fo, GC_finalize): Likewise. * finalize.c [!GC_MOVE_DISAPPEARING_LINK_NOT_NEEDED] (GC_move_disappearing_link_inner): Likewise. * mark.c (GC_mark_some_inner): Likewise. * mark.c [PARALLEL_MARK] (GC_do_parallel_mark): Likewise. * os_dep.c [OPENBSD && GC_OPENBSD_UTHREADS] (GC_find_limit_openbsd, GC_skip_hole_openbsd): Likewise. * os_dep.c [NEED_FIND_LIMIT || USE_PROC_FOR_LIBRARIES && THREADS] (GC_find_limit_with_bound): Likewise. * os_dep.c (GC_register_data_segments): Likewise. * os_dep.c [MPROTECT_VDB || PROC_VDB || SOFT_VDB] (GC_dirty_init): Likewise. * pthread_stop_world.c (GC_start_world): Likewise. * pthread_support.c (GC_new_thread): Likewise. * thread_local_alloc.c (return_freelists): Likewise. * win32_threads.c (GC_new_thread, GC_lookup_thread_inner, GC_delete_gc_thread_no_free): Likewise. * blacklst.c (GC_promote_black_lists): Remove comment that the allocation lock is held, and add the corresponding assertion to the beginning of the function. * blacklst.c [!PARALLEL_MARK] (GC_add_to_black_list_normal, GC_add_to_black_list_stack): Likewise. * darwin_stop_world.c (GC_stop_world, GC_start_world): Likewise. * mark_rts.c (GC_remove_root_at_pos, GC_remove_roots_inner, GC_exclude_static_roots_inner): Likewise. * pthread_stop_world.c (GC_push_all_stacks, GC_suspend_all): Likewise. * pthread_support.c (GC_check_finalizer_nested): Likewise. * thread_local_alloc.c (GC_destroy_thread_local): Likewise. * win32_threads.c (GC_check_finalizer_nested, GC_push_all_stacks): Likewise. * blacklst.c (GC_is_black_listed): Refine comment about the allocation lock. * darwin_stop_world.c (GC_push_all_stacks): Add assertion that the lock is held on entrance. * gcj_mlc.c (maybe_finalize): Likewise. * malloc.c [THREADS] (GC_free_inner): Likewise. * dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove, GC_init_dyld): Remove comment the allocation lock should not be held, and add the corresponding assertion to the beginning of the function. * finalize.c (GC_invoke_finalizers): Likewise. * mark.c [PARALLEL_MARK] (GC_help_marker): Likewise. * pthread_support.c (GC_init_parallel): Likewise. * win32_threads.c (GC_lookup_pthread, GC_init_parallel): Likewise. * finalize.c (GC_finalize_all): Remove comment that the lock is not held on entrance. * gcj_mlc.c (GC_init_gcj_malloc): Likewise. * typd_mlc.c (GC_add_ext_descriptor): Likewise. * include/gc/javaxfc.h (GC_finalize_all): Add comment the function acquires the allocation lock. * mallocx.c (GC_generic_malloc_many): Adjust comment about GC lock. * new_hblk.c (GC_build_fl): Likewise. * pthread_support.c (GC_new_thread): Move the assertion about the allocation lock closer to the beginning of the function. * win32_threads.c (GC_new_thread): Likewise.
* Specify that out-of-memory is unlikely in typed alloc and make descriptorIvan Maidanski2022-05-081-4/+5
| | | | | | | | | (refactoring) * typd_mlc.c (GC_make_array_descriptor): Specify EXPECT(FALSE) for result==NO_MEM, !one_element and !beginning expressions. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Specify EXPECT(FALSE) for !op expression.
* Workaround TSan FP about race between generic_malloc and array_mark_procIvan Maidanski2022-05-061-1/+7
| | | | | | | * typd_mlc.c (get_complex_descr): New static function (defined with GC_ATTR_NO_SANITIZE_THREAD attribute). * typd_mlc.c (GC_array_mark_proc): Use get_complex_descr() instead of direct access of addr[nwords-1].
* Remove extra space after comma in license termsIvan Maidanski2022-05-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (reformatting) * CMakeLists.txt: Remove an extra space after comma in license header comment. * Makefile.am: Likewise. * allchblk.c: Likewise. * alloc.c: Likewise. * backgraph.c: Likewise. * blacklst.c: Likewise. * checksums.c: Likewise. * configure.ac: Likewise. * cord/cordbscs.c: Likewise. * cord/cordprnt.c: Likewise. * cord/cordxtra.c: Likewise. * cord/tests/cordtest.c: Likewise. * cord/tests/de.c: Likewise. * cord/tests/de_cmds.h: Likewise. * cord/tests/de_win.c: Likewise. * cord/tests/de_win.h: Likewise. * cord/tests/de_win.rc: Likewise. * darwin_stop_world.c: Likewise. * dbg_mlc.c: Likewise. * dyn_load.c: Likewise. * extra/gc.c: Likewise. * extra/msvc_dbg.c: Likewise. * extra/pcr_interface.c: Likewise. * extra/real_malloc.c: Likewise. * finalize.c: Likewise. * fnlz_mlc.c: Likewise. * gc_badalc.cc: Likewise. * gc_cpp.cc: Likewise. * gc_dlopen.c: Likewise. * gcj_mlc.c: Likewise. * headers.c: Likewise. * include/gc/cord.h: Likewise. * include/gc/cord_pos.h: Likewise. * include/gc/ec.h: Likewise. * include/gc/gc.h: Likewise. * include/gc/gc_backptr.h: Likewise. * include/gc/gc_config_macros.h: Likewise. * include/gc/gc_disclaim.h: Likewise. * include/gc/gc_gcj.h: Likewise. * include/gc/gc_inline.h: Likewise. * include/gc/gc_mark.h: Likewise. * include/gc/gc_pthread_redirects.h: Likewise. * include/gc/gc_tiny_fl.h: Likewise. * include/gc/gc_typed.h: Likewise. * include/gc/gc_version.h: Likewise. * include/gc/javaxfc.h: Likewise. * include/gc/leak_detector.h: Likewise. * include/include.am: Likewise. * include/private/darwin_semaphore.h: Likewise. * include/private/darwin_stop_world.h: Likewise. * include/private/dbg_mlc.h: Likewise. * include/private/gc_alloc_ptrs.h: Likewise. * include/private/gc_atomic_ops.h: Likewise. * include/private/gc_hdrs.h: Likewise. * include/private/gc_locks.h: 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: Likewise. * include/private/specific.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * m4/gc_set_version.m4: Likewise. * mach_dep.c: Likewise. * malloc.c: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * new_hblk.c: Likewise. * obj_map.c: Likewise. * os_dep.c: Likewise. * pthread_start.c: Likewise. * pthread_stop_world.c: Likewise. * pthread_support.c: Likewise. * ptr_chck.c: Likewise. * reclaim.c: Likewise. * specific.c: Likewise. * tests/atomicops.c: Likewise. * tests/cpp.cc: Likewise. * tests/disclaim.c: Likewise. * tests/disclaim_bench.c: Likewise. * tests/gctest.c: Likewise. * tests/tests.am: Likewise. * tests/weakmap.c: Likewise. * thread_local_alloc.c: Likewise. * tools/setjmp_t.c: Likewise. * tools/threadlibs.c: Likewise. * typd_mlc.c: Likewise. * win32_threads.c: Likewise. * LICENSE: Remove an extra space after comma in license terms.
* Simplify expression to clear extra bits in GC_add_ext_descriptorIvan Maidanski2022-05-011-8/+3
| | | | | | | | | | (refactoring) * typd_mlc.c (GC_add_ext_descriptor): Remove last_part and extra_bits local variables; improve comment regarding clearing extra bits; replace (x<<n)>>n expression to x&(GC_WORD_MAX>>n); compute ed_bitmap of the last element of GC_ext_descriptors directly (i.e., w/o intermediate variables).
* Remove extra parentheses in return statementIvan Maidanski2022-05-011-33/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) Also, replace 0 to NULL where appropriate. * allchblk.c (setup_header, GC_get_first_part, GC_allochblk_nth): Remove outermost parentheses in the expression of return statement. * alloc.c (GC_never_stop_func, GC_timeout_stop_func, GC_adj_bytes_allocd, GC_try_to_collect_inner, GC_collect_a_little, GC_stopped_mark, GC_try_to_collect_general, GC_expand_hp_inner, GC_collect_or_expand, GC_allocobj): Likewise. * blacklst.c (GC_is_black_listed, GC_number_stack_black_listed, total_stack_black_listed): Likewise. * checksums.c (GC_checksum): Likewise. * cord/cordbscs.c (CORD_cat_char_star, CORD_cat, CORD_len, CORD_index_access_fn, CORD_apply_access_fn, CORD_substr_checked, CORD_substr, CORD_iter5, CORD_iter, CORD_riter4, CORD_riter, CORD_concat_forest, CORD_balance, CORD__pos_fetch, CORD__prev, CORD_prev, CORD_pos_to_cord, CORD_pos_valid): Likewise. * cord/cordprnt.c (extract_conv_spec, CORD_vsprintf, CORD_sprintf, CORD_fprintf, CORD_vfprintf, CORD_printf, CORD_vprintf): Likewise. * cord/cordxtra.c (CORD_cat_char, CORD_catn, CORD_fill_proc, CORD_batched_fill_proc, CORD_cmp, CORD_ncmp, CORD_to_char_star, CORD_from_char_star, CORD_to_const_char_star, CORD_fetch, CORD_put_proc, CORD_batched_put_proc, CORD_put, CORD_chr_proc, CORD_rchr_proc, CORD_batched_chr_proc, CORD_chr, CORD_rchr, CORD_str, CORD_from_file_eager, CORD_lf_func, CORD_from_file_lazy_inner, CORD_from_file_lazy, CORD_from_file): Likewise. * cord/tests/cordtest.c (test_fn, id_cord_fn, test_basics): Likewise. * cord/tests/de.c (line_pos, add_hist, retrieve_line, beep): Likewise. * cord/tests/de_win.c (WinMain, plain_chars, control_chars, WndProc): Likewise. * dbg_mlc.c (store_debug_info, GC_debug_generic_malloc, GC_debug_generic_malloc, GC_debug_realloc, GC_make_closure): Likewise. * dyn_load.c (GC_FirstDLOpenedLinkMap): Likewise. * extra/real_malloc.c (real_malloc): Likewise. * finalize.c (GC_register_disappearing_link, GC_unregister_disappearing_link): Likewise. * gc_dlopen.c (dlopen): Likewise. * gcj_mlc.c (maybe_finalize, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * headers.c (GC_find_header, alloc_hdr, get_index, GC_install_header, GC_next_block, GC_prev_block): Likewise. * malloc.c (GC_generic_malloc): Likewise. * mallocx.c (GC_realloc, GC_generic_malloc_ignore_off_page): Likewise. * mark.c (GC_collection_in_progress, GC_mark_some, GC_signal_mark_stack_overflow, GC_block_was_dirty, GC_push_next_marked, GC_push_next_marked_dirty, GC_push_next_marked_uncollectable): Likewise. * mark_rts.c (GC_is_static_root, rt_hash, GC_roots_present, GC_remove_tmp_roots, GC_approx_sp): Likewise. * misc.c (GC_default_oom_fn, GC_clear_stack_inner, GC_base, GC_write, GC_get_warn_proc, GC_call_with_alloc_lock): Likewise. * new_hblk.c (GC_build_fl_clear2, GC_build_fl_clear4, GC_build_fl2, GC_build_fl4, GC_build_fl): Likewise. * obj_map.c (GC_register_displacement_inner): Likewise. * os_dep.c (GC_find_limit_openbsd, GC_skip_hole_openbsd, GC_get_writable_length, GC_get_writable_length, GC_get_main_stack_base, GC_FreeBSDGetDataStart, GC_unix_mmap_get_mem, GC_unix_sbrk_get_mem, os2_alloc, GC_wince_get_mem, GC_win32_get_mem, GC_push_thread_stack, GC_push_old_obj, GC_write_fault_handler, catch_exception_raise_state, catch_exception_raise_state_identity): Likewise. * pthread_support.c (GC_new_thread, GC_lookup_thread, GC_get_nprocs, pthread_sigmask, pthread_create): Likewise. * ptr_chck.c (GC_same_obj, GC_default_is_visible_print_proc, GC_default_is_valid_displacement_print_proc, GC_is_visible, GC_pre_incr, GC_post_incr): Likewise. * reclaim.c (GC_block_empty, GC_reclaim_uninit, GC_n_set_marks, GC_reclaim_all): Likewise. * tests/cpp.cc (main): Likewise. * tests/gctest.c (fake_gcj_mark_proc, reverse1, reverse, ints, gcj_reverse1, gcj_reverse, gcj_ints, uncollectable_ints, mktree, alloc8bytes, main, test): Likewise. * tools/if_mach.c (main): Likewise. * tools/if_not_there.c (main): Likewise. * tools/setjmp_t.c (getpagesize, main, g): Likewise. * typd_mlc.c (GC_add_ext_descriptor, GC_add_ext_descriptor, GC_double_descr, GC_make_array_descriptor, GC_make_sequence_descriptor, GC_typed_mark_proc, GC_descr_obj_size, GC_push_complex_descriptor, GC_array_mark_proc, GC_make_descriptor, GC_calloc_explicitly_typed): Likewise. * win32_threads.c (GC_new_thread, GC_lookup_thread_inner, GC_get_stack_min, GC_pthread_create, GC_pthread_start_inner): Likewise. * allchblk.c (GC_get_first_part, GC_allochblk_nth): Replace 0 to NULL where appropriate. * alloc.c (GC_allocobj): Likewise. * blacklst.c (GC_is_black_listed): Likewise. * cord/cordbscs.c (CORD_from_fn_inner, CORD_substr_checked): Likewise. * cord/cordxtra.c (CORD_cat_char, CORD_to_char_star, CORD_from_char_star, CORD_lf_func, CORD_from_file_lazy_inner): Likewise. * dbg_mlc.c (store_debug_info, GC_debug_generic_malloc, GC_debug_generic_malloc): Likewise. * dyn_load.c (GC_FirstDLOpenedLinkMap): Likewise. * gcj_mlc.c (GC_debug_gcj_malloc): Likewise. * headers.c (GC_next_block, GC_prev_block): Likewise. * malloc.c (GC_generic_malloc, strdup): Likewise. * mallocx.c (GC_realloc): Likewise. * misc.c (GC_default_oom_fn, GC_base): Likewise. * os_dep.c (GC_get_main_stack_base, os2_alloc, GC_win32_get_mem): Likewise. * pthread_support.c (GC_new_thread, GC_lookup_thread): Likewise. * ptr_chck.c (GC_same_obj, GC_is_visible, GC_default_is_valid_displacement_print_proc): Likewise. * tests/gctest.c (mktree): Likewise. * typd_mlc.c (GC_make_array_descriptor, GC_push_complex_descriptor, GC_array_mark_proc, GC_calloc_explicitly_typed): Likewise. * win32_threads.c (GC_new_thread, GC_lookup_thread_inner): Likewise. * alloc.c (GC_never_stop_func, GC_timeout_stop_func): Replace 0 and 1 (in return statement) to FALSE and TRUE, respectively. * include/private/gcconfig.h: Remove outermost parentheses in the expression of return statement in comment.
* Check pointer tag in all mark procedures (E2K)Ivan Maidanski2022-01-121-5/+6
| | | | | | | | | | | | | | | | | | | | | Issue #411 (bdwgc). Do not mark objects if its pointer tag is non-zero, not only in GC_mark_from and GC_push_all_eager, but also in add_back_edges, GC_ignore_self_finalize_mark_proc, GC_typed_mark_proc and GC_push_conditional_eager. * backgraph.c [MAKE_BACK_GRAPH] (add_back_edges): Change type of current_p local variable from word* to ptr_t. * typd_mlc.c (GC_typed_mark_proc): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (add_back_edges): Use LOAD_WORD_OR_CONTINUE() instead of direct dereference of current_p. * finalize.c (GC_ignore_self_finalize_mark_proc): Likewise. * mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Likewise. * typd_mlc.c (GC_typed_mark_proc): Likewise. * finalize.c (GC_ignore_self_finalize_mark_proc): Rename q and r local variables to current_p and q, respectively.
* Move public header files to include/gc in source treeIvan Maidanski2021-11-251-2/+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.
* Remove useless empty statements after block ones (refactoring)Ivan Maidanski2021-09-081-1/+1
| | | | | | | | | * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Remove extra ';' after block statement ('}'). * new_hblk.c [!SMALL_CONFIG] (GC_build_fl_clear2, GC_build_fl_clear4, GC_build_fl2, GC_build_fl4): Likewise. * typd_mlc.c (GC_double_descr): Likewise.
* Move GC state pointer variables into GC_arraysIvan Maidanski2020-07-191-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is intended to simplify GC reinitialization. GC_push_finalizer_structures() and GC_push_typed_structures() are called now regardless of GC_no_dls and GC_roots_were_cleared values. * finalize.c (dl_hashtbl_s, fnlz_roots_s): Move struct to gc_priv.h. * typd_mlc.c (typed_ext_descr_t): Likewise. * finalize.c [!GC_NO_FINALIZATION] (GC_dl_hashtbl, GC_fnlz_roots): Remove static variable. * finalize.c [!GC_NO_FINALIZATION && !GC_LONG_REFS_NOT_NEEDED] (GC_ll_hashtbl): Likewise. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_toggleref_arr): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcjobjfreelist): Likewise. * headers.c (GC_all_bottom_indices, GC_all_bottom_indices_end, GC_scratch_free_ptr, GC_hdr_free_list): Likewise. * mark.c (GC_scan_ptr): Likewise. * mark.c [PARALLEL_MARK] (GC_main_local_mark_stack): Likewise. * typd_mlc.c (GC_ext_descriptors): Likewise. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GCToggleRef): Define type as an alias to union toggle_ref_u. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_mark_togglerefs): Remove TODO item. * include/private/gc_priv.h (disappearing_link, finalizable_object): Declare struct. * include/private/gc_priv.h (GC_arrays): Add _all_bottom_indices, _all_bottom_indices_end, _scratch_free_ptr, _hdr_free_list, _scan_ptr, _ext_descriptors fields. * include/private/gc_priv.h [PARALLEL_MARK] (GC_arrays): Add _main_local_mark_stack field. * include/private/gc_priv.h [GC_GCJ_SUPPORT] (GC_arrays): Add _gcjobjfreelist field. * include/private/gc_priv.h [!GC_NO_FINALIZATION && GC_LONG_REFS_NOT_NEEDED] (GC_arrays): Add _ll_hashtbl field. * include/private/gc_priv.h [!GC_NO_FINALIZATION] (GC_arrays): Add _dl_hashtbl, _fnlz_roots fields. * include/private/gc_priv.h [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_arrays): Add _toggleref_arr field. * include/private/gc_priv.h (GC_arrays._roots_were_cleared): Define field only if THREADS. * mark_rts.c (GC_clear_roots): Set GC_roots_were_cleared only if THREADS. * mark_rts.c (GC_push_gc_structures): Remove static function. * mark_rts.c (GC_push_roots): Do not call GC_push_gc_structures. * mark_rts.c [!GC_NO_FINALIZATION] (GC_push_roots): Call GC_push_finalizer_structures (regardless of GC_no_dls and GC_roots_were_cleared). * mark_rts.c [THREADS] (GC_push_roots): If GC_no_dls or GC_roots_were_cleared then call GC_push_thread_structures. * mark_rts.c (GC_push_roots): If GC_push_typed_structures is non-null then call GC_push_typed_structures (regardless of GC_no_dls and GC_roots_were_cleared).
* Remove GC_eobjfreelist variable in typd_mlc.cIvan Maidanski2020-07-181-7/+6
| | | | | | | | | | (code refactoring) * typd_mlc.c (GC_eobjfreelist): Remove static variable. * typd_mlc.c (GC_init_explicit_typing): Do not set GC_eobjfreelist. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Define opp local variable; use GC_obj_kinds[GC_explicit_kind].ok_freelist instead of GC_eobjfreelist.
* Move GC state non-pointer variables into GC_arraysIvan Maidanski2020-07-101-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) This commit is intended to simplify GC reinitialization. * alloc.c (GC_n_heap_sects, GC_fo_entries): Remove variable definition. * alloc.c [USE_PROC_FOR_LIBRARIES] (GC_n_memory): Likewise. * finalize.c [!GC_NO_FINALIZATION] (GC_log_fo_table_size): Likewise. * finalize.c [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (GC_toggleref_array_size, GC_toggleref_array_capacity): Likewise. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_kind): Likewise. * mark.c (GC_mark_stack_size, GC_mark_state, GC_mark_stack_too_small, GC_objects_are_marked): Likewise. * mark.c [PARALLEL_MARK] (GC_first_nonempty): Likewise. * mark.c [TRACE_BUF] (GC_trace_buf_ptr): Likewise. * mark_rts.c (n_root_sets, GC_roots_were_cleared, GC_excl_table_entries): Likewise. * os_dep.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_n_heap_bases): Likewise. * typd_mlc.c (GC_ed_size, GC_avail_descr, GC_explicit_typing_initialized): Likewise. * extra/MacOS.c (GC_fo_entries): Remove variable declaration. * include/private/gc_pmark.h (GC_mark_stack_size, GC_mark_stack_too_small, GC_mark_state): Likewise. * include/private/gc_priv.h (GC_n_heap_sects, GC_fo_entries): Likewise. * include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES] (GC_n_memory): Likewise. * include/private/gc_pmark.h (mark_state_t): Move typedef to gc_priv.h. * include/private/gc_priv.h (_GC_arrays._scratch_end_ptr, _GC_arrays._scratch_last_end_ptr): Document. * include/private/gc_priv.h [PARALLEL_MARK] (_GC_arrays): Add _first_nonempty field. * include/private/gc_priv.h (_GC_arrays): Add _mark_stack_size, _mark_state, _mark_stack_too_small, _objects_are_marked, _n_heap_sects, _n_memory, _fo_entries, _n_root_sets, _excl_table_entries, _roots_were_cleared, _explicit_typing_initialized, _ed_size, _avail_descr fields. * include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES] (_GC_arrays): Add _n_memory field. * include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32] (_GC_arrays): Add _n_heap_bases field. * include/private/gc_priv.h [!GC_NO_FINALIZATION] (_GC_arrays): Add _log_fo_table_size field. * include/private/gc_priv.h [!GC_NO_FINALIZATION && !GC_TOGGLE_REFS_NOT_NEEDED] (_GC_arrays): Add _toggleref_array_size, _toggleref_array_capacity fields. * include/private/gc_priv.h [TRACE_BUF] (_GC_arrays): Add _trace_buf_ptr field. * include/private/gc_priv.h [ENABLE_DISCLAIM] (_GC_arrays): Add _finalized_kind field. * include/private/gc_priv.h (GC_first_nonempty, GC_mark_stack_size, GC_mark_state, GC_mark_stack_too_small, GC_objects_are_marked, GC_n_heap_sects, GC_n_memory, GC_n_heap_bases, GC_fo_entries, GC_log_fo_table_size, GC_toggleref_array_size, GC_toggleref_array_capacity, GC_trace_buf_ptr, GC_finalized_kind, n_root_sets, GC_excl_table_entries, GC_roots_were_cleared, GC_explicit_typing_initialized, GC_ed_size, GC_avail_descr): Define macro.
* Rename ext_descr to typed_ext_descr_tIvan Maidanski2020-06-211-11/+12
| | | | | | | | (code refactoring) * typd_mlc.c (ext_descr): Rename to typed_ext_descr_t. * typd_mlc.c (GC_ext_descriptors, GC_add_ext_descriptor): Rename ext_descr to typed_ext_descr_t.
* Eliminate 'poor global variable name' code defect in typd_mlcIvan Maidanski2018-08-301-3/+3
| | | | | | (fix of commit a825a2d) * typd_mlc.c (ld, ad, sd): Remove unused global variables.
* Add GC_reachable_here after GC_dirty in GC sourceIvan Maidanski2018-06-231-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Fix missing GC_dirty calls for GC-allocated objects used internallyIvan Maidanski2018-05-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change matters only in case of MANUAL_VDB mode. * finalize.c (GC_grow_table, GC_register_disappearing_link, GC_unregister_disappearing_link_inner, GC_process_togglerefs, GC_toggleref_add, GC_move_disappearing_link_inner, GC_register_finalizer_inner, ITERATE_DL_HASHTBL_END, DELETE_DL_HASHTBL_ENTRY, GC_finalize, GC_enqueue_all_finalizers): Call GC_dirty where needed. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * pthread_start.c [GC_PTHREADS && !GC_WIN32_THREADS] (GC_inner_start_routine): Likewise. * pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS] (GC_new_thread, GC_delete_thread, GC_delete_gc_thread): Likewise. * specific.c [USE_CUSTOM_SPECIFIC] (GC_setspecific, GC_remove_specific_after_fork): Likewise. * typd_mlc.c (GC_make_sequence_descriptor, GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise. * win32_threads.c (GC_new_thread, GC_delete_gc_thread_no_free, GC_delete_thread, GC_CreateThread): Likewise. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1] (GC_beginthreadex): Likewise. * win32_threads.c [GC_PTHREADS] (GC_pthread_create, GC_pthread_start_inner): Likewise. * include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call GC_end_stubborn_change(my_fl) after GC_FAST_M_AO_STORE() call unless kind is GC_I_PTRFREE. * include/gc_inline.h (GC_CONS): Call GC_end_stubborn_change(result).
* Remove code duplication in gcj_malloc and malloc_explicitly_typedIvan Maidanski2018-05-161-9/+7
| | | | | | | | | (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.
* Eliminate 'boolean result used in bitwise operation' cppcheck warningIvan Maidanski2018-04-201-1/+1
| | | | | | * finalize.c (GC_push_finalizer_structures): Replace (word)&sym to (word)(&sym). * typd_mlc.c (GC_add_ext_descriptor): Likewise.
* Avoid potential race when accessing size_map tableHans Boehm2018-02-261-1/+1
| | | | | | | | | | | | | | | | | | 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.