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

Method spill_impl

winch/codegen/src/codegen/context.rs:834–862  ·  view source on GitHub ↗

Spill locals and registers to memory. TODO: optimize the spill range; At any point in the program, the stack might already contain memory entries; we could effectively ignore that range; only focusing on the range that contains spillable values.

(
        stack: &mut Stack,
        regalloc: &mut RegAlloc,
        frame: &Frame<Emission>,
        masm: &mut M,
    )

Source from the content-addressed store, hash-verified

832 // entries; we could effectively ignore that range; only focusing on the
833 // range that contains spillable values.
834 fn spill_impl<M: MacroAssembler>(
835 stack: &mut Stack,
836 regalloc: &mut RegAlloc,
837 frame: &Frame<Emission>,
838 masm: &mut M,
839 ) -> Result<()> {
840 for v in stack.inner_mut() {
841 match v {
842 Val::Reg(r) => {
843 let slot = masm.push(r.reg, r.ty.try_into()?)?;
844 regalloc.free(r.reg);
845 *v = Val::mem(r.ty, slot);
846 }
847 Val::Local(local) => {
848 let slot = frame.get_wasm_local(local.index);
849 let addr = masm.local_address(&slot)?;
850 masm.with_scratch_for(slot.ty, |masm, scratch| {
851 masm.load(addr, scratch.writable(), slot.ty.try_into()?)?;
852 let stack_slot = masm.push(scratch.inner(), slot.ty.try_into()?)?;
853 *v = Val::mem(slot.ty, stack_slot);
854 wasmtime_environ::error::Ok(())
855 })?;
856 }
857 _ => {}
858 }
859 }
860
861 Ok(())
862 }
863
864 /// Prepares for emitting a binary operation where four 64-bit operands are
865 /// used to produce two 64-bit operands, e.g. a 128-bit binop.

Callers

nothing calls this directly

Calls 11

OkFunction · 0.85
inner_mutMethod · 0.80
get_wasm_localMethod · 0.80
with_scratch_forMethod · 0.80
pushMethod · 0.45
try_intoMethod · 0.45
freeMethod · 0.45
local_addressMethod · 0.45
loadMethod · 0.45
writableMethod · 0.45
innerMethod · 0.45

Tested by

no test coverage detected