separate tangerine whistle and spurious dragon opcode dispatcher
This commit is contained in:
parent
6f51cf9103
commit
7eafd75d17
|
@ -184,6 +184,18 @@ proc genHomesteadJumpTable(ops: array[Op, NimNode]): array[Op, NimNode] {.compil
|
||||||
|
|
||||||
let HomesteadOpDispatch {.compileTime.}: array[Op, NimNode] = genHomesteadJumpTable(FrontierOpDispatch)
|
let HomesteadOpDispatch {.compileTime.}: array[Op, NimNode] = genHomesteadJumpTable(FrontierOpDispatch)
|
||||||
|
|
||||||
|
proc genTangerineJumpTable(ops: array[Op, NimNode]): array[Op, NimNode] {.compileTime.} =
|
||||||
|
result = ops
|
||||||
|
result[SelfDestruct] = newIdentNode "selfDestructEIP150"
|
||||||
|
|
||||||
|
let TangerineOpDispatch {.compileTime.}: array[Op, NimNode] = genTangerineJumpTable(HomesteadOpDispatch)
|
||||||
|
|
||||||
|
proc genSpuriousJumpTable(ops: array[Op, NimNode]): array[Op, NimNode] {.compileTime.} =
|
||||||
|
result = ops
|
||||||
|
result[SelfDestruct] = newIdentNode "selfDestructEIP161"
|
||||||
|
|
||||||
|
let SpuriousOpDispatch {.compileTime.}: array[Op, NimNode] = genSpuriousJumpTable(TangerineOpDispatch)
|
||||||
|
|
||||||
proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNode =
|
proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNode =
|
||||||
|
|
||||||
let instr = quote do: `computation`.instr
|
let instr = quote do: `computation`.instr
|
||||||
|
@ -245,19 +257,35 @@ macro genFrontierDispatch(computation: BaseComputation): untyped =
|
||||||
macro genHomesteadDispatch(computation: BaseComputation): untyped =
|
macro genHomesteadDispatch(computation: BaseComputation): untyped =
|
||||||
result = opTableToCaseStmt(HomesteadOpDispatch, computation)
|
result = opTableToCaseStmt(HomesteadOpDispatch, computation)
|
||||||
|
|
||||||
|
macro genTangerineDispatch(computation: BaseComputation): untyped =
|
||||||
|
result = opTableToCaseStmt(TangerineOpDispatch, computation)
|
||||||
|
|
||||||
|
macro genSpuriousDispatch(computation: BaseComputation): untyped =
|
||||||
|
result = opTableToCaseStmt(SpuriousOpDispatch, computation)
|
||||||
|
|
||||||
proc frontierVM(computation: BaseComputation) =
|
proc frontierVM(computation: BaseComputation) =
|
||||||
genFrontierDispatch(computation)
|
genFrontierDispatch(computation)
|
||||||
|
|
||||||
proc homesteadVM(computation: BaseComputation) =
|
proc homesteadVM(computation: BaseComputation) =
|
||||||
genHomesteadDispatch(computation)
|
genHomesteadDispatch(computation)
|
||||||
|
|
||||||
|
proc tangerineVM(computation: BaseComputation) =
|
||||||
|
genTangerineDispatch(computation)
|
||||||
|
|
||||||
|
proc spuriousVM(computation: BaseComputation) =
|
||||||
|
genSpuriousDispatch(computation)
|
||||||
|
|
||||||
proc selectVM(computation: BaseComputation, fork: Fork) =
|
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
|
||||||
case fork
|
case fork
|
||||||
of FkFrontier..FkThawing:
|
of FkFrontier..FkThawing:
|
||||||
computation.frontierVM()
|
computation.frontierVM()
|
||||||
of FkHomestead..FkSpurious:
|
of FkHomestead..FkDao:
|
||||||
computation.homesteadVM()
|
computation.homesteadVM()
|
||||||
|
of FkTangerine:
|
||||||
|
computation.tangerineVM()
|
||||||
|
of FkSpurious:
|
||||||
|
computation.spuriousVM()
|
||||||
else:
|
else:
|
||||||
raise newException(VMError, "Unknown or not implemented fork: " & $fork)
|
raise newException(VMError, "Unknown or not implemented fork: " & $fork)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue