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)
| 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<()> { |
no test coverage detected