Make heap walker accept callback
authorIvan Maidanski <ivmai@mail.ru>
Tue, 4 Aug 2015 22:20:32 +0000 (01:20 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 4 Aug 2015 22:24:11 +0000 (01:24 +0300)
commit84fcf4c60351ce8dc7251f2af8c08e0a25eb8ac0
tree17dcbaea3f260d6165bd517febf55ebbbc7bea39
parenta20fa5174654eff73fd5164a9135646cc76108de
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.
alloc.c
include/gc.h
include/gc_mark.h
include/private/gc_priv.h
reclaim.c
tests/test.c