mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
fixes #19728
don't zero-filling memory for "trivial types" without destructor in
refc. I tested locally with internal apis.
(cherry picked from commit b421d0f8ee)
This commit is contained in:
@@ -1925,6 +1925,13 @@ proc genArrayLen(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||
else: putIntoDest(p, d, e, rope(lengthOrd(p.config, typ)))
|
||||
else: internalError(p.config, e.info, "genArrayLen()")
|
||||
|
||||
proc isTrivialTypesToSnippet(t: PType): Rope =
|
||||
if containsGarbageCollectedRef(t) or
|
||||
hasDestructor(t):
|
||||
result = rope"NIM_FALSE"
|
||||
else:
|
||||
result = rope"NIM_TRUE"
|
||||
|
||||
proc genSetLengthSeq(p: BProc, e: PNode, d: var TLoc) =
|
||||
if optSeqDestructors in p.config.globalOptions:
|
||||
e[1] = makeAddr(e[1], p.module.idgen)
|
||||
@@ -1945,10 +1952,11 @@ proc genSetLengthSeq(p: BProc, e: PNode, d: var TLoc) =
|
||||
genTypeInfoV1(p.module, t.skipTypes(abstractInst), e.info)])
|
||||
|
||||
else:
|
||||
const setLenPattern = "($3) #setLengthSeqV2($1, $4, $2)"
|
||||
const setLenPattern = "($3) #setLengthSeqV2($1, $4, $2, $5)"
|
||||
call.snippet = ropecg(p.module, setLenPattern, [
|
||||
rdLoc(a), rdLoc(b), getTypeDesc(p.module, t),
|
||||
genTypeInfoV1(p.module, t.skipTypes(abstractInst), e.info)])
|
||||
genTypeInfoV1(p.module, t.skipTypes(abstractInst), e.info),
|
||||
isTrivialTypesToSnippet(t.skipTypes(abstractInst)[0])])
|
||||
|
||||
genAssignment(p, a, call, {})
|
||||
gcUsage(p.config, e)
|
||||
|
||||
Reference in New Issue
Block a user