Expand description
Per-program closure type collection + emission.
A $closure_<sig> rec-group type is needed wherever a function-typed value
occupies a slot — which is wider than the set of closures the module builds,
since the closure may be built by a caller in another package. The module’s
own closure literals and adapters cover what it constructs; three collectors
cover the shapes it only names:
CodegenAnalysis’s type funnel — every type the module mentions, after substitution: expression types, slot annotations, cast targets, plus the sigs the shape-dispatch paths build for themselves — a method call’s, from its own arity, and a property access’s() -> R/(W) -> voidaccessor branch, which is emitted whether or not an accessor is declared.class_member_sigs— local class members, whose ABI is fixed by the declaration whether or not the module mentions them.collect_from_dependencies— the imported surface of other packages.
Local interface and type declarations need no collector of their own: an
object shape’s payload is a uniform (ref null $Object) array and casts test
function fields signature-blind, so a member’s type never becomes a Wasm
type on its own. The one thing a member does fix is the sig its dispatch
goes through, and the funnel takes that from the call site — where the
generics are already substituted, which the declaration’s spelling isn’t.
Missing a sig is an internal compiler failure, so these over-collect
freely: emit_arity_closures dedups, and an unused shape costs one func
type plus one struct type.
Structs§
Functions§
- allocate_
methods - class_
member_ sigs - Closure signatures for each local class’s members — its own, and the ones it
inherits from a dependency class. An instance flowing through an
interface-typed receiver carries every method in its chain as a
$closure_<sig>value in the object-fields payload. - classify
- collect_
from_ dependencies - Consumer modules must re-declare these as a local closure rec group so
import signatures and cast sites using
(ref $closure_<sig>)resolve under WasmGC structural canonicalization. - declared_
funcs ref.funcin a const-expr requires declarative element coverage; these are the target indices.- emit_
arity_ closures - Structural canonicalization unifies prelude and consumer copies at instantiation time.
- emit_
env_ types - Must run after
box_types::emitso env-field lookups for boxed captures resolve. - emit_
func_ and_ struct_ types - emit_
method_ bodies - emit_
method_ function_ entries - Must be called after existing function-section entries so pre-allocated indices match.
- emit_
vtable_ global