Documentation
¶
Index ¶
- Constants
- func AssertSavedRegistersFit(end int64)
- func CheckStackGuardPage(s []byte)
- func DeterministicCompilationVerifierRandomizeIndexes(ctx context.Context) []int
- func GetCurrentFunctionIndex(ctx context.Context) int
- func GetCurrentFunctionName(ctx context.Context) string
- func GoFunctionIndexFromExitCode(exitCode ExitCode) int
- func NewDeterministicCompilationVerifierContext(ctx context.Context, localFunctions int) context.Context
- func PrintEnabledIndex(ctx context.Context) bool
- func PtrFromUintptr[T any](ptr uintptr) *T
- func ResetMap[K comparable, V any](m map[K]V) map[K]V
- func SetCurrentFunctionName(ctx context.Context, index int, functionName string) context.Context
- func TryTableIDFromExitCode(exitCode ExitCode) int
- func VerifyOrSetDeterministicCompilationContextValue(ctx context.Context, scope string, newValue string)
- type CatchClauseInstance
- type EhClause
- type EhEntry
- type ExitCode
- type IDedPool
- type ModuleContextOffsetData
- func (m *ModuleContextOffsetData) GlobalInstanceOffset(i wasm.Index) Offset
- func (m *ModuleContextOffsetData) ImportedFunctionOffset(i wasm.Index) (executableOffset, moduleCtxOffset, typeIDOffset Offset)
- func (m *ModuleContextOffsetData) LocalMemoryInstancePtrOffset(memoryIndex int) Offset
- func (m *ModuleContextOffsetData) MemoryOffset(memoryIndex int) Offset
- func (m *ModuleContextOffsetData) TableOffset(tableIndex int) Offset
- func (m *ModuleContextOffsetData) TagOffset(tagIndex int) Offset
- type Offset
- type Perfmap
- type Pool
- type Queue
- type ThrowFrame
- type TryTableInfo
- type VarLength
- type VarLengthPool
Constants ¶
const ( FrontEndLoggingEnabled = false SSALoggingEnabled = false RegAllocLoggingEnabled = false )
const ( PrintSSA = false PrintOptimizedSSA = 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 native.functionInstance. FunctionInstanceSize = 24 // FunctionInstanceExecutableOffset is an offset of `executable` field in native.functionInstance FunctionInstanceExecutableOffset = 0 // FunctionInstanceModuleContextOpaquePtrOffset is an offset of `moduleContextOpaquePtr` field in native.functionInstance FunctionInstanceModuleContextOpaquePtrOffset = 8 // FunctionInstanceTypeIDOffset is an offset of `typeID` field in native.functionInstance FunctionInstanceTypeIDOffset = 16 )
const ExitCodeMask = 0xff
const NeedFunctionNameInContext = PrintSSA || PrintOptimizedSSA || PrintSSAToBackendIRLowering || PrintRegisterAllocated || PrintFinalizedMachineCode || PrintMachineCodeHexPerFunction || DeterministicCompilationVerifierEnabled || PerfMapEnabled
nolint
const PerfMapEnabled = false
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 AssertSavedRegistersFit ¶ added in v0.2.0
func AssertSavedRegistersFit(end int64)
AssertSavedRegistersFit panics if a save/restore layout that ends at absolute offset end (exclusive) within native.executionContext would run past savedRegisters and into the fields after it -- which, since the store is a raw offset off the execution context pointer, would silently corrupt trampoline addresses and guest state rather than fault. Every backend layout of that region goes through here; see ExecutionContextOffsetSavedRegistersEnd.
func CheckStackGuardPage ¶
func CheckStackGuardPage(s []byte)
CheckStackGuardPage checks the given stack guard page is not corrupted.
func DeterministicCompilationVerifierRandomizeIndexes ¶
DeterministicCompilationVerifierRandomizeIndexes randomizes the indexes for the deterministic compilation verifier. Returns a slice that maps an index to the randomized index.
func GetCurrentFunctionIndex ¶
GetCurrentFunctionIndex returns the current function index.
func GetCurrentFunctionName ¶
GetCurrentFunctionName returns the current function name.
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 PrintEnabledIndex ¶
PrintEnabledIndex returns true if the current function index is the print target.
func PtrFromUintptr ¶
PtrFromUintptr resurrects the original *T from the given uintptr. The caller of this function MUST be sure that ptr is valid.
func ResetMap ¶
func ResetMap[K comparable, V any](m map[K]V) map[K]V
ResetMap resets the map to an empty state, or creates a new map if it is nil.
func SetCurrentFunctionName ¶
SetCurrentFunctionName sets the current function name to the given `functionName`.
func TryTableIDFromExitCode ¶
TryTableIDFromExitCode extracts the try-table ID from an ExitCodeTryTableEnter exit code. Uses the same encoding as GoFunctionIndexFromExitCode (upper 24 bits).
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 CatchClauseInstance ¶
type CatchClauseInstance struct {
Kind byte // wasm.CatchKindCatch, etc.
TagIndex uint32 // module-local tag index
}
CatchClauseInstance is a runtime catch clause with resolved tag index.
type EhClause ¶
type EhClause struct {
// Kind is one of wasm.CatchKindCatch, CatchKindCatchRef, CatchKindCatchAll,
// CatchKindCatchAllRef.
Kind byte
// TagIndex is the module-local tag index (meaningful for Catch/CatchRef only).
TagIndex uint32
// LandingPad is the executable offset of this clause's handler block.
// Function-relative as constructed by the compiler; rebased to an
// absolute address (like sourceMap.executableOffsets) when the
// compiledModule's executable is finalized / deserialized from cache.
LandingPad uintptr
}
EhClause is one compiled catch clause belonging to an EhEntry. Unlike the interpreter's exceptionTableCatchClause (which has a single targetPC per clause), the compiled analogue needs a per-clause LandingPad because the native frontend compiles one dedicated handler block per catch clause (each reloading a different set of exception params / exnref and jumping to a different wasm target block).
type EhEntry ¶
type EhEntry struct {
// StartOffset/EndOffset delimit one contiguous run of native code
// belonging to this try_table's body: any return address in
// [StartOffset, EndOffset) is considered "inside" this try for the
// purposes of exception matching. Function-relative as constructed;
// rebased to absolute addresses at the same time as LandingPad.
//
// A single try_table may be represented by *multiple* EhEntry values
// (one per contiguous run) if block layout did not keep its body's
// native code contiguous; all such runs share the same Clauses and
// TryTableID.
StartOffset, EndOffset uintptr
// Clauses are this try_table's catch clauses, in declaration order (the
// same order used for first-match semantics today).
Clauses []EhClause
// TryTableID indexes into compiledModule.tryTableInfo, giving access to
// NumLocals/ReuseLocals so the throw path can correctly restore
// execCtx.localsSaveAreaPtr when unwinding past an abandoned frame that
// had its own (now-discarded) locals save area.
TryTableID int
}
EhEntry is one PC-range entry in a function's exception side table: the compiled analogue of the interpreter's exceptionTableEntry (interpreter/interpreter.go). Entries for a given function are stored in *encounter order* -- i.e. a nested try_table's entry is appended after its lexically-enclosing try_table's entry, exactly mirroring how the interpreter builds its exceptionTable during lowering. A throw searches a function's entries **backwards**, so this ordering alone (no separate depth field) gives innermost-try-first matching, identical to searchExceptionTable's `for i := len(table) - 1; i >= 0; i--` loop.
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 ExitCodeMemoryWait32 ExitCodeMemoryWait64 ExitCodeMemoryNotify ExitCodeUnalignedAtomic // ExitCodeThrowAlloc is the first phase of wasm throw: Go allocates the // Exception heap object (with Params sized to the tag's param count) and // writes its Params data pointer to execCtx.exceptionParamsPtr. // Compiled code then stores params directly into the Exception.Params slice, // followed by ExitCodeThrow to search for a matching handler. ExitCodeThrowAlloc // ExitCodeThrow is the shared throw/throw_ref exit code. // The exnref is passed on the stack. The handler searches for a // matching catch clause and restores the stack checkpoint. ExitCodeThrow // ExitCodeNullReference is an exit code for a null reference trap (throw_ref with null exnref). ExitCodeNullReference // ExitCodeTryTableEnter is an exit code for entering a try_table block. // The catch clause info is encoded in the upper bits. The dispatch loop // saves the current SP/FP/returnAddress as a try handler checkpoint. ExitCodeTryTableEnter // ExitCodeTryTableLeave is an exit code for leaving a try_table block. // The dispatch loop pops the most recent try handler. ExitCodeTryTableLeave // ExitCodeGCCheck is the shared exit code for the GC proposal's runtime type checks: ref.test, // ref.cast, and the subtype-aware call_indirect check. Which one is meant is the trampoline's mode // operand; see gcCheckMode. ExitCodeGCCheck )
type IDedPool ¶
type IDedPool[T any] struct { // contains filtered or unexported fields }
IDedPool is a pool of T that can be allocated and reset, with a way to get T by an ID.
func NewIDedPool ¶
NewIDedPool returns a new IDedPool.
func (*IDedPool[T]) GetOrAllocate ¶
GetOrAllocate returns the T with the given id.
func (*IDedPool[T]) MaxIDEncountered ¶
MaxIDEncountered returns the maximum id encountered so far.
type ModuleContextOffsetData ¶
type ModuleContextOffsetData struct {
TotalSize int
ModuleInstanceOffset,
MemoriesBegin,
ImportedFunctionsBegin,
GlobalsBegin,
TypeIDs1stElement,
TablesBegin,
TagsBegin,
BeforeListenerTrampolines1stElement,
AfterListenerTrampolines1stElement,
DataInstances1stElement,
ElementInstances1stElement Offset
}
ModuleContextOffsetData allows the compilers to get the information about offsets to the fields of native.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 native.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 native.functionInstance whose size matches FunctionInstanceSize.
func (*ModuleContextOffsetData) LocalMemoryInstancePtrOffset ¶ added in v0.2.0
func (m *ModuleContextOffsetData) LocalMemoryInstancePtrOffset(memoryIndex int) Offset
LocalMemoryInstancePtrOffset returns the offset, within the memoryIndex-th local memory's record, of the *wasm.MemoryInstance pointer field (only meaningful for a local, i.e. non-imported, memory -- see MemoriesBegin).
func (*ModuleContextOffsetData) MemoryOffset ¶ added in v0.2.0
func (m *ModuleContextOffsetData) MemoryOffset(memoryIndex int) Offset
MemoryOffset returns the offset of the memoryIndex-th memory's record.
func (*ModuleContextOffsetData) TableOffset ¶
func (m *ModuleContextOffsetData) TableOffset(tableIndex int) Offset
TableOffset returns an offset of the i-th table instance.
func (*ModuleContextOffsetData) TagOffset ¶
func (m *ModuleContextOffsetData) TagOffset(tagIndex int) Offset
TagOffset returns an offset of the i-th tag instance pointer.
type Offset ¶
type Offset int32
Offset represents an offset of a field of a struct.
const ( // ExecutionContextOffsetExitCodeOffset is an offset of `exitCode` field in native.executionContext ExecutionContextOffsetExitCodeOffset Offset = 0 // ExecutionContextOffsetGCPause is the flag a loop header polls so a collection can stop the world: the // collector writes 1 into it and compiled code calls the GC trampoline when it sees one. It sits in the // padding after the exit code, and the safepoint reuses the GC trampoline rather than adding a second // address field, so the collector costs this struct nothing at all -- which matters because it is // embedded in the per-call callEngine, close enough to a Go size class boundary that eight bytes would // cost 256 per call. See wasm.GCSafepoint. ExecutionContextOffsetGCPause Offset = 4 // ExecutionContextOffsetCallerModuleContextPtr is an offset of `callerModuleContextPtr` field in native.executionContext ExecutionContextOffsetCallerModuleContextPtr Offset = 8 // ExecutionContextOffsetOriginalFramePointer is an offset of `originalFramePointer` field in native.executionContext ExecutionContextOffsetOriginalFramePointer Offset = 16 // ExecutionContextOffsetOriginalStackPointer is an offset of `originalStackPointer` field in native.executionContext ExecutionContextOffsetOriginalStackPointer Offset = 24 // ExecutionContextOffsetGoReturnAddress is an offset of `goReturnAddress` field in native.executionContext ExecutionContextOffsetGoReturnAddress Offset = 32 // ExecutionContextOffsetStackBottomPtr is an offset of `stackBottomPtr` field in native.executionContext. // NOTE: the value at this offset is the stack-bounds-check LIMIT, i.e. the // buffer bottom biased UP by backend.StackBoundsCheckMarginBytes (H7's // MARGIN); the prologue/go-call checks compare SP directly against it. See // callEngine.stackCheckLimitPtr and the proof on StackBoundsCheckMarginBytes. ExecutionContextOffsetStackBottomPtr Offset = 40 // ExecutionContextOffsetGoCallReturnAddress is an offset of `goCallReturnAddress` field in native.executionContext ExecutionContextOffsetGoCallReturnAddress Offset = 48 // ExecutionContextOffsetStackPointerBeforeGoCall is an offset of `StackPointerBeforeGoCall` field in native.executionContext ExecutionContextOffsetStackPointerBeforeGoCall Offset = 56 // ExecutionContextOffsetStackGrowRequiredSize is an offset of `stackGrowRequiredSize` field in native.executionContext ExecutionContextOffsetStackGrowRequiredSize Offset = 64 // ExecutionContextOffsetMemoryGrowTrampolineAddress is an offset of `memoryGrowTrampolineAddress` field in native.executionContext ExecutionContextOffsetMemoryGrowTrampolineAddress Offset = 72 // ExecutionContextOffsetStackGrowCallTrampolineAddress is an offset of `stackGrowCallTrampolineAddress` field in native.executionContext. ExecutionContextOffsetStackGrowCallTrampolineAddress Offset = 80 // ExecutionContextOffsetCheckModuleExitCodeTrampolineAddress is an offset of `checkModuleExitCodeTrampolineAddress` field in native.executionContext. ExecutionContextOffsetCheckModuleExitCodeTrampolineAddress Offset = 88 // ExecutionContextOffsetSavedRegistersBegin is an offset of the first element of `savedRegisters` field in native.executionContext ExecutionContextOffsetSavedRegistersBegin Offset = 96 // ExecutionContextOffsetSavedRegistersEnd is one past the last byte of `savedRegisters`. // // The field is sized to the largest layout either ISA actually writes there, not to a round // number: amd64's stackGrowSaveVRegs needs 464 bytes (29 registers x a 16-byte slot each) and // arm64's saveRequiredRegs needs 496 (stp/ldp-paired, see registerSaveRestoreSlots). The // remaining slack is deliberately small -- savedRegisters sits inside the per-call callEngine, // so every unused byte here is paid on every invocation, and the 1024 bytes this used to be // pushed that allocation a whole Go size class up. // // AssertSavedRegistersFit is what keeps it honest: both backends run it over every register // list they lay out, so a list that outgrows this bound fails loudly at code-generation time // (i.e. on the first module ever compiled) rather than silently writing over the fields below. ExecutionContextOffsetSavedRegistersEnd Offset = 608 // ExecutionContextOffsetGoFunctionCallCalleeModuleContextOpaque is an offset of `goFunctionCallCalleeModuleContextOpaque` field in native.executionContext ExecutionContextOffsetGoFunctionCallCalleeModuleContextOpaque Offset = 608 // ExecutionContextOffsetTableGrowTrampolineAddress is an offset of `tableGrowTrampolineAddress` field in native.executionContext ExecutionContextOffsetTableGrowTrampolineAddress Offset = 616 // ExecutionContextOffsetRefFuncTrampolineAddress is an offset of `refFuncTrampolineAddress` field in native.executionContext ExecutionContextOffsetRefFuncTrampolineAddress Offset = 624 ExecutionContextOffsetMemmoveAddress Offset = 632 ExecutionContextOffsetFramePointerBeforeGoCall Offset = 640 ExecutionContextOffsetMemoryWait32TrampolineAddress Offset = 648 ExecutionContextOffsetMemoryWait64TrampolineAddress Offset = 656 ExecutionContextOffsetMemoryNotifyTrampolineAddress Offset = 664 // ExecutionContextOffsetThrowAllocTrampolineAddress is the address of the // throw-alloc trampoline, which allocates the Exception heap object, // sets exceptionParamsPtr, and returns the exnref. ExecutionContextOffsetThrowAllocTrampolineAddress Offset = 672 ExecutionContextOffsetThrowTrampolineAddress Offset = 680 ExecutionContextOffsetTryTableEnterTrampolineAddress Offset = 688 ExecutionContextOffsetTryTableLeaveTrampolineAddress Offset = 696 // ExecutionContextOffsetExceptionRef holds the exnref of the caught exception, // used on the throw side and by catch_ref/catch_all_ref handlers. ExecutionContextOffsetExceptionRef Offset = 704 // ExecutionContextOffsetExceptionParamsPtr points into the Exception's // Params slice backing array. Used by both throw (store params) and // catch (load params) sides. ExecutionContextOffsetExceptionParamsPtr Offset = 712 // ExecutionContextOffsetCaughtExceptionClauseIdx is the matched catch clause index // written by handleException and read by compiled handler dispatch code. ExecutionContextOffsetCaughtExceptionClauseIdx Offset = 720 // ExecutionContextOffsetLocalsSaveAreaPtr points to a heap-allocated buffer // where locals are mirrored inside try_table bodies, so that handler blocks // can read throw-time local values after stack-clone restore. ExecutionContextOffsetLocalsSaveAreaPtr Offset = 728 // ExecutionContextOffsetInterruptCounter is an offset of the `interruptCounter` // field. Loop headers increment it and, under WithCloseOnContextDone with a // non-zero interrupt-check interval, only perform the module-exit-code check // when (counter & (interval-1)) == 0 (see frontend loop lowering). ExecutionContextOffsetInterruptCounter Offset = 736 // ExecutionContextOffsetInterruptCheckMask is an offset of the // `interruptCheckMask` field. It holds (interval-1); loop headers load it at // runtime (rather than baking it as a constant) so the amortized-check // frequency can be retuned per run/per loop without recompiling. ExecutionContextOffsetInterruptCheckMask Offset = 744 // ExecutionContextOffsetGCCheckTrampolineAddress is the address of the trampoline behind ref.test, // ref.cast and the subtype-aware call_indirect check. See nativeapi.ExitCodeGCCheck. ExecutionContextOffsetGCCheckTrampolineAddress Offset = 752 // ExecutionContextOffsetMemclrAddress is the offset of `memclrAddress`, the entry PC of // the Go runtime's memclrNoHeapPointers, called by the memory.fill lowering. ExecutionContextOffsetMemclrAddress Offset = 760 )
type Perfmap ¶
type Perfmap struct {
// contains filtered or unexported fields
}
Perfmap holds perfmap entries to be flushed into a perfmap file.
var PerfMap *Perfmap
func (*Perfmap) AddEntry ¶
AddEntry writes a perfmap entry directly into the perfmap file, not using the entries.
func (*Perfmap) AddModuleEntry ¶
AddModuleEntry adds a perfmap entry into the perfmap file. index is the index of the function in the module, offset is the offset of the function in the module, size is the size of the function, and name is the name of the function.
Note that the entries are not flushed into the perfmap file until Flush is called, and the entries are module-scoped; Perfmap must be locked until Flush is called.
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.
type Queue ¶
type Queue[T any] struct { Data []T // contains filtered or unexported fields }
Queue is the resettable queue where the underlying slice is reused.
type ThrowFrame ¶
ThrowFrame is one frame yielded by the throw-time stack walk (the exception-handling variant of unwindStack that additionally recovers each frame's own base, not just its return address). Populated differently per ISA:
- arm64 (backend/isa/arm64/unwind_stack.go): frames are chained via an in-stack frame_size word, so SP is directly, self-containedly recoverable during the walk; FP is unused (left zero) since arm64 has no dedicated frame-pointer register.
- amd64 (backend/isa/amd64/stack.go): frames are chained via the classic RBP chain, so FP (=RBP) is directly recoverable during the walk, but SP is not (amd64 has no on-stack frame_size marker); the caller (call_engine.go) computes SP = FP - FrameSize() for whichever single frame turns out to match, using the compiled function's FrameSize (backend.Machine.FrameSize) recorded at compile time.
type TryTableInfo ¶
type TryTableInfo struct {
CatchClauses []CatchClauseInstance
NumLocals int
// ReuseLocals is true for nested same-function try_tables that share
// the enclosing try_table's locals save area instead of allocating.
ReuseLocals bool
// FloorSize is the number of wasm operand-stack values present *below*
// this try_table's own block params at the point it is entered (the
// "operand floor" -- see docs/design/eh-side-table.md sec 4.1, category
// 4). These are values computed before the try that a catch
// continuation may still consume; nothing inside the try body can
// observe or mutate them (they are below its own floor), so a single
// entry-time snapshot would suffice to reconstruct them -- but doing so
// generally requires threading them through the catch target's block
// params (so the SSA builder can merge the normal-path value with a
// landing-pad reload), which touches every branch site that can target
// a catch label; that is deferred (see call_engine.go's
// activeCatchScope.savedRegisters doc comment).
//
// NOT currently used to skip the callee-saved-register snapshot/restore
// (an earlier version of this pass gated it on FloorSize == 0 and
// reverted that after it crashed a real C++/Emscripten-compiled module,
// see activeCatchScope's doc comment for the full story): FloorSize
// only accounts for *wasm-level* operand-stack values, but handler
// blocks unconditionally call reloadAfterCall(), which reads through
// moduleCtxPtrValue -- a per-function SSA value live across the entire
// function body regardless of the wasm operand stack, and just as
// vulnerable to living in a callee-saved register across the enter
// call as any category-4 value. So FloorSize is computed and
// serialized but currently inert; a future pass (Opus) should either
// give moduleCtxPtrValue (and anything else with a whole-function live
// range) its own memory-based reload in handler blocks -- symmetric to
// how locals are reloaded -- or otherwise account for it, before this
// field can safely gate anything.
FloorSize int
}
TryTableInfo holds try_table metadata assigned during compilation and looked up at runtime by try_table ID.
type VarLength ¶
type VarLength[T any] struct { // contains filtered or unexported fields }
VarLength is a variable length array that can be reused via a pool.
func NewNilVarLength ¶
NewNilVarLength returns a new VarLength[T] with a nil backing.
func (VarLength[T]) Append ¶
func (i VarLength[T]) Append(p *VarLengthPool[T], items ...T) VarLength[T]
Append appends items to the backing slice just like the `append` builtin function in Go.
type VarLengthPool ¶
type VarLengthPool[T any] struct { // contains filtered or unexported fields }
VarLengthPool is a pool of VarLength[T] that can be allocated and reset.
func NewVarLengthPool ¶
func NewVarLengthPool[T any]() VarLengthPool[T]
NewVarLengthPool returns a new VarLengthPool.
func (*VarLengthPool[T]) Allocate ¶
func (p *VarLengthPool[T]) Allocate(knownMin int) VarLength[T]
Allocate allocates a new VarLength[T] from the pool.