From 6751721ab5e1e2815d2f41ccaf961c3fdb5e0700 Mon Sep 17 00:00:00 2001 From: Ico Doornekamp Date: Sat, 18 Jan 2020 10:38:52 +0100 Subject: [PATCH] Cleanup, remove lib/system/allocators.nim. seqs_v2 and strs_v2 now use allocShared0 by default. --- compiler/ccgexprs.nim | 12 +-- compiler/ccgliterals.nim | 4 +- compiler/ccgtypes.nim | 2 +- lib/system/alloc.nim | 8 ++ lib/system/allocators.nim | 86 ------------------- lib/system/memalloc.nim | 4 +- lib/system/seqs_v2.nim | 40 ++++----- lib/system/strs_v2.nim | 50 +++++------ lib/system/widestrs.nim | 8 +- tests/destructor/tbintree2.nim | 6 +- tests/destructor/tgcdestructors.nim | 7 +- tests/destructor/tnewruntime_misc.nim | 9 +- tests/destructor/tnewruntime_strutils.nim | 6 +- tests/destructor/tsimpleclosure.nim | 6 +- tests/destructor/tuse_ownedref_after_move.nim | 7 +- tests/destructor/tv2_raise.nim | 7 +- tests/destructor/twidgets.nim | 6 +- tests/destructor/twidgets_unown.nim | 6 +- 18 files changed, 72 insertions(+), 202 deletions(-) delete mode 100644 lib/system/allocators.nim diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index e52be902b1310..cc5e8bac7b2eb 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2037,15 +2037,15 @@ proc genDestroy(p: BProc; n: PNode) = of tyString: var a: TLoc initLocExpr(p, arg, a) - linefmt(p, cpsStmts, "if ($1.p && $1.p->allocator) {$n" & - " $1.p->allocator->dealloc($1.p->allocator, $1.p, $1.p->cap + 1 + sizeof(NI) + sizeof(void*));$n" & + linefmt(p, cpsStmts, "if ($1.p && $1.p->allocated) {$n" & + " #deallocShared($1.p);$n" & " $1.p = NIM_NIL; }$n", [rdLoc(a)]) of tySequence: var a: TLoc initLocExpr(p, arg, a) - linefmt(p, cpsStmts, "if ($1.p && $1.p->allocator) {$n" & - " $1.p->allocator->dealloc($1.p->allocator, $1.p, ($1.p->cap * sizeof($2)) + sizeof(NI) + sizeof(void*));$n" & + linefmt(p, cpsStmts, "if ($1.p && $1.p->allocated) {$n" & + " #deallocShared($1.p);$n" & " $1.p = NIM_NIL; }$n", [rdLoc(a), getTypeDesc(p.module, t.lastSon)]) else: discard "nothing to do" @@ -2884,8 +2884,8 @@ proc genConstSeqV2(p: BProc, n: PNode, t: PType; isConst: bool): Rope = appcg(p.module, cfsData, "static $5 struct {$n" & - " NI cap; void* allocator; $1 data[$2];$n" & - "} $3 = {$2, NIM_NIL, $4};$n", [ + " NI cap; NI allocated; $1 data[$2];$n" & + "} $3 = {$2, 0, $4};$n", [ getTypeDesc(p.module, base), n.len, payload, data, if isConst: "const" else: ""]) result = "{$1, ($2*)&$3}" % [rope(n.len), getSeqPayloadType(p.module, t), payload] diff --git a/compiler/ccgliterals.nim b/compiler/ccgliterals.nim index b513485087326..422b25a7ce28e 100644 --- a/compiler/ccgliterals.nim +++ b/compiler/ccgliterals.nim @@ -55,8 +55,8 @@ proc genStringLiteralV1(m: BModule; n: PNode): Rope = proc genStringLiteralDataOnlyV2(m: BModule, s: string; result: Rope; isConst: bool) = m.s[cfsData].addf("static $4 struct {$n" & - " NI cap; void* allocator; NIM_CHAR data[$2+1];$n" & - "} $1 = { $2, NIM_NIL, $3 };$n", + " NI cap; NI allocated; NIM_CHAR data[$2+1];$n" & + "} $1 = { $2, 0, $3 };$n", [result, rope(s.len), makeCString(s), rope(if isConst: "const" else: "")]) diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 56f227e372101..04fc0341e451c 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -432,7 +432,7 @@ proc seqV2ContentType(m: BModule; t: PType; check: var IntSet) = appcg(m, m.s[cfsTypes], """$N $3ifndef $2_Content_PP $3define $2_Content_PP -struct $2_Content { NI cap;#AllocatorObj* allocator;$1 data[SEQ_DECL_SIZE];}; +struct $2_Content { NI cap;NI allocated;$1 data[SEQ_DECL_SIZE];}; $3endif$N """, [getTypeDescAux(m, t.skipTypes(abstractInst)[0], check), result, rope"#"]) diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index c65abe5c2c32a..a73396882a431 100644 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -997,13 +997,21 @@ template instantiateForRegion(allocator: untyped) {.dirty.} = proc deallocOsPages = deallocOsPages(allocator) + proc c_getenv(env: cstring): cstring {.importc: "getenv", header: "".} + proc alloc(size: Natural): pointer = result = alloc(allocator, size) + if c_getenv("DUMP") != nil: + cfprintf(cstderr, "alloc %p: %d\n", result, size); proc alloc0(size: Natural): pointer = result = alloc0(allocator, size) + if c_getenv("DUMP") != nil: + cfprintf(cstderr, "alloc %p: %d\n", result, size); proc dealloc(p: pointer) = + if c_getenv("DUMP") != nil: + cfprintf(cstderr, "dealloc %p\n", p); dealloc(allocator, p) proc realloc(p: pointer, newSize: Natural): pointer = diff --git a/lib/system/allocators.nim b/lib/system/allocators.nim deleted file mode 100644 index e642999a81c7a..0000000000000 --- a/lib/system/allocators.nim +++ /dev/null @@ -1,86 +0,0 @@ -# -# -# Nim's Runtime Library -# (c) Copyright 2017 Nim contributors -# -# See the file "copying.txt", included in this -# distribution, for details about the copyright. -# - -## Unstable API. - -type - AllocatorFlag* {.pure.} = enum ## flags describing the properties of the allocator - ThreadLocal ## the allocator is thread local only. - ZerosMem ## the allocator always zeros the memory on an allocation - Allocator* = ptr AllocatorObj - AllocatorObj* {.inheritable, compilerproc.} = object - alloc*: proc (a: Allocator; size: int; alignment: int = 8): pointer {.nimcall, raises: [], tags: [], gcsafe.} - dealloc*: proc (a: Allocator; p: pointer; size: int) {.nimcall, raises: [], tags: [], gcsafe.} - realloc*: proc (a: Allocator; p: pointer; oldSize, newSize: int): pointer {.nimcall, raises: [], tags: [], gcsafe.} - deallocAll*: proc (a: Allocator) {.nimcall, raises: [], tags: [], gcsafe.} - flags*: set[AllocatorFlag] - name*: cstring - allocCount: int - deallocCount: int - -var - localAllocator {.threadvar.}: Allocator - sharedAllocator: Allocator - allocatorStorage {.threadvar.}: AllocatorObj - -when defined(useMalloc) and not defined(nimscript): - import "system/ansi_c" - -import "system/memory" - -template `+!`(p: pointer, s: int): pointer = - cast[pointer](cast[int](p) +% s) - -proc getLocalAllocator*(): Allocator = - result = localAllocator - if result == nil: - result = addr allocatorStorage - result.alloc = proc (a: Allocator; size: int; alignment: int = 8): pointer {.nimcall, raises: [].} = - when defined(useMalloc) and not defined(nimscript): - result = c_malloc(cuint size) - # XXX do we need this? - nimZeroMem(result, size) - elif compileOption("threads"): - result = system.allocShared0(size) - else: - result = system.alloc0(size) - inc a.allocCount - result.dealloc = proc (a: Allocator; p: pointer; size: int) {.nimcall, raises: [].} = - when defined(useMalloc) and not defined(nimscript): - c_free(p) - elif compileOption("threads"): - system.deallocShared(p) - else: - system.dealloc(p) - inc a.deallocCount - result.realloc = proc (a: Allocator; p: pointer; oldSize, newSize: int): pointer {.nimcall, raises: [].} = - when defined(useMalloc) and not defined(nimscript): - result = c_realloc(p, cuint newSize) - elif compileOption("threads"): - result = system.reallocShared(p, newSize) - else: - result = system.realloc(p, newSize) - nimZeroMem(result +! oldSize, newSize - oldSize) - result.deallocAll = nil - result.flags = {ThreadLocal, ZerosMem} - result.name = "nim_local" - localAllocator = result - -proc setLocalAllocator*(a: Allocator) = - localAllocator = a - -proc getSharedAllocator*(): Allocator = - result = sharedAllocator - -proc setSharedAllocator*(a: Allocator) = - sharedAllocator = a - -proc allocCounters*(): (int, int) = - let a = getLocalAllocator() - result = (a.allocCount, a.deallocCount) diff --git a/lib/system/memalloc.nim b/lib/system/memalloc.nim index b48a6d70a9b2c..8ff184a1602dc 100644 --- a/lib/system/memalloc.nim +++ b/lib/system/memalloc.nim @@ -122,7 +122,7 @@ when hasAlloc: ## The freed memory must belong to its allocating thread! ## Use `deallocShared <#deallocShared,pointer>`_ to deallocate from a shared heap. - proc allocShared*(size: Natural): pointer {.noconv, rtl, benign, raises: [], tags: [].} + proc allocShared*(size: Natural): pointer {.noconv, compilerproc, rtl, benign, raises: [], tags: [].} ## Allocates a new memory block on the shared heap with at ## least ``size`` bytes. ## @@ -196,7 +196,7 @@ when hasAlloc: ## `freeShared <#freeShared,ptr.T>`_. cast[ptr T](reallocShared(p, T.sizeof * newSize)) - proc deallocShared*(p: pointer) {.noconv, rtl, benign, raises: [], tags: [].} + proc deallocShared*(p: pointer) {.noconv, compilerproc, rtl, benign, raises: [], tags: [].} ## Frees the memory allocated with ``allocShared``, ``allocShared0`` or ## ``reallocShared``. ## diff --git a/lib/system/seqs_v2.nim b/lib/system/seqs_v2.nim index ed49d3abc7ac2..546ebf39a7b22 100644 --- a/lib/system/seqs_v2.nim +++ b/lib/system/seqs_v2.nim @@ -9,15 +9,20 @@ # import typetraits -# strs already imported allocators for us. +# strs already imported allocateds for us. proc supportsCopyMem(t: typedesc): bool {.magic: "TypeTrait".} ## Default seq implementation used by Nim's core. type + + NimSeqPayloadBase = object + cap: int + allocated: int + NimSeqPayload[T] = object cap: int - allocator: Allocator + allocated: int data: UncheckedArray[T] NimSeqV2*[T] = object @@ -26,22 +31,16 @@ type const nimSeqVersion {.core.} = 2 -template payloadSize(cap): int = cap * sizeof(T) + sizeof(int) + sizeof(Allocator) +template payloadSize(cap): int = cap * sizeof(T) + sizeof(NimSeqPayloadBase) # XXX make code memory safe for overflows in '*' -type - PayloadBase = object - cap: int - allocator: Allocator - proc newSeqPayload(cap, elemSize: int): pointer {.compilerRtl, raises: [].} = # we have to use type erasure here as Nim does not support generic # compilerProcs. Oh well, this will all be inlined anyway. if cap > 0: - let allocator = getLocalAllocator() - var p = cast[ptr PayloadBase](allocator.alloc(allocator, cap * elemSize + sizeof(int) + sizeof(Allocator))) - p.allocator = allocator + var p = cast[ptr NimSeqPayloadBase](allocShared0(cap * elemSize + sizeof(NimSeqPayloadBase))) + p.allocated = 1 p.cap = cap result = p else: @@ -53,7 +52,7 @@ proc prepareSeqAdd(len: int; p: pointer; addlen, elemSize: int): pointer {. template `+!`(p: pointer, s: int): pointer = cast[pointer](cast[int](p) +% s) - const headerSize = sizeof(int) + sizeof(Allocator) + const headerSize = sizeof(NimSeqPayloadBase) if addlen <= 0: result = p elif p == nil: @@ -61,22 +60,17 @@ proc prepareSeqAdd(len: int; p: pointer; addlen, elemSize: int): pointer {. else: # Note: this means we cannot support things that have internal pointers as # they get reallocated here. This needs to be documented clearly. - var p = cast[ptr PayloadBase](p) + var p = cast[ptr NimSeqPayloadBase](p) let cap = max(resize(p.cap), len+addlen) - if p.allocator == nil: - let allocator = getLocalAllocator() - var q = cast[ptr PayloadBase](allocator.alloc(allocator, - headerSize + elemSize * cap)) + if p.allocated == 0: + var q = cast[ptr NimSeqPayloadBase](allocShared0(headerSize + elemSize * cap)) copyMem(q +! headerSize, p +! headerSize, len * elemSize) - q.allocator = allocator + q.allocated = 1 q.cap = cap result = q else: - let allocator = p.allocator - var q = cast[ptr PayloadBase](allocator.realloc(allocator, p, - headerSize + elemSize * p.cap, - headerSize + elemSize * cap)) - q.allocator = allocator + var q = cast[ptr NimSeqPayloadBase](reallocShared(p, headerSize + elemSize * cap)) + q.allocated = 1 q.cap = cap result = q diff --git a/lib/system/strs_v2.nim b/lib/system/strs_v2.nim index 555028f31de8b..486bca8c84943 100644 --- a/lib/system/strs_v2.nim +++ b/lib/system/strs_v2.nim @@ -9,12 +9,14 @@ ## Default new string implementation used by Nim's core. -import allocators - type + NimStrPayloadBase = object + cap: int + allocated: int + NimStrPayload {.core.} = object cap: int - allocator: Allocator + allocated: int data: UncheckedArray[char] NimStringV2 {.core.} = object @@ -23,13 +25,13 @@ type const nimStrVersion {.core.} = 2 -template isLiteral(s): bool = s.p == nil or s.p.allocator == nil +template isLiteral(s): bool = s.p == nil or s.p.allocated == 0 -template contentSize(cap): int = cap + 1 + sizeof(int) + sizeof(Allocator) +template contentSize(cap): int = cap + 1 + sizeof(NimStrPayloadBase) template frees(s) = if not isLiteral(s): - s.p.allocator.dealloc(s.p.allocator, s.p, contentSize(s.p.cap)) + deallocShared(s.p) proc resize(old: int): int {.inline.} = if old <= 0: result = 4 @@ -41,18 +43,15 @@ proc prepareAdd(s: var NimStringV2; addlen: int) {.compilerRtl.} = if addlen > 0: let oldP = s.p # can't mutate a literal, so we need a fresh copy here: - let allocator = getLocalAllocator() - s.p = cast[ptr NimStrPayload](allocator.alloc(allocator, contentSize(s.len + addlen))) - s.p.allocator = allocator + s.p = cast[ptr NimStrPayload](allocShared0(contentSize(s.len + addlen))) + s.p.allocated = 1 s.p.cap = s.len + addlen if s.len > 0: # we are about to append, so there is no need to copy the \0 terminator: copyMem(unsafeAddr s.p.data[0], unsafeAddr oldP.data[0], s.len) elif s.len + addlen > s.p.cap: let cap = max(s.len + addlen, resize(s.p.cap)) - s.p = cast[ptr NimStrPayload](s.p.allocator.realloc(s.p.allocator, s.p, - oldSize = contentSize(s.p.cap), - newSize = contentSize(cap))) + s.p = cast[ptr NimStrPayload](reallocShared(s.p, contentSize(cap))) s.p.cap = cap proc nimAddCharV1(s: var NimStringV2; c: char) {.compilerRtl.} = @@ -65,9 +64,8 @@ proc toNimStr(str: cstring, len: int): NimStringV2 {.compilerproc.} = if len <= 0: result = NimStringV2(len: 0, p: nil) else: - let allocator = getLocalAllocator() - var p = cast[ptr NimStrPayload](allocator.alloc(allocator, contentSize(len))) - p.allocator = allocator + var p = cast[ptr NimStrPayload](allocShared0(contentSize(len))) + p.allocated = 1 p.cap = len if len > 0: # we are about to append, so there is no need to copy the \0 terminator: @@ -98,9 +96,8 @@ proc rawNewString(space: int): NimStringV2 {.compilerproc.} = if space <= 0: result = NimStringV2(len: 0, p: nil) else: - let allocator = getLocalAllocator() - var p = cast[ptr NimStrPayload](allocator.alloc(allocator, contentSize(space))) - p.allocator = allocator + var p = cast[ptr NimStrPayload](allocShared0(contentSize(space))) + p.allocated = 1 p.cap = space result = NimStringV2(len: 0, p: p) @@ -108,9 +105,8 @@ proc mnewString(len: int): NimStringV2 {.compilerproc.} = if len <= 0: result = NimStringV2(len: 0, p: nil) else: - let allocator = getLocalAllocator() - var p = cast[ptr NimStrPayload](allocator.alloc(allocator, contentSize(len))) - p.allocator = allocator + var p = cast[ptr NimStrPayload](allocShared0(contentSize(len))) + p.allocated = 1 p.cap = len result = NimStringV2(len: len, p: p) @@ -131,23 +127,21 @@ proc nimAsgnStrV2(a: var NimStringV2, b: NimStringV2) {.compilerRtl.} = a.p = b.p else: if isLiteral(a) or a.p.cap < b.len: - let allocator = if a.p != nil and a.p.allocator != nil: a.p.allocator else: getLocalAllocator() # we have to allocate the 'cap' here, consider # 'let y = newStringOfCap(); var x = y' # on the other hand... These get turned into moves now. frees(a) - a.p = cast[ptr NimStrPayload](allocator.alloc(allocator, contentSize(b.len))) - a.p.allocator = allocator + a.p = cast[ptr NimStrPayload](allocShared0(contentSize(b.len))) + a.p.allocated = 1 a.p.cap = b.len a.len = b.len copyMem(unsafeAddr a.p.data[0], unsafeAddr b.p.data[0], b.len+1) proc nimPrepareStrMutationV2(s: var NimStringV2) {.compilerRtl.} = - if s.p != nil and s.p.allocator == nil: + if s.p != nil and s.p.allocated == 0: let oldP = s.p # can't mutate a literal, so we need a fresh copy here: - let allocator = getLocalAllocator() - s.p = cast[ptr NimStrPayload](allocator.alloc(allocator, contentSize(s.len))) - s.p.allocator = allocator + s.p = cast[ptr NimStrPayload](allocShared0(contentSize(s.len))) + s.p.allocated = 1 s.p.cap = s.len copyMem(unsafeAddr s.p.data[0], unsafeAddr oldP.data[0], s.len+1) diff --git a/lib/system/widestrs.nim b/lib/system/widestrs.nim index f3a6f9d77a5f3..59e507a4d74b0 100644 --- a/lib/system/widestrs.nim +++ b/lib/system/widestrs.nim @@ -18,8 +18,6 @@ type when defined(nimv2): - import system / allocators - type WideCString* = ptr UncheckedArray[Utf16Char] @@ -29,8 +27,7 @@ when defined(nimv2): proc `=destroy`(a: var WideCStringObj) = if a.data != nil: - let alor = getLocalAllocator() - alor.dealloc(alor, a.data, a.bytes) + deallocShared(a.data) a.data = nil proc `=`(a: var WideCStringObj; b: WideCStringObj) {.error.} @@ -41,8 +38,7 @@ when defined(nimv2): proc createWide(a: var WideCStringObj; bytes: int) = a.bytes = bytes - let alor = getLocalAllocator() - a.data = cast[typeof(a.data)](alor.alloc(alor, bytes)) + a.data = cast[typeof(a.data)](allocShared0(bytes)) template `[]`(a: WideCStringObj; idx: int): Utf16Char = a.data[idx] template `[]=`(a: WideCStringObj; idx: int; val: Utf16Char) = a.data[idx] = val diff --git a/tests/destructor/tbintree2.nim b/tests/destructor/tbintree2.nim index 5f88ffff5f525..678bb0943af22 100644 --- a/tests/destructor/tbintree2.nim +++ b/tests/destructor/tbintree2.nim @@ -1,10 +1,8 @@ discard """ cmd: '''nim c --newruntime $file''' - output: '''0 -3 3 alloc/dealloc pairs: 0''' + output: '''0''' """ -import system / allocators import system / ansi_c import random @@ -99,5 +97,3 @@ proc main() = main() -let (a, d) = allocCounters() -discard cprintf("%ld %ld alloc/dealloc pairs: %ld\n", a, d, system.allocs) diff --git a/tests/destructor/tgcdestructors.nim b/tests/destructor/tgcdestructors.nim index 4a66b4f77065b..c274fe8583f3c 100644 --- a/tests/destructor/tgcdestructors.nim +++ b/tests/destructor/tgcdestructors.nim @@ -9,11 +9,9 @@ ha a: @[4, 2, 3] 0 30 -true -41 41''' +true''' """ -import system / allocators include system / ansi_c proc main = @@ -202,6 +200,3 @@ takeAinArray() echo ga == "foo" -#echo s -let (a, d) = allocCounters() -discard cprintf("%ld %ld\n", a, d) diff --git a/tests/destructor/tnewruntime_misc.nim b/tests/destructor/tnewruntime_misc.nim index 612d1a11653d8..224a61252beaf 100644 --- a/tests/destructor/tnewruntime_misc.nim +++ b/tests/destructor/tnewruntime_misc.nim @@ -4,14 +4,12 @@ discard """ Indeed axc (v: 10) -0 new: 0 +63 ... destroying GenericObj[T] GenericObj[system.int] -test -''' +test''' """ -import system / allocators import system / ansi_c import tables @@ -87,8 +85,7 @@ proc testWrongAt() = testWrongAt() -let (a, d) = allocCounters() -discard cprintf("%ld new: %ld\n", a - unpairedEnvAllocs() - d, allocs) +discard cprintf("%ld\n", unpairedEnvAllocs()) #------------------------------------------------- type diff --git a/tests/destructor/tnewruntime_strutils.nim b/tests/destructor/tnewruntime_strutils.nim index 76f2d1a7639ed..e99df13dfb18b 100644 --- a/tests/destructor/tnewruntime_strutils.nim +++ b/tests/destructor/tnewruntime_strutils.nim @@ -2,13 +2,11 @@ discard """ valgrind: true cmd: '''nim c --newruntime -d:useMalloc $file''' output: ''' -@[(input: @["KXSC", "BGMC"]), (input: @["PXFX"]), (input: @["WXRQ", "ZSCZD"])] -461 461''' +@[(input: @["KXSC", "BGMC"]), (input: @["PXFX"]), (input: @["WXRQ", "ZSCZD"])]''' """ import strutils, os, std / wordwrap -import system / allocators import system / ansi_c # bug #11004 @@ -214,5 +212,3 @@ staticTests() let xaa = @[""].join() let xbb = @["", ""].join() -let (a, d) = allocCounters() -discard cprintf("%ld %ld\n", a, d) diff --git a/tests/destructor/tsimpleclosure.nim b/tests/destructor/tsimpleclosure.nim index 088f4a95c735b..a1de64c063db5 100644 --- a/tests/destructor/tsimpleclosure.nim +++ b/tests/destructor/tsimpleclosure.nim @@ -4,11 +4,9 @@ discard """ 70 hello hello -hello -2 2 alloc/dealloc pairs: 0''' +hello''' """ -import system / allocators import system / ansi_c proc main(): owned(proc()) = @@ -60,5 +58,3 @@ when false: stringIter() -let (a, d) = allocCounters() -discard cprintf("%ld %ld alloc/dealloc pairs: %ld\n", a, d, system.allocs) diff --git a/tests/destructor/tuse_ownedref_after_move.nim b/tests/destructor/tuse_ownedref_after_move.nim index 31f580db3f7fa..46540837c3d9c 100644 --- a/tests/destructor/tuse_ownedref_after_move.nim +++ b/tests/destructor/tuse_ownedref_after_move.nim @@ -1,10 +1,9 @@ discard """ cmd: '''nim c --newruntime $file''' - errormsg: "'=' is not available for type ; requires a copy because it's not the last read of ':envAlt.b1'; another read is done here: tuse_ownedref_after_move.nim(53, 4)" - line: 49 + errormsg: "'=' is not available for type ; requires a copy because it's not the last read of ':envAlt.b1'; another read is done here: tuse_ownedref_after_move.nim(52, 4)" + line: 48 """ -import system / allocators import system / ansi_c type @@ -56,5 +55,3 @@ proc main = main() -let (a, d) = allocCounters() -discard cprintf("%ld %ld new: %ld\n", a, d, allocs) diff --git a/tests/destructor/tv2_raise.nim b/tests/destructor/tv2_raise.nim index 409cdead8d24b..adff7a5c2ee5b 100644 --- a/tests/destructor/tv2_raise.nim +++ b/tests/destructor/tv2_raise.nim @@ -1,12 +1,10 @@ discard """ cmd: '''nim c --newruntime $file''' - output: '''OK 3 -5 2''' + output: '''OK 3''' """ import strutils, math import system / ansi_c -import system / allocators proc mainA = try: @@ -50,6 +48,3 @@ except: inc ok echo "OK ", ok - -let (a, d) = allocCounters() -discard cprintf("%ld %ld\n", a, d) diff --git a/tests/destructor/twidgets.nim b/tests/destructor/twidgets.nim index 9537748e34277..d2227bee42224 100644 --- a/tests/destructor/twidgets.nim +++ b/tests/destructor/twidgets.nim @@ -1,11 +1,9 @@ discard """ cmd: '''nim c --newruntime $file''' output: '''button -clicked! -1 1 alloc/dealloc pairs: 0''' +clicked!''' """ -import system / allocators import system / ansi_c type @@ -74,5 +72,3 @@ proc main = main() -let (a, d) = allocCounters() -discard cprintf("%ld %ld alloc/dealloc pairs: %ld\n", a, d, allocs) diff --git a/tests/destructor/twidgets_unown.nim b/tests/destructor/twidgets_unown.nim index d594ad54c4e92..08b1b5cafa110 100644 --- a/tests/destructor/twidgets_unown.nim +++ b/tests/destructor/twidgets_unown.nim @@ -1,11 +1,9 @@ discard """ cmd: '''nim c --newruntime $file''' output: '''button -clicked! -6 6 alloc/dealloc pairs: 0''' +clicked!''' """ -import system / allocators import system / ansi_c type @@ -71,5 +69,3 @@ proc main = main() -let (a, d) = allocCounters() -discard cprintf("%ld %ld alloc/dealloc pairs: %ld\n", a, d, allocs)