diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2015-08-05 01:20:32 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2015-08-05 01:24:11 +0300 |
commit | 84fcf4c60351ce8dc7251f2af8c08e0a25eb8ac0 (patch) | |
tree | 17dcbaea3f260d6165bd517febf55ebbbc7bea39 /include | |
parent | a20fa5174654eff73fd5164a9135646cc76108de (diff) | |
download | bdwgc-84fcf4c60351ce8dc7251f2af8c08e0a25eb8ac0.tar.gz |
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.
Diffstat (limited to 'include')
-rw-r--r-- | include/gc.h | 3 | ||||
-rw-r--r-- | include/gc_mark.h | 10 | ||||
-rw-r--r-- | include/private/gc_priv.h | 2 |
3 files changed, 10 insertions, 5 deletions
diff --git a/include/gc.h b/include/gc.h index e98431ca..d1423818 100644 --- a/include/gc.h +++ b/include/gc.h @@ -392,9 +392,6 @@ GC_API GC_ATTR_DEPRECATED unsigned long GC_time_limit; GC_API void GC_CALL GC_set_time_limit(unsigned long); GC_API unsigned long GC_CALL GC_get_time_limit(void); -GC_API void (*GC_mercury_callback_reachable_object)(GC_word *, size_t); - /* This object on the heap is reachable. */ - /* Public procedures */ /* Set whether the GC will allocate executable memory pages or not. */ diff --git a/include/gc_mark.h b/include/gc_mark.h index 28d2005a..7edb7f5e 100644 --- a/include/gc_mark.h +++ b/include/gc_mark.h @@ -289,6 +289,16 @@ typedef void (GC_CALLBACK * GC_push_other_roots_proc)(void); GC_API void GC_CALL GC_set_push_other_roots(GC_push_other_roots_proc); GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void); +/* Walk the GC heap visiting all reachable objects. Assume the caller */ +/* holds the allocation lock. Object base pointer, object size and */ +/* client custom data are passed to the callback (holding the lock). */ +typedef void (GC_CALLBACK *GC_reachable_object_proc)(void * /* obj */, + size_t /* bytes */, + void * /* client_data */); +GC_API void GC_CALL GC_enumerate_reachable_objects_inner( + GC_reachable_object_proc, + void * /* client_data */) GC_ATTR_NONNULL(1); + #ifdef __cplusplus } /* end of extern "C" */ #endif diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index e369a7cc..f3f0718e 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -2082,8 +2082,6 @@ void GC_print_static_roots(void); extern word GC_fo_entries; /* should be visible in extra/MacOS.c */ -GC_INNER void GC_mercury_enumerate_reachable_objects(void); - #ifdef KEEP_BACK_PTRS GC_INNER void GC_store_back_pointer(ptr_t source, ptr_t dest); GC_INNER void GC_marked_for_finalization(ptr_t dest); |