wasm

package
v0.19.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 4 Imported by: 2

Documentation

Overview

Package wasm provides the generic components used to build wazero plugins.

Index

Constants

View Source
const PageSize = 64 * 1024

PageSize is the size of memory pages in WebAssembly programs (64 KiB).

Variables

This section is empty.

Functions

func Read

func Read(memory api.Memory, offset, length uint32) []byte

Read returns a byte slice from a module memory. The function calls Read on the given memory and panics if offset/length are beyond the range of memory.

Types

type Memory

type Memory struct {
	api.Memory
	// contains filtered or unexported fields
}

Memory is an implementation of the api.Memory interface of wazero backed by a Go byte slice. The memory has a fixed size and cannot grow nor shrink.

This type is mostly useful in tests to construct memory areas where output parameters can be stored.

func NewFixedSizeMemory

func NewFixedSizeMemory(size uint32) *Memory

NewFixedSizeMemory constructs a Memory instance of size bytes aligned on the WebAssembly page size.

func (*Memory) Definition

func (mem *Memory) Definition() api.MemoryDefinition

func (*Memory) Grow

func (mem *Memory) Grow(uint32) (uint32, bool)

func (*Memory) Read

func (mem *Memory) Read(offset, length uint32) ([]byte, bool)

func (*Memory) ReadByte

func (mem *Memory) ReadByte(offset uint32) (byte, bool)

func (*Memory) ReadFloat32Le

func (mem *Memory) ReadFloat32Le(offset uint32) (float32, bool)

func (*Memory) ReadFloat64Le

func (mem *Memory) ReadFloat64Le(offset uint32) (float64, bool)

func (*Memory) ReadUint16Le

func (mem *Memory) ReadUint16Le(offset uint32) (uint16, bool)

func (*Memory) ReadUint32Le

func (mem *Memory) ReadUint32Le(offset uint32) (uint32, bool)

func (*Memory) ReadUint64Le

func (mem *Memory) ReadUint64Le(offset uint32) (uint64, bool)

func (*Memory) Size

func (mem *Memory) Size() uint32

func (*Memory) Write

func (mem *Memory) Write(offset uint32, value []byte) bool

func (*Memory) WriteByte

func (mem *Memory) WriteByte(offset uint32, value byte) bool

func (*Memory) WriteFloat32Le

func (mem *Memory) WriteFloat32Le(offset uint32, value float32) bool

func (*Memory) WriteFloat64Le

func (mem *Memory) WriteFloat64Le(offset uint32, value float64) bool

func (*Memory) WriteString

func (mem *Memory) WriteString(offset uint32, value string) bool

func (*Memory) WriteUint16Le

func (mem *Memory) WriteUint16Le(offset uint32, value uint16) bool

func (*Memory) WriteUint32Le

func (mem *Memory) WriteUint32Le(offset uint32, value uint32) bool

func (*Memory) WriteUint64Le

func (mem *Memory) WriteUint64Le(offset uint32, value uint64) bool

type SEGFAULT

type SEGFAULT struct{ Offset, Length uint32 }

SEGFAULT is an error type used as value in panics triggered by reading outside of the addressable memory of a program.

func (SEGFAULT) Error

func (err SEGFAULT) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL