Skip to content

Commit e8bbbd1

Browse files
perf(javascript): stop executing acorn code on the lazy parse path (#21667)
* perf(javascript): own class bodies, methods and object property values Land class declarations/expressions, class bodies, methods, fields, static blocks, object methods, shorthand values and property clash checks on single-shape nodes with the private-name bookkeeping owned, gated back to acorn on plugin overrides. acorn's share of parse time drops to ~1% on class- and module-heavy inputs, and many-small-module parsing gets ~4% faster. * perf(javascript): stop executing acorn code on the lazy parse path Own the remaining utility layer — token predicates, scope accessors, error raising, template-token dispatch, directive prologue, binding-list items, catch params, the super/class/import atoms and the async/top-level-await statement heads — as exact copies, so a lazy parse runs entirely in owned code. A tripwire test instruments acorn's prototype and asserts zero calls; what remains of the dependency is the class relationship, the token/context and Unicode tables, and cold fallbacks (using declarations, non-lazy modes, plugin gates). * fix(javascript): serialize parse-error locations in the persistent cache Register a serializer for the parser's ParserPosition so modules carrying a ModuleParseError stay serializable, restoring the acorn Position behavior (deserializes to a plain line/column object). * perf(javascript): trim walker allocations (#21668) - one-argument fast dispatch for per-identifier hook calls (no rest array + spread per identifier) - closure-free scope entry/exit for the internal block/function scope walks - guard-branch closures only allocated when a guard frame exists - inline the Identifier left side of assignments past enterPattern - pin StackedMap stale-view semantics with unit tests * chore(changeset): split the lazy-path and walker entry from the parser exactness one * test(js-parser): cover the public inBlockScope delegate The walkers now enter and leave block scopes through the closure-free cores, so nothing in the repository executed the plugin-facing inBlockScope any more. Assert its contract: a child definitions scope, reset shorthand state, and termination propagating outward only on an executed path. * style(js-parser): keep plain comments within two lines Condense the fourteen comments the diff grows past the two-line limit, keeping the invariant each one records.
1 parent 4448f8b commit e8bbbd1

7 files changed

Lines changed: 3620 additions & 1230 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Parse without acorn, serialize parse-error locations, trim walker allocations.

0 commit comments

Comments
 (0)