Function analyze_legacy

Source
pub fn analyze_legacy(bytecode: Bytes) -> (JumpTable, Bytes)
Expand description

Analyze the bytecode to find the jumpdests. Used to create a jump table that is needed for crate::LegacyAnalyzedBytecode. This function contains a hot loop and should be optimized as much as possible.

ยงSafety

The function uses unsafe pointer arithmetic, but maintains the following invariants:

  • The iterator never advances beyond the end of the bytecode
  • All pointer offsets are within bounds of the bytecode
  • The jump table is never accessed beyond its allocated size

Undefined behavior if the bytecode does not end with a valid STOP opcode. Please check crate::LegacyAnalyzedBytecode::new for details on how the bytecode is validated.