move exception handler to executeOpcodes
This commit is contained in:
parent
039256de6a
commit
fb97d8d0ce
|
@ -231,12 +231,6 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
|
||||||
|
|
||||||
# Wrap the case statement in while true + computed goto
|
# Wrap the case statement in while true + computed goto
|
||||||
result = quote do:
|
result = quote do:
|
||||||
try:
|
|
||||||
let fork = `computation`.getFork
|
|
||||||
if `computation`.execPrecompiles(fork):
|
|
||||||
computation.nextProc()
|
|
||||||
return
|
|
||||||
|
|
||||||
if `computation`.tracingEnabled:
|
if `computation`.tracingEnabled:
|
||||||
`computation`.prepareTracer()
|
`computation`.prepareTracer()
|
||||||
`computation`.instr = `computation`.code.next()
|
`computation`.instr = `computation`.code.next()
|
||||||
|
@ -245,11 +239,6 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
|
||||||
# TODO lots of macro magic here to unravel, with chronicles...
|
# TODO lots of macro magic here to unravel, with chronicles...
|
||||||
# `computation`.logger.log($`computation`.stack & "\n\n", fgGreen)
|
# `computation`.logger.log($`computation`.stack & "\n\n", fgGreen)
|
||||||
`result`
|
`result`
|
||||||
except:
|
|
||||||
let msg = getCurrentExceptionMsg()
|
|
||||||
let errorMsg = "Opcode Dispatch Error msg=" & msg & ", depth=" & $computation.msg.depth
|
|
||||||
`computation`.setError(errorMsg, true)
|
|
||||||
computation.nextProc()
|
|
||||||
|
|
||||||
macro genFrontierDispatch(computation: BaseComputation): untyped =
|
macro genFrontierDispatch(computation: BaseComputation): untyped =
|
||||||
result = opTableToCaseStmt(FrontierOpDispatch, computation)
|
result = opTableToCaseStmt(FrontierOpDispatch, computation)
|
||||||
|
@ -263,10 +252,8 @@ proc frontierVM(computation: BaseComputation) =
|
||||||
proc homesteadVM(computation: BaseComputation) =
|
proc homesteadVM(computation: BaseComputation) =
|
||||||
genHomesteadDispatch(computation)
|
genHomesteadDispatch(computation)
|
||||||
|
|
||||||
proc executeOpcodes(computation: BaseComputation) =
|
proc selectVM(computation: BaseComputation, fork: Fork) =
|
||||||
# TODO: Optimise getting fork and updating opCodeExec only when necessary
|
# TODO: Optimise getting fork and updating opCodeExec only when necessary
|
||||||
let fork = computation.getFork
|
|
||||||
|
|
||||||
case fork
|
case fork
|
||||||
of FkFrontier..FkThawing:
|
of FkFrontier..FkThawing:
|
||||||
computation.frontierVM()
|
computation.frontierVM()
|
||||||
|
@ -274,3 +261,15 @@ proc executeOpcodes(computation: BaseComputation) =
|
||||||
computation.homesteadVM()
|
computation.homesteadVM()
|
||||||
else:
|
else:
|
||||||
raise newException(VMError, "Unknown or not implemented fork: " & $fork)
|
raise newException(VMError, "Unknown or not implemented fork: " & $fork)
|
||||||
|
|
||||||
|
proc executeOpcodes(computation: BaseComputation) =
|
||||||
|
try:
|
||||||
|
let fork = computation.getFork
|
||||||
|
if `computation`.execPrecompiles(fork):
|
||||||
|
computation.nextProc()
|
||||||
|
return
|
||||||
|
computation.selectVM(fork)
|
||||||
|
except:
|
||||||
|
let msg = getCurrentExceptionMsg()
|
||||||
|
computation.setError(&"Opcode Dispatch Error msg={msg}, depth={computation.msg.depth}", true)
|
||||||
|
computation.nextProc()
|
||||||
|
|
Loading…
Reference in New Issue