Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSSAUnsupported = errors.New("ssa lowering: unsupported wasm feature")
ErrSSAUnsupported is returned by LowerFunction (and the rest of the SSA pipeline) when a wasm function uses a feature the lowering / optimizer / emitter does not yet handle. Translate surfaces it as a hard build error; there is no longer a legacy direct-opcode fallback.
Functions ¶
func LowerFunction ¶
func LowerFunction(mod *wasm.Module, funcIdx uint32, name string, throwSet *ThrowSet) (resFn *ssa.Func, resErr error)
LowerFunction decodes a single wasm function body and produces an ssa.Func.
Anything not yet implemented returns ErrSSAUnsupported wrapped with the function index and the offending opcode; Translate fails the build with that message so the gap can be addressed in the SSA pipeline rather than worked around silently.
Types ¶
type ThrowSet ¶ added in v0.5.0
type ThrowSet struct {
// contains filtered or unexported fields
}
ThrowSet answers "can a call to this function leave an exception pending?" — the question the branch-based EH lowering asks at every call site to decide whether to emit a check-and-branch.
A function may throw when its body contains `throw` or `rethrow`, when it calls a may-throw function, or when it performs a `call_indirect` whose type could resolve to one (conservatively: any indirect call to a signature some may-throw function has). Host imports never throw: a wasm exception can only be raised by wasm code, and the generated host interfaces have no way to set the pending state.
Being conservative only costs a predictable branch on a flag that is almost always false, so the analysis stays simple: no attempt is made to prove that an enclosing catch_all swallows everything.
func ComputeThrowSet ¶ added in v0.5.0
ComputeThrowSet runs the analysis over a module. callees maps a function index to the indices it calls directly (the call graph codegen already builds); when nil the direct-call edges are rescanned here.
func (*ThrowSet) AnyThrows ¶ added in v0.5.0
AnyThrows reports whether the module contains any throwing code at all. When false the whole EH machinery (module state, call-site checks) can be skipped.
func (*ThrowSet) IndirectMayThrow ¶ added in v0.5.0
IndirectMayThrow reports whether a call_indirect of the given type index can leave an exception pending.