Documentation
¶
Index ¶
- Constants
- Variables
- func GoFunctionIndexFromExitCode(exitCode ExitCode) int
- type ExecutionContextOffsetData
- type ExitCode
- type ModuleContextOffsetData
- func (m *ModuleContextOffsetData) GlobalInstanceOffset(i wasm.Index) Offset
- func (m *ModuleContextOffsetData) ImportedFunctionOffset(i wasm.Index) (executableOffset, moduleCtxOffset, typeIDOffset Offset)
- func (m *ModuleContextOffsetData) LocalMemoryBase() Offset
- func (m *ModuleContextOffsetData) LocalMemoryLen() Offset
- func (m *ModuleContextOffsetData) TableOffset(tableIndex int) Offset
- type Offset
- type Pool
Constants ¶
const ( // FunctionInstanceSize is the size of wazevo.functionInstance. FunctionInstanceSize = 24 // FunctionInstanceExecutableOffset is an offset of `executable` field in wazevo.functionInstance FunctionInstanceExecutableOffset = 0 // FunctionInstanceModuleContextOpaquePtrOffset is an offset of `moduleContextOpaquePtr` field in wazevo.functionInstance FunctionInstanceModuleContextOpaquePtrOffset = 8 // FunctionInstanceTypeIDOffset is an offset of `typeID` field in wazevo.functionInstance FunctionInstanceTypeIDOffset = 16 )
const ExitCodeMask = 0xff
Variables ¶
var ExecutionContextOffsets = ExecutionContextOffsetData{
ExitCodeOffset: 0,
CallerModuleContextPtr: 8,
OriginalFramePointer: 16,
OriginalStackPointer: 24,
GoReturnAddress: 32,
StackBottomPtr: 40,
GoCallReturnAddress: 48,
StackPointerBeforeGrow: 56,
StackGrowRequiredSize: 64,
MemoryGrowTrampolineAddress: 72,
StackGrowCallSequenceAddress: 80,
SavedRegistersBegin: 96,
GoFunctionCallCalleeModuleContextOpaque: 1120,
GoFunctionCallStackBegin: 1128,
}
Functions ¶
Types ¶
type ExecutionContextOffsetData ¶
type ExecutionContextOffsetData struct { // ExitCodeOffset is an offset of `exitCode` field in wazevo.executionContext ExitCodeOffset Offset // CallerModuleContextPtr is an offset of `callerModuleContextPtr` field in wazevo.executionContext CallerModuleContextPtr Offset // CallerModuleContextPtr is an offset of `originalFramePointer` field in wazevo.executionContext OriginalFramePointer Offset // OriginalStackPointer is an offset of `originalStackPointer` field in wazevo.executionContext OriginalStackPointer Offset // GoReturnAddress is an offset of `goReturnAddress` field in wazevo.executionContext GoReturnAddress Offset // StackBottomPtr is an offset of `stackBottomPtr` field in wazevo.executionContext StackBottomPtr Offset // GoCallReturnAddress is an offset of `goCallReturnAddress` field in wazevo.executionContext GoCallReturnAddress Offset // GoCallReturnAddress is an offset of `stackPointerBeforeGoCall` field in wazevo.executionContext StackPointerBeforeGrow Offset // StackGrowRequiredSize is an offset of `stackGrowRequiredSize` field in wazevo.executionContext StackGrowRequiredSize Offset // MemoryGrowTrampolineAddress is an offset of `memoryGrowTrampolineAddress` field in wazevo.executionContext MemoryGrowTrampolineAddress Offset // StackGrowCallSequenceAddress is an offset of `stackGrowCallSequenceAddress` field in wazevo.executionContext StackGrowCallSequenceAddress Offset // GoCallReturnAddress is an offset of the first element of `savedRegisters` field in wazevo.executionContext SavedRegistersBegin Offset // GoFunctionCallCalleeModuleContextOpaque is an offset of `goFunctionCallCalleeModuleContextOpaque` field in wazevo.executionContext GoFunctionCallCalleeModuleContextOpaque Offset // GoFunctionCallStackBegin is an offset of the first element of `goFunctionCallStack` field in wazevo.executionContext GoFunctionCallStackBegin Offset }
ExecutionContextOffsetData allows the compilers to get the information about offsets to the fields of wazevo.executionContext, which are necessary for compiling various instructions. This is globally unique.
type ExitCode ¶
type ExitCode uint32
ExitCode is an exit code of an execution of a function.
const ( ExitCodeOK ExitCode = iota ExitCodeGrowStack ExitCodeGrowMemory ExitCodeUnreachable ExitCodeMemoryOutOfBounds // ExitCodeCallGoModuleFunction is an exit code for a call to an api.GoModuleFunction. ExitCodeCallGoModuleFunction // ExitCodeCallGoFunction is an exit code for a call to an api.GoFunction. ExitCodeCallGoFunction ExitCodeTableOutOfBounds ExitCodeIndirectCallNullPointer ExitCodeIndirectCallTypeMismatch )
type ModuleContextOffsetData ¶
type ModuleContextOffsetData struct { TotalSize int ModuleInstanceOffset, LocalMemoryBegin, ImportedMemoryBegin, ImportedFunctionsBegin, GlobalsBegin, TypeIDs1stElement, TablesBegin Offset }
ModuleContextOffsetData allows the compilers to get the information about offsets to the fields of wazevo.moduleContextOpaque, This is unique per module.
func NewModuleContextOffsetData ¶
func NewModuleContextOffsetData(m *wasm.Module) ModuleContextOffsetData
NewModuleContextOffsetData creates a ModuleContextOffsetData determining the structure of moduleContextOpaque for the given Module. The structure is described in the comment of wazevo.moduleContextOpaque.
func (*ModuleContextOffsetData) GlobalInstanceOffset ¶
func (m *ModuleContextOffsetData) GlobalInstanceOffset(i wasm.Index) Offset
GlobalInstanceOffset returns an offset of the i-th global instance.
func (*ModuleContextOffsetData) ImportedFunctionOffset ¶
func (m *ModuleContextOffsetData) ImportedFunctionOffset(i wasm.Index) ( executableOffset, moduleCtxOffset, typeIDOffset Offset, )
ImportedFunctionOffset returns an offset of the i-th imported function. Each item is stored as wazevo.functionInstance whose size matches FunctionInstanceSize.
func (*ModuleContextOffsetData) LocalMemoryBase ¶
func (m *ModuleContextOffsetData) LocalMemoryBase() Offset
LocalMemoryBase returns an offset of the first byte of the local memory.
func (*ModuleContextOffsetData) LocalMemoryLen ¶
func (m *ModuleContextOffsetData) LocalMemoryLen() Offset
LocalMemoryLen returns an offset of the length of the local memory buffer.
func (*ModuleContextOffsetData) TableOffset ¶
func (m *ModuleContextOffsetData) TableOffset(tableIndex int) Offset
TableOffset returns an offset of the i-th table instance.
type Pool ¶
type Pool[T any] struct { // contains filtered or unexported fields }
Pool is a pool of T that can be allocated and reset. This is useful to avoid unnecessary allocations.
func (*Pool[T]) Allocate ¶
func (p *Pool[T]) Allocate() *T
Allocate allocates a new T from the pool.