Documentation
¶
Index ¶
- Constants
- func CheckStackGuardPage(s []byte)
- func DeterministicCompilationVerifierGetRandomizedLocalFunctionIndex(ctx context.Context, index int) int
- func DeterministicCompilationVerifierRandomizeIndexes(ctx context.Context)
- func EnableHighRegisterPressure(ctx context.Context) context.Context
- func GetCurrentFunctionName(ctx context.Context) string
- func GoFunctionIndexFromExitCode(exitCode ExitCode) int
- func IsHighRegisterPressure(ctx context.Context) bool
- func NewDeterministicCompilationVerifierContext(ctx context.Context, localFunctions int) context.Context
- func SetCurrentFunctionName(ctx context.Context, functionName string) context.Context
- func VerifyOrSetDeterministicCompilationContextValue(ctx context.Context, scope string, newValue string)
- 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 ( FrontEndLoggingEnabled = false SSALoggingEnabled = false RegAllocLoggingEnabled = false )
const ( PrintSSA = false PrintOptimizedSSA = false PrintBlockLaidOutSSA = false PrintSSAToBackendIRLowering = false PrintRegisterAllocated = false PrintFinalizedMachineCode = false PrintMachineCodeHexPerFunction = printMachineCodeHexPerFunctionUnmodified || PrintMachineCodeHexPerFunctionDisassemblable //nolint // PrintMachineCodeHexPerFunctionDisassemblable prints the machine code while modifying the actual result // to make it disassemblable. This is useful when debugging the final machine code. See the places where this is used for detail. // When this is enabled, functions must not be called. PrintMachineCodeHexPerFunctionDisassemblable = false )
const ( // StackGuardCheckEnabled enables the stack guard check to ensure that our stack bounds check works correctly. StackGuardCheckEnabled = false StackGuardCheckGuardPageSize = 8096 )
----- Stack Guard Check -----
const ( // DeterministicCompilationVerifierEnabled enables the deterministic compilation verifier. This is disabled by default // since the operation is expensive. But when in doubt, enable this to make sure the compilation is deterministic. DeterministicCompilationVerifierEnabled = false DeterministicCompilationVerifyingIter = 5 )
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
const NeedFunctionNameInContext = PrintSSA || PrintOptimizedSSA || PrintBlockLaidOutSSA || PrintSSAToBackendIRLowering || PrintRegisterAllocated || PrintFinalizedMachineCode || PrintMachineCodeHexPerFunction || DeterministicCompilationVerifierEnabled
nolint
const ( // SSAValidationEnabled enables the SSA validation. This is disabled by default since the operation is expensive. SSAValidationEnabled = false )
----- Validations -----
Variables ¶
This section is empty.
Functions ¶
func CheckStackGuardPage ¶
func CheckStackGuardPage(s []byte)
CheckStackGuardPage checks the given stack guard page is not corrupted.
func DeterministicCompilationVerifierGetRandomizedLocalFunctionIndex ¶
func DeterministicCompilationVerifierGetRandomizedLocalFunctionIndex(ctx context.Context, index int) int
DeterministicCompilationVerifierGetRandomizedLocalFunctionIndex returns the randomized index for the given `index` which is assigned by DeterministicCompilationVerifierRandomizeIndexes.
func DeterministicCompilationVerifierRandomizeIndexes ¶
DeterministicCompilationVerifierRandomizeIndexes randomizes the indexes for the deterministic compilation verifier. To get the randomized index, use DeterministicCompilationVerifierGetRandomizedLocalFunctionIndex.
func EnableHighRegisterPressure ¶
EnableHighRegisterPressure enables the high register pressure mode.
func GetCurrentFunctionName ¶
GetCurrentFunctionName returns the current function name.
func IsHighRegisterPressure ¶
IsHighRegisterPressure returns true if the current compilation is under high register pressure.
func NewDeterministicCompilationVerifierContext ¶
func NewDeterministicCompilationVerifierContext(ctx context.Context, localFunctions int) context.Context
NewDeterministicCompilationVerifierContext creates a new context with the deterministic compilation verifier used per wasm.Module.
func SetCurrentFunctionName ¶
SetCurrentFunctionName sets the current function name to the given `functionName`.
func VerifyOrSetDeterministicCompilationContextValue ¶
func VerifyOrSetDeterministicCompilationContextValue(ctx context.Context, scope string, newValue string)
VerifyOrSetDeterministicCompilationContextValue verifies that the `newValue` is the same as the previous value for the given `scope` and the current function name. If the previous value doesn't exist, it sets the value to the given `newValue`.
If the verification fails, this prints the diff and exits the process.
Types ¶
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 ExitCodeIntegerDivisionByZero ExitCodeIntegerOverflow ExitCodeInvalidConversionToInteger ExitCodeCheckModuleExitCode ExitCodeCallListenerBefore ExitCodeCallListenerAfter ExitCodeCallGoModuleFunctionWithListener ExitCodeCallGoFunctionWithListener ExitCodeTableGrow ExitCodeRefFunc )
type ModuleContextOffsetData ¶
type ModuleContextOffsetData struct { TotalSize int ModuleInstanceOffset, LocalMemoryBegin, ImportedMemoryBegin, ImportedFunctionsBegin, GlobalsBegin, TypeIDs1stElement, TablesBegin, BeforeListenerTrampolines1stElement, AfterListenerTrampolines1stElement, DataInstances1stElement, ElementInstances1stElement 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, withListener bool) 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 Offset ¶
type Offset int32
Offset represents an offset of a field of a struct.
const ( // ExecutionContextOffsetExitCodeOffset is an offset of `exitCode` field in wazevo.executionContext ExecutionContextOffsetExitCodeOffset Offset = 0 // ExecutionContextOffsetCallerModuleContextPtr is an offset of `callerModuleContextPtr` field in wazevo.executionContext ExecutionContextOffsetCallerModuleContextPtr Offset = 8 // ExecutionContextOffsetOriginalFramePointer is an offset of `originalFramePointer` field in wazevo.executionContext ExecutionContextOffsetOriginalFramePointer Offset = 16 // ExecutionContextOffsetOriginalStackPointer is an offset of `originalStackPointer` field in wazevo.executionContext ExecutionContextOffsetOriginalStackPointer Offset = 24 // ExecutionContextOffsetGoReturnAddress is an offset of `goReturnAddress` field in wazevo.executionContext ExecutionContextOffsetGoReturnAddress Offset = 32 // ExecutionContextOffsetStackBottomPtr is an offset of `stackBottomPtr` field in wazevo.executionContext ExecutionContextOffsetStackBottomPtr Offset = 40 // ExecutionContextOffsetGoCallReturnAddress is an offset of `goCallReturnAddress` field in wazevo.executionContext ExecutionContextOffsetGoCallReturnAddress Offset = 48 // ExecutionContextOffsetStackPointerBeforeGoCall is an offset of `StackPointerBeforeGoCall` field in wazevo.executionContext ExecutionContextOffsetStackPointerBeforeGoCall Offset = 56 // ExecutionContextOffsetStackGrowRequiredSize is an offset of `stackGrowRequiredSize` field in wazevo.executionContext ExecutionContextOffsetStackGrowRequiredSize Offset = 64 // ExecutionContextOffsetMemoryGrowTrampolineAddress is an offset of `memoryGrowTrampolineAddress` field in wazevo.executionContext ExecutionContextOffsetMemoryGrowTrampolineAddress Offset = 72 // ExecutionContextOffsetStackGrowCallTrampolineAddress is an offset of `stackGrowCallTrampolineAddress` field in wazevo.executionContext. ExecutionContextOffsetStackGrowCallTrampolineAddress Offset = 80 // ExecutionContextOffsetCheckModuleExitCodeTrampolineAddress is an offset of `checkModuleExitCodeTrampolineAddress` field in wazevo.executionContext. ExecutionContextOffsetCheckModuleExitCodeTrampolineAddress Offset = 88 // ExecutionContextOffsetSavedRegistersBegin is an offset of the first element of `savedRegisters` field in wazevo.executionContext ExecutionContextOffsetSavedRegistersBegin Offset = 96 // ExecutionContextOffsetGoFunctionCallCalleeModuleContextOpaque is an offset of `goFunctionCallCalleeModuleContextOpaque` field in wazevo.executionContext ExecutionContextOffsetGoFunctionCallCalleeModuleContextOpaque Offset = 1120 // ExecutionContextOffsetTableGrowTrampolineAddress is an offset of `tableGrowTrampolineAddress` field in wazevo.executionContext ExecutionContextOffsetTableGrowTrampolineAddress Offset = 1128 // ExecutionContextOffsetRefFuncTrampolineAddress is an offset of `refFuncTrampolineAddress` field in wazevo.executionContext ExecutionContextOffsetRefFuncTrampolineAddress Offset = 1136 ExecutionContextOffsetMemmoveAddress Offset = 1144 )
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 NewPool ¶
NewPool returns a new Pool. resetFn is called when a new T is allocated in Pool.Allocate.
func (*Pool[T]) Allocate ¶
func (p *Pool[T]) Allocate() *T
Allocate allocates a new T from the pool.