Expand description
The Closure value descriptor (§4.10).
A closure value carries a function pointer (the JIT’d entry point of the
closure’s synthetic function) plus a captured environment (the values it
closes over, each a GcRef). A single CLOSURE descriptor serves every
closure because the per-closure knowledge (arity, env size) lives in the
payload.
Per §5.5, function and closure values are never equatable or hashable —
they have no structural identity. The equals/hash callbacks are None.
§Calling convention
The closure’s synthetic function takes the closure value itself as a hidden
first explicit parameter (after the implicit ctx): its MIR signature is
fn(ctx, closure_self, params...). At entry, a prologue loads each captured
value via praxis_closure_capture and
binds it to a local. Calling a closure value is an indirect call: the call
site reads fn_ptr via
praxis_closure_fn_ptr, then emits a
native call_indirect passing [ctx, closure, args...]. Keeping the
closure value intact at the call site (rather than spreading the env into
trailing params) makes the indirect call uniform per-arity and keeps the
closure self-contained for fault snapshots and future borrow/move semantics.
Structs§
- Closure
Payload - The runtime payload of a closure value: the function pointer plus the
captured environment values (one
GcRefper captured variable, in capture order established by the HIR capture analysis).
Statics§
- CLOSURE
- Descriptor for the
Closurevalue type (§4.10). Closures are never equatable or hashable (§5.5: function values have no structural identity).