Repository navigation
Take oxc 0.160 and carry the parser's stack floor and speculation budget over - #1327
Open
tolgaergin wants to merge 4 commits into
Open
tolgaergin wants to merge 4 commits into
tolgaergin wants to merge 4 commits into
Conversation
…get over
Moves every oxc crate from 0.158.0 to 0.160.0 in one step, as the shared
AST types and the vendored parser require, and rebases
vendor/oxc_parser on 0.160.0.
0.160 parses a parenthesized list once and turns its elements into arrow
parameters or an expression after its `)`. The patch now also checks the
stack floor in advance_to, which moves to a token the lexer has already
read, and in the new conversions and checks that turn those elements into
parameters. The checks borrow the parser, so the stop is kept in a Cell
and reported even when no further token is read. Checkpoints no longer
copy the lexer's diagnostics, so the budget counts only bytes read again
after rewinds. Across the 370,776 JavaScript and TypeScript files of a
local package store, the most any file read again was 0.75 bytes per
byte, and none used more than 30% of its budget.
0.160 gives a key written without brackets its own PropertyKey variants:
StaticStringLiteral, StaticNumericLiteral and StaticBigIntLiteral. The
threat rules matched `"name":` and `17:` keys by the old variants, which
still compiled but no longer matched. That missed `rm` of the home
directory through `const {'rmSync': remove} = require('fs')` and an
environment upload through a bundle's numbered module table. They now
match both forms.
Tests:
- Parenthesized lists that 0.158 parsed twice now parse in linear time.
- The budget tests use TypeScript generic arrow heads nested in defaults,
which 0.160 still parses twice per level.
- The floor test now parses lists that become arrow parameters.
- The deep-calls timing test runs on a 256 MiB stack, because a debug
build of 0.160 parses its deepest source in more than 64 MiB.
Dependabot proposes oxc crates as one group from now on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y lexer rewind oxc 0.160 walked every parenthesis inside a closing one to find where the expression innermost in them starts, so `((((…a…))))` was quadratic without speculating: 80,000 levels, which fit on a 64 MiB stack, took four seconds in a release build. ParserState::last_parenthesized keeps the innermost start of the ParenthesizedExpression built last, so each level reads it instead of walking the chain. 80,000 levels now take 3 ms. The speculation budget was compared only at the parser's rewinds, so a lookahead that rewinds only the lexer, such as deciding whether `(` starts a function type, could pass the budget without the parse stopping or reporting it. The lexer now compares at every rewind and keeps the stop, and a parse that reached the stack floor still reports only that. The budget tests now assert that their sources exhaust the budget, not only that they end up read without parsing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t::cover, and test the async speculation The parser reads a member chain in a loop, so it uses no stack per member. Two functions then recursed once per member: set_pure_on_call_or_new_expr, for `/*#__PURE__*/a.b.c…`, and jsx_member_expression_eq, which compares `<a.b.c…>` with its closing tag. A debug build overflowed its stack on 200,000 members, and a release build relied on the optimizer turning the tail calls into loops. Both are loops now. SimpleAssignmentTarget::cover, which nested parentheses recurse through without passing AssignmentTarget::cover, checks the floor too. The arguments of an `async(…)` that mention `await` are parsed again as parameters when `=>` follows, so nesting such heads in their defaults still makes JavaScript speculate quadratically: 500 bytes read again per byte at 1,000 levels. The budget stops it. A test now covers it, and the budget's documentation no longer says only TypeScript speculates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, and match template keys
Before parsing the arguments of an `async(…)` that mention `await` again
as parameters, oxc 0.160 walked every entry recorded for a literal ending
in a spread and a comma, or for a CoverInitializedName, anywhere before
them, while reading almost nothing again. Neither map forgets entries no
conversion consumes, so a 4 MiB file of `[...a,];` and `async(await)=>0;`
took about 25 seconds without reaching the speculation budget. Both maps
are ordered now, and the entries inside the arguments are split off: that
file parses in 57 ms.
destructured_methods also reads a key written as a template without
substitutions, so `const {[`rmSync`]: remove} = require('fs')` keeps its
method.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tolgaergin
force-pushed
the
deps/oxc-0.160
branch
from
November 25, 2026 01:53
6263957 to
6c8467c
Compare
tolgaergin
marked this pull request as ready for review
November 25, 2026 03:39
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.
Moves every oxc crate from 0.158.0 to 0.160.0 in one step and rebases the patched
vendor/oxc_parseronto it. Supersedes #1307, #1306 and #1305, which each bumped one oxc crate (0.159.0) and couldn't build alone. 0.160.0 came out on 2026-11-23, after those PRs opened. Taking it now saves rebasing the patch again next week.The vendored parser (
vendor/oxc_parser/LPM-PATCH.md)Upstream rewrote what the patch hooks into. A parenthesized list is now parsed once (a cover grammar) and turned into arrow parameters or an expression after its
). Checkpoints are O(1) and no longer copy the lexer's diagnostics. The patch was ported by hand and now makes three changes.Stack floor:
advance, the JSX variants, andadvance_to, whicheat_if_nextandparse_import_statementuse to move to a token the lexer has already read.AssignmentTarget::coverandSimpleAssignmentTarget::cover;cover_expression_to_binding_patternandcover_assignment_target_to_binding_pattern;check_cover_bindingandcheck_cover_binding_target. These take&self, sostack_exhaustedis aCell<bool>: a check at the floor sets it, and the parse stops at its next token and reports it.set_pure_on_call_or_new_exprandjsx_member_expression_eqrecursed once per member of a chain the parser reads in a loop. A debug build overflowed its stack on 200,000 members. Both are loops now.Speculation budget:
Linear time where upstream 0.160 is quadratic without speculating:
ParserState::last_parenthesizedlets a chain of parentheses find its innermost expression without walking the chain at each level. 80,000 nested parentheses took 4.1 s in a release build; they now take 3.4 ms.async(…)that mentionawaitagain as parameters, upstream walked every entry recorded for a[...a,]literal or aCoverInitializedNamebefore them. A 4 MiB file of[...a,];andasync(await)=>0;would have taken about 25 s without reaching the budget. Both maps areBTreeMaps now, and the entries inside the arguments are split off: that file parses in 57 ms.lpm-stack-floor.patchis regenerated, and applying it to the pristine 0.160.0 crate reproduces the vendored tree byte for byte.Measurements (release builds):
PARSE_SPECULATION_PER_BYTE = 2stays.AST changes that still compiled
0.160 gives keys written without brackets their own
PropertyKeyvariants:StaticStringLiteral,StaticNumericLiteralandStaticBigIntLiteral.ObjectProperty.computedis gone. The oldStringLiteral/NumericLiteralvariants now mean computed keys only. Three threat-rule matches used the old variants, so they compiled but silently stopped matching:destructured_methods:const {'rmSync': remove} = require('fs'); remove(os.homedir(), …)was no longerdestructiveFilesystem.Ancestry::numeric_propertyandBundles::collect: a bundle's numbered module table ({17: (m,e,r) => …}) no longer resolved, which lost the environment-upload finding through a bundled class.Both now match the plain and the computed form, as 0.158 did.
destructured_methodsalso reads a template key without substitutions ([`rmSync`]:), which 0.158 missed too.static_name()covers the same keys as before.oxc_semantic 0.160 gives
catch(e){var e=…}a separatevarbinding. Compared with 0.158, the only difference in findings is an extrashelltag fore.exec()after such atry, which throws at run time anyway.Tests
Rule regressions:
aliased_filesystem_methods_keep_their_imported_identitycoversrmSync,'rmSync',['rmSync']and[`rmSync`].bundled_class_helper_preserves_the_environment_upload_flowcovers17:and[17]:.Each failed before its fix.
Floor test: renamed to
parenthesized_lists_parsed_just_above_the_floor_become_parameters_or_expressions_without_overflowing.=>(arrays, objects, defaults, rests,async, TypeScript return types and annotations) and((a))=0.Parser timing tests (
syntax.rs), each failing before its fix:parentheses_nested_tens_of_thousands_of_levels_deep_parse_in_linear_time: 1.28 s against 15 ms before.async_arrow_heads_parsed_again_after_many_spread_literals_parse_in_linear_time: 5.8 s against 147 ms before.pure_comments_and_jsx_names_on_member_chains_of_any_length_parse_without_overflowing: aborted before.lookahead_that_reads_past_the_speculation_budget_stops_the_parse.Budget tests: 0.160 no longer speculates on nested parenthesized lists, so
parenthesized_lists_nested_in_defaults_are_parsed_in_linear_timenow expects those sources parsed. The budget is tested with shapes 0.160 still parses twice per level, and each test asserts the budget stopped the parse (syntax::exhausts_the_speculation_budget):x=<T>(a=<T>(a=…))));async(…)heads that mentionawait(x=async(a=async(a=…await 0)=>0)=>0).All three fail with the budget turned off.
Deep-calls timing test:
calls_nested_thousands_of_levels_deep_are_analyzed_in_one_passruns on a 256 MiB stack. A debug build of 0.160 fits 6,724 levels of its object-and-arrow shape in 64 MiB (0.158: 8,173), below the test's 8,000. Release builds fit 30,943.Dependabot now proposes all
oxc_*crates as one group, aboverust-minor-and-patch, likewindows-rs.Review
Reviewed by Sol 6.2, Fable 5.2 and Opus 5.5. Every finding above was verified against the code and fixed test-first. A Gemini 4 Neon performance review is running.
Checks run locally (macOS, this branch)
cargo clippy --workspace --all-targets --locked -- -D warnings: clean.cargo fmt --check: clean.cargo test -p lpm-security: 854 pass.cargo test -p lpm-runner: 652 pass.GIT_CONFIG_KEY_0).🤖 Generated with Claude Code