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

Method assign_context_args

winch/codegen/src/codegen/call.rs:261–302  ·  view source on GitHub ↗

Materializes any [ContextArgs] as a function argument.

(
        sig: &ABISig,
        context: &ContextArgs,
        masm: &mut M,
    )

Source from the content-addressed store, hash-verified

259
260 /// Materializes any [ContextArgs] as a function argument.
261 fn assign_context_args<M: MacroAssembler>(
262 sig: &ABISig,
263 context: &ContextArgs,
264 masm: &mut M,
265 ) -> Result<()> {
266 ensure!(
267 sig.params().len() >= context.len(),
268 CodeGenError::vmcontext_arg_expected(),
269 );
270 for (context_arg, operand) in context
271 .as_slice()
272 .iter()
273 .zip(sig.params_without_retptr().iter().take(context.len()))
274 {
275 match (context_arg, operand) {
276 (VMContextLoc::Pinned, ABIOperand::Reg { ty, reg, .. }) => {
277 masm.mov(writable!(*reg), vmctx!(M).into(), (*ty).try_into()?)?;
278 }
279 (VMContextLoc::Pinned, ABIOperand::Stack { ty, offset, .. }) => {
280 let addr = masm.address_at_sp(SPOffset::from_u32(*offset))?;
281 masm.store(vmctx!(M).into(), addr, (*ty).try_into()?)?;
282 }
283 (VMContextLoc::OffsetFromPinned(offset), ABIOperand::Reg { ty, reg, .. }) => {
284 let addr = masm.address_at_vmctx(*offset)?;
285 masm.load(addr, writable!(*reg), (*ty).try_into()?)?;
286 }
287 (VMContextLoc::OffsetFromPinned(_), ABIOperand::Stack { .. }) => {
288 crate::bail!("unimplemented load from vmctx into stack");
289 }
290
291 (VMContextLoc::Reg(src), ABIOperand::Reg { ty, reg, .. }) => {
292 masm.mov(writable!(*reg), (*src).into(), (*ty).try_into()?)?;
293 }
294
295 (VMContextLoc::Reg(src), ABIOperand::Stack { ty, offset, .. }) => {
296 let addr = masm.address_at_sp(SPOffset::from_u32(*offset))?;
297 masm.store((*src).into(), addr, (*ty).try_into()?)?;
298 }
299 }
300 }
301 Ok(())
302 }
303
304 /// Assign arguments for the function call.
305 fn assign<M: MacroAssembler>(

Callers

nothing calls this directly

Calls 12

OkFunction · 0.85
params_without_retptrMethod · 0.80
iterMethod · 0.45
as_sliceMethod · 0.45
takeMethod · 0.45
lenMethod · 0.45
movMethod · 0.45
try_intoMethod · 0.45
address_at_spMethod · 0.45
storeMethod · 0.45
address_at_vmctxMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected