platform/upstream/libgc.git
11 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.

11 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.

11 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).

11 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.

11 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)

11 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.

11 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)

11 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.

11 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).

11 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.

11 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).

11 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).

11 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.

11 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).

11 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.

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

11 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).

11 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.

11 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).

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 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.

11 years agoFix debug_register_displacement calls from GC_debug_generic_malloc_inner
Ivan Maidanski [Wed, 7 Nov 2012 17:00:36 +0000 (21:00 +0400)]
Fix debug_register_displacement calls from GC_debug_generic_malloc_inner
(fix commit 38965f2)

* dbg_mlc.c (GC_start_debugging_inner): New static routine (move code
from old GC_start_debugging except for GC_register_displacement call
and add assertion on the lock).
* dbg_mlc.c (GC_start_debugging): Invoke GC_start_debugging_inner
holding the lock.
* dbg_mlc.c (GC_debug_register_displacement): Optimize speed (lock
once and use _inner variant of GC_register_displacement).
* dbg_mlc.c (GC_debug_generic_malloc_inner,
GC_debug_generic_malloc_inner_ignore_off_page): Invoke
GC_start_debugging_inner instead of GC_start_debugging (since the lock
is already acquired).

11 years agoAdd 'bytes reclaimed' counters to public GC_prof_stats_s
Ivan Maidanski [Wed, 7 Nov 2012 03:05:49 +0000 (07:05 +0400)]
Add 'bytes reclaimed' counters to public GC_prof_stats_s

* alloc.c (GC_finish_collection): Add GC_bytes_found value to
GC_reclaimed_bytes_before_gc (if the former is non-negative and
not GC_GET_HEAP_USAGE_NOT_NEEDED) before reseting GC_bytes_found.
* include/gc.h (GC_prof_stats_s): Add bytes_reclaimed_since_gc and
reclaimed_bytes_before_gc fields.
* include/private/gc_priv.h (GC_reclaimed_bytes_before_gc): Declare
new GC inner variable (only if not GC_GET_HEAP_USAGE_NOT_NEEDED).
* misc.c (GC_reclaimed_bytes_before_gc): Define new variable (only if
not GC_GET_HEAP_USAGE_NOT_NEEDED).
* misc.c (fill_prof_stats): Fill in bytes_reclaimed_since_gc and
reclaimed_bytes_before_gc fields.
* tests/test.c (check_heap_stats): Invoke GC_get_heap_usage_safe,
GC_get_prof_stats, GC_get_prof_stats_unsafe (only if not
GC_GET_HEAP_USAGE_NOT_NEEDED).

11 years agoUpdate TODO (add GC_prof_stats_s candidate fields)
Ivan Maidanski [Tue, 6 Nov 2012 16:21:09 +0000 (20:21 +0400)]
Update TODO (add GC_prof_stats_s candidate fields)

11 years agoAdd GC_get_prof_stats[_unsafe]() to GC public API
Ivan Maidanski [Tue, 6 Nov 2012 15:53:02 +0000 (19:53 +0400)]
Add GC_get_prof_stats[_unsafe]() to GC public API

* include/gc.h (GC_get_heap_size): Update comment.
* include/gc.h (GC_prof_stats_s): New structure.
* include/gc.h (GC_get_prof_stats): New API function.
* include/gc.h (GC_get_prof_stats_unsafe): New API function (only if
GC_THREADS).
* misc.c (fill_prof_stats): New static function (only if not
GC_GET_HEAP_USAGE_NOT_NEEDED).
* misc.c (GC_get_prof_stats): New API function definition (only if not
GC_GET_HEAP_USAGE_NOT_NEEDED).
* misc.c (GC_get_prof_stats_unsafe): New API function definition (only
if THREADS but not GC_GET_HEAP_USAGE_NOT_NEEDED).

11 years agoRecognize GC_GET_HEAP_USAGE_NOT_NEEDED option
Ivan Maidanski [Tue, 6 Nov 2012 15:08:40 +0000 (19:08 +0400)]
Recognize GC_GET_HEAP_USAGE_NOT_NEEDED option

* misc.c (GC_get_heap_usage_safe): Do not define if
GC_GET_HEAP_USAGE_NOT_NEEDED (for smaller code size if requested).

11 years agoAdd FIXME for GC_max_large_allocd_bytes and GC_mark_stack_size growth
Ivan Maidanski [Tue, 6 Nov 2012 03:52:34 +0000 (07:52 +0400)]
Add FIXME for GC_max_large_allocd_bytes and GC_mark_stack_size growth

* malloc.c (GC_alloc_large): Add FIXME for GC_max_large_allocd_bytes
(currently there is no way for the variable value to be decreased over
the run time).
* mark.c (alloc_mark_stack): Add FIXME for GC_mark_stack_size.

11 years agoFix unit in comment for some counters in gc_priv.h
Ivan Maidanski [Tue, 6 Nov 2012 03:13:29 +0000 (07:13 +0400)]
Fix unit in comment for some counters in gc_priv.h

* include/private/gc_priv.h (_GC_arrays): Fix comment for
_bytes_allocd_before_gc, _bytes_allocd, _composite_in_use and
_atomic_in_use fields (replace "words" unit with "bytes").
* include/private/gc_priv.h (GC_objfreelist): Fix comment (replace
"words" unit with "bytes").

11 years agoUpdate ChangeLog file
Ivan Maidanski [Wed, 31 Oct 2012 16:49:40 +0000 (20:49 +0400)]
Update ChangeLog file

11 years agoFix potential double fclose in test_extras (cordtest)
Ivan Maidanski [Wed, 24 Oct 2012 04:29:42 +0000 (08:29 +0400)]
Fix potential double fclose in test_extras (cordtest)

* cord/tests/cordtest.c (test_extras): Explicitly clear cord handles
obtained from CORD_from_file(), invoke GC_gcollect and
GC_invoke_finalizers to force f1a, f1b, f2 handles to be closed before
removing the files; remove the second attempts to remove the files on
rename failure (print a warning instead) as it might cause double
fclose (or double free); add comments.

11 years agoCheck traceable_allocator.allocate result before dereference in test_cpp
Ivan Maidanski [Wed, 24 Oct 2012 03:57:45 +0000 (07:57 +0400)]
Check traceable_allocator.allocate result before dereference in test_cpp

* tests/test_cpp.cc (main): Check "xptr" value (obtained from
traceable_allocator.allocate) for NULL (and exit with the
corresponding message in that case) before dereferencing it.

11 years agoFix pthread_attr_t resource leak in pthread_create
Ivan Maidanski [Wed, 24 Oct 2012 03:18:03 +0000 (07:18 +0400)]
Fix pthread_attr_t resource leak in pthread_create

* pthread_support.c (pthread_create): Cleanup my_attr resource by
calling pthread_attr_destroy (only if GC_ASSERTIONS).

11 years agoEliminate warning and simplify expression in GC_init_explicit_typing
Ivan Maidanski [Tue, 23 Oct 2012 05:04:57 +0000 (09:04 +0400)]
Eliminate warning and simplify expression in GC_init_explicit_typing

* typd_mlc.c (GC_init_explicit_typing): Cast -1 argument of
WORDS_TO_BYTES() to word (instead of casting its result) to avoid
"overflow in signed shift operation" warning (issued by some static
code analysis tools).
* typd_mlc.c (GC_init_explicit_typing): Simplify expression for
computing GC_bm_table elements (remove redundant right shift of
unsigned -1 before left shift for the same amount of bits).

11 years agoMinimize code duplication in GC_mark_and_push
Ivan Maidanski [Tue, 23 Oct 2012 04:46:38 +0000 (08:46 +0400)]
Minimize code duplication in GC_mark_and_push

* mark.c (GC_mark_and_push): Minimize code duplication (regarding
GC_ADD_TO_BLACK_LIST_NORMAL call) and eliminate
"nested checking of GC_all_interior_pointers value" warning (issued by
some code analysis tools).

11 years agoEliminate 'cast from int to pointer' warning in GC_exclude_static_roots
Ivan Maidanski [Tue, 23 Oct 2012 03:57:48 +0000 (07:57 +0400)]
Eliminate 'cast from int to pointer' warning in GC_exclude_static_roots

* mark_rts.c (GC_exclude_static_roots): Cast integer literal to
pointer via word type (to eliminate compiler warning).

11 years agoFix GC_clear_stack by declaring 'dummy' local array as volatile
Ivan Maidanski [Tue, 23 Oct 2012 03:45:51 +0000 (07:45 +0400)]
Fix GC_clear_stack by declaring 'dummy' local array as volatile

* misc.c (GC_clear_stack): Declare "dummy" local array as volatile to
prevent optimizing it out by compiler; add cast of "dummy" to void*
(to un-volatile the pointer) in BZERO call (only if THREADS).

11 years agoEliminate 'unused result' compiler warning in main() of test_cpp
Ivan Maidanski [Tue, 23 Oct 2012 03:28:36 +0000 (07:28 +0400)]
Eliminate 'unused result' compiler warning in main() of test_cpp

* tests/test_cpp.cc (main): Cast "b" local variable to void (to
outline that the result of new B(i) unused intentionally).

11 years agoEliminate 'uninitialized variable use' warning in test_printf (cord)
Ivan Maidanski [Mon, 22 Oct 2012 04:26:27 +0000 (08:26 +0400)]
Eliminate 'uninitialized variable use' warning in test_printf (cord)

* cord/tests/cordtest.c (test_printf): Initialize "l" and "s" local
variables (those values should be set by CORD_sprintf) to prevent
"uninitialized variable use" compiler (or static code analysis tool)
warning as well as for better testing of CORD_sprintf.

11 years agoDocument GC_NAMESPACE macro in README
Ivan Maidanski [Sat, 20 Oct 2012 12:16:01 +0000 (16:16 +0400)]
Document GC_NAMESPACE macro in README

* doc/README.macros (GC_NAMESPACE): Document.

11 years agoUpdate AUTHORS
Ivan Maidanski [Sat, 20 Oct 2012 12:09:49 +0000 (16:09 +0400)]
Update AUTHORS

11 years agoOptionally put gc_cpp symbols into 'boehmgc' namespace
Alexander Herz [Sat, 20 Oct 2012 12:07:12 +0000 (16:07 +0400)]
Optionally put gc_cpp symbols into 'boehmgc' namespace

* include/gc_cpp.h (GC_NAMESPACE): Recognize new macro.
* include/gc_cpp.h (GC_NS_QUALIFY): New macro definition (prefixing
argument with "boehmgc" namespace if GC_NAMESPACE).
* include/gc_cpp.h (GCPlacement, gc, gc_cleanup, GCCleanUpFunc,
gc::operator new, gc::operator delete, gc::operator new[],
gc::operator delete[], gc_cleanup::~gc_cleanup, gc_cleanup::cleanup):
Put into "boehmgc" namespace if GC_NAMESPACE.
* include/gc_cpp.h (operator new, operator delete, operator new[]):
Wrap GCPlacement, GCCleanUpFunc, UseGC, PointerFreeGC symbols into
GC_NS_QUALIFY.
* tests/test_cpp.cc (USE_GC, main): Wrap UseGC, GC, NoGC symbols into
GC_NS_QUALIFY.
* tests/test_cpp.cc (class B, class C, class D, class E): Wrap gc,
gc_cleanup class names into GC_NS_QUALIFY.

11 years agoFix GC_unix_mmap_get_mem for open of /dev/zero failure
Ivan Maidanski [Fri, 19 Oct 2012 05:10:07 +0000 (09:10 +0400)]
Fix GC_unix_mmap_get_mem for open of /dev/zero failure

* os_dep.c (GC_unix_mmap_get_mem): Check open("/dev/zero") (or open
of similar file on Symbian) result and abort (with the appropriate
message) on failure (only if USE_MMAP_ANON is undefined).

11 years agoCheck GC_base result in GC_print_all_smashed_proc
Ivan Maidanski [Fri, 19 Oct 2012 04:58:46 +0000 (08:58 +0400)]
Check GC_base result in GC_print_all_smashed_proc

* dbg_mlc.c (GC_print_all_smashed_proc): Add a code for a
LINT-like (static code analysis) tool to instruct it that GC_base is
invoked only with valid GC_smashed[] elements (so its result passed
to GC_print_smashed_obj is non-NULL).

11 years agoSpecify GC_pthread_join result is unused in threadkey_test
Ivan Maidanski [Fri, 19 Oct 2012 04:11:43 +0000 (08:11 +0400)]
Specify GC_pthread_join result is unused in threadkey_test

* tests/threadkey_test.c (main): Explicitly cast result of
GC_pthread_join to void (to outline that the result is unused
intentionally).

11 years agoImprove staticrootstest checks (tests)
Ivan Maidanski [Fri, 19 Oct 2012 03:50:18 +0000 (07:50 +0400)]
Improve staticrootstest checks (tests)

* tests/staticrootstest.c (libsrl_init): Report error (and exit) if
libsrl_init returns NULL; report the corresponding error if staticroot
content is not as expected.

11 years agoSpecify GC_malloc result is unused in some tests
Ivan Maidanski [Fri, 19 Oct 2012 03:27:29 +0000 (07:27 +0400)]
Specify GC_malloc result is unused in some tests

* tests/middle.c (main): Explicitly cast result of GC_malloc[_atomic]
to void (to outline that the result is unused intentionally).
* tests/test.c (run_one_test): Likewise.

11 years agoAdd comment for big local_mark_stack variables in mark.c
Ivan Maidanski [Fri, 19 Oct 2012 03:12:09 +0000 (07:12 +0400)]
Add comment for big local_mark_stack variables in mark.c

* mark.c (LOCAL_MARK_STACK_SIZE): Fix letter case in comment.
* mark.c (GC_do_parallel_mark, GC_help_marker): Add comment about
local_mark_stack local variable size (some static analysis tools
issue warning about it).
* mark.c (GC_help_marker): Move local_mark_stack variable declaration
down to be the last one in the function.

11 years agoEliminate SIGBUS-related dead code in GC_write_fault_handler (Linux)
Ivan Maidanski [Thu, 18 Oct 2012 15:05:54 +0000 (19:05 +0400)]
Eliminate SIGBUS-related dead code in GC_write_fault_handler (Linux)

* os_dep.c (GC_old_bus_handler_used_si): Define only if
FREEBSD/HURD/HPUX (since not used otherwise).
* os_dep.c (SIG_OK): Add comment.
* os_dep.c (GC_write_fault_handler): Replace as check of "sig" value
for SIGSEGV with that of SIGBUS and do this check only if
FREEBSD/HURD/HPUX (to avoid "dead code" compiler warning).
* os_dep.c (GC_dirty_init): Do not set GC_old_bus_handler_used_si
for LINUX (since used only on FREEBSD/HURD/HPUX); do not fix
GC_old_bus_handler value in case it is SIG_IGN for LINUX; add comment.

11 years agoRemove nested always-false ifdef for HPUX and FREEBSD
Ivan Maidanski [Thu, 18 Oct 2012 05:35:46 +0000 (09:35 +0400)]
Remove nested always-false ifdef for HPUX and FREEBSD

* include/private/gcconfig.h (USE_HPUX_FIXED_STACKBOTTOM): Add missing
dot in comment.
* os_dep.c (old_bus_act, GC_set_and_save_fault_handler,
GC_reset_fault_handler): Remove false ifdef check for HPUX and FREEBSD
inside ifdef for SUNOS5SIGS, IRIX5, OSF1, HURD, or NETBSD.

11 years agoDefine old_bus_handler static variable only if used (Unix)
Ivan Maidanski [Thu, 18 Oct 2012 04:50:36 +0000 (08:50 +0400)]
Define old_bus_handler static variable only if used (Unix)

* os_dep.c (old_bus_handler): Define only if SIGBUS (only for
UNIX_LIKE or NEED_FIND_LIMIT).

11 years agoFix vsprintf_args cleanup in CORD_vsprintf
Ivan Maidanski [Wed, 17 Oct 2012 18:07:54 +0000 (22:07 +0400)]
Fix vsprintf_args cleanup in CORD_vsprintf

* cord/cordprnt.c (CORD_vsprintf): Invoke va_end (before return) for
vsprintf_args initialized by [__]va_copy (only if __va_copy defined
or GCC but not DJGPP).

11 years agoMinor code refactoring of GC_allochblk_nth
Ivan Maidanski [Wed, 17 Oct 2012 17:58:38 +0000 (21:58 +0400)]
Minor code refactoring of GC_allochblk_nth

* allchblk.c (GC_allochblk_nth): Simplify code in the loop (which
allocates and drops the block in small chunks) by first calling
GC_install_header if h != hbp (instead of calling it a conditional
expression) and, then, calling setup_header if hhdr is non-NULL.

11 years agoAdd comment for _DYNAMIC[] compared to NULL in GC_FirstDLOpenedLinkMap
Ivan Maidanski [Wed, 17 Oct 2012 17:44:24 +0000 (21:44 +0400)]
Add comment for _DYNAMIC[] compared to NULL in GC_FirstDLOpenedLinkMap

* dyn_load.c (GC_FirstDLOpenedLinkMap): Add comment for
_DYNAMIC-is-NULL code branch; cast _DYNAMIC (array symbol) to ptr_t
in comparison to NULL (0).

11 years agoAdd comment about sigaction sa_restorer field
Ivan Maidanski [Wed, 17 Oct 2012 17:34:33 +0000 (21:34 +0400)]
Add comment about sigaction sa_restorer field

* os_dep.c (GC_find_limit_openbsd, GC_skip_hole_openbsd,
GC_set_and_save_fault_handler, GC_dirty_init): Add comment about
sigaction sa_restorer field initialization (some static code analysis
tools report about uninitialized field but according to Linux manual
it is obsolete and should not be used).
* pthread_stop_world.c (GC_stop_init): Likewise.

11 years agoFix sizeof in GC_push_thread_structures
Ivan Maidanski [Wed, 17 Oct 2012 17:21:11 +0000 (21:21 +0400)]
Fix sizeof in GC_push_thread_structures

* pthread_support.c (GC_push_thread_structures): Fix sizeof argument
(take size of GC_thread_key variable instead of its address) if
THREAD_LOCAL_ALLOC.
* win32_threads.c (GC_push_thread_structures): Likewise.

11 years agoFix GC_CreateThread and GC_beginthreadex definition for Cygwin
Ivan Maidanski [Tue, 9 Oct 2012 18:20:48 +0000 (22:20 +0400)]
Fix GC_CreateThread and GC_beginthreadex definition for Cygwin

* win32_threads.c (CreateThread, ExitThread, _beginthreadex,
_endthreadex): Undefine unconditionally (because the original function
might be used even for GC_PTHREADS targets).
* win32_threads.c (GC_beginthreadex, GC_endthreadex): Do not define
on Cygwin because the latter does not provide _beginthreadex and
_endthreadex.

11 years agoPort BDWGC to Android/x86
Ivan Maidanski [Sat, 29 Sep 2012 10:07:55 +0000 (14:07 +0400)]
Port BDWGC to Android/x86

* include/private/gc_priv.h (SETJMP, LONGJMP, JMP_BUF): Explicitly
define to setjmp/longjmp/jmp_buf (instead of
sigsetjmp/siglongjmp/sigjmp_buf), respectively, if GC_NO_SIGSETJMP.
* include/private/gcconfig.h (GC_NO_SIGSETJMP): New macro, define for
Android/x86.
* include/private/gcconfig.h (NO_GETCONTEXT): define for Android/x86
(since getcontext is missing in Android).

11 years agoMove 'include setjmp.h' from mach_dep.c to gc_priv.h
Ivan Maidanski [Sat, 29 Sep 2012 09:13:01 +0000 (13:13 +0400)]
Move 'include setjmp.h' from mach_dep.c to gc_priv.h

* include/private/gc_priv.h: Include setjmp.h unconditionally (since
SETJMP/LONGJMP is always defined).
* mach_dep.c: Remove redundant include setjmp.h.

11 years agoFix a typo in comment of GC_with_callee_saves_pushed
Ivan Maidanski [Sat, 29 Sep 2012 08:27:39 +0000 (12:27 +0400)]
Fix a typo in comment of GC_with_callee_saves_pushed

* mach_dep.c (GC_with_callee_saves_pushed): Fix a typo in comment.

11 years agoDo not define _setjmp/_longjmp macros in mach_dep.c (code refactoring)
Ivan Maidanski [Sat, 29 Sep 2012 08:23:40 +0000 (12:23 +0400)]
Do not define _setjmp/_longjmp macros in mach_dep.c (code refactoring)

* mach_dep.c (_setjmp, _longjmp): Remove unused macro definition (if
OS2, or CX_UX or __CC_ARM).
* mach_dep.c (GC_with_callee_saves_pushed): Use setjmp instead of
_setjmp also for OS2, CX_UX and __CC_ARM.

11 years agotests: Log error messages to stderr instead of stdout
Ivan Maidanski [Tue, 18 Sep 2012 11:47:36 +0000 (15:47 +0400)]
tests: Log error messages to stderr instead of stdout

* tests/initsecondarythread.c (main): Print error messages using
fprintf(stderr) instead of printf().
* tests/subthread_create.c (entry, main): Likewise.
* tests/thread_leak_test.c (main): Likewise.
* tests/trace_test.c (mktree): Likewise.
* tests/thread_leak_test.c (main): Call exit(2) if thread creation or
joining failed.

11 years agoUpdate ChangeLog file
Ivan Maidanski [Tue, 18 Sep 2012 10:32:40 +0000 (14:32 +0400)]
Update ChangeLog file

11 years agoEliminate 'unused value' compiler warning in GC_stop_world (Pthreads)
Ivan Maidanski [Wed, 12 Sep 2012 05:46:41 +0000 (09:46 +0400)]
Eliminate 'unused value' compiler warning in GC_stop_world (Pthreads)

* pthread_stop_world.c (GC_stop_world): Eliminate
"assigned value never used" compiler warning for "code" local variable
in conditional statement checking sem_wait result.

11 years agoFix null-pointer dereference in CORD_substr_closure
Ivan Maidanski [Tue, 11 Sep 2012 19:55:32 +0000 (23:55 +0400)]
Fix null-pointer dereference in CORD_substr_closure

* cord/cordbscs.c (CORD_substr_closure): Prevent SEGV if CORD_from_fn
returned NULL/CORD_EMPTY (in case "n" argument is zero).

11 years agoFix min_bytes_allocd comment
Ivan Maidanski [Tue, 11 Sep 2012 19:23:13 +0000 (23:23 +0400)]
Fix min_bytes_allocd comment

* alloc.c (min_bytes_allocd): Fix comment (replace "words" with
"bytes").

11 years agoRemove nested EXPECT in GC_core_finalized_malloc
Ivan Maidanski [Tue, 11 Sep 2012 19:13:06 +0000 (23:13 +0400)]
Remove nested EXPECT in GC_core_finalized_malloc

* fnlz_mlc.c (GC_core_finalized_malloc): Remove duplicate (nested)
EXPECT for SMALL_OBJ (since the latter already contains the former).

11 years agoEnable 'Force GC at every GC_malloc' debug-related functionality
Ivan Maidanski [Tue, 11 Sep 2012 19:03:55 +0000 (23:03 +0400)]
Enable 'Force GC at every GC_malloc' debug-related functionality

* doc/README.environment (GC_COLLECT_AT_MALLOC): Document.
* doc/README.macros (GC_COLLECT_AT_MALLOC): Likewise.
* fnlz_mlc.c (GC_core_finalized_malloc): Insert
GC_DBG_COLLECT_AT_MALLOC invocation (before LOCK).
* gcj_mlc.c (GC_core_gcj_malloc, GC_gcj_malloc_ignore_off_page):
Likewise.
* malloc.c (GC_generic_malloc, GC_malloc_atomic, GC_malloc,
GC_malloc_uncollectable): Likewise.
* mallocx.c (GC_generic_malloc_ignore_off_page,
GC_generic_malloc_many, GC_malloc_atomic_uncollectable): Likewise.
* typd_mlc.c (GC_malloc_explicitly_typed,
GC_malloc_explicitly_typed_ignore_off_page): Likewise.
* include/private/gc_priv.h (GC_COLLECT_AT_MALLOC): Recognize new
macro.
(GC_dbg_collect_at_malloc_min_lb): New global variable declaration
(only if GC_COLLECT_AT_MALLOC defined).
(GC_DBG_COLLECT_AT_MALLOC): Define new macro (invoking GC_gcollect).
* malloc.c (GC_dbg_collect_at_malloc_min_lb): New global variable
(only if GC_COLLECT_AT_MALLOC defined).
* misc.c (GC_init): Test "GC_COLLECT_AT_MALLOC" environment variable
and alter default GC_dbg_collect_at_malloc_min_lb value (only if
GC_COLLECT_AT_MALLOC macro defined).

11 years agoFix min_bytes_allocd preventing potential infinite loop in GC_allocobj
Ivan Maidanski [Tue, 11 Sep 2012 04:30:25 +0000 (08:30 +0400)]
Fix min_bytes_allocd preventing potential infinite loop in GC_allocobj

* alloc.c (min_bytes_allocd): Do not return zero in case of big
GC_free_space_divisor value (return 1 instead to prevent infinite loop
in GC_allocobj if GC_adj_bytes_allocd returns zero); update comment.

11 years agoUpdate information about GC_free_space_divisor in README
Ivan Maidanski [Tue, 11 Sep 2012 04:17:59 +0000 (08:17 +0400)]
Update information about GC_free_space_divisor in README

* README (GC_free_space_divisor): Update information.

11 years agoUpdate ChangeLog file
Ivan Maidanski [Sun, 9 Sep 2012 09:26:33 +0000 (13:26 +0400)]
Update ChangeLog file

11 years agoEliminate Clang warning for GC_pthread_exit attribute
Ivan Maidanski [Sun, 9 Sep 2012 08:57:38 +0000 (12:57 +0400)]
Eliminate Clang warning for GC_pthread_exit attribute

* include/gc_pthread_redirects.h (GC_PTHREAD_EXIT_DECLARED): Test and
define new macro (only if GC_PTHREAD_EXIT_ATTRIBUTE) to prevent Clang
warning "attribute declaration must precede definition" for
GC_pthread_exit when this header included from extra/gc.c tail.

11 years agoReplace var-args GC_noop with fixed-args one
Ivan Maidanski [Sun, 9 Sep 2012 07:15:48 +0000 (11:15 +0400)]
Replace var-args GC_noop with fixed-args one
(to suppress Clang warning that arguments were dropped)

* alloc.c (GC_stopped_mark, GC_try_to_collect_general): Use GC_noop6
instead of var-args GC_noop.
* include/private/gc_priv.h (GC_noop): Replace var-args (and
platform-specific) prototype with GC_noop6 one.
* mark.c (GC_noop): Replace with GC_noop6 (with all arguments
ignored); refine comment.

11 years agoRemove dummy GC_noop call from code visible to Lint tool only
Ivan Maidanski [Sun, 9 Sep 2012 06:42:48 +0000 (10:42 +0400)]
Remove dummy GC_noop call from code visible to Lint tool only
(Minor code refactoring.)

* misc.c (GC_init): Remove dummy GC_noop call from Lint-only code.
* tests/test.c (main): Likewise.

11 years agoUse GC_noop1 instead of GC_noop in GC_pause; remove duplicate GC_noop1
Ivan Maidanski [Sat, 8 Sep 2012 19:54:50 +0000 (23:54 +0400)]
Use GC_noop1 instead of GC_noop in GC_pause; remove duplicate GC_noop1
prototype (minor code refactoring)

* include/private/gc_locks.h (GC_noop1): Remove prototype (since
already declared in gc_priv.h).
* pthread_support.c (GC_pause): Replace varargs GC_noop invocation
(with a single argument) to GC_noop1.

11 years agoUpdate ChangeLog and AUTHORS files
Ivan Maidanski [Wed, 5 Sep 2012 22:16:24 +0000 (02:16 +0400)]
Update ChangeLog and AUTHORS files

11 years agoFix GC_get_stack_base assembly code (Cygwin/Clang)
Colin LeMahieu [Wed, 5 Sep 2012 22:02:16 +0000 (02:02 +0400)]
Fix GC_get_stack_base assembly code (Cygwin/Clang)

* os_dep.c (GC_get_stack_base): Use inline assembly statement instead
of variable assembly attribute (to workaround clang 3.1 linkage error
on Cygwin).

11 years agoUpdate ChangeLog file
Ivan Maidanski [Thu, 30 Aug 2012 04:54:09 +0000 (08:54 +0400)]
Update ChangeLog file

11 years agoEliminate 'missing exception specification' warning in gc_cpp.cc (Clang)
Ivan Maidanski [Thu, 30 Aug 2012 04:52:13 +0000 (08:52 +0400)]
Eliminate 'missing exception specification' warning in gc_cpp.cc (Clang)

* gc_cpp.cc (GC_NEW_DELETE_NEED_THROW): Define new macro (if not defined
yet) for GCC v4.2+ (or clang).
* gc_cpp.cc: Include new (for std::bad_alloc) if
GC_NEW_DELETE_NEED_THROW.
* gc_cpp.cc (GC_DECL_NEW_THROW, GC_DECL_DELETE_THROW): New macros
(used to eliminate compiler "missing exception specification" warning
for 'new' and 'delete' operators).
* gc_cpp.cc (new, delete, new[], delete[]): Use
GC_DECL_NEW/DELETE_THROW to define 'throw' clause properly.

11 years ago.gitignore: Remove old /include/private/config.h.in entry
Ivan Maidanski [Thu, 30 Aug 2012 04:47:42 +0000 (08:47 +0400)]
.gitignore: Remove old /include/private/config.h.in entry

11 years agoUpdate ChangeLog file
Ivan Maidanski [Thu, 30 Aug 2012 04:46:37 +0000 (08:46 +0400)]
Update ChangeLog file

11 years ago.gitignore: remove path prefix for config.h and stamp-h1
Ivan Maidanski [Thu, 30 Aug 2012 04:39:25 +0000 (08:39 +0400)]
.gitignore: remove path prefix for config.h and stamp-h1

* .gitignore: Add include/config.h.in (to ignore); remove path for
config.h and stamp-h1 (to ignore files both located in /include/private
(old behavior) and in /include folders).

11 years agoInclude "config.h" instead of "private/config.h" on HAVE_CONFIG_H
Ivan Maidanski [Thu, 30 Aug 2012 04:32:15 +0000 (08:32 +0400)]
Include "config.h" instead of "private/config.h" on HAVE_CONFIG_H
(Change the behavior of HAVE_CONFIG_H macro to the standard one
which assumes that no folder is specified in #include "config.h".)

* configure.ac (AM_CONFIG_HEADER): Replace include/private/config.h to
include/config.h.
* cord/cordbscs.c: Include "config.h" (instead of "private/config.h")
if HAVE_CONFIG_H defined.
* cord/cordprnt.c: Likewise.
* cord/cordxtra.c: Likewise.
* gc_cpp.cc: Likewise.
* include/private/gc_pmark.h: Likewise.
* include/private/gc_priv.h: Likewise.
* real_malloc.c: Likewise.
* tests/disclaim_test.c: Likewise.
* tests/initsecondarythread.c: Likewise.
* tests/subthread_create.c: Likewise.
* tests/test.c: Likewise.
* tests/test_cpp.cc: Likewise.
* tests/thread_leak_test.c: Likewise.
* tests/threadkey_test.c: Likewise.

11 years agoUpdate ChangeLog file
Ivan Maidanski [Mon, 27 Aug 2012 04:41:13 +0000 (08:41 +0400)]
Update ChangeLog file

11 years agoUpdate AUTHORS (add email)
Ivan Maidanski [Sun, 26 Aug 2012 19:03:50 +0000 (23:03 +0400)]
Update AUTHORS (add email)

11 years agoFix unportable '==' test operators in configure
Thomas Klausner [Sun, 26 Aug 2012 18:58:17 +0000 (22:58 +0400)]
Fix unportable '==' test operators in configure

* configure.ac: Replace all unportable '==' test operators with '='
ones.

11 years agoElaborate comment on dependencies in autogen.sh.
Petter Urkedal [Tue, 21 Aug 2012 21:08:08 +0000 (23:08 +0200)]
Elaborate comment on dependencies in autogen.sh.

11 years agoUpdate ChangeLog file
Ivan Maidanski [Tue, 21 Aug 2012 18:20:04 +0000 (22:20 +0400)]
Update ChangeLog file

11 years agoAdd note about 'pkg-config' solving problem with autoconf 2.68 or older
Ivan Maidanski [Tue, 21 Aug 2012 18:09:50 +0000 (22:09 +0400)]
Add note about 'pkg-config' solving problem with autoconf 2.68 or older
(Cygwin/MinGW, OS X)

* autogen.sh: Add comment about 'pkg-config'.
* TODO: Remove note about 'autoreconf' failure.

11 years agoUpdate ChangeLog file
Ivan Maidanski [Sun, 5 Aug 2012 09:53:43 +0000 (13:53 +0400)]
Update ChangeLog file

11 years agoFix GC_clear_stack_inner by using GC_approx_sp
Ivan Maidanski [Wed, 1 Aug 2012 22:02:08 +0000 (02:02 +0400)]
Fix GC_clear_stack_inner by using GC_approx_sp

* misc.c (GC_clear_stack_inner): Use GC_approx_sp() instead of
"dummy[0]" set to "&dummy" value (that worked as expected only for
STACK_GROWS_DOWN case).

11 years agoFix all address-of-dummy operations by using GC_approx_sp() instead
Ivan Maidanski [Wed, 1 Aug 2012 19:36:16 +0000 (23:36 +0400)]
Fix all address-of-dummy operations by using GC_approx_sp() instead
(previous commit 'd6acbda' has not solved this problem)

* alloc.c (min_bytes_allocd, GC_stopped_mark): Use GC_approx_sp()
instead of "&dummy"; remove 'dummy' local variable.
* dyn_load.c (GC_cond_add_roots): Likewise.
* misc.c (GC_init): Likewise.
* os_dep.c (GC_get_stack_base, GC_get_main_stack_base): Likewise.
* pthread_stop_world.c (GC_suspend_handler_inner,
nacl_pre_syscall_hook, __nacl_suspend_thread_if_needed): Likewise.
* pthread_support.c (GC_thr_init): Likewise.
* ptr_chck.c (GC_on_stack): Likewise.
* win32_threads.c (GC_push_stack_for): Likewise.
* misc.c (GC_clear_stack_inner): Store address of volatile 'dummy'
local array (i.e. 'sp' value) to its first element (and use it in the
comparison of addresses) to prevent any harmful optimizations as C
officially disallows comparisons of pointers to different objects
(e.g., some Mac OS X clang releases might turn a conditional
expression that uses 'dummy' address into a constant); update comment.
* misc.c (GC_call_with_stack_base): Use "&base" instead of "&dummy"
(it is safe to use address of base here); remove dummy variable.
* os_dep.c (currently_updating): Change type from "word" to "int*".
* os_dep.c (async_set_pht_entry_from_index): Remove volatile and casts
for 'update_dummy' local variable.
* tools/setjmp_t.c (main): Define volatile 'sp' local variable, store
its address to it and use it instead of "&dummy"; remove 'dummy' local
variable.

11 years agoFix GC_call_with_stack_base to prevent its tail-call optimization
Ivan Maidanski [Wed, 1 Aug 2012 19:12:22 +0000 (23:12 +0400)]
Fix GC_call_with_stack_base to prevent its tail-call optimization

* misc.c (GC_call_with_stack_base): Call GC_noop1 after fn()
invocation to prevent a tail-call optimization.