(&mut self, mem: u32)
| 1775 | } |
| 1776 | |
| 1777 | fn visit_memory_grow(&mut self, mem: u32) -> Self::Output { |
| 1778 | let at = self.context.stack.ensure_index_at(1)?; |
| 1779 | let mem = MemoryIndex::from_u32(mem); |
| 1780 | // The stack at this point contains: [ delta ] |
| 1781 | // The desired state is |
| 1782 | // [ vmctx, delta, index ] |
| 1783 | let builtin = self.env.builtins.memory_grow::<M::ABI>()?; |
| 1784 | let builtin = self.prepare_builtin_defined_memory_arg(mem, at + 1, builtin)?; |
| 1785 | |
| 1786 | let heap = self.env.resolve_heap(mem); |
| 1787 | FnCall::emit::<M>(&mut self.env, self.masm, &mut self.context, builtin)?; |
| 1788 | |
| 1789 | // The memory32_grow builtin returns a pointer type, therefore we must |
| 1790 | // ensure that the return type is representative of the address space of |
| 1791 | // the heap type. |
| 1792 | match (self.env.ptr_type(), heap.index_type()) { |
| 1793 | (WasmValType::I64, WasmValType::I64) => Ok(()), |
| 1794 | // When the heap type is smaller than the pointer type, we adjust |
| 1795 | // the result of the memory32_grow builtin. |
| 1796 | (WasmValType::I64, WasmValType::I32) => { |
| 1797 | let top: Reg = self.context.pop_to_reg(self.masm, None)?.into(); |
| 1798 | self.masm.wrap(writable!(top), top)?; |
| 1799 | self.context.stack.push(TypedReg::i32(top).into()); |
| 1800 | Ok(()) |
| 1801 | } |
| 1802 | _ => Err(format_err!(CodeGenError::unsupported_32_bit_platform())), |
| 1803 | } |
| 1804 | } |
| 1805 | |
| 1806 | fn visit_data_drop(&mut self, data_index: u32) -> Self::Output { |
| 1807 | self.emit_data_drop(DataIndex::from_u32(data_index)) |
nothing calls this directly
no test coverage detected