mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 05:14:14 +00:00
stubbing berlin opcodes
This commit is contained in:
parent
e2cd9b20fa
commit
5a78b8a5a7
@ -535,6 +535,9 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
|
||||
Msize: fixed GasBase,
|
||||
Gas: fixed GasBase,
|
||||
JumpDest: fixed GasJumpDest,
|
||||
BeginSub: fixed GasBase,
|
||||
ReturnSub: fixed GasLow,
|
||||
JumpSub: fixed GasHigh,
|
||||
|
||||
# 60s & 70s: Push Operations
|
||||
Push1: fixed GasVeryLow,
|
||||
|
@ -95,6 +95,9 @@ fill_enum_holes:
|
||||
Msize = 0x59, # Get the size of active memory in bytes.
|
||||
Gas = 0x5a, # Get the amount of available gas, including the corresponding reduction for the cost of this instruction.
|
||||
JumpDest = 0x5b, # Mark a valid destination for jumps. This operation has no effect on machine state during execution.
|
||||
BeginSub = 0x5c, # Marks the entry point to a subroutine
|
||||
ReturnSub = 0x5d, # Returns control to the caller of a subroutine.
|
||||
JumpSub = 0x5e, # Transfers control to a subroutine.
|
||||
|
||||
# 60s & 70s: Push Operations.
|
||||
Push1 = 0x60, # Place 1-byte item on stack.
|
||||
|
@ -542,6 +542,18 @@ op jumpDest, inline = true:
|
||||
## 0x5b, Mark a valid destination for jumps. This operation has no effect on machine state during execution.
|
||||
discard
|
||||
|
||||
op beginSub, inline = true:
|
||||
## 0x5c, Marks the entry point to a subroutine
|
||||
discard
|
||||
|
||||
op returnSub, inline = true:
|
||||
## 0x5d, Returns control to the caller of a subroutine.
|
||||
discard
|
||||
|
||||
op jumpSub, inline = true:
|
||||
## 0x5e, Transfers control to a subroutine.
|
||||
discard
|
||||
|
||||
# ##########################################
|
||||
# 60s & 70s: Push Operations.
|
||||
# 80s: Duplication Operations
|
||||
|
@ -229,6 +229,14 @@ proc genIstanbulJumpTable(ops: array[Op, NimNode]): array[Op, NimNode] {.compile
|
||||
|
||||
let IstanbulOpDispatch {.compileTime.}: array[Op, NimNode] = genIstanbulJumpTable(PetersburgOpDispatch)
|
||||
|
||||
proc genBerlinJumpTable(ops: array[Op, NimNode]): array[Op, NimNode] {.compileTime.} =
|
||||
result = ops
|
||||
result[BeginSub] = newIdentNode "beginSub"
|
||||
result[ReturnSub] = newIdentNode "returnSub"
|
||||
result[JumpSub] = newIdentNode "jumpSub"
|
||||
|
||||
let BerlinOpDispatch {.compileTime.}: array[Op, NimNode] = genBerlinJumpTable(IstanbulOpDispatch)
|
||||
|
||||
proc opTableToCaseStmt(opTable: array[Op, NimNode], c: NimNode): NimNode =
|
||||
|
||||
let instr = quote do: `c`.instr
|
||||
@ -308,6 +316,9 @@ macro genPetersburgDispatch(c: Computation): untyped =
|
||||
macro genIstanbulDispatch(c: Computation): untyped =
|
||||
result = opTableToCaseStmt(IstanbulOpDispatch, c)
|
||||
|
||||
macro genBerlinDispatch(c: Computation): untyped =
|
||||
result = opTableToCaseStmt(BerlinOpDispatch, c)
|
||||
|
||||
proc frontierVM(c: Computation) =
|
||||
genFrontierDispatch(c)
|
||||
|
||||
@ -332,6 +343,9 @@ proc petersburgVM(c: Computation) {.gcsafe.} =
|
||||
proc istanbulVM(c: Computation) {.gcsafe.} =
|
||||
genIstanbulDispatch(c)
|
||||
|
||||
proc berlinVM(c: Computation) {.gcsafe.} =
|
||||
genBerlinDispatch(c)
|
||||
|
||||
proc selectVM(c: Computation, fork: Fork) {.gcsafe.} =
|
||||
# TODO: Optimise getting fork and updating opCodeExec only when necessary
|
||||
case fork
|
||||
@ -349,8 +363,10 @@ proc selectVM(c: Computation, fork: Fork) {.gcsafe.} =
|
||||
c.constantinopleVM()
|
||||
of FkPetersburg:
|
||||
c.petersburgVM()
|
||||
else:
|
||||
of FkIstanbul:
|
||||
c.istanbulVM()
|
||||
else:
|
||||
c.berlinVM()
|
||||
|
||||
proc executeOpcodes(c: Computation) =
|
||||
let fork = c.fork
|
||||
|
Loading…
x
Reference in New Issue
Block a user