diff options
author | def <dennis@felsin9.de> | 2015-03-10 15:31:55 +0100 |
---|---|---|
committer | def <dennis@felsin9.de> | 2015-03-10 15:31:55 +0100 |
commit | 573fa9b8919d5ea5bcae8aaf7b7295c42526b6e4 (patch) | |
tree | 5cb3364638d3be1f6c05dfcfbe14dab2e9d689e4 | |
parent | f7e35542e1e9b67c89394a639ea9a5e3e0010fb1 (diff) | |
download | Nim-573fa9b8919d5ea5bcae8aaf7b7295c42526b6e4.tar.gz |
Clean up GCs a bit
-rw-r--r-- | lib/system/gc.nim | 1 | ||||
-rw-r--r-- | lib/system/gc2.nim | 18 |
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 42da2ed89..c4374d00c 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -463,6 +463,7 @@ proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap): pointer = proc newObjNoInit(typ: PNimType, size: int): pointer {.compilerRtl.} = result = rawNewObj(typ, size, gch) + when defined(memProfiler): nimProfile(size) proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} = result = rawNewObj(typ, size, gch) diff --git a/lib/system/gc2.nim b/lib/system/gc2.nim index b8a61d627..4e3dee51c 100644 --- a/lib/system/gc2.nim +++ b/lib/system/gc2.nim @@ -634,8 +634,6 @@ proc rawNewObj(typ: PNimType, size: int, gch: var TGcHeap, rc1 = false): pointer gcTrace(res, csAllocated) release(gch) result = cellToUsr(res) - zeroMem(result, size) - when defined(memProfiler): nimProfile(size) sysAssert(allocInv(gch.region), "rawNewObj end") {.pop.} @@ -670,23 +668,31 @@ template trimAt(roots: var TCellSeq, at: int): stmt = proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} = setStackTop(gch) 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.} = 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) - result = rawNewObj(typ, size, gch, false) + result = newObj(typ, size) cast[PGenericSeq](result).len = len cast[PGenericSeq](result).reserved = len proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl.} = setStackTop(gch) result = rawNewObj(typ, size, gch, true) + when defined(memProfiler): nimProfile(size) proc newSeqRC1(typ: PNimType, len: int): pointer {.compilerRtl.} = setStackTop(gch) 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).reserved = len |