ReviewOS

home-lang/home

feat(aot): lower type-checked TypeScript (HIR) to native code for a statically resolvable subset

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

Problem

This is the plan's own AOT answer — home build --target=x64 my.ts (Phase 7 of TS_PARITY_PLAN.md), with an extern "js" escape hatch and a GC-vs-escape-analysis design spike. It is marked blocked on Phase 6, but Phase 6's coarse gate is now saturated (5,907/5,907). Today no code lowers TS or HIR to native — native codegen imports only ast, not hir. With sound types, the checker's types can drive real machine representations instead of JIT speculation. (New direction.)

Evidence (origin/main @ d4b219507)

Scope

  • Write the subset spec: which TS constructs lower (numbers, strings, classes with fixed shape, closures, generics via monomorphization, discriminated unions) and which fall back to the engine via extern "js".
  • Decide memory management (tracing GC vs. RC + escape analysis) in a short decision record.
  • Spike: fib.ts and a class/struct sample compile to native without JSC and match Node's output.

Acceptance criteria

  • Spec and decision record merged in docs/.
  • Spike samples build and run without JSC linked, output identical to Node.

Depends on: #784, #796, #797, #801 Part of #814.

Sign in to comment on this issue.