]> granicus.if.org Git - gc/log
gc
9 years agoNaCl GC improvements (fix volatile for vars accessed by syscall hooks)
Elijah Taylor [Thu, 31 Jan 2013 20:48:49 +0000 (12:48 -0800)]
NaCl GC improvements (fix volatile for vars accessed by syscall hooks)
(Apply part of commit 204bcc6 from 'mono_libgc' branch.)

Conflicts:
* pthread_stop_world.c
* pthread_support.c

9 years agoDefine GC_LINUX_THREADS, NO_EXECUTE_PERMISSION in configure for NaCl
Elijah Taylor [Fri, 17 Dec 2010 00:26:34 +0000 (16:26 -0800)]
Define GC_LINUX_THREADS, NO_EXECUTE_PERMISSION in configure for NaCl
(Apply part of commit 14b353e from 'mono_libgc' branch.)

* configure.ac: Handle *-*-nacl* (define GC_LINUX_THREADS and
NO_EXECUTE_PERMISSION).

9 years agoFix gc.mak regarding msvc_dbg and test (MSVC)
Ivan Maidanski [Wed, 30 Sep 2015 21:46:06 +0000 (00:46 +0300)]
Fix gc.mak regarding msvc_dbg and test (MSVC)

* gc.mak (CLEAN, BSC32_SBRS, LINK32_OBJS): Rename msvc_dbg.* to
msvc_dbg.copied.* file names.
* gc.mak (CLEAN): Erase msvc_dbg.copied.c, test.copied.c.
* gc.mak (msvc_dbg.copied.c): New rule.
* gc.mak (CLEAN, LINK32_OBJS, BSC32_SBRS, test.c): Rename test.* to
test.copied.* file names.
* gc.mak (CPP_PROJ): Add /D for "ALL_INTERIOR_POINTERS".

9 years ago.gitignore: Ignore .copied.c, .dll.manifest, idb, ilk files (MSVC)
Ivan Maidanski [Wed, 23 Sep 2015 07:43:53 +0000 (10:43 +0300)]
.gitignore: Ignore .copied.c, .dll.manifest, idb, ilk files (MSVC)

9 years agoFix race (and potential deadlock) at marker threads initialization
Ivan Maidanski [Tue, 22 Sep 2015 05:42:40 +0000 (08:42 +0300)]
Fix race (and potential deadlock) at marker threads initialization

* include/private/gc_priv.h (GC_wait_for_markers_init): New prototype.
* mark.c (GC_wait_for_markers_init): New function (if PARALLEL_MARK).
* pthread_support.c (GC_mark_thread): Notify start_mark_threads()
about completion of marker data initialization.
* win32_threads.c (GC_mark_thread): Likewise.
* pthread_support.c (start_mark_threads): Add assertion about
GC_fl_builder_count; call GC_wait_for_markers_init.
* win32_threads.c (start_mark_threads): Likewise.
* win32_threads.c (GC_mark_thread): Reformat code.

9 years agoFix 'value truncated' compiler warning in CORD_cat (MS VC)
Ivan Maidanski [Fri, 18 Sep 2015 22:26:36 +0000 (01:26 +0300)]
Fix 'value truncated' compiler warning in CORD_cat (MS VC)

* cord/cordbscs.c (CORD_cat_char_star, CORD_cat): Cast "lenx" to
unsigned char (to workaround false compiler warning about value
truncation).

9 years agoFix compilation for Android clang/arm with bfd linker
Ivan Maidanski [Wed, 16 Sep 2015 22:18:36 +0000 (01:18 +0300)]
Fix compilation for Android clang/arm with bfd linker

* include/private/thread_local_alloc.h (USE_COMPILER_TLS): Do not
define if ARM32 (and PLATFORM_ANDROID and __clang__); update comment.

9 years agoEnable thread-local storage for Android Clang
Ivan Maidanski [Wed, 16 Sep 2015 09:14:34 +0000 (12:14 +0300)]
Enable thread-local storage for Android Clang

* include/private/thread_local_alloc.h (USE_COMPILER_TLS): Define for
Android NDK clang3.6+ arm/arm64/x86/x86_64 (NDK r10e); update comment.

9 years agowindows-untested: Fix paths to msvc_dbg.c/h
Ivan Maidanski [Tue, 15 Sep 2015 07:49:01 +0000 (10:49 +0300)]
windows-untested: Fix paths to msvc_dbg.c/h

* windows-untested/vc60/gc.dsp (SOURCE): Fix paths to msvc_dbg.c and
msvc_dbg.h.
* windows-untested/vc60/libgc.dsp (SOURCE): Likewise.
* windows-untested/vc60/libgcmt.dsp (SOURCE): Likewise.
* windows-untested/vc60/libgcmt.dsp (File RelativePath): Likewise.
* windows-untested/vc70/libgc.vcproj (File RelativePath): Likewise.
* windows-untested/vc70/libgcmt.vcproj (File RelativePath): Likewise.
* windows-untested/vc71/gc.vcproj (File RelativePath): Likewise.
* windows-untested/vc71/libgc.vcproj (File RelativePath): Likewise.
* windows-untested/vc71/libgcmt.vcproj (File RelativePath): Likewise.

9 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 15 Sep 2015 07:15:35 +0000 (10:15 +0300)]
Update AUTHORS file

9 years agoFix typos in README for ews4800
Terrell Russell [Mon, 14 Sep 2015 18:48:41 +0000 (14:48 -0400)]
Fix typos in README for ews4800

* doc/README.ews4800: Fix typos ("information", "vendor", "the").

9 years agoUpdate compiler options in gc.mak (Win32)
Ivan Maidanski [Mon, 14 Sep 2015 08:25:03 +0000 (11:25 +0300)]
Update compiler options in gc.mak (Win32)

* gc.mak (CFG): Fix info about default configuration.
* gc.mak (CPP_PROJ): Replace deprecated /GX option with /EHsc; remove
deprecated /YX option; add /D _CRT_SECURE_NO_DEPRECATE option (to
suppress warning about vsprintf usage).

9 years ago.gitignore: Ignore .exp and .sbr also in subfolders (MSVC)
Ivan Maidanski [Mon, 14 Sep 2015 07:41:44 +0000 (10:41 +0300)]
.gitignore: Ignore .exp and .sbr also in subfolders (MSVC)

9 years agoTurn off sigsetjmp workaround for Android/x86 starting from NDK r8e
Ivan Maidanski [Fri, 11 Sep 2015 08:57:54 +0000 (11:57 +0300)]
Turn off sigsetjmp workaround for Android/x86 starting from NDK r8e

* include/private/gcconfig.h (GC_NO_SIGSETJMP): Do not define for
Android/x86 if NDK r8e+; update comment.

9 years agoFix abort message in GC_move_long_link
Ivan Maidanski [Thu, 10 Sep 2015 23:16:42 +0000 (02:16 +0300)]
Fix abort message in GC_move_long_link

* finalize.c (GC_move_long_link): Fix function name in abort message.

9 years agoFix 'comparison of non-null parameter is always false' warning (Clang)
Ivan Maidanski [Thu, 10 Sep 2015 08:48:05 +0000 (11:48 +0300)]
Fix 'comparison of non-null parameter is always false' warning (Clang)

* alloc.c (GC_set_stop_func, GC_try_to_collect): Use
NONNULL_ARG_NOT_NULL to check argument marked as non-null (in
function declaration) is actually non-null.
* finalize.c (GC_general_register_disappearing_link,
GC_register_long_link, GC_move_disappearing_link, GC_move_long_link):
Likewise.
* misc.c (GC_set_warn_proc, GC_set_abort_func, GC_set_oom_fn): Likewise.
* include/private/gc_priv.h (NONNULL_ARG_NOT_NULL): New macro.

9 years agoAllow fork() automatic handling on Android with API level 21+
Ivan Maidanski [Thu, 10 Sep 2015 07:32:52 +0000 (10:32 +0300)]
Allow fork() automatic handling on Android with API level 21+

* include/private/gcconfig.h (CAN_CALL_ATFORK): Define also if
__ANDROID_API__ >= 21.

9 years agoConsistently use int[] type for '_end' symbol
Ivan Maidanski [Thu, 10 Sep 2015 07:23:00 +0000 (10:23 +0300)]
Consistently use int[] type for '_end' symbol
(code refactoring)

* include/private/gcconfig.h (_end): Change char[] type to int[] (for
remaining entries).

9 years agoWorkaround 'sa_sigaction member missing' compiler error (Android/x32)
Ivan Maidanski [Wed, 9 Sep 2015 22:36:30 +0000 (01:36 +0300)]
Workaround 'sa_sigaction member missing' compiler error (Android/x32)

Client should define NO_SA_SIGACTION to enable the workaround.

* include/private/gcconfig.h (NO_SA_SIGACTION): New macro (explicitly
define if SA_SIGINFO undefined).
* include/private/gcconfig.h (MPROTECT_VDB): Undefine if
NO_SA_SIGACTION unless DARWIN, MSWIN32 or MSWINCE.
* pthread_stop_world.c (GC_suspend_handler, GC_stop_init): Check
NO_SA_SIGACTION instead of SA_SIGINFO.

9 years agoSupport build for Android 64-bit (arm64, mips64, x86_64)
Ivan Maidanski [Wed, 9 Sep 2015 21:15:22 +0000 (00:15 +0300)]
Support build for Android 64-bit (arm64, mips64, x86_64)

* include/private/gcconfig.h (_end): Replace type from char[] to int[]
to avoid redefinition error (as it is also declared in gc.h) for
Linux/x86_64.
* include/private/gcconfig.h (NO_GETCONTEXT): Define for all Android
targets.
* include/private/gcconfig.h (USE_TKILL_ON_ANDROID): New macro
(defined only for 32-bit Android targets).
* pthread_stop_world.c (tkill, android_thread_kill, GC_suspend_all,
GC_start_world): Use USE_TKILL_ON_ANDROID instead of PLATFORM_ANDROID.

9 years agoFix 'cast to pointer from integer' warning in GC_on_thread_event (64-bit)
Ivan Maidanski [Wed, 9 Sep 2015 20:55:37 +0000 (23:55 +0300)]
Fix 'cast to pointer from integer' warning in GC_on_thread_event (64-bit)

* pthread_stop_world.c (GC_suspend_all, GC_start_world): Cast thread_id
to pointer via word type on passing to GC_on_thread_event; add comment.

9 years agoSupport Android API level 21
Ivan Maidanski [Wed, 9 Sep 2015 08:42:43 +0000 (11:42 +0300)]
Support Android API level 21
(fix 'link_map redefinition' error on Android with API level 21+)

* dyn_load.c (link_map, r_debug): Do not define if android-21 (or
higher) API is used; update comment.

9 years agoFix (allow) thread local allocations from within pthread TLS destructors
Niklas Therning [Tue, 6 Jan 2015 22:32:43 +0000 (23:32 +0100)]
Fix (allow) thread local allocations from within pthread TLS destructors

Prevents the GC_thread_key from being cleared on thread exit until
after the thread has been unregistered by GC_unregister_my_thread_inner.

* include/private/thread_local_alloc.h (GC_remove_specific): Call
pthread_setspecific(key, NULL) if USE_PTHREAD_SPECIFIC; update comment.
* thread_local_alloc.c (reset_thread_key): New static function if
USE_PTHREAD_SPECIFIC); define (as macro) to 0 otherwise.
* thread_local_alloc.c (GC_init_thread_local): Pass reset_thread_key
(instead of 0) to GC_key_create.

9 years agoFix 'visibility attribute not supported' GCC warning (IBM AIX)
Ivan Maidanski [Wed, 2 Sep 2015 08:52:30 +0000 (11:52 +0300)]
Fix 'visibility attribute not supported' GCC warning (IBM AIX)

* configure.ac (enable_shared): Add -D GC_NO_VISIBILITY to CFLAGS if
not ac_cv_fvisibility_hidden.
* include/cord.h (CORD_API): Do not use visibility attribute if
GC_NO_VISIBILITY.
* include/gc_config_macros.h (GC_API): Likewise.
* include/private/gc_priv.h (GC_INNER, GC_API_OSCALL): Likewise.

9 years agoMerge branch 'toggleref'
Ivan Maidanski [Tue, 1 Sep 2015 06:59:25 +0000 (09:59 +0300)]
Merge branch 'toggleref'

9 years agoFix data race in GC_init_explicit_typing
Ivan Maidanski [Tue, 1 Sep 2015 06:57:38 +0000 (09:57 +0300)]
Fix data race in GC_init_explicit_typing

* typd_mlc.c: Force include atomic_ops.h if
GC_FORCE_INCLUDE_ATOMIC_OPS (by default it is included if
PARALLEL_MARK or pthreads are used).
* typd_mlc.c (GC_explicit_typing_initialized): Use AO_t if
AO_load_acquire() available.
* typd_mlc.c (GC_init_explicit_typing): Move locking (and
GC_explicit_typing_initialized access) outside to the caller
(GC_make_descriptor); remove comment; remove "register" keyword for
local variable.
* typd_mlc.c (GC_make_descriptor): Use AO_load_acquire (if available)
to fetch GC_explicit_typing_initialized value (to avoid data race and
avoid lock acquiring on each call).
* typd_mlc.c (GC_explicit_typing_initialized,
GC_malloc_explicitly_typed_ignore_off_page,
GC_calloc_explicitly_typed): Add assertion on
GC_explicit_typing_initialized is true.

9 years agoSupport FreeBSD/mips
Carlos J. Puga Medina [Sat, 29 Aug 2015 06:21:26 +0000 (09:21 +0300)]
Support FreeBSD/mips

* include/private/gcconfig.h (MIPS, mach_type_known, OS_TYPE,
ALIGNMENT, MPROTECT_VDB, SIG_SUSPEND, SIG_THR_RESTART, DYNAMIC_LOADING,
DATASTART_USES_BSDGETDATASTART): Define for FreeBSD/mips.
* os_dep.c (CODE_OK): Define to si->si_code==SEGV_ACCERR for
FreeBSD/mips.

9 years agoReduce GCToggleRef size twice (convert struct to union)
Ivan Maidanski [Fri, 28 Aug 2015 20:21:23 +0000 (23:21 +0300)]
Reduce GCToggleRef size twice (convert struct to union)

* finalize.c (GCToggleRef): Replace struct with union; update comment.
* finalize.c (GC_process_togglerefs): Check lowest bit of strong_ref
to select between strong_ref and weak_ref.
* finalize.c (GC_mark_togglerefs, GC_clear_togglerefs): Likewise.
* finalize.c (GC_process_togglerefs): Store only strong_ref or
weak_ref to GC_toggleref_arr elements.
* finalize.c (GC_toggleref_add): Likewise.

9 years agoCode refactoring of toggle-ref support
Ivan Maidanski [Thu, 27 Aug 2015 22:37:33 +0000 (01:37 +0300)]
Code refactoring of toggle-ref support

