Documentation
¶
Overview ¶
Package frontend implements the translation of WebAssembly to SSA IR using the ssa package.
Index ¶
- Variables
- func FunctionIndexToFuncRef(idx wasm.Index) ssa.FuncRef
- func SignatureForListener(wasmSig *wasm.FunctionType) (*ssa.Signature, *ssa.Signature)
- func SignatureForWasmFunctionType(typ *wasm.FunctionType) ssa.Signature
- func WasmTypeToSSAType(vt wasm.ValueType) ssa.Type
- type Compiler
- func (c *Compiler) Init(idx, typIndex wasm.Index, typ *wasm.FunctionType, localTypes []wasm.ValueType, ...)
- func (c *Compiler) LowerToSSA()
- func (c *Compiler) PendingEhEntries() []EhPendingEntry
- func (c *Compiler) SetInlineLeaves(on bool)
- func (c *Compiler) SetVecMap(on bool)
- func (c *Compiler) TryTableMetadata() []nativeapi.TryTableInfo
- func (c *Compiler) WithTryTableMetadata(t tryTableMetadata) *Compiler
- type EhPendingClause
- type EhPendingEntry
- type SharedTryTableMetadata
Constants ¶
This section is empty.
Variables ¶
var ClampedDivHook func(lo, hi int64)
ClampedDivHook, when set, is told of each clamped division the frontend lowers.
var LoopYield = true
LoopYield turns emitPreemptCheck on. It is a variable only so the hang test can show that, without the check, its loops do hang the process.
var PopcountLoopHook func()
PopcountLoopHook, when set, is told of each popcount loop the frontend lowers.
VecPlanHook, when set, is told of each loop the frontend considers, and whether planVecMap took it. It exists for tests that survey a corpus.
var VecSumHook func(fn wasm.Index, pc int)
VecSumHook, when set, is told of each vector sum the frontend lowers.
Functions ¶
func SignatureForListener ¶
SignatureForListener returns the signatures for the listener functions.
func SignatureForWasmFunctionType ¶
func SignatureForWasmFunctionType(typ *wasm.FunctionType) ssa.Signature
SignatureForWasmFunctionType returns the ssa.Signature for the given wasm.FunctionType.
Types ¶
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler is in charge of lowering Wasm to SSA IR, and does the optimization on top of it in architecture-independent way.
func NewFrontendCompiler ¶
func NewFrontendCompiler(m *wasm.Module, ssaBuilder ssa.Builder, offset *nativeapi.ModuleContextOffsetData, listenerOn bool, sourceInfo bool) *Compiler
NewFrontendCompiler returns a frontend Compiler.
func (*Compiler) Init ¶
func (c *Compiler) Init(idx, typIndex wasm.Index, typ *wasm.FunctionType, localTypes []wasm.ValueType, body []byte, needListener bool, bodyOffsetInCodeSection uint64)
Init initializes the state of frontendCompiler and make it ready for a next function.
func (*Compiler) LowerToSSA ¶
func (c *Compiler) LowerToSSA()
LowerToSSA lowers the current function to SSA IR which will be held by ssaBuilder.
After calling this, the caller will be able to access the SSA info in *Compiler.ssaBuilder.
Note that this only does the naive lowering, and do not do any optimization, instead the caller is expected to do so.
func (*Compiler) PendingEhEntries ¶
func (c *Compiler) PendingEhEntries() []EhPendingEntry
PendingEhEntries returns the EhPendingEntry values accumulated while lowering the function most recently processed by LowerToSSA.
func (*Compiler) SetInlineLeaves ¶ added in v0.6.0
SetInlineLeaves turns off lowering small callees in place of their calls (see isInlinableLeaf), for tests that pin how a call is lowered. It must be called before lowering.
func (*Compiler) SetVecMap ¶ added in v0.7.0
SetVecMap turns off vectorizing loops (see lowerVecMap), for tests that pin how a loop is lowered. It must be called before lowering.
func (*Compiler) TryTableMetadata ¶
func (c *Compiler) TryTableMetadata() []nativeapi.TryTableInfo
TryTableMetadata returns the accumulated try_table metadata.
func (*Compiler) WithTryTableMetadata ¶
WithTryTableMetadata replaces the try_table metadata table implementation.
type EhPendingClause ¶
type EhPendingClause struct {
Kind byte
TagIndex uint32
HandlerBlkID ssa.BasicBlockID
}
EhPendingClause is one not-yet-resolved catch clause of an EhPendingEntry: the compiled handler block's ID stands in for its executable offset (EhClause.LandingPad), which is only known after this function has been fully compiled (Lower+RegAlloc+Finalize).
type EhPendingEntry ¶
type EhPendingEntry struct {
BodyBlkIDStart, BodyBlkIDEnd ssa.BasicBlockID
Clauses []EhPendingClause
// TryTableID is the module-local try-table ID assigned via
// tryTableMetadata.Append for this same try_table, letting the throw
// path look up NumLocals/ReuseLocals (nativeapi.TryTableInfo) for
// locals-save-area bookkeeping when unwinding past this try's frame.
TryTableID int
}
EhPendingEntry is one not-yet-resolved try_table body range, recorded by the frontend while lowering a try_table-with-catch. BodyBlkIDStart is the ID of the try body's first block (bodyBlk); BodyBlkIDEnd is the exclusive upper bound of every ssa.BasicBlockID allocated while lowering that body (including nested constructs and nested try_tables), captured via ssa.Builder.BlockIDMax() at the try_table's own `end`. Because the frontend allocates a try_table's handler blocks *before* its own bodyBlk (see the OpcodeTryTable lowering), [BodyBlkIDStart, BodyBlkIDEnd) never contains a handler-block ID, even though those IDs are numerically close.
The engine resolves this, after compiling the function, into one or more nativeapi.EhEntry values (one per contiguous run of the body's blocks in the final code layout -- see nativeapi.EhEntry's doc comment) using backend.Compiler.CompiledBlockOffsets().
type SharedTryTableMetadata ¶
type SharedTryTableMetadata struct {
// contains filtered or unexported fields
}
SharedTryTableMetadata is the thread-safe implementation for parallel compilation.
func NewSharedTryTableMetadata ¶
func NewSharedTryTableMetadata() *SharedTryTableMetadata
NewSharedTryTableMetadata creates a new SharedTryTableMetadata.
func (*SharedTryTableMetadata) Append ¶
func (s *SharedTryTableMetadata) Append(info nativeapi.TryTableInfo) int
func (*SharedTryTableMetadata) Table ¶
func (s *SharedTryTableMetadata) Table() []nativeapi.TryTableInfo