| 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 { |