Understand the Stack Frame Layout
mainThe stack frame is inspired by the stitch WebAssembly interpreter and consists of four main parts:
- Frame Header: Contains the saved stack pointer, return address, current instance, and value slots for parameters and return values.
- Locals: Contains the local variables of the current function.
- Constant Pool: Contains constant values. Its size is determined during translation based on Wasm-level code size.
- Dynamic Stack: Contains intermediate values produced by instructions. Its size is fixed at the end of translation based on the maximum stack height.
Slots vs Values
All values are indexed in 64-bit slots (StackSlot == UInt64).
i32,i64,f32,f64, andrefoccupy 1 slot.v128occupies 2 consecutive slots (lothenhi).
Note: Register indices always refer to the first slot of a value. For a v128 value, the register index points to the lo slot, and reg + 1 points to the hi slot.