Skip to content

Compact checker type metadata - #64774

Merged
Jake Bailey (jakebailey) merged 1 commit into
jakebailey/mem/generated-ast-accessorsfrom
jakebailey/mem/compact-type-headers
Oct 14, 2026
Merged

Jake Bailey (jakebailey) merged 1 commit into
jakebailey/mem/generated-ast-accessorsfrom
jakebailey/mem/compact-type-headers

Conversation

@jakebailey

@jakebailey Jake Bailey (jakebailey) commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Each type carries a self-referential interface solely to recover its concrete representation. Replace it with a compact concrete-kind tag, separate from the mutable semantic flags, and recover the concrete type from its offset-zero header.

  • Saves 16 bytes per type on 64-bit systems and removes redundant GC-visible pointer storage.
  • Casts are checked against the kind tag; offset-zero embedding is asserted at compile time.

Part of the memory optimization stack summarized in #64734.

Each type carries a self-referential interface solely to recover its
concrete representation. That costs space in every type and adds GC
pointer work even though the representation is fixed at construction.

A compact concrete-kind tag saves 16 bytes per type on 64-bit hosts.
Keep it separate from mutable semantic flags so casts stay valid as
checking discovers more information.
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 13, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to stack #64792 October 13, 2026 17:37
@jakebailey Jake Bailey (jakebailey) changed the title Compact checker type metadata Compact checker type metadata Each type carries a self-referential interface solely to recover its concrete representation. Replace it with a compact concrete-kind tag, separate from the mutable semantic flags, and recover the concrete type from its offset-zero header. - Saves **16 bytes per type on 64-bit systems** and removes redundant GC-visible pointer storage. - Casts are checked against the kind tag; offset-zero embedding is asserted at compile time. Oct 13, 2026
@jakebailey Jake Bailey (jakebailey) changed the title Compact checker type metadata Each type carries a self-referential interface solely to recover its concrete representation. Replace it with a compact concrete-kind tag, separate from the mutable semantic flags, and recover the concrete type from its offset-zero header. - Saves **16 bytes per type on 64-bit systems** and removes redundant GC-visible pointer storage. - Casts are checked against the kind tag; offset-zero embedding is asserted at compile time. Compact checker type metadata Oct 13, 2026
@jakebailey
Jake Bailey (jakebailey) marked this pull request as ready for review October 13, 2026 17:41
Copilot AI balanced review requested due to automatic review settings October 13, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The foundational unsafe-pointer representation change affects every checker type and warrants final human validation.

0 open findings

What changed in this PR

Replaces self-referential type metadata with compact kind tags and offset-zero casts, reducing checker memory usage.

Changes:

  • Adds tagged concrete and base-type casts with layout assertions.
  • Updates type construction and tracing.
  • Adds cast, allocation-lifetime, size tests, and a checker benchmark.
File Description
tsc/​internal/​checker/​types.go Defines compact type metadata and casts.
tsc/​internal/​checker/​checker.go Assigns concrete kinds during construction.
tsc/​internal/​checker/​tracer.go Uses kind-aware intrinsic access.
tsc/​internal/​checker/​types_test.go Tests casts and header size.
tsc/​internal/​checker/​checker_test.go Tests allocation lifetime and benchmarks checking.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@jakebailey
Jake Bailey (jakebailey) removed this pull request from stack #64792 October 13, 2026 20:15
@jakebailey
Jake Bailey (jakebailey) added this pull request to stack #64805 October 13, 2026 20:16
@jakebailey
Jake Bailey (jakebailey) removed this pull request from stack #64805 October 13, 2026 20:49
@jakebailey
Jake Bailey (jakebailey) added this pull request to stack #64806 October 13, 2026 20:50
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit f3a9375 Oct 14, 2026
80 checks passed
@jakebailey
Jake Bailey (jakebailey) deleted the jakebailey/mem/compact-type-headers branch October 14, 2026 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants