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[]).
Ivan Maidanski [Thu, 14 Mar 2013 17:31:05 +0000 (21:31 +0400)]
Fix GC_INIT_CONF_ROOTS in gc.h for Android/x86 and Android/mips
* include/gc.h (GC_INIT_CONF_ROOTS): Do not define to register static
data root in range from __data_start to _end on non-ARM Android
(because __data_start symbol does not exist for x86 and mips); refine
the comment.
Andy Wingo [Wed, 13 Feb 2013 14:45:33 +0000 (15:45 +0100)]
Fix tests makefile to link with new GNU ld linking rules
* tests/tests.am (gctest_LDADD, threadleaktest_LDADD,
threadkey_test_LDADD, subthread_create_LDADD,
initsecondarythread_LDADD): Link to pthreads (or appropriate
threading libraries) as needed; fixes failure to link with new GNU ld
linking rules.
Ivan Maidanski [Fri, 22 Feb 2013 04:25:27 +0000 (08:25 +0400)]
Workaround 'ELF_DATA/EM_ALPHA redefined' warning in Android linker.h
* 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 workaround a bug (avoiding
"macro redefined" warnings) in Android 4.1 (and 4.2) Bionic which has
the mismatching macro definitions in headers included from linker.h.
Ivan Maidanski [Sat, 16 Feb 2013 19:42:24 +0000 (23:42 +0400)]
Add assertion on number_of_objs to GC_extend_size_map
* misc.c (GC_extend_size_map): Add assertion for number_of_objs (result
of integer division) to be non-zero (this assertion violation is
observed in some Android emulators when gcc -march value does not match
target CPU).
Ivan Maidanski [Wed, 13 Feb 2013 20:47:30 +0000 (00:47 +0400)]
Allow not to rely on __data_start value (Linux)
* os_dep.c (GC_init_linux_data_start): Skip use of [__]data_start if
IGNORE_PROG_DATA_START (useful if give wrong value).
* os_dep.c (GC_init_linux_data_start): Add assertion checks for
[__]data_start to be not greater than _end.
Ivan Maidanski [Wed, 13 Feb 2013 20:29:44 +0000 (00:29 +0400)]
Allow to omit libc atexit() call
* misc.c (GC_exit_check): Do not define if DONT_USE_ATEXIT (since
unused in this case).
* misc.c (GC_init): Do not call atexit if DONT_USE_ATEXIT (useful if
atexit is missing in libc, e.g., to workaround linkage problems in
Android NDK).
Ivan Maidanski [Wed, 23 Jan 2013 19:59:19 +0000 (23:59 +0400)]
Adjust punctuation in comments and documentation
* win32_threads.c (GC_pthread_join): Add a space character after comma
in comment.
* include/private/gcconfig.h: Likewise.
* doc/README.Mac: Likewise.
* doc/porting.html: Likewise.
* ptr_chck.c (GC_same_obj): Remove redundant comma in comment.
Ivan Maidanski [Sun, 6 Jan 2013 09:05:24 +0000 (13:05 +0400)]
Do not use pthread_getattr_np if NO_PTHREAD_GETATTR_NP specified
* include/private/gcconfig.h (NO_PTHREAD_GETATTR_NP): Define new macro
for NaCl.
* os_dep.c (GC_get_main_stack_base, GC_get_stack_base): Test
NO_PTHREAD_GETATTR_NP instead of NACL (i.e., do not use
pthread_getattr_np if NO_PTHREAD_GETATTR_NP).
Ivan Maidanski [Sun, 23 Dec 2012 14:52:10 +0000 (18:52 +0400)]
Fix GC_win32_free_heap to prevent memory leak if USE_GLOBAL_ALLOC
* os_dep.c (GC_win32_free_heap): Test GLOBAL_ALLOC_TEST instead of
GC_no_win32_dlls to determine whether the memory is allocated using
GlobalAlloc (only if MSWIN32).
Ivan Maidanski [Sun, 23 Dec 2012 12:13:45 +0000 (16:13 +0400)]
Fix dwSize argument of VirtualFree call in detect_GetWriteWatch (Win32)
* os_dep.c (detect_GetWriteWatch): Pass 0 (instead of GC_page_size)
to Win32 VirtualFree if GWW_VDB (dwSize must be 0 if MEM_RELEASE
according to MSDN).
Ivan Maidanski [Sun, 23 Dec 2012 10:47:09 +0000 (14:47 +0400)]
Add assertion to LONG_MULT and remove useless assert in PUSH_CONTENTS_HDR
* include/private/gc_pmark.h (LONG_MULT): Add static assertion that
the size of variable is large enough to hold multiplication result.
* include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Remove useless
assertion check for a unsigned "high_prod" value to be non-negative
(only if MARK_BIT_PER_OBJ).
Ivan Maidanski [Sun, 23 Dec 2012 09:25:59 +0000 (13:25 +0400)]
Move GC_print_trace code inside LOCK/UNLOCK to GC_print_trace_inner
(code refactoring)
* mark.c (GC_print_trace_inner): New function (only if TRACE_BUF).
* mark.c (GC_print_trace): Move code to GC_print_trace_inner (except
for LOCK/UNLOCK); invoke GC_print_trace_inner (either with lock held
or not depending on "lock" variable value).
Ivan Maidanski [Sun, 23 Dec 2012 09:13:37 +0000 (13:13 +0400)]
Adjust printf format specifiers in GC_print_trace
* mark.c (GC_print_trace): Adjust printf format specifier for
arguments of word type (cast to long type).
* mark.c (GC_print_trace): Replace printf() call with GC_printf.
Ivan Maidanski [Wed, 12 Dec 2012 19:45:32 +0000 (23:45 +0400)]
Turn on world-stop delay logging at debug level by default for Android
* alloc.c (GC_stopped_mark): Use GC_PRINT_STATS_FLAG instead of
GC_print_stats in the condition for logging world-stop pause time.
* include/private/gc_priv.h (GC_PRINT_STATS_FLAG): New macro (defined
as !GC_quiet if GC_ANDROID_LOG otherwise as GC_print_stats.
* include/private/gc_priv.h (GC_DBGLOG_PRINTF): Define using
GC_PRINT_STATS_FLAG instead of GC_quiet; update comment.
Ivan Maidanski [Wed, 12 Dec 2012 16:49:07 +0000 (20:49 +0400)]
Replace GC_stats_log_printf with GC_DBG/INFOLOG_PRINTF
(minimize logging for Android when print_stats is off)
* alloc.c (GC_try_to_collect_inner, GC_stopped_mark,
GC_finish_collection): Use GC_log_printf instead of
GC_stats_log_printf.
* finalize.c (GC_print_finalization_stats): Likewise.
* include/private/gc_priv.h (GC_COND_LOG_PRINTF): Likewise.
* alloc.c (GC_stopped_mark): Use GC_DBGLOG_PRINTF instead of
GC_COND_LOG_PRINTF (useful for Android).
* alloc.c (GC_expand_hp_inner): Reformat comment.
* alloc.c (GC_expand_hp_inner): Use GC_INFOLOG_PRINTF instead of
GC_COND_LOG_PRINTF (useful for Android).
* include/private/gc_priv.h (GC_stats_log_printf): Remove (macro and
prototype).
* include/private/gc_priv.h (GC_DBGLOG_PRINTF, GC_INFOLOG_PRINTF):
New macro (redirecting either to GC_COND_LOG_PRINTF or to
GC_log_printf/GC_info_log_printf if GC_ANDROID_LOG).
* include/private/gc_priv.h (GC_info_log_printf): New prototype (only
if GC_ANDROID_LOG).
* misc.c (GC_stats_log_printf): Rename to GC_info_log_printf.
Ivan Maidanski [Wed, 12 Dec 2012 04:16:30 +0000 (08:16 +0400)]
Do not duplicate android_log_write output to GC log file (Android)
* include/private/gc_priv.h (GC_real_print_stats): Remove macro.
* include/private/gc_priv.h (GC_print_stats): Define as external
variable (instead of a macro) for GC_ANDROID_LOG (only if not
SMALL_CONFIG).
* misc.c (GC_real_print_stats, GC_init): Replace GC_real_print_stats
back to GC_print_stats.
* misc.c (GC_printf, GC_LOG_PRINTF_IMPL, GC_warn_printf, GC_err_puts):
Do not duplicate output to GC_stdout/err, GC_log if GC_ANDROID_LOG
(after calling __android_log_write).
* misc.c (GC_LOG_PRINTF_IMPL): Remove unused "fileLogCond" argument.
* misc.c (GC_default_warn_proc): Do not duplicate output to
GC_stderr if GC_ANDROID_LOG (before __android_log_assert invocation).
Ivan Maidanski [Tue, 11 Dec 2012 16:17:16 +0000 (20:17 +0400)]
Replace GC_COND_LOG_PRINTF calls with WARN for allocation failure messages
* alloc.c (GC_expand_hp_inner): Replace GC_COND_LOG_PRINTF call to
WARN() call (with WARN_PRIdPTR argument type format specifier) for the
message about failure.
* headers.c (GC_scratch_alloc): Likewise.
* mark.c (GC_mark_some, alloc_mark_stack): Likewise.
Ivan Maidanski [Mon, 10 Dec 2012 04:31:32 +0000 (08:31 +0400)]
Remove DebugBreak on WriteFile failure (Win32)
* misc.c (GC_write): Rename "tmp" local variable to "res"; remove
DebugBreak on WriteFile failure since DebugBreak is a part of ABORT
unless NO_DEBUGGING (only for MSWIN32 and MSWINCE targets).
Ivan Maidanski [Mon, 10 Dec 2012 03:46:03 +0000 (07:46 +0400)]
Prevent abort on GC_err/warn_printf write failure
* misc.c (GC_LOG_PRINTF_IMPL, GC_warn_printf): Do not abort in case of
failure of write which duplicates message to log/stderr (if
GC_ANDROID_LOG).
* misc.c (GC_err_puts): Do not abort in case of stderr write failure.