Repository navigation
Remove checker pointer from Type - #64946
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
Every type carried a pointer back to its checker, costing a word per type header just so a handful of free helpers could reach the checker. Those helpers can take the checker explicitly instead, shrinking Type from 40 to 32 bytes on 64-bit platforms. Lazily resolved class and interface references still need the checker to resolve members on demand, so the pointer moves to LazyState, which only exists for those types.
Member
Author
|
TypeScript Bot (@typescript-bot) perf test this faster |
Contributor
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The removed cross-checker ownership guard needs replacement to preserve the existing validation invariant.
1 open issue
What changed in this PR
Reduces the native compiler’s Type header from 40 to 32 bytes by removing its checker pointer and passing checker context explicitly where needed.
Changes:
- Moves checker ownership needed for lazy member resolution into
LazyState. - Updates type comparison, inference, relation checking, and tracing to receive checker context.
- Adjusts size assertions and existing comparison tests.
| File | Description |
|---|---|
tsc/internal/testrunner/compiler_runner.go |
Uses checker-bound comparison in union-ordering checks. |
tsc/internal/checker/utilities.go |
Converts type comparison helpers to checker methods. |
tsc/internal/checker/types.go |
Removes the header pointer and adds checker context to lazy state. |
tsc/internal/checker/types_test.go |
Updates header-size and mapper-comparison assertions. |
tsc/internal/checker/tracer.go |
Passes checker context through traced-type adapters. |
tsc/internal/checker/relater.go |
Updates relation and recursion helpers to use checker context. |
tsc/internal/checker/nodebuilderimpl.go |
Supplies the checker when allocating extra type storage. |
tsc/internal/checker/inference.go |
Makes depth and ordering helpers checker methods. |
tsc/internal/checker/flow.go |
Uses checker-bound union membership lookup. |
tsc/internal/checker/checker.go |
Initializes lazy-state ownership and updates affected callers. |
Review effort: Balanced
| if t1.checker != t2.checker { | ||
| panic("Cannot compare types from different checkers") | ||
| } | ||
| // First sort in order of increasing type flags values. |
Contributor
|
Jake Bailey (@jakebailey) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Member
Author
|
Pretty disappointing, but I also didn't check the size class, and then also I don't think we allocate these in arenas |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This brings the Type type down from 40 bytes to 32 bytes.
Unfortunately, lazy members has made this more annoying, hence sticking a checker pointer into LazyState.