]> granicus.if.org Git - gc/log
gc
11 years agoFix make disclaim_test to link with new GNU ld linking rules
Ivan Maidanski [Thu, 28 Feb 2013 03:48:05 +0000 (07:48 +0400)]
Fix make disclaim_test to link with new GNU ld linking rules

* tests/tests.am (disclaim_test_LDADD): Link to pthreads (or appropriate
threading libraries) as needed.

11 years agoFix tests makefile to link with new GNU ld linking rules
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.

11 years agoWorkaround 'ELF_DATA/EM_ALPHA redefined' warning in Android linker.h
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.

11 years agoAdd assertion on number_of_objs to GC_extend_size_map
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).

11 years agoAllow not to rely on __data_start value (Linux)
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.

11 years agoAllow to omit libc atexit() call
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).

11 years ago.gitignore: Ignore .gch files
Ivan Maidanski [Sun, 27 Jan 2013 10:33:59 +0000 (14:33 +0400)]
.gitignore: Ignore .gch files

11 years agoAdjust punctuation in comments and documentation
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.

11 years agoUpdate AUTHORS file
Ivan Maidanski [Wed, 23 Jan 2013 19:20:50 +0000 (23:20 +0400)]
Update AUTHORS file

11 years agoAdd AArch64 (64-bit ARM) target support
Yvan Roux [Wed, 23 Jan 2013 19:15:57 +0000 (23:15 +0400)]
Add AArch64 (64-bit ARM) target support

* include/private/gcconfig.h (AARCH64): New macro (defined only if
__aarch64__).
* include/private/gcconfig.h (mach_type_known): Update comment adding
ARM AArch64 target.
* include/private/gcconfig.h (NOSYS, mach_type_known, CPP_WORDSZ,
MACH_TYPE, ALIGNMENT, HBLKSIZE, OS_TYPE, LINUX_STACKBOTTOM,
DYNAMIC_LOADING, DATASTART, DATAEND, STACKBOTTOM): Define for AArch64.

11 years agoDo not include sigcontext.h if NO_SIGCONTEXT_H (Linux)
Ivan Maidanski [Sun, 6 Jan 2013 09:32:09 +0000 (13:32 +0400)]
Do not include sigcontext.h if NO_SIGCONTEXT_H (Linux)

* os_dep.c: Do not include [asm/]sigcontext.h (and linux/version.h)
if NO_SIGCONTEXT_H is defined (only if LINUX and not POWERPC).

11 years agoDo not use pthread_getattr_np if NO_PTHREAD_GETATTR_NP specified
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).

12 years agoFix reference to debugging-related README file in README and Makefile.dj
Ivan Maidanski [Fri, 28 Dec 2012 03:22:06 +0000 (07:22 +0400)]
Fix reference to debugging-related README file in README and Makefile.dj

* README: Change README.debugging to debugging.html.
* Makefile.dj (OTHER_FILES): Likewise.

12 years agoFix GC_win32_free_heap compilation error for Cygwin
Ivan Maidanski [Sun, 23 Dec 2012 12:03:36 +0000 (16:03 +0400)]
Fix GC_win32_free_heap compilation error for Cygwin
(fix commit 'caa5af9')

* os_dep.c (GC_win32_free_heap): Do not invoke virtual free for
Cygwin, remove "else" branch  (only if MSWIN32 but not CYGWIN32).

12 years agoFix: VirtualAlloc leaks when freeing the heap on win32
Max Mouratov [Sun, 21 Oct 2012 14:39:17 +0000 (20:39 +0600)]
Fix: VirtualAlloc leaks when freeing the heap on win32

12 years agoFix GC_win32_free_heap to prevent memory leak if USE_GLOBAL_ALLOC
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).

12 years agoFix dwSize argument of VirtualFree call in detect_GetWriteWatch (Win32)
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).

12 years agoAdd assertion to LONG_MULT and remove useless assert in PUSH_CONTENTS_HDR
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).

12 years agoMake GC_print_trace always thread-safe and remove 'lock' argument
Ivan Maidanski [Sun, 23 Dec 2012 10:23:50 +0000 (14:23 +0400)]
Make GC_print_trace always thread-safe and remove 'lock' argument

* mark.c (GC_print_trace): Remove "lock" argument assuming always true
(GC_print_trace is used for debugging purposes only and not exported
publicly).

12 years agoMove GC_print_trace code inside LOCK/UNLOCK to GC_print_trace_inner
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).

12 years agoAdjust printf format specifiers in GC_print_trace
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.

12 years agoFix GC_print_trace missing unlock
Ivan Maidanski [Sun, 23 Dec 2012 08:53:34 +0000 (12:53 +0400)]
Fix GC_print_trace missing unlock

* mark.c (GC_print_trace): Perform UNLOCK (if "lock" is on) before
return (inside loop).

12 years agoChange definition of macros represented as block to be simple statement
Ivan Maidanski [Sun, 23 Dec 2012 07:58:21 +0000 (11:58 +0400)]
Change definition of macros represented as block to be simple statement
(code refactoring)

* backgraph.c (FOR_EACH_PRED): Wrap outermost block into do/while (0).
* include/gc_inline.h (GC_FAST_MALLOC_GRANS, GC_MALLOC_WORDS,
GC_MALLOC_ATOMIC_WORDS, GC_CONS): Likewise.
* include/private/gc_hdrs.h (HC_GET_HDR, GET_BI, GET_HDR_ADDR,
GET_HDR, SET_HDR): Likewise.
* include/private/gc_locks.h (LOCK, UNLOCK): Likewise.
* include/private/gc_pmark.h (PUSH_OBJ, PUSH_CONTENTS,
SET_MARK_BIT_EXIT_IF_SET, OR_WORD_EXIT_IF_SET, LONG_MULT,
PUSH_CONTENTS_HDR, GC_PUSH_ONE_STACK, GC_PUSH_ONE_HEAP, GC_MARK_FO):
Likewise.
* include/private/gc_priv.h (GET_TIME, GC_ASSERT, COND_DUMP_CHECKS,
DISABLE_CANCEL, RESTORE_CANCEL): Likewise.
* include/private/gcconfig.h (PREFETCH): Likewise.
* mark.c (PUSH_GRANULE): Likewise.
* misc.c (GC_PRINTF_FILLBUF): Likewise.
* include/private/gc_locks.h (SET_LOCK_HOLDER, UNSET_LOCK_HOLDER):
Define as "(void)0" instead of empty.
* include/private/gc_priv.h (ASSERT_CANCEL_DISABLED): Likewise.
* include/private/gcconfig.h (PREFETCH, PREFETCH_FOR_WRITE): Likewise.
* win32_threads.c (UNPROTECT_THREAD): Likewise.
* include/private/gc_priv.h (GC_INLINE): Refine comment.
* include/private/gc_priv.h (MAKE_COOLER, MAKE_HOTTER,
GC_ADD_TO_BLACK_LIST_NORMAL, GC_ADD_TO_BLACK_LIST_STACK, COND_DUMP):
Replace block in "else" branch with a statement and remove trailing
';' symbol.
* include/private/gc_priv.h (ABORT_RET): Invert "if" condition moving
statement from "then" branch to "else" one; remove outermost {};
remove trailing ';' symbol
* os_dep.c (PROTECT, UNPROTECT): Likewise.
* pthread_support.c (INIT_REAL_SYMS): Likewise.
* win32_threads.c (SET_PTHREAD_MAP_CACHE): Cast result to void.
* win32_threads.c (PUSH2, PUSH4): Add outermost parentheses.