* alloc.c (GC_stopped_mark): Move GC_process_togglerefs() call from
GC_stop_world; do not call it if GC_NO_FINALIZATION or
GC_TOGGLE_REFS_NOT_NEEDED.
* darwin_stop_world.c (GC_stop_world): Remove GC_process_togglerefs()
call.
* pthread_stop_world.c (GC_stop_world): Likewise.
* doc/README.macros (GC_TOGGLE_REFS_NOT_NEEDED): Document.
* finalize.c (GCToggleRef, GC_process_togglerefs, push_and_mark_object,
GC_clear_togglerefs, GC_toggleref_add): Replace GC_PTR with void*.
* include/gc.h (GC_toggleref_add): Likewise.
* finalize.c (GCToggleRef, GC_toggleref_callback, GC_toggleref_arr,
GC_toggleref_array_size, GC_toggleref_array_capacity,
GC_process_togglerefs, push_and_mark_object, GC_mark_togglerefs,
GC_clear_togglerefs, GC_set_toggleref_func, ensure_toggleref_capacity,
GC_toggleref_add): Do not defined if GC_TOGGLE_REFS_NOT_NEEDED.
* finalize.c (GCToggleRef): Add comment.
* finalize.c (GC_toggleref_array): Rename to GC_toggleref_arr.
* finalize.c (GC_toggleref_callback, GC_toggleref_array,
GC_toggleref_array_size, GC_toggleref_array_capacity): Make it STATIC
(instead "static").
* finalize.c (GC_process_togglerefs): Decorate with GC_INNER; remove
"toggle_ref_counts", "res" local variables; rename "w" local variable
to "new_size"; add assertion on lock state; use GC_TOGGLE_REF_* enum
element in switch statement; use BZERO to clear moved elements of
GC_toggleref_arr.
* finalize.c (GC_normal_finalize_mark_proc): Declare (before use).
* finalize.c (push_and_mark_object): Replace PUSH_OBJ with
GC_normal_finalize_mark_proc call.
* finalize.c (GC_mark_togglerefs, GC_clear_togglerefs): Remove
"object" local variable.
* finalize.c (GC_toggleref_register_callback): Rename to
GC_set_toggleref_func; change argument to GC_toggleref_func (which
returns GC_ToggleRefStatus instead of int).
* finalize.c (GC_toggleref_register_callback, GC_toggleref_add):
Decorate with GC_API and GC_CALL.
* include/gc.h (GC_toggleref_register_callback): Likewise.
* finalize.c (GC_set_toggleref_func): Acquire allocation lock.
* finalize.c (GC_get_toggleref_func): New API function.
* finalize.c (ensure_toggleref_capacity): Rename "capacity" argument
to "capacity_inc"; add assertion on argument value; rename "tmp" local
variable to "new_array"; remove unused "old_capacity" variable; replace
memcpy() with BCOPY() call.
* finalize.c (GC_toggleref_add): Rename "strong_ref" argument to
"is_strong_ref".
* finalize.c (GC_finalize): Do not call GC_clear_togglerefs and
GC_mark_togglerefs if GC_TOGGLE_REFS_NOT_NEEDED.
* include/gc.h (GC_ToggleRefStatus, GC_toggleref_func): New type.
* include/gc.h (GC_toggleref_register_callback): Add comment
(including about locking).
* include/gc.h (GC_get_toggleref_func): New API function declaration.
* include/gc.h (GC_toggleref_add): Decorate with GC_CALL; add comment;
add GC_ATTR_NONNULL attribute.
* include/private/gc_priv.h (GC_process_togglerefs): Do not declare if
GC_TOGGLE_REFS_NOT_NEEDED; decorate with GC_INNER.

9 years agoFix out-of-memory handling in GC_toggleref_add
Ivan Maidanski [Tue, 25 Aug 2015 07:19:05 +0000 (10:19 +0300)]
Fix out-of-memory handling in GC_toggleref_add

* finalize.c (ensure_toggleref_capacity): Change return type from void
to GC_bool; return FALSE on allocation failure (or desired capacity
value overflow).
* finalize.c (GC_toggleref_add): Change return type from void to int.
* include/gc.h (GC_toggleref_add): Likewise.
* finalize.c (GC_toggleref_add): Return GC_NO_MEMORY if
ensure_toggleref_capacity failed, GC_SUCCESS otherwise (including the
case of no callback).

9 years agoFix clearing of moved toggle-refs array elements
Ivan Maidanski [Fri, 14 Aug 2015 07:29:48 +0000 (10:29 +0300)]
Fix clearing of moved toggle-refs array elements

* finalize.c (GC_process_togglerefs): Replace "w" to "i" local variable
in the loop which clears unused part of GC_toggleref_array.

9 years agoFix memory management for toggle-ref
Rodrigo Kumpera [Thu, 13 Mar 2014 22:47:26 +0000 (18:47 -0400)]
Fix memory management for toggle-ref
(Apply commit 960f233 from 'mono_libgc' branch.)

Replace GC_free with GC_INTERNAL_FREE. The former might take the GC lock
and deadlock us.

Replace GC_INTERNAL_MALLOC with GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE as
we don't need the rest of the GC messing around with the toggleref array.

9 years agoAdd toggle-ref support
Rodrigo Kumpera [Wed, 26 Feb 2014 17:14:39 +0000 (12:14 -0500)]
Add toggle-ref support
(Apply commit af75406 from 'mono_libgc' branch.)

GC backed toggleref machinery.  This enables
an embedder to support toggleref style of external memory management
without hooking up to the host retain/release machinery.
The API export two entry points.  The first let the caller register
a callback that decides the state of a given object, by
probably inspecting its native state.  The second allows registration
of objects with the toggleref machinery.
The idea of toggleref is that we keep an external reference to an
object and it can be  either a strong or weak reference.  We use
a weak reference when the external peer has no interest into the
object and a strong otherwise.

9 years agoMark fo_head, finalize_now with a single GC_push_all call
Ivan Maidanski [Wed, 19 Aug 2015 07:23:36 +0000 (10:23 +0300)]
Mark fo_head, finalize_now with a single GC_push_all call
(code refactoring)

* finalize.c (GC_fnlz_roots): New static variable.
* finalize.c (GC_fo_head, GC_finalize_now): Move into GC_fnlz_roots
(remove "GC_" prefix for field names).
* finalize.c (GC_push_finalizer_structures): Replace GC_ASSERT and
GC_PUSH_ALL_SYM for GC_fo_head, GC_finalize_now with a single
GC_ASSERT and GC_PUSH_ALL_SYM for GC_fnlz_roots.
* finalize.c (GC_register_finalizer_inner,
GC_register_finalizer_unreachable, GC_finalize,
GC_should_invoke_finalizers, GC_invoke_finalizers,
GC_notify_or_invoke_finalizers): Replace access to GC_fo_head,
GC_finalize_now with access to the corresponding field of
GC_fnlz_roots.

9 years agoCode refactoring of GC_push_finalizer/thread/typed_structures
Ivan Maidanski [Mon, 17 Aug 2015 11:32:19 +0000 (14:32 +0300)]
Code refactoring of GC_push_finalizer/thread/typed_structures

* finalize.c (GC_push_finalizer_structures): Replace GC_push_all with
GC_PUSH_ALL_SYM invocation.
* pthread_support.c (GC_push_thread_structures): Likewise.
* typd_mlc.c (GC_push_typed_structures_proc): Likewise.
* win32_threads.c (GC_push_thread_structures): Likewise.
* include/private/gc_priv.h (GC_PUSH_ALL_SYM): New macro (handy one to
push a symbol content).

9 years agoGC_make_descriptor code refactoring (eliminate two local variables)
Ivan Maidanski [Mon, 17 Aug 2015 11:47:58 +0000 (14:47 +0300)]
GC_make_descriptor code refactoring (eliminate two local variables)

* typd_mlc.c (GC_make_descriptor): Remove "all_bits_set", "index"
local variables; collapse "return result" statements.

9 years agoFix exporting of GC_push_finalizer_structures
Ivan Maidanski [Fri, 7 Aug 2015 18:35:14 +0000 (21:35 +0300)]
Fix exporting of GC_push_finalizer_structures

* finalize.c (GC_push_finalizer_structures): Use GC_API, GC_CALL
instead of GC_INNER (to match that of gc_mark.h).

9 years agoFix exporting of GC_push_all_eager
Ivan Maidanski [Fri, 7 Aug 2015 18:00:36 +0000 (21:00 +0300)]
Fix exporting of GC_push_all_eager

