diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-11-03 09:46:33 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-11-03 09:46:49 +0100 |
commit | 3f4b9971fc098e05a75f0d830f2f04e1dc814668 (patch) | |
tree | f6cb2faabd980b7a7edebc45e9ab25b371467809 /lib/core | |
parent | 4c9a7e6f00c034414d0d12e2c7110417908c33b2 (diff) | |
download | Nim-3f4b9971fc098e05a75f0d830f2f04e1dc814668.tar.gz |
newruntime: only check for dangling refs when 'owned ref T' support is enabled
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/runtime_v2.nim | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/core/runtime_v2.nim b/lib/core/runtime_v2.nim index fe4bf37bf..aa2511ce4 100644 --- a/lib/core/runtime_v2.nim +++ b/lib/core/runtime_v2.nim @@ -71,13 +71,14 @@ proc nimIncRef(p: pointer) {.compilerRtl, inl.} = proc nimRawDispose(p: pointer) {.compilerRtl.} = when not defined(nimscript): - when hasThreadSupport: - let hasDanglingRefs = atomicLoadN(addr head(p).rc, ATOMIC_RELAXED) != 0 - else: - let hasDanglingRefs = head(p).rc != 0 - if hasDanglingRefs: - cstderr.rawWrite "[FATAL] dangling references exist\n" - quit 1 + when defined(nimOwnedEnabled): + when hasThreadSupport: + let hasDanglingRefs = atomicLoadN(addr head(p).rc, ATOMIC_RELAXED) != 0 + else: + let hasDanglingRefs = head(p).rc != 0 + if hasDanglingRefs: + cstderr.rawWrite "[FATAL] dangling references exist\n" + quit 1 when defined(useMalloc): c_free(p -! sizeof(RefHeader)) else: |