frontend

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package frontend implements the translation of WebAssembly to SSA IR using the ssa package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FunctionIndexToFuncRef

func FunctionIndexToFuncRef(idx wasm.Index) ssa.FuncRef

func SignatureForListener

func SignatureForListener(wasmSig *wasm.FunctionType) (*ssa.Signature, *ssa.Signature)

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.

func WasmTypeToSSAType

func WasmTypeToSSAType(vt wasm.ValueType) ssa.Type

WasmTypeToSSAType converts wasm.ValueType to ssa.Type.

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, ensureTermination bool, 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) SetInterruptCheckInterval

func (c *Compiler) SetInterruptCheckInterval(interval uint64)

SetInterruptCheckInterval sets the loop interrupt-check interval used when ensureTermination is active. interval must be 0 (check every iteration) or a power of two. 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

func (c *Compiler) WithTryTableMetadata(t tryTableMetadata) *Compiler

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 (*SharedTryTableMetadata) Table

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL