perf(parser): specialize identifier reference parsing (#28303)

Inline identifier parsing and bypass async/contextual disambiguation for
ordinary identifiers.

Native parse time versus parent: 2.7% lower with fresh arenas, 2.3%
lower with reuse (geometric mean, 12 files, arm64 macOS; 3 rounds × 100
samples).

Validated existing Rust/Node suites, parser/ESTree/token conformance,
allocation snapshots, and x86 compilation. AI-assisted implementation.

Depends on #28302.
This commit is contained in:
Boshen authored and GitHub committed 2026-10-29 16:30:20 +08:00
1 parent 0d6641a113
commit 36669393e7
1 file changed
+4
+4
View File
@@ -263,6 +263,10 @@ impl<'a, C: Config> ParserImpl<'a, C> {
/// `TemplateLiteral`[?Yield, ?Await, ~Tagged]
/// `CoverParenthesizedExpressionAndArrowParameterList`[?Yield, ?Await]
fn parse_primary_expression(&mut self) -> Expression<'a> {
// Ordinary identifiers do not need async-function or contextual-keyword disambiguation.
if self.at(Kind::Ident) {
return self.parse_identifier_expression();
}
// FunctionExpression, GeneratorExpression
// AsyncFunctionExpression, AsyncGeneratorExpression
if self.at_function_with_async() {