ReviewOS

home-lang/home

perf(ts-emit): JIT-friendly JS output driven by sound types

#819
Open chris opened this 9 days ago ·
9 days ago

Problem

The cheapest way to use sound types today needs no JSC fork: when the checker knows types for certain, the TS→JS printer can emit code in the shapes JSC's JIT optimizes best. Right now the emitter only erases types. Shapes worth targeting: every declared class field initialized in the constructor in declaration order (stable structures), int-typed arithmetic, typed arrays for sound number[], and no delete / shape-changing patterns.

Evidence (origin/main @ d4b219507)

Scope

  • Behind sound mode, add emit transforms that preserve semantics while improving shapes: field pre-initialization, int arithmetic hints, typed-array lowering for proven numeric arrays.
  • Each transform is individually gated so its effect can be measured.
  • Keep default (tsc/Bun parity) emit byte-identical.

Acceptance criteria

  • Each transform has an emit test and a semantic-equivalence test.
  • Measured speedup (or none) per transform on the compute benchmarks, recorded in the PR.
  • TS→JS emit parity suite unchanged with sound mode off.

Depends on: #784 Related: #818 Part of #814.

Sign in to comment on this issue.