12 years agoDefine CORD_ec_append macro to expression instead of block (cord)
Ivan Maidanski [Sat, 22 Dec 2012 19:09:00 +0000 (23:09 +0400)]
Define CORD_ec_append macro to expression instead of block (cord)
(code refactoring)

* include/ec.h (CORD_ec_init): Cast result to void (no return value).
* include/ec.h (CORD_ec_append): Replace block with void expression;
remove redundant parentheses.

12 years agoRefine comment of GC_is_heap_ptr and GC_thread_is_registered in gc.h
Ivan Maidanski [Sat, 22 Dec 2012 18:45:11 +0000 (22:45 +0400)]
Refine comment of GC_is_heap_ptr and GC_thread_is_registered in gc.h

* include/gc.h (GC_is_heap_ptr, GC_thread_is_registered): Refine
comment (specify TRUE is encoded as any non-zero value).

12 years agoUse EXPECT in GC_COND/VERBOSE_LOG_PRINTF
Ivan Maidanski [Sat, 22 Dec 2012 17:55:45 +0000 (21:55 +0400)]
Use EXPECT in GC_COND/VERBOSE_LOG_PRINTF

* include/private/gc_priv.h (GC_COND_LOG_PRINTF,
GC_VERBOSE_LOG_PRINTF): Use EXPECT to test GC_print_stats value.

12 years agoUpdate AUTHORS (add email)
Ivan Maidanski [Sat, 22 Dec 2012 09:31:09 +0000 (13:31 +0400)]
Update AUTHORS (add email)

12 years agoDefine functions in darwin_semaphore.h as inline instead of static
Ivan Maidanski [Fri, 14 Dec 2012 21:13:06 +0000 (01:13 +0400)]
Define functions in darwin_semaphore.h as inline instead of static

* include/private/darwin_semaphore.h: Reformat comment.
* include/private/darwin_semaphore.h (sem_init, sem_post, sem_wait,
sem_destroy): Define as GC_INLINE instead of static.

12 years agoReplace '`' symbol with double-quote in comments
Ivan Maidanski [Fri, 14 Dec 2012 21:03:50 +0000 (01:03 +0400)]
Replace '`' symbol with double-quote in comments

* doc/README.win32: Replace "`" symbol (and paring single-quote) with
double-quote symbol.
* dyn_load.c (GC_register_dynlib_callback): Likewise.
* finalize.c (GC_should_invoke_finalizers): Likewise.
* include/private/gc_priv (GC_INLINE, ptr_t): Likewise.
* include/private/gcconfig.h (DATAEND): Likewise.

12 years agoTurn on world-stop delay logging at debug level by default for Android
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.

12 years agoImprove logged messages about heap size and usage
Ivan Maidanski [Wed, 12 Dec 2012 19:05:36 +0000 (23:05 +0400)]
Improve logged messages about heap size and usage

* alloc.c (GC_stopped_mark): Print heap size to debug log in KiB
(using TO_KiB_UL macro) excluding unmapped memory size.
* alloc.c (GC_compute_heap_usage_percent): New inline function.
* alloc.c (GC_finish_collection): Use GC_DBGLOG_PRINTF instead of
GC_COND_LOG_PRINTF for heap usage logging; print heap usage in KiB;
log memory heap utilization in percent (using
GC_compute_heap_usage_percent).
* alloc.c (GC_expand_hp_inner): Log increased heap size (in KiB)
instead of increment size.
* include/private/gc_priv.h (TO_KiB_UL): New macro.

12 years agoReplace GC_stats_log_printf with GC_DBG/INFOLOG_PRINTF
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.

12 years agoRedirect WRITE to __android_log_write if GC_ANDROID_LOG (Android)
Ivan Maidanski [Wed, 12 Dec 2012 14:52:14 +0000 (18:52 +0400)]
Redirect WRITE to __android_log_write if GC_ANDROID_LOG (Android)
(code refactoring)

* misc.c (GC_stdout, GC_stderr, GC_log): Do not define as static
variable if GC_ANDROID_LOG.
* misc.c (GC_init): Do not allow to set GC_log and GC_stdout/err if
GC_ANDROID_LOG.
* misc.c (GC_ANDROID_LOG_TAG): Move definition (and include
android/log.h) upper to precede GC_write definition for Unix.
* misc.c (GC_stdout, GC_stderr, GC_long): Define specially
for GC_ANDROID_LOG (define to ANDROID_LOG_DEBUG/ERROR logging level).
* misc.c (WRITE): Define specially for GC_ANDROID_LOG (first argument
is used as logging level) redirecting to __android_log_write.
* misc.c (GC_printf, GC_stats_log_printf, GC_verbose_log_printf,
GC_warn_printf, GC_err_puts): Remove __android_log_write call
(unconditionally invoke WRITE instead).
* misc.c (GC_log_printf): Remove Android-specific implementation (use
general instead).
* misc.c (GC_stats_log_printf, GC_verbose_log_printf): Expand
GC_LOG_PRINTF_IMPL macro.
* misc.c (GC_LOG_PRINTF_IMPL): Remove macro.

12 years agoDo not duplicate android_log_write output to GC log file (Android)
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).

12 years agoReplace GC_COND_LOG_PRINTF calls with WARN for allocation failure messages
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.

12 years agoReplace GC_log/err_printf() followed by ABORT with ABORT_ARGn()
Ivan Maidanski [Tue, 11 Dec 2012 05:28:12 +0000 (09:28 +0400)]
Replace GC_log/err_printf() followed by ABORT with ABORT_ARGn()
(code refactoring)

* allchblk.c (GC_freehblk): Replace GC_COND_LOG_PRINTF (or
GC_log_printf, or GC_err_printf) followed by ABORT with ABORT_ARG<n>
(where 'n' is the number of arguments matching format string).
* alloc.c (GC_check_fl_marks): Likewise.
* dbg_mlc.c (GC_debug_change_stubborn, GC_debug_end_stubborn_change,
GC_debug_free, GC_debug_realloc): Likewise.
* dyn_load.c (GC_register_dynamic_libraries): Likewise.
* os_dep.c (GC_get_maps, GC_register_data_segments, GC_remap, PROTECT,
GC_write_fault_handler, GC_mprotect_thread): Likewise.
* pthread_stop_world.c (GC_suspend_all, GC_start_world): Likewise.
* ptr_chck.c (GC_default_same_obj_print_proc,
GC_default_is_valid_displacement_print_proc,
GC_default_is_visible_print_proc): Likewise.
* specific.c (GC_check_tsd_marks): Likewise.
* win32_threads.c (GC_register_my_thread_inner): Likewise.
* include/private/gc_priv.h (ABORT_ARG1, ABORT_ARG2, ABORT_ARG3): New
macro.

12 years agoRemove redundant GC_err_printf before abort
Ivan Maidanski [Tue, 11 Dec 2012 04:11:50 +0000 (08:11 +0400)]
Remove redundant GC_err_printf before abort

* dbg_mlc.c (GC_debug_realloc): Remove redundant GC_err_printf
invocation before abort; refine abort message.
* os_dep.c (GC_register_data_segments): Likewise.

12 years agoEnable on-demand debug logging in GC_FindTopOfStack (Darwin)
Ivan Maidanski [Tue, 11 Dec 2012 04:05:42 +0000 (08:05 +0400)]
Enable on-demand debug logging in GC_FindTopOfStack (Darwin)

* darwin_stop_world.c (GC_FindTopOfStack): Test DEBUG_THREADS_EXTRA
instead of DEBUG_THREADS; uncomment GC_log_printf calls inside
DEBUG_THREADS_EXTRA.

12 years agoPrepend '#' symbol to GC number in logged messages
Ivan Maidanski [Mon, 10 Dec 2012 16:14:43 +0000 (20:14 +0400)]
Prepend '#' symbol to GC number in logged messages

* alloc.c (GC_maybe_gc, GC_stopped_mark): Put '#' sign in printed
messages preceding GC_gc_no value (to identify it as a collection
number).
* include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Likewise.
* malloc.c (GC_free): Likewise.
* mark.c (GC_mark_from): Likewise.
* thread_local_alloc.c (GC_malloc): Likewise.

12 years agoRemove abort on open log failure from GC_write (Win32)
Ivan Maidanski [Mon, 10 Dec 2012 04:40:19 +0000 (08:40 +0400)]
Remove abort on open log failure from GC_write (Win32)

* misc.c (GC_write): Do not abort (unconditionally) if
GC_CreateLogFile failed, return -1 (or, even, 0 if NO_DEBUGGING)
instead; update comment (Win32 only).

12 years agoRemove DebugBreak on WriteFile failure (Win32)
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).

12 years agoPrevent abort on GC_err/warn_printf write failure
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.

12 years agoMerge branch 'add-long-weakref'
Ivan Maidanski [Sun, 9 Dec 2012 19:30:22 +0000 (23:30 +0400)]
Merge branch 'add-long-weakref'

12 years agoAdd assertion to GC_enable() ensuring no counter underflow
Ivan Maidanski [Sun, 9 Dec 2012 19:24:51 +0000 (23:24 +0400)]
Add assertion to GC_enable() ensuring no counter underflow

* misc.c (GC_enable): Add assertion against GC_dont_gc underflow.

12 years agoFix typo and refine comment of GC_enable in public header
Ivan Maidanski [Sun, 9 Dec 2012 19:15:28 +0000 (23:15 +0400)]
Fix typo and refine comment of GC_enable in public header

* include/gc.h (GC_enable): Fix typo and refine comment.

12 years agoMerge branch 'master' into add-long-weakref
Ivan Maidanski [Sun, 9 Dec 2012 18:41:54 +0000 (22:41 +0400)]
Merge branch 'master' into add-long-weakref

Conflicts:
finalize.c

12 years agoAdd tests for GC_register/move/unregister_long_link
Ivan Maidanski [Sun, 9 Dec 2012 18:36:09 +0000 (22:36 +0400)]
Add tests for GC_register/move/unregister_long_link

* tests/test.c (live_long_refs): New global variable (only if
not GC_LONG_REFS_NOT_NEEDED and not MACOS).
* tests/test.c (mktree): Test GC_REGISTER_LONG_LINK,
GC_move_long_link, GC_unregister_long_link (using live_long_refs)
unless GC_LONG_REFS_NOT_NEEDED.
* tests/test.c (check_heap_stats): Define "still_long_live" local
variable, count non-null elements of live_long_refs, print number of
non-null elements of live_long_refs (if any) unless
GC_LONG_REFS_NOT_NEEDED.

12 years agoUpdate TODO (add FIXME regarding Win32 threads)
Ivan Maidanski [Sat, 8 Dec 2012 08:49:15 +0000 (12:49 +0400)]
Update TODO (add FIXME regarding Win32 threads)

12 years agoMake GC_generic_malloc_ignore_off_page() public
Ivan Maidanski [Sat, 8 Dec 2012 08:39:07 +0000 (12:39 +0400)]
Make GC_generic_malloc_ignore_off_page() public

* include/gc_mark.h (GC_generic_malloc): Refine comment.
* include/gc_mark.h (GC_generic_malloc_ignore_off_page): Move
prototype from gc_priv.h and make it public; add GC_ATTR_MALLOC
attribute.
* include/private/gc_priv.h (GC_generic_malloc): Move comment to
gc_mark.h.
* include/private/gc_priv.h (GC_generic_malloc_ignore_off_page):
Remove GC-inner prototype.
* include/private/gc_priv.h (GC_generic_malloc_inner): Update comment.
* mallocx.c (GC_generic_malloc_ignore_off_page): Likewise.
* mallocx.c (GC_generic_malloc_ignore_off_page): Make public.

12 years agoUpdate AUTHORS file
Ivan Maidanski [Sat, 8 Dec 2012 06:34:50 +0000 (10:34 +0400)]
Update AUTHORS file

12 years agoFix GC_malloc_explicitly_typed_ignore_off_page for large allocations
Reimer Behrends [Sat, 8 Dec 2012 06:33:06 +0000 (10:33 +0400)]
Fix GC_malloc_explicitly_typed_ignore_off_page for large allocations

* typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Use
BYTES_TO_GRANULES instead of BYTES_TO_WORDS when calculating "lg"
local variable value.

12 years agoFix GC_remove_all_threads_but_me for Android (fork support)
Ivan Maidanski [Fri, 30 Nov 2012 14:01:30 +0000 (18:01 +0400)]
Fix GC_remove_all_threads_but_me for Android (fork support)

* pthread_support.c (GC_remove_all_threads_but_me): Update kernel_id
of "me" (if PLATFORM_ANDROID).

12 years agoAllow pthread_kill error code logging in GC_suspend/resume (debugging)
Ivan Maidanski [Fri, 30 Nov 2012 04:08:20 +0000 (08:08 +0400)]
Allow pthread_kill error code logging in GC_suspend/resume (debugging)

* pthread_stop_world.c (GC_suspend_all, GC_start_world): Log
pthread_kill error code on failure if DEBUG_THREADS.

12 years agoFix ABORT definition for mingw32ce (WinCE)
Ivan Maidanski [Sun, 25 Nov 2012 19:13:59 +0000 (23:13 +0400)]
Fix ABORT definition for mingw32ce (WinCE)

* include/private/gc_priv.h (ABORT): Define as block statement
(instead of expression) for Win32/WinCE (unless NO_DEBUGGING) because
DebugBreak is defined as a statement in some toolchains (e.g.,
mingw32ce).

12 years agoFix GC_CreateThread 'dwStackSize' argument type for Win64
Ivan Maidanski [Sun, 25 Nov 2012 18:35:06 +0000 (22:35 +0400)]
Fix GC_CreateThread 'dwStackSize' argument type for Win64

* include/gc.h (GC_uintptr_t): Define (for Win32/CE) even if
GC_NO_THREAD_DECLS; move definition upper than GC_CreateThread.
* include/gc.h (GC_WIN32_SIZE_T): New macro (defined as GC_uintptr_t,
Win32 threads only).
* include/gc.h (GC_CreateThread): Use GC_WIN32_SIZE_T instead of DWORD
type for "dwStackSize" argument (Win32 threads only).
* win32_threads.c (GC_CreateThread): Likewise.
* tests/test.c (fork_a_thread): Verify types of GC_CreateThread
arguments by explicit casts (only if GC_WIN32_THREADS).

12 years agoMinor code refactoring of dumping routines related to 'long' links
Ivan Maidanski [Sat, 24 Nov 2012 14:31:12 +0000 (18:31 +0400)]
Minor code refactoring of dumping routines related to 'long' links

* finalize.c (struct disappearing_link): Remove STATIC.
* finalize.c (GC_dl_hashtbl, GC_ll_hashtbl): Define separately from
dl_hashtbl_s definition.
* finalize.c (GC_grow_table): Reformat comment.
* finalize.c (GC_dump_finalization_links): Pass 'dl_hashtbl' argument
as pointer to constant struct.
* finalize.c (GC_dump_finalization_links, GC_dump_finalization):
Adjust printed message.
* finalize.c (GC_old_ll_entries): Do not define if
GC_LONG_REFS_NOT_NEEDED.
* finalize.c (IF_LONG_REFS_PRESENT_ELSE): New macro (only if not
SMALL_CONFIG).
* finalize.c (GC_print_finalization_stats): Use
IF_LONG_REFS_PRESENT_ELSE (instead of testing GC_LONG_REFS_NOT_NEEDED);
make printed messages more compact.

12 years agoPrevent POSIX fork if mprotect_thread is started (Darwin)
Ivan Maidanski [Thu, 22 Nov 2012 04:39:20 +0000 (08:39 +0400)]
Prevent POSIX fork if mprotect_thread is started (Darwin)

* pthread_support.c (GC_atfork_prepare): Abort if GC_dirty_maintained
is set for Darwin (only if MPROTECT_VDB) since graceful suspend/resume
of mprotect_thread is unsupported at present.

12 years agoAdd manual POSIX fork handling support (Android)
Ivan Maidanski [Wed, 21 Nov 2012 18:26:29 +0000 (22:26 +0400)]
Add manual POSIX fork handling support (Android)

* include/gc.h (GC_set_handle_fork): Update comment.
* include/gc.h (GC_atfork_prepare, GC_atfork_parent, GC_atfork_child):
New API proto.
* include/private/gc_priv.h (GC_handle_fork): Change type from GC_bool
to int (to hold a value of -1).
* misc.c (GC_handle_fork): Likewise.
* include/private/gc_priv.h (GC_handle_fork): Add comment.
* misc.c (GC_set_handle_fork): Likewise.
* include/private/gcconfig.h (CAN_HANDLE_FORK): Define also for HURD
and PLATFORM_ANDROID; do not define if HAVE_NO_FORK already defined.
* include/private/gcconfig.h (CAN_CALL_ATFORK): New macro (defined if
CAN_HANDLE_FORK but not HURD or PLATFORM_ANDROID).
* include/private/gcconfig.h (HAVE_NO_FORK): New macro (defined for
Win32, OS/2 and others).
* misc.c (GC_atfork_prepare, GC_atfork_parent, GC_atfork_child): New
API function definition (only if not CAN_HANDLE_FORK and not
HAVE_NO_FORK).
* misc.c (GC_handle_fork): Map all negative values of argument except
for -1 to a positive one stored to GC_handle_fork; call GC_init to
initialize GC_stderr before ABORT invocation (only if not
SMALL_CONFIG).
* pthread_support.c (GC_atfork_prepare, GC_atfork_parent,
GC_atfork_child): New API function definition (only if
CAN_HANDLE_FORK).
* win32_threads.c (GC_atfork_prepare, GC_atfork_parent,
GC_atfork_child): Likewise.
* pthread_support.c (GC_thr_init): No pthread_atfork call if not
CAN_CALL_ATFORK; adjust GC_handle_fork value if pthread_atfork
succeeds; do not about in case of pthread_atfork failure provided
GC_handle_fork is -1 (only if CAN_HANDLE_FORK).
* win32_threads.c (GC_thr_init): Likewise.
* tests/test.c (TEST_FORK_WITHOUT_ATFORK): Recognize new macro (do not
define NO_TEST_HANDLE_FORK in this case and set INIT_FORK_SUPPORT to
no-op).
* tests/test.c (INIT_FORK_SUPPORT): Define to GC_set_handle_fork(-1)
unless HANDLE_FORK, or NO_TEST_HANDLE_FORK or TEST_FORK_WITHOUT_ATFORK.
* tests/test.c (run_one_test): Surround fork() invocation with
GC_atfork_prepare, GC_atfork_parent, GC_atfork_child calls.
* win32_threads.c: Include unistd.h if CAN_CALL_ATFORK defined
(instead of CAN_HANDLE_FORK) to get pthread_atfork prototype.

12 years agoImprove fork test logging in gctest
Ivan Maidanski [Tue, 20 Nov 2012 17:13:40 +0000 (21:13 +0400)]
Improve fork test logging in gctest

* tests/test.c (run_one_test): Move fork testing block upper (so that
other tests run in parallel in parent process).
* tests/test.c (run_one_test): Log "fork performed" and
"child started" events (only if not NO_TEST_HANDLE_FORK).

12 years agoMinor code refactoring of GC fork handlers (remove GC prefix)
Ivan Maidanski [Tue, 20 Nov 2012 16:55:55 +0000 (20:55 +0400)]
Minor code refactoring of GC fork handlers (remove GC prefix)

* pthread_support.c (GC_fork_prepare_proc, GC_fork_parent_proc,
GC_fork_child_proc): Declare as "static" instead of STATIC; remove
"GC_" prefix.
* win32_threads.c (GC_fork_prepare_proc, GC_fork_parent_proc,
GC_fork_child_proc): Likewise.
* pthread_support.c (GC_fork_parent_proc): Refine comment.
* pthread_support.c (GC_thr_init): Remove "GC_" prefix for
fork_prepare/parent/child_proc (only if CAN_HANDLE_FORK).
* win32_threads.c (GC_thr_init): Likewise.

12 years agoAdded GC_LONG_REFS_NOT_NEEDED ifdefs to exclude long link
Zach Saw [Mon, 19 Nov 2012 22:46:33 +0000 (09:46 +1100)]
Added GC_LONG_REFS_NOT_NEEDED ifdefs to exclude long link
functionality and other minor changes.

* finalize.c (GC_push_finalizer_structures,
GC_register_long_link, GC_unregister_long_link,
GC_move_long_link, GC_finalize): GC_LONG_REFS_NOT_NEEDED ifdefs to
exclude long link functionality.
* finalize.c (GC_dump_finalization_links,
GC_register_disappearing_link_inner,
GC_move_disappearing_link_inner): Changed from GC_INLINE to STATIC
function declaration.
* include/gc.h: use 2 spaces as a sentence delimiter in comment
added in previous commit.

12 years agoUpdate TODO (add FIXME regarding forking in Cygwin)
Ivan Maidanski [Mon, 19 Nov 2012 16:03:10 +0000 (20:03 +0400)]
Update TODO (add FIXME regarding forking in Cygwin)

12 years agoAdd public GC_start_mark_threads() to allow parallel marker in fork child
Ivan Maidanski [Mon, 19 Nov 2012 15:58:51 +0000 (19:58 +0400)]
Add public GC_start_mark_threads() to allow parallel marker in fork child

* include/gc.h (GC_start_mark_threads): New API function prototype.
* misc.c (GC_start_mark_threads): New API function definition (empty)
if THREADS but not PARALLEL_MARK or not CAN_HANDLE_FORK.
* pthread_support.c (available_markers_m1): New static variable or
macro (redirecting to GC_markers_m1) depending on CAN_HANDLE_FORK
(only if PARALLEL_MARK).
* win32_threads.c (available_markers_m1): Likewise.
* pthread_support.c (start_mark_threads): Redirect to
GC_start_mark_threads (and decorate with GC_API/GC_CALL) if
CAN_HANDLE_FORK (and PARALLEL_MARK); skip start if parallel markers
are disabled or already started if CAN_HANDLE_FORK; iterate up to
available_markers_m1 (instead of GC_markers_m1); always set
GC_markers_m1 value.
* win32_threads.c (start_mark_threads): Likewise.
* pthread_support.c (GC_thr_init): Set (and test) available_markers_m1
value instead of GC_markers_m1/GC_parallel (only if PARALLEL_MARK).
* win32_threads.c (GC_thr_init): Likewise.
* tests/test.c (NO_TEST_HANDLE_FORK): Do not define if
TEST_HANDLE_FORK.
* tests/test.c (run_one_test): Invoke GC_start_mark_threads (and
additional GC_gcollect) in forked child (only if THREADS but not
NO_TEST_HANDLE_FORK); do not call tiny_reverse_test if not THREADS.
* win32_threads.c (start_mark_threads): Add assertion that the caller
is not holding the allocation lock (to match that in
pthread_support.c) if GC_PTHREADS_PARAMARK.

