Skip to content

Class Documentation: WasmMemory

Ashton Meuser edited this page Aug 27, 2023 · 5 revisions

WasmMemory

Inherits: StreamPeer

Interact directly with exported WebAssembly module memory.

Description

Interact directly with exported WebAssembly module memory.

Methods

Return Method
int get_position ()
Dictionary inspect ()
Error grow ( int pages )
WasmMemory seek ( int p_pos )

Method Descriptions

int get_position ()

The current memory offset of the StreamPeer. Can be set using seek. Note that this position is advanced by reading from or writing to memory using any of the familiar StreamPeer methods. For example, writing an integer using put_64() will advance the position by eight bytes (64 bits).

Dictionary inspect ()

Inspect the minimum, maximum, and current memory sizes.

Error grow ( int pages )

Grow the memory by a number of pages. Per WebAssembly specifications, each memory page is 65536 bytes. Memory can be created by an instantiated Wasm module or created externally to be used as a module import. External memory must be grown before being used as a module import. Allocated memory can not be decreased i.e. grown by a negative number of pages.

WasmMemory seek ( int p_pos )

Set the memory offset of the StreamPeer. Values will be read from and written to this position. This method returns the SteamPeerWasm and can therefore be chained e.g. wasm.memory.seek(0).get_64().