Skip to content

fix(bytecode): skip DUPN/SWAPN/EXCHANGE immediates in analyze_legacy#3801

Open
cuiweixie wants to merge 1 commit into
bluealloy:mainfrom
cuiweixie:fix/analyze-legacy-dupn-swapn-exchange-immediate
Open

fix(bytecode): skip DUPN/SWAPN/EXCHANGE immediates in analyze_legacy#3801
cuiweixie wants to merge 1 commit into
bluealloy:mainfrom
cuiweixie:fix/analyze-legacy-dupn-swapn-exchange-immediate

Conversation

@cuiweixie

Copy link
Copy Markdown
Contributor

Summary

  • Skip the 1-byte immediate of DUPN/SWAPN/EXCHANGE during legacy analysis (same as PUSH), so a JUMPDEST byte in that immediate is not marked as a valid jump target.
  • Simplify end-of-bytecode padding: incomplete immediates are covered by iterator overflow; only append a final STOP when needed.
  • Add regression tests for jump-table correctness and truncated opcode padding.

Test plan

  • cargo test -p revm-bytecode --lib dupn_swapn -- --nocapture
  • cargo test -p revm-bytecode --lib legacy::analysis::tests
  • Confirm the two new tests fail if the skip branch is removed

Treat these opcodes like PUSH when building the jump table so JUMPDEST
bytes in the immediate are not marked valid, and simplify padding now
that incomplete immediates are covered by iterator overflow.
@cuiweixie
cuiweixie force-pushed the fix/analyze-legacy-dupn-swapn-exchange-immediate branch from 8c93604 to 83a6bf9 Compare July 15, 2026 23:03
@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 3.59%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 180 untouched benchmarks
⏩ 1 skipped benchmark1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation blake2/2_rounds 3.4 µs 3.2 µs +3.59%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing cuiweixie:fix/analyze-legacy-dupn-swapn-exchange-immediate (83a6bf9) with main (a094a93)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

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.

1 participant