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
This commit is contained in:
parent
f500895efe
commit
b68eb1cad0
21 changed files with 275 additions and 312 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue