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

Method emit_set_local

winch/codegen/src/codegen/mod.rs:540–555  ·  view source on GitHub ↗

Pops the value at the stack top and assigns it to the local at the given index, returning the typed register holding the source value.

(&mut self, index: u32)

Source from the content-addressed store, hash-verified

538 /// the given index, returning the typed register holding the
539 /// source value.
540 pub fn emit_set_local(&mut self, index: u32) -> Result<TypedReg> {
541 // Materialize any references to the same local index that are in the
542 // value stack by spilling.
543 if self.context.stack.contains_latent_local(index) {
544 self.context.spill(self.masm)?;
545 }
546 let src = self.context.pop_to_reg(self.masm, None)?;
547 // Need to get address of local after `pop_to_reg` since `pop_to_reg`
548 // will pop the machine stack causing an incorrect address to be
549 // calculated.
550 let (ty, addr) = self.context.frame.get_local_address(index, self.masm)?;
551 self.masm
552 .store(RegImm::reg(src.reg), addr, ty.try_into()?)?;
553
554 Ok(src)
555 }
556
557 /// Loads the address of the given global.
558 pub fn emit_get_global_addr(&mut self, index: GlobalIndex) -> Result<(WasmValType, Reg, u32)> {

Callers 2

visit_local_setMethod · 0.80
visit_local_teeMethod · 0.80

Calls 7

OkFunction · 0.85
contains_latent_localMethod · 0.80
spillMethod · 0.80
pop_to_regMethod · 0.80
get_local_addressMethod · 0.45
storeMethod · 0.45
try_intoMethod · 0.45

Tested by

no test coverage detected