pub fn max_depth_bound(wasm_ops: &[WasmOp]) -> u32Expand description
#587: a conservative UPPER BOUND on the wasm value-stack depth this op
sequence can reach. Used by the ARM backend’s pool-grow exhaustion-
recovery rung to size the i64 spill-slot pool: the number of values
simultaneously spilled by the direct selector can never exceed the
number of values simultaneously live on the operand stack, so a pool of
max_depth_bound slots (plus the resolver/result-parking transients the
caller adds) cannot exhaust through the deepest-value spill loop.
Over-approximation rules (never under-counts in reachable code):
- Modeled ops apply their exact pops/pushes; a would-be underflow clamps to 0 (malformed input is someone else’s Err, not a panic here).
- Unmodeled/
Bailops (call, terminators, SIMD, …) are treated as net+1— every wasm op pushes at most one value net, so this only ever over-counts (a call pops its args; a terminator pushes nothing). Block/Loop/If/Else/Endare stack-neutral in the effects table, which over-counts (ifreally pops its condition) — same direction.