12 years agoUpdate TODO file ('heap sections overflow' Cygwin bug fixed)
Ivan Maidanski [Mon, 19 Nov 2012 05:38:46 +0000 (09:38 +0400)]
Update TODO file ('heap sections overflow' Cygwin bug fixed)

12 years agoFix heap sections overflow for Win32/Cygwin with enabled parallel marker
Ivan Maidanski [Mon, 19 Nov 2012 05:36:04 +0000 (09:36 +0400)]
Fix heap sections overflow for Win32/Cygwin with enabled parallel marker

* include/private/gc_priv.h (MAX_HEAP_SECTS): Define to 384 instead of
128 if Win32/Cygwin and PARALLEL_MARK.

12 years agoAdjust logged messages in start_mark_threads and GC_thr_init
Ivan Maidanski [Mon, 19 Nov 2012 05:23:58 +0000 (09:23 +0400)]
Adjust logged messages in start_mark_threads and GC_thr_init

* pthread_support.c (start_mark_threads): Move GC_COND_LOG_PRINTF call
to the function end (i.e., call pthread_attr_destroy first).
* pthread_support.c (GC_thr_init): Do not log number of marker threads
since start_mark_threads logs number of started mark helper threads
(only if PARALLEL_MARK).
* win32_threads.c (start_mark_threads): Update comment; move logging
of started mark helper threads from GC_thr_init().
* win32_threads.c (GC_thr_init): Log corresponding message if parallel
marking is disabled (similar to that in pthread_support.c, only if
PARALLEL_MARK).

12 years agoMinor code refactoring of GC_thr_init (use 'markers_m1' local variable)
Ivan Maidanski [Mon, 19 Nov 2012 04:50:44 +0000 (08:50 +0400)]
Minor code refactoring of GC_thr_init (use 'markers_m1' local variable)

* pthread_support.c (GC_thr_init): Declare "markers_m1" local
variable, use it for keeping intermediate results (and store the final
result to global GC_markers_m1).
* win32_threads.c (GC_thr_init): Likewise.
* pthread_support.c (GC_thr_init): Remove redundant check of
GC_parallel.

12 years agoEliminate 'unused variable' compiler warning in start_mark_threads (HP/UX)
Ivan Maidanski [Mon, 19 Nov 2012 04:10:48 +0000 (08:10 +0400)]
Eliminate 'unused variable' compiler warning in start_mark_threads (HP/UX)

* pthread_support.c (start_mark_threads): Remove unused "code" local
variable (only if HPUX or GC_DGUX386_THREADS).

12 years agoRedone the comments for long link GC_API functions.
Zach Saw [Mon, 19 Nov 2012 01:45:07 +0000 (12:45 +1100)]
Redone the comments for long link GC_API functions.

* include/gc.h: As above.

12 years agoMerge branch 'add-long-weakref' of https://github.com/zachsaw/bdwgc into add-long...
Zach Saw [Mon, 19 Nov 2012 01:36:12 +0000 (12:36 +1100)]
Merge branch 'add-long-weakref' of https://github.com/zachsaw/bdwgc into add-long-weakref

12 years agoAdded long weakref support.
Zach Saw [Mon, 19 Nov 2012 01:34:10 +0000 (12:34 +1100)]
Added long weakref support.

* include/gc.h: Added 3 GC_API functions for long weakref support:
GC_register_long_link, GC_unregister_long_link and GC_move_long_link.
* include/gc.h: Added corresponding GC_REGISTER_LONG_LINK macros.
* finalize.c: Add implementation of the above functions,
GC_ll_hashtbl for long links and GC_old_ll_entries.
* finalize.c (GC_push_finalizer_structures): GC_push_all long link
hash table entries as well.
* finalize.c (GC_dump_finalization): Refactored dump
disappearing link code out to GC_dump_finalization_links accepting
an argument of pointer to struct dl_hashtbl_s.
* finalize.c (GC_print_finalization_stats): Added long link stats
print out.
* finalize.c (GC_finalize): Added saving current GC_ll_hashtbl
entry count to GC_old_ll_entries,
GC_make_disappearing_links_disappear and
GC_remove_dangling_disappearing_links for long links.

12 years agodded long weakref support.
Zach Saw [Mon, 19 Nov 2012 01:34:10 +0000 (12:34 +1100)]
dded long weakref support.

* include/gc.h: Added 3 GC_API functions for long weakref support:
GC_register_long_link, GC_unregister_long_link and GC_move_long_link.
* include/gc.h: Added corresponding GC_REGISTER_LONG_LINK macros.
* finalize.c: Add implementation of the above functions,
GC_ll_hashtbl for long links and GC_old_ll_entries.
* finalize.c (GC_push_finalizer_structures): GC_push_all long link
hash table entries as well.
* finalize.c (GC_dump_finalization): Refactored dump
disappearing link code out to GC_dump_finalization_links accepting
an argument of pointer to struct dl_hashtbl_s.
* finalize.c (GC_print_finalization_stats): Added long link stats
print out.
* finalize.c (GC_finalize): Added saving current GC_ll_hashtbl
entry count to GC_old_ll_entries,
GC_make_disappearing_links_disappear and
GC_remove_dangling_disappearing_links for long links.

12 years agoFix GC_marker_Id elements initialization (WinCE)
Ivan Maidanski [Sun, 18 Nov 2012 19:20:23 +0000 (23:20 +0400)]
Fix GC_marker_Id elements initialization (WinCE)

* win32_threads.c (GC_marker_cv, GC_marker_Id): Move variable
definition up to precede GC_mark_thread (only if PARALLEL_MARK and
DONT_USE_SIGNALANDWAIT).
* win32_threads.c (GC_mark_thread): Set corresponding element of
GC_marker_Id[] to GetCurrentThreadId() value (only if PARALLEL_MARK
and DONT_USE_SIGNALANDWAIT).
* win32_threads.c (start_mark_threads): Do not set GC_marker_Id[]
elements here because GetCurrentThreadId should be invoked from the
corresponding thread; update comment (only if PARALLEL_MARK and
DONT_USE_SIGNALANDWAIT).

12 years agoMove LOCK/UNLOCK from GC_unregister_disappearing_link_inner outer
Ivan Maidanski [Sat, 17 Nov 2012 14:55:14 +0000 (18:55 +0400)]
Move LOCK/UNLOCK from GC_unregister_disappearing_link_inner outer

* finalize.c (GC_unregister_disappearing_link_inner): Add comment;
change return type (return entry of unregistered linked or NULL);
do not check link alignment; do not acquire the lock and do not free
the unregistered entry.
* finalize.c (GC_unregister_disappearing_link): Check link alignment,
invoke GC_unregister_disappearing_link_inner holding the allocation
lock and free found entry (if any).

12 years agoMinor code refactoring of GC_register/move/unregister_disappearing_link
Ivan Maidanski [Sat, 17 Nov 2012 13:35:53 +0000 (17:35 +0400)]
Minor code refactoring of GC_register/move/unregister_disappearing_link

* finalize.c (dl_set_next): Cast result to void.
* finalize.c (GC_general_register_disappearing_link,
GC_unregister_disappearing_link_inner,
GC_move_disappearing_link_inner, DELETE_DL_HASHTBL_ENTRY): Use
explicit comparison to NULL instead of "!" operator.
* finalize.c (FREE_DL_ENTRY): New macro.
* finalize.c (GC_unregister_disappearing_link_inner): Use
FREE_DL_ENTRY.
* finalize.c (GC_move_disappearing_link_inner): Add comment; use NULL
instead of 0 for pointers.
* finalize.c (GC_dump_finalization, ITERATE_DL_HASHTBL_BEGIN,
GC_finalize, GC_enqueue_all_finalizers): Remove redundant parenthesis
in expression for dl_size/fo_size calculation.
* finalize.c (DELETE_DL_HASHTBL_ENTRY): Add outermost '{', '}' braces.
* finalize.c (GC_make_disappearing_links_disappear_inner,
GC_remove_dangling_disappearing_links_inner): Move outermost '{', '}'
braces to ITERATE_DL_HASHTBL_BEGIN/END, respectively; add trailing ';'
for DELETE_DL_HASHTBL_ENTRY call.

12 years agoChanged pointer comparison to NULL from p == NULL to !p.
Zach Saw [Fri, 16 Nov 2012 10:46:59 +0000 (21:46 +1100)]
Changed pointer comparison to NULL from p == NULL to !p.
* finalize.c (ITERATE_DL_HASHTBL_BEGIN) : As above.

12 years agoChanged pointer comparison to NULL from p == NULL to !p.
Zach Saw [Fri, 16 Nov 2012 10:44:01 +0000 (21:44 +1100)]
Changed pointer comparison to NULL from p == NULL to !p.
* finalize.c (DELETE_DL_HASHTBL_ENTRY) : As above.

12 years agoRemoved _inner suffix from
Zach Saw [Fri, 16 Nov 2012 10:32:53 +0000 (21:32 +1100)]
Removed _inner suffix from
GC_make_disappearing_links_disappear_inner and
GC_remove_dangling_disappearing_links_inner.
Also replace 0 with NULL for pointers for refactored codes.
Moved DCL_LOCK_STATE to immediately follow last local var decl.
GC_move_disappearing_link_locked: rename back to
GC_move_disappearing_link_inner.
* finalize.c (GC_make_disappearing_links_disappear,
GC_remove_dangling_disappearing_links,
GC_move_disappearing_link_inner, GC_move_disappearing_link) :
As described above.

12 years agoCreated GC_make_disappearing_links_disappear and
Zach Saw [Thu, 15 Nov 2012 23:20:11 +0000 (10:20 +1100)]
Created GC_make_disappearing_links_disappear and
GC_remove_dangling_disappearing_links. Moved related code under
comments for those respective functions into their respective
*_inner functions which accepts an additional dl_hashtbl_s struct.
Also refactored dl_hashtbl iteration and entry deletion codes into
macros to ease readability.

* finalize.c (GC_finalize): As described above.

12 years agoMoved code from GC_move_disappearing_link_inner that is within
Zach Saw [Thu, 15 Nov 2012 22:34:36 +0000 (09:34 +1100)]
Moved code from GC_move_disappearing_link_inner that is within
locked region to GC_move_disappearing_link_locked. Also moved
DECL_LOCK_STATE from GC_unregister_disappearing_link to
GC_unregister_disappearing_link_inner.

* finalize.c (GC_move_disappearing_link_inner,
GC_unregister_disappearing_link_inner): As described above.

12 years agoImprove logging for Android differentiating messages by log level
Ivan Maidanski [Thu, 15 Nov 2012 19:06:14 +0000 (23:06 +0400)]
Improve logging for Android differentiating messages by log level

* include/private/gc_priv.h (VERBOSE): Move definition to be upper
than GC_print_stats.
* include/private/gc_priv.h (GC_print_stats): Define as macro (to
VERBOSE) if GC_ANDROID_LOG.
* include/private/gc_priv.h (GC_real_print_stats): New macro defined
to GC_print_stats if not GC_ANDROID_LOG otherwise declared as global
variable replacing GC_print_stats.
* include/private/gc_priv.h (GC_stats_log_printf,
GC_verbose_log_printf): Declare as GC_INNER function instead of
macro if GC_ANDROID_LOG.
* misc.c (GC_print_stats): Replace to GC_real_print_stats.
* misc.c (GC_init): Set GC_real_print_stats instead of GC_print_stats.
* misc.c (GC_log_printf): Use DEBUG log level instead of INFO (only if
GC_ANDROID_LOG).
* misc.c (GC_warn_printf): New macro (if not GC_ANDROID_LOG) or static
routine (that writes to Android log at WARN level).
* misc.c (GC_stats_log_printf, GC_verbose_log_printf): New GC_INNER
function definition (only if GC_ANDROID_LOG) using INFO/VERBOSE
Android log levels.
* misc.c (GC_default_warn_proc): Use GC_warn_printf instead of
GC_err_printf.

12 years agoCall GC_stats/verbose_log_printf instead of GC_log_printf if print_stats
Ivan Maidanski [Thu, 15 Nov 2012 17:47:22 +0000 (21:47 +0400)]
Call GC_stats/verbose_log_printf instead of GC_log_printf if print_stats
(code refactoring)

* alloc.c (GC_try_to_collect_inner, GC_stopped_mark,
GC_finish_collection): Use GC_stats_log_printf instead of
GC_log_printf inside "if (GC_print_stats)" blocks.
* include/private/gc_priv.h (GC_COND_LOG_PRINTF): Likewise.
* finalize.c (GC_print_finalization_stats): Use GC_stats_log_printf
instead of GC_log_printf (since the function is invoked only inside
"if (GC_print_stats)" blocks).
* include/private/gc_priv.h (GC_printf, GC_log_printf): Refine
comment.
* include/private/gc_priv.h (GC_stats_log_printf,
GC_verbose_log_printf): New macro (redirected to GC_log_printf).
* reclaim.c (GC_reclaim_all): Use GC_verbose_log_printf instead of
GC_log_printf inside "if (GC_print_stats==VERBOSE)" blocks.
* include/private/gc_priv.h (GC_COND_LOG_PRINTF): Likewise.
* misc.c (GC_LOG_PRINTF_IMPL): New macro (only if GC_ANDROID_LOG,
copy most code from GC_log_printf).
* misc.c (GC_log_printf): Define separately for Android using
GC_LOG_PRINTF_IMPL macro (only if GC_ANDROID_LOG).

12 years agoAdjust GC_dont_expand/gc/precollect and GC_print_stats type to match gc.h
Ivan Maidanski [Thu, 15 Nov 2012 04:40:42 +0000 (08:40 +0400)]
Adjust GC_dont_expand/gc/precollect and GC_print_stats type to match gc.h

* alloc.c (GC_dont_expand): Change type from GC_bool to int (as
declared in gc.h).
* misc.c (GC_dont_gc, GC_dont_precollect, GC_print_stats): Likewise.
* misc.c (GC_dont_gc, GC_dont_precollect): Initialize to FALSE instead
of 0.

12 years agoMoved most code from disappearing_link manipulation functions
Zach Saw [Thu, 15 Nov 2012 01:18:25 +0000 (12:18 +1100)]
Moved most code from disappearing_link manipulation functions
(except for argument checks) to new *_inner function, accepting
a pointer to GC_dl_hashtbl along with the original arguments.

* finalize.c (GC_general_register_disappearing_link,
GC_unregister_disappearing_link, GC_move_disappearing_link):
Moved code out into their respective *_inner functions, namely
GC_register_disappearing_link_inner,
GC_unregister_disappearing_link_inner,
GC_move_disappearing_link_inner respectively. These _inner
functions accept an additional argument which is a pointer
to struct dl_hashtbl_s on top of its original arguments.

