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