nimbus-eth1/nimbus/evm
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
..
interpreter create per-fork opcode dispatcher (#2579) 2024-08-28 10:20:36 +02:00
tracer Convert GasInt to uint64, bump nim-eth and nimbus-eth2 (#2461) 2024-07-07 06:52:11 +00:00
blake2b_f.nim Add check copyright year linter to CI 2023-11-01 10:41:20 +07:00
blscurve.nim Bump nim-blscurve for gcc-14 compatibility (#2365) 2024-06-15 17:34:07 +00:00
code_bytes.nim Fix CodeBytes: invalidPositions out of bound crash (#2523) 2024-07-25 19:23:53 +07:00
code_stream.nim create per-fork opcode dispatcher (#2579) 2024-08-28 10:20:36 +02:00
computation.nim create per-fork opcode dispatcher (#2579) 2024-08-28 10:20:36 +02:00
evm_errors.nim Remove exceptions from EVM (#2314) 2024-06-07 15:24:32 +07:00
evmc_api.nim Bump nim-eth, nim-web3, nimbus-eth2 (#2344) 2024-06-14 14:31:08 +07:00
evmc_helpers.nim Add check copyright year linter to CI 2023-11-01 10:41:20 +07:00
internals.nim Separate evmc gasCosts and nim-evm gasCosts (#2454) 2024-07-05 07:00:03 +07:00
interpreter_dispatch.nim create per-fork opcode dispatcher (#2579) 2024-08-28 10:20:36 +02:00
memory.nim odds and ends (#2481) 2024-07-13 20:42:49 +02:00
message.nim EVM embrace more EVMC types 2023-08-28 21:36:23 +07:00
modexp.nim Add style check to config.nims and fix styles in source code (#2038) 2024-02-20 10:07:38 +07:00
nimdoc.cfg Add check copyright year linter to CI 2023-11-01 10:41:20 +07:00
precompiles.nim EVM: use assign2 whenever possible (#2499) 2024-07-17 20:48:50 +07:00
stack.nim Hash bump 2024-08-08 07:46:35 +02:00
state.nim Don't write slot hashes on import (#2564) 2024-08-16 08:22:51 +02:00
state_transactions.nim avoid allocations for slot storage (#2455) 2024-07-04 23:48:45 +00:00
types.nim odds and ends (#2481) 2024-07-13 20:42:49 +02:00