Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Unity-Technologies/bdwgc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-05-28Merge pull request #57 from Unity-Technologies/disable-automatic-collection-apijonas echterhoff
Add GC_set_disable_automatic_collection API to disable automatic peri…
2020-05-28Add GC_set_disable_automatic_collection API to disable automatic periodic ↵disable-automatic-collection-apiJonas Echterhoff
collections
2020-05-28Merge pull request #56 from Unity-Technologies/fix-nda-platformsTim Cannell
Fix nda platforms
2020-05-26Change name; also start collectionJonas Echterhoff
2020-05-18Add GC_trigger_collection APIJonas Echterhoff
2020-02-26extract platform defines to seperate values that can be set from the compilertimcannell
2018-10-31more type fixesJonas Echterhoff
2018-10-30Fix string formatJonas Echterhoff
2018-10-29Fix precision warning on windowsJonas Echterhoff
2018-10-19use 64-bit integers for nanoseconds so we won't overflowJonas Echterhoff
2018-10-18Suport nanosecond precision in time_limit apisJonas Echterhoff
2018-06-01Reapply Unity changesJonas Echterhoff
2018-05-15Remove stubborn objects allocation code completelyIvan Maidanski
(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.
2018-04-24Expose API to control rate and max prior attempts of collect_a_littleJonathan Chambers
(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.
2018-04-23Expose API to control the minimum bytes allocated before a GC occursJonathan Chambers
(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().
2018-04-06Add assertions about held lock for apply_to_each_object callersIvan Maidanski
(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).
2018-03-15Add assertions to ensure ADD_CALL_CHAIN is called holding the lockIvan Maidanski
(code refactoring) * alloc.c (GC_collect_a_little_inner, GC_allocobj): Add assertion that the allocation lock is held. * dbg_mlc.c (GC_store_debug_info_inner): Likewise. * dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner, GC_debug_generic_malloc_inner_ignore_off_page): Likewise. * finalize.c [!GC_TOGGLE_REFS_NOT_NEEDED] (ensure_toggleref_capacity): Likewise. * specific.c [USE_CUSTOM_SPECIFIC] (GC_key_create_inner): Likewise. * alloc.c (GC_allocobj): Remove comment (about the lock). * dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner): Likewise.
2018-03-01Eliminate 'unused const variable' Clang warning for copyright and versionIvan Maidanski
Issue #206 (bdwgc). * alloc.c (GC_copyright): Declare (inside EXTERN_C_BEGIN/END) before the definition. * alloc.c [!GC_NO_VERSION_VAR] (GC_version): Likewise.
2018-02-26Revert 'Workaround TSan false positives in extend_size_map'Ivan Maidanski
This reverts commit e522d6d791680b55825b5f11a4c082eb4770ecf5. Because there is again a data race here, not a false positive, though it is again not likely to fail in practice.
2018-02-16Convert GC source files to valid C++ codeIvan Maidanski
Issue #206 (bdwgc). * alloc.c (GC_copyright): Change type from char* const to const char* const. * alloc.c (GC_set_fl_marks, GC_clear_fl_marks, GC_finish_collection, GC_allocobj): Add missing explicit casts from void* to ptr_t. * backgraph.c [MAKE_BACK_GRAPH] (add_back_edges): Likewise. * blacklst.c (GC_default_print_heap_obj_proc, GC_print_blacklisted_ptr): Likewise. * dbg_mlc.c (GC_get_back_ptr_info, GC_store_debug_info_inner, GC_store_debug_info, GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc, GC_debug_malloc_stubborn, GC_debug_malloc_atomic, GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable, GC_debug_free, GC_debug_free_inner, GC_debug_register_finalizer, GC_debug_register_finalizer_no_order, GC_debug_register_finalizer_unreachable, GC_debug_register_finalizer_ignore_self): Likewise. * finalize.c (GC_grow_table, push_and_mark_object, ensure_toggleref_capacity, GC_dump_finalization_links, GC_dump_finalization, GC_make_disappearing_links_disappear, GC_remove_dangling_disappearing_links, GC_finalize): Likewise. * gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Likewise. * mallocx.c (GC_memalign): Likewise. * mark.c (GC_mark_from, GC_mark_and_push, GC_push_all_eager, GC_push_all_stack, GC_push_marked1, GC_push_marked2, GC_push_marked4): Likewise. * mark_rts.c (GC_exclude_static_roots_inner): Likewise. * misc.c (GC_base): Likewise. * new_hblk.c (GC_new_hblk): Likewise. * pthread_support.c (GC_register_altstack, GC_thr_init, GC_record_stack_base): Likewise. * ptr_chck.c (GC_is_visible): Likewise. * reclaim.c (GC_reclaim_small_nonempty_block, GC_disclaim_and_reclaim_or_free_small_block): Likewise. * thread_local_alloc.c (GC_mark_thread_local_fls_for): Likewise. * typd_mlc.c (GC_typed_mark_proc, GC_malloc_explicitly_typed_ignore_off_page): Likewise. * win32_threads.c (GC_record_stack_base, GC_get_stack_min, GC_push_stack_for): Likewise. * blacklst.c (GC_copy_bl): Rename "new" argument to "dest". * dbg_mlc.c (GC_store_debug_info_inner, GC_print_smashed_obj): Change type of p argument from ptr_t to void*. * include/private/gc_priv.h (GC_is_heap_base, GC_is_static_root): Likewise. * mark_rts.c [!THREADS] (GC_is_static_root): Likewise. * os_dep.c (GC_is_malloc_heap_base, GC_is_heap_base): Likewise. * ptr_chck.c (GC_on_stack): Likewise. * dbg_mlc.c (GC_print_obj): Change type of kind_str local variable from char* to const char*. * dbg_mlc.c (GC_debug_strdup, GC_debug_strndup): Cast result of GC_debug_malloc_atomic() to char*. * mallocx.c (GC_strdup, GC_strndup): Likewise. * dbg_mlc.c (GC_debug_wcsdup): Cast result of GC_debug_malloc_atomic() to wchar_t*. * mallocx.c (GC_wcsdup): Likewise. * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_register_dynamic_libraries): Cast p local variable to char*. * os_dep.c (GC_register_data_segments): Likewise. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_disclaim): Cast masked fc_word to struct GC_finalizer_closure* (instead of void*). * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_malloc): Cast result of GC_malloc_kind() to word*. * typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed): Likewise. * include/private/gc_priv.h (WARN): Cast away const qualifier for msg (and the string literal). * misc.c (GC_default_on_abort): Remove cast to void* for WRITE() buf argument. * misc.c (GC_new_free_list_inner): Cast result local variable to void**. * misc.c (GC_new_free_list): Change type of result local variable from void* to void**. * pthread_support.c (GC_start_rtn_prepare_thread): Cast arg to struct start_info*. * win32_threads.c [GC_PTHREADS] (GC_pthread_start_inner): Likewise. * reclaim.c (GC_print_free_list): Replace ptr_t flh to void *flh_next local variable; remove redundant casts. * tools/if_mach.c (EXECV_ARGV_T): New macro; add comment. * tools/if_not_there.c (EXECV_ARGV_T): Likewise. * tools/if_mach.c (main): Use EXECV_ARGV_T instead of void* for execvp() argument. * tools/if_not_there.c (main): Likewise. * typd_mlc.c (LeafDescriptor, ComplexArrayDescriptor, SequenceDescriptor): Move struct definition out of union ComplexDescriptor. * typd_mlc.c (GC_add_ext_descriptor): Rename "new" local variable to newExtD. * win32_threads.c (GC_CreateThread, GC_beginthreadex): Cast result of GC_malloc_uncollectable() to thread_args*. * win32_threads.c [PARALLEL_MARK && !MSWINCE && __cplusplus] (GC_thr_init): Do not cast GetProcessAffinityMask() arguments to void*.
2018-02-08Change type of hb_sz field (of hblkhdr) from size_t to wordIvan Maidanski
This is needed to make the size of hb_sz to be the same as of AO_t. * allchblk.c [USE_MUNMAP] (GC_unmap_old): Cast hhdr->hb_sz to size_t when passed to GC_unmap(). * allchblk.c (GC_allochblk_nth): Cast hhdr->hb_sz to signed_word when assigned to size_avail. * allchblk.c [USE_MUNMAP] (GC_allochblk_nth): Cast hhdr->hb_sz to size_t when passed to GC_remap(). * alloc.c (GC_set_fl_marks, GC_clear_fl_marks): Change type of sz and bit_no local variables from size_t/unsigned to word. * dbg_mlc.c (GC_check_heap_block): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (per_object_helper): Cast hhdr->hb_sz to size_t; change type of i local variables from int to size_t. * checksums.c [CHECKSUMS] (GC_on_free_list): Change type of sz local variable from size_t to word. * mark.c (GC_push_marked, GC_push_unconditionally, GC_block_was_dirty): Likewise. * reclaim.c (GC_reclaim_small_nonempty_block, GC_disclaim_and_reclaim_or_free_small_block, GC_reclaim_block, GC_n_set_marks): Likewise. * checksums.c [CHECKSUMS] (GC_add_block): Remove bytes local variable (to avoid casting of hhdr->hb_sz). * dbg_mlc.c (GC_debug_free): Change type of i and obj_sz local variables from size_t to word. * dbg_mlc.c (GC_check_leaked): Likewise. * extra/pcr_interface.c (GC_enumerate_block): Change type of sz local variable from int to size_t. * extra/pcr_interface.c (GC_enumerate_block): Cast hhdr->hb_sz to size_t when assigned to sz. * mallocx.c (GC_realloc): Likewise. * mark.c (GC_set_hdr_marks): Likewise. * reclaim.c (GC_do_enumerate_reachable_objects): Likewise. * include/private/gc_pmark.h [MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR): Cast hhdr->hb_sz to size_t in assignment of obj_displ. * include/private/gc_priv.h (struct hblkhdr): Change type of hb_sz from size_t to word. * include/private/gc_priv.h (MARK_BIT_NO): Cast offset argument to word instead of unsigned. * malloc.c (GC_free): Cast hhdr->hb_sz to size_t. * mallocx.c (GC_get_kind_and_size): Likewise. * mark.c (GC_clear_hdr_marks): Likewise. * misc.c (GC_size): Likewise. * misc.c (GC_do_blocking): Remove redundant cast of hhdr->hb_sz. * reclaim.c (GC_reclaim_clear, GC_reclaim_uninit, GC_disclaim_and_reclaim, GC_continue_reclaim): Change type of sz argument from size_t to word. * typd_mlc.c (GC_array_mark_proc): Change type of sz and nwords local variables from size_t to word.
2018-02-01Initial support of Sony PlayStation Portable 2Jonathan Chambers
(part of commit 9379c66 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * alloc.c [!MACOS && !MSWINCE && !SN_TARGET_ORBIS && !__CC_ARM]: Do not include sys/types.h if SN_TARGET_PSP2. * dyn_load.c [!MACOS && !_WIN32_WCE && !SN_TARGET_ORBIS && !__CC_ARM]: Likewise. * os_dep.c [!OS2 && !PCR && !AMIGA && !MACOS && !MSWINCE && !SN_TARGET_ORBIS && !__CC_ARM]: Likewise. * include/gc_config_macros.h [SN_TARGET_PSP2] (GC_THREADS): Define macro. * include/private/gcconfig.h [SN_TARGET_PSP2] (mach_type_known): Likewise. * include/private/gcconfig.h [ARM32 && SN_TARGET_PSP2] (NO_HANDLE_FORK, DATASTART, DATAEND, STACKBOTTOM): Likewise. * include/private/gcconfig.h [SN_TARGET_PSP2] (THREADS, GET_MEM): Likewise. * include/private/gc_locks.h [GC_PTHREADS && !GC_WIN32_THREADS && !SN_TARGET_ORBIS]: Do not include gc_atomic_ops.h if SN_TARGET_PSP2. * include/private/gc_locks.h [SN_TARGET_PSP2]: Include psp2-support.h. * include/private/gc_locks.h [SN_TARGET_PSP2] (GC_allocate_ml_PSP2): Declare GC_EXTERN variable. * include/private/gc_locks.h [SN_TARGET_PSP2] (UNCOND_LOCK, UNCOND_UNLOCK): Define (using GC_allocate_ml_PSP2 instead of GC_allocate_ml). * include/private/gc_priv.h [!HBLKSIZE && (LARGE_CONFIG || !SMALL_CONFIG) && SN_TARGET_PSP2] (CPP_LOG_HBLKSIZE): Define to 16 (instead of 12). * include/private/gcconfig.h [ARM32] (NOSYS): Do not define if SN_TARGET_PSP2. * os_dep.c (SBRK_ARG_T, OPT_MAP_ANON, GC_unix_mmap_get_mem, GC_unix_sbrk_get_mem, GC_unix_get_mem): Likewise. * pthread_support.c (GC_pthread_join, GC_pthread_detach, GC_pthread_create): Likewise. * include/private/gcconfig.h [ARM32 && SN_TARGET_PSP2] (psp2_get_stack_bottom): Declare external function. * include/private/gcconfig.h [SN_TARGET_PSP2] (psp2_get_mem): Likewise. * include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD && SN_TARGET_PSP2] (MUNMAP_THRESHOLD): Define to 2. * mach_dep.c: Skip everything in this file if SN_TARGET_PSP2. * pthread_stop_world.c: Likewise. * misc.c [SN_TARGET_PSP2] (GC_allocate_ml_PSP2): Define global varible (instead of GC_allocate_ml). * misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH && !AMIGA && !SN_TARGET_ORBIS && !__CC_ARM]: Do not include unistd.h if SN_TARGET_PSP2. * misc.c [SN_TARGET_PSP2] (GC_write): Define to no-op. * pthread_support.c: Do not include sys/mman.h if SN_TARGET_PSP2.
2018-01-29Initial support of Orbis targetJonathan Chambers
(part of commit 9379c66 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * alloc.c [!MACOS && !MSWINCE && !__CC_ARM]: Do not include sys/types.h if SN_TARGET_ORBIS. * dyn_load.c [!MACOS && !_WIN32_WCE && !__CC_ARM]: Likewise. * include/gc_config_macros.h [SN_TARGET_ORBIS] (GC_THREADS): Define. * include/gc_config_macros.h [__FreeBSD__] (GC_FREEBSD_THREADS): Do not define if SN_TARGET_ORBIS. * include/private/gcconfig.h [__FreeBSD__ || __DragonFly__ || __FreeBSD_kernel__] (FREEBSD): Likewise. * include/private/gcconfig.h [!LINUX && !NETBSD && !FREEBSD && !OPENBSD && !DARWIN && !_WIN32 && !__CEGCC__ && !NN_PLATFORM_CTR !NN_BUILD_TARGET_PLATFORM_NX && !SYMBIAN] (NOSYS): Likewise. * include/private/gc_locks.h [THREADS && GC_PTHREADS && !GC_WIN32_THREADS]: Do not include gc_atomic_ops.h if SN_TARGET_ORBIS. * include/private/gc_locks.h [SN_TARGET_ORBIS && GC_PTHREADS] (USE_PTHREAD_LOCKS): Define. * include/private/gc_priv.h [SN_TARGET_ORBIS] (CPP_LOG_HBLKSIZE): Define to 16 (instead of 12). * include/private/gcconfig.h [SN_TARGET_ORBIS && (__amd64__ || __x86_64__)] (X86_64): Define. * include/private/gcconfig.h [X86_64] (CACHE_LINE_SIZE): Do not define if already defined. * include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS] (DATASTART, DATAEND, STACKBOTTOM): Define. * include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS]: Include pthread.h. * include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS] (ps4_get_stack_bottom): Declare. * include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD && SN_TARGET_ORBIS] (MUNMAP_THRESHOLD): Define to 2. * include/private/gcconfig.h [SN_TARGET_ORBIS] (THREADS): Define. * pthread_support.c: Do not include sys/mman.h, sys/time.h, sys/types.h, fcntl.h if SN_TARGET_ORBIS. * pthread_support.c (GC_pthread_join, GC_pthread_detach, GC_pthread_create): Do not define if SN_TARGET_ORBIS.
2017-12-08Workaround TSan data race report in check_fl_marksIvan Maidanski
* alloc.c [GC_ASSERTIONS && THREAD_LOCAL_ALLOC && AO_HAVE_load_acquire_read] (GC_check_fl_marks): Skip the whole check if THREAD_SANITIZER; add comment.
2017-11-29Remove redundant THREADS macro checksIvan Maidanski
(code refactoring) THREAD_LOCAL_ALLOC macro implies THREADS one. * alloc.c [GC_ASSERTIONS && THREAD_LOCAL_ALLOC] (GC_check_fl_marks, GC_check_tls, GC_finish_collection): Do not check whether THREADS macro is defined. * include/private/gc_priv.h [GC_ASSERTIONS && THREAD_LOCAL_ALLOC] (GC_check_fl_marks): Likewise.
2017-11-16Workaround TSan false positives in extend_size_mapIvan Maidanski
Thread Sanitizer reports data races between fill_size_map (called from GC_extend_size_map) and GC_gcj_malloc[_ignore_off_page], GC_malloc_kind_global, GC_generic_malloc_uncollectable, GC_malloc_explicitly_typed_ignore_off_page which read a value from GC_size_map before acquiring the allocation lock. These races could be ignored as the value is verified after acquiring the lock. * alloc.c: Refine comment about GC_allocobj (and GC_size_map) usage for the case of a multi-threaded environment. * malloc.c (fill_size_map): New static function (with GC_ATTR_NO_SANITIZE_THREAD attribute). * malloc.c (GC_extend_size_map): Use fill_size_map() to fill in a region of GC_size_map.
2017-11-14Remove GENERAL_MALLOC internal macroIvan Maidanski
(code refactoring) * alloc.c: Update comment (about GC_allocobj usage). * include/private/gc_priv.h (GENERAL_MALLOC): Remove. * include/private/gc_priv.h (GENERAL_MALLOC_IOP): Move to typd_mlc.c. * malloc.c (GC_malloc_kind_global): Expand GENERAL_MALLOC macro; copy the comment from gc_priv.h.
2017-11-10Add basic calculation of the total full-collection timePaul Bone
Issue #139 (bdwgc). New API functions: GC_start_performance_measurement, GC_get_full_gc_total_time. This patch is based on code originally written by Zoltan Somogyi on 2008-03-18. * alloc.c [!NO_CLOCK] (full_gc_total_time, measure_performance): New static variable definition; add comment. * alloc.c [!NO_CLOCK] (GC_start_performance_measurement, GC_get_full_gc_total_time): New API function definition. * alloc.c [!NO_CLOCK] (GC_try_to_collect_inner): Declare start_time_valid local variable; set start_time_valid to true if GET_TIME(start_time) is called; call GET_TIME(start_time) also if measure_performance; declare time_diff local variable (used to store the result of MS_TIME_DIFF()); GET_TIME(current_time) is called only if start_time_valid; update full_gc_total_time if measure_performance. * include/gc.h (GC_start_performance_measurement, GC_get_full_gc_total_time): New API function declaration. * tests/test.c (INIT_PERF_MEASUREMENT): New macro. * tests/test.c (GC_COND_INIT): Call INIT_PERF_MEASUREMENT. * tests/test.c [!NO_CLOCK] (check_heap_stats): Call GC_get_full_gc_total_time() and print the total time of full collections.
2017-10-25Do not use system clock consistently if NO_CLOCKIvan Maidanski
Issue #139 (bdwgc). * alloc.c (GC_try_to_collect_inner, world_stopped_total_time, world_stopped_total_divisor, MAX_TOTAL_TIME_DIVISOR, GC_stopped_mark): Replace "ifndef SMALL_CONFIG" with "ifndef NO_CLOCK". * reclaim.c (GC_reclaim_all): Likewise. * alloc.c (GC_finish_collection): Replace "ifndef SMALL_CONFIG" with "ifndef NO_CLOCK" except for GC_print_finalization_stats invocation. * doc/README.macros (NO_CLOCK): Document. * include/private/gc_priv.h (CLOCK_TYPE, GET_TIME, MS_TIME_DIFF): Do not define if NO_CLOCK. * include/private/gc_priv.h (GC_print_stats): Define as a macro (to 0) only if both NO_CLOCK and SMALL_CONFIG are defined. * misc.c (GC_print_stats): Do not define if both NO_CLOCK and SMALL_CONFIG are defined. * misc.c (GC_init): Do not set GC_print_stats only if both NO_CLOCK and SMALL_CONFIG are defined. * tests/test.c (run_one_test): Do not define start_time, reverse_time, time_diff local variables (and do not use GET_TIME, MS_TIME_DIFF) if NO_CLOCK is defined.
2017-08-30Remove unnecessary type casts of printf arguments to unsigned longIvan Maidanski
(code refactoring) * alloc.c [!NO_DEBUGGING] (GC_print_heap_sects): Remove unnecessary cast to unsigned long in GC_*_printf call and adjust printf format specifier to match the argument type. * checksums.c [CHECKSUMS] (GC_checksum): Likewise. * mark.c [PARALLEL_MARK] (GC_mark_local): Likewise. * tests/test.c (typed_test): Likewise. * checksums.c [CHECKSUMS] (GC_checksum): Change type of GC_n_clean, GC_n_dirty from int to unsigned long.
2017-08-19Add assertion that no hb_n_marks underflow occursIvan Maidanski
Issue #177 (bdwgc). * alloc.c (GC_clear_fl_marks): Add GC_ASSERT that hhdr->hb_n_marks is non-zero before decrementing it. * mark.c (GC_clear_mark_bit): Likewise.
2017-08-14Remove redundant check that clear_fl_marks argument is non-nullIvan Maidanski
(code refactoring) * alloc.c (GC_clear_fl_marks): Do not check that q is not null (because it is checked by the caller).
2017-07-21New API function (GC_is_incremental_mode)Ivan Maidanski
* alloc.c (GC_is_incremental_mode): New public function definition. * include/gc.h (GC_full_freq): Update comment. * include/gc.h (GC_is_incremental_mode): New public function declaration. * tests/test.c [!GC_WIN32_THREADS && !GC_PTHREADS] (main): Print "Switched to incremental mode" and friend messages only if GC_is_incremental_mode(). * tests/test.c [!GC_PTHREADS] (main): Likewise.
2017-07-21Fix GC_incremental declaration/definition type mismatchIvan Maidanski
* alloc.c [!GC_DISABLE_INCREMENTAL] (GC_incremental): Change variable type from int to GC_bool (to match that of the declaration in gc_priv.h).
2017-01-19Add assertion to allocobj that live unmarked object cannot be reclaimedIvan Maidanski
* alloc.c (GC_allocobj): Add assertion before GC_continue_reclaim call that either GC_is_full_gc is FALSE or the corresponding ok_reclaim_list element is NULL (i.e. GC_continue_reclaim call is a no-op).
2016-10-24Workaround 'value of macro unknown' cppcheck info messagesIvan Maidanski
The messages are eliminated for the macros: __int64, _SIGRTMIN, ARM_THREAD_STATE32, ARM_UNIFIED_THREAD_STATE, FIXUP_POINTER, GC_COLLECT_AT_MALLOC, GC_FREE_SPACE_DIVISOR, GC_FULL_FREQ, GC_INITIAL_HEAP_SIZE, GC_MAX_RETRIES, GC_MAXIMUM_HEAP_SIZE, GC_MIN_MARKERS, GC_SIG_SUSPEND, GC_SIG_THR_RESTART, GC_TIME_LIMIT, HEURISTIC2_LIMIT, MAP_ANONYMOUS, RTLD_DI_LINKMAP, SAVE_CALL_COUNT, SIZE_MAX. * alloc.c (GC_full_freq, GC_free_space_divisor, GC_time_limit): Define to default immediate value if CPPCHECK. * darwin_stop_world.c [ARM32 && ARM_THREAD_STATE32] (GC_ARM_UNIFIED_THREAD_STATE): New macro (defined to ARM_UNIFIED_THREAD_STATE unless CPPCHECK). * darwin_stop_world.c [ARM32 && ARM_THREAD_STATE32] (GC_stack_range_for): Use GC_ARM_UNIFIED_THREAD_STATE; do not use value of ARM_THREAD_STATE32 if CPPCHECK. * dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_RTLD_DI_LINKMAP): New macro (defined to RTLD_DI_LINKMAP unless CPPCHECK). * dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_FirstDLOpenedLinkMap): Use GC_RTLD_DI_LINKMAP. * include/gc.h (GC_word, GC_signed_word): Do not define to __int64 if CPPCHECK. * include/gc.h (GC_INIT_CONF_MAX_RETRIES, GC_INIT_CONF_FREE_SPACE_DIVISOR, GC_INIT_CONF_FULL_FREQ, GC_INIT_CONF_TIME_LIMIT, GC_INIT_CONF_SUSPEND_SIGNAL, GC_INIT_CONF_THR_RESTART_SIGNAL, GC_MAXIMUM_HEAP_SIZE, GC_INITIAL_HEAP_SIZE): Define to empty if CPPCHECK. * include/private/gc_priv.h [SIZE_MAX] (GC_SIZE_MAX): Do not define to SIZE_MAX if CPPCHECK. * include/private/gc_priv.h [DARWIN && ARM32 && ARM_UNIFIED_THREAD_STATE] (GC_MACH_THREAD_STATE): Do not define to ARM_UNIFIED_THREAD_STATE if CPPCHECK. * include/private/gc_priv.h [GC_PTHREADS && _SIGRTMIN] (SIG_SUSPEND): Do not define to _SIGRTMIN if CPPCHECK. * pthread_stop_world.c [!SIG_THR_RESTART && _SIGRTMIN] (SIG_THR_RESTART): Likewise. * include/private/gcconfig.h [SAVE_CALL_CHAIN && SAVE_CALL_COUNT] (NFRAMES): Define to immediate value (do not use value of SAVE_CALL_COUNT) if CPPCHECK. * include/private/gcconfig.h [!FIXUP_POINTER && POINTER_MASK] (FIXUP_POINTER): Define to a sample expression (not using values of POINTER_MASK and POINTER_SHIFT) if CPPCHECK. * malloc.c [GC_COLLECT_AT_MALLOC] (GC_dbg_collect_at_malloc_min_lb): Define to sample value (not using value of GC_COLLECT_AT_MALLOC) if CPPCHECK. * misc.c [GC_INITIAL_HEAP_SIZE] (GC_init): Define to default immediate value if CPPCHECK. * os_dep.c [!BEOS && !OS2 && !SWIN32 && !GC_OPENBSD_THREADS && !STACKBOTTOM && HEURISTIC2_LIMIT] (GC_get_main_stack_base): Do not use value of HEURISTIC2_LIMIT if CPPCHECK. * os_dep.c [USE_MMAP_ANON && MAP_ANONYMOUS] (OPT_MAP_ANON): Do not use value of MAP_ANONYMOUS if CPPCHECK. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && !GC_TIME_LIMIT] (GC_TIME_LIMIT): Do not define. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_brief_async_signal_safe_sleep): Do not use value of GC_TIME_LIMIT if CPPCHECK. * pthread_support.c [PARALLEL_MARK && GC_MIN_MARKERS] (GC_thr_init): Do not use value of GC_MIN_MARKERS if CPPCHECK. * win32_threads.c [PARALLEL_MARK && GC_MIN_MARKERS] (GC_thr_init): Likewise. * tests/test.c [GC_DEBUG && SAVE_CALL_CHAIN && SAVE_CALL_COUNT] (check_heap_stats): Use NFRAMES instead of SAVE_CALL_COUNT (i.e. do not use value of SAVE_CALL_COUNT).
2016-10-21Eliminate 'printf format specifies type void*' GCC pedantic warningsIvan Maidanski
Explicitly cast pointer arguments (passed to printf and ABORT_ARGn) to void* to match %p format specifier. * allchblk.c [!NO_DEBUGGING] (GC_dump_regions): Cast arguments to void* those printf format specifier is %p. * alloc.c [!NO_DEBUGGING] (GC_print_heap_sects): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (backwards_height): Likewise. * blacklst.c (GC_default_print_heap_obj_proc): Likewise. * blacklst.c [PRINT_BLACK_LIST] (GC_print_blacklisted_ptr): Likewise. * cord/cordbscs.c (CORD_dump_inner): Likewise. * darwin_stop_world.c [DEBUG_THREADS_EXTRA] (GC_FindTopOfStack): Likewise. * darwin_stop_world.c [DEBUG_THREADS] (GC_stack_range_for): Likewise. * dbg_mlc.c (GC_print_obj): Likewise. * dbg_mlc.c [!SHORT_DBG_HDRS] (GC_print_smashed_obj): Likewise. * dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynamic_libraries_dl_iterate_phdr): Likewise. * dyn_load.c [IRIX5] (GC_register_dynamic_libraries): Likewise. * finalize.c [!NO_DEBUGGING] (GC_dump_finalization_links, GC_dump_finalization): Likewise. * include/private/gc_pmark.h [MARK_BIT_PER_GRANULE || MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR): Likewise. * mark.c [ENABLE_TRACE] (GC_mark_from): Likewise. * mark_rts.c [!NO_DEBUGGING] (GC_print_static_roots): Likewise. * mark_rts.c [DEBUG_ADD_DEL_ROOTS] (GC_add_roots_inner, GC_remove_root_at_pos): Likewise. * misc.c [ENABLE_TRACE] (GC_init): Likewise. * os_dep.c [LINUX || HURD] (GC_init_linux_data_start): Likewise. * os_dep.c [!OS2 && !MSWIN32] (GC_register_data_segments): Likewise. * os_dep.c [USE_MUNMAP && !USE_WINALLOC && !NACL] (GC_remap): Likewise. * os_dep.c [!DARWIN && !MSWIN32 && !MSWINCE] (GC_write_fault_handler): Likewise. * os_dep.c [PROC_VDB && DEBUG_DIRTY_BITS] (GC_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN && BROKEN_EXCEPTION_HANDLING] (catch_exception_raise): Likewise. * pthread_stop_world.c [DEBUG_THREADS] (GC_push_all_stacks): Likewise. * pthread_support.c [DEBUG_THREADS] (GC_unregister_my_thread_inner, GC_unregister_my_thread, GC_start_rtn_prepare_thread): Likewise. * reclaim.c [!NO_DEBUGGING] (GC_print_free_list): Likewise. * specific.c [USE_CUSTOM_SPECIFIC && GC_ASSERTIONS] (GC_check_tsd_marks): Likewise. * win32_threads.c [DEBUG_THREADS] (GC_push_stack_for): Likewise. * win32_threads.c [GC_PTHREADS && DEBUG_THREADS] (GC_pthread_join, GC_pthread_create, GC_pthread_start_inner, GC_thread_exit_proc): Likewise. * dbg_mlc.c: Remove duplicate check of SHORT_DBG_HDRS. * include/private/gc_pmark.h [MARK_BIT_PER_GRANULE || MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR): Add missing parentheses around "source" argument when casting it to ptr_t.
2016-10-14Eliminate more 'scope of variable can be reduced' cppcheck style warningsIvan Maidanski
* allchblk.c [MARK_BIT_PER_GRANULE] (setup_header): Move local variable declarations to the inner scope where the variables are actually used. * alloc.c [!SMALL_CONFIG] (GC_try_to_collect_inner, GC_finish_collection): Likewise. * alloc.c (GC_stopped_mark): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (add_edge): Likewise. * darwin_stop_world.c [GC_DARWIN_THREADS] (GC_push_all_stacks, GC_stop_world, GC_thread_resume): Likewise. * dyn_load.c [USE_PROC_FOR_LIBRARIES] (sort_heap_sects): Likewise. * dyn_load.c [ALPHA && OSF1 || HPUX] (GC_register_dynamic_libraries): Likewise. * dyn_load.c [DARWIN] (GC_dyld_image_add, GC_dyld_image_remove): Likewise. * extra/AmigaOS.c (GC_amiga_free_all_mem, GC_amiga_allocwrapper_any): Likewise. * extra/msvc_dbg.c (GetDescriptionFromAddress): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_core_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * include/new_gc_alloc.h (single_client_gc_alloc_template::deallocate, single_client_gc_alloc_template::ptr_free_deallocate, single_client_traceable_alloc_template::deallocate, single_client_traceable_alloc_template::ptr_free_deallocate): Likewise. * malloc.c [THREADS] (GC_free_inner): Likewise. * mark_rts.c (GC_add_roots_inner): Likewise. * misc.c (GC_clear_stack): Likewise. * os_dep.c [GWW_VDB] (GC_gww_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB] (GC_protect_heap): Likewise. * os_dep.c [PROC_VDB] (GC_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise): Likewise. * pthread_stop_world.c [GC_NETBSD_THREADS_WORKAROUND] (GC_start_world): Likewise. * pthread_support.c [!GC_NO_PTHREAD_SIGMASK] (pthread_sigmask): Likewise. * reclaim.c [!SMALL_CONFIG] (GC_reclaim_all): Likewise. * tests/test.c (run_one_test): Likewise. * tests/test.c [MACOS] (SetMinimumStack): Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC] (return_single_freelist): Likewise. * typd_mlc.c (GC_make_descriptor): Likewise. * win32_threads.c (GC_start_world, GC_CreateThread): Likewise. * win32_threads.c [!GC_PTHREADS_PARAMARK] (GC_start_mark_threads_inner): Likewise. * win32_threads.c [!MSWINCE && !CYGWIN32] (GC_beginthreadex): Likewise.
2016-10-04Eliminate more 'scope of variable can be reduced' cppcheck style warningsIvan Maidanski
* allchblk.c (GC_compute_large_free_bytes, GC_print_hblkfreelist, free_list_index_of, GC_dump_regions, GC_add_to_fl, GC_unmap_old, GC_allochblk_nth): Move local variable declaration to the inner scope where the variable is actually used. * alloc.c (GC_maybe_gc, GC_collect_a_little_inner, GC_set_fl_marks, GC_clear_fl_marks): Likewise. * dyn_load.c (GC_register_dynamic_libraries): Likewise. * finalize.c (GC_ignore_self_finalize_mark_proc, GC_register_finalizer_inner, GC_dump_finalization_links, GC_dump_finalization, GC_make_disappearing_links_disappear, GC_remove_dangling_disappearing_links, GC_invoke_finalizers): Likewise. * headers.c (GC_install_counts): Likewise. * malloc.c (GC_malloc_kind_global, GC_generic_malloc_uncollectable, GC_free): Likewise. * mark.c (GC_push_all_eager, GC_push_marked1, GC_push_marked2, GC_push_marked4): Likewise. * mark_rts.c (GC_next_exclusion, GC_exclude_static_roots_inner, GC_push_conditional_with_exclusions): Likewise. * misc.c (GC_base, GC_parse_mem_size_arg, GC_write): Likewise. * os_dep.c (GC_repeat_read, GC_get_maps, GC_least_described_address, GC_register_root_section, GC_register_data_segments): Likewise. * reclaim.c (GC_reclaim_block, GC_start_reclaim): Likewise. * finalize.c (ITERATE_DL_HASHTBL_BEGIN): Declare prev_dl local variable.
2016-09-27Code refactoring of divide-by-HBLKSIZE occurrencesIvan Maidanski
* alloc.c (GC_print_heap_sects): Replace "/HBLKSIZE" with divHBLKSZ. * blacklst.c (total_stack_black_listed): Likewise.
2016-09-27Fix GC_collect_or_expand to prevent allocation size value wrap-aroundIvan Maidanski
Relates to issue #135 on Github. * alloc.c (GC_WORD_MAX): New macro. * alloc.c (GC_collect_or_expand): Limit blocks_to_get by GC_WORD_MAX / HBLKSIZE value (to avoid multiplication overflow in GC_expand_hp_inner).
2016-09-23Fix malloc routines to prevent size value wrap-aroundIvan Maidanski
See issue #135 on Github. * allchblk.c (GC_allochblk, GC_allochblk_nth): Use OBJ_SZ_TO_BLOCKS_CHECKED instead of OBJ_SZ_TO_BLOCKS. * malloc.c (GC_alloc_large): Likewise. * alloc.c (GC_expand_hp_inner): Type of "bytes" local variable changed from word to size_t; cast ROUNDUP_PAGESIZE argument to size_t; prevent overflow when computing GC_heapsize+bytes > GC_max_heapsize. * dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc, GC_debug_generic_malloc_inner, GC_debug_generic_malloc_inner_ignore_off_page, GC_debug_malloc_stubborn, GC_debug_malloc_atomic, GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable): Use SIZET_SAT_ADD (instead of "+" operator) to add extra bytes to lb value. * fnlz_mlc.c (GC_finalized_malloc): Likewise. * gcj_mlc.c (GC_debug_gcj_malloc): Likewise. * include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES, ADD_SLOP, ROUNDUP_PAGESIZE): Likewise. * include/private/gcconfig.h (GET_MEM): Likewise. * mallocx.c (GC_malloc_many, GC_memalign): Likewise. * os_dep.c (GC_wince_get_mem, GC_win32_get_mem): Likewise. * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise. * headers.c (GC_scratch_alloc): Change type of bytes_to_get from word to size_t (because ROUNDUP_PAGESIZE_IF_MMAP result type changed). * include/private/gc_priv.h: Include limits.h (unless SIZE_MAX already defined). * include/private/gc_priv.h (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): Move from malloc.c file. * include/private/gc_priv.h (SIZET_SAT_ADD): New macro (defined before include gcconfig.h). * include/private/gc_priv.h (EXTRA_BYTES, GC_page_size): Change type to size_t. * os_dep.c (GC_page_size): Likewise. * include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES, ADD_SLOP, ROUNDUP_PAGESIZE): Add comment about the argument. * include/private/gcconfig.h (GET_MEM): Likewise. * include/private/gc_priv.h (ROUNDUP_GRANULE_SIZE, ROUNDED_UP_GRANULES, ADD_SLOP, OBJ_SZ_TO_BLOCKS, ROUNDUP_PAGESIZE, ROUNDUP_PAGESIZE_IF_MMAP): Rename argument to "lb". * include/private/gc_priv.h (OBJ_SZ_TO_BLOCKS_CHECKED): New macro. * include/private/gcconfig.h (GC_win32_get_mem, GC_wince_get_mem, GC_unix_get_mem): Change argument type from word to int. * os_dep.c (GC_unix_mmap_get_mem, GC_unix_get_mem, GC_unix_sbrk_get_mem, GC_wince_get_mem, GC_win32_get_mem): Likewise. * malloc.c (GC_alloc_large_and_clear): Call OBJ_SZ_TO_BLOCKS only if no value wrap around is guaranteed. * malloc.c (GC_generic_malloc): Do not check for lb_rounded < lb case (because ROUNDED_UP_GRANULES and GRANULES_TO_BYTES guarantees no value wrap around). * mallocx.c (GC_generic_malloc_ignore_off_page): Likewise. * misc.c (GC_init_size_map): Change "i" local variable type from int to size_t. * os_dep.c (GC_write_fault_handler, catch_exception_raise): Likewise. * misc.c (GC_envfile_init): Cast len to size_t when passed to ROUNDUP_PAGESIZE_IF_MMAP. * os_dep.c (GC_setpagesize): Cast GC_sysinfo.dwPageSize and GETPAGESIZE() to size_t (when setting GC_page_size). * os_dep.c (GC_unix_mmap_get_mem, GC_unmap_start, GC_remove_protection): Expand ROUNDUP_PAGESIZE macro but without value wrap-around checking (the argument is of word type). * os_dep.c (GC_unix_mmap_get_mem): Replace -GC_page_size with ~GC_page_size+1 (because GC_page_size is unsigned); remove redundant cast to size_t. * os_dep.c (GC_unix_sbrk_get_mem): Add explicit cast of GC_page_size to SBRK_ARG_T. * os_dep.c (GC_wince_get_mem): Change type of res_bytes local variable to size_t. * typd_mlc.c: Do not include limits.h. * typd_mlc.c (GC_SIZE_MAX, GC_SQRT_SIZE_MAX): Remove (as defined in gc_priv.h now).
2016-09-13Eliminate 'assigned value never used' CSA warning in min_bytes_allocdIvan Maidanski
The warning was reported only if GC_ALWAYS_MULTITHREADED. * alloc.c (min_bytes_allocd): Assign stack_size value for the single-threaded case only if GC_need_to_lock is false.
2016-07-22Fix missing new-line and redundant trailing dot in WARN messagesIvan Maidanski
* allchblk.c (GC_get_first_part, GC_allochblk_nth): Remove '.' before '\n' in WARN message. * os_dep.c (GC_read_dirty, GC_mprotect_thread, GC_dirty_init): Likewise. * win32_threads.c (GC_start_mark_threads_inner): Likewise. * alloc.c (GC_collect_or_expand): Remove space before '...' in WARN message. * dyn_load.c (GC_register_dynlib_callback): Add '\n' at the end of WARN message. * os_dep.c (GC_unix_mmap_get_mem, GC_unix_mmap_get_mem): Likewise.
2016-06-30Revert "Refactoring of GC_Xobjfreelist" partiallyIvan Maidanski
This reverts commit 41871b970c8fd9704835c1a221a8f9f1deea707a partially (GC_malloc_kind_global, GC_generic_malloc_uncollectable, GC_destroy_thread_local are not reverted).
2016-01-05Refactoring of GC_XobjfreelistAlessandro Bruni
(use single array to keep free lists of all kinds) * alloc.c: Update comment (replace GC_objfreelist with GC_freelists[NORMAL]). * checksums.c (GC_on_free_list): Replace GC_sobjfreelist with GC_freelists[STUBBORN]. * mark.c (GC_obj_kinds): Likewise. * include/private/gc_priv.h (PTRFREE, NORMAL, UNCOLLECTABLE, AUNCOLLECTABLE, STUBBORN, IS_UNCOLLECTABLE): Move definition upper to be before _GC_arrays declaration. * include/private/gc_priv.h (PREDEFINED_KINDS): New macro. * include/private/gc_priv.h (GC_freelists): New macro (of global variable if SEPARATE_GLOBALS). * include/private/gc_priv.h (_GC_arrays): Replace _objfreelist, _aobjfreelist, _uobjfreelist, _auobjfreelist, _sobjfreelist fields with single _freelists[] field. * include/private/gc_priv.h (GC_objfreelist, GC_aobjfreelist, GC_auobjfreelist, GC_sobjfreelist, GC_uobjfreelist, beginGC_objfreelist, endGC_objfreelist, beginGC_aobjfreelist, endGC_aobjfreelist): Remove macro. * include/private/gc_priv.h (GC_objfreelist, GC_aobjfreelist): Replace variable declarations with single GC_freelists[] one (if SEPARATE_GLOBALS). * malloc.c (GC_malloc_atomic): Replace GC_aobjfreelist with GC_freelists[PTRFREE]. * mallocx.c (GC_aobjfreelist_ptr): Likewise. * mark.c (GC_obj_kinds): Likewise. * thread_local_alloc.c (GC_destroy_thread_local): Likewise. * malloc.c (GC_malloc): Replace GC_objfreelist with GC_freelists[NORMAL]. * mallocx.c (GC_objfreelist_ptr): Likewise. * mark.c (GC_obj_kinds): Likewise. * thread_local_alloc.c (GC_destroy_thread_local): Likewise. * malloc.c (GC_malloc_uncollectable): Replace GC_uobjfreelist with GC_freelists[UNCOLLECTABLE]. * mallocx.c (GC_uobjfreelist_ptr): Likewise. * mark.c (GC_obj_kinds): Likewise. * mallocx.c (GC_auobjfreelist_ptr, GC_malloc_atomic_uncollectable): Replace GC_auobjfreelist with GC_freelists[AUNCOLLECTABLE]. * mark.c (GC_obj_kinds): Likewise. * misc.c (GC_init): Exclude whole GC_freelists from scanning instead of beginGC_objfreelist and beginGC_aobjfreelist (if SEPARATE_GLOBALS).
2015-10-22Fix lock assert violation in GC_gcollect_inner if GC_ALWAYS_MULTITHREADEDIvan Maidanski
* alloc.c (GC_expand_hp): Do not hold the allocation lock when calling GC_init. * malloc.c (GC_alloc_large, GC_generic_malloc_inner): Likewise. * mallocx.c (GC_generic_malloc_many): Likewise. * misc.c (GC_enable_incremental): Likewise. * misc.c (GC_init): Surround GC_gcollect_inner call with LOCK/UNLOCK (only if GC_ASSERTIONS and GC_ALWAYS_MULTITHREADED otherwise redundant).
2015-10-22Add assertion on lock status to GC_alloc_large and its callersIvan Maidanski
(code refactoring) * alloc.c (GC_try_to_collect_inner): Remove comment about expected lock status; add assertion about holding the allocation lock. * finalize.c (GC_grow_table): Likewise. * malloc.c (GC_alloc_large, GC_alloc_large_and_clear, GC_generic_malloc_inner, GC_generic_malloc_inner_ignore_off_page): Likewise. * misc.c (GC_new_free_list_inner): Likewise.
2015-09-10Fix 'comparison of non-null parameter is always false' warning (Clang)Ivan Maidanski
* alloc.c (GC_set_stop_func, GC_try_to_collect): Use NONNULL_ARG_NOT_NULL to check argument marked as non-null (in function declaration) is actually non-null. * finalize.c (GC_general_register_disappearing_link, GC_register_long_link, GC_move_disappearing_link, GC_move_long_link): Likewise. * misc.c (GC_set_warn_proc, GC_set_abort_func, GC_set_oom_fn): Likewise. * include/private/gc_priv.h (NONNULL_ARG_NOT_NULL): New macro.
2015-08-28Code refactoring of toggle-ref supportIvan Maidanski
* alloc.c (GC_stopped_mark): Move GC_process_togglerefs() call from GC_stop_world; do not call it if GC_NO_FINALIZATION or GC_TOGGLE_REFS_NOT_NEEDED. * darwin_stop_world.c (GC_stop_world): Remove GC_process_togglerefs() call. * pthread_stop_world.c (GC_stop_world): Likewise. * doc/README.macros (GC_TOGGLE_REFS_NOT_NEEDED): Document. * finalize.c (GCToggleRef, GC_process_togglerefs, push_and_mark_object, GC_clear_togglerefs, GC_toggleref_add): Replace GC_PTR with void*. * include/gc.h (GC_toggleref_add): Likewise. * finalize.c (GCToggleRef, GC_toggleref_callback, GC_toggleref_arr, GC_toggleref_array_size, GC_toggleref_array_capacity, GC_process_togglerefs, push_and_mark_object, GC_mark_togglerefs, GC_clear_togglerefs, GC_set_toggleref_func, ensure_toggleref_capacity, GC_toggleref_add): Do not defined if GC_TOGGLE_REFS_NOT_NEEDED. * finalize.c (GCToggleRef): Add comment. * finalize.c (GC_toggleref_array): Rename to GC_toggleref_arr. * finalize.c (GC_toggleref_callback, GC_toggleref_array, GC_toggleref_array_size, GC_toggleref_array_capacity): Make it STATIC (instead "static"). * finalize.c (GC_process_togglerefs): Decorate with GC_INNER; remove "toggle_ref_counts", "res" local variables; rename "w" local variable to "new_size"; add assertion on lock state; use GC_TOGGLE_REF_* enum element in switch statement; use BZERO to clear moved elements of GC_toggleref_arr. * finalize.c (GC_normal_finalize_mark_proc): Declare (before use). * finalize.c (push_and_mark_object): Replace PUSH_OBJ with GC_normal_finalize_mark_proc call. * finalize.c (GC_mark_togglerefs, GC_clear_togglerefs): Remove "object" local variable. * finalize.c (GC_toggleref_register_callback): Rename to GC_set_toggleref_func; change argument to GC_toggleref_func (which returns GC_ToggleRefStatus instead of int). * finalize.c (GC_toggleref_register_callback, GC_toggleref_add): Decorate with GC_API and GC_CALL. * include/gc.h (GC_toggleref_register_callback): Likewise. * finalize.c (GC_set_toggleref_func): Acquire allocation lock. * finalize.c (GC_get_toggleref_func): New API function. * finalize.c (ensure_toggleref_capacity): Rename "capacity" argument to "capacity_inc"; add assertion on argument value; rename "tmp" local variable to "new_array"; remove unused "old_capacity" variable; replace memcpy() with BCOPY() call. * finalize.c (GC_toggleref_add): Rename "strong_ref" argument to "is_strong_ref". * finalize.c (GC_finalize): Do not call GC_clear_togglerefs and GC_mark_togglerefs if GC_TOGGLE_REFS_NOT_NEEDED. * include/gc.h (GC_ToggleRefStatus, GC_toggleref_func): New type. * include/gc.h (GC_toggleref_register_callback): Add comment (including about locking). * include/gc.h (GC_get_toggleref_func): New API function declaration. * include/gc.h (GC_toggleref_add): Decorate with GC_CALL; add comment; add GC_ATTR_NONNULL attribute. * include/private/gc_priv.h (GC_process_togglerefs): Do not declare if GC_TOGGLE_REFS_NOT_NEEDED; decorate with GC_INNER.