* include/gc_mark.h (GC_push_all_eager): Move comment from gc_priv.h.
* include/private/gc_priv.h (GC_push_all_eager): Remove (because has
it might have calling conventions different from that in gc.h).

9 years agoDistinct long-link table growth log message
Ivan Maidanski [Tue, 4 Aug 2015 22:43:46 +0000 (01:43 +0300)]
Distinct long-link table growth log message

* finalize.c (GC_register_disappearing_link_inner): Add tbl_log_name
argument and pass it to GC_COND_LOG_PRINTF (instead of "dl" name).
* finalize.c (GC_general_register_disappearing_link,
GC_register_long_link): Pass corresponding link hashtable short name
("dl" or "long dl") to GC_register_disappearing_link_inner.

9 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 4 Aug 2015 22:28:52 +0000 (01:28 +0300)]
Update AUTHORS file

9 years agoMake heap walker accept callback
Ivan Maidanski [Tue, 4 Aug 2015 22:20:32 +0000 (01:20 +0300)]
Make heap walker accept callback

* alloc.c (GC_mercury_callback_reachable_object): Remove.
* include/gc.h (GC_mercury_callback_reachable_object): Likewise.
* include/private/gc_priv.h (GC_mercury_enumerate_reachable_objects):
Likewise.
* alloc.c (GC_finish_collection): Do not call
GC_mercury_enumerate_reachable_objects.
* include/gc_mark.h (GC_reachable_object_proc): New public typedef.
* include/gc_mark.h (GC_enumerate_reachable_objects_inner): New API
function declaration.
* reclaim.c (enumerate_reachable_s): New struct type.
* reclaim.c (GC_mercury_do_enumerate_reachable_objects): Rename to
GC_do_enumerate_reachable_objects; replace while() with for(); use 2nd
argument to pass client callback and custom data; call client callback
(passed via the argument) instead of
GC_mercury_callback_reachable_object; pass object size in bytes
instead of words to client callback.
* reclaim.c (GC_mercury_enumerate_reachable_objects): Rename to
GC_enumerate_reachable_objects_inner; decorate with GC_API/GC_CALL;
add 2 arguments (client callback and custom data); remove assertion
for GC_mercury_callback_reachable_object; add assertion for acquired
lock.
* tests/test.c: Include gc_mark.h unconditionally.
* tests/test.c (reachable_objs_counter,
reachable_objs_count_enumerator): New function.
* tests/test.c (check_heap_stats): New local variable "obj_count";
invoke GC_call_with_alloc_lock(reachable_objs_count_enumerator);
print final number of reachable objects.

9 years agoAdd support for enumerating the reachable objects in the heap
Peter Wang [Mon, 16 Jun 2014 11:05:05 +0000 (21:05 +1000)]
Add support for enumerating the reachable objects in the heap
(Apply part of commit dbf2db8 from 'paulbone/mercury7_4_pbone' branch.)

This can be used to do heap profiling, helping the developer work out which
objects are live or what kinds of objects account for a lot of their heap
space.

* alloc.c:
* include/gc.h:
* include/private/gc_priv.h:
* reclaim.c:
    As above.

9 years agoReplace non-API occurrences of GC_word to word
Ivan Maidanski [Tue, 28 Jul 2015 08:20:44 +0000 (11:20 +0300)]
Replace non-API occurrences of GC_word to word
(code refactoring)

* finalize.c (last_finalizer_notification): Use "word" type instead of
GC_word.
* include/private/dbg_mlc.h (HIDE_BACK_PTR): Likewise.
* include/private/gc_priv.h (WARN): Likewise.
* include/private/gcconfig.h (POINTER_MASK): Likewise.
* mark.c (GC_push_marked): Likewise.
* misc.c (GC_init, GC_set_max_retries): Likewise.
* os_dep.c (GC_unmap, GC_remap, GC_unmap_gap): Likewise.
* typd_mlc.c (GC_add_ext_descriptor): Likewise.
* include/private/gcconfig.h (GC_amiga_get_mem, ps3_get_mem): Rename
argument to bytes.

9 years agoCode refactoring of 'alt-stack registration support'
Ivan Maidanski [Mon, 27 Jul 2015 07:34:35 +0000 (10:34 +0300)]
Code refactoring of 'alt-stack registration support'

* darwin_stop_world.c (GC_stack_range_for, GC_push_all_stacks):
Reformat code dealing with alt-stack.
* pthread_stop_world.c (GC_push_all_stacks): Likewise.
* darwin_stop_world.c (GC_stack_range_for): Cast pointers to word when
compared.
* GC_push_all_stacks (GC_push_all_stacks): Likewise.
* include/gc.h (GC_register_altstack): Reformat comment; decorate with
GC_CALL; comment out argument names; change type of altstack_size and
stack_size to word.
* include/private/pthread_support.h (altstack, altstack_size, stack,
stack_size): Refine and reformat comment.
* include/private/pthread_support.h (altstack_size, stack_size): Change
type from int to word.
* pthread_support.c (main_stack_size, main_altstack_size): Likewise.
* pthread_support.c (main_pthread_self): Rename to main_pthread_id.
* pthread_support.c (GC_register_altstack): Decorate with GC_API and
GC_CALL.
* win32_threads.c (GC_register_altstack): Likewise.
* pthread_support.c (GC_register_altstack): Rename "thread" local
variable to "me"; new local variable "self"; use DCL_LOCK_STATE;
reformat code.
* pthread_support.c (GC_thr_init): New local variable "self"; compare
thread id using THREAD_EQUAL; reformat code.
* win32_threads.c (GC_register_altstack): Add GC_ATTR_UNUSED to all
arguments to avoid compiler warning (while the function is
unimplemented); add TODO.

9 years agoAdd alt-stack registration support
Zoltan Varga [Mon, 21 May 2012 23:02:05 +0000 (01:02 +0200)]
Add alt-stack registration support
(Apply commit ff4ec56 from 'mono_libgc' branch.)

Fix altstack support in libgc by registering the bounds of the normal
stack and the altstack with it.

* darwin_stop_world.c (GC_stack_range_for): Add paltstack_lo,
paltstack_hi argments; set *paltstack_lo, *paltstack_hi, adjust lo and
hi if p->altstack set.
* darwin_stop_world.c (GC_push_all_stacks): Declare altstack_lo,
altstack_hi local variables; pass &altstack_lo, &altstack_hi to
GC_stack_range_for; do not call GC_push_all_stack(lo, hi) and
adjust total_size by hi-lo if lo is NULL; call
GC_push_all_stack(altstack_lo, altstack_hi) and increment total_size
by altstack_hi-altstack_lo if altstack_lo is non-NULL.
* include/gc.h (GC_register_altstack): New API function declaration.
* include/private/pthread_support.h (GC_Thread_Rep): Add altstack,
altstack_size, stack, stack_size fields.
* pthread_stop_world.c (GC_push_all_stacks): Adjust hi value if
p->altstack set.
* pthread_support.c (main_pthread_self, main_stack, main_altstack,
main_stack_size, main_altstack_size): New static variables.
* pthread_support.c (GC_register_altstack): New function.
* pthread_support.c (GC_thr_init): Set altstack, altstack_size, stack,
stack_size fields from values saved by GC_register_altstack (if called
before GC_thr_init).
* win32_threads.c (GC_register_altstack): New function (unimplemented).

9 years agoRemove unsupported FreeBSD/ia64 case from gcconfig.h
Ivan Maidanski [Tue, 21 Jul 2015 06:50:24 +0000 (09:50 +0300)]
Remove unsupported FreeBSD/ia64 case from gcconfig.h

* include/private/gcconfig.h (IA64, mach_type_known): Do not define if
FREEBSD and __ia64__.

9 years agoFreeBSD/arm support improvement
Carlos J. Puga Medina [Tue, 21 Jul 2015 06:44:41 +0000 (09:44 +0300)]
FreeBSD/arm support improvement

Update the arm32 code to match arm64, powerpc and x86.

* include/private/gc_priv.h: Include machine/trap.h if
DATASTART_USES_BSDGETDATASTART (instead of checking for FREEBSD and
particular CPUs).
* include/private/gcconfig.h (ALIGNMENT, HEURISTIC2,
SEARCH_FOR_DATA_START): Remove for FreeBSD/arm.
* include/private/gcconfig.h (MPROTECT_VDB, SIG_SUSPEND,
SIG_THR_RESTART, DATASTART, DATASTART_USES_BSDGETDATASTART): Define
macro if FREEBSD and ARM32.
* os_dep.c (CODE_OK): Define for FreeBSD/arm.

9 years agoCode refactoring of 'finalization extension API'
Ivan Maidanski [Sun, 19 Jul 2015 14:14:16 +0000 (17:14 +0300)]
Code refactoring of 'finalization extension API'

* finalize.c (GC_object_finalized_proc, GC_set_finalizer_notify_proc):
Use GC_await_finalize_proc type.
* finalize.c (GC_object_finalized_proc): Use STATIC instead of
"static".
* finalize.c (GC_set_finalizer_notify_proc): Rename to
GC_set_await_finalize_proc.
* include/gc.h (GC_set_finalizer_notify_proc): Likewise.
* finalize.c (GC_set_await_finalize_proc): Add LOCK/UNLOCK.
* finalize.c (GC_set_await_finalize_proc): Decorate with GC_CALL.
* include/gc.h (GC_set_await_finalize_proc): Likewise.
* finalize.c (GC_get_await_finalize_proc): New API function.
* include/gc.h (GC_await_finalize_proc): New type.
* include/gc.h (GC_set_await_finalize_proc): Document.
* include/gc.h (GC_get_await_finalize_proc): New API function
declaration.

9 years agoImplement the finalization extension API
Rodrigo Kumpera [Fri, 30 May 2014 01:51:29 +0000 (21:51 -0400)]
Implement the finalization extension API
(Apply commit c429e9f from 'mono_libgc' branch.)

Conflicts:

    finalize.c
    include/gc.h

9 years agoFix Makefile.direct for Cygwin
Paul Bone [Thu, 16 Jul 2015 17:31:24 +0000 (20:31 +0300)]
Fix Makefile.direct for Cygwin
(Apply part of commit 9f229e2 from "paulbone/mercury7_4_pbone" branch.)

* Makefile.direct (CXX, AS): Add comment.
* Makefile.direct (LD): New variable.
* Makefile.direct (libalphagc.so, libirixgc.so, mach_dep.o): Use LD
variable.
* Makefile.direct (mach_dep.o): Replace "as $(AS_ABI_FLAG)" with $(AS).
* Makefile.direct (mach_dep.o, mark_rts.o): Add Cygwin-specific rules.

9 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 14 Jul 2015 08:16:52 +0000 (11:16 +0300)]
Update AUTHORS file

9 years agoCode refactoring regarding 'data start' definition for FreeBSD
Ivan Maidanski [Sun, 12 Jul 2015 07:26:06 +0000 (10:26 +0300)]
Code refactoring regarding 'data start' definition for FreeBSD

* include/private/gcconfig.h (DATASTART_USES_BSDGETDATASTART): New
macro defined for FreeBSD when DATASTART is defined to
GC_FreeBSDGetDataStart().
* include/private/gcconfig.h (GC_FreeBSDGetDataStart,
DATASTART_IS_FUNC): Move declare/definition from the place where
DATASTART defined for FreeBSD to common place guarded with the check
of DATASTART_USES_BSDGETDATASTART.
* include/private/gcconfig.h (GC_FreeBSDGetDataStart): Decorate with
GC_INNER.
* os_dep.c (GC_FreeBSDGetDataStart): Likewise.
* os_dep.c (GC_FreeBSDGetDataStart): Define only if
DATASTART_USES_BSDGETDATASTART (instead of checking FREEBSD and
CPU-specific macros).

9 years agoFix support of FreeBSD/aarch64
Carlos J. Puga Medina [Sat, 11 Jul 2015 18:31:40 +0000 (21:31 +0300)]
Fix support of FreeBSD/aarch64

* include/private/gc_priv.h: Include machine/trap.h if qqqFREEBSD and
AARCH64 defined.
* os_dep.c (GC_FreeBSDGetDataStart, CODE_OK): Define if FREEBSD and
AARCH64.
* include/private/gc_priv.h: Replace checking powerpc/__powerpc__
macros with POWERPC.
* os_dep.c: Likewise.
* include/private/gcconfig.h (ALIGNMENT, HEURISTIC2,
SEARCH_FOR_DATA_START): Do not define for FREEBSD/AARCH64.
* include/private/gcconfig.h (MPROTECT_VDB, FREEBSD_STACKBOTTOM,
DATASTART, DATASTART_IS_FUNC): Define if FREEBSD and AARCH64 defined.

9 years agoCode refactoring, add test and document GC_get_memory_use
Ivan Maidanski [Thu, 9 Jul 2015 21:29:43 +0000 (00:29 +0300)]
Code refactoring, add test and document GC_get_memory_use

* include/gc.h (GC_get_memory_use): Add comment.
* include/gc.h (GC_get_memory_use): Decorate with GC_CALL; change
return type from long to size_t.
* misc.c (GC_get_memory_use): Likewise.
* misc.c (get_size): Rename to block_add_size.
* misc.c (get_size): Rename lptr parameter to pbytes; code refactoring.
* misc.c (GC_get_memory_use): Rename "c" local variable to "bytes";
add DCL_LOCK_STATE.
* tests/test.c (check_heap_stats): Call GC_get_memory_use (and print
returned value).

9 years agoAdd API function to calculate total memory in use by all GC blocks
Eli Barzilay [Wed, 8 Jul 2015 21:49:31 +0000 (00:49 +0300)]
Add API function to calculate total memory in use by all GC blocks
(Apply part of commit db2b9f1 from 'racket_gc' branch.)

* include/gc.h (GC_get_memory_use): New API function declaration.
* misc.c (get_size, GC_get_memory_use): New function.

9 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 7 Jul 2015 22:48:57 +0000 (01:48 +0300)]
Update AUTHORS file

9 years agoFix GC_get_stack_base if called before GC_init (Win32)
Eli Barzilay [Tue, 7 Jul 2015 22:22:23 +0000 (01:22 +0300)]
Fix GC_get_stack_base if called before GC_init (Win32)
(Apply part of commit db2b9f1 from 'racket_gc' branch.)

* os_dep.c (GC_get_stack_base): Call GC_setpagesize if GC_page_size is
not initialized (only if MSWIN32 but not CYGWIN32).

9 years agoExport GC_push_finalizer_structures
Ivan Maidanski [Mon, 6 Jul 2015 18:46:55 +0000 (21:46 +0300)]
Export GC_push_finalizer_structures

* include/gc_mark.h (GC_push_finalizer_structures): New API function
declaration.
* include/private/gc_priv.h (GC_push_finalizer_structures): Remove.

9 years agoRefine GC_free_space_divisor comment regarding its initial value
Ivan Maidanski [Mon, 6 Jul 2015 17:37:34 +0000 (20:37 +0300)]
Refine GC_free_space_divisor comment regarding its initial value

* include/gc.h (GC_free_space_divisor): Update comment regarding
initial value which is now controlled by GC_FREE_SPACE_DIVISOR macro
(defined at collector or client compile time).

9 years agoUpdate AUTHORS file
Ivan Maidanski [Sat, 4 Jul 2015 07:12:43 +0000 (10:12 +0300)]
Update AUTHORS file

9 years agoSupport FreeBSD/aarch64
Carlos J. Puga Medina [Fri, 3 Jul 2015 18:55:54 +0000 (21:55 +0300)]
Support FreeBSD/aarch64

* include/private/gcconfig.h (NOSYS): Do not define if FREEBSD and
__aarch64__.
* include/private/gcconfig.h (AARCH64, mach_type_known): Define if
FREEBSD and __aarch64__.
* include/private/gcconfig.h (ALIGNMENT, OS_TYPE, DYNAMIC_LOADING,
HEURISTIC2, SEARCH_FOR_DATA_START): Likewise.

9 years agoFix various spelling errors
David Van Horn [Wed, 2 Feb 2011 19:56:42 +0000 (14:56 -0500)]
Fix various spelling errors
(Apply commit 1efc418 from 'racket_gc' branch.)

* ChangeLog: Fix typo (accommodate).
* win32_threads.c (GC_pthread_create): Fix typo (interceptable).

Conflicts:

    Makefile.dj
    doc/README.changes
    dyn_load.c
    win32_threads.c

9 years agowin32: support MinGW build
Matthew Flatt [Fri, 7 Dec 2012 13:58:40 +0000 (07:58 -0600)]
win32: support MinGW build
(Apply commit 7f44cc9 from 'racket_gc' branch.)

A MinGW build is the same shape as a MSVC build (but without
MzCOM), unlike a Cygwin build.

* include/gc_config_macros.h (GC_API): Define to declspec(dllexport)
if GC_DLL and __MINGW32_DELAY_LOAD__ (even if no GC_BUILD).

Conflicts:

    include/gc_config_macros.h

9 years agoUpdate AUTHORS file
Ivan Maidanski [Sun, 28 Jun 2015 08:07:16 +0000 (11:07 +0300)]
Update AUTHORS file

9 years agoHarmonize OSX/iOS configuration; enable compiling for iPhone simulator
Joao Abecasis [Wed, 27 May 2015 12:26:12 +0000 (14:26 +0200)]
Harmonize OSX/iOS configuration; enable compiling for iPhone simulator

Darwin setup would assume i386/x86_64 was OS X, while arm/arm64 was iOS.
The iPhone simulator, however, breaks this assumption, covering both
i386 and x86_64 (depending on the simulated device).
With this patch <TargetConditionals.h> is pulled in and TARGET_OS_IPHONE
used to detect an iOS target -- both device and simulator.
Otherwise, #defines were moved to keep Darwin setup similar across
i386/x86_64/arm/arm64, making GC_DONT_REGISTER_MAIN_STATIC_DATA and
TARGET_OS_IPHONE options respected across the board.
(Apart from the added #include, Darwin on PowerPC is left as it was.)

* include/private/gcconfig.h: Include TargetConditionals.h (if DARWIN).
* include/private/gcconfig.h (DARWIN_DONT_PARSE_STACK): Move definition
to the place of OS_TYPE definition.
* include/private/gcconfig.h (DYNAMIC_LOADING): Define only if
GC_DONT_REGISTER_MAIN_STATIC_DATA (only if DARWIN).
* include/private/gcconfig.h (NO_DYLD_BIND_FULLY_IMAGE): Define only if
TARGET_OS_IPHONE != 0 (including simulator case).

9 years ago[Fix] Do not reference thread state struct for exception state (Darwin)
Joao Abecasis [Wed, 27 May 2015 09:31:56 +0000 (11:31 +0200)]
[Fix] Do not reference thread state struct for exception state (Darwin)

THREAD_FLD was being used to indirect access to both thread state and
exception state, which broke compilation for recent versions of iOS in
32-bit mode.
With this THREAD_FLD's logic is split, THREAD_FLD_NAME will prefix field
names as needed, while THREAD_FLD injects "ts_32." wrapper as needed to
access thread state.
Macros to access exception state updated to use THREAD_FLD_NAME.

* include/private/gc_priv.h (THREAD_FLD_NAME): New macro (only if
DARWIN).
* include/private/gc_priv.h (DARWIN_EXC_STATE_DAR): Define using
THREAD_FLD_NAME.
* os_dep.c (DARWIN_EXC_STATE_DAR): Use THREAD_FLD_NAME instead of
THREAD_FLD.

9 years agoEliminate warning about 64-bit pointer-to-int cast (Win64/pthreads-w32)
Ivan Maidanski [Wed, 24 Jun 2015 11:51:14 +0000 (14:51 +0300)]
Eliminate warning about 64-bit pointer-to-int cast (Win64/pthreads-w32)

* include/private/gc_locks.h (NUMERIC_THREAD_ID): Cast to unsigned long
through "word" type if GC_WIN32_PTHREADS but not winpthreads (to
suppress "cast from pointer to integer of different size" compiler
warning).
* win32_threads.c (NUMERIC_THREAD_ID): Likewise.
* win32_threads.c (NUMERIC_THREAD_ID): Do not define unless
GC_ASSERTIONS.

9 years agoExport GC_push_all_eager
Ivan Maidanski [Tue, 23 Jun 2015 12:17:27 +0000 (15:17 +0300)]
Export GC_push_all_eager

* include/gc_mark.h (GC_push_all_eager): New API function declaration.
* mark.c (GC_push_all_eager): Add GC_API, GC_CALL; change arguments
type from ptr_t to char*.

9 years agoAdd profiling callback events to indicate start/end of reclaim phase
Ivan Maidanski [Tue, 23 Jun 2015 11:52:41 +0000 (14:52 +0300)]
Add profiling callback events to indicate start/end of reclaim phase

* alloc.c (GC_finish_collection): Send GC_EVENT_RECLAIM_START and
GC_EVENT_RECLAIM_END to indicate objects marking phase start/end.
* include/gc.h (GC_EventType): Add GC_EVENT_RECLAIM_START/END.

9 years agoStandalone profiling callback for threads suspend/resume
Ivan Maidanski [Tue, 23 Jun 2015 11:39:29 +0000 (14:39 +0300)]
Standalone profiling callback for threads suspend/resume

* alloc.c (GC_on_collection_event, GC_set_on_collection_event,
GC_get_on_collection_event): Move from misc.c.
* alloc.c (GC_on_collection_event): Make STATIC.
* include/private/gc_priv.h (GC_on_collection_event): Remove
declaration.
* include/gc.h (GC_on_collection_event_proc): Remove 2nd argument of
the callback.
* alloc.c (GC_try_to_collect_inner, GC_stopped_mark): Likewise.
* darwin_stop_world.c (GC_suspend_thread_list, GC_stop_world,
GC_thread_resume): Use GC_on_thread_event instead of
GC_on_collection_event.
* pthread_stop_world.c (GC_suspend_all, GC_start_world): Likewise.
* win32_threads.c (GC_suspend, GC_start_world): Likewise.
* include/gc.h (GC_on_collection_event_proc): Update comment.
* include/gc.h (GC_set_on_collection_event,
GC_get_on_collection_event): Add comment.
* include/gc.h (GC_on_thread_event_proc): New callback type (only if
GC_THREADS).
* include/gc.h (GC_set_on_thread_event, GC_get_on_thread_event): New
API function declaration (only if GC_THREADS).
* include/private/gc_priv.h (GC_on_thread_event): New variable
declaration (only if THREADS).
* misc.c (GC_on_thread_event): New global variable (only if THREADS).
* misc.c (GC_set_on_thread_event, GC_get_on_thread_event): New API
function (only if THREADS).

9 years agoAdjust places where profiling callbacks invoked (to match Mono GC)
Ivan Maidanski [Sat, 20 Jun 2015 19:22:07 +0000 (22:22 +0300)]
Adjust places where profiling callbacks invoked (to match Mono GC)

* alloc.c (GC_try_to_collect_inner): Move sending of GC_EVENT_START to
the beginning of function (i.e. send right after GC_dont_gc check);
move sending of GC_EVENT_END from GC_finish_collection to the end of
this function (send it only if collection completed successfully); add
TODO note about GC_EVENT_ABANDON notification.
* alloc.c (start_world_inner): Remove.
* alloc.c (GC_stopped_mark): Send GC_EVENT_PRE_STOP_WORLD,
GC_EVENT_POST_STOP_WORLD, GC_EVENT_PRE_START_WORLD,
GC_EVENT_POST_START_WORLD only if THREADS.
* alloc.c (GC_stopped_mark): Send GC_EVENT_MARK_START before
minimizing junk left in registers/stack (instead of after).
* alloc.c (GC_stopped_mark): Do not send GC_EVENT_MARK_END in case of
abandoned collection (add TODO note about GC_EVENT_MARK_ABANDON).
* alloc.c (GC_stopped_mark): Send GC_EVENT_MARK_END after checking
debugged objects for consistency (instead of before it).
* darwin_stop_world.c (GC_suspend_thread_list): Send
GC_EVENT_THREAD_SUSPENDED (in addition to that in GC_stop_world).
* darwin_stop_world.c (GC_thread_resume): Move sending of
GC_EVENT_THREAD_UNSUSPENDED from GC_start_world().
* pthread_stop_world.c (GC_suspend_all, GC_start_world): Do not send
GC_EVENT_THREAD_SUSPENDED if pthread_kill/android_thread_kill failed.
* pthread_stop_world.c (GC_start_world): Send
GC_EVENT_THREAD_UNSUSPENDED after pthread_resume_np (in case of
GC_OPENBSD_UTHREADS).
* win32_threads.c (GC_stop_world): Move sending of
GC_EVENT_THREAD_SUSPENDED to GC_suspend().
* win32_threads.c (GC_suspend, GC_start_world): Remove redundant cast
to void* of THREAD_HANDLE().

9 years agoRename GCEventKind to GC_EventType (profiling event type)
Ivan Maidanski [Fri, 19 Jun 2015 21:26:07 +0000 (00:26 +0300)]
Rename GCEventKind to GC_EventType (profiling event type)

* include/gc.h (GCEventKind, GC_on_collection_event_proc): Rename
GCEventKind to GC_EventType.

9 years agoRename and reorder profiling callback events (to match Mono GC API)
Ivan Maidanski [Fri, 19 Jun 2015 16:23:29 +0000 (19:23 +0300)]
Rename and reorder profiling callback events (to match Mono GC API)

* include/gc.h (GCEventKind): Reorder events.
* include/gc.h (GCEventKind): Rename events (GC_EVENT_COLLECTION_BEGIN
to GC_EVENT_START, GC_EVENT_MARK_BEGIN to GC_EVENT_MARK_START,
GC_EVENT_COLLECTION_END to GC_EVENT_END,
GC_EVENT_STOPWORLD_BEGIN/END to GC_EVENT_PRE/POST_STOP_WORLD,
GC_EVENT_STARTWORLD_BEGIN/END to GC_EVENT_PRE/POST_START_WORLD).
* alloc.c (GC_try_to_collect_inner, start_world_inner, GC_stopped_mark,
GC_finish_collection): Likewise.

9 years agoMerge branch 'profiling-callbacks'
Ivan Maidanski [Sun, 17 May 2015 18:03:22 +0000 (21:03 +0300)]
Merge branch 'profiling-callbacks'

9 years agoCode refactoring of "event callbacks" functionality
Ivan Maidanski [Sun, 17 May 2015 15:23:52 +0000 (18:23 +0300)]
Code refactoring of "event callbacks" functionality

* alloc.c (GC_on_collection_event): Remove declaration (moved to
gc_priv.h).
* darwin_stop_world.c (GC_on_collection_event): Likewise.
* pthread_stop_world.c (GC_on_collection_event): Likewise.
* win32_threads.c (GC_on_collection_event): Likewise.
* alloc.c (start_world): Rename to start_world_inner; inline it.
* darwin_stop_world.c (GC_start_world): Wrap long code lines.
* pthread_stop_world.c (GC_suspend_all, GC_start_world): Likewise.
* win32_threads.c (GC_stop_world, GC_start_world): Likewise.
* include/gc.h: Remove trailing space at EOLn.
* include/private/gc_priv.h (GC_on_collection_event): Declare global
variable (using GC_EXTERN).
* misc.c (GC_on_collection_event): Add GC_INNER; replace NULL to 0.

9 years agoFix logic/compile errors in "event callbacks" code (Darwin, Pthreads)
Ivan Maidanski [Sun, 17 May 2015 14:37:51 +0000 (17:37 +0300)]
Fix logic/compile errors in "event callbacks" code (Darwin, Pthreads)

* darwin_stop_world.c (GC_stop_world): Replace
GC_EVENT_THREAD_UNSUSPENDED to GC_EVENT_THREAD_SUSPENDED.
* pthread_stop_world.c (GC_on_collection_event): Declare.
* pthread_stop_world.c (GC_suspend_all): Change type of "thread_id"
local variable to pthread_t (or pid_t for Android) instead of int; fix
"threadid" parameter to "thread_id" in GC_on_collection_event call;
implement notification for NaCl target.
* pthread_stop_world.c (GC_start_world): Declare "thread_id" local
variable; implement notification for NaCl target.

9 years agoUpdate AUTHORS file
Ivan Maidanski [Sun, 17 May 2015 11:43:35 +0000 (14:43 +0300)]
Update AUTHORS file

9 years agoUpdate AUTHORS file
Ivan Maidanski [Sun, 17 May 2015 11:10:32 +0000 (14:10 +0300)]
Update AUTHORS file

9 years agoAdd build system plumbing for building with -Werror.
Alex Ronne Petersen [Tue, 10 Jun 2014 07:34:01 +0000 (09:34 +0200)]
Add build system plumbing for building with -Werror.

* Makefile.am (AM_CFLAGS): Add $(WERROR_CFLAGS).
* configure.ac (WERROR_CFLAGS): Define based on --enable-werror new
configure option value.

Conflicts:

    Makefile.am
    configure.ac

9 years agoUpdate ChangeLog file
Ivan Maidanski [Sat, 16 May 2015 10:56:03 +0000 (13:56 +0300)]
Update ChangeLog file

9 years agoUpdate ChangeLog file
Ivan Maidanski [Thu, 14 May 2015 22:00:01 +0000 (01:00 +0300)]
Update ChangeLog file
(Apply commit e2ed67b from 'release-7_4' branch.)

Conflicts:

    ChangeLog

9 years agoMerge branch 'jtotz-bdwgc-integrate-2'
Ivan Maidanski [Mon, 11 May 2015 16:16:08 +0000 (19:16 +0300)]
Merge branch 'jtotz-bdwgc-integrate-2'

9 years agoAvoid new[] debug variant definition for ancient MS VC++
Ivan Maidanski [Mon, 4 May 2015 20:21:06 +0000 (23:21 +0300)]
Avoid new[] debug variant definition for ancient MS VC++
(restore behavior broken in commit 3d784ed)

* include/gc_cpp.h (operator new[]): Update comment.
* include/gc_cpp.h (operator new[]): Do not define the debug variant
for MS VC pre-v7; add comment.

Conflicts:

    include/gc_cpp.h

9 years agoRe-enable gc_cpp.h usage for GC compiled without ATOMIC_UNCOLLECTABLE
Ivan Maidanski [Fri, 10 Apr 2015 23:01:41 +0000 (02:01 +0300)]
Re-enable gc_cpp.h usage for GC compiled without ATOMIC_UNCOLLECTABLE

GC_ATOMIC_UNCOLLECTABLE macro is recognized (in gc_cpp.h) to enable
GC_malloc_atomic_uncollectable functionality.

* include/gc_cpp.h (enum GCPlacement): Remove NoGCPointerFree alias.
* include/gc_cpp.h (enum GCPlacement): Do not declare PointerFreeNoGC
element unless GC_ATOMIC_UNCOLLECTABLE defined.
* include/gc_cpp.h (gc::operator new, operator new): Do not handle
PointerFreeNoGC (and do not call GC_MALLOC_ATOMIC_UNCOLLECTABLE) unless
GC_ATOMIC_UNCOLLECTABLE defined.

9 years agoReformat code of gc_cpp.cc/h
Ivan Maidanski [Mon, 11 May 2015 15:25:22 +0000 (18:25 +0300)]
Reformat code of gc_cpp.cc/h

* include/gc_cpp.h: Reformat code (and comments).
* gc_cpp.cc: Likewise.
* include/gc_cpp.h (operator new): Replace if-then-else with switch.

Conflicts:

    include/gc_cpp.h

9 years agoRestore definition of new/delete operators in gc_cpp.cc (for non-VC)
Ivan Maidanski [Mon, 4 May 2015 17:28:24 +0000 (20:28 +0300)]
Restore definition of new/delete operators in gc_cpp.cc (for non-VC)
(revert part of commit 3d784ed)

* gc_cpp.cc (new, delete, new[], delete[]): Add definition (unless
_MSC_VER defined).

Conflicts:

    gc_cpp.cc

9 years agoRemove commented out code in gc_cpp.cc/h
Ivan Maidanski [Mon, 11 May 2015 15:12:03 +0000 (18:12 +0300)]
Remove commented out code in gc_cpp.cc/h
(code refactoring)

* gc_cpp.cc: Remove commented out code.
* include/gc_cpp.h: Likewise.

Conflicts:

    gc_cpp.cc
    include/gc_cpp.h

9 years agoput all the cpp stuff in header
Johannes Totz [Tue, 13 Jul 2010 14:14:53 +0000 (15:14 +0100)]
put all the cpp stuff in header
otherwise vc9 will mix up new and delete operators (due to arbitrary ordering during linking)

Conflicts:

gc_cpp.cc
include/gc_cpp.h

9 years agoenable atomic-uncollectable
Johannes Totz [Mon, 24 Jan 2011 17:56:37 +0000 (17:56 +0000)]
enable atomic-uncollectable
pretty much the same as system's malloc, but is useful in force-include scenarios

Conflicts:

    include/gc.h
    include/gc_cpp.h
    vc9/libgc.vcproj

9 years agoEnable gc.h inclusion by client without implicit include windows.h (Win32)
Ivan Maidanski [Fri, 8 May 2015 06:26:36 +0000 (09:26 +0300)]
Enable gc.h inclusion by client without implicit include windows.h (Win32)

* doc/README.macros (GC_DONT_INCLUDE_WINDOWS_H): Document.
* include/gc.h: Include windows.h unless GC_DONT_INCLUDE_WINDOWS_H
(only for Win32).
* include/gc.h (DECLSPEC_NORETURN): Define to __declspec(noreturn) by
default if windows.h not included (instead of empty).
* include/gc.h (GC_WIN32_SIZE_T): Define to DWORD (or unsigned long)
unless _WIN64 (instead of GC_uintptr_t which is unsigned int for
32-bit target).
* include/gc.h (GC_DllMain, GC_CreateThread, GC_ExitThread): If WINAPI
undefined (i.e., if windows.h not included by or prior to gc.h) then
declare the prototype using built-in C types instead of Windows types.

9 years agoAdjust code indentation of malloc/calloc/str[n]dup
Ivan Maidanski [Thu, 16 Apr 2015 07:33:16 +0000 (10:33 +0300)]
Adjust code indentation of malloc/calloc/str[n]dup
(and do not define GC_init_lib_bounds if unused)

* malloc.c (GC_debug_malloc_replacement): Do not define/undefine macro
if REDIRECT_MALLOC_IN_HEADER.
* malloc.c (GC_libpthread_start, GC_libpthread_start,
GC_libpthread_end, GC_libld_start, GC_init_lib_bounds): Do not define
if REDIRECT_MALLOC_IN_HEADER.
* malloc.c (GC_debug_malloc_replacement, malloc, GC_init_lib_bounds,
calloc, strdup, strndup, free): Reformat code (adjust indentation) and
comments.
* malloc (free): Do not call GC_free if IGNORE_FREE defined.

Conflicts:

malloc.c

9 years agoRecognize REDIRECT_MALLOC_IN_HEADER macro
Ivan Maidanski [Sun, 25 Nov 2012 08:07:13 +0000 (12:07 +0400)]
Recognize REDIRECT_MALLOC_IN_HEADER macro

* include/private/gcconfig.h: Do not issue error on REDIRECT_MALLOC
and THREADS if REDIRECT_MALLOC_IN_HEADER defined.
* malloc.c (malloc, calloc, strdup, strndup, free): Do not define if
REDIRECT_MALLOC_IN_HEADER.
* mallocx.c (realloc): Likewise.

Conflicts:

    include/gc.h
    include/private/gcconfig.h
    malloc.c
    mallocx.c

9 years agoDo not pass VC-specific 'pragma message' in gc.h to other compilers (Win64)
Ivan Maidanski [Sun, 5 Apr 2015 15:59:45 +0000 (18:59 +0300)]
Do not pass VC-specific 'pragma message' in gc.h to other compilers (Win64)

* include/gc.h: Pass pragma message (to identify missing predefined
symbols for Win64) only if _MSC_VER (as it is specific to VC); report
the message only on first gc.h inclusion; adjust related comment.

Conflicts:

    include/gc.h

9 years agodebug helper for preproc symbol mix up
Johannes Totz [Tue, 24 Aug 2010 19:40:51 +0000 (20:40 +0100)]
debug helper for preproc symbol mix up
i got bitten by it... for some reason _WIN64 is not defined all the time. glitch in vc9?

Conflicts:

    include/gc.h

9 years agoRemove erroneous GC_use_threads_discovery call from GC_DllMain
Ivan Maidanski [Sun, 25 Nov 2012 09:42:04 +0000 (13:42 +0400)]
Remove erroneous GC_use_threads_discovery call from GC_DllMain

* win32_threads.c (GC_use_threads_discovery): Uncomment assertion;
update comment.
* win32_threads.c (GC_DllMain): Remove erroneous
GC_use_threads_discovery call; add comment.
* windows-untested/vc9/libgc.vcproj (PreprocessorDefinitions): Add
GC_DISCOVER_TASK_THREADS (due to removal of GC_use_threads_discovery
from GC_DllMain).

Conflicts:

    win32_threads.c

9 years agovc9: Move to windows-untested; adjust scripts in *.vcproj
Ivan Maidanski [Sun, 18 Nov 2012 08:18:50 +0000 (12:18 +0400)]
vc9: Move to windows-untested; adjust scripts in *.vcproj

9 years agono _DLL should not be defined here! it's predefined by the compiler
Johannes Totz [Thu, 24 Mar 2011 12:36:25 +0000 (12:36 +0000)]
no _DLL should not be defined here! it's predefined by the compiler
depending on which runtime library option was enabled

Conflicts:

    vc9/libgc.vcproj

9 years agoadd two more test cases
Johannes Totz [Fri, 20 Aug 2010 01:09:56 +0000 (02:09 +0100)]
add two more test cases

Conflicts:

tests/huge_test.c

9 years agoadd x64
Johannes Totz [Thu, 29 Jul 2010 15:18:09 +0000 (16:18 +0100)]
add x64
note that size_t types are 64 bit wide on x64 whereas dword types stay fixed at being 32 bit wide

Conflicts:

    include/gc.h
    win32_threads.c

9 years agofix us some project files for vc9
Johannes Totz [Tue, 13 Jul 2010 14:15:27 +0000 (15:15 +0100)]
fix us some project files for vc9

Conflicts:

windows-untested/vc60/gc.dsp
windows-untested/vc60/libgc.dsp
windows-untested/vc60/libgcmt.dsp
windows-untested/vc70/gc.vcproj
windows-untested/vc70/libgc.vcproj
windows-untested/vc70/libgcmt.vcproj