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

Method pop_to_addr

winch/codegen/src/codegen/context.rs:276–307  ·  view source on GitHub ↗

Pops the value stack top and stores it at the specified address.

(&mut self, masm: &mut M, addr: M::Address)

Source from the content-addressed store, hash-verified

274
275 /// Pops the value stack top and stores it at the specified address.
276 pub fn pop_to_addr<M: MacroAssembler>(&mut self, masm: &mut M, addr: M::Address) -> Result<()> {
277 let val = self.stack.pop().expect("a value at stack top");
278 let ty = val.ty();
279 let size: OperandSize = ty.try_into()?;
280 match val {
281 Val::Reg(tr) => {
282 masm.store(tr.reg.into(), addr, size)?;
283 self.free_reg(tr.reg);
284 }
285 Val::I32(v) => masm.store(RegImm::i32(v), addr, size)?,
286 Val::I64(v) => masm.store(RegImm::i64(v), addr, size)?,
287 Val::F32(v) => masm.store(RegImm::f32(v.bits()), addr, size)?,
288 Val::F64(v) => masm.store(RegImm::f64(v.bits()), addr, size)?,
289 Val::V128(v) => masm.store(RegImm::v128(v), addr, size)?,
290 Val::Local(local) => {
291 let slot = self.frame.get_wasm_local(local.index);
292 let local_addr = masm.local_address(&slot)?;
293 masm.with_scratch::<IntScratch, _>(|masm, scratch| {
294 masm.load(local_addr, scratch.writable(), size)?;
295 masm.store(scratch.inner().into(), addr, size)
296 })?;
297 }
298 Val::Memory(_) => {
299 masm.with_scratch_for(ty, |masm, scratch| {
300 masm.pop(scratch.writable(), size)?;
301 masm.store(scratch.inner().into(), addr, size)
302 })?;
303 }
304 }
305
306 Ok(())
307 }
308
309 /// Move a stack value to the given register.
310 pub fn move_val_to_reg<M: MacroAssembler>(

Callers 1

pop_abi_results_implMethod · 0.80

Calls 15

i64Function · 0.85
v128Function · 0.85
OkFunction · 0.85
free_regMethod · 0.80
get_wasm_localMethod · 0.80
with_scratch_forMethod · 0.80
expectMethod · 0.45
popMethod · 0.45
tyMethod · 0.45
try_intoMethod · 0.45
storeMethod · 0.45
bitsMethod · 0.45

Tested by

no test coverage detected