Skip to content

feat(evm): add block-local runtime stack overlay#551

Open
ZR74 wants to merge 1 commit into
DTVMStack:mainfrom
ZR74:feat/evm-block-local-overlay
Open

feat(evm): add block-local runtime stack overlay#551
ZR74 wants to merge 1 commit into
DTVMStack:mainfrom
ZR74:feat/evm-block-local-overlay

Conversation

@ZR74

@ZR74 ZR74 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

2. What is the scope of this PR (e.g. component or file name):

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

  • Affects user behaviors
  • Contains CI/CD configuration changes
  • Contains documentation changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

6. Release note

None

Copilot AI review requested due to automatic review settings June 24, 2026 07:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a block-local runtime stack overlay for the EVM bytecode visitor when ZEN_ENABLE_EVM_STACK_SSA_LIFT is disabled, aiming to reduce per-op stack load/store pressure while preserving correctness across helper/gas/control-flow boundaries. It also refines analyzer metadata to distinguish “JIT entry state materializable” from “stack SSA liftable”, and updates module-level JIT fallback gating accordingly.

Changes:

  • Add a block-local runtime-stack overlay to EVMByteCodeVisitor (SSA-lift-off mode), including lazy stack loads and explicit flush/sync points at runtime-visible boundaries.
  • Extend the MIR builder with stackDrop() and hasOpcodeGasMeteringBoundary() to support efficient overlay flushing and safe gas-check boundaries.
  • Update analyzer metadata (CanMaterializeJITEntryState) and adjust runtime module fallback checks to only apply deep-entry / dynamic-trampoline gates in SSA-lift mode; add/adjust tests and documentation.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/action/evm_bytecode_visitor.h Implements the SSA-off runtime stack overlay, flush/sync logic at boundaries, and integrates gas-boundary syncing.
src/compiler/evm_frontend/evm_mir_compiler.h Adds new builder surface: stackDrop() and hasOpcodeGasMeteringBoundary().
src/compiler/evm_frontend/evm_mir_compiler.cpp Implements gas-boundary detection and stackDrop() lowering to runtime stack top/size updates.
src/compiler/evm_frontend/evm_analyzer.h Adds CanMaterializeJITEntryState, refactors deep-entry risk detection, and separates materializability from liftability.
src/runtime/evm_module.cpp Gates deep-entry and dynamic-trampoline fallback checks behind ZEN_ENABLE_EVM_STACK_SSA_LIFT.
src/tests/evm_jit_frontend_tests.cpp Updates mocks and adds/adjusts tests to validate overlay behavior and analyzer materializability metadata.
docs/modules/compiler/spec.md Documents SSA-off overlay semantics and how it affects fallback gating.
docs/changes/2026-06-23-evm-block-local-overlay/README.md Adds a Light change proposal documenting motivation, design, and validation pointers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

⚡ Performance Regression Check Results

✅ Performance Check Passed (interpreter)

Performance Benchmark Results (threshold: 25%)

