MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / compute

Method compute

crates/wasmtime/src/runtime/debug.rs:721–749  ·  view source on GitHub ↗
(frame: VirtualFrame, store_code: &StoreCode)

Source from the content-addressed store, hash-verified

719
720impl FrameData {
721 fn compute(frame: VirtualFrame, store_code: &StoreCode) -> Self {
722 let frame_table = store_code.code_memory().frame_table().unwrap();
723 // Parse the frame descriptor.
724 let (data, slot_to_fp_offset) = frame_table
725 .frame_descriptor(frame.frame_descriptor)
726 .unwrap();
727 let frame_state_slot = FrameStateSlot::parse(data).unwrap();
728 let slot_to_fp_offset = usize::try_from(slot_to_fp_offset).unwrap();
729
730 // Materialize the stack shape so we have O(1) access to its
731 // elements, and so we don't need to keep the borrow to the
732 // module alive.
733 let mut stack = frame_state_slot
734 .stack(frame.stack_shape)
735 .collect::<Vec<_>>();
736 stack.reverse(); // Put top-of-stack last.
737
738 // Materialize the local offsets/types so we don't need to
739 // keep the borrow to the module alive.
740 let locals = frame_state_slot.locals().collect::<Vec<_>>();
741
742 FrameData {
743 slot_to_fp_offset,
744 func_key: frame_state_slot.func_key(),
745 wasm_pc: frame.wasm_pc,
746 stack,
747 locals,
748 }
749 }
750
751 fn slot_addr(&self, fp: usize) -> *mut u8 {
752 let fp: *mut u8 = core::ptr::with_exposed_provenance_mut(fp);

Callers

nothing calls this directly

Calls 9

code_memoryMethod · 0.80
frame_descriptorMethod · 0.80
reverseMethod · 0.80
func_keyMethod · 0.80
parseFunction · 0.50
unwrapMethod · 0.45
frame_tableMethod · 0.45
stackMethod · 0.45
localsMethod · 0.45

Tested by

no test coverage detected