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

Method load_results

crates/wasmtime/src/runtime/component/func.rs:632–655  ·  view source on GitHub ↗
(
        cx: &'a mut LiftContext<'b>,
        results_ty: &'a TypeTuple,
        src: &mut core::slice::Iter<'_, ValRaw>,
    )

Source from the content-addressed store, hash-verified

630 }
631
632 fn load_results<'a, 'b>(
633 cx: &'a mut LiftContext<'b>,
634 results_ty: &'a TypeTuple,
635 src: &mut core::slice::Iter<'_, ValRaw>,
636 ) -> Result<impl Iterator<Item = Result<Val>> + use<'a, 'b>> {
637 // FIXME(#4311): needs to read an i64 for memory64
638 let ptr = usize::try_from(src.next().unwrap().get_u32())?;
639 if ptr % usize::try_from(results_ty.abi.align32)? != 0 {
640 bail!("return pointer not aligned");
641 }
642
643 let bytes = cx
644 .memory()
645 .get(ptr..)
646 .and_then(|b| b.get(..usize::try_from(results_ty.abi.size32).unwrap()))
647 .ok_or_else(|| crate::format_err!("pointer out of bounds of memory"))?;
648
649 let mut offset = 0;
650 Ok(results_ty.types.iter().map(move |ty| {
651 let abi = cx.types.canonical_abi(ty);
652 let offset = abi.next_field32_size(&mut offset);
653 Val::load(cx, *ty, &bytes[offset..][..abi.size32 as usize])
654 }))
655 }
656
657 #[cfg(feature = "component-model-async")]
658 pub(crate) fn instance(self) -> Instance {

Callers

nothing calls this directly

Calls 11

OkFunction · 0.85
next_field32_sizeMethod · 0.80
loadFunction · 0.50
get_u32Method · 0.45
unwrapMethod · 0.45
nextMethod · 0.45
getMethod · 0.45
memoryMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
canonical_abiMethod · 0.45

Tested by

no test coverage detected