Ivan Maidanski [Sun, 1 Dec 2013 15:01:46 +0000 (19:01 +0400)]
New macro (GC_ALWAYS_MULTITHREADED) to set multi-threaded mode implicitly
* darwin_stop_world.c (GC_use_threads_discovery): Skip assertion on
GC_need_to_lock if GC_ALWAYS_MULTITHREADED.
* misc.c (GC_init): Likewise.
* doc/README.macros (GC_ALWAYS_MULTITHREADED): Document.
* include/gc.h (GC_allow_register_threads): Update comment (regarding
GC_ALWAYS_MULTITHREADED).
* include/private/gc_locks.h (I_HOLD_LOCK): Reformat code.
* include/private/gc_locks.h (GC_need_to_lock): Define as macro
(to TRUE) if GC_ALWAYS_MULTITHREADED defined.
* include/private/gc_locks.h (LOCK, UNLOCK): Define to UNCOND_[UN]LOCK
if GC_ALWAYS_MULTITHREADED.
* misc.c (GC_init): Call GC_init_parallel() if GC_ALWAYS_MULTITHREADED
but not GC_NO_THREADS_DISCOVERY (only for Win32, needed since
GC_allow_register_threads does nothing if GC_ALWAYS_MULTITHREADED).
* misc.c (IF_NEED_TO_LOCK): Ignore GC_parallel if
GC_ALWAYS_MULTITHREADED (since GC_need_to_lock is always true).
* pthread_support.c (GC_need_to_lock): Do not define varaible if
GC_ALWAYS_MULTITHREADED (since defined as a macro).
* win32_threads.c (GC_need_to_lock): Likewise.
* pthread_support.c (GC_allow_register_threads, pthread_create): Do
not alter value of GC_need_to_lock if GC_ALWAYS_MULTITHREADED.
* win32_threads.c (GC_allow_register_threads, GC_CreateThread,
GC_beginthreadex, GC_pthread_create, GC_init_parallel): Likewise.
* win32_threads.c (GC_allow_register_threads): Do not alter
"parallel_initialized" value if GC_ALWAYS_MULTITHREADED (so that
GC_allow_register_threads is a no-op if the macro defined).
Ivan Maidanski [Sat, 23 Nov 2013 20:16:38 +0000 (00:16 +0400)]
Fix 'Bad signal in suspend_handler' abort on FreeBSD-9.2
* pthread_stop_world.c (GC_suspend_handler_inner): If signal number
is zero then silently return (instead of ABORT) if FREEBSD (to
workaround a bug in FreeBSD 9.2-RELEASE regarding signals processing,
bug is observed only if THREAD_LOCAL_ALLOC defined).
Ivan Maidanski [Thu, 21 Nov 2013 22:37:37 +0000 (02:37 +0400)]
Allow to force GC_dump_regularly set on at compilation
* doc/README.macros (GC_DUMP_REGULARLY): Document.
* misc.c (GC_dump_regularly): Turn on by default if GC_DUMP_REGULARLY
macro defined (but not NO_DEBUGGING) - useful for embedded environments.
* misc.c (GC_init): Skip "GC_DUMP_REGULARLY" environments variable check
if GC_dump_regularly already set by the corresponding macro (only if not
NO_DEBUGGING).
Ivan Maidanski [Sat, 16 Nov 2013 09:06:34 +0000 (13:06 +0400)]
Enable prefetch operations by default (GCC 3.0+)
* include/private/gcconfig.h (PREFETCH): Update comment; remove FIXME.
* include/private/gcconfig.h (NO_PREFETCH_FOR_WRITE): Define if
USE_I686_PREFETCH defined but not FORCE_WRITE_PREFETCH.
* include/private/gcconfig.h (PREFETCH, PREFETCH_FOR_WRITE,
CLEAR_DOUBLE): Reformat code (for IA64).
* include/private/gcconfig.h (PREFETCH, PREFETCH_FOR_WRITE): Make
default definition to GCC (v3+) built-in operation for all platforms
(instead of only for Linux/x64) unless NO_PREFETCH (or
NO_PREFETCH_FOR_WRITE, respectively) defined.
Ivan Maidanski [Mon, 11 Nov 2013 18:32:18 +0000 (22:32 +0400)]
Workaround 'ELF_DATA/EM_ALPHA redefined' warning in Android link.h
(revert part of commit a6e4ee9)
* dyn_load.c: Include asm/elf.h and linux/elf-em.h explicitly, and
undefine ELF_DATA and EM_ALPHA (if PLATFORM_ANDROID and
BIONIC_ELFDATA_REDEF_BUG are defined) to avoid "macro redefined"
warnings reported for link.h of Android Bionic.
Ivan Maidanski [Sat, 9 Nov 2013 07:56:35 +0000 (11:56 +0400)]
Fix dyn_load.c compilation for Android 4.3
* dyn_load.c (struct link_map, r_debug): Define explicitly (matching
that of Android 4.2 Bionic) instead of include linker.h (only if
PLATFORM_ANDROID); remove workaround enabled by
BIONIC_ELFDATA_REDEF_BUG regarding ELF_DATA redefinition (as linker.h
is not included); update comment.
Ivan Maidanski [Sat, 9 Nov 2013 07:37:09 +0000 (11:37 +0400)]
Eliminate GCC warning about uninitialized 'hhdr' in GC_allochblk_nth
* allchblk.c (GC_allochblk_nth): Replace "for" condition with
conditional "return" since otherwise GCC reports
"'hhdr' may be used uninitialized" warning in case of -O0 optimization
level; remove comment about bogus compiler warning; refine comment
for "thishdr" local variable.
Ivan Maidanski [Mon, 16 Sep 2013 04:50:49 +0000 (08:50 +0400)]
Fix race in GC_print_all_errors regarding GC_leaked
* reclaim.c (GC_add_leaked): Remove FIXME.
* reclaim.c (GC_print_all_errors): Declare n_leaked, leaked[] local
variables initialized from GC_[n_]leaked while holding the allocation
lock (reset GC_n_leaked and GC_leaked[] as well); add GC_ASSERT for
n_leaked; use [n_]leaked while printing leaked objects count and
pointers.
* reclaim.c (GC_print_all_errors): Acquire lock to reset
printing_errors.
Ivan Maidanski [Fri, 6 Sep 2013 19:36:39 +0000 (23:36 +0400)]
Fix collection of objects referenced only from GC_mark_stack_X variables
(Apply commit a7a5666 from 'release-7_2' branch.)
* include/private/gc_pmark.h (mse): Move to gc_priv.h (as used by
GC_mark_stack_limit, GC_mark_stack_top, GC_mark_stack).
* include/private/gc_pmark.h (GC_mark_stack_limit, GC_mark_stack_top,
GC_mark_stack): Remove variable declaration.
* include/private/gc_priv.h (_GC_arrays): Add _mark_stack,
_mark_stack_limit, _mark_stack_top fields.
* include/private/gc_priv.h (GC_mark_stack_limit, GC_mark_stack_top,
GC_mark_stack): Define macro (redirecting to the corresponding field
of GC_arrays).
* mark.c (GC_mark_stack, GC_mark_stack_limit, GC_mark_stack_top):
Remove variable; move comment to gc_priv.h.
* mark.c (GC_push_marked1, GC_push_marked2, GC_push_marked4): Undefine
GC_mark_stack_top and GC_mark_stack_limit macros (before redefining
them to local variables) at function start, redefine them back to the
corresponding field of GC_arrays at function exit.
Ivan Maidanski [Sun, 1 Sep 2013 16:06:38 +0000 (20:06 +0400)]
Prevent misleading AC_MSG_ERROR/AS_IF errors reported in configure.ac
* configure.ac (PKG_CHECK_MODULES): Move AS_IF and AC_MSG_ERROR out of
ACTION-IF-NOT-FOUND argument (setting "missing_libatomic_ops" variable
instead) to prevent misleading
"possibly undefined macro: AC_MSG_ERROR, AS_IF" error reported by
Autoconf (pointing to code lines where these macros first occur) in
case of PKG_CHECK_MODULES is not defined in aclocal.m4; add comment
about missing Autotools pkg.m4 file.
Ivan Maidanski [Sun, 1 Sep 2013 10:00:08 +0000 (14:00 +0400)]
Replace deprecated [CXX]INCLUDES to AM_C[PP]FLAGS in configure.ac
* configure.ac (INCLUDES): Replace with AM_CFLAGS (as the former is
deprecated in Automake 1.13.4).
* configure.ac (CXXINCLUDES): Replace with AM_CPPFLAGS.
Ivan Maidanski [Sun, 25 Aug 2013 08:37:19 +0000 (12:37 +0400)]
Remove changes in Makefile.in and doc/gc.man specific to FreeBSD ports
(Revert part of commit 8666ba2 from 'freebsd-ports-devel-boehm-gc' branch.)
(Apply commit 8f8d395 from 'release-7_2' branch.)
Ivan Maidanski [Sun, 25 Aug 2013 05:59:42 +0000 (09:59 +0400)]
Use __builtin_extract_return_addr in GC_RETURN_ADDR_PARENT (gcc/x86)
* include/gc_config_macros.h (GC_RETURN_ADDR_PARENT): Use
__builtin_extract_return_addr (since the address passed to dladdr);
do not define the macro for GCC pre-v4.
Ivan Maidanski [Sat, 24 Aug 2013 16:32:11 +0000 (20:32 +0400)]
Prevent use of unsupported __builtin_return_address(1) in GC_DBG_EXTRAS
* include/gc_config_macros.h (GC_CAN_SAVE_CALL_STACKS): Define also
for __amd64__ (synonym for __x86_64__).
* include/gc_config_macros.h (GC_RETURN_ADDR_PARENT): Define only for
x86 and x86_64 (which have frame-pointer register, for other targets
GCC might report "unsupported argument to __builtin_return_address"
warning).
Ivan Maidanski [Sat, 24 Aug 2013 14:43:29 +0000 (18:43 +0400)]
Define GC_caller_func_offset only if HAVE_DLADDR and GC_RETURN_ADDR_PARENT
(Apply commit 5d94f18 from 'release-7_2' branch.)
* dbg_mlc.c (GC_caller_func_offset): Do not define (and do not include
dlfcn.h) unless GC_ADD_CALLER; test HAVE_DLADDR (and
GC_RETURN_ADDR_PARENT) instead of FREEBSD macro.
* dbg_mlc.c (GC_caller_func_offset): Use STATIC; replace the K&R-style
function definition with the ANSI C one; remove unnecessary "const" in
type casts; do not call dladdr() if address is 0.
* dbg_mlc.c (GC_debug_malloc, GC_debug_realloc): Move assignment of
"s" argument to "unknown" to GC_caller_func_offset (if GC_ADD_CALLER).
* dbg_mlc.c (GC_debug_realloc): Do not call GC_caller_func_offset if
"p" argument is NULL (i.e., if redirected to GC_debug_malloc)..
* include/private/gcconfig.h (HAVE_DLADDR): Define for FREEBSD.
Ivan Maidanski [Fri, 23 Aug 2013 18:51:07 +0000 (22:51 +0400)]
Adjust GC_debug_malloc/realloc_replacement macro to match the API function
* malloc.c (GC_debug_malloc_replacement): Pass NULL (instead of
"unknown") to "s" argument of GC_debug_malloc to match that
replacement definition in dbg_mlc.c.
* mallocx.c (GC_debug_realloc_replacement): Likewise.
Ivan Maidanski [Thu, 22 Aug 2013 06:58:58 +0000 (10:58 +0400)]
Fix old_segv/bus_act variables initialization for FreeBSD
* os_dep.c (old_segv_act): Define static variable for FREEBSD (same as
for NETBSD).
* os_dep.c (GC_set_and_save_fault_handler): Reformat code (related to
FreeBSD).
* os_dep.c (GC_reset_fault_handler): Initialize old_segv_act (and
old_bus_act) for FREEBSD (same as for NETBSD).
Ivan Maidanski [Sun, 21 Jul 2013 14:27:07 +0000 (18:27 +0400)]
Fix GC_caller_func_offset and GC_DBG_RA names
(Apply commit 28e6e4f from 'release-7_2' branch.)
* dbg_mlc.c (GC_caller_func_offset): Test FREEBSD macro instead of
__FreeBSD__ (since the former is always defined in gcconfig.h included
from this file indirectly).
* dyn_load.c (ElfW): Likewise.
* dbg_mlc.c (GC_caller_func): Fix name to GC_caller_func_offset.
* dbg_mlc.c (GC_debug_realloc): Invoke GC_caller_func_offset if
GC_ADD_CALLER (same as in GC_debug_malloc and commit 2cdf7ec).
* include/private/gc_priv.h (RA): Fix name to GC_DBG_RA.
* include/private/gcconfig.h (X86_64): Test __x86_64__ in addition to
__amd64__ for FreeBSD (proposed in commit b54833a).
FreeBSD New ports collection for boehm-gc v7.2d
(Apply commit 8666ba2 from 'release-7_2' branch.)
* include/private/gc_priv.h (RA): Define to "GC_RETURN_ADDR_PARENT,"
if GC_RETURN_ADDR_PARENT defined.
* include/private/gcconfig.h (FREEBSD): Group rules.
Ivan Maidanski [Sat, 20 Jul 2013 13:01:01 +0000 (17:01 +0400)]
Fix 'stack section' pointer passed to push_all_stack_sections (Pthreads)
* pthread_stop_world.c (GC_push_all_stacks): Use
traced_stack_sect->prev instead of traced_stack_sect if saved_stack_ptr
(of traced_stack_sect) is the same as stop_info.stack_ptr of the
examined thread (thus preventing assertion violation in
GC_push_all_stack_sections invoked during incremental collection).
Ivan Maidanski [Sat, 20 Jul 2013 11:21:37 +0000 (15:21 +0400)]
Fix stackbottom/stack_end assignment in GC_call_with_gc_active
* misc.c (GC_call_with_gc_active): Add GC_noop1 call between "fn" call
and "return" statement to discourage the compiler from treating the
function call as a tail one (thus ensuring "stackbottom" COOLER_THAN
any stack pointer value obtained inside "fn").
* pthread_support.c (GC_call_with_gc_active): Likewise.
* win32_threads.c (GC_call_with_gc_active): Likewise.
Ivan Maidanski [Wed, 17 Jul 2013 06:07:19 +0000 (10:07 +0400)]
Fix assertion violation in GC_mark_from prefetch loop
* mark.c (GC_mark_from): If "descr" is less than size of word then
skip prefetching and PUSH_CONTENTS of the current entry (thus,
eliminate assertion violation in the prefetch loop) if SMALL_CONFIG is
not defined.
Ivan Maidanski [Tue, 16 Jul 2013 14:54:54 +0000 (18:54 +0400)]
Eliminate GC_first_nonempty atomic value reload in GC_mark_local assertion
* mark.c (GC_mark_from, GC_mark_local, GC_do_parallel_mark): Reformat
code partially.
* mark.c (GC_mark_local): Use "my_first_nonempty" in assertion
instead of reloading value of GC_first_nonempty twice.
Ivan Maidanski [Tue, 16 Jul 2013 12:19:12 +0000 (16:19 +0400)]
Allow to compile GC_inner_start_routine aside from extra/gc.c
(for proper exceptions support on Linux)
* extra/gc.c: Do not include pthread_start.c if
GC_PTHREAD_START_STANDALONE defined (thus pthread_start.c could go to
a standalone compilation unit).
* include/private/pthread_support.h (GC_INNER_PTHRSTART): New macro
(defined to either empty or GC_INNER depending on
GC_PTHREAD_START_STANDALONE).
* include/private/pthread_support.h (GC_start_rtn_prepare_thread,
GC_thread_exit_proc): Replace GC_INNER to GC_INNER_PTHRSTART.
* pthread_support.c (GC_thread_exit_proc,
GC_start_rtn_prepare_thread): Likewise.
* pthread_start.c (GC_inner_start_routine): Define as
GC_INNER_PTHRSTART; do not call GC_log_printf if
GC_PTHREAD_START_STANDALONE (since the function might be visible only
within extra/gc.c compilation unit).
* pthread_support.c (GC_inner_start_routine): Declare as
GC_INNER_PTHRSTART.
Ivan Maidanski [Mon, 15 Jul 2013 13:34:54 +0000 (17:34 +0400)]
Define [UN]SET_LOCK_HOLDER and I_[DONT_]HOLD_LOCK macros only if used
(code refactoring)
* include/private/gc_locks.h (SET_LOCK_HOLDER, UNSET_LOCK_HOLDER,
I_HOLD_LOCK, I_DONT_HOLD_LOCK): Do not define unless GC_ASSERTIONS.
* include/private/gc_locks.h (SET_LOCK_HOLDER, UNSET_LOCK_HOLDER):
Do not define unless THREADS.
Ivan Maidanski [Mon, 15 Jul 2013 13:18:12 +0000 (17:18 +0400)]
Do not set GC_lock_holder by call_with_alloc_lock if assertions disabled
* include/private/gc_locks.h (GC_lock_holder): Do not declare unless
GC_ASSERTIONS (the variable is not longer used to prevent recursive
reentry in the system call wrapper).
* misc.c (GC_call_with_alloc_lock): Remove [UN]SET_LOCK_HOLDER
explicit calls since GC_lock_holder is set properly by [UN]LOCK()
(in case of GC_ASSERTIONS).
* pthread_support.c (GC_lock_holder): Do not define unless
GC_ASSERTIONS; adjust comment.
* win32_threads.c (GC_lock_holder): Likewise.
Ivan Maidanski [Mon, 15 Jul 2013 12:02:36 +0000 (16:02 +0400)]
Add double-lock assertion to GC_acquire_mark_lock
* pthread_support.c (GC_acquire_mark_lock): Add assertion that
GC_mark_lock_holder is not set to the current thread on the function
entry (i.e., assertion against double lock).
* win32_threads.c (GC_acquire_mark_lock): Likewise.
Ivan Maidanski [Mon, 15 Jul 2013 11:48:44 +0000 (15:48 +0400)]
Mark GC_started_thread_while_stopped() as GC_INNER
* mark.c (GC_started_thread_while_stopped): Declare as GC_INNER
(declared only if GC_WIN32_THREADS).
* win32_threads.c (GC_started_thread_while_stopped): Define as GC_INNER.
Ivan Maidanski [Thu, 11 Jul 2013 12:34:00 +0000 (16:34 +0400)]
Enable thread-local allocation support for Clang on Cygwin
* include/private/thread_local_alloc.h (USE_PTHREAD_SPECIFIC): Use
(instead of USE_COMPILER_TLS) for clang3.1/x86 cygwin to workaround
"thread-local storage is unsupported for the current target" error.
Ivan Maidanski [Wed, 12 Jun 2013 05:50:04 +0000 (09:50 +0400)]
Improve debug-only messages of add/remove_roots and init_linux_data_start
* mark_rts.c (GC_add_roots_inner, GC_remove_root_at_pos): Log r_tmp
value (only if DEBUG_ADD_DEL_ROOTS).
* os_dep.c (GC_init_linux_data_start): Log unresolved [__]data_start
symbol (only if DEBUG_ADD_DEL_ROOTS and LINUX).
Ivan Maidanski [Mon, 10 Jun 2013 18:39:08 +0000 (22:39 +0400)]
Workaround 'unresolved __tls_get_addr' error for Android NDK Clang/x86
* include/private/thread_local_alloc.h (USE_COMPILER_TLS): Do not use
for Android NDK Clang (to workaround "unresolved __tls_get_addr" linker
error reported both by clang/x86 and clang/mips).
Ivan Maidanski [Sun, 9 Jun 2013 15:34:43 +0000 (19:34 +0400)]
Workaround 'unresolved __tls_get_addr' error for Android NDK clang/mips
* include/private/thread_local_alloc.h (USE_COMPILER_TLS): Do not use
for Android NDK Clang/mips (to workaround "unresolved __tls_get_addr"
linker error).
Ivan Maidanski [Sun, 9 Jun 2013 14:47:44 +0000 (18:47 +0400)]
Use pthread API to operate thread-local data on Linux if no compiler TLS
* include/private/thread_local_alloc.h (USE_PTHREAD_SPECIFIC): Define
for GC_LINUX_THREADS (instead of default USE_CUSTOM_SPECIFIC) if
compiler TLS is unavailable (e.g., for linux/arm).
Ivan Maidanski [Sat, 8 Jun 2013 13:16:19 +0000 (17:16 +0400)]
Suppress 'GC_dont_gc deprecated' warning in gc.h if GC_DONT_GC
* include/gc.h (GC_dont_gc): Do not specify GC_ATTR_DEPRECATED if
GC_DONT_GC defined (to avoid deprecated warning in
GC_INIT_CONF_MAX_RETRIES which assigns GC_dont_gc directly).
Ivan Maidanski [Sat, 8 Jun 2013 07:52:02 +0000 (11:52 +0400)]
Remove unused UTHREAD_SP_OFFSET macro (OpenBSD)
* include/private/gcconfig.h (UTHREAD_SP_OFFSET): Do not define (since
no longer used for OpenBSD because pthread_stackseg_np is used to get
thread stack pointer).
Ivan Maidanski [Sat, 1 Jun 2013 10:33:33 +0000 (14:33 +0400)]
Register dynamic libraries via dl_iterate_phdr on Android if possible
* dyn_load.c (HAVE_DL_ITERATE_PHDR): Define also for Android.
* dyn_load.c (dl_iterate_phdr): Declare explicitly for Android (since
no prototype in NDK link.h for ARM).
Ivan Maidanski [Sat, 1 Jun 2013 10:21:09 +0000 (14:21 +0400)]
Fix GC_INIT_CONF_ROOTS in gc.h for Android (define __data_start as weak)
* include/gc.h (GC_INIT_CONF_ROOTS): Define __data_start as weak
symbol for Android (including x86 and MIPS targets); do not call
GC_add_roots if __data_start symbol is unresolved.
Ivan Maidanski [Sun, 5 May 2013 20:02:40 +0000 (00:02 +0400)]
Adjust build scripts to enable additional test library in staticrootstest
(The 2nd test library contains global data too but has no GC_INIT call.)
* tests/tests.am (staticrootstest_CFLAGS,
libstaticrootslib2_test_la_CFLAGS): New definition (to test with
libsrl_getpelem2() enabled).
* tests/tests.am (staticrootstest_LDADD, check_LTLIBRARIES): Add
libstaticrootslib2_test.la.
* tests/tests.am (libstaticrootslib2_test_la_SOURCES,
libstaticrootslib2_test_la_LIBADD,
libstaticrootslib2_test_la_LDFLAGS): New definition (similar to that
of libstaticrootslib_test_la_X).
Ivan Maidanski [Sun, 5 May 2013 13:13:54 +0000 (17:13 +0400)]
Improve staticrootstest: add global data to library, add lib w/o GC_INIT
* tests/staticrootslib.c: Do not include stdio.h (not needed).
* tests/staticrootslib.c (root, root_nz): New static variables.
* tests/staticrootstest.c (root_nz): Likewise.
* tests/staticrootslib.c (libsrl_getpelem): New exported function
(exported as "libsrl_getpelem2" if STATICROOTSLIB2).
* tests/staticrootslib.c (libsrl_mktree, libsrl_init): Do not define
if STATICROOTSLIB2.
* tests/staticrootslib.c (libsrl_init): Do not call GC_INIT if
STATICROOTSLIB_INIT_IN_MAIN defined.
* tests/staticrootstest.c (libsrl_getpelem, libsrl_getpelem2): Declare
imported function.
* tests/staticrootstest.c (main): Call GC_INIT if
STATICROOTSLIB_INIT_IN_MAIN defined; set *libsrl_getpelem2() (only if
STATICROOTSLIB2 defined), *libsrl_getpelem() and root_nz[] elements
(similar to that of root[]).