Skip to content

fix(jit): decouple JUMPDEST analysis from instruction decoding - #358

Merged
DaniPopes merged 1 commit into
mainfrom
jit-eip8024-jumpdest
Aug 13, 2026
Merged

DaniPopes merged 1 commit into
mainfrom
jit-eip8024-jumpdest

Conversation

@rakita

@rakita rakita commented Aug 13, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the JIT failure surfaced by the devnet-8 [email protected] fixtures on #357 (eip8024_dupn_swapn_exchange/eip_vectors/vector_push_in_immediate_masks_jumpdest). The bug predates the fixture bump; the v8.1.0 eip_vectors are just the first fixtures to exercise it.

EIP-8024 leaves JUMPDEST analysis unchanged: only PUSH data is skipped, DUPN/SWAPN/EXCHANGE immediates are analyzed as if they were opcodes. The bytecode parser instead marked every decoded JUMPDEST instruction as a valid jump target, and the decoder does consume EIP-8024 immediates, so the two disagreed once such an immediate entered the stream. In e6605b ([DUPN, PUSH1 0x5b]) the analysis masks the 0x5b behind the PUSH1, but decoding yielded it as a JUMPDEST instruction and the JIT accepted the jump the interpreter rejects.

Fix

  • Compute the valid-jump-target bitmap with the legacy scan over the raw bytes, decoupled from instruction decoding.
  • Generalize the existing DUPN-immediate rewind: any analysis-valid target swallowed by a consumed immediate (a DUPN-family immediate byte, or a 0x5b inside desynchronized PUSH data) is re-yielded so jumps have an instruction to land on. Analysis-aligned PUSH data never contains valid targets, so pre-EIP-8024 bytecode never rewinds.
  • Exclude analysis-masked decoded JUMPDESTs from the dynamic jump dispatch table.

Execution cannot fall through into rewound bytes: every immediate that desynchronizes decoding from the analysis is an invalid DUPN/SWAPN/EXCHANGE encoding (decode_single/decode_pair reject 91..=127, which covers 0x5b and all PUSH opcodes), so the opcode preceding them halts at runtime.

Validation

  • New codegen matrix tests: static + dynamic jump to a PUSH-masked 0x5b after DUPN (must be invalid), and a jump to an analysis-valid 0x5b inside desynchronized PUSH data (must land).
  • All 2,226 evm2-jit-codegen tests and the 30 .evm snapshot tests pass; workspace suite passes.
  • With this fix cherry-picked onto feat: glamsterdam devnet-8 gas repricing #357 (so the fixtures match the gas schedule): the full for_amsterdam devnet state-test corpus (2,737 files, EVM2_COMPILED_EEST_SUBSET=all) passes through the JIT — the configuration the jit ubuntu jit CI job runs.

Note: #357's JIT job needs this fix to go green (rebase or merge-order either way).

EIP-8024 leaves JUMPDEST analysis unchanged: only PUSH data is skipped,
DUPN/SWAPN/EXCHANGE immediates are analyzed as if they were opcodes. The
bytecode parser instead marked every decoded JUMPDEST instruction as a
valid jump target, and the decoder does consume EIP-8024 immediates, so
the two disagreed once such an immediate entered the stream. In
e6605b ([DUPN, PUSH1 0x5b]) the analysis masks the 0x5b behind the
PUSH1, but decoding yielded it as a JUMPDEST and the JIT accepted the
jump the interpreter rejects (caught by the devnet-8
eip8024 test_vector_push_in_immediate_masks_jumpdest fixtures).

Compute the valid-target bitmap with the legacy scan over the raw
bytes, generalize the existing DUPN-immediate rewind to re-yield any
analysis-valid target swallowed by a consumed immediate (including
targets inside desynchronized PUSH data), and exclude analysis-masked
decoded JUMPDESTs from the dynamic jump dispatch table.

Execution cannot fall through into rewound bytes: every immediate that
desynchronizes decoding from the analysis is an invalid
DUPN/SWAPN/EXCHANGE encoding, so the opcode preceding them halts.
@DaniPopes
DaniPopes merged commit 524a268 into main Aug 13, 2026
30 checks passed
@DaniPopes
DaniPopes deleted the jit-eip8024-jumpdest branch August 13, 2026 20:23

This branch was previously deployed

1 inactive deployment
codspeed — 79810b63 Deployed Aug 13, 2026 by rakita via codspeed #587
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