Documentation ¶
Index ¶
- Constants
- Variables
- type Build
- func (b *Build) Close() (err error)
- func (b *Build) FinishInstance(prog *Program, maxMemorySize, entryFuncIndex int) (*Instance, error)
- func (b *Build) FinishProgram(sectionMap SectionMap, mod compile.Module, startFuncIndex int, entryFuncs bool, ...) (*Program, error)
- func (b *Build) FinishText(stackSize, stackUsage, globalsSize, memorySize int) error
- func (b *Build) GlobalsMemoryBuffer() interface{ ... }
- func (b *Build) ImportResolver() interface{ ... }
- func (b *Build) MemoryAlignment() int
- func (b *Build) ModuleWriter() io.Writer
- func (b *Build) ObjectMap() *object.CallMap
- func (b *Build) ReadStack(r io.Reader, types []wa.FuncType, funcTypeIndexes []uint32) error
- func (b *Build) TextBuffer() interface{ ... }
- type Filesystem
- type Instance
- func (inst *Instance) BeginMutation(textAddr uint64) (file interface{ ... }, err error)
- func (inst *Instance) Breakpoints() []uint64
- func (inst *Instance) CheckHaltedMutation(result wa.ScalarCategory) (uint64, error)
- func (inst *Instance) CheckMutation() error
- func (inst *Instance) Close() error
- func (inst *Instance) EntryAddr() uint32
- func (inst *Instance) ExportStack(textMap stack.TextMap) ([]byte, error)
- func (inst *Instance) Final() bool
- func (inst *Instance) Globals(prog *Program) ([]uint64, error)
- func (inst *Instance) GlobalsSize() int
- func (inst *Instance) MaxMemorySize() int
- func (inst *Instance) MemorySize() int
- func (inst *Instance) MonotonicTime() uint64
- func (inst *Instance) ReplaceCallStack(funcAddr uint32, funcArgs []uint64) error
- func (inst *Instance) Result() int32
- func (inst *Instance) SetBreakpoints(a []uint64)
- func (inst *Instance) SetEntryFunc(prog *Program, index int) error
- func (inst *Instance) SetFinal()
- func (inst *Instance) SetResult(n int32)
- func (inst *Instance) SetTrap(id trap.ID)
- func (inst *Instance) StackSize() int
- func (inst *Instance) StackUsage() int
- func (inst *Instance) Stacktrace(textMap stack.TextMap, funcTypes []wa.FuncType) ([]stack.Frame, error)
- func (inst *Instance) StartAddr() uint32
- func (inst *Instance) Store(name, progName string, prog *Program) error
- func (inst *Instance) TextAddr() uint64
- func (inst *Instance) Trap() trap.ID
- func (inst *Instance) Unstore() error
- type InstanceStorage
- type Program
- func (prog *Program) Breakpoints() []uint64
- func (prog *Program) Close() error
- func (prog *Program) LoadBuffers() (bs *snapshot.Buffers, err error)
- func (prog *Program) ModuleSize() int64
- func (prog *Program) NewModuleReader() io.Reader
- func (prog *Program) PageSize() int
- func (prog *Program) Random() bool
- func (prog *Program) ResolveEntryFunc(exportName string, started bool) (int, error)
- func (prog *Program) Store(name string) error
- func (prog *Program) Text() (file interface{ ... }, err error)
- func (prog *Program) TextSize() int
- type ProgramStorage
- type SectionMap
- type Storage
Constants ¶
const TextRevision = 0
Variables ¶
var ErrInvalidState = errors.New("instance state is invalid")
var Memory mem
Memory implements Storage. It doesn't support program or instance persistence.
Functions ¶
This section is empty.
Types ¶
type Build ¶
type Build struct {
// contains filtered or unexported fields
}
Build a program and optionally an instance. FinishText, FinishProgram and (optionally) FinishInstance must be called in that order.
func NewBuild ¶
func NewBuild(storage Storage, moduleSize, maxTextSize int, objectMap *object.CallMap, instance bool) (*Build, error)
NewBuild for a program and optionally an instance.
func (*Build) FinishInstance ¶
FinishInstance after FinishProgram. Applicable only if an instance storage was specified in NewBuild call.
func (*Build) FinishProgram ¶
func (b *Build) FinishProgram(sectionMap SectionMap, mod compile.Module, startFuncIndex int, entryFuncs bool, snap *snapshot.Snapshot, bufferSectionHeaderLength int) (*Program, error)
FinishProgram after module, stack, globals and memory have been populated.
func (*Build) FinishText ¶
FinishText after TextBuffer has been populated.
func (*Build) GlobalsMemoryBuffer ¶
GlobalsMemoryBuffer is valid after FinishText. It must be populated before FinishProgram is called.
func (*Build) ImportResolver ¶
func (*Build) MemoryAlignment ¶
MemoryAlignment of GlobalsMemoryBuffer.
func (*Build) ModuleWriter ¶
ModuleWriter is valid after NewBuild. The module must be written before FinishProgram is called.
type Filesystem ¶
type Filesystem struct {
// contains filtered or unexported fields
}
Filesystem implements Storage. It supports program and instance persistence.
func NewFilesystem ¶
func NewFilesystem(root string) (*Filesystem, error)
func NewFilesystemWithOwnership ¶
func NewFilesystemWithOwnership(root string, uid, gid int) (fs *Filesystem, err error)
func (*Filesystem) Close ¶
func (fs *Filesystem) Close() error
func (*Filesystem) Instances ¶
func (fs *Filesystem) Instances() ([]string, error)
func (*Filesystem) LoadInstance ¶
func (fs *Filesystem) LoadInstance(name string) (inst *Instance, err error)
func (*Filesystem) LoadProgram ¶
func (fs *Filesystem) LoadProgram(name string) (*Program, error)
func (*Filesystem) Programs ¶
func (fs *Filesystem) Programs() ([]string, error)
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is a program state. It may be undergoing mutation.
func NewInstance ¶
func (*Instance) BeginMutation ¶
BeginMutation must be invoked when mutation starts. CheckMutation and Close may be called during the mutation. The returned file handle is valid until the next Instance method call.
func (*Instance) Breakpoints ¶
Breakpoints are in ascending order and unique.
func (*Instance) CheckHaltedMutation ¶
func (inst *Instance) CheckHaltedMutation(result wa.ScalarCategory) (uint64, error)
CheckHaltedMutation is like CheckMutation, but it also returns the result of the top-level function. The result is undefined if the program terminated in some other way.
This is useful only with ReplaceCallStack, if you know that the program exits by returning.
func (*Instance) CheckMutation ¶
CheckMutation can be invoked after the mutation has ended.
func (*Instance) ExportStack ¶
func (*Instance) GlobalsSize ¶
func (*Instance) MaxMemorySize ¶
func (*Instance) MemorySize ¶
func (*Instance) MonotonicTime ¶
func (*Instance) ReplaceCallStack ¶
ReplaceCallStack with a "suspended" function call with given arguments. Pending start function, entry function, and existing suspended state are discarded. Arguments are not checked against function signature.
This is a low-level API primarily useful for testing.
func (*Instance) SetBreakpoints ¶
SetBreakpoints which must have been sorted and deduplicated.
func (*Instance) StackUsage ¶
func (*Instance) Stacktrace ¶
type InstanceStorage ¶
type InstanceStorage interface { Instances() (names []string, err error) LoadInstance(name string) (*Instance, error) // contains filtered or unexported methods }
func PersistentMemory ¶
func PersistentMemory(storage *Filesystem) InstanceStorage
PersistentMemory supports instance persistence by copying data to and from a Filesystem.
func PrepareInstances ¶
func PrepareInstances(ctx Context, storage InstanceStorage, bufsize int) InstanceStorage
PrepareInstances wraps an InstanceStorage. The wrapper creates instance resources in advance.
type Program ¶
func Snapshot ¶
func Snapshot(oldProg *Program, inst *Instance, buffers *snapshot.Buffers, suspended bool) (newProg *Program, err error)
Snapshot creates a new program from an instance. The instance must not be running.
func (*Program) Breakpoints ¶
Breakpoints are in ascending order and unique.
func (*Program) ModuleSize ¶
func (*Program) NewModuleReader ¶
func (*Program) ResolveEntryFunc ¶
ResolveEntryFunc index or the implicit _start function index. The started argument is disregarded if the program is a snapshot.
type ProgramStorage ¶
type ProgramStorage interface { Programs() (names []string, err error) // contains filtered or unexported methods }
func PreparePrograms ¶
func PreparePrograms(ctx Context, storage ProgramStorage, bufsize int) ProgramStorage
PreparePrograms wraps a ProgramStorage. The wrapper creates program resources in advance.
type SectionMap ¶
type Storage ¶
type Storage interface { ProgramStorage InstanceStorage LoadProgram(name string) (*Program, error) }
func CombinedStorage ¶
func CombinedStorage(prog ProgramStorage, inst InstanceStorage) Storage