12 years agoUpdate AUTHORS file
Ivan Maidanski [Wed, 14 Nov 2012 18:18:56 +0000 (22:18 +0400)]
Update AUTHORS file

12 years agoUpdate finalize.c
zachsaw [Wed, 14 Nov 2012 10:14:25 +0000 (21:14 +1100)]
Update finalize.c

Changed C99-style designated init of GC_dl_hashtbl struct to use old C89-style for wider compiler compatibility.

12 years agoRefactored disappearing link hash table variables into a hash table struct
Zach Saw [Wed, 14 Nov 2012 05:31:19 +0000 (16:31 +1100)]
Refactored disappearing link hash table variables into a hash table struct

12 years agoAdd support of Android logger
Ivan Maidanski [Tue, 13 Nov 2012 05:15:59 +0000 (09:15 +0400)]
Add support of Android logger

* doc/README.macros (GC_ANDROID_LOG): Document new macro.
* misc.c: Include android/log.h if GC_ANDROID_LOG.
* misc.c (GC_ANDROID_LOG_TAG): Define new macro if GC_ANDROID_LOG (and
not ye defined).
* misc.c (GC_printf, GC_log_printf, GC_err_puts): Output message using
__android_log_write with ANDROID_LOG_DEBUG/INFO/ERROR level
(respectively) and GC_ANDROID_LOG_TAG logger name if GC_ANDROID_LOG
(skip writing to GC_stdout/stderr/log (respectively) in this case
unless redirected to a file).
* misc.c (GC_default_on_abort): If GC_ANDROID_LOG then invoke
__android_log_assert after WRITE with the same message except for
omitting redundant "\n" (and ignore GC_LOOP_ON_ABORT checking in this
case because android_log_assert is a no-return function).

12 years agoCode refactoring of GC_X_printf to improve extensibility
Ivan Maidanski [Tue, 13 Nov 2012 04:04:41 +0000 (08:04 +0400)]
Code refactoring of GC_X_printf to improve extensibility

* misc.c (GC_DEFAULT_STDOUT_FD, GC_DEFAULT_STDERR_FD): New macro.
* misc.c (GC_stdout, GC_stderr, GC_log): Use GC_DEFAULT_STDOUT_FD and
GC_DEFAULT_STDERR_FD (only if not OS2, MACOS, Win32).
* misc.c (GC_PRINTF_IMPL): Replace with GC_PRINTF_FILLBUF (move out
"buf" array definition, move out WRITE call, remove "f" and "f_name"
arguments, add "buf" argument, use sizeof(buf)-1 instead of BUFSZ.
* misc.c (GC_printf, GC_err_printf, GC_log_printf): Declare and use
"buf" array; replace GC_PRINTF_IMPL with GC_PRINTF_FILLBUF.
* misc.c (GC_printf, GC_log_printf): Call WRITE to output "buf"
content.
* misc.c (GC_err_printf): Call GC_err_puts to output "buf" content.
* misc.c (GC_default_warn_proc): Add TODO item.

12 years agoBetter document GC_warn_proc in gc.h
Ivan Maidanski [Mon, 12 Nov 2012 18:01:26 +0000 (22:01 +0400)]
Better document GC_warn_proc in gc.h

* include/gc.h (GC_warn_proc): Refine comment (add information about
the arguments).

12 years agoReplace conditional GC_log_printf calls with GC_COND/VERBOSE_LOG_PRINTF
Ivan Maidanski [Mon, 12 Nov 2012 17:56:57 +0000 (21:56 +0400)]
Replace conditional GC_log_printf calls with GC_COND/VERBOSE_LOG_PRINTF
(code refactoring)

* allchblk.c (GC_freehblk): Replace
"if (GC_print_stats) GC_log_printf" with GC_COND_LOG_PRINTF.
* alloc.c (GC_timeout_stop_func, GC_maybe_gc, GC_try_to_collect_inner,
GC_stopped_mark, GC_finish_collection, GC_expand_hp_inner,
GC_collect_or_expand): Likewise.
* backgraph.c (backwards_height, GC_print_back_graph_stats): Likewise.
* checksums.c (GC_check_blocks, GC_check_dirty): Likewise.
* dyn_load.c (GC_register_dynamic_libraries): Likewise.
* finalize.c (GC_general_register_disappearing_link,
GC_register_finalizer_inner): Likewise.
* gcj_mlc.c (GC_init_gcj_malloc): Likewise.
* headers.c (GC_scratch_alloc): Likewise.
* mark.c (GC_mark_some_inner, GC_mark_some,
GC_signal_mark_stack_overflow, GC_return_mark_stack,
alloc_mark_stack): Likewise.
* obj_map.c (GC_add_map_entry): Likewise.
* os_dep.c (GC_get_maps, backing_store_base_from_proc,
GC_register_data_segments, detect_GetWriteWatch,
GC_add_current_malloc_heap, GC_remap, PROTECT, GC_write_fault_handler,
GC_dirty_init, GC_mprotect_thread): Likewise.
* pthread_stop_world.c (GC_stop_world, GC_start_world, GC_stop_init):
Likewise.
* pthread_support.c (start_mark_threads, GC_thr_init): Likewise.
* win32_threads.c (GC_register_my_thread_inner, GC_thr_init):
Likewise.
* alloc.c (GC_finish_collection): Replace
"if (GC_print_stats == VERBOSE) GC_log_printf" with
GC_VERBOSE_LOG_PRINTF.
* blacklst.c (GC_promote_black_lists): Likewise.
* darwin_stop_world.c (GC_push_all_stacks): Likewise.
* mark.c (GC_mark_local, GC_do_parallel_mark): Likewise.
* os_dep.c (GC_dirty_init): Likewise.
* pthread_stop_world.c (GC_push_all_stacks): Likewise.
* win32_threads.c (GC_push_all_stacks): Likewise.
* include/private/gc_priv.h (GC_COND_LOG_PRINTF,
GC_VERBOSE_LOG_PRINTF): New macro (check GC_print_stats and call
GC_log_printf if enabled).
* os_dep.c (GC_dirty_init, GC_read_dirty): Replace
"if (GC_print_stats) GC_err_printf" with WARN.

12 years agoFix Win32 GC_write preventing potential infinite recursion at abort
Ivan Maidanski [Sun, 11 Nov 2012 14:57:29 +0000 (18:57 +0400)]
Fix Win32 GC_write preventing potential infinite recursion at abort

* misc.c (GC_write): Define "inside_write" static variable (only
for Win32 and only if THREADS and GC_ASSERTIONS or
GC_PRINT_VERBOSE_STATS); if this variable is set then just return,
set this variable if GC_write_disabled or GC_log is
INVALID_HANDLE_VALUE just before ABORT call (to prevent infinite
recursion).
* misc.c (GC_default_on_abort): Do not call WRITE if GC_write_disabled
(only for Win32 and only if THREADS and GC_ASSERTIONS) to prevent
abort in GC_write.

12 years agoReplace Win32 GC_delete_gc_thread with GC_delete_gc_thread_no_free
Ivan Maidanski [Sun, 11 Nov 2012 12:29:09 +0000 (16:29 +0400)]
Replace Win32 GC_delete_gc_thread with GC_delete_gc_thread_no_free

* win32_threads.c (GC_delete_gc_thread): Rename to
GC_delete_gc_thread_no_free; remove GC_INTERNAL_FREE call; update
comment.
* win32_threads.c (GC_delete_thread, GC_suspend, GC_DllMain): Replace
GC_delete_gc_thread call with GC_delete_gc_thread_no_free one (since
GC_win32_dll_threads is true thus there is no entry to free).
* win32_threads.c (GC_delete_thread): Change type of "t" local
variable from GC_thread to GC_vthread.
* win32_threads.c (GC_stop_world): Update comment.
* win32_threads.c (GC_pthread_join, GC_pthread_detach): Replace
GC_delete_gc_thread call with GC_delete_gc_thread_no_free and
GC_INTERNAL_FREE calls (since GC_win32_dll_threads is false).
* win32_threads.c (GC_pthread_detach): Add assertion that
GC_win32_dll_threads is false.

12 years agoImprove GC output atomicity in GC_print_obj, GC_print_all_errors
Ivan Maidanski [Sun, 11 Nov 2012 07:26:38 +0000 (11:26 +0400)]
Improve GC output atomicity in GC_print_obj, GC_print_all_errors
(as well as in GC_print_backtrace, GC_print_all_smashed_proc)

* blacklst.c (GC_default_print_heap_obj_proc): Refine printed message;
output object kind; output trailing "\n".
* reclaim.c (GC_print_all_errors): Do not print object kind (before
GC_print_heap_obj call).
* dbg_mlc.c (GC_print_backtrace): Remove redundant printed "\n" after
GC_print_heap_obj call.
* reclaim.c (GC_print_all_errors): Likewise.
* dbg_mlc.c (GC_print_type): Remove (move code to GC_print_obj
replacing "p" local variable with "q").
* dbg_mlc.c (GC_print_obj): Merge adjacent GC_err_printf and
GC_err_puts invocation into a single GC_err_printf one (for output
atomicity).
* dbg_mlc.c (GC_print_all_smashed_proc): Print number of found objects
first.
* reclaim.c (GC_print_all_errors): Likewise.
* dbg_mlc.c (GC_print_all_smashed_proc): Remove printed "\n" at list
end.
* include/private/gc_priv.h (GC_print_heap_obj, GC_printf): Refine
comments.

12 years agoImprove GC error printing atomicity in GC_add_to_black_list_normal/stack
Ivan Maidanski [Sat, 10 Nov 2012 11:37:06 +0000 (15:37 +0400)]
Improve GC error printing atomicity in GC_add_to_black_list_normal/stack
(as well as in GC_print_sig_mask, GC_print_block_list, GC_print_free_list)

* blacklst.c (GC_print_source_ptr): Replace with 3-argument
GC_print_blacklisted_ptr(); rename "p" to "source" argument;
move GC_err_printf calls surrounding GC_print_source_ptr invocation
from GC_add_to_black_list_normal and GC_add_to_black_list_stack;
replace GC_default_print_heap_obj_proc call with the corresponding
GC_err_printf call; merge adjacent GC_err_printf calls into single
one (for output in-line atomicity).
* blacklst.c (GC_add_to_black_list_normal,
GC_add_to_black_list_stack): Replace GC_print_source_ptr (and
surrounding GC_err_printf) call with GC_print_blacklisted_ptr one.
* pthread_stop_world.c (GC_print_sig_mask): Print each blocked signal
on a separate line (replace multiple GC_printf calls with a single one
ending with "\n").
* reclaim.c (GC_print_block_descr): Terminate GC_printf message with
"\n" (for output in-line atomicity).
* reclaim.c (GC_print_block_list): Remove redundant "\n" at the
beginning of GC_printf message (since GC_print_block_descr prints
new-line at the end of the message).
* reclaim.c (GC_print_free_list): Enumerate printed objects starting
from 0 (instead of 1); print information about each free object on
a separate line (replace multiple GC_printf calls with a single one
ending with "\n"); remove "lastBlock" local variable.

12 years agoFix GC_lock comment (pthreads)
Ivan Maidanski [Thu, 8 Nov 2012 18:17:28 +0000 (22:17 +0400)]
Fix GC_lock comment (pthreads)

* pthread_support.c (GC_lock): Fix USE_SPIN_LOCK macro name in comment.

12 years agoImprove GC error printing atomicity in GC_debug_X and GC_print_obj
Ivan Maidanski [Thu, 8 Nov 2012 17:51:10 +0000 (21:51 +0400)]
Improve GC error printing atomicity in GC_debug_X and GC_print_obj

* dbg_mlc.c (GC_generate_random_backtrace_no_gc): Refine comment.
* dbg_mlc.c (GC_print_type): Replace multiple code fragments calling
GC_err_puts with a single invocation of GC_err_puts (or GC_err_printf)
at the routine end (code refactoring).
* dbg_mlc.c (IF_NOT_SHORTDBG_HDRS, COMMA_IFNOT_SHORTDBG_HDRS): New
macro (used by GC_print_obj).
* dbg_mlc.c (GC_print_obj, GC_debug_malloc,
GC_debug_malloc_ignore_off_page,
GC_debug_malloc_atomic_ignore_off_page, GC_debug_malloc_stubborn,
GC_debug_malloc_atomic, GC_debug_malloc_uncollectable,
GC_debug_malloc_atomic_uncollectable): Replace adjacent GC_err_printf
and GC_err_puts calls with a single GC_err_printf invocation (for
output atomicity).
* gcj_mlc.c (GC_debug_gcj_malloc): Likewise.
* os_dep.c (GC_register_data_segments): Likewise.
* dbg_mlc.c (GC_malloc_stubborn): Fix printed function name.

12 years agoSimplify LOCK/UNLOCK macro definition for static code analysis tools
Ivan Maidanski [Thu, 8 Nov 2012 17:19:02 +0000 (21:19 +0400)]
Simplify LOCK/UNLOCK macro definition for static code analysis tools

* include/private/gc_locks.h (USE_PTHREAD_LOCKS): Explicitly define
if LINT2 and GC_PTHREADS.
* include/private/gc_locks.h (LOCK, UNLOCK): Redirect to
UNCOND_[UN]LOCK (omitting GC_need_to_lock check) if LINT2.

12 years agoAvoid LOCK/UNLOCK hard-coding in gc_locks.h for PS3 target
Ivan Maidanski [Thu, 8 Nov 2012 16:48:17 +0000 (20:48 +0400)]
Avoid LOCK/UNLOCK hard-coding in gc_locks.h for PS3 target

* include/private/gc_locks.h (USE_PTHREAD_LOCKS): Define for
SN_TARGET_PS3 target.
* include/private/gcconfig.h (NO_PTHREAD_TRYLOCK): Likewise.
* include/private/gc_locks.h (GC_allocate_ml, LOCK, UNLOCK): Remove
explicit definition for SN_TARGET_PS3.
* include/private/gc_locks.h (UNCOND_LOCK): Define as
pthread_mutex_lock(...) instead of GC_lock() (which calls
pthread_mutex_lock) if USE_PTHREAD_LOCKS but not GC_ASSERTIONS and
not USE_SPIN_LOCK.

12 years agoUse GC_log_printf for logging instead of GC_[err_]printf
Ivan Maidanski [Thu, 8 Nov 2012 04:01:51 +0000 (08:01 +0400)]
Use GC_log_printf for logging instead of GC_[err_]printf

* backgraph.c (GC_print_back_graph_stats): Use GC_err_printf instead
of GC_printf (since invoked GC_print_heap_obj uses GC_err_printf).
* darwin_stop_world.c (GC_FindTopOfStack): Replace GC_printf with
GC_log_printf (inside DEBUG_THREADS blocks).
* include/private/gc_priv.h (GC_printf, GC_log_printf): Add comment.
* malloc.c (GC_free): Replace GC_err_printf with GC_log_printf (inside
LOG_ALLOCS block).
* thread_local_alloc.c (GC_malloc): Likewise.