Expand description
Thin Node Architecture for Cache-Efficient AST
This module implements a cache-optimized AST representation where each node is exactly 16 bytes (4 nodes per 64-byte cache line), compared to the previous 208-byte Node enum (0.31 nodes per cache line).
§Architecture
Instead of a single large enum, we use:
Node- A 16-byte header containing kind, flags, position, and a data index- Typed storage pools - Separate Vec
for each node category
The data_index field points into the appropriate pool based on kind.
§Performance Impact
- Before: 208 bytes/node = 0.31 nodes/cache-line
- After: 16 bytes/node = 4 nodes/cache-line
- Improvement: 13x better cache locality for AST traversal
§Design Principles
- Common data inline: kind, flags, pos, end are accessed constantly
- Rare data indirect: modifiers, type parameters, etc. via index
- No heap allocation per node: All storage in arena vectors
- O(1) node access: Direct index into typed pool
Structs§
- Access
Expr Data - Data for property/element access
- Accessor
Data - Data for accessor declarations (get/set)
- Array
Type Data - Data for array type
- Binary
Expr Data - Data for binary expressions
- Binding
Element Data - Data for binding elements
- Binding
Pattern Data - Data for binding patterns
- Block
Data - Data for block statements
- Call
Expr Data - Data for call/new expressions
- Case
Clause Data - Data for case/default clauses
- Catch
Clause Data - Data for catch clauses
- Class
Data - Data for class declarations
- Composite
Type Data - Data for union/intersection types
- Computed
Property Data - Data for computed property names
- Conditional
Expr Data - Data for conditional expressions (a ? b : c)
- Conditional
Type Data - Data for conditional types
- Constructor
Data - Data for constructor declarations
- Decorator
Data - Data for decorator nodes
- Enum
Data - Data for enum declarations
- Enum
Member Data - Data for enum members
- Export
Assignment Data - Data for export assignments
- Export
Decl Data - Data for export declarations
- Expr
Statement Data - Data for expression statements
- Expr
With Type Args Data - Data for expression with type arguments
- Expression
Statement Data - Data for expression statements
- Extended
Node Info - Extended node info for nodes that need more than what fits in Node
- ForIn
OfData - Data for for-in/for-of statements
- Function
Data - Data for function declarations/expressions/arrows
- Function
Type Data - Data for type nodes (function type, constructor type)
- Heritage
Data - Data for heritage clauses
- Identifier
Data - Data for identifier nodes (
Identifier,PrivateIdentifier) - IfStatement
Data - Data for if statements
- Import
Attribute Data - Data for import attribute
- Import
Attributes Data - Data for import attributes
- Import
Clause Data - Data for import clauses
- Import
Decl Data - Data for import declarations
- Index
Signature Data - Data for index signatures
- Indexed
Access Type Data - Data for indexed access type
- Infer
Type Data - Data for infer type
- Interface
Data - Data for interface declarations
- JsxAttribute
Data - Data for JSX attribute
- JsxAttributes
Data - Data for JSX attributes
- JsxClosing
Data - Data for JSX closing elements
- JsxElement
Data - Data for JSX elements
- JsxExpression
Data - Data for JSX expression
- JsxFragment
Data - Data for JSX fragments
- JsxNamespaced
Name Data - Data for JSX namespaced name
- JsxOpening
Data - Data for JSX self-closing/opening elements
- JsxSpread
Attribute Data - Data for JSX spread attribute
- JsxText
Data - Data for JSX text
- Jump
Data - Data for break/continue statements
- Labeled
Data - Data for labeled statements
- Literal
Data - Data for string literals (
StringLiteral, template parts) - Literal
Expr Data - Data for object/array literals
- Literal
Type Data - Data for literal types
- Loop
Data - Data for for/while/do loops
- Mapped
Type Data - Data for mapped type
- Method
Decl Data - Data for method declarations (class methods)
- Module
Block Data - Data for module blocks: { statements }
- Module
Data - Data for module/namespace declarations
- Named
Imports Data - Data for namespace/named imports
- Named
Tuple Member Data - Data for named tuple member
- Node
- A thin 16-byte node header for cache-efficient AST storage.
- Node
Arena - Arena for thin nodes with typed data pools. Provides O(1) allocation and cache-efficient storage.
- Node
Info - Common node information that both arena types can provide. This struct contains the essential fields needed by most consumers.
- Node
View - A view into a node that provides convenient access to both the Node header and its type-specific data. This avoids the need to pass the arena around when working with node data.
- Parameter
Data - Data for parameter declarations
- Parenthesized
Data - Data for parenthesized expressions
- Property
Assignment Data - Data for property assignments
- Property
Decl Data - Data for property declarations
- Qualified
Name Data - Data for qualified names
- Return
Data - Data for return/throw statements
- Shorthand
Property Data - Data for shorthand property assignments
- Signature
Data - Data for property/method signatures
- Source
File Data - Data for source files
- Specifier
Data - Data for import/export specifiers
- Spread
Data - Data for spread assignments
- Switch
Data - Data for switch statements
- Tagged
Template Data - Data for tagged template expressions
- Template
Expr Data - Data for debugger/empty statements (no data needed, use token)
- Template
Literal Type Data - Data for template literal types
- Template
Span Data - Data for template spans
- TryData
- Data for try statements
- Tuple
Type Data - Data for tuple type
- Type
Alias Data - Data for type alias declarations
- Type
Assertion Data - Data for as/satisfies/type assertion expressions
- Type
Literal Data - Data for type literal
- Type
Operator Data - Data for type operator (keyof, unique, readonly)
- Type
Parameter Data - Data for type parameter declarations
- Type
Predicate Data - Data for type predicate
- Type
Query Data - Data for type query (typeof)
- Type
RefData - Data for type references
- Unary
Expr Data - Data for unary expressions (prefix/postfix)
- Unary
Expr Data Ex - Data for spread/await/yield expressions
- Variable
Data - Data for variable declarations
- Variable
Declaration Data - Data for variable declarations (individual)
- With
Data - Data for with statements
- Wrapped
Type Data - Data for optional/rest types
Enums§
- Node
Category - Categories of nodes that share storage pools. Nodes in the same category have similar data layouts.
Traits§
- Node
Access - Trait for unified access to AST nodes across different arena implementations. This allows consumers (binder, checker, emitter) to work with either different arena implementations without code changes.