Skip to main content

walk_frames

Function walk_frames 

Source
pub unsafe fn walk_frames(
    start_fp: usize,
    stack_maps: &StackMapRegistry,
) -> Vec<StackRoot>
Expand description

Walk JIT frames starting from the given frame pointer, collecting all GC roots.

Uses Cranelift’s frame_size metadata (the FP-to-SP distance, aka active_size()) to compute SP at each safepoint: SP = caller_FP - frame_size. This is the same approach Wasmtime uses and is correct on both x86_64 and aarch64, regardless of prologue structure or callee-saved register layout.

§Safety

  • start_fp must be a valid frame pointer from within a JIT call chain (typically gc_trigger’s FP, read via inline asm).
  • stack_maps must contain entries for all JIT functions in the call chain.
  • All frames in the chain must have frame pointers (force-frame-pointers = true).