nimbus-eth1/nimbus/evm/interpreter
Jacek Sieka 8857fccb44
create per-fork opcode dispatcher (#2579)
In the current VM opcode dispatcher, a two-level case statement is
generated that first matches the opcode and then uses another nested
case statement to select the actual implementation based on which fork
it is, causing the dispatcher to grow by `O(opcodes) * O(forks)`.

The fork does not change between instructions causing significant
inefficiency for this approach - not only because it repeats the fork
lookup but also because of code size bloat and missed optimizations.

A second source of inefficiency in dispatching is the tracer code which
in the vast majority of cases is disabled but nevertheless sees multiple
conditionals being evaluated for each instruction only to remain
disabled throughout exeuction.

This PR rewrites the opcode dispatcher macro to generate a separate
dispatcher for each fork and tracer setting and goes on to pick the
right one at the start of the computation.

This has many advantages:

* much smaller dispatcher
* easier to compile
* better inlining
* fewer pointlessly repeated instruction
* simplified macro (!)
* slow "low-compiler-memory" dispatcher code can be removed

Net block import improvement at about 4-6% depending on the contract -
synthetic EVM benchmnarks would show an even better result most likely.
2024-08-28 10:20:36 +02:00
..
op_handlers EVM cosmetic changes, one less indirect access of VmCpt (#2503) 2024-07-19 08:44:01 +07:00
utils Bump nim-eth, nim-web3, nimbus-eth2 (#2344) 2024-06-14 14:31:08 +07:00
evmc_gas_costs.nim Convert GasInt to uint64, bump nim-eth and nimbus-eth2 (#2461) 2024-07-07 06:52:11 +00:00
forks_list.md saner source code grouping 2022-12-02 13:51:42 +07:00
forks_list.png saner source code grouping 2022-12-02 13:51:42 +07:00
gas_costs.nim create per-fork opcode dispatcher (#2579) 2024-08-28 10:20:36 +02:00
gas_meter.nim create per-fork opcode dispatcher (#2579) 2024-08-28 10:20:36 +02:00
op_codes.nim Bump nim-evmc to 86d22a026b0aa07c07b3afd7d91ca475e0eae12a (#2113) 2024-03-28 13:47:02 +07:00
op_dispatcher.nim create per-fork opcode dispatcher (#2579) 2024-08-28 10:20:36 +02:00
op_handlers.nim create per-fork opcode dispatcher (#2579) 2024-08-28 10:20:36 +02:00