Skip to content
Monpediaby Unity Nodes
OpenPull Request

[vm] Form EVM memory addresses from a 32-bit offset

by ryankeletiCreated Dec 4, 2026category-labs/monad

The JIT forms an EVM memory address as rax + [rbx + memory.data]. The upper bits of rax were zero only because a bound check, or an earlier check on the same stack element, said so. If such a check were wrong, the access could land anywhere in the address space.

Write the offset to eax with a 32-bit move on every path, so the address is at most 4 GB past memory.data whatever the checks did:

  • The elided path loads the offset with mov_stack_elem_low32_to_gp.
  • For bits <= 32, is_bounded_by_bits returns rax written through eax. Only the stack slot case costs an extra mov eax, eax.
  • A live offset in a general register is copied with mov eax, r32.

Emitter.MemoryOffsetIs32Bit checks the emitted code: every add rax, [rbx + memory.data] follows a 32-bit write to eax.

(Linear EXE-394)