summaryrefslogtreecommitdiff
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* Fix overlapping region assertion in mark_some if malloc redirect on LinuxIvan Maidanski2023-05-161-0/+1
| | | | | | | | | * alloc.c [SET_REAL_HEAP_BOUNDS && INCLUDE_LINUX_THREAD_DESCR] (GC_add_to_heap): If endp is greater than GC_greatest_real_heap_addr then add [p,endp) region to the data roots exclusions; add comment. * include/private/gc_priv.h [INCLUDE_LINUX_THREAD_DESCR] (SET_REAL_HEAP_BOUNDS, GC_least_real_heap_addr, GC_greatest_real_heap_addr): Define.
* Make comparisons to the lowest heap boundary strictIvan Maidanski2023-05-133-6/+7
| | | | | | | | | | | | | | | | | | | | | | * 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.
* Fix old name (typo) of gc_priv.hIvan Maidanski2023-05-131-1/+1
| | | | | | * blacklst.c: Fix old file name in comment ("gc_priv.h"). * include/private/gcconfig.h: Likewise. * tools/setjmp_t.c (main): Fix old file name in message ("gc_priv.h").
* Fix comparisons to heap boundary in GC_get_back_ptr_info and GC_mark_fromIvan Maidanski2023-05-132-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The region delimited by GC_least_plausible_heap_addr and GC_greatest_plausible_heap_addr might contain part of static data roots or stacks (in addition to potential heap expansion areas). Certain comparisons in GC_get_back_ptr_info (when ALIGNMENT is 1) and in GC_mark_from (in assertions) expect the real heap boundaries. * alloc.c [SET_REAL_HEAP_BOUNDS] (GC_add_to_heap): Update GC_least_real_heap_addr and GC_greatest_real_heap_addr variables. * dbg_mlc.c [KEEP_BACK_PTRS && ALIGNMENT == 1] (GC_get_back_ptr_info): Compare alternate_target and target 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). * include/gc/gc_mark.h (GC_greatest_plausible_heap_addr): Refine comment. * include/private/gc_priv.h [GC_ASSERTIONS || KEEP_BACK_PTRS && ALIGNMENT == 1] (SET_REAL_HEAP_BOUNDS): Define macro. * include/private/gc_priv.h [GC_ASSERTIONS || KEEP_BACK_PTRS && ALIGNMENT == 1] (GC_least_real_heap_addr, GC_greatest_real_heap_addr): Define (as macro). * include/private/gc_priv.h [GC_ASSERTIONS || KEEP_BACK_PTRS && ALIGNMENT == 1] (_GC_arrays._least_real_heap_addr, _GC_arrays._greatest_real_heap_addr): New field; add comment. * mark.c (GC_mark_from): Use GC_greatest_real_heap_addr and GC_least_real_heap_addr instead of GC_least_plausible_heap_addr and GC_greatest_plausible_heap_addr, respectively, in assertions.
* Fix 'AST broken' cppcheck syntax error in GC_init_linux_data_startIvan Maidanski2023-05-081-2/+6
| | | | | | | (fix of commit 2bcec83b6) * include/private/gcconfig.h [(MSWIN32 || MSWINCE) && CPPCHECK] (DATAEND): Do not define to empty.
* Remove code duplication in gcconfig.h for HurdIvan Maidanski2023-05-081-23/+21
| | | | | | | | | (refactoring) * include/private/gcconfig.h [HURD && (I386 || X86_64)] (OS_TYPE, HEURISTIC2, SEARCH_FOR_DATA_START, DATAEND, DYNAMIC_LOADING, USE_MMAP_ANON): Move defintion to common place. * include/private/gcconfig.h [HURD] (MPROTECT_VDB): Add TODO item.
* Support Hurd/x86_64Samuel Thibault2023-05-081-0/+14
| | | | | | | | | * include/private/gcconfig.h [__x86_64__ && __GNU__] (HURD, X86_64, mach_type_known): Define macro. * include/private/gcconfig.h [X86_64 && HURD] (OS_TYPE, HEURISTIC2, SEARCH_FOR_DATA_START, DATAEND, DYNAMIC_LOADING, USE_MMAP_ANON): Likewise. * include/private/gcconfig.h [X86_64 && HURD] (_end): Declare variable.
* Add API to get total stopped-world marking timeIvan Maidanski2023-05-041-2/+8
| | | | | | | | | | | | | | | | | | | | New public function is GC_get_stopped_mark_total_time(). * alloc.c [!NO_CLOCK] (stopped_mark_total_time, stopped_mark_total_ns_frac): New static variable. * alloc.c [!NO_CLOCK] (GC_get_stopped_mark_total_time): New API function definition. * alloc.c [!NO_CLOCK] (GC_stopped_mark): Define start_time_valid, ns_frac_diff local variables; call GET_TIME() also if measure_performance; add TODO item (about code duplication); update stopped_mark_total_time and stopped_mark_total_ns_frac values. * alloc.c (GC_stopped_mark): Move logging of "Marking for collection" upper to be before GET_TIME(start_time). * include/gc/gc.h (GC_get_full_gc_total_time): Refine documentation. * include/gc/gc.h (GC_get_stopped_mark_total_time): New API prototype. * tests/gctest.c [!NO_CLOCK] (check_heap_stats): Call GC_get_stopped_mark_total_time() to report total stopped-world marking time.
* Fix unused GC_parse_version if no SOFT_VDB and no parallel mark on LinuxIvan Maidanski2023-04-261-1/+1
| | | | | | | | | | (fix of commit 6e1b82b0a) * include/private/gc_priv.h [GLIBC_2_19_TSX_BUG && THREADS] (GC_parse_version): Do not declare unless GC_PTHREADS_PARAMARK. * os_dep.c [(!SOFT_VDB || NO_SOFT_VDB_LINUX_VER_RUNTIME_CHECK) && GLIBC_2_19_TSX_BUG && THREADS] (GC_parse_version): Do not define unless GC_PTHREADS_PARAMARK.
* New API for more optimal usage of GC_calloc_explicitly_typedIvan Maidanski2023-04-261-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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().
* Do incremental mark some in GC_collect_a_little even if GC is disabledIvan Maidanski2023-04-251-1/+3
| | | | | | | | | | | | | | | | | | | | Previous behavior was not documented but this API function did nothing in this case. That might cause a deadlock in the client code if the incremental collection was ongoing and the client called GC_collect_a_little() repeatedly (while the result is true). The new behavior, for the cause of disabled garbage collection, is to perform some amount of marking if the incremental collection is ongoing (but not stopping the world and, thus, not causing the memory reclaim to start), returning true if there is something more to mark. * alloc.c (GC_try_to_collect_inner): Change a loop to do-while one. * alloc.c (GC_collect_a_little): Do not check GC_dont_gc (i.e. call GC_collect_a_little_inner() unconditionally); add comment. * include/gc/gc.h (GC_collect_a_little): Update comment (describe the case when GC is disabled). * tests/gctest.c (check_heap_stats): Do not call GC_is_disabled(); add comment.
* Provide global non-throwing operator new/delete in gccpp libraryIvan Maidanski2023-04-201-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note: this might require define GC_INCLUDE_NEW by client before include gc_cpp.h on Windows hosts (to have nothrow_t declared before the global inline operator new and delete are defined). * gc_cpp.cc [(!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW) && !GC_INLINE_STD_NEW && GC_OPERATOR_NEW_NOTHROW] (operator new, operator delete): Define with nothrow_t argument. * gc_cpp.cc [(!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW) && !GC_INLINE_STD_NEW && GC_OPERATOR_NEW_ARRAY && !CPPCHECK && GC_OPERATOR_NEW_NOTHROW] (operator new[], operator delete[]): Likewise. * include/gc/gc_cpp.h [GC_INLINE_STD_NEW && GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_NEW_NOTHROW] (operator new[], operator delete[]): Likewise. * include/gc/gc_cpp.h [GC_INLINE_STD_NEW && GC_OPERATOR_NEW_NOTHROW] (operator new, operator delete): Likewise. * include/gc/gc_cpp.h [!GC_OPERATOR_NEW_NOTHROW && !GC_NO_OPERATOR_NEW_NOTHROW && (GC_INCLUDE_NEW && (__cplusplus>=201103L || _MSVC_LANG>=201103L) || __NOTHROW_T_DEFINED)] (GC_OPERATOR_NEW_NOTHROW): Define macro; add comment. * include/gc/gc_cpp.h [!GC_INLINE_STD_NEW && GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_NEW_NOTHROW] (operator new[], operator delete[]): Add prototype with nothrow_t argument (with commented out GC_ATTR_MALLOC). * include/gc/gc_cpp.h [!GC_INLINE_STD_NEW && GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_NOTHROW] (operator new, operator delete): Likewise.
* Define sized delete operator in 'gc' classIvan Maidanski2023-04-201-36/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc_cpp.cc [!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW] (operator delete): Replace __cplusplus>=201703L||_MSVC_LANG>=201703L to defined(GC_OPERATOR_SIZED_DELETE). * include/gc/gc_cpp.h [GC_INLINE_STD_NEW]: Likewise. * gc_cpp.cc [!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW] (GC_ALLOCATOR_THROW_OR_ABORT, operator new, operator delete, operator new[], operator delete[]): Do not define if GC_INLINE_STD_NEW. * gc_cpp.cc (operator new, operator delete): Reformat code. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && !GC_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (GC_INLINE_STD_NEW): Define macro. * include/gc/gc_cpp.h [!GC_NO_OPERATOR_SIZED_DELETE && !GC_OPERATOR_SIZED_DELETE && (__cplusplus>=201402L || _MSVC_LANG>=201402L)] (GC_OPERATOR_SIZED_DELETE): Likewise. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)]: Check GC_INLINE_STD_NEW instead. * include/gc/gc_cpp.h [GC_OPERATOR_SIZED_DELETE] (gc::operator delete(void*,GC_SIZE_T)): Declare. * include/gc/gc_cpp.h [GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_SIZED_DELETE] (gc::operator delete[](void*,GC_SIZE_T)): Likewise. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_SIZED_DELETE] (operator delete[](void*,GC_SIZE_T)): Likewise. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_SIZED_DELETE] (operator delete(void*,GC_SIZE_T)): Likewise. * include/gc/gc_cpp.h [GC_OPERATOR_SIZED_DELETE] (gc::operator delete(void*,GC_SIZE_T)): Define inline function. * include/gc/gc_cpp.h [GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_SIZED_DELETE] (gc::operator delete[](void*,GC_SIZE_T)): Likewise.
* Specify throw and noexcept for operator new/delete in gc_cpp.h for MS VCIvan Maidanski2023-04-191-5/+8
| | | | | | | | | | | | | | | | (fix of commit eb571cb86) * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_ARRAY] (operator new[]): Add GC_DECL_NEW_THROW. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER] (operator new): Likewise. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_ARRAY] (operator delete[]): Add GC_NOEXCEPT. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER] (operator delete): Likewise. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_ARRAY] (operator new[](size_t,int,const char*,int)): New prototype.
* Fix 'C++17 does not allow dynamic exc spec' warn if GC_NO_INLINE_STD_NEWIvan Maidanski2023-04-191-8/+14
| | | | | | | | | | | | | | | | | | | | (fix of commit 17364f061) * gc_cpp.cc: Do not include <new> directly. * gc_cpp.cc [!GC_INCLUDE_NEW] (GC_INCLUDE_NEW): Define macro. * gc_cpp.cc (GC_DECL_NEW_THROW): Move definition to gc_cpp.h. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (GC_DECL_INLINE_NEW_THROW): Do not define. * include/gc/gc_cpp.h [GC_NEW_DELETE_NEED_THROW && !(__cplusplus>=201703L || _MSVC_LANG>=201703L) && !GC_INCLUDE_NEW] (GC_DECL_NEW_THROW): Define to empty. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (operator new, operator new[]): Replace GC_DECL_INLINE_NEW_THROW attribute to GC_DECL_NEW_THROW.
* Fix 'size_t not found in namespace std' dmc error in gc_allocator.hIvan Maidanski2023-04-172-17/+33
| | | | | | | | | | | | | | | | | | | | | (fix of commit 08eb0da6f) * gc_cpp.cc (operator new, operator delete): Use GC_SIZE_T instead of std::size_t. * include/gc/gc_allocator.h (GC_ALCTR_PTRDIFF_T, GC_ALCTR_SIZE_T): Define macro (and undefine it at the end of file). * include/gc/gc_allocator.h (GC_selective_alloc, gc_allocator.size_type, gc_allocator.max_size, gc_allocator_ignore_off_page.size_type, gc_allocator_ignore_off_page.max_size, traceable_allocator.size_type, traceable_allocator.max_size): Use GC_ALCTR_SIZE_T instead of std::size_t. * include/gc/gc_allocator.h (gc_allocator.difference_type, gc_allocator_ignore_off_page.difference_type, traceable_allocator.difference_type): Use GC_ALCTR_PTRDIFF_T instead of std::ptrdiff_t. * include/gc/gc_cpp.h [GC_INCLUDE_NEW] (GC_PTRDIFF_T, GC_SIZE_T): Do not use std:: prefix unless __cplusplus>=201103L.
* Fix 'operator new is missing throw(bad_alloc)' clang warning in gc_cpp.hIvan Maidanski2023-04-171-2/+14
| | | | | | | | | | | | | | | | | The warning was reported on Window and only if __cplusplus < 201103L. * gc_cpp.cc [GC_NEW_DELETE_THROW_NOT_NEEDED && !GC_NEW_DELETE_NEED_THROW && GC_GNUC_PREREQ(4,2) && (__cplusplus<201103L || __clang__)] (GC_NEW_DELETE_NEED_THROW): Move definition to gc_cpp.h. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (GC_DECL_INLINE_NEW_THROW): New macro. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (operator new): Add GC_DECL_INLINE_NEW_THROW attribute.
* Prefix size_t and ptrdiff_t with namespace 'std' in C++ filesIvan Maidanski2023-04-172-128/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note: this affects gc_cpp.h only if GC_INCLUDE_NEW is defined (i.e. "new" header is included). * gc_cpp.cc (operator new, operator delete): Use std::size_t instead of size_t. * include/gc/gc_allocator.h (GC_selective_alloc, gc_allocator.size_type, gc_allocator.max_size, gc_allocator_ignore_off_page.size_type, gc_allocator_ignore_off_page.max_size, traceable_allocator.size_type, traceable_allocator.max_size): Likewise. * gc_cpp.cc (operator delete): Remove name of unused argument (and cast to void). * include/gc/gc_cpp.h (operator new, operator delete): Likewise. * gc_cpp.cc: Reformat code. * include/gc/gc_cpp.h: Likewise. * include/gc/gc_allocator.h (gc_allocator.difference_type, gc_allocator_ignore_off_page.difference_type, traceable_allocator.difference_type): Use std::ptrdiff_t instead of ptrdiff_t. * include/gc/gc_cpp.h (GC_PTRDIFF_T, GC_SIZE_T): New macro (depending on GC_INCLUDE_NEW). * include/gc/gc_cpp.h (operator new, operator delete): Use GC_SIZE_T instead of size_t. * include/gc/gc_cpp.h (gc_cleanup): Reformat comments. * include/gc/gc_cpp.h (gc_cleanup::cleanup): Use GC_PTRDIFF_T instead of ptrdiff_t. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && _MSC_VER] (operator new): Remove duplicate code.
* Ensure 'new' system header is included by gc_cpp.h if GC_INCLUDE_NEWIvan Maidanski2023-04-171-1/+4
| | | | | | * include/gc/gc_cpp.h [GC_INCLUDE_NEW]: Include <new> right after include gc.h (regardless of GC_NEW_ABORTS_ON_OOM and _LIBCPP_NO_EXCEPTIONS).
* Allow gc_allocator<T> and friends to be defined in namespace boehmgcIvan Maidanski2023-04-171-0/+9
| | | | | | | | | | | | | | | | The client should define GC_NAMESPACE_ALLOCATOR before include gc_allocator.h to have all symbols of the latter to be defined in namespace boehmgc. * docs/README.macros (GC_NAMESPACE_ALLOCATOR): Document. * include/gc/gc_allocator.h [GC_NAMESPACE_ALLOCATOR] (GC_true_type, GC_false_type, GC_type_traits, GC_DECLARE_PTRFREE, GC_selective_alloc, gc_allocator, gc_allocator_ignore_off_page, traceable_allocator): Define symbols (all) in boehmgc namespace. * tests/cpp.cc (GC_NAMESPACE_ALLOCATOR): Define macro (before include gc_allocator.h). * tests/cpp.cc (gc_allocator, gc_allocator_ignore_off_page, traceable_allocator): Using the symbol of namespace boehmgc.
* Replace C style comments to C++ ones in gc_allocator.hIvan Maidanski2023-04-171-19/+14
| | | | | * include/gc/gc_allocator.h (GC_true_type, GC_selective_alloc, traceable_allocator): Transform comment style to a C++ one.
* Allow align argument of GC_memalign to be smaller than pointer sizeIvan Maidanski2023-04-171-4/+6
| | | | | | | | | | | | (fix of commit ba137368d) This is largely to match the standard requirements on aligned_alloc(). * include/gc/gc.h (GC_memalign): Update comment. * mallocx.c (GC_memalign): Allow align to be less than a pointer size (provided it is non-zero). * mallocx.c (GC_memalign, GC_posix_memalign): Do not expect align argument is invalid.
* Redirect _aligned_malloc/free() in leak_detector.hIvan Maidanski2023-04-171-0/+5
| | | | | | | | | | * include/gc/leak_detector.h (_aligned_malloc, _aligned_free): Redefine macro. * include/gc/leak_detector.h (_aligned_free): Use GC_base (because GC_memalign might return a pointer inside the allocated object to ensure the requested alignment). * tests/leak.c (main): Call _aligned_malloc() and _aligned_free(); print error and exit in case of _aligned_malloc() failure.
* Do not add extra byte to large ignore-off-page objectsIvan Maidanski2023-04-122-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.
* Mark GC_add_roots_inner() as GC_INNERIvan Maidanski2023-04-121-0/+5
| | | | | | | | (refactoring) * include/private/gc_priv.h [!AMIGA] (GC_add_roots_inner): Declare as GC_INNER. * mark_rts.c [!AMIGA] (GC_add_roots_inner): Define as GC_INNER.
* Add assertion about GC lock to GC_add_roots_inner and its callersIvan Maidanski2023-04-121-0/+1
| | | | | | | | | | | | | | | | | | | | (refactoring) Also, add the assertion to GC_roots_present() and COND_DUMP_CHECKS(). * dyn_load.c [HAVE_DL_ITERATE_PHDR && PT_GNU_RELRO] (GC_register_dynlib_callback): Add assertion that GC lock is held. * dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynamic_libraries_dl_iterate_phdr): Likewise. * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_cond_add_roots): Likewise. * dyn_load.c [ALPHA && OSF1 || HPUX || AIX || HAIKU] (GC_register_dynamic_libraries): Likewise. * include/private/gc_priv.h (COND_DUMP_CHECKS): Likewise. * mark_rts.c (GC_roots_present, GC_add_roots_inner): Likewise. * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_cond_add_roots): Check THREADS instead of GC_WIN32_THREADS; check base==limit before stack_top assignment.
* Acquire GC lock in GC_is_tmp_rootIvan Maidanski2023-04-111-0/+2
| | | | | | | | | | * include/gc/gc_mark.h (GC_is_tmp_root): Document function. * include/gc/gc_mark.h (GC_is_tmp_root): Add comment that the function acquires the GC lock. * mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Likewise. * mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Define res local variable; change code to have only single return statement; wrap code into LOCK/UNLOCK.
* Document assumption about GC lock for GC_clear_exclusion_tableIvan Maidanski2023-04-111-0/+1
| | | | | | | * include/gc/gc.h (GC_clear_exclusion_table): Add comment about GC lock. * mark_rts.c (GC_clear_exclusion_table): Likewise. * mark_rts.c (GC_clear_exclusion_table): Copy comment from gc.h.
* Refine comment of GC_print_free_list regarding GC lockIvan Maidanski2023-04-101-2/+3
| | | | | | | | (documentation) * include/gc/gc_inline.h (GC_print_free_list): Add comment about assumption about the GC lock. * reclaim.c (GC_print_free_list): Likewise.
* Refine documentation of GC_register_disclaim_proc and GC_finalized_mallocIvan Maidanski2023-04-101-21/+21
| | | | | * include/gc/gc_disclaim.h (GC_register_disclaim_proc, GC_finalized_malloc): Refine comment.
* Do not prohibit zero proc argument in GC_register_disclaim_procIvan Maidanski2023-04-101-1/+1
| | | | | | | | | | | (fix of commit 1d3675499) * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_register_disclaim_proc): Do not check that proc is non-zero. * include/gc/gc_disclaim.h (GC_register_disclaim_proc): Remove GC_ATTR_NONNULL(2) attribute. * reclaim.c [ENABLE_DISCLAIM] (GC_disclaim_and_reclaim): Add assertion that disclaim is non-zero.
* Acquire lock in GC_register_disclaim_procIvan Maidanski2023-04-101-1/+1
| | | | | | | | | GC_obj_kinds should be updated with the allocation lock held. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_register_disclaim_proc): Wrap the code into LOCK/UNLOCK. * include/gc/gc_disclaim.h (GC_register_disclaim_proc): Add comment that the function acquires the lock.
* Refine comparisons to GC_greatest_plausible_heap_addrIvan Maidanski2023-04-091-4/+5
| | | | | | | | | | | | | | | | | | 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.
* Fix null pointer dereference in TRACE_TARGETIvan Maidanski2023-04-091-1/+2
| | | | | * include/private/gc_pmark.h [ENABLE_TRACE] (TRACE_TARGET): Do not dereference GC_trace_addr if it is not a pointer to a heap object.
* Fix signals delivery fail in find-leak mode if init from non-main threadIvan Maidanski2023-04-062-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #542 (bdwgc). The scenario of the failure (on Linux): - Find-leak mode is on - pthread_create/join primitives are not redirected - GC is initialized from a thread other than primordial - that thread is terminated (but not unregistered as the 1st one in GC) - the primordial thread exits and launches GC_exit_check - GC_gcollect tries to suspend the terminated thread by sending a signal - the signal is not delivered but pthread_kill just returns zero - the signal sending is retried until aborting with the proper message. The proposed solution (workaround) is not to call GC_gcollect at the process exit (in the find-leak mode) if GC_init was called from a thread other than primordial one. Check in GC_exit_check() (which is called if GC_find_leak) that the thread executing at-exit functions is the same as the one performed the GC initialization, otherwise the latter thread might already be dead but still registered and this, as a consequence, might cause a signal delivery fail when suspending the threads on platforms that do not guarantee ESRCH returned if the signal is not delivered (as observed on Ubuntu 22). * include/private/gc_priv.h [THREADS && !DONT_USE_ATEXIT] (GC_is_main_thread): Declare GC_INNER function. * include/private/pthread_support.h [GC_WIN32_THREADS && !DONT_USE_ATEXIT] (GC_main_thread_id): Declare variable. * include/private/pthread_support.h [GC_WIN32_THREADS && !GC_NO_THREADS_DISCOVERY] (GC_main_thread_id): Do not depend on GC_ASSERTIONS. * misc.c [!DONT_USE_ATEXIT && THREADS] (GC_exit_check): If not GC_is_main_thread() or not GC_thread_is_registered() then do not call GC_gcollect(); add comment; do not set and clear GC_in_thread_creation. * pthread_support.c [!GC_NO_THREADS_DISCOVERY && GC_WIN32_THREADS || !DONT_USE_ATEXIT] (GC_main_thread_id): Define variable. * pthread_support.c [!DONT_USE_ATEXIT] (GC_is_main_thread): Implement. * pthread_support.c [!GC_WIN32_THREADS] (GC_thr_init): Define self_id local variable. * pthread_support.c [!GC_WIN32_THREADS && !DONT_USE_ATEXIT] (GC_thr_init): Set GC_main_thread_id. * win32_threads.c [!DONT_USE_ATEXIT] (GC_thr_init): Likewise. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_main_thread_id): Do not define variable.
* Eliminate 'atomic_thread_fence is unsupported with tsan' gcc-11 warningIvan Maidanski2023-03-301-1/+24
| | | | | | | | | | | | | | | The workaround is to use __atomic_test_and_set instead of __atomic_thread_fence in case of option -fsanitize=thread is passed to gcc (or clang). The old behavior could be turned on by defining AO_USE_ATOMIC_THREAD_FENCE macro. * include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC && !GC_PRIVATE_H && !THREAD_SANITIZER && (__has_feature(thread_sanitizer) || __SANITIZE_THREAD__)] (THREAD_SANITIZER): Define. * include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC && THREAD_SANITIZER && !AO_USE_ATOMIC_THREAD_FENCE] (AO_nop_full): Define as inline function using __atomic_test_and_set() on a dummy local variable (instead of __atomic_thread_fence usage).
* Do not add extra byte to non-small uncollectible objectsIvan Maidanski2023-03-251-1/+2
| | | | | | | | | | | | Previously EXTRA_BYTES value was not added to the allocation size only for small uncollectible objects. * include/gc/gc.h (GC_all_interior_pointers): Refine comment (regarding uncollectible objects). * malloc.c (GC_generic_malloc_uncollectable): Define lb_orig local variable; decrement lb before if(SMALL_OBJ(lb)); do not expect original lb is zero; pass lb_orig (instead of lb) to GC_DBG_COLLECT_AT_MALLOC() and to oom_fn().
* Rename ROUNDED_UP_GRANULES macro to ALLOC_REQUEST_GRANSIvan Maidanski2023-03-242-13/+16
| | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * include/gc/gc_tiny_fl.h (GC_RAW_BYTES_FROM_INDEX): Update comment (rename ROUNDED_UP_GRANULES to ALLOC_REQUEST_GRANS). * include/private/gc_priv.h (ADD_SLOP): Rename to ADD_EXTRA_BYTES; move definition upper (to be before ALLOC_REQUEST_GRANS). * include/private/gc_priv.h (ROUNDED_UP_GRANULES): Rename to ALLOC_REQUEST_GRANS; refine comment. * include/private/gc_priv.h (SMALL_OBJ): Remove extra parentheses; add comment. * include/private/gc_priv.h (_GC_arrays._size_map): Refine comment. * malloc.c (GC_extend_size_map, GC_generic_malloc_aligned): Rename ROUNDED_UP_GRANULES to ALLOC_REQUEST_GRANS. * misc.c (GC_init_size_map): Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_malloc_kind): Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC && GC_GCJ_SUPPORT] (GC_gcj_malloc): Likewise. * malloc.c (GC_generic_malloc_inner): Rename ADD_SLOP to ADD_EXTRA_BYTES. * mallocx.c (GC_realloc): Likewise. * mallocx.c (GC_malloc_many): Define lg local variable; use ALLOC_REQUEST_GRANS() and GRANULES_TO_BYTES(); remove comment.
* Avoid code duplication in IGNORE_OFF_PAGE-specific malloc functionsIvan Maidanski2023-03-241-19/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Move increment of GC_bytes_allocd to GC_alloc_largeIvan Maidanski2023-03-221-6/+6
| | | | | | | | | | | | | | | | | | | | | (refactoring) * include/private/gc_priv.h (GC_alloc_large): Update comment (mention that GC_bytes_allocd is updated too). * malloc.c (GC_alloc_large_and_clear): Likewise. * include/private/gc_priv.h (GC_allocobj): Rename sz argument to gran; update comment. * malloc.c (GC_alloc_large): Increment GC_bytes_allocd (by rounded lb). * malloc.c (GC_generic_malloc_inner): Reformat code; remove lb_adjusted local variable. * malloc.c (GC_generic_malloc_inner_ignore_off_page, GC_generic_malloc_inner, GC_generic_malloc_aligned): Do not update GC_bytes_allocd. * mallocx.c (GC_generic_malloc_ignore_off_page): Likewise. * malloc.c (GC_generic_malloc_inner_ignore_off_page): Remove op and lb_adjusted local variables. * mallocx.c (GC_generic_malloc_ignore_off_page): Remove lb_rounded local variable.
* Fix description of client promise for IGNORE_OFF_PAGE allocated objectsIvan Maidanski2023-03-204-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | (documentation) The client should keep a pointer within the first heap block for such an allocated object. Previously, it was mentioned in the documentation and comments that such a pointer should be within the first 256 or 512 bytes. * README.md (The C Interface to the Allocator): Fix the description (comment) of GC_malloc_ignore_off_page (the client promises to keep a pointer within the first hblk of the object instead of 256 or 512 bytes, or a page). * docs/gcinterface.md (GC_MALLOC_IGNORE_OFF_PAGE): Likewise. * gc.man (GC_malloc_atomic_ignore_off_page): Likewise. * include/gc/gc.h (GC_malloc_ignore_off_page): Likewise. * include/gc/gc_mark.h (GC_generic_malloc_ignore_off_page): Likewise. * include/private/gc_priv.h (IGNORE_OFF_PAGE): Likewise. * include/private/gc_priv.h [DBG_HDRS_ALL || GC_GCJ_SUPPORT || !GC_NO_FINALIZATION] (GC_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. * include/gc/gc_gcj.h (GC_gcj_malloc_ignore_off_page): Refine comment.
* New API for disappearing links registration accepting interior pointersIvan Maidanski2023-03-181-3/+11
| | | | | | | | | | | | | | GC_GENERAL_REGISTER_DISAPPEARING_LINK_SAFE() and GC_REGISTER_LONG_LINK_SAFE() macros are provided. * include/gc/gc.h (GC_GENERAL_REGISTER_DISAPPEARING_LINK_SAFE, GC_REGISTER_LONG_LINK_SAFE): New API macros. * include/gc/gc.h [GC_DEBUG] (GC_GENERAL_REGISTER_DISAPPEARING_LINK): Use GC_GENERAL_REGISTER_DISAPPEARING_LINK_SAFE() instead of GC_general_register_disappearing_link() and GC_base() directly. * include/gc/gc.h [GC_DEBUG] (GC_REGISTER_LONG_LINK): Use GC_REGISTER_LONG_LINK_SAFE() instead of GC_register_long_link() and GC_base() directly.
* Fix mistyped GC_register_finalizer[_unreachable] in commentsIvan Maidanski2023-03-181-1/+1
| | | | | | | | (fix of commits 074de161d, f69ca1a96) * dbg_mlc.c (store_old): Fix name in comment ("GC_register_finalizer"). * include/gc/gc.h (GC_java_finalization): Fix name in comment ("GC_register_finalizer_unreachable").
* Better document link argument of GC_general_register_disappearing_linkIvan Maidanski2023-03-181-4/+5
| | | | | * include/gc/gc.h (GC_general_register_disappearing_link): Improve comment to outline that link could be in any memory.
* Define GC_print_stats as GC_INNERIvan Maidanski2023-03-161-3/+3
| | | | | | | | | | | | | | (refactoring) * extra/MacOS.c [USE_TEMPORARY_MEMORY && !SHARED_LIBRARY_BUILD] (GC_MacFreeTemporaryMemory): Do not use GC_print_stats (assume it is always zero). * include/private/gc_priv.h [!NO_CLOCK || !SMALL_CONFIG] (GC_print_stats): Declared as GC_EXTERN; refine comment. * misc.c [!NO_CLOCK || !SMALL_CONFIG] (GC_print_stats): Define as GC_INNER. * tests/gctest.c [!GC_PRINT_VERBOSE_STATS && !GCTEST_PRINT_VERBOSE] (GC_print_stats): Update comment.
* Move platform-dependent getspecific() call to a dedicated functionIvan Maidanski2023-03-101-1/+1
| | | | | | | | | | | | (refactoring) * include/private/thread_local_alloc.h: Reformat comment. * pthread_stop_world.c [NACL] (GC_nacl_gc_thread_sel): Add TODO item. * pthread_support.c (GC_thread_is_registered): Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_get_tlfs): New STATIC function (move part of code from GC_malloc_kind). * thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_malloc_kind): Use GC_get_tlfs().
* Fix GC_thread_is_registered for finished threadsIvan Maidanski2023-03-101-0/+2
| | | | | | | | | | | | | (fix of commit 83c1eecd0) A finished thread may still stay in GC_threads, but it is no longer considered during a garbage collection phase, thus GC_thread_is_registered() should return false in such a case. * include/gc/gc.h [GC_THREADS] (GC_thread_is_registered): Refine comment (describe the case when the thread is marked as finished). * pthread_support.c (GC_thread_is_registered): Define and set me local variable; return FALSE if KNOWN_FINISHED(me).
* Remove MAIN_THREAD flag in GC_threadIvan Maidanski2023-03-093-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c (GC_stack_range_for): Do not check MAIN_THREAD bit of p->flags. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_set_stackbottom, GC_get_my_stackbottom): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_call_with_gc_active): Likewise. * darwin_stop_world.c (GC_stack_range_for): Do not use GC_stackbottom. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_get_my_stackbottom): Likewise. * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Do not check GC_stackbottom if THREADS. * include/gc/gc.h (GC_stackbottom): Refine comment (mention that it could be change only before GC initialization if multi-threaded, mention GC_set_stackbottom). * include/private/gcconfig.h [IA64 && (HPUX || LINUX)] (BACKING_STORE_BASE): Remove. * include/private/pthread_support.h [!GC_WIN32_THREADS] (MAIN_THREAD): Likewise. * mark_rts.c [!THREADS && IA64] (GC_push_current_stack): Use GC_register_stackbottom instead of BACKING_STORE_BASE. * pthread_stop_world.c [IA64] (GC_push_all_stacks): Do not use BACKING_STORE_BASE (GC_register_stackbottom). * pthread_support.c [!GC_WIN32_THREADS] (GC_thr_init): Do not set MAIN_THREAD bit of me->flags. * pthread_support.c (GC_set_stackbottom, GC_get_my_stackbottom): Move crtn local variable to outer scope. * pthread_support.c [!GC_WIN32_THREADS] (GC_set_stackbottom): Do not set GC_stackbottom (and GC_register_stackbottom) if GC is initialized. * pthread_support.c [!GC_WIN32_THREADS && IA64] (GC_get_my_stackbottom): Do not use GC_register_stackbottom. * pthread_support.c (GC_call_with_gc_active): Move stack_end local variable to outer scope. * pthread_support.c [!GC_WIN32_THREADS] (GC_call_with_gc_active): Do not use and set GC_stackbottom.
* Do not hard-code page size for wasm32-wasiBruce Mitchener2023-03-061-3/+0
| | | | | | | | | | | | | | | (refactoring) PR #534 (bdwgc). Instead of defining GETPAGESIZE() for WASI, we can do what we do in Emscripten and other targets and just fall back to the default handling of this which invokes getpagesize(). * include/private/gcconfig.h [WEBASSEMBLY]: Remove comment about page size. * include/private/gcconfig.h [WEBASSEMBLY && WASI] (GETPAGESIZE): Remove explicit definition.
* Define GC_self_thread_inner to lookup GC_thread of current threadIvan Maidanski2023-03-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * include/private/pthread_support.h (GC_self_thread_inner): New macro. * pthread_stop_world.c (GC_lookup_thread_async): Replace to no-arg GC_lookup_self_thread_async(); update comment. * pthread_stop_world.c (GC_suspend_handler_inner): Remove self local variable, use pthread_self() instead. * pthread_stop_world.c [NACL] (__nacl_suspend_thread_if_needed): Likewise. * pthread_stop_world.c (GC_suspend_handler_inner): Call GC_lookup_self_thread_async() instead of GC_lookup_thread_async(self). * pthread_stop_world.c [NACL] (GC_nacl_shutdown_gc_thread): Do not use GC_lookup_thread(pthread_self()) in assertion. * win32_threads.c (GC_thr_init): Likewise. * pthread_support.c (GC_self_thread): New STATIC function. * pthread_support.c [!GC_NO_FINALIZATION] (GC_reset_finalizer_nested): Remove me local variable. * pthread_support.c [!GC_NO_FINALIZATION] (GC_reset_finalizer_nested, GC_check_finalizer_nested): Call GC_self_thread_inner() instead of GC_lookup_thread(thread_id_self()). * pthread_support.c [!GC_WIN32_THREADS] (GC_register_altstack, GC_thr_init): Likewise. * pthread_support.c [THREAD_LOCAL_ALLOC] (GC_init_parallel): Likewise. * pthread_support.c (GC_do_blocking_inner, GC_set_stackbottom, GC_get_stackbottom, GC_call_with_gc_active, GC_unregister_my_thread, GC_register_my_thread): Likewise. * pthread_support.c [GC_HAVE_PTHREAD_EXIT] (GC_pthread_exit): Likewise. * pthread_support.c [GC_ASSERTIONS && THREAD_LOCAL_ALLOC] (GC_is_thread_tsd_valid): Use GC_self_thread() instead of locking and GC_lookup_thread(thread_id_self()). * pthread_support.c (GC_thread_is_registered): Likewise. * pthread_support.c [GC_ASSERTIONS] (GC_allow_register_threads): Likewise. * pthread_support.c (GC_thread_is_registered, GC_get_stackbottom, GC_call_with_gc_active, GC_unregister_my_thread, GC_register_my_thread): Remove self_id local variable. * pthread_support.c [!GC_WIN32_THREADS] (GC_register_altstack, GC_thr_init): Likewise. * pthread_support.c [GC_HAVE_PTHREAD_EXIT] (GC_pthread_exit): Likewise.