Skip to main content

ensure_branch_targets_are_block_starts

Function ensure_branch_targets_are_block_starts 

Source
pub fn ensure_branch_targets_are_block_starts(
    code: &mut Vec<u8>,
    bitmask: &mut Vec<u8>,
    jump_table: &mut [u32],
)
Expand description

Post-pass: ensure all PVM branch targets are basic block starts (ϖ).

Scans the PVM code for branch/jump instructions, extracts their targets, and inserts fallthrough (opcode 1) before any target not preceded by a terminator. Adjusts all branch offsets and jump table entries to account for the inserted bytes.

This guarantees the JAM spec invariant: all branch targets ∈ ϖ.