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

native

package
v0.57.29 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package native runs kernel guests on wazero.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Function

type Function struct {
	// contains filtered or unexported fields
}

Function is an exported wazero guest function.

func (*Function) Call

func (f *Function) Call(ctx context.Context, args ...uint64) ([]uint64, error)

Call invokes the function as a new guest call of its instance.

type Global

type Global struct {
	// contains filtered or unexported fields
}

Global is an exported wazero guest global.

func (*Global) Get

func (g *Global) Get() uint64

Get returns the current value.

func (*Global) Set

func (g *Global) Set(val uint64)

Set changes the value; it has no effect on an immutable global.

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance is a running wazero guest and its active guest calls. Only the goroutine running the guest uses it.

func (*Instance) Close

func (i *Instance) Close(ctx context.Context) error

Close stops the instance and releases it.

func (*Instance) ExportedFunction

func (i *Instance) ExportedFunction(name string) engine.Function

ExportedFunction returns an exported function, or nil when the guest does not export it.

func (*Instance) ExportedGlobal

func (i *Instance) ExportedGlobal(name string) engine.Global

ExportedGlobal returns an exported global, or nil when the guest does not export it.

func (*Instance) Memory

func (i *Instance) Memory() engine.Memory

Memory returns the instance's linear memory, or nil when the guest has none.

type Memory

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

Memory is the linear memory of a wazero guest.

func (*Memory) Grow

func (m *Memory) Grow(pages uint32) (uint32, bool)

Grow adds pages of 64 KiB and returns the previous size in pages.

func (*Memory) Read

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

Read returns length bytes at offset. The slice aliases guest memory.

func (*Memory) ReadByteAt

func (m *Memory) ReadByteAt(offset uint32) (byte, bool)

ReadByteAt returns the byte at offset.

func (*Memory) ReadUint32Le

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

ReadUint32Le returns the little-endian uint32 at offset.

func (*Memory) ReadUint64Le

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

ReadUint64Le returns the little-endian uint64 at offset.

func (*Memory) Size

func (m *Memory) Size() uint32

Size returns the memory size in bytes.

func (*Memory) Write

func (m *Memory) Write(offset uint32, data []byte) bool

Write copies data to offset.

func (*Memory) WriteByteAt

func (m *Memory) WriteByteAt(offset uint32, val byte) bool

WriteByteAt writes one byte at offset.

func (*Memory) WriteUint32Le

func (m *Memory) WriteUint32Le(offset uint32, val uint32) bool

WriteUint32Le writes a little-endian uint32 at offset.

func (*Memory) WriteUint64Le

func (m *Memory) WriteUint64Le(offset uint32, val uint64) bool

WriteUint64Le writes a little-endian uint64 at offset.

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module is a compiled wazero module.

func (*Module) Close

func (m *Module) Close(ctx context.Context) error

Close releases the compiled module.

func (*Module) Instantiate

func (m *Module) Instantiate(ctx context.Context, name string) (engine.Instance, error)

Instantiate creates an instance of the module named name. The kernel calls the guest's entry itself, so instantiation starts nothing.

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

Runtime is a wazero runtime with threads enabled. Canceling the context of a running guest stops it, even while it computes.

func New

func New(ctx context.Context) *Runtime

New creates a Runtime.

func (*Runtime) Close

func (r *Runtime) Close(ctx context.Context) error

Close releases the runtime and every module it compiled.

func (*Runtime) Compile

func (r *Runtime) Compile(ctx context.Context, wasm []byte) (engine.Module, error)

Compile compiles a WebAssembly binary into a reusable module.

func (*Runtime) Define

func (r *Runtime) Define(ctx context.Context, module string, fns map[string]engine.HostFunction) error

Define provides fns to guests as the imports of module.

func (*Runtime) Snapshotter

func (r *Runtime) Snapshotter(ctx context.Context) engine.Snapshotter

Snapshotter returns the snapshotter of the host call running under ctx, or nil when its guest is not transformed with Asyncify.

Jump to

Keyboard shortcuts

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