Skip to content

sgns::runtime::WasmMemory

#include <wasm_memory.hpp>

Inherited by sgns::runtime::binaryen::WasmMemoryImpl

Public Functions

Name
virtual ~WasmMemory() =default
virtual void reset() =0
virtual WasmSize size() const =0
Return the size of the memory.
virtual void resize(WasmSize newSize) =0
virtual WasmPointer allocate(WasmSize size) =0
virtual boost::optional< WasmSize > deallocate(WasmPointer ptr) =0
virtual int8_t load8s(WasmPointer addr) const =0
virtual uint8_t load8u(WasmPointer addr) const =0
virtual int16_t load16s(WasmPointer addr) const =0
virtual uint16_t load16u(WasmPointer addr) const =0
virtual int32_t load32s(WasmPointer addr) const =0
virtual uint32_t load32u(WasmPointer addr) const =0
virtual int64_t load64s(WasmPointer addr) const =0
virtual uint64_t load64u(WasmPointer addr) const =0
virtual std::array< uint8_t, 16 > load128(WasmPointer addr) const =0
virtual base::Buffer loadN(WasmPointer addr, WasmSize n) const =0
virtual std::string loadStr(WasmPointer addr, WasmSize n) const =0
virtual void store8(WasmPointer addr, int8_t value) =0
virtual void store16(WasmPointer addr, int16_t value) =0
virtual void store32(WasmPointer addr, int32_t value) =0
virtual void store64(WasmPointer addr, int64_t value) =0
virtual void store128(WasmPointer addr, const std::array< uint8_t, 16 > & value) =0
virtual void storeBuffer(WasmPointer addr, gsl::span< const uint8_t > value) =0
virtual WasmSpan storeBuffer(gsl::span< const uint8_t > value) =0
allocates buffer in memory and copies value into memory

Public Attributes

Name
uint32_t kMaxMemorySize

Public Functions Documentation

function ~WasmMemory

virtual ~WasmMemory() =default

function reset

virtual void reset() =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::reset

Resets allocated and deallocated memory information

function size

virtual WasmSize size() const =0

Return the size of the memory.

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::size

function resize

virtual void resize(
    WasmSize newSize
) =0

Parameters:

  • newSize

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::resize

Resizes memory to the given size

function allocate

virtual WasmPointer allocate(
    WasmSize size
) =0

Parameters:

  • size allocated memory size

Return: address to allocated memory. If there is no available slot for such allocation, then -1 is returned

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::allocate

Allocates memory of given size and returns address in the memory

function deallocate

virtual boost::optional< WasmSize > deallocate(
    WasmPointer ptr
) =0

Parameters:

  • ptr address of deallocated memory

Return: size of deallocated memory or none if given address does not point to any allocated pieces of memory

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::deallocate

Deallocates memory in provided region

function load8s

virtual int8_t load8s(
    WasmPointer addr
) const =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::load8s

Load integers from provided address

function load8u

virtual uint8_t load8u(
    WasmPointer addr
) const =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::load8u

function load16s

virtual int16_t load16s(
    WasmPointer addr
) const =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::load16s

function load16u

virtual uint16_t load16u(
    WasmPointer addr
) const =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::load16u

function load32s

virtual int32_t load32s(
    WasmPointer addr
) const =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::load32s

function load32u

virtual uint32_t load32u(
    WasmPointer addr
) const =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::load32u

function load64s

virtual int64_t load64s(
    WasmPointer addr
) const =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::load64s

function load64u

virtual uint64_t load64u(
    WasmPointer addr
) const =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::load64u

function load128

virtual std::array< uint8_t, 16 > load128(
    WasmPointer addr
) const =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::load128

function loadN

virtual base::Buffer loadN(
    WasmPointer addr,
    WasmSize n
) const =0

Parameters:

  • addr address in memory to load bytes
  • n number of bytes to be loaded

Return: Buffer of length N

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::loadN

Load bytes from provided address into the buffer of size n

function loadStr

virtual std::string loadStr(
    WasmPointer addr,
    WasmSize n
) const =0

Parameters:

  • addr address in memory to load bytes
  • n number of bytes

Return: string with data

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::loadStr

Load string from address into buffer of size n

function store8

virtual void store8(
    WasmPointer addr,
    int8_t value
) =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::store8

Store integers at given address of the wasm memory

function store16

virtual void store16(
    WasmPointer addr,
    int16_t value
) =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::store16

function store32

virtual void store32(
    WasmPointer addr,
    int32_t value
) =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::store32

function store64

virtual void store64(
    WasmPointer addr,
    int64_t value
) =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::store64

function store128

virtual void store128(
    WasmPointer addr,
    const std::array< uint8_t, 16 > & value
) =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::store128

function storeBuffer

virtual void storeBuffer(
    WasmPointer addr,
    gsl::span< const uint8_t > value
) =0

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::storeBuffer

function storeBuffer

virtual WasmSpan storeBuffer(
    gsl::span< const uint8_t > value
) =0

allocates buffer in memory and copies value into memory

Parameters:

  • value buffer to store

Return: full wasm pointer to allocated buffer

Reimplemented by: sgns::runtime::binaryen::WasmMemoryImpl::storeBuffer

Public Attributes Documentation

variable kMaxMemorySize

static uint32_t kMaxMemorySize                                      =
std::numeric_limits<uint32_t>::max();

Updated on 2026-03-04 at 13:10:43 -0800