Help us shape the future of Go! Take the 2026 Go Developer Survey

wasmbin

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package wasmbin rewrites the one part of a WebAssembly binary the engine needs to change: the limits of the module's own linear memory.

A browser cannot cap a memory the module defines itself, as wazero's WithMemoryLimitPages does; the cap has to be in the binary. Making the memory shared at the same time lets the engine's worker read and write the guest's memory directly while it serves WASI calls (the threads proposal's limits encoding: 0x01 min max, 0x03 min max shared).

Index

Constants

View Source
const MaxPages = 65536

MaxPages is the most pages a 32-bit memory can have.

Variables

View Source
var ErrInvalid = errors.New("invalid WebAssembly binary")

ErrInvalid is wrapped by every refusal of a binary.

Functions

func LimitMemory

func LimitMemory(mod []byte, maxPages uint32, shared bool) ([]byte, error)

LimitMemory returns a copy of mod whose defined memory has maximum maxPages (or its own maximum if lower), shared if asked. It refuses a module that imports its memory, defines more than one, or needs more than maxPages to start.

Types

This section is empty.

Jump to

Keyboard shortcuts

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