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).
Patrick C. Beard [Mon, 23 Jan 2012 17:21:48 +0000 (21:21 +0400)]
Integrate ancient 'pcbeard' GC port for MacOS 9 Classic
* include/private/gc_priv.h (bcopy, bzero, BCOPY_EXISTS): Add
definition for ancient MacOS/ppc.
* mach_dep.c (PushMacRegisters): Add implementation for MacOS/ppc.
* mach_dep.c (GC_push_regs): Fix to work on MacOS/ppc.
Ivan Maidanski [Mon, 23 Jan 2012 16:08:30 +0000 (20:08 +0400)]
Split GC_abort with GC_on_abort and abort() invoked from ABORT
(to let ABORT inherit 'noreturn' attribute of abort)
* misc.c (GC_abort): Replace with GC_on_abort (return from GC_on_abort
instead of abort); update the comment.
* include/private/gc_priv.h (GC_abort): Likewise.
* include/private/gc_priv.h (GC_on_abort): Define as empty macro in
case of SMALL_CONFIG.
* include/private/gc_priv.h (ABORT): Always call GC_on_abort (unless
PCR) and abort (or _exit, or ExitProcess or DebugBreak, depending on
the target).
Ivan Maidanski [Mon, 23 Jan 2012 04:17:19 +0000 (08:17 +0400)]
Replace ABORTs followed by statement with ABORT_RET having dummy
condition (to suppress 'statement unreachable' compiler warnings
caused by abort tagged as 'no-return')
* dbg_mlc.c (GC_debug_realloc): Replace ABORT() with ABORT_RET().
* gcj_mlc.c (mark_stack_limit): Likewise.
* os_dep.c (catch_exception_raise_state,
catch_exception_raise_state_identity): Likewise.
* typd_mlc.c (GC_descr_obj_size, GC_push_complex_descriptor): Likewise.
* include/private/gc_priv.h (ABORT_RET): New macro.
* mark.c (GC_mark_from): Put ABORT_RET instead of "cannot happen"
comment.
Ivan Maidanski [Mon, 23 Jan 2012 04:03:10 +0000 (08:03 +0400)]
Turn some unreachable return statements into reachable (to suppress
compiler warning)
* dbg_mlc.c (GC_generate_random_heap_address): Change function
algorithm structure to have reachable return statement at function end.
* mark.c (GC_mark_some): Likewise.
* os_dep.c (GC_mprotect_thread): Place a dummy return statement (which
uses function "arg"); remove unreachable return statement.
* win32_threads.c (GC_DllMain): Place GC_ASSERT before
GC_get_stack_base.
Paolo Molaro [Wed, 16 Feb 2005 21:23:39 +0000 (21:23 +0000)]
alloc: tune the code to collect instead of expanding the heap if
there are many finalizers and we reclaimed some memory from cleaning
the finalization queue (should fix Mono bugs #71001 and #70701).
(Apply commit a43aba7 from 'mono_libgc' branch)
* alloc.c (last_fo_entries, last_bytes_finalized): New static
variable.
* alloc.c (GC_collect_or_expand): Test GC_fo_entries delta (in case
of non-zero GC_bytes_finalized value) in the condition of toggling
garabage collection; update last_fo_entries and last_bytes_finalized
values.
* include/private/gc_priv.h (GC_fo_entries): Declare global variable
(for use in GC_collect_or_expand).
Ivan Maidanski [Wed, 18 Jan 2012 04:51:16 +0000 (08:51 +0400)]
Fix GC_finalized_malloc for out-of-memory case (and for missing
'const' qualifier)
* fnlz_mlc.c (GC_finalized_disclaim): Add 'const' qualifier for "fc"
pointer.
* fnlz_mlc.c (GC_core_finalized_malloc, GC_finalized_malloc): Cast
"op" to 'const' pointer on "fclos" storing.
* fnlz_mlc.c (GC_finalized_malloc): Use GC_get_oom_fn() instead of
locked read of GC_oom_fn.
* fnlz_mlc.c (GC_core_finalized_malloc): Test GC_generic_malloc result
for NULL (return NULL in this case).
* fnlz_mlc.c (GC_core_finalized_malloc): Add assertion on GC_size
returned value (at least just to outline that it might be bigger than
"lb" value).
Ivan Maidanski [Wed, 18 Jan 2012 04:44:11 +0000 (08:44 +0400)]
Improve disclaim_bench and disclaim_test
* tests/disclaim_bench.c: Do not include assert.h.
* tests/disclaim_test.c: Likewise.
* tests/disclaim_bench.c (my_assert): New macro.
* tests/disclaim_test.c: Likewise.
* tests/disclaim_bench.c (testobj_finalize, testobj_new): Replace
assert with my_assert.
* tests/disclaim_test.c (misc_sizes_dct, test_misc_sizes, pair_dct,
pair_new, pair_check_rec): Likewise.
* tests/disclaim_test.c (misc_sizes_dct): Test "cd" value (at least to
prevent "unused argument" compiler warning).
* tests/disclaim_test.c (test_misc_sizes): Use ANSI C style of
function declaration.
* tests/disclaim_bench.c (fclos): Add 'const' qualifier (since
GC_finalized_malloc now accepts const pointer).
* tests/disclaim_test.c (test_misc_sizes, pair_new): Likewise.
* tests/disclaim_test.c (test_misc_sizes, pair_new): Test
GC_finalized_malloc result for NULL.
Petter Urkedal [Mon, 16 Jan 2012 20:51:35 +0000 (04:51 +0800)]
Move finalizer closure to the end of objects.
* fnlz_mlc.c: Move finalizer closure for finalized object kinds to the end
of objects. This way, we don't require all interior pointers, and GC_base
returns the expected address.
* tests/disclaim_test.c: Improve test coverage.
Ivan Maidanski [Tue, 17 Jan 2012 04:19:04 +0000 (08:19 +0400)]
Fix cordtest temporary file names for Win32
* cord/tests/cordtest.c (FNAME1, FNAME2): Do not specify folder
(platform-dependent) for temporary file; use same short file name
(DOS-compatible) for all targets.
Ivan Maidanski [Mon, 16 Jan 2012 04:55:33 +0000 (08:55 +0400)]
Remove dependency on cord in gc_config_macros.h (libcord visibility fix)
* include/cord.h: Do not include gc_config_macros.h.
* include/cord.h (CORD_API): Define similar to GC_API definition in
gc_config_macros.h.
* include/gc_config_macros.h: Revert changes done in
"libcord visibility fix" (do not test CORD_H, do not define
GC_API_EXPORT and GC_API_IMPORT).
Ivan Maidanski [Mon, 16 Jan 2012 04:42:33 +0000 (08:42 +0400)]
Minor adjustment of libcord visibility fix
* cord/cord.am (libcord_la_CPPFLAGS): Do not define CORD_BUILD and
GC_DLL here (same approach as for GC_BUILD).
* cord/cordbscs.c: Include config.h if HAVE_CONFIG_H (for GC_DLL) and
define CORD_BUILD (before including cord.h).
* cord/cordprnt.c: Likewise.
* cord/cordxtra.c: Likewise.
Petter Urkedal [Sat, 14 Jan 2012 10:11:12 +0000 (11:11 +0100)]
Fix visibility of symbols in libcord.
* include/gc_config_macros.h: Make the export specifications usable also to
the cord library.
* include/cord.h, include/private/cord_pos.h: Define CORD_API and annotate
the public API.
Petter Urkedal [Sun, 8 Jan 2012 09:30:42 +0000 (17:30 +0800)]
Export mark-bit manipulation functions.
* include/private/gc_priv.h, include/gc_mark.h: Move GC_is_marked,
GC_clear_mark_bit and GC_set_mark_bit to a public header and adjust
prototypes and comment.
* mark.c: Adjust prototypes accordingly.
Ivan Maidanski [Fri, 13 Jan 2012 15:53:47 +0000 (19:53 +0400)]
Fix extra/gc.c to enable GC source inclusion from multi-threaded app
* extra/gc.c: Include gc_pthread_redirects.h (unless
GC_NO_THREAD_REDIRECTS) to restore thread calls macro-based
redirection after the corresponding undef's in pthread_support.c.
* win32_threads.c: Restore thread calls macro-based redirection
(unless GC_NO_THREAD_REDIRECTS) at the file end.
* extra/gc.c: Remove "file not well tested" comment.
Paolo Molaro [Mon, 24 Jan 2005 15:29:23 +0000 (15:29 +0000)]
Add on-heap-resize event notification to API
(Apply part of commit 3f1314a from 'mono_libgc' branch)
* include/gc.h (GC_on_heap_resize): New API variable declaration.
* alloc.c (GC_on_heap_resize): New global variable.
* alloc.c (GC_finish_collection): Invoke GC_on_heap_resize (if
non-zero) on returning true.
Ivan Maidanski [Thu, 12 Jan 2012 03:51:16 +0000 (07:51 +0400)]
Replace repeating '==' sequences in documentation with double '=' mark
* TODO: Replace sequences of repeating '==' identifying section
titles (which is also used by git-apply) with two '=' symbols at the
beginning and at the end of each title.
* ChangeLog: Likewise.
* doc/README.Mac: Likewise.
* doc/README.darwin: Likewise.
* configure.ac: Remove sequences of repeating '==' (in a comment).
* doc/README.amiga: Likewise.
Ivan Maidanski [Thu, 12 Jan 2012 03:25:56 +0000 (07:25 +0400)]
Improve GC_thread_is_registered implementation and testing
* pthread_support.c (GC_thread_is_registered): Call pthread_self
outside LOCK; add DCL_LOCK_STATE declaration; replace "ptr" local
variable with "GC_thread me" (and remove cast).
* win32_threads.c (GC_thread_is_registered): Fix implementation by
calling GC_lookup_thread_inner (now works the same as in
pthread_support.c).
* tests/test.c (run_one_test): Test GC_thread_is_registered (only if
THREADS).
Zoltan Varga [Thu, 3 Mar 2005 21:09:34 +0000 (21:09 +0000)]
Add GC_thread_is_registered API function
(Apply commit 9b40e5d from 'mono_libgc' branch)
* include/gc.h (GC_thread_is_registered): Declare new API function
(only if GC_THREADS).
* pthread_support.c (GC_thread_is_registered): New API function
implementation.
* win32_threads.c (GC_thread_is_registered): Likewise.
Ivan Maidanski [Tue, 10 Jan 2012 18:03:20 +0000 (22:03 +0400)]
Optimization: move pthread_self calls out of LOCK section
* pthread_support.c (GC_do_blocking_inner, GC_call_with_gc_active,
pthread_exit): Move pthread_self call out of LOCK section (declare
"self" local variable).
* win32_threads.c (GC_call_with_gc_active): Move GetCurrentThreadId
call out of LOCK section (declare "thread_id" local variable).
Zoltan Varga [Mon, 23 Feb 2009 21:26:49 +0000 (21:26 +0000)]
Avoid unnecessary GC_find_limit invocation if GC_no_dls
(Apply commit f5d47a1 from 'mono_libgc' branch)
* os_dep.c (GC_init_linux_data_start): Avoid the call to
GC_find_limit() if GC_no_dls is TRUE, as it is not needed and
it complicates debugging since it causes a SIGSEGV.
* os_dep.c (GC_register_data_segments): Add assertion for DATASTART.
Ivan Maidanski [Tue, 10 Jan 2012 10:16:26 +0000 (14:16 +0400)]
Add 'const' qualifier for GC_make_descriptor bitmap argument
* include/gc_typed.h (GC_make_descriptor): Make bm pointer const
(replace GC_bitmap type with "const GC_word*").
* typd_mlc.c (GC_add_ext_descriptor, GC_make_descriptor): Likewise.
* tests/test.c (bm_huge): Make array const to test updated
GC_make_descriptor declaration.
Ivan Maidanski [Tue, 10 Jan 2012 09:58:14 +0000 (13:58 +0400)]
Enable platform-specific disabling of static data scanning
(Reworked commit a0347f0 from 'mono_libgc' branch)
* include/private/gcconfig.h (GC_DONT_REGISTER_MAIN_STATIC_DATA):
Recognize new macro.
* include/private/gcconfig.h (DYNAMIC_LOADING): Do not define for
Darwin/arm if GC_DONT_REGISTER_MAIN_STATIC_DATA.
* misc.c (GC_REGISTER_MAIN_STATIC_DATA): Define to FALSE if
GC_DONT_REGISTER_MAIN_STATIC_DATA (and not DYNAMIC_LOADING).
Ivan Maidanski [Tue, 10 Jan 2012 06:27:33 +0000 (10:27 +0400)]
Win32: allow DllMain chaining on the client side
(Reworked commits e55eb9c, 34a996f from 'mono_libgc' branch)
* configure.ac (enable_win32_dllmain): Recognize new AC "enable"
option.
* configure.ac (GC_INSIDE_DLL): New AC macro (defined only if
enable_win32_dllmain).
* README.macros (GC_INSIDE_DLL): Document.
* include/gc.h (GC_DllMain): Declare as API function (for Win32) if
GC_INSIDE_DLL.
* win32_threads.c (GC_INSIDE_DLL): Recognize (treat the same as
GC_DLL).
* win32_threads.c (DllMain): Rename to GC_DllMain; use GC_API export
declarator if GC_INSIDE_DLL, otherwise define GC_DllMain macro as
a synonym to DllMain.
Ivan Maidanski [Thu, 29 Dec 2011 14:46:53 +0000 (18:46 +0400)]
Replace printf PRIxMAX specifier with '%p' for thread id debug output
* pthread_support.c (GC_new_thread, GC_delete_thread,
GC_delete_gc_thread, GC_unregister_my_thread_inner,
GC_unregister_my_thread, GC_thread_exit_proc,
GC_start_rtn_prepare_thread, pthread_create): Output thread id value
(when DEBUG_THREADS) using %p format specifier instead of PRIxMAX, %x
and %lx (casting passed id value to pointer type instead of uintmax_t).
* pthread_start.c (GC_inner_start_routine): Likewise.
GC_stop_world, GC_thread_resume, GC_start_world): Likewise.
* pthread_stop_world.c (GC_suspend_handler_inner, GC_restart_handler,
GC_push_all_stacks, GC_suspend_all, GC_stop_world, GC_start_world):
Likewise.
* darwin_stop_world.c (GC_stack_range_for, GC_suspend_thread_list,
* pthread_start.c: Do not include inttypes.h.
* pthread_support.c: Likewise.
* pthread_support.c (GC_count_threads): Define only if DEBUG_THREADS.
* pthread_support.c (GC_unregister_my_thread): Rename gc_self local
variable to "me".
* pthread_support.c (pthread_create): Report thread started (when
DEBUG_THREADS) only if result is 0.
Ivan Maidanski [Thu, 29 Dec 2011 12:12:37 +0000 (16:12 +0400)]
Add GC_is_heap_ptr() to GC API
* include/gc.h (GC_is_heap_ptr): New API function declaration.
* misc.c (GC_is_heap_ptr): New function.
* tests/test.c (run_one_test): Add GC_is_heap_ptr tests.
Ivan Maidanski [Thu, 29 Dec 2011 08:37:01 +0000 (12:37 +0400)]
Refactoring: rename GC_EXPECT to EXPECT in .c files
* fnlz_mlc.c (GC_core_finalized_malloc, GC_finalized_malloc):
Rename GC_EXPECT to EXPECT; replace 0/1 with TRUE/FALSE for the 2nd
argument of EXPECT.
* thread_local_alloc.c (GC_gcj_malloc): Likewise.
Ivan Maidanski [Wed, 28 Dec 2011 07:13:35 +0000 (11:13 +0400)]
configure: do not compile pthread_stop_world.c for Cygwin/Darwin
(to reduce linker warnings about empty object files)
* Makefile.am (libgc_la_SOURCES): Do not add pthread_start.c,
pthread_support.c, pthread_stop_world.c entries for Cygwin and
win32-pthread; do not add pthread_stop_world.c entry for Darwin.
Ivan Maidanski [Wed, 28 Dec 2011 06:42:49 +0000 (10:42 +0400)]
Fix compiler warning in GC_dyld_image_add/remove (Darwin)
* dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove): Declare i, j
local variables as unsigned (to prevent compiler warning in
a comparison involving sizeof)
Ivan Maidanski [Wed, 28 Dec 2011 06:42:49 +0000 (10:42 +0400)]
Fix compiler warning in GC_dyld_image_add/remove (Darwin)
* dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove): Declare i, j
local variables as unsigned (to prevent compiler warning in
a comparison involving sizeof)
Ivan Maidanski [Tue, 27 Dec 2011 07:43:41 +0000 (11:43 +0400)]
MacOSX: Accept i386_ prefix for exception_state_t (for compatibility)
* os_dep.c (DARWIN_EXC_STATE, DARWIN_EXC_STATE_COUNT,
DARWIN_EXC_STATE_T): Define to i386_EXCEPTION_STATE,
i386_EXCEPTION_STATE_COUNT and i386_exception_state_t, respectively,
for Darwin/x86 if i386_EXCEPTION_STATE_COUNT macro is defined.
Ivan Maidanski [Mon, 26 Dec 2011 12:36:07 +0000 (16:36 +0400)]
configure: Add script code to force USE_MMAP for some targets
(Apply part of commit 21a49a9 from 'gcc_boehmgc' branch)
* configure.ac (gc_use_mmap): New variable (blank currently); add
comment and FIXME.
* configure.ac (USE_MMAP): Force define in case of gc_use_mmap is yes.