ARC: solves phase ordering problems (#12654)

This commit is contained in:
Andreas Rumpf 2019-11-14 23:19:18 +01:00 • committed by GitHub
commit a14abc5708
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 65 additions and 62 deletions

View file

@ -1005,13 +1005,15 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
decodeB(rkNode)
let a = regs[rb].node
if a.kind == nkSym:
regs[ra].node = if a.sym.ast.isNil: newNode(nkNilLit)
else:
let ast = a.sym.ast.shallowCopy
for i in 0..<a.sym.ast.len:
ast[i] = a.sym.ast[i]
ast[bodyPos] = transformBody(c.graph, a.sym)
ast.copyTree()
regs[ra].node =
if a.sym.ast.isNil:
newNode(nkNilLit)
else:
let ast = a.sym.ast.shallowCopy
for i in 0..<a.sym.ast.len:
ast[i] = a.sym.ast[i]
ast[bodyPos] = transformBody(c.graph, a.sym, cache=true)
ast.copyTree()
of opcSymOwner:
decodeB(rkNode)
let a = regs[rb].node
@ -1983,7 +1985,7 @@ proc execProc*(c: PCtx; sym: PSym; args: openArray[PNode]): PNode =
"NimScript: attempt to call non-routine: " & sym.name.s)
proc evalStmt*(c: PCtx, n: PNode) =
let n = transformExpr(c.graph, c.module, n, noDestructors = true)
let n = transformExpr(c.graph, c.module, n)
let start = genStmt(c, n)
# execute new instructions; this redundant opcEof check saves us lots
# of allocations in 'execute':
@ -1991,7 +1993,7 @@ proc evalStmt*(c: PCtx, n: PNode) =
discard execute(c, start)
proc evalExpr*(c: PCtx, n: PNode): PNode =
let n = transformExpr(c.graph, c.module, n, noDestructors = true)
let n = transformExpr(c.graph, c.module, n)
let start = genExpr(c, n)
assert c.code[start].opcode != opcEof
result = execute(c, start)
@ -2037,7 +2039,7 @@ proc evalConstExprAux(module: PSym;
g: ModuleGraph; prc: PSym, n: PNode,
mode: TEvalMode): PNode =
if g.config.errorCounter > 0: return n
let n = transformExpr(g, module, n, noDestructors = true)
let n = transformExpr(g, module, n)
setupGlobalCtx(module, g)
var c = PCtx g.vm
let oldMode = c.mode