wasmer

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 17 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
)

Variables

View Source
var (
	ErrAddrOverflow           = errors.New("addr overflow")
	ErrInstanceNotStart       = errors.New("instance has not started")
	ErrInstanceAlreadyStart   = errors.New("instance has already started")
	ErrInvalidParam           = errors.New("invalid param")
	ErrRegisterNotFunc        = errors.New("register a non-func object")
	ErrRegisterArgType        = errors.New("register func with invalid arg type")
	ErrInvalidReturnAddress   = errors.New("invalid return address")
	ErrMallocFunctionNotFound = errors.New("could not find memory allocate function")
)

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 NewWasmerVM

func NewWasmerVM(options ...VMOptions) api.WasmVM

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 Instance

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

func NewWasmerInstance

func NewWasmerInstance(vm *VM, module *Module, options ...InstanceOptions) (*Instance, error)

func (*Instance) Acquire

func (i *Instance) Acquire() bool

func (*Instance) GetByte

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

func (*Instance) GetData

func (i *Instance) GetData() interface{}

func (*Instance) GetExportsFunc

func (i *Instance) GetExportsFunc(funcName string) (api.WasmFunction, error)

func (*Instance) GetExportsMem

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

func (*Instance) GetMemory

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

func (*Instance) GetModule

func (i *Instance) GetModule() api.WasmModule

func (*Instance) GetUint32

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

func (*Instance) HandleError

func (i *Instance) HandleError(err error)

func (*Instance) Lock

func (i *Instance) Lock(data interface{})

func (*Instance) Malloc

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

func (*Instance) PutByte

func (i *Instance) PutByte(addr uint64, b byte) error

func (*Instance) PutMemory

func (i *Instance) PutMemory(addr uint64, size uint64, content []byte) error

func (*Instance) PutUint32

func (i *Instance) PutUint32(addr uint64, value uint32) error

func (*Instance) Release

func (i *Instance) Release()

func (*Instance) SetData

func (i *Instance) SetData(data interface{})

func (*Instance) Start

func (i *Instance) Start() error

func (*Instance) Stop

func (i *Instance) Stop()

func (*Instance) Unlock

func (i *Instance) Unlock()

type InstanceOptions

type InstanceOptions func(instance *Instance)

func InstanceWithDebug

func InstanceWithDebug(debug *dwarfInfo) InstanceOptions

func InstanceWithLogger

func InstanceWithLogger(logger logr.Logger) InstanceOptions

func InstanceWithMallocFunctionNames

func InstanceWithMallocFunctionNames(names ...string) InstanceOptions

func InstanceWithStartFunctionNames

func InstanceWithStartFunctionNames(names ...string) InstanceOptions

type Module

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

func NewWasmerModule

func NewWasmerModule(vm *VM, module *wasmerGo.Module, wasmBytes []byte, options ...ModuleOptions) *Module

func (*Module) GetABINameList

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

func (*Module) Init

func (m *Module) Init()

func (*Module) NewInstance

func (m *Module) NewInstance() (api.WasmInstance, error)

type ModuleOptions

type ModuleOptions func(module *Module)

func ModuleWithLogger

func ModuleWithLogger(logger logr.Logger) ModuleOptions

type VM

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

func (*VM) Close

func (w *VM) Close() (err error)

Close implements io.Closer

func (*VM) Init

func (w *VM) Init()

func (*VM) Name

func (w *VM) Name() string

func (*VM) NewModule

func (w *VM) NewModule(wasmBytes []byte) (api.WasmModule, error)

type VMOptions

type VMOptions func(vm *VM)

func VMWithLogger

func VMWithLogger(logger logr.Logger) VMOptions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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