Retrieves the size of the table, pushing the result to the value stack.
(&mut self, table_data: &TableData)
| 1485 | |
| 1486 | /// Retrieves the size of the table, pushing the result to the value stack. |
| 1487 | pub fn emit_compute_table_size(&mut self, table_data: &TableData) -> Result<()> { |
| 1488 | let size = self.context.any_gpr(self.masm)?; |
| 1489 | let ptr_size: OperandSize = self.env.ptr_type().try_into()?; |
| 1490 | |
| 1491 | self.masm.with_scratch::<IntScratch, _>(|masm, scratch| { |
| 1492 | if let Some(offset) = table_data.import_from { |
| 1493 | masm.load_ptr(masm.address_at_vmctx(offset)?, scratch.writable())?; |
| 1494 | } else { |
| 1495 | masm.mov(scratch.writable(), vmctx!(M).into(), ptr_size)?; |
| 1496 | }; |
| 1497 | |
| 1498 | let size_addr = |
| 1499 | masm.address_at_reg(scratch.inner(), table_data.current_elems_offset)?; |
| 1500 | masm.load(size_addr, writable!(size), table_data.current_elements_size) |
| 1501 | })?; |
| 1502 | |
| 1503 | let dst = TypedReg::new(table_data.index_type(), size); |
| 1504 | self.context.stack.push(dst.into()); |
| 1505 | Ok(()) |
| 1506 | } |
| 1507 | |
| 1508 | /// Retrieves the size of the memory, pushing the result to the value stack. |
| 1509 | fn load_memory_length(&mut self, heap_data: &HeapData, size_reg: Reg) -> Result<()> { |
no test coverage detected