diff options
author | dzaima <dzaimagit@gmail.com> | 2024-04-03 04:08:09 +0300 |
---|---|---|
committer | dzaima <dzaimagit@gmail.com> | 2024-04-03 05:03:37 +0300 |
commit | 647a0b97e756f23298867e20a6095ee9953c9d9f (patch) | |
tree | 63455c8603b310eafe54c3e3eb988f4ad3f4cd99 | |
parent | d21a77119fd9ca3c6fae980ffa0fd33d09b2580f (diff) |
error on nested GC
-rw-r--r-- | src/opt/gc.c | 4 | ||||
-rw-r--r-- | src/opt/gc.h | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/opt/gc.c b/src/opt/gc.c index a054e9c2..1ac16927 100644 --- a/src/opt/gc.c +++ b/src/opt/gc.c @@ -168,8 +168,11 @@ static void gcv2_unmark_visit(Value* x) { #endif GLOBAL u64 gc_lastAlloc; +GLOBAL bool gc_running; void gc_forceGC(bool toplevel) { #if ENABLE_GC + if (gc_running) fatal("starting GC while GC is in the middle of running"); + gc_running = 1; u64 startTime=0, startSize=0; if (gc_log_enabled) { startTime = nsTime(); @@ -193,6 +196,7 @@ void gc_forceGC(bool toplevel) { fprintf(stderr, "; took %.3fms\n", (nsTime()-startTime)/1e6); } gc_lastAlloc = endSize; + gc_running = 0; #endif } diff --git a/src/opt/gc.h b/src/opt/gc.h index a0e5aeaa..f65e2e14 100644 --- a/src/opt/gc.h +++ b/src/opt/gc.h @@ -1,6 +1,7 @@ #pragma once extern GLOBAL u64 gc_depth; +extern GLOBAL bool gc_running; static void gc_disable() { gc_depth++; } static void gc_enable() { gc_depth--; } |