Wire up MulOperationOptimized and SubOperationOptimized to EVM #10030
Wire up MulOperationOptimized and SubOperationOptimized to EVM #10030siladu merged 5 commits intobesu-eth:mainfrom
Conversation
… enableOptimizedOpcodes flag Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
There was a problem hiding this comment.
Pull request overview
Wires previously-existing optimized MUL and SUB opcode implementations into the EVM interpreter behind the enableOptimizedOpcodes flag (default-enabled per description), and adds JMH benchmarks for the optimized variants.
Changes:
- Route opcodes
0x02 (MUL)and0x03 (SUB)to optimized implementations whenenableOptimizedOpcodesis enabled - Fix constructor naming and success result constant usage in
MulOperationOptimized - Add JMH benchmarks for
MulOperationOptimizedandSubOperationOptimized
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| evm/src/main/java/org/hyperledger/besu/evm/operation/MulOperationOptimized.java | Fixes class internals to align with MUL semantics (constructor + success result). |
| evm/src/main/java/org/hyperledger/besu/evm/EVM.java | Routes MUL/SUB opcodes to optimized implementations behind the config flag. |
| ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/SubOperationOptimizedBenchmark.java | Adds benchmark harness for optimized SUB execution. |
| ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/MulOperationOptimizedBenchmark.java | Adds benchmark harness for optimized MUL execution. |
| case 0x02 -> | ||
| evmConfiguration.enableOptimizedOpcodes() | ||
| ? MulOperationOptimized.staticOperation(frame) | ||
| : MulOperation.staticOperation(frame); | ||
| case 0x03 -> | ||
| evmConfiguration.enableOptimizedOpcodes() | ||
| ? SubOperationOptimized.staticOperation(frame) | ||
| : SubOperation.staticOperation(frame); |
There was a problem hiding this comment.
runToHalt is on a hot path, and these new cases add more repeated calls to evmConfiguration.enableOptimizedOpcodes() during opcode dispatch. Consider caching the flag once (e.g., a local final boolean optimized = evmConfiguration.enableOptimizedOpcodes();) and using that in the switch cases to avoid repeated virtual/interface calls during interpretation.
...behind enableOptimizedOpcodes flag, enabled by default.
Noticed these were in the codebase since 57a7e7d and had prop tests in UInt256 but just weren't wired up.
macbook:
TODO: