Andreas Rumpf 2020-11-26 19:05:21 +01:00 • committed by GitHub
commit cf516713d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 6 deletions

View file

@ -249,13 +249,15 @@ proc openArrayLoc(p: BProc, formalType: PType, n: PNode): Rope =
else: internalError(p.config, "openArrayLoc: " & typeToString(a.t)) else: internalError(p.config, "openArrayLoc: " & typeToString(a.t))
proc withTmpIfNeeded(p: BProc, a: TLoc, needsTmp: bool): TLoc = proc withTmpIfNeeded(p: BProc, a: TLoc, needsTmp: bool): TLoc =
if needsTmp and a.lode.typ != nil: # Bug https://github.com/status-im/nimbus-eth2/issues/1549
var tmp: TLoc # Aliasing is preferred over stack overflows.
getTemp(p, a.lode.typ, tmp, needsInit=false) # Also don't regress for non ARC-builds, too risky.
genAssignment(p, tmp, a, {}) if needsTmp and a.lode.typ != nil and p.config.selectedGC in {gcArc, gcOrc} and
tmp getSize(p.config, a.lode.typ) < 1024:
getTemp(p, a.lode.typ, result, needsInit=false)
genAssignment(p, result, a, {})
else: else:
a result = a
proc genArgStringToCString(p: BProc, n: PNode, needsTmp: bool): Rope {.inline.} = proc genArgStringToCString(p: BProc, n: PNode, needsTmp: bool): Rope {.inline.} =
var a: TLoc var a: TLoc

View file

@ -471,6 +471,14 @@ proc getTemp(p: BProc, t: PType, result: var TLoc; needsInit=false) =
result.storage = OnStack result.storage = OnStack
result.flags = {} result.flags = {}
constructLoc(p, result, not needsInit) constructLoc(p, result, not needsInit)
when false:
# XXX Introduce a compiler switch in order to detect these easily.
if getSize(p.config, t) > 1024 * 1024:
if p.prc != nil:
echo "ENORMOUS TEMPORARY! ", p.config $ p.prc.info
else:
echo "ENORMOUS TEMPORARY! ", p.config $ p.lastLineInfo
writeStackTrace()
proc getTempCpp(p: BProc, t: PType, result: var TLoc; value: Rope) = proc getTempCpp(p: BProc, t: PType, result: var TLoc; value: Rope) =
inc(p.labels) inc(p.labels)

View file

@ -16,6 +16,7 @@ discard """
2,2 2,2
1,2 1,2
''' '''
cmd: "nim c --gc:orc $file"
""" """
template test = template test =