alloc

abstract fun alloc(n: Int): WasmPointer(source)
abstract fun alloc(n: String): WasmPointer(source)

Attempts to allocate the given number of bytes from the pstack. On success, it zeroes out a block of memory of the given size, adjusts the pstack pointer, and returns a pointer to the memory. On error, returns throws a WasmAllocError. The memory must eventually be released using pstack.restore().

The n may be a string accepted by wasm.sizeofIR(), and any string value not accepted by that function will trigger a WasmAllocError exception.

This method always adjusts the given value to be a multiple of 8 bytes because failing to do so can lead to incorrect results when reading and writing 64-bit values from/to the WASM heap. Similarly, the returned address is always 8-byte aligned.