Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ast): use atom for Directive and Hashbang #701

Merged
merged 3 commits into from
Aug 9, 2023
Merged

Conversation

hyf0
Copy link
Contributor

@hyf0 hyf0 commented Aug 9, 2023

The main reason is using Atom to remove the lifetime for convenience.

And after removing the lifetime of these nodes, the Program<'a> doesn't rely on &'a source anymore, which allows us to specify more accurate lifetimes.

https://github.com/web-infra-dev/oxc/blob/f5b8690309c97f17e979dc232417006ffd75fbab/crates/oxc_parser/src/lib.rs#L135

https://github.com/web-infra-dev/oxc/blob/f5b8690309c97f17e979dc232417006ffd75fbab/crates/oxc_parser/src/lib.rs#L95

@hyf0 hyf0 changed the title feat(ast): use atom for Directive and Hashbang feat(ast): use atom for Directive and Hashbang Aug 9, 2023
@github-actions github-actions bot added A-parser Area - Parser A-minifier Area - Minifier A-printer Area - Printer labels Aug 9, 2023
@hyf0 hyf0 force-pushed the hyf_32849230849023 branch from b106d52 to a641495 Compare August 9, 2023 05:23
@hyf0
Copy link
Contributor Author

hyf0 commented Aug 9, 2023

I'm not sure the use case. But more accurate lifetimes after this PR allow us to have the AST while being droped the source_text.

image

Copy link
Member

@Boshen Boshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo fmt failed :-(

@Boshen
Copy link
Member

Boshen commented Aug 9, 2023

I'm not sure the use case. But more accurate lifetimes after this PR allow us to have the AST while being droped the source_text.

image

You can also allocator.alloc(source_text) I think.

@Boshen
Copy link
Member

Boshen commented Aug 9, 2023

I'm not sure the use case. But more accurate lifetimes after this PR allow us to have the AST while being droped the source_text.

image

I don't think it's related to this PR 🤔 Program still has lifetime 'a, do we need to fix the parser signature as well?

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 95.00% and no project coverage change.

Comparison is base (f5b8690) 89.52% compared to head (98defb3) 89.52%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #701   +/-   ##
=======================================
  Coverage   89.52%   89.52%           
=======================================
  Files         205      205           
  Lines       42229    42229           
=======================================
  Hits        37804    37804           
  Misses       4425     4425           
Files Changed Coverage Δ
crates/oxc_ast/src/ast/js.rs 65.84% <ø> (ø)
crates/oxc_ast/src/ast_kind.rs 17.26% <0.00%> (ø)
crates/oxc_formatter/src/gen.rs 93.10% <ø> (ø)
crates/oxc_hir/src/hir.rs 34.26% <ø> (ø)
crates/oxc_hir/src/hir_kind.rs 0.00% <ø> (ø)
crates/oxc_minifier/src/printer/gen.rs 89.11% <ø> (ø)
crates/oxc_ast/src/ast_builder.rs 98.21% <100.00%> (ø)
crates/oxc_ast/src/visit.rs 99.20% <100.00%> (ø)
crates/oxc_ast_lower/src/lib.rs 99.36% <100.00%> (ø)
crates/oxc_hir/src/hir_builder.rs 87.43% <100.00%> (ø)
... and 3 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hyf0
Copy link
Contributor Author

hyf0 commented Aug 9, 2023

I don't think it's related to this PR 🤔 Program still has lifetime 'a, do we need to fix the parser signature as well?

No, it's not. It should be fixed in another PR(if you think this should be fixed), but that PR requires the changes in this PR.

do we need to fix the parser signature as well?

Yes. Probably something like Parser<'arena, 'source_txt>

@Boshen Boshen merged commit 3516759 into main Aug 9, 2023
@Boshen Boshen deleted the hyf_32849230849023 branch August 9, 2023 05:52
@Boshen
Copy link
Member

Boshen commented Aug 9, 2023

Thank you!

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2023

Benchmark Results

Linux

group                            main                                   pr
-----                            ----                                   --
minifier/antd.js                 1.01    240.7±3.16ms    26.5 MB/sec    1.00    238.3±2.68ms    26.8 MB/sec
minifier/react.development.js    1.00      2.6±0.01ms    26.8 MB/sec    1.00      2.6±0.01ms    26.8 MB/sec
minifier/typescript.js           1.02    410.7±3.94ms    25.1 MB/sec    1.00    403.3±4.10ms    25.6 MB/sec
minifier/vue.js                  1.02     15.6±0.44ms    20.9 MB/sec    1.00     15.3±0.14ms    21.3 MB/sec
parser/antd.js                   1.01     76.7±1.18ms    83.1 MB/sec    1.00     76.1±1.09ms    83.8 MB/sec
parser/react.development.js      1.01   853.7±15.00µs    80.6 MB/sec    1.00    841.5±7.36µs    81.8 MB/sec
parser/typescript.js             1.01    131.6±0.40ms    78.4 MB/sec    1.00    130.5±0.41ms    79.1 MB/sec
parser/vue.js                    1.02      5.4±0.12ms    60.6 MB/sec    1.00      5.3±0.02ms    62.1 MB/sec
semantic/antd.js                 1.00     76.5±3.58ms    83.4 MB/sec    1.01     77.3±1.41ms    82.5 MB/sec
semantic/react.development.js    1.00   833.3±18.00µs    82.6 MB/sec    1.01   838.7±15.34µs    82.0 MB/sec
semantic/typescript.js           1.01    169.1±5.42ms    61.0 MB/sec    1.00    167.6±5.16ms    61.6 MB/sec
semantic/vue.js                  1.01      5.5±0.12ms    59.8 MB/sec    1.00      5.4±0.07ms    60.4 MB/sec

Windows

group                            main                                   pr
-----                            ----                                   --
minifier/antd.js                 1.06   320.1±11.89ms    19.9 MB/sec    1.00    301.0±9.50ms    21.2 MB/sec
minifier/react.development.js    1.08      3.6±1.84ms    19.1 MB/sec    1.00      3.3±0.03ms    20.6 MB/sec
minifier/typescript.js           1.02   487.2±14.35ms    21.2 MB/sec    1.00   479.3±10.75ms    21.5 MB/sec
minifier/vue.js                  1.00     20.3±0.46ms    16.1 MB/sec    1.00     20.3±0.32ms    16.1 MB/sec
parser/antd.js                   1.02     82.8±2.14ms    77.0 MB/sec    1.00     80.8±2.16ms    78.9 MB/sec
parser/react.development.js      1.02   892.5±12.26µs    77.1 MB/sec    1.00   878.0±10.11µs    78.4 MB/sec
parser/typescript.js             1.02    140.1±2.19ms    73.6 MB/sec    1.00    137.2±2.12ms    75.2 MB/sec
parser/vue.js                    1.01      5.8±0.04ms    56.5 MB/sec    1.00      5.7±0.07ms    57.0 MB/sec
semantic/antd.js                 1.06    87.5±10.75ms    72.9 MB/sec    1.00     82.8±3.72ms    77.0 MB/sec
semantic/react.development.js    1.00  1107.9±28.44µs    62.1 MB/sec    1.01  1123.5±33.28µs    61.2 MB/sec
semantic/typescript.js           1.02   204.0±16.02ms    50.6 MB/sec    1.00   199.0±11.30ms    51.8 MB/sec
semantic/vue.js                  1.00      7.2±0.11ms    45.0 MB/sec    1.01      7.3±0.11ms    44.8 MB/sec

Boshen pushed a commit that referenced this pull request Jan 6, 2025
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [compact_str](https://redirect.github.com/ParkMyCar/compact_str) | workspace.dependencies | patch | `0.8.0` -> `0.8.1` |
| [handlebars](https://redirect.github.com/sunng87/handlebars-rust) | workspace.dependencies | minor | `6.2.0` -> `6.3.0` |
| [insta](https://insta.rs/) ([source](https://redirect.github.com/mitsuhiko/insta)) | workspace.dependencies | minor | `1.41.1` -> `1.42.0` |
| [itertools](https://redirect.github.com/rust-itertools/itertools) | workspace.dependencies | minor | `0.13.0` -> `0.14.0` |
| [petgraph](https://redirect.github.com/petgraph/petgraph) | workspace.dependencies | minor | `0.6.5` -> `0.7.0` |
| [prettyplease](https://redirect.github.com/dtolnay/prettyplease) | workspace.dependencies | patch | `0.2.25` -> `0.2.27` |
| [syn](https://redirect.github.com/dtolnay/syn) | workspace.dependencies | patch | `2.0.93` -> `2.0.95` |
| [tempfile](https://stebalien.com/projects/tempfile-rs/) ([source](https://redirect.github.com/Stebalien/tempfile)) | workspace.dependencies | minor | `3.14.0` -> `3.15.0` |

---

### Release Notes

<details>
<summary>ParkMyCar/compact_str (compact_str)</summary>

### [`v0.8.1`](https://redirect.github.com/ParkMyCar/compact_str/compare/v0.8.0...v0.8.1)

[Compare Source](https://redirect.github.com/ParkMyCar/compact_str/compare/v0.8.0...v0.8.1)

</details>

<details>
<summary>sunng87/handlebars-rust (handlebars)</summary>

### [`v6.3.0`](https://redirect.github.com/sunng87/handlebars-rust/blob/HEAD/CHANGELOG.md#630---2025-01-05)

[Compare Source](https://redirect.github.com/sunng87/handlebars-rust/compare/v6.2.0...v6.3.0)

-   \[Added] Builders for some non-exhaustive structs \[[#&#8203;688](https://redirect.github.com/sunng87/handlebars-rust/issues/688)]
-   \[Changed] `and` and `or` helper now accepts multiple parameters \[[#&#8203;687](https://redirect.github.com/sunng87/handlebars-rust/issues/687)]
-   \[Changed] MSRV is now 1.73

</details>

<details>
<summary>mitsuhiko/insta (insta)</summary>

### [`v1.42.0`](https://redirect.github.com/mitsuhiko/insta/blob/HEAD/CHANGELOG.md#1420)

[Compare Source](https://redirect.github.com/mitsuhiko/insta/compare/1.41.1...1.42.0)

-   Text snapshots no longer contain `snapshot_type: text` in their metadata.  For
    context, we originally added this in the prior release (1.41.0) to support
    binary snapshots, but some folks disliked the diff noise on any snapshot
    changes, and the maintainers' weighted votes favored reverting.  I apologize
    that this will cause some additional churn for those who used `cargo test --force-update-snapshots` to update their snapshots to the 1.41 format;
    running this again with 1.42 will remove those metadata entries.  To confirm:
    this doesn't affect whether snapshot tests pass or fail — the worst impact is
    some additional diffs in metadata.  [#&#8203;690](https://redirect.github.com/mitsuhiko/insta/issues/690)
-   Pending snapshots are no longer removed throughout the workspace by
    `cargo-insta` before running tests.  Instead, running a test will overwrite or
    remove its own pending snapshot.  To remove all pending snapshots, use `cargo
    insta reject` or run tests with `--unreferenced=delete`.  [#&#8203;651](https://redirect.github.com/mitsuhiko/insta/issues/651)
-   `insta::internals::SettingsBindDropGuard` (returned from
    `Settings::bind_to_scope`) no longer implements `Send`. This was incorrect and
    any tests relying on this behavior where not working properly. Fixes [#&#8203;694](https://redirect.github.com/mitsuhiko/insta/issues/694) in
    [#&#8203;695](https://redirect.github.com/mitsuhiko/insta/issues/695) by [@&#8203;jalil-salame](https://redirect.github.com/jalil-salame)

</details>

<details>
<summary>rust-itertools/itertools (itertools)</summary>

### [`v0.14.0`](https://redirect.github.com/rust-itertools/itertools/blob/HEAD/CHANGELOG.md#0140)

[Compare Source](https://redirect.github.com/rust-itertools/itertools/compare/v0.13.0...v0.14.0)

##### Breaking

-   Increased MSRV to 1.63.0 ([#&#8203;960](https://redirect.github.com/rust-itertools/itertools/issues/960))
-   Removed generic parameter from `cons_tuples` ([#&#8203;988](https://redirect.github.com/rust-itertools/itertools/issues/988))

##### Added

-   Added `array_combinations` ([#&#8203;991](https://redirect.github.com/rust-itertools/itertools/issues/991))
-   Added `k_smallest_relaxed` and variants ([#&#8203;925](https://redirect.github.com/rust-itertools/itertools/issues/925))
-   Added `next_array` and `collect_array` ([#&#8203;560](https://redirect.github.com/rust-itertools/itertools/issues/560))
-   Implemented `DoubleEndedIterator` for `FilterOk` ([#&#8203;948](https://redirect.github.com/rust-itertools/itertools/issues/948))
-   Implemented `DoubleEndedIterator` for `FilterMapOk` ([#&#8203;950](https://redirect.github.com/rust-itertools/itertools/issues/950))

##### Changed

-   Allow `Q: ?Sized` in `Itertools::contains` ([#&#8203;971](https://redirect.github.com/rust-itertools/itertools/issues/971))
-   Improved hygiene of `chain!` ([#&#8203;943](https://redirect.github.com/rust-itertools/itertools/issues/943))
-   Improved `into_group_map_by` documentation ([#&#8203;1000](https://redirect.github.com/rust-itertools/itertools/issues/1000))
-   Improved `tree_reduce` documentation ([#&#8203;955](https://redirect.github.com/rust-itertools/itertools/issues/955))
-   Improved discoverability of `merge_join_by` ([#&#8203;966](https://redirect.github.com/rust-itertools/itertools/issues/966))
-   Improved discoverability of `take_while_inclusive` ([#&#8203;972](https://redirect.github.com/rust-itertools/itertools/issues/972))
-   Improved documentation of `find_or_last` and `find_or_first` ([#&#8203;984](https://redirect.github.com/rust-itertools/itertools/issues/984))
-   Prevented exponentially large type sizes in `tuple_combinations` ([#&#8203;945](https://redirect.github.com/rust-itertools/itertools/issues/945))
-   Added `track_caller` attr for `asser_equal` ([#&#8203;976](https://redirect.github.com/rust-itertools/itertools/issues/976))

##### Notable Internal Changes

-   Fixed clippy lints ([#&#8203;956](https://redirect.github.com/rust-itertools/itertools/issues/956), [#&#8203;987](https://redirect.github.com/rust-itertools/itertools/issues/987), [#&#8203;1008](https://redirect.github.com/rust-itertools/itertools/issues/1008))
-   Addressed warnings within doctests ([#&#8203;964](https://redirect.github.com/rust-itertools/itertools/issues/964))
-   CI: Run most tests with miri ([#&#8203;961](https://redirect.github.com/rust-itertools/itertools/issues/961))
-   CI: Speed up "cargo-semver-checks" action ([#&#8203;938](https://redirect.github.com/rust-itertools/itertools/issues/938))
-   Changed an instance of `default_features` in `Cargo.toml` to `default-features` ([#&#8203;985](https://redirect.github.com/rust-itertools/itertools/issues/985))

</details>

<details>
<summary>petgraph/petgraph (petgraph)</summary>

### [`v0.7.0`](https://redirect.github.com/petgraph/petgraph/blob/HEAD/RELEASES.rst#Version-070-2024-12-31)

[Compare Source](https://redirect.github.com/petgraph/petgraph/compare/[email protected]@v0.7.0)

\==========================

-   Re-released version 0.6.6 with the correct version number, as it included a major update to an exposed crate (`#664`\_).

### [`v0.6.6`](https://redirect.github.com/petgraph/petgraph/blob/HEAD/RELEASES.rst#Version-066-2024-12-31---yanked)

[Compare Source](https://redirect.github.com/petgraph/petgraph/compare/[email protected]@v0.6.6)

\===================================

-   Add graph6 format encoder and decoder (`#658`\_)
-   Dynamic Topological Sort algorithm support (`#675`\_)
-   Add `UndirectedAdaptor` (`#695`\_)
-   Add `LowerHex` and `UpperHex` implementations for `Dot` (`#687`\_)
-   Make `serde` support more complete (`#550`\_)
-   Process multiple edges in the Floyd-Warshall implementation (`#685`\_)
-   Update `fixedbitset` to 0.5.7 (`#664`\_)
-   Fix `immediately_dominated_by` function called on root of graph returns root itself (`#670`\_)
-   Fix adjacency matrix for `Csr` and `List` (`#648`\_)
-   Fix clippy warnings (`#701`\_)
-   Add performance note to the `all_simple_paths` function documentation (`#693`\_)

.. \_`#658`: [https://github.com/petgraph/petgraph/pull/658](https://redirect.github.com/petgraph/petgraph/pull/658)
.. \_`#675`: [https://github.com/petgraph/petgraph/pull/675](https://redirect.github.com/petgraph/petgraph/pull/675)
.. \_`#695`: [https://github.com/petgraph/petgraph/pull/695](https://redirect.github.com/petgraph/petgraph/pull/695)
.. \_`#687`: [https://github.com/petgraph/petgraph/pull/687](https://redirect.github.com/petgraph/petgraph/pull/687)
.. \_`#550`: [https://github.com/petgraph/petgraph/pull/550](https://redirect.github.com/petgraph/petgraph/pull/550)
.. \_`#685`: [https://github.com/petgraph/petgraph/pull/685](https://redirect.github.com/petgraph/petgraph/pull/685)
.. \_`#664`: [https://github.com/petgraph/petgraph/pull/664](https://redirect.github.com/petgraph/petgraph/pull/664)
.. \_`#670`: [https://github.com/petgraph/petgraph/pull/670](https://redirect.github.com/petgraph/petgraph/pull/670)
.. \_`#648`: [https://github.com/petgraph/petgraph/pull/648](https://redirect.github.com/petgraph/petgraph/pull/648)
.. \_`#701`: [https://github.com/petgraph/petgraph/pull/701](https://redirect.github.com/petgraph/petgraph/pull/701)
.. \_`#693`: [https://github.com/petgraph/petgraph/pull/693](https://redirect.github.com/petgraph/petgraph/pull/693)

</details>

<details>
<summary>dtolnay/prettyplease (prettyplease)</summary>

### [`v0.2.27`](https://redirect.github.com/dtolnay/prettyplease/releases/tag/0.2.27)

[Compare Source](https://redirect.github.com/dtolnay/prettyplease/compare/0.2.26...0.2.27)

-   Avoid trailing '.' on non-macro float literals ([#&#8203;89](https://redirect.github.com/dtolnay/prettyplease/issues/89))

### [`v0.2.26`](https://redirect.github.com/dtolnay/prettyplease/releases/tag/0.2.26)

[Compare Source](https://redirect.github.com/dtolnay/prettyplease/compare/0.2.25...0.2.26)

-   Synthesize parentheses for precedence ([#&#8203;88](https://redirect.github.com/dtolnay/prettyplease/issues/88))

</details>

<details>
<summary>dtolnay/syn (syn)</summary>

### [`v2.0.95`](https://redirect.github.com/dtolnay/syn/releases/tag/2.0.95)

[Compare Source](https://redirect.github.com/dtolnay/syn/compare/2.0.94...2.0.95)

-   Fix parenthesization of struct literals in let-chains ([#&#8203;1832](https://redirect.github.com/dtolnay/syn/issues/1832))

### [`v2.0.94`](https://redirect.github.com/dtolnay/syn/releases/tag/2.0.94)

[Compare Source](https://redirect.github.com/dtolnay/syn/compare/2.0.93...2.0.94)

-   Expression precedence fixes ([#&#8203;1811](https://redirect.github.com/dtolnay/syn/issues/1811), [#&#8203;1812](https://redirect.github.com/dtolnay/syn/issues/1812), [#&#8203;1813](https://redirect.github.com/dtolnay/syn/issues/1813), [#&#8203;1814](https://redirect.github.com/dtolnay/syn/issues/1814), [#&#8203;1815](https://redirect.github.com/dtolnay/syn/issues/1815), [#&#8203;1816](https://redirect.github.com/dtolnay/syn/issues/1816), [#&#8203;1818](https://redirect.github.com/dtolnay/syn/issues/1818), [#&#8203;1819](https://redirect.github.com/dtolnay/syn/issues/1819), [#&#8203;1820](https://redirect.github.com/dtolnay/syn/issues/1820), [#&#8203;1825](https://redirect.github.com/dtolnay/syn/issues/1825), [#&#8203;1826](https://redirect.github.com/dtolnay/syn/issues/1826), [#&#8203;1827](https://redirect.github.com/dtolnay/syn/issues/1827), [#&#8203;1828](https://redirect.github.com/dtolnay/syn/issues/1828), [#&#8203;1829](https://redirect.github.com/dtolnay/syn/issues/1829), [#&#8203;1830](https://redirect.github.com/dtolnay/syn/issues/1830))

</details>

<details>
<summary>Stebalien/tempfile (tempfile)</summary>

### [`v3.15.0`](https://redirect.github.com/Stebalien/tempfile/blob/HEAD/CHANGELOG.md#3150)

[Compare Source](https://redirect.github.com/Stebalien/tempfile/compare/v3.14.0...v3.15.0)

Re-seed the per-thread RNG from system randomness when we repeatedly fail to create temporary files ([#&#8203;314](https://redirect.github.com/Stebalien/tempfile/issues/314)). This resolves a potential DoS vector ([#&#8203;178](https://redirect.github.com/Stebalien/tempfile/issues/178)) while avoiding `getrandom` in the common case where it's necessary. The feature is optional but enabled by default via the `getrandom` feature.

For libc-free builds, you'll either need to disable this feature or opt-in to a different [`getrandom` backend](https://redirect.github.com/rust-random/getrandom?tab=readme-ov-file#opt-in-backends).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 11am on monday" in timezone Asia/Shanghai, Automerge - "before 11am on monday" in timezone Asia/Shanghai.

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/oxc-project/oxc).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS44NS4wIiwidXBkYXRlZEluVmVyIjoiMzkuODUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-minifier Area - Minifier A-parser Area - Parser A-printer Area - Printer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants