reduce stack usage

This commit is contained in:
andri lim 2019-03-23 20:44:12 +07:00
parent 527891cdb8
commit d9a9459d95
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 10 additions and 10 deletions

View File

@ -186,7 +186,7 @@ let HomesteadOpDispatch {.compileTime.}: array[Op, NimNode] = genHomesteadJumpTa
proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNode =
let instr = genSym(nskVar)
let instr = quote do: `computation`.instr
result = nnkCaseStmt.newTree(instr)
# Add a branch for each (opcode, proc) pair
@ -199,28 +199,26 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
trace "op: Stop"
if not `computation`.code.atEnd() and `computation`.tracingEnabled:
# we only trace `REAL STOP` and ignore `FAKE STOP`
let lastOpIndex = `computation`.traceOpCodeStarted(`asOp`)
`computation`.traceOpCodeEnded(`asOp`, lastOpIndex)
`computation`.opIndex = `computation`.traceOpCodeStarted(`asOp`)
`computation`.traceOpCodeEnded(`asOp`, `computation`.opIndex)
break
else:
if BaseGasCosts[op].kind == GckFixed:
quote do:
var lastOpIndex: int
if `computation`.tracingEnabled:
lastOpIndex = `computation`.traceOpCodeStarted(`asOp`)
`computation`.opIndex = `computation`.traceOpCodeStarted(`asOp`)
`computation`.gasMeter.consumeGas(`computation`.gasCosts[`asOp`].cost, reason = $`asOp`)
`opImpl`(`computation`)
if `computation`.tracingEnabled:
`computation`.traceOpCodeEnded(`asOp`, lastOpIndex)
`computation`.traceOpCodeEnded(`asOp`, `computation`.opIndex)
`instr` = `computation`.code.next()
else:
quote do:
var lastOpIndex: int
if `computation`.tracingEnabled:
lastOpIndex = `computation`.traceOpCodeStarted(`asOp`)
`computation`.opIndex = `computation`.traceOpCodeStarted(`asOp`)
`opImpl`(`computation`)
if `computation`.tracingEnabled:
`computation`.traceOpCodeEnded(`asOp`, lastOpIndex)
`computation`.traceOpCodeEnded(`asOp`, `computation`.opIndex)
when `asOp` in {Return, Revert, SelfDestruct}:
break
else:
@ -235,7 +233,7 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
result = quote do:
if `computation`.tracingEnabled:
`computation`.prepareTracer()
var `instr` = `computation`.code.next()
`computation`.instr = `computation`.code.next()
while true:
{.computedGoto.}
# TODO lots of macro magic here to unravel, with chronicles...

View File

@ -65,6 +65,8 @@ type
forkOverride*: Option[Fork]
logEntries*: seq[Log]
dbsnapshot*: Snapshot
instr*: Op
opIndex*: int
Error* = ref object
info*: string