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,
)
| 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. |
nothing calls this directly
no test coverage detected