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

Method raw_instance

crates/wasmtime/src/runtime/debug.rs:501–520  ·  view source on GitHub ↗
(&self, store: &mut StoreOpaque)

Source from the content-addressed store, hash-verified

499 }
500
501 fn raw_instance<'a>(&self, store: &mut StoreOpaque) -> Result<&'a crate::vm::Instance> {
502 let frame_data = self.frame_data(store)?;
503
504 // Read out the vmctx slot.
505
506 // SAFETY: vmctx is always at offset 0 in the slot. (See
507 // crates/cranelift/src/func_environ.rs in
508 // `update_stack_slot_vmctx()`.) The frame/activation is
509 // still valid because we verified this in `frame_data` above.
510 let vmctx: usize =
511 unsafe { *(frame_data.slot_addr(self.cursor.frame().fp()) as *mut usize) };
512 let vmctx: *mut VMContext = core::ptr::with_exposed_provenance_mut(vmctx);
513 let vmctx = NonNull::new(vmctx).expect("null vmctx in debug state slot");
514 // SAFETY: the stored vmctx value is a valid instance in this
515 // store; we only visit frames from this store in the
516 // backtrace.
517 let instance = unsafe { crate::vm::Instance::from_vmctx(vmctx) };
518 // SAFETY: the instance pointer read above is valid.
519 Ok(unsafe { instance.as_ref() })
520 }
521
522 /// Get the instance associated with the current frame.
523 pub fn instance(&self, mut store: impl AsContextMut) -> Result<Instance> {

Callers 2

instanceMethod · 0.80
moduleMethod · 0.80

Calls 8

OkFunction · 0.85
frame_dataMethod · 0.80
slot_addrMethod · 0.80
frameMethod · 0.80
newFunction · 0.50
fpMethod · 0.45
expectMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected