summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-08-22 19:20:45 +0200
committerAraq <rumpf_a@web.de>2013-08-22 19:20:45 +0200
commit3940bd5b84ec41f91f784573c0b0e02bfa2f8bc9 (patch)
tree2743215e4a58afcc48cfd996fb08fdea6d7e890d /lib/system
parent6f1fc1b5ba7f74fde21467f5f0bfd294ad9292f3 (diff)
downloadNim-3940bd5b84ec41f91f784573c0b0e02bfa2f8bc9.tar.gz
GC: added static cycleGC checks
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/gc.nim10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/system/gc.nim b/lib/system/gc.nim
index cb264fe0d..36c008bef 100644
--- a/lib/system/gc.nim
+++ b/lib/system/gc.nim
@@ -173,9 +173,10 @@ proc rtlAddCycleRoot(c: PCell) {.rtl, inl.} =
   # we MUST access gch as a global here, because this crosses DLL boundaries!
   when hasThreadSupport and hasSharedHeap:
     AcquireSys(HeapLock)
-  if c.color != rcPurple:
-    c.setColor(rcPurple)
-    incl(gch.cycleRoots, c)
+  when cycleGC:
+    if c.color != rcPurple:
+      c.setColor(rcPurple)
+      incl(gch.cycleRoots, c)
   when hasThreadSupport and hasSharedHeap:
     ReleaseSys(HeapLock)
 
@@ -811,7 +812,8 @@ proc CollectZCT(gch: var TGcHeap): bool =
       # as this might be too slow.
       # In any case, it should be removed from the ZCT. But not
       # freed. **KEEP THIS IN MIND WHEN MAKING THIS INCREMENTAL!**
-      if canBeCycleRoot(c): excl(gch.cycleRoots, c)
+      when cycleGC:
+        if canBeCycleRoot(c): excl(gch.cycleRoots, c)
       when logGC: writeCell("zct dealloc cell", c)
       gcTrace(c, csZctFreed)
       # We are about to free the object, call the finalizer BEFORE its