Expand description
Whole-program number-type inference.
Ling values are NaN-boxed: a u64 is either a raw f64 or a tagged pointer/
singleton. The naive code path tag-checks both operands on every arithmetic op
and branches to a runtime fallback. That overhead dominates numeric loops.
This pass recovers static type information the untyped MIR throws away. A local
is a number when every value that can flow into it is provably an f64.
Because Ling discards declared parameter types, parameter and return types are
inferred interprocedurally from call sites with a greatest fixpoint: assume
everything is a number, then retract that wherever a non-number can reach.
The JIT/AOT backends consult the result to emit raw fadd/fcmp/… with no tag
checks wherever both operands are known numbers, closing most of the gap to
native code.
Structs§
- Number
Types - Per-function static types: which local indices are proven numbers (
f64) or strict booleans (aTAG_TRUE/TAG_FALSEsingleton).
Functions§
- analyze
- Compute number-ness for every function in the program.