diff options
-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--; } |