From 8f1f6e418ddc6bb03331a3aa7b1aa23bb824addb Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 16 Dec 2023 15:07:30 +0000 Subject: Add mark_reachable() --- runtime/src/gc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'runtime/src') diff --git a/runtime/src/gc.c b/runtime/src/gc.c index 97f26ba1..6958a772 100644 --- a/runtime/src/gc.c +++ b/runtime/src/gc.c @@ -103,3 +103,15 @@ void shed__runtime__gc_add_perm_root(ShedObject gc_root) { gc_perm_roots[gc_perm_root_index] = (struct ShedGcObjectHeader*) gc_root; gc_perm_root_index++; } + +// == Collection == + +void mark_reachable() { + for (size_t i = 0; i < gc_perm_root_index; i++) { + mark(gc_perm_roots[i]); + } + + for (size_t i = 0; i < gc_root_stack_index; i++) { + mark(gc_root_stack[i]); + } +} -- cgit v1.2.3