reduce stack usage
This commit is contained in:
parent
527891cdb8
commit
d9a9459d95
|
@ -186,7 +186,7 @@ let HomesteadOpDispatch {.compileTime.}: array[Op, NimNode] = genHomesteadJumpTa
|
||||||
|
|
||||||
proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNode =
|
proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNode =
|
||||||
|
|
||||||
let instr = genSym(nskVar)
|
let instr = quote do: `computation`.instr
|
||||||
result = nnkCaseStmt.newTree(instr)
|
result = nnkCaseStmt.newTree(instr)
|
||||||
|
|
||||||
# Add a branch for each (opcode, proc) pair
|
# Add a branch for each (opcode, proc) pair
|
||||||
|
@ -199,28 +199,26 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
|
||||||
trace "op: Stop"
|
trace "op: Stop"
|
||||||
if not `computation`.code.atEnd() and `computation`.tracingEnabled:
|
if not `computation`.code.atEnd() and `computation`.tracingEnabled:
|
||||||
# we only trace `REAL STOP` and ignore `FAKE STOP`
|
# we only trace `REAL STOP` and ignore `FAKE STOP`
|
||||||
let lastOpIndex = `computation`.traceOpCodeStarted(`asOp`)
|
`computation`.opIndex = `computation`.traceOpCodeStarted(`asOp`)
|
||||||
`computation`.traceOpCodeEnded(`asOp`, lastOpIndex)
|
`computation`.traceOpCodeEnded(`asOp`, `computation`.opIndex)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if BaseGasCosts[op].kind == GckFixed:
|
if BaseGasCosts[op].kind == GckFixed:
|
||||||
quote do:
|
quote do:
|
||||||
var lastOpIndex: int
|
|
||||||
if `computation`.tracingEnabled:
|
if `computation`.tracingEnabled:
|
||||||
lastOpIndex = `computation`.traceOpCodeStarted(`asOp`)
|
`computation`.opIndex = `computation`.traceOpCodeStarted(`asOp`)
|
||||||
`computation`.gasMeter.consumeGas(`computation`.gasCosts[`asOp`].cost, reason = $`asOp`)
|
`computation`.gasMeter.consumeGas(`computation`.gasCosts[`asOp`].cost, reason = $`asOp`)
|
||||||
`opImpl`(`computation`)
|
`opImpl`(`computation`)
|
||||||
if `computation`.tracingEnabled:
|
if `computation`.tracingEnabled:
|
||||||
`computation`.traceOpCodeEnded(`asOp`, lastOpIndex)
|
`computation`.traceOpCodeEnded(`asOp`, `computation`.opIndex)
|
||||||
`instr` = `computation`.code.next()
|
`instr` = `computation`.code.next()
|
||||||
else:
|
else:
|
||||||
quote do:
|
quote do:
|
||||||
var lastOpIndex: int
|
|
||||||
if `computation`.tracingEnabled:
|
if `computation`.tracingEnabled:
|
||||||
lastOpIndex = `computation`.traceOpCodeStarted(`asOp`)
|
`computation`.opIndex = `computation`.traceOpCodeStarted(`asOp`)
|
||||||
`opImpl`(`computation`)
|
`opImpl`(`computation`)
|
||||||
if `computation`.tracingEnabled:
|
if `computation`.tracingEnabled:
|
||||||
`computation`.traceOpCodeEnded(`asOp`, lastOpIndex)
|
`computation`.traceOpCodeEnded(`asOp`, `computation`.opIndex)
|
||||||
when `asOp` in {Return, Revert, SelfDestruct}:
|
when `asOp` in {Return, Revert, SelfDestruct}:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -235,7 +233,7 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
|
||||||
result = quote do:
|
result = quote do:
|
||||||
if `computation`.tracingEnabled:
|
if `computation`.tracingEnabled:
|
||||||
`computation`.prepareTracer()
|
`computation`.prepareTracer()
|
||||||
var `instr` = `computation`.code.next()
|
`computation`.instr = `computation`.code.next()
|
||||||
while true:
|
while true:
|
||||||
{.computedGoto.}
|
{.computedGoto.}
|
||||||
# TODO lots of macro magic here to unravel, with chronicles...
|
# TODO lots of macro magic here to unravel, with chronicles...
|
||||||
|
|
|
@ -65,6 +65,8 @@ type
|
||||||
forkOverride*: Option[Fork]
|
forkOverride*: Option[Fork]
|
||||||
logEntries*: seq[Log]
|
logEntries*: seq[Log]
|
||||||
dbsnapshot*: Snapshot
|
dbsnapshot*: Snapshot
|
||||||
|
instr*: Op
|
||||||
|
opIndex*: int
|
||||||
|
|
||||||
Error* = ref object
|
Error* = ref object
|
||||||
info*: string
|
info*: string
|
||||||
|
|
Loading…
Reference in New Issue