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

Method emit_table_set

winch/codegen/src/codegen/mod.rs:664–694  ·  view source on GitHub ↗

Emit the `table.set` operation for a function-reference table. Expects the value stack to contain `[index, value]` (with `value` on top) and consumes both.

(&mut self, table_index: TableIndex)

Source from the content-addressed store, hash-verified

662 /// Expects the value stack to contain `[index, value]` (with `value` on
663 /// top) and consumes both.
664 pub fn emit_table_set(&mut self, table_index: TableIndex) -> Result<()> {
665 let table = self.env.table(table_index);
666 ensure!(
667 table.ref_type.heap_type == WasmHeapType::Func,
668 CodeGenError::unsupported_wasm_type()
669 );
670 ensure!(
671 self.tunables.table_lazy_init,
672 CodeGenError::unsupported_table_eager_init()
673 );
674 let ptr_type = self.env.ptr_type();
675 let table_data = self.env.resolve_table_data(table_index);
676 let value = self.context.pop_to_reg(self.masm, None)?;
677 let index = self.context.pop_to_reg(self.masm, None)?;
678 let base = self.context.any_gpr(self.masm)?;
679 let elem_addr = self.emit_compute_table_elem_addr(index.into(), base, &table_data)?;
680 // Set the initialized bit.
681 self.masm.or(
682 writable!(value.into()),
683 value.into(),
684 RegImm::i64(FUNCREF_INIT_BIT as i64),
685 ptr_type.try_into()?,
686 )?;
687
688 self.masm.store_ptr(value.into(), elem_addr)?;
689
690 self.context.free_reg(value);
691 self.context.free_reg(index);
692 self.context.free_reg(base);
693 Ok(())
694 }
695
696 /// Emit the `table.grow` operation.
697 pub fn emit_table_grow(&mut self, table_index: TableIndex) -> Result<()> {

Callers 4

visit_table_setMethod · 0.45
emit_table_fillMethod · 0.45
emit_table_copyMethod · 0.45
emit_table_initMethod · 0.45

Calls 12

i64Function · 0.85
OkFunction · 0.85
resolve_table_dataMethod · 0.80
pop_to_regMethod · 0.80
any_gprMethod · 0.80
free_regMethod · 0.80
tableMethod · 0.45
ptr_typeMethod · 0.45
orMethod · 0.45
try_intoMethod · 0.45
store_ptrMethod · 0.45

Tested by

no test coverage detected