refactor(minifier): merge persistent symbol metadata#24639
Conversation
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. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will not alter performance
Comparing Footnotes
|
327de79 to
baf8949
Compare
1152440 to
51bc9a5
Compare
Monitor OxcCommit:
|
51bc9a5 to
97edfe3
Compare
00f1815 to
b38c502
Compare
97edfe3 to
a988cf9
Compare
Merge activity
|
Pure-call summaries and member-write effects used separate sparse hash maps even though both are keyed by `SymbolId` and remain valid across peephole iterations. This stores both values in one `PersistentSymbolMetadata` entry. Summary replacement and monotone member-effect strengthening remain independent, and clearing a dynamic-binding summary updates an existing entry without allocating or discarding its member effect. The regenerated allocation snapshot records fewer system allocations: checker 155→152, pdf 2469→2467, antd 1044→1038, and kitchen-sink 1872→1867. `minsize.snap` remains byte-identical. The PR tip passed the full `oxc_minifier` suite independently. The completed stack also passed clippy with warnings denied, formatting, minsize and allocation regeneration, and `just ready`. ## Stack 1. #24636 — function-summary correctness 2. #24637 — explicit symbol effect types 3. #24638 — grouped reference counts 4. **#24639 — merged persistent metadata** 5. #24640 — SymbolState facade Implemented with AI assistance (OpenAI Codex). The contributor remains responsible for reviewing, understanding, and submitting the changes under the repository AI usage policy.
Pure-function summaries trusted resolved read and write references, but redeclarations, direct `eval`, and classic Script globals can replace a binding without producing such a reference. A later call could therefore be folded according to an earlier empty declaration and lose runtime side effects.
## Example
```js
function foo() {}
eval("foo = () => side_effect()")
foo()
```
Bindings with redeclarations, bindings visible to direct eval, and classic Script-root bindings do not receive a reusable summary; the eval restriction is intentionally non-sticky so removing the final eval can enable the optimization in a later pass. Module and CommonJS bindings retain the existing fold.
The PR tip passed the full `oxc_minifier` suite independently. The completed stack also passed clippy with warnings denied, formatting, minsize and allocation regeneration, and `just ready`.
## Stack
1. **#24636 — function-summary correctness**
2. #24637 — explicit symbol effect types
3. #24638 — grouped reference counts
4. #24639 — merged persistent metadata
5. #24640 — SymbolState facade
Implemented with AI assistance (OpenAI Codex). The contributor remains responsible for reviewing, understanding, and submitting the changes under the repository AI usage policy.
Pure-call summaries and member-write hazards encoded semantic states through nested `Option` values and independent bitflags. Reviewers had to reconstruct which combinations were valid and which implications producers must maintain. This introduces `FunctionSummary` for reusable call proofs and an ordered `MemberWriteEffect` for `None < Hazard < MayMutatePrototype`. Prototype mutation is therefore hazardous by construction, the removed bitflag dependency is no longer needed, and producers and consumers share named contracts. Behavior is unchanged relative to #24636. The PR tip passed the full `oxc_minifier` suite independently. The completed stack also passed clippy with warnings denied, formatting, minsize and allocation regeneration, and `just ready`. ## Stack 1. #24636 — function-summary correctness 2. **#24637 — explicit symbol effect types** 3. #24638 — grouped reference counts 4. #24639 — merged persistent metadata 5. #24640 — SymbolState facade Implemented with AI assistance (OpenAI Codex). The contributor remains responsible for reviewing, understanding, and submitting the changes under the repository AI usage policy.
a988cf9 to
db06764
Compare
`SymbolValue` exposed three related counters directly, so every consumer had to coordinate read, write, and member-write-target invariants itself. This groups them in `ReferenceCounts` and exposes factual queries such as `has_single_read` and `has_only_member_write_target_reads`. The existing 48-byte `SymbolValue` layout is preserved, and the refactor does not change minified output. The PR tip passed the full `oxc_minifier` suite independently. The completed stack also passed clippy with warnings denied, formatting, minsize and allocation regeneration, and `just ready`. ## Stack 1. #24636 — function-summary correctness 2. #24637 — explicit symbol effect types 3. **#24638 — grouped reference counts** 4. #24639 — merged persistent metadata 5. #24640 — SymbolState facade Implemented with AI assistance (OpenAI Codex). The contributor remains responsible for reviewing, understanding, and submitting the changes under the repository AI usage policy.
b38c502 to
7492af4
Compare
`MinifierState` separately exposed dense per-pass values, sparse persistent metadata, and optional reachability state even though all three are indexed by semantic symbols. Its private-member stack also used symbol terminology despite storing names rather than `SymbolId`s. This introduces a `SymbolState` facade that documents the three storage lifecycles and forwards their operations while leaving the reachability algorithm in its dedicated module. The class-local tracker is renamed around private-member usage so it cannot be confused with semantic symbol state. The PR tip passed the full `oxc_minifier` suite independently. The completed stack also passed clippy with warnings denied, formatting, minsize and allocation regeneration, and `just ready`. ## Stack 1. #24636 — function-summary correctness 2. #24637 — explicit symbol effect types 3. #24638 — grouped reference counts 4. #24639 — merged persistent metadata 5. **#24640 — SymbolState facade** Implemented with AI assistance (OpenAI Codex). The contributor remains responsible for reviewing, understanding, and submitting the changes under the repository AI usage policy.

Pure-call summaries and member-write effects used separate sparse hash maps even though both are keyed by
SymbolIdand remain valid across peephole iterations.This stores both values in one
PersistentSymbolMetadataentry. Summary replacement and monotone member-effect strengthening remain independent, and clearing a dynamic-binding summary updates an existing entry without allocating or discarding its member effect.The regenerated allocation snapshot records fewer system allocations: checker 155→152, pdf 2469→2467, antd 1044→1038, and kitchen-sink 1872→1867.
minsize.snapremains byte-identical.The PR tip passed the full
oxc_minifiersuite independently. The completed stack also passed clippy with warnings denied, formatting, minsize and allocation regeneration, andjust ready.Stack
Implemented with AI assistance (OpenAI Codex). The contributor remains responsible for reviewing, understanding, and submitting the changes under the repository AI usage policy.