diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-11-20 14:34:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 14:34:05 +0100 |
commit | 85ffcd80c05ae1bbf853121059c39a215a29ae54 (patch) | |
tree | 04d342d28caedab16c27aca10e3a3647c87944c3 /lib/core | |
parent | a88004114d6bfbef31268c96f4d1fc871e70ab03 (diff) | |
download | Nim-85ffcd80c05ae1bbf853121059c39a215a29ae54.tar.gz |
more arc improvements (#12690)
* ARC: bugfix for =destroy for inherited objects * added code useful for debugging
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/runtime_v2.nim | 7 |
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'. |