diff options
author | Ico Doornekamp <ico@pruts.nl> | 2020-01-23 14:25:22 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2020-01-23 14:25:22 +0100 |
commit | b68eb1cad0dc13d497ae0e620dd2178a6367644c (patch) | |
tree | 4456c09a2cf5a964cc1d6cb2cae16dabfa0ff2a8 /compiler/ccgexprs.nim | |
parent | f500895efe84525c131beadd2e83b30caa6674a3 (diff) | |
download | Nim-b68eb1cad0dc13d497ae0e620dd2178a6367644c.tar.gz |
Removed lib/system/allocators.nim. seqs_v2 and strs_v2 now uses allocShared0. (#13190)
* Cleanup, remove lib/system/allocators.nim. seqs_v2 and strs_v2 now use allocShared0 by default. * Fixed -d:useMalloc allocShared / reallocShared / deallocShared. These now use the alloc/dealloc/realloc implementation that also takes care of zeroing memory at realloc. * Removed debug printfs * Removed unpairedEnvAllocs() from tests/destructor/tnewruntime_misc * More mmdisp cleanups. The shared allocators do not need to zero memory or throw since the regular ones already do that * Introduced realloc0 and reallocShared0, these procs are now used by strs_v2 and seqs_v2. This also allowed the -d:useMalloc allocator to drop the extra header with allocation length. * Moved strs_v2/seqs_v2 'allocated' flag into 'cap' field * Added 'getAllocStats()' to get low level alloc/dealloc counters. Enable with -d:allocStats * *allocShared implementations for boehm and go allocators now depend on the proper *allocImpl procs
Diffstat (limited to 'compiler/ccgexprs.nim')
-rw-r--r-- | compiler/ccgexprs.nim | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index d718eab42..c23b64257 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->cap & NIM_STRLIT_FLAG)) {$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->cap & NIM_STRLIT_FLAG)) {$n" & + " #deallocShared($1.p);$n" & " $1.p = NIM_NIL; }$n", [rdLoc(a), getTypeDesc(p.module, t.lastSon)]) else: discard "nothing to do" @@ -2917,8 +2917,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; $1 data[$2];$n" & + "} $3 = {$2 | NIM_STRLIT_FLAG, $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] |