Benchmark Baseline (us) Current (us) Change Status
total/main/blake2b_huff/8415nulls 4.06 4.19 +3.3% PASS
total/main/blake2b_huff/empty 0.07 0.06 -8.0% PASS
total/main/blake2b_shifts/8415nulls 20.18 20.16 -0.1% PASS
total/main/sha1_divs/5311 12.51 12.66 +1.2% PASS
total/main/sha1_divs/empty 0.15 0.15 -2.1% PASS
total/main/sha1_shifts/5311 9.33 9.74 +4.3% PASS
total/main/sha1_shifts/empty 0.07 0.07 +0.7% PASS
total/main/snailtracer/benchmark 112.81 117.65 +4.3% PASS
total/main/structarray_alloc/nfts_rank 1.45 1.47 +1.4% PASS
total/main/swap_math/insufficient_liquidity 0.00 0.00 -4.4% PASS
total/main/swap_math/received 0.01 0.01 -2.4% PASS
total/main/swap_math/spent 0.01 0.01 -4.3% PASS
total/main/weierstrudel/1 0.41 0.41 -0.3% PASS
total/main/weierstrudel/15 4.67 4.81 +3.0% PASS
total/micro/JUMPDEST_n0/empty 3.01 3.01 +0.0% PASS
total/micro/jump_around/empty 0.11 0.09 -21.8% PASS
total/micro/loop_with_many_jumpdests/empty 67.46 67.43 -0.0% PASS
total/micro/memory_grow_mload/by1 0.25 0.24 -1.9% PASS
total/micro/memory_grow_mload/by16 0.27 0.26 -2.0% PASS
total/micro/memory_grow_mload/by32 0.16 0.16 -2.6% PASS
total/micro/memory_grow_mload/nogrow 0.13 0.12 -5.9% PASS
total/micro/memory_grow_mstore/by1 0.26 0.27 +2.2% PASS
total/micro/memory_grow_mstore/by16 0.15 0.15 +0.0% PASS
total/micro/memory_grow_mstore/by32 0.29 0.32 +12.2% PASS
total/micro/memory_grow_mstore/nogrow 0.25 0.25 +0.6% PASS
total/micro/signextend/one 0.27 0.27 +0.3% PASS
total/micro/signextend/zero 0.49 0.50 +2.2% PASS
total/synth/ADD/b0 3.25 3.21 -1.0% PASS
total/synth/ADD/b1 5.96 6.04 +1.2% PASS
total/synth/ADDRESS/a0 7.05 6.81 -3.3% PASS
total/synth/ADDRESS/a1 6.04 5.98 -0.8% PASS
total/synth/AND/b0 3.03 3.02 -0.1% PASS
total/synth/AND/b1 5.32 5.35 +0.5% PASS
total/synth/BYTE/b0 6.89 6.91 +0.3% PASS
total/synth/BYTE/b1 9.02 9.28 +2.9% PASS
total/synth/CALLDATASIZE/a0 5.24 5.36 +2.3% PASS
total/synth/CALLDATASIZE/a1 4.30 4.32 +0.4% PASS
total/synth/CALLER/a0 7.03 7.01 -0.3% PASS
total/synth/CALLER/a1 7.34 7.28 -0.9% PASS
total/synth/CALLVALUE/a0 4.04 3.12 -22.8% PASS
total/synth/CALLVALUE/a1 6.48 6.09 -6.1% PASS
total/synth/CODESIZE/a0 6.40 6.65 +3.9% PASS
total/synth/CODESIZE/a1 6.25 6.30 +0.9% PASS
total/synth/DUP1/d0 2.08 2.18 +4.7% PASS
total/synth/DUP1/d1 2.24 2.32 +3.4% PASS
total/synth/DUP10/d0 2.10 2.18 +4.0% PASS
total/synth/DUP10/d1 2.39 2.42 +1.2% PASS
total/synth/DUP11/d0 1.44 1.44 +0.0% PASS
total/synth/DUP11/d1 2.37 2.23 -5.7% PASS
total/synth/DUP12/d0 2.24 2.23 -0.5% PASS
total/synth/DUP12/d1 1.69 1.67 -1.1% PASS
total/synth/DUP13/d0 2.10 2.20 +4.7% PASS
total/synth/DUP13/d1 2.29 2.15 -6.1% PASS
total/synth/DUP14/d0 1.44 1.44 -0.1% PASS
total/synth/DUP14/d1 2.25 2.43 +8.2% PASS
total/synth/DUP15/d0 2.28 2.25 -1.3% PASS
total/synth/DUP15/d1 1.64 1.76 +7.4% PASS
total/synth/DUP16/d0 2.09 2.11 +1.2% PASS
total/synth/DUP16/d1 2.32 2.29 -1.3% PASS
total/synth/DUP2/d0 1.44 1.44 +0.1% PASS
total/synth/DUP2/d1 2.20 2.28 +3.8% PASS
total/synth/DUP3/d0 2.11 2.14 +1.4% PASS
total/synth/DUP3/d1 1.86 1.90 +1.8% PASS
total/synth/DUP4/d0 2.18 2.14 -1.8% PASS
total/synth/DUP4/d1 2.28 2.25 -1.3% PASS
total/synth/DUP5/d0 1.44 1.44 -0.3% PASS
total/synth/DUP5/d1 2.25 2.15 -4.5% PASS
total/synth/DUP6/d0 2.14 2.21 +3.5% PASS
total/synth/DUP6/d1 1.64 1.90 +15.8% PASS
total/synth/DUP7/d0 2.18 2.25 +3.1% PASS
total/synth/DUP7/d1 2.30 2.32 +0.9% PASS
total/synth/DUP8/d0 1.44 1.44 +0.0% PASS
total/synth/DUP8/d1 2.29 2.15 -5.8% PASS
total/synth/DUP9/d0 2.23 2.02 -9.4% PASS
total/synth/DUP9/d1 1.65 1.66 +0.6% PASS
total/synth/EQ/b0 6.80 6.84 +0.6% PASS
total/synth/EQ/b1 7.21 7.29 +1.2% PASS
total/synth/GAS/a0 4.08 4.00 -2.0% PASS
total/synth/GAS/a1 7.42 7.27 -1.9% PASS
total/synth/GT/b0 7.06 7.13 +1.0% PASS
total/synth/GT/b1 7.38 7.22 -2.1% PASS
total/synth/ISZERO/u0 11.40 11.34 -0.5% PASS
total/synth/JUMPDEST/n0 3.01 3.01 -0.1% PASS
total/synth/LT/b0 7.11 7.10 -0.1% PASS
total/synth/LT/b1 6.34 6.26 -1.2% PASS
total/synth/MSIZE/a0 6.43 6.43 +0.0% PASS
total/synth/MSIZE/a1 6.79 6.74 -0.7% PASS
total/synth/MUL/b0 9.33 8.82 -5.5% PASS
total/synth/MUL/b1 6.84 6.80 -0.7% PASS
total/synth/NOT/u0 7.05 6.96 -1.3% PASS
total/synth/OR/b0 5.21 5.21 -0.0% PASS
total/synth/OR/b1 4.01 3.44 -14.1% PASS
total/synth/PC/a0 5.41 5.18 -4.3% PASS
total/synth/PC/a1 4.30 4.51 +4.8% PASS
total/synth/PUSH1/p0 2.52 2.47 -2.1% PASS
total/synth/PUSH1/p1 1.75 1.98 +12.6% PASS
total/synth/PUSH10/p0 2.47 2.44 -1.3% PASS
total/synth/PUSH10/p1 2.00 1.99 -0.5% PASS
total/synth/PUSH11/p0 2.49 2.49 -0.1% PASS
total/synth/PUSH11/p1 2.52 2.49 -0.9% PASS
total/synth/PUSH12/p0 1.52 1.51 -0.6% PASS
total/synth/PUSH12/p1 2.48 2.48 -0.1% PASS
total/synth/PUSH13/p0 2.41 2.45 +1.7% PASS
total/synth/PUSH13/p1 1.77 1.98 +11.8% PASS
total/synth/PUSH14/p0 2.47 2.50 +0.9% PASS
total/synth/PUSH14/p1 2.47 2.50 +1.5% PASS
total/synth/PUSH15/p0 1.52 1.52 +0.0% PASS
total/synth/PUSH15/p1 2.38 2.52 +5.9% PASS
total/synth/PUSH16/p0 2.81 2.58 -8.2% PASS
total/synth/PUSH16/p1 1.78 1.76 -0.9% PASS
total/synth/PUSH17/p0 2.56 2.42 -5.3% PASS
total/synth/PUSH17/p1 2.40 2.48 +3.4% PASS
total/synth/PUSH18/p0 1.52 1.52 +0.0% PASS
total/synth/PUSH18/p1 2.59 2.44 -6.0% PASS
total/synth/PUSH19/p0 2.53 2.54 +0.4% PASS
total/synth/PUSH19/p1 1.77 1.77 -0.2% PASS
total/synth/PUSH2/p0 2.47 2.33 -5.6% PASS
total/synth/PUSH2/p1 2.51 2.37 -5.8% PASS
total/synth/PUSH20/p0 2.44 2.42 -0.8% PASS
total/synth/PUSH20/p1 2.53 2.51 -0.8% PASS
total/synth/PUSH21/p0 1.52 1.52 -0.2% PASS
total/synth/PUSH21/p1 2.54 2.66 +5.0% PASS
total/synth/PUSH22/p0 2.58 2.48 -3.9% PASS
total/synth/PUSH22/p1 1.77 1.78 +0.1% PASS
total/synth/PUSH23/p0 2.55 2.51 -1.3% PASS
total/synth/PUSH23/p1 2.50 2.46 -1.5% PASS
total/synth/PUSH24/p0 1.52 1.52 +0.2% PASS
total/synth/PUSH24/p1 2.46 2.41 -2.0% PASS
total/synth/PUSH25/p0 2.48 2.39 -3.5% PASS
total/synth/PUSH25/p1 1.78 2.00 +12.4% PASS
total/synth/PUSH26/p0 2.47 2.44 -1.3% PASS
total/synth/PUSH26/p1 2.51 2.56 +2.0% PASS
total/synth/PUSH27/p0 1.52 1.53 +0.5% PASS
total/synth/PUSH27/p1 2.59 2.57 -0.7% PASS
total/synth/PUSH28/p0 2.48 2.56 +3.0% PASS
total/synth/PUSH28/p1 1.95 1.78 -8.9% PASS
total/synth/PUSH29/p0 2.53 2.53 +0.1% PASS
total/synth/PUSH29/p1 2.62 2.46 -6.1% PASS
total/synth/PUSH3/p0 1.51 1.52 +0.7% PASS
total/synth/PUSH3/p1 2.48 2.38 -4.0% PASS
total/synth/PUSH30/p0 1.54 1.57 +1.9% PASS
total/synth/PUSH30/p1 2.51 2.59 +3.3% PASS
total/synth/PUSH31/p0 2.42 2.49 +2.9% PASS
total/synth/PUSH31/p1 1.80 1.79 -0.6% PASS
total/synth/PUSH32/p0 2.57 2.46 -4.3% PASS
total/synth/PUSH32/p1 2.48 2.52 +1.6% PASS
total/synth/PUSH4/p0 2.54 2.39 -5.5% PASS
total/synth/PUSH4/p1 1.76 1.98 +12.6% PASS
total/synth/PUSH5/p0 2.44 2.46 +0.8% PASS
total/synth/PUSH5/p1 2.49 2.40 -3.7% PASS
total/synth/PUSH6/p0 1.51 1.52 +0.6% PASS
total/synth/PUSH6/p1 2.58 2.40 -6.7% PASS
total/synth/PUSH7/p0 2.43 2.53 +4.1% PASS
total/synth/PUSH7/p1 1.96 1.76 -9.5% PASS
total/synth/PUSH8/p0 2.46 2.45 -0.5% PASS
total/synth/PUSH8/p1 2.52 2.49 -1.3% PASS
total/synth/PUSH9/p0 1.52 1.52 -0.3% PASS
total/synth/PUSH9/p1 2.42 2.41 -0.2% PASS
total/synth/RETURNDATASIZE/a0 3.96 3.72 -6.1% PASS
total/synth/RETURNDATASIZE/a1 6.43 6.44 +0.2% PASS
total/synth/SAR/b0 4.44 4.44 -0.1% PASS
total/synth/SAR/b1 7.79 7.79 +0.1% PASS
total/synth/SGT/b0 5.74 6.06 +5.6% PASS
total/synth/SGT/b1 5.15 4.92 -4.5% PASS
total/synth/SHL/b0 6.97 6.84 -1.8% PASS
total/synth/SHL/b1 3.95 3.64 -8.0% PASS
total/synth/SHR/b0 6.97 6.76 -3.0% PASS
total/synth/SHR/b1 6.10 6.34 +4.0% PASS
total/synth/SIGNEXTEND/b0 3.43 3.45 +0.7% PASS
total/synth/SIGNEXTEND/b1 6.46 6.58 +1.9% PASS
total/synth/SLT/b0 4.31 4.16 -3.4% PASS
total/synth/SLT/b1 5.70 5.43 -4.6% PASS
total/synth/SUB/b0 5.90 5.71 -3.3% PASS
total/synth/SUB/b1 6.11 5.97 -2.4% PASS
total/synth/SWAP1/s0 3.43 3.43 +0.0% PASS
total/synth/SWAP10/s0 3.45 3.45 +0.2% PASS
total/synth/SWAP11/s0 4.03 3.67 -8.7% PASS
total/synth/SWAP12/s0 3.81 3.63 -4.7% PASS
total/synth/SWAP13/s0 3.46 3.46 +0.0% PASS
total/synth/SWAP14/s0 4.07 3.74 -8.1% PASS
total/synth/SWAP15/s0 4.35 4.80 +10.4% PASS
total/synth/SWAP16/s0 3.39 3.39 +0.1% PASS
total/synth/SWAP2/s0 4.22 4.08 -3.2% PASS
total/synth/SWAP3/s0 3.99 3.92 -1.6% PASS
total/synth/SWAP4/s0 3.44 3.44 -0.0% PASS
total/synth/SWAP5/s0 3.95 3.90 -1.4% PASS
total/synth/SWAP6/s0 3.76 3.87 +2.9% PASS
total/synth/SWAP7/s0 3.45 3.45 +0.0% PASS
total/synth/SWAP8/s0 3.74 3.81 +1.8% PASS
total/synth/SWAP9/s0 3.86 3.78 -2.0% PASS
total/synth/XOR/b0 4.92 4.98 +1.2% PASS
total/synth/XOR/b1 5.07 5.01 -1.2% PASS
total/synth/loop_v1 13.50 14.04 +4.0% PASS
total/synth/loop_v2 13.83 13.30 -3.8% PASS

Summary: 194 benchmarks, 0 regressions


⚠️ Performance Regression Detected (multipass)

No benchmark summary available.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants