wasmtime

package
v1.6.5-rc47 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecCustom   byte = 0
	SecType     byte = 1
	SecImport   byte = 2
	SecFunction byte = 3
	SecTable    byte = 4
	SecMemory   byte = 5
	SecGlobal   byte = 6
	SecExport   byte = 7
	SecStart    byte = 8
	SecElement  byte = 9
	SecCode     byte = 10
	SecData     byte = 11
)
View Source
const MaxFuelInStore = 1024 * 1024 * 1024

Variables

View Source
var (
	ErrInvalidWasmCode       = errors.New("invalid wasm code")
	ErrFailedToNewWasmModule = errors.New("failed to new wasm module")
	ErrInstanceNotStarted    = errors.New("instance not started")
	ErrInvalidExportFunc     = errors.New("invalid export func")
	ErrInvalidExportMem      = errors.New("invalid export memory")
	ErrInvalidImportFunc     = errors.New("invalid import func")
	ErrMemAccessOverflow     = errors.New("memory access overflow")
	ErrUnknownABIName        = errors.New("unknown abi name")
)

Functions

func DecodeULeb128

func DecodeULeb128(value []byte) uint32

DecodeULeb128 decodes an unsigned LEB128 value to an unsigned int32 value. Returns the result as a uint32.

func LoadCustomSections

func LoadCustomSections(data []byte) (map[string]CustomSection, int, error)

func NewWasmtimeInstance

func NewWasmtimeInstance(vm *VM, mod *Module) types.Instance

func NewWasmtimeVM

func NewWasmtimeVM(id string) types.VM

NewWasmtimeVM creates wasmtime vm

func ReadULEB128

func ReadULEB128(data []byte) (int, int)

ReadULEB128 read a uLEB128 at the starting position. Returns (number read, number of bytes read).

Types

type CustomSection

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

func NewCustomSection

func NewCustomSection(data []byte) CustomSection

NewCustomSection properly read name and data from a custom section.

type DwarfInfo

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

func ParseDwarf

func ParseDwarf(data []byte) *DwarfInfo

func (*DwarfInfo) GetLineReader

func (d *DwarfInfo) GetLineReader() *dwarf.LineReader

func (*DwarfInfo) SeekPC

func (d *DwarfInfo) SeekPC(pc uint64) *dwarf.LineEntry

type Instance

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

func (*Instance) Acquire

func (i *Instance) Acquire() bool

func (*Instance) Call

func (i *Instance) Call(name string, args ...interface{}) (interface{}, uint64, error)

func (*Instance) GetByte

func (i *Instance) GetByte(addr int32) (byte, error)

func (*Instance) GetExportsFunc

func (i *Instance) GetExportsFunc(name string) (types.Function, error)

func (*Instance) GetExportsMem

func (i *Instance) GetExportsMem(name string) ([]byte, error)

func (*Instance) GetMemory

func (i *Instance) GetMemory(addr, size int32) ([]byte, error)

func (*Instance) GetModule

func (i *Instance) GetModule() types.Module

func (*Instance) GetUint32

func (i *Instance) GetUint32(addr int32) (uint32, error)

func (*Instance) GetUserdata

func (i *Instance) GetUserdata() any

func (*Instance) HandleError

func (i *Instance) HandleError(err error)

func (*Instance) ID

func (i *Instance) ID() string

func (*Instance) Lock

func (i *Instance) Lock(data any)

func (*Instance) Malloc

func (i *Instance) Malloc(size int32) (int32, error)

func (*Instance) PutByte

func (i *Instance) PutByte(addr int32, v byte) error

func (*Instance) PutMemory

func (i *Instance) PutMemory(addr, size int32, data []byte) error

func (*Instance) PutUint32

func (i *Instance) PutUint32(addr int32, v uint32) error

func (*Instance) RegisterImports

func (i *Instance) RegisterImports(name string) error

func (*Instance) Release

func (i *Instance) Release()

func (*Instance) SetUserdata

func (i *Instance) SetUserdata(data any)

func (*Instance) Start

func (i *Instance) Start() error

func (*Instance) Started

func (i *Instance) Started() bool

func (*Instance) Stop

func (i *Instance) Stop()

func (*Instance) Unlock

func (i *Instance) Unlock()

type Module

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

func NewWasmtimeModule

func NewWasmtimeModule(vm *VM, mod *wasmtime.Module, code []byte) (*Module, error)

NewWasmtimeModule

func (*Module) GetABINameList

func (m *Module) GetABINameList() []string

func (*Module) Init

func (m *Module) Init()

func (*Module) NewInstance

func (m *Module) NewInstance() types.Instance

type VM

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

func (*VM) Close

func (vm *VM) Close() error

func (*VM) ID

func (vm *VM) ID() string

func (*VM) Init

func (vm *VM) Init()

func (*VM) Name

func (vm *VM) Name() string

func (*VM) NewModule

func (vm *VM) NewModule(code []byte) (types.Module, error)

Jump to

Keyboard shortcuts

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