Bletner/runtime header refactor#2050
Conversation
aac2e28 to
2e275f2
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the VM runtime code by moving function implementations from header files to separate compilation units. The primary goal is to reduce header bloat and improve compilation times by separating interface declarations from implementations.
Changes:
- Moved template and inline function implementations from
.hppto new.cppfiles for storage, selfdestruct, memory, log, keccak, environment, data, create, and call modules - Renamed top-level functions
monad::createandmonad::calltomonad::execute_create_messageandmonad::execute_call_messagefor clarity - Refactored anonymous namespace usage in evm.cpp from macro-based to explicit namespace syntax
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| category/vm/runtime/storage.hpp | Converted inline implementations to forward declarations |
| category/vm/runtime/storage.cpp | Added implementations with EXPLICIT_TRAITS for template instantiation |
| category/vm/runtime/selfdestruct.hpp | Converted inline implementation to forward declaration |
| category/vm/runtime/selfdestruct.cpp | Added implementation with EXPLICIT_TRAITS |
| category/vm/runtime/memory.hpp | Converted inline implementations to forward declarations |
| category/vm/runtime/memory.cpp | Added implementations with EXPLICIT_TRAITS |
| category/vm/runtime/log.hpp | Converted inline implementations to forward declarations |
| category/vm/runtime/log.cpp | Added implementations with EXPLICIT_TRAITS |
| category/vm/runtime/keccak.hpp | Moved implementation to .cpp and removed ethash include from header |
| category/vm/runtime/keccak.cpp | Added implementation with ethash include |
| category/vm/runtime/environment.hpp | Converted inline implementations to forward declarations |
| category/vm/runtime/environment.cpp | Added implementations for blockhash, selfbalance, and blobhash |
| category/vm/runtime/data.hpp | Converted inline implementations to forward declarations |
| category/vm/runtime/data.cpp | Added implementations with EXPLICIT_TRAITS for templated functions |
| category/vm/runtime/create.hpp | Converted inline implementations to forward declarations |
| category/vm/runtime/create.cpp | Added implementations with EXPLICIT_TRAITS |
| category/vm/runtime/call.hpp | Converted inline implementations to forward declarations |
| category/vm/runtime/call.cpp | Added implementations with EXPLICIT_TRAITS |
| category/vm/runtime/CMakeLists.txt | Added all new .cpp files to build system |
| test/vm/unit/runtime/fixture.cpp | Updated includes, added ethash/keccak.hpp and span |
| category/execution/ethereum/evm.hpp | Renamed create/call to execute_create_message/execute_call_message |
| category/execution/ethereum/evm.cpp | Updated function names and refactored anonymous namespace syntax |
| category/execution/ethereum/evmc_host.hpp | Updated function calls to use new names |
| category/execution/ethereum/execute_transaction.cpp | Updated function calls to use new names |
| category/execution/ethereum/evm_test.cpp | Updated all test calls to use new function names |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2e275f2 to
8142db5
Compare
andreaslyn
left a comment
There was a problem hiding this comment.
Performance of some of these runtime functions is potentially negatively affected by not getting inlined. Can you find a representative set of micro benchmarks and report the before and after numbers?
f06849c to
47b9dcf
Compare
66b7751 to
1ce8637
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Refactor category/vm/runtime to separate interface from implementation while maintaining performance for hot-path functions and minimizing header dependencies. Implementation separation: - Create 7 new .cpp files (call, data, create, log, environment, selfdestruct, storage) - Move large function implementations from .hpp to .cpp files - Apply EXPLICIT_TRAITS macro for template instantiation across EVM and Monad traits - Update CMakeLists.txt to build new .cpp files Performance optimizations: - Keep critical hot-path functions as inline in headers: * Memory operations: mload, mstore, mstore8, mcopy * Transient storage: tload, tstore * Hashing: sha3 * Data access: calldataload * Call helpers: message_flags - Enable compiler inlining at call sites for frequently-executed operations - Avoid cross-translation-unit call overhead for performance-critical paths Header dependency cleanup: - Remove unused includes from headers (assert.h, evmc.hpp, limits, array) - Move implementation-only includes to .cpp files (delegation.hpp, storage_costs.hpp, uint256.hpp) - Remove unnecessary forward declarations - Headers now only include what they need for declarations and inline implementations - Improves compilation times by reducing transitive dependencies Additional changes: - Fix fixture.cpp to include ethash/keccak.hpp directly - Rename monad::call/create to execute_call_message/execute_create_message - Update evm_test.cpp to use renamed functions - Re-add explicit instantiations in evm.cpp - Fix storage.cpp to include transmute.hpp unconditionally - Use angle bracket includes (<category/...>) instead of double quotes in .cpp files - Fix include ordering to match clang-tidy requirements (std headers, third-party, project) These functions are executed thousands of times per contract and benefit significantly from inlining. Without LTO, keeping them inline prevents performance degradation from cross-TU calls. Verified with: - 400 EVM tests passing - Clean clang-tidy results - Clean clang-format-19 formatting Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1ce8637 to
73aa4ef
Compare
No description provided.