Ivan Maidanski [Fri, 24 Feb 2012 10:34:34 +0000 (14:34 +0400)]
Fix Cygwin support to handle fork() properly
* include/private/gcconfig.h (HANDLE_FORK): Define also for Cygwin
(but not for win32-pthreads and not if Win32 memory allocation used).
* win32_threads.c: Include unistd.h if HANDLE_FORK (for
pthread_atfork).
* win32_threads.c (GC_wait_for_gc_completion): Add wait_for_all
argument.
* win32_threads.c (GC_unregister_my_thread, GC_thread_exit_proc): Pass
FALSE ("wait_for_all" argument) to GC_wait_for_gc_completion.
* win32_threads.c (GC_remove_all_threads_but_me, GC_fork_prepare_proc,
GC_fork_parent_proc, GC_fork_child_proc): New functions (similar to
that in pthread_support.c) if HANDLE_FORK.
* win32_threads.c (GC_thr_init): Invoke pthread_atfork if HANDLE_FORK.
Ivan Maidanski [Fri, 24 Feb 2012 07:29:48 +0000 (11:29 +0400)]
Fix fork() handling for Darwin partially
(still not handled well for Darwin if GC incremental mode is on)
* os_dep.c (GC_dirty_init): Add FIXME regarding fork (Darwin).
* pthread_support.c (GC_remove_all_threads_but_me): Update mach_thread
for "me" (Darwin).
* pthread_support.c (GC_fork_prepare_proc): Output warning if
GC_dirty_maintained (if DARWIN and MPROTECT_VDB).
* pthread_support.c (GC_fork_prepare_proc, GC_fork_child_proc): Add
FIXME (for Darwin).
* tests/test.c (run_one_test): Do not test fork() for Darwin with
incremental mode on (if HANDLE_FORK); add FIXME.
Ivan Maidanski [Tue, 21 Feb 2012 17:12:47 +0000 (21:12 +0400)]
Fix Win32 GC_unregister_my_thread to ensure no ongoing incremental GC
* win32_threads.c (GC_wait_for_gc_completion): Add function (similar
implementation as in pthread_support.c).
* win32_threads.c (GC_unregister_my_thread, GC_thread_exit_proc):
Call GC_wait_for_gc_completion to prevent collecting from unregistered
thread; remove FIXME.
Andy Wingo [Mon, 20 Feb 2012 17:51:21 +0000 (21:51 +0400)]
Fix gcconfig to turn on POSIX fork() support by default
(define HANDLE_FORK on Unix platforms with pthreads)
* doc/README.macros (HANDLE_FORK): Replace with NO_HANDLE_FORK; update
the documentation.
* include/private/gcconfig.h (HANDLE_FORK): Explicitly define if
GC_PTHREADS unless already defined or NO_HANDLE_FORK is defined, or
unsupported on the target.
Ivan Maidanski [Thu, 16 Feb 2012 19:17:23 +0000 (23:17 +0400)]
Allow GC_exclude_static_roots() region start to be unaligned
(let the client not to care about the alignment of excluded memory area)
* include/gc.h (GC_exclude_static_roots): Update the comment.
* mark_rts.c (GC_exclude_static_roots): Allow the lower boundary to be
unaligned as well; reverse boundary rounding direction (since the
boundaries specify exclusion region); update the comment.
Ivan Maidanski [Thu, 16 Feb 2012 18:47:28 +0000 (22:47 +0400)]
Fix GC_push_all/selected boundaries check
* mark.c (GC_push_all, GC_push_selected): Properly check for empty
region after boundaries alignment (for the case when boundaries
unaligned and the region is short than one word); simplify the checked
condition.
Ivan Maidanski [Thu, 16 Feb 2012 18:05:31 +0000 (22:05 +0400)]
Fix GC_finalizer_nested size to workaround alignment problem in Watcom
* finalize.c (GC_finalizer_nested): Change type from char to int to
force GC symbols proper alignment for some compilers (e.g., Watcom);
add comment.
* finalize.c (GC_check_finalizer_nested): Cast GC_finalizer_nested
properly (since it holds an unsigned char value).
* os_dep.c (GC_get_maps): Remove static "init_buf" variable (of char
size) and initialize "maps_buf" to NULL since it is allocated anyway
(since maps_size is non-zero).
* os_dep.c (GC_register_data_segments): Remove static "dummy" variable
(of char size) and use GC_pages_executable instead.
Ivan Maidanski [Thu, 16 Feb 2012 17:28:07 +0000 (21:28 +0400)]
Add assertion ensuring proper alignment of 'pushed' GC symbols
* finalize.c (GC_push_finalizer_structures): Assert word alignment of
dl_head, fo_head, GC_finalize_now.
* pthread_support.c (GC_thr_init): Assert word alignment of GC_threads
(passed to GC_push_all).
* win32_threads.c (GC_thr_init): Likewise.
* thread_local_alloc.c (GC_init_thread_local): Assert word alignment
of GC_thread_key.
* typd_mlc.c (GC_add_ext_descriptor): Assert word alignment of
GC_ext_descriptors.
Ivan Maidanski [Tue, 14 Feb 2012 04:41:56 +0000 (08:41 +0400)]
Remove unsupported MMAP_STACKS (specific to Solaris threads)
* doc/README.macros (MMAP_STACKS): Remove.
* dyn_load.c (GC_register_dynamic_libraries): Remove check of
MMAP_STACKS since GC_is_thread_stack is missing since removal of
Solaris threads support (IRIX5).
Ivan Maidanski [Tue, 14 Feb 2012 04:37:02 +0000 (08:37 +0400)]
Improve GC_allochblk algorithm of block splitting when unmapping enabled
(allow splitting up to limit based on per-list free space amount but
skipping unmapped blocks)
* allchblk.c (GC_allochblk_nth): Change type of "may_split" argument
from GC_bool to int (to hold 3rd value).
* allchblk.c (AVOID_SPLIT_REMAPPED): New macro (used as a value for
"may_split").
* allchblk.c (GC_allochblk): Add "may_split" local variable (set to
TRUE by default and passed to GC_allochblk_nth); do not zero
split_limit in case of USE_MUNMAP (and remove FIXME); set may_split to
AVOID_SPLIT_REMAPPED in case of USE_MUNMAP and split_limit is
a non-zero value computed by GC_enough_large_bytes_left.
* allchblk.c (GC_allochblk_nth): Update usage comment; if may_split is
AVOID_SPLIT_REMAPPED and hhdr is unmapped then continue search instead
of remapping memory and splitting the block.
Ivan Maidanski [Mon, 13 Feb 2012 04:09:52 +0000 (08:09 +0400)]
Do not avoid splitting if nothing currently unmapped (USE_MUNMAP)
* allchblk.c (GC_free_bytes, GC_enough_large_bytes_left,
GC_compute_large_free_bytes): Define even for USE_MUNMAP case.
* allchblk.c (INCR_FREE_BYTES, FREE_ASSERT): Always define as
non-empty.
* allchblk.c (GC_compute_large_free_bytes, GC_print_hblkfreelist,
GC_remove_from_fl): Remove check of USE_MUNMAP (same implementation as
if without memory unmapping).
* allchblk.c (GC_compute_large_free_bytes): Remove FIXME.
* allchblk.c (GC_allochblk): Do not avoid splitting if
GC_unmapped_bytes is zero (meaning nothing unmapped); add FIXME to
relax the condition.
Ivan Maidanski [Sun, 12 Feb 2012 09:20:00 +0000 (13:20 +0400)]
Minor code refactoring of GC_freehblk (change type of local variable)
* allchblk.c (GC_freehblk): Change type of "size" local variable from
singed_word to word; cast "hbp" to ptr_t instead of word (for getting
"next" address).
Ivan Maidanski [Thu, 9 Feb 2012 15:56:48 +0000 (19:56 +0400)]
Allow to get memory via Win32 VirtualAlloc (USE_WINALLOC) on Cygwin
* README.macros (USE_WINALLOC): Document.
* include/private/gcconfig.h (USE_WINALLOC): Add comment.
* include/private/gcconfig.h (USE_MMAP): Explicitly undefine if
USE_WINALLOC.
* os_dep.c (GC_wince_get_mem): Move definition up to simplify ifdef.
* os_dep.c (GC_win32_get_mem): Test USE_WINALLOC instead of CYGWIN32;
test GLOBAL_ALLOC_TEST value only if MSWIN32.
Ivan Maidanski [Thu, 9 Feb 2012 15:15:52 +0000 (19:15 +0400)]
Code refactoring (test single macro instead of MSWIN32/MSWINCE pair)
* alloc.c (GC_stopped_mark): Test USE_WINALLOC macro instead of
MSWIN32 and MSWINCE.
* include/private/gc_priv.h (GC_add_current_malloc_heap): Likewise.
* os_dep.c (MMAP_SUPPORTED, SBRK_ARG_T, GC_mem_top_down, GC_unmap,
GC_remap, GC_unmap_gap, PROTECT, UNPROTECT): Likewise.
* include/private/gcconfig.h (USE_WINALLOC): New macro (defined if
MSWIN32 or MSWINCE).
* os_dep.c (GC_sysinfo): Define just before GC_setpagesize.
* os_dep.c (GC_malloc_heap_list, GC_is_malloc_heap_base,
GC_get_allocation_base, GC_add_current_malloc_heap, GC_is_heap_base):
Test USE_WINALLOC macro instead of CYGWIN32.
* os_dep.c (USE_GLOBAL_ALLOC): Define macro even if CYGWIN32 (to
remove redundant macro test).
* os_dep.c (GC_mem_top_down): Remove STATIC (as used for debugging);
define as macro in case of 0 value.
Ivan Maidanski [Tue, 7 Feb 2012 05:12:47 +0000 (09:12 +0400)]
Code refactoring of GC_remap
* os_dep.c (GC_remap): Move start_addr testing out of ifdef block;
move "result" local variable to the block where used; swap NaCl and
non-NaCl code blocks.
Ivan Maidanski [Mon, 6 Feb 2012 15:49:06 +0000 (19:49 +0400)]
Allow to exclude finalization support by GC_NO_FINALIZATION macro
* doc/README.macros (GC_NO_FINALIZATION): Document.
* alloc.c (GC_finish_collection): Do not call GC_finalize and
GC_print_finalization_stats if GC_NO_FINALIZATION.
* dbg_mlc.c (closure, GC_make_closure, GC_debug_invoke_finalizer,
OFN_UNSET, store_old, GC_debug_register_finalizer,
GC_debug_register_finalizer_no_order,
GC_debug_register_finalizer_unreachable,
GC_debug_register_finalizer_ignore_self): Do not define if
GC_NO_FINALIZATION.
* finalize.c: Skip all definitions if GC_NO_FINALIZATION.
* finalize.c (GC_call_with_alloc_lock): Move to misc.c.
* include/private/gc_priv.h (GC_INVOKE_FINALIZERS): Define to empty
if GC_NO_FINALIZATION.
* include/private/gc_priv.h (GC_notify_or_invoke_finalizers,
GC_push_finalizer_structures, GC_finalize,
GC_print_finalization_stats): Do not declare if GC_NO_FINALIZATION.
* mark_rts.c (GC_push_gc_structures): Do not call
GC_push_finalizer_structures if GC_NO_FINALIZATION.
* misc.c (GC_call_with_alloc_lock): Move from "finalize" module.
* tests/test.c (mktree): Do not declare "my_index" and "new_link"
local variables, do not update live_indicators_count, do not call
GC_REGISTER_FINALIZER, GC_GENERAL_REGISTER_DISAPPEARING_LINK,
GC_move_disappearing_link, GC_unregister_disappearing_link if
GC_NO_FINALIZATION.
* tests/test.c (check_heap_stats): Do not declare "still_live",
"late_finalize_count" local variables and do not check finalization
for failures if GC_NO_FINALIZATION.
Ivan Maidanski [Fri, 3 Feb 2012 18:11:28 +0000 (22:11 +0400)]
Move finalize.c global variables outside to alloc.c and misc.c
(to minimize number of linked global symbols of 'finalize' module in
case finalization not unused)
* alloc.c (GC_fo_entries): Move global variable definition from
finalize.c.
* finalize.c (GC_fo_entries): Likewise.
* finalize.c (GC_finalize_on_demand, GC_java_finalization,
GC_finalizer_notifier): Move global variable definition to misc.c.
* misc.c (GC_finalize_on_demand, GC_java_finalization,
GC_finalizer_notifier): Likewise.
Ivan Maidanski [Fri, 3 Feb 2012 16:13:11 +0000 (20:13 +0400)]
Implement GC_get_stack_base for Darwin if threads support is off
* os_dep.c (GC_get_stack_base): Define separately for NEED_FIND_LIMIT
case; tag the argument with "unused" attribute for the case when
GC_UNIMPLEMENTED is returned; add implementation (as the last
alternative) based on GC_get_main_stack_base (e.g., for Darwin)
for the single-threaded case unless GC_stack_base has more that
one field (IA-64).
Ivan Maidanski [Fri, 3 Feb 2012 15:34:47 +0000 (19:34 +0400)]
Prevent compiler warnings in GC_FindTopOfStack and GC_ports (Darwin)
* darwin_stop_world.c (GC_FindTopOfStack): Initialize "frame" local
variable from "stack_start" unless done via PPC lwz/ld instruction (to
prevent "uninitialized variable use" compiler warning;
add assertion for "stack_start" value; add 'U' suffix to int constant
to prevent comparison of signed and unsigned value.
* os_dep.c (GC_ports): Explicitly initialize "reply" field to zero if
THREADS (to suppress compiler warning on Darwin).
Ivan Maidanski [Wed, 1 Feb 2012 16:49:25 +0000 (20:49 +0400)]
gctest: Avoid use of deprecated GC_dont_gc and GC_stackbottom
* tests/test.c (GC_amiga_gctest_malloc_explicitly_typed,
GC_amiga_gctest_calloc_explicitly_typed): Do not unnecessarily check
GC_dont_gc value.
* tests/test.c (check_heap_stats): Get stack base via
GC_get_stack_base() (report error if failed) instead of accessing
GC_stackbottom.
Ivan Maidanski [Tue, 31 Jan 2012 16:10:14 +0000 (20:10 +0400)]
Add assertions to check GC_large_free_bytes and GC_root_size values by
GC_finish_collection even if GC_dump_regularly is off
* allchblk.c (GC_compute_large_free_bytes): New inner function
(defined only if GC_ASSERTIONS or not NO_DEBUGGING).
* mark_rts.c (GC_compute_root_size): Likewise.
* allchblk.c (GC_print_hblkfreelist): Call GC_compute_large_free_bytes
instead of computing large_free_bytes itself (only if not USE_MUNMAP
for now); remove "sz" local variable.
* allchblk.c (GC_print_hblkfreelist): Refine logged messages (for
total value).
* mark_rts.c (GC_print_static_roots): Likewise.
* include/private/gc_priv.h (GC_dump_regularly, COND_DUMP): Move
definition down below GC_ASSERT one.
* include/private/gc_priv.h (GC_compute_large_free_bytes,
GC_compute_root_size): New function declaration (only if
GC_ASSERTIONS).
* include/private/gc_priv.h (COND_DUMP_CHECKS): New macro (invoke
GC_ASSERT for GC_large_free_bytes and GC_root_size).
* include/private/gc_priv.h (COND_DUMP): Invoke COND_DUMP_CHECKS
unless GC_dump_regularly.
* mark_rts.c (GC_print_static_roots): Call GC_compute_root_size
instead of computing root size itself; rename "total" local variable
to "size".
Ivan Maidanski [Tue, 31 Jan 2012 04:22:16 +0000 (08:22 +0400)]
Adjust GC_requested_heapsize on GC_init if GC_INITIAL_HEAP_SIZE given
* misc.c (GC_init): Adjust GC_requested_heapsize if GC_expand_hp_inner
(called with the value passed by "GC_INITIAL_HEAP_SIZE" environment
variable) succeeded.
Ivan Maidanski [Tue, 31 Jan 2012 04:01:06 +0000 (08:01 +0400)]
Make logged info of GC_stopped_mark and GC_print_heap_sects more compact
* alloc.c (GC_stopped_mark, GC_print_heap_sects): Make output of
GC_log_printf (printing amount of reclaimed memory and total heap
size) more compact (to fit into 80-characters line for reasonable
values).
Ivan Maidanski [Mon, 30 Jan 2012 19:11:16 +0000 (23:11 +0400)]
Open log file in APPEND mode (Win32) if file name given via
environment variable (to match behavior in Unix/Cygwin)
* misc.c (GC_CreateLogFile): Declare "appendToFile" local variable;
open log file either in CREATE_ALWAYS mode (and move file pointer to
log end) if the log file name is specified via environment variable.
Ivan Maidanski [Mon, 30 Jan 2012 18:20:04 +0000 (22:20 +0400)]
Code refactoring of GC_CreateLogFile (Win32)
* misc.c (GC_LOG_STD_NAME): New macro.
* misc.c (GC_init, GC_CreateLogFile): Use GC_LOG_STD_NAME instead
of "gc.log".
* misc.c (GC_CreateLogFile): Rename "logPath" local variable to
"pathBuf".
* misc.c (GC_CreateLogFile): Declare/use "hFile" and "logPath" local
variables.
Ivan Maidanski [Mon, 30 Jan 2012 12:42:29 +0000 (16:42 +0400)]
Code refactoring of GC_get_nprocs (define for every supported target
and simplify GC_thr_init)
* pthread_support.c (GC_get_nprocs): Define for all targets (either as
macro as inline function); group all implementations together.
* pthread_support.c (get_ncpu): Rename to GC_get_nprocs.
* pthread_support.c (GC_thr_init): Call GC_get_nprocs() for all
targets.
* pthread_support.c (GC_get_nprocs): Remove debug logging (of CPUs
number).
* pthread_support.c (GC_thr_init): Log number of CPUs (if
GC_print_stats) even in case PARALLEL_MARK is disabled.
Ivan Maidanski [Sun, 29 Jan 2012 18:52:30 +0000 (22:52 +0400)]
Use union of AO_t and word for mse_descr to avoid type casting
(which breaks 'strict-aliasing' compiler optimization)
* include/private/gc_pmark.h (GC_ms_entry): Change type of mse_descr
from word to word_ptr_ao_u.
* include/private/gc_pmark.h (GC_mark_stack_top): Add FIXME.
* include/private/gc_pmark.h (OR_WORD_EXIT_IF_SET): Add 'volatile'
keyword to type cast for AO_or argument.
* include/private/gc_priv.h (counter_t): Add 'volatile' in case of
defining as AO_t (replace typedef with a macro).
* include/private/gc_priv.h (word_ptr_ao_u): New union type.
* include/private/gc_pmark.h (PUSH_OBJ): Add ".w" suffix to mse_descr.
* mark.c (GC_mark_from, GC_steal_mark_stack, GC_push_all): Likewise.
* mark.c (GC_steal_mark_stack): Use "ao" element of union to load and
clear mse_descr atomically; remove pointer type casts.
Ivan Maidanski [Sun, 29 Jan 2012 16:17:31 +0000 (20:17 +0400)]
Code refactoring of Darwin GC_dyld_image_add/remove (make read-only
array 'const' and remove trailing NULL)
* dyn_load.c (GC_dyld_add_sect_fmts): Add 'const' keyword to global
array definition; remove trailing NULL.
* dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove): Test array
index boundary instead of testing for trailing NULL.
Ivan Maidanski [Sun, 29 Jan 2012 16:07:31 +0000 (20:07 +0400)]
Use union of AO_t and 'tse' data pointer in specific.c to avoid type
casting (breaking strict-aliasing rules)
* include/private/specific.h (ptse_ao_u): New union type.
* include/private/specific.h (thread_specific_data): Change type of
"hash" field from "tse" pointer to ptse_ao_u.
* specific.c (invalid_tse): Put to 'const' data section.
* specific.c (GC_key_create_inner, GC_setspecific, GC_remove_specific,
GC_slow_getspecific, GC_check_tsd_marks): Use "p" element of union to
access "tse" pointer of hash table.
* specific.c (GC_setspecific): Use "ao" element of union to store
"hash" table entry atomically; remove type cast.
Ivan Maidanski [Sun, 29 Jan 2012 15:15:46 +0000 (19:15 +0400)]
Remove part of DllMain-specific code which is always disabled (Win32)
* win32_threads.c (first_thread, GC_push_thread_structures): Refine
the comment.
* win32_threads.c (GC_delete_gc_thread, GC_push_thread_structures):
Remove pthread-specific code from the code specific to DllMain-based
thread registration (since GC_PTHREADS cannot be defined if
GC_NO_THREADS_DISCOVERY is undefined).
* win32_threads.c (GC_DllMain): Reformat the code.
Ivan Maidanski [Sun, 29 Jan 2012 14:03:27 +0000 (18:03 +0400)]
Add missing 'volatile' for AO_t variable definitions
(to minimize number of casts breaking strict-aliasing rules)
* mallocx.c (GC_bytes_allocd_tmp): Change type from signed_word to
AO_t.
* mallocx.c (GC_generic_malloc_many): Use AO_load to get
GC_bytes_allocd_tmp value; remove type cast for GC_bytes_allocd_tmp
passed to AO_fetch_and_add.
* pthread_support.c (GC_spin_count, GC_block_count,
GC_unlocked_count): Add "volatile" for AO_t global variable (defined
only if LOCK_STATS).
* win32_threads.c (GC_attached_thread, GC_block_count,
GC_unlocked_count): Likewise.
* win32_threads.c (GC_Thread_Rep): Add "volatile" for "in_use" AO_t
field.
* win32_threads.c (GC_started_thread_while_stopped): Remove "result"
local variable; use AO_compare_and_swap_release (if available) instead
of AO_nop_full/load/store for GC_attached_thread.
* win32_threads.c (GC_stop_world): Clear GC_attached_thread using
AO_store.
Ivan Maidanski [Sat, 28 Jan 2012 17:39:28 +0000 (21:39 +0400)]
gctest: Output marker threads count at end
* tests/test.c (run_one_test): Adjust printf format specifier.
* tests/test.c (main): Move printf for completed collections number
to check_heap_stats().
* tests/test.c (check_heap_stats): Print number of marker threads.
Ivan Maidanski [Sat, 28 Jan 2012 15:28:13 +0000 (19:28 +0400)]
Make GC_parallel a synonym to GC_markers_m1
* include/gc.h (GC_parallel, GC_enable_incremental): Update comment.
* include/private/gc_priv.h (GC_markers_m1): Define as a synonym
(macro) to GC_parallel instead of declaring a global variable (only
if PARALLEL_MARKER); update the comment.
* mark.c (GC_markers_m1): Remove global variable.
* pthread_support.c (start_mark_threads): Remove unnecessary
GC_parallel zeroing (after setting GC_markers_m1 to 0).
* win32_threads.c (start_mark_threads): Likewise.
* pthread_support.c (GC_fork_child_proc, GC_thr_init): Remove
unnecessary GC_markers_m1 zeroing (after setting GC_parallel to FALSE).
* win32_threads.c (GC_thr_init): Likewise.
* pthread_support.c (GC_thr_init): Set GC_parallel to FALSE instead of
zeroing GC_markers_m1; remove GC_parallel assignment to TRUE (since
GC_markers_m1 is set to non-zero value); add the comment.
* pthread_support.c (GC_thr_init): Set GC_parallel to FALSE instead of
zeroing GC_markers_m1; add the comment.
* pthread_support.c (GC_thr_init): Remove GC_parallel assignment to
TRUE (since GC_markers_m1 is set to non-zero value).
* win32_threads.c (GC_thr_init): Likewise.
Ivan Maidanski [Fri, 27 Jan 2012 05:46:55 +0000 (09:46 +0400)]
Code refactoring of GC_finish_collection (eliminate code duplication
via COMMA_IF_USE_MUNMAP new macro)
* alloc.c (IF_USE_MUNMAP, COMMA_IF_USE_MUNMAP): New macro (defined
conditionally based on USE_MUNMAP).
* alloc.c (GC_finish_collection): Eliminate code duplication via
[COMMA_]IF_USE_MUNMAP macro.
* alloc.c (GC_try_to_collect_general): Use IF_USE_MUNMAP instead of
ifdef USE_MUNMAP.
Ivan Maidanski [Fri, 27 Jan 2012 05:40:15 +0000 (09:40 +0400)]
Fix GC_init_linux_data_start to set GC_data_start to valid address
even if GC_no_dls
(fix commit db0da19)
* os_dep.c (GC_init_linux_data_start): Test GC_no_dls only to avoid
GC_find_limit call; initialize GC_data_start to DATAEND in case of
GC_no_dls to make data root empty (to prevent incorrect argument
passed to GC_add_roots_inner call in GC_register_data_segments).
* os_dep.c (GC_register_data_segments): Do not invoke
GC_add_roots_inner if upper bound (obtained from sbrk) is not upper
than DATASTART (e.g., if the latter is set to DATAEND on GC_no_dls).
Ivan Maidanski [Thu, 26 Jan 2012 16:36:57 +0000 (20:36 +0400)]
Fix static data roots registration on Android (if GC is shared
library) by defining GC_INIT_CONF_ROOTS
* include/gc.h (GC_INIT_CONF_ROOTS): Define to register static data
root in range from "__data_start" to "_end" on Android (unless
explicitly prohibited by client via GC_NOT_DLL macro) since the client
data root is not registered automatically if GC is build as a shared
library.
* tests/test.c (GC_COND_INIT): Invoke GC_INIT also on Android.
Ivan Maidanski [Thu, 26 Jan 2012 05:16:10 +0000 (09:16 +0400)]
Fix gcconfig.h to define USE_GET_STACKBASE_FOR_MAIN for Android
(causing pthread_attr_getstack to be used to get main stack base
even in single-threaded mode instead of GC_linux_main_stack_base)
* include/private/gcconfig.h (USE_GET_STACKBASE_FOR_MAIN): Define if
PLATFORM_ANDROID.
Ivan Maidanski [Thu, 26 Jan 2012 05:13:48 +0000 (09:13 +0400)]
Add debug logging on data roots addition or removal (enabled by
DEBUG_ADD_DEL_ROOTS new macro)
* mark_rts.c (GC_add_roots_inner): Debug logging at adding new entry
to GC_static_roots (only if DEBUG_ADD_DEL_ROOTS).
* mark_rts.c (GC_clear_roots, GC_remove_root_at_pos): Add debug
logging (only if DEBUG_ADD_DEL_ROOTS).
Petter Urkedal [Wed, 25 Jan 2012 19:30:02 +0000 (03:30 +0800)]
Remove closure data from GC_register_disclaim_proc.
* include/gc_disclaim.h, fnlz_mlc.c (GC_disclaim_proc, GC_register_disclaim_proc):
Remove CD from typedef and function.
* reclaim.c (GC_reclaim_uninit, GC_reclaim_block): Adjust calls.
* include/private/gc_priv.h, misc.c: Remove CD from object kind struct and
initializers.
Ivan Maidanski [Wed, 25 Jan 2012 15:12:36 +0000 (19:12 +0400)]
Move GC_register_disclaim_proc to fnlz_mlc
* misc.c (GC_register_disclaim_proc): Move definition to fnlz_mlc.c
(to minimize linked code size in case "disclaim" finalization is
unused).
* misc.c: Do not include gc_disclaim.h.
* fnlz_mlc.c (GC_register_disclaim_proc): Add GC_ASSERT for kind
passed by the client.
Ivan Maidanski [Tue, 24 Jan 2012 15:31:53 +0000 (19:31 +0400)]
Workaround some Linux/arm kernels bug to get correct GC_nprocs value
* pthread_support.c (STAT_READ, STAT_BUF_SIZE): Move the definition
out of PLATFORM_ANDROID condition.
* pthread_support.c (GC_get_nprocs_present): New static function
obtaining number of avalable CPUs from
"/sys/devices/system/cpu/present" (only Linux/arm excluding NaCl).
* pthread_support.c (GC_thr_init): Invoke GC_get_nprocs_present
(unless set from the environment variable) to workaround a bug in
some Linux/arm kernels (including Android).
Ivan Maidanski [Tue, 24 Jan 2012 04:39:47 +0000 (08:39 +0400)]
Fix GC_get_nprocs (Linux) returned variable type
* pthread_support.c (GC_get_nprocs): Change "result" local variable
type to int from word (to match returned value type); remove redundant
cast; initialize "result" variable just before its use.
Ivan Maidanski [Tue, 24 Jan 2012 04:22:01 +0000 (08:22 +0400)]
Recognize GC_LOG_TO_FILE_ALWAYS macro to log to 'gc.log' by default
* misc.c (GC_init): If "GC_LOG_FILE" environment variable is unset and
GC_LOG_TO_FILE_ALWAYS macro defined then open "gc.log" file for GC
logging (only Unix and Cygwin).
Ivan Maidanski [Mon, 23 Jan 2012 18:23:39 +0000 (22:23 +0400)]
Prevent 'unused var' warnings and adjust ABORT message in GC_DllMain
* win32_threads.c (GC_DllMain): Do not declare "sb" and "sb_result"
local variables if unused.
* win32_threads (GC_DllMain): Remove redundant test for
THREAD_LOCAL_ALLOC (since it is always off if GC_NO_THREADS_DISCOVERY);
adjust ABORT message (for DLL_PROCESS_ATTACH case if PARALLEL_MARK).