summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/core/runtime_v2.nim7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/core/runtime_v2.nim b/lib/core/runtime_v2.nim
index 0d55ff4ac..3dd4a77c6 100644
--- a/lib/core/runtime_v2.nim
+++ b/lib/core/runtime_v2.nim
@@ -68,6 +68,7 @@ proc nimIncRef(p: pointer) {.compilerRtl, inl.} =
     atomicInc head(p).rc
   else:
     inc head(p).rc
+    #cprintf("[INCREF] %p\n", p)
 
 proc nimRawDispose(p: pointer) {.compilerRtl.} =
   when not defined(nimscript):
@@ -113,13 +114,15 @@ proc nimDecRefIsLast(p: pointer): bool {.compilerRtl, inl.} =
       if atomicLoadN(addr head(p).rc, ATOMIC_RELAXED) == 0:
         result = true
       else:
-        if atomicDec(head(p).rc) <= 0:
-          result = true
+        discard atomicDec(head(p).rc)
     else:
       if head(p).rc == 0:
         result = true
+        #cprintf("[DESTROY] %p\n", p)
       else:
         dec head(p).rc
+        # According to Lins it's correct to do nothing else here.
+        #cprintf("[DeCREF] %p\n", p)
 
 proc GC_unref*[T](x: ref T) =
   ## New runtime only supports this operation for 'ref T'.