perf(codegen): reorder match arms based on usage patterns#14496
Conversation
Reorder Statement and Expression match arms to align with parser frequency, improving branch prediction performance. Changes: - Statement: BlockStatement, ExpressionStatement, VariableDeclaration and control flow statements moved to top, TS-specific moved to bottom - Expression: Identifier, member access, calls, and literals moved to top, JSX and TS assertions moved to bottom The new order follows the parser's pattern matching sequence, which reflects real-world JavaScript/TypeScript code frequency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
There was a problem hiding this comment.
Pull Request Overview
This PR reorders match arms in the Statement and Expression enums within the code generator to align with typical JavaScript/TypeScript usage patterns, potentially improving branch prediction performance through better CPU cache utilization.
Key changes:
- Reordered Statement match arms to prioritize common statements like BlockStatement, ExpressionStatement, and VariableDeclaration
- Reordered Expression match arms to prioritize frequent expressions like Identifier, member access, and function calls
- Moved TypeScript-specific constructs to the bottom as they're less common in runtime scenarios
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CodSpeed Performance ReportMerging #14496 will not alter performanceComparing Summary
Footnotes |
Summary
Reorders Statement and Expression match arms in
oxc_codegento align with parser frequency, improving branch prediction performance.Changes
Statement match reordering:
BlockStatement,ExpressionStatement,VariableDeclaration,IfStatement,ReturnStatement,FunctionDeclarationForStatement,WhileStatement,DoWhileStatement,SwitchStatement, etc.WithStatement,DebuggerStatementExpression match reordering:
Identifier,StaticMemberExpression,ComputedMemberExpression,CallExpressionNumericLiteral,StringLiteral,BooleanLiteral,NullLiteralThe new order follows the parser's pattern matching sequence (from
parse_statement_list_itemandparse_primary_expression), which reflects real-world JavaScript/TypeScript code frequency.Test plan
oxc_codegentests pass (86 passed)oxc_transformerverified (30 tests passed)just fmt🤖 Generated with Claude Code