mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-25 10:25:32 +00:00
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 =
|
||||
|
||||
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...
|
||||
|
@ -65,6 +65,8 @@ type
|
||||
forkOverride*: Option[Fork]
|
||||
logEntries*: seq[Log]
|
||||
dbsnapshot*: Snapshot
|
||||
instr*: Op
|
||||
opIndex*: int
|
||||
|
||||
Error* = ref object
|
||||
info*: string
|
||||
|
Loading…
x
Reference in New Issue
Block a user