aboutsummaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-12-16 15:07:30 +0000
committerMichael Williamson <mike@zwobble.org>2023-12-16 15:07:30 +0000
commit8f1f6e418ddc6bb03331a3aa7b1aa23bb824addb (patch)
treec4c589baf934726be276a29ef6332ffda96b3ba7 /runtime/src
parent3eef5e16a7871b230378b24709ee7f0638872f5a (diff)
Add mark_reachable()
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/gc.c12
1 files changed, 12 insertions, 0 deletions
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]);
+ }
+}