Clean up GCs a bit
This commit is contained in:
parent
f7e35542e1
commit
573fa9b891
2 changed files with 13 additions and 6 deletions
|
|
@ -463,6 +463,7 @@ proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap): pointer =
|
||||||
|
|
||||||
proc newObjNoInit(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
proc newObjNoInit(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
||||||
result = rawNewObj(typ, size, gch)
|
result = rawNewObj(typ, size, gch)
|
||||||
|
when defined(memProfiler): nimProfile(size)
|
||||||
|
|
||||||
proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
||||||
result = rawNewObj(typ, size, gch)
|
result = rawNewObj(typ, size, gch)
|
||||||
|
|
|
||||||
|
|
@ -634,8 +634,6 @@ proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap, rc1 = false): pointer
|
||||||
gcTrace(res, csAllocated)
|
gcTrace(res, csAllocated)
|
||||||
release(gch)
|
release(gch)
|
||||||
result = cellToUsr(res)
|
result = cellToUsr(res)
|
||||||
zeroMem(result, size)
|
|
||||||
when defined(memProfiler): nimProfile(size)
|
|
||||||
sysAssert(allocInv(gch.region), "rawNewObj end")
|
sysAssert(allocInv(gch.region), "rawNewObj end")
|
||||||
|
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
@ -670,23 +668,31 @@ template trimAt(roots: var TCellSeq, at: int): stmt =
|
||||||
proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
||||||
setStackTop(gch)
|
setStackTop(gch)
|
||||||
result = rawNewObj(typ, size, gch, false)
|
result = rawNewObj(typ, size, gch, false)
|
||||||
|
zeroMem(result, size)
|
||||||
|
when defined(memProfiler): nimProfile(size)
|
||||||
|
|
||||||
|
proc newObjNoInit(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
||||||
|
setStackTop(gch)
|
||||||
|
result = rawNewObj(typ, size, gch, false)
|
||||||
|
when defined(memProfiler): nimProfile(size)
|
||||||
|
|
||||||
proc newSeq(typ: PNimType, len: int): pointer {.compilerRtl.} =
|
proc newSeq(typ: PNimType, len: int): pointer {.compilerRtl.} =
|
||||||
setStackTop(gch)
|
setStackTop(gch)
|
||||||
# `rawNewObj` already uses locks, so no need for them here.
|
# `newObj` already uses locks, so no need for them here.
|
||||||
let size = addInt(mulInt(len, typ.base.size), GenericSeqSize)
|
let size = addInt(mulInt(len, typ.base.size), GenericSeqSize)
|
||||||
result = rawNewObj(typ, size, gch, false)
|
result = newObj(typ, size)
|
||||||
cast[PGenericSeq](result).len = len
|
cast[PGenericSeq](result).len = len
|
||||||
cast[PGenericSeq](result).reserved = len
|
cast[PGenericSeq](result).reserved = len
|
||||||
|
|
||||||
proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
||||||
setStackTop(gch)
|
setStackTop(gch)
|
||||||
result = rawNewObj(typ, size, gch, true)
|
result = rawNewObj(typ, size, gch, true)
|
||||||
|
when defined(memProfiler): nimProfile(size)
|
||||||
|
|
||||||
proc newSeqRC1(typ: PNimType, len: int): pointer {.compilerRtl.} =
|
proc newSeqRC1(typ: PNimType, len: int): pointer {.compilerRtl.} =
|
||||||
setStackTop(gch)
|
setStackTop(gch)
|
||||||
let size = addInt(mulInt(len, typ.base.size), GenericSeqSize)
|
let size = addInt(mulInt(len, typ.base.size), GenericSeqSize)
|
||||||
result = rawNewObj(typ, size, gch, true)
|
result = newObjRC1(typ, size)
|
||||||
cast[PGenericSeq](result).len = len
|
cast[PGenericSeq](result).len = len
|
||||||
cast[PGenericSeq](result).reserved = len
|
cast[PGenericSeq](result).reserved = len
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue