ARC: remove unnecessary code

This commit is contained in:
Araq
2020-01-26 09:35:52 +01:00
committed by Andreas Rumpf
parent 6efac70181
commit ab35f07e77
2 changed files with 3 additions and 18 deletions

View File

@@ -57,8 +57,6 @@ template head(p: pointer): Cell =
const
traceCollector = defined(traceArc)
var allocs*: int
proc nimNewObj(size: int): pointer {.compilerRtl.} =
let s = size + sizeof(RefHeader)
when defined(nimscript):
@@ -71,10 +69,6 @@ proc nimNewObj(size: int): pointer {.compilerRtl.} =
result = allocShared0(s) +! sizeof(RefHeader)
else:
result = alloc0(s) +! sizeof(RefHeader)
when hasThreadSupport:
atomicInc allocs
else:
inc allocs
when traceCollector:
cprintf("[Allocated] %p\n", result -! sizeof(RefHeader))
@@ -100,14 +94,6 @@ proc nimRawDispose(p: pointer) {.compilerRtl.} =
deallocShared(p -! sizeof(RefHeader))
else:
dealloc(p -! sizeof(RefHeader))
if allocs > 0:
when hasThreadSupport:
discard atomicDec(allocs)
else:
dec allocs
else:
cstderr.rawWrite "[FATAL] unpaired dealloc\n"
quit 1
template dispose*[T](x: owned(ref T)) = nimRawDispose(cast[pointer](x))
#proc dispose*(x: pointer) = nimRawDispose(x)

View File

@@ -1,7 +1,7 @@
discard """
cmd: '''nim c --newruntime $file'''
cmd: '''nim c -d:nimAllocStats --newruntime $file'''
output: '''331665
allocs 0'''
(allocCount: 333335, deallocCount: 333335)'''
"""
# bug #11053
@@ -87,6 +87,5 @@ proc main() =
discard
echo res
when isMainModule:
dumpAllocStats:
main()
echo "allocs ", allocs