Rust编写的JavaScript引擎,该项目是一个试验性质的项目。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
957 B

Lexer string interning (#1758) This Pull Request is part of #279. It adds a string interner to Boa, which allows many types to not contain heap-allocated strings, and just contain a `NonZeroUsize` instead. This can move types to the stack (hopefully I'll be able to move `Token`, for example, maybe some `Node` types too. Note that the internet is for now only available in the lexer. Next steps (in this PR or future ones) would include also using interning in the parser, and finally in execution. The idea is that strings should be represented with a `Sym` until they are displayed. Talking about display. I have changed the `ParseError` type in order to not contain anything that could contain a `Sym` (basically tokens), which might be a bit faster, but what is important is that we don't depend on the interner when displaying errors. The issue I have now is in order to display tokens. This requires the interner if we want to know identifiers, for example. The issue here is that Rust doesn't allow using a `fmt::Formatter` (only in nightly), which is making my head hurt. Maybe someone of you can find a better way of doing this. Then, about `cursor.expect()`, this is the only place where we don't have the expected token type as a static string, so it's failing to compile. We have the option of changing the type definition of `ParseError` to contain an owned string, but maybe we can avoid this by having a `&'static str` come from a `TokenKind` with the default values, such as "identifier" for an identifier. I wanted for you to think about it and maybe we can just add that and avoid allocations there. Oh, and this depends on the VM-only branch, so that has to be merged before :) Another thing to check: should the interner be in its own module?
3 years ago
[package]
name = "boa_interner"
description = "String interner for the Boa JavaScript engine."
keywords = ["javascript", "js", "string", "interner"]
categories = ["data-structures", "no-std"]
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
Lexer string interning (#1758) This Pull Request is part of #279. It adds a string interner to Boa, which allows many types to not contain heap-allocated strings, and just contain a `NonZeroUsize` instead. This can move types to the stack (hopefully I'll be able to move `Token`, for example, maybe some `Node` types too. Note that the internet is for now only available in the lexer. Next steps (in this PR or future ones) would include also using interning in the parser, and finally in execution. The idea is that strings should be represented with a `Sym` until they are displayed. Talking about display. I have changed the `ParseError` type in order to not contain anything that could contain a `Sym` (basically tokens), which might be a bit faster, but what is important is that we don't depend on the interner when displaying errors. The issue I have now is in order to display tokens. This requires the interner if we want to know identifiers, for example. The issue here is that Rust doesn't allow using a `fmt::Formatter` (only in nightly), which is making my head hurt. Maybe someone of you can find a better way of doing this. Then, about `cursor.expect()`, this is the only place where we don't have the expected token type as a static string, so it's failing to compile. We have the option of changing the type definition of `ParseError` to contain an owned string, but maybe we can avoid this by having a `&'static str` come from a `TokenKind` with the default values, such as "identifier" for an identifier. I wanted for you to think about it and maybe we can just add that and avoid allocations there. Oh, and this depends on the VM-only branch, so that has to be merged before :) Another thing to check: should the interner be in its own module?
3 years ago
[features]
default = ["std"]
std = ["once_cell/std"]
Lexer string interning (#1758) This Pull Request is part of #279. It adds a string interner to Boa, which allows many types to not contain heap-allocated strings, and just contain a `NonZeroUsize` instead. This can move types to the stack (hopefully I'll be able to move `Token`, for example, maybe some `Node` types too. Note that the internet is for now only available in the lexer. Next steps (in this PR or future ones) would include also using interning in the parser, and finally in execution. The idea is that strings should be represented with a `Sym` until they are displayed. Talking about display. I have changed the `ParseError` type in order to not contain anything that could contain a `Sym` (basically tokens), which might be a bit faster, but what is important is that we don't depend on the interner when displaying errors. The issue I have now is in order to display tokens. This requires the interner if we want to know identifiers, for example. The issue here is that Rust doesn't allow using a `fmt::Formatter` (only in nightly), which is making my head hurt. Maybe someone of you can find a better way of doing this. Then, about `cursor.expect()`, this is the only place where we don't have the expected token type as a static string, so it's failing to compile. We have the option of changing the type definition of `ParseError` to contain an owned string, but maybe we can avoid this by having a `&'static str` come from a `TokenKind` with the default values, such as "identifier" for an identifier. I wanted for you to think about it and maybe we can just add that and avoid allocations there. Oh, and this depends on the VM-only branch, so that has to be merged before :) Another thing to check: should the interner be in its own module?
3 years ago
[dependencies]
boa_macros.workspace = true
phf = { version = "0.11.1", default-features = false, features = ["macros"] }
rustc-hash = { version = "1.1.0", default-features = false }
static_assertions = "1.1.0"
Bump once_cell from 1.17.0 to 1.17.1 (#2602) Bumps [once_cell](https://github.com/matklad/once_cell) from 1.17.0 to 1.17.1. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/matklad/once_cell/blob/master/CHANGELOG.md">once_cell's changelog</a>.</em></p> <blockquote> <h2>1.17.1</h2> <ul> <li>Make <code>OnceRef</code> implementation compliant with <a href="https://github-redirect.dependabot.com/rust-lang/rust/issues/95228">strict provenance</a>.</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/matklad/once_cell/commit/35148638c54c6233545c65d1a5e09d5ba0661806"><code>3514863</code></a> Merge <a href="https://github-redirect.dependabot.com/matklad/once_cell/issues/222">#222</a></li> <li><a href="https://github.com/matklad/once_cell/commit/f0ad5f083d4a6a51a61a0fa5ee9cdf0ed562178a"><code>f0ad5f0</code></a> Bump version to 1.17.1 and update the changelog.</li> <li><a href="https://github.com/matklad/once_cell/commit/78ab172105ef089c1568d1be11432c916694b64b"><code>78ab172</code></a> Merge <a href="https://github-redirect.dependabot.com/matklad/once_cell/issues/219">#219</a></li> <li><a href="https://github.com/matklad/once_cell/commit/6e351e5204e223f25baf4f63aefa861610ee3649"><code>6e351e5</code></a> Use AtomicPtr for race::OnceRef to avoid ptr-int-ptr casts (keeping</li> <li><a href="https://github.com/matklad/once_cell/commit/d706539c6f7cd47d0e8037d832c0c95214fb5f91"><code>d706539</code></a> Merge <a href="https://github-redirect.dependabot.com/matklad/once_cell/issues/214">#214</a></li> <li><a href="https://github.com/matklad/once_cell/commit/cc07949250ed44b208ff3d19af8f6b6577fea1e2"><code>cc07949</code></a> Explain safety of <code>unsync::OnceCell::get(&amp;self)</code> in more detail</li> <li><a href="https://github.com/matklad/once_cell/commit/af9d29c966beb51e53b419cad65c949d7744de21"><code>af9d29c</code></a> drop useless arg</li> <li>See full diff in <a href="https://github.com/matklad/once_cell/compare/v1.17.0...v1.17.1">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=once_cell&package-manager=cargo&previous-version=1.17.0&new-version=1.17.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>
2 years ago
once_cell = {version = "1.17.1", default-features = false, features = ["critical-section"]}
Bump indexmap from 1.9.1 to 1.9.2 (#2446) Bumps [indexmap](https://github.com/bluss/indexmap) from 1.9.1 to 1.9.2. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/bluss/indexmap/blob/master/RELEASES.md">indexmap's changelog</a>.</em></p> <blockquote> <ul> <li> <p>1.9.2</p> <ul> <li><code>IndexMap</code> and <code>IndexSet</code> both implement <code>arbitrary::Arbitrary&lt;'_&gt;</code> and <code>quickcheck::Arbitrary</code> if those optional dependency features are enabled.</li> </ul> </li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/bluss/indexmap/commit/4d52cf338c6ff9f742aac716f41b8a5497842f92"><code>4d52cf3</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/bluss/indexmap/issues/247">#247</a> from cuviper/arbitrary-1.x</li> <li><a href="https://github.com/bluss/indexmap/commit/4d410509d2e67c3d33e17c6d4cdbf622ea8458f8"><code>4d41050</code></a> Release 1.9.2</li> <li><a href="https://github.com/bluss/indexmap/commit/bc1a12f7f31993ca68bb64929d347caaba72415c"><code>bc1a12f</code></a> Add an Arbitrary release note</li> <li><a href="https://github.com/bluss/indexmap/commit/2251812717e75ba59630494fd76cd979840bcc3d"><code>2251812</code></a> impl Arbitrary for IndexMap and IndexSet</li> <li><a href="https://github.com/bluss/indexmap/commit/fe98ec2a03cf4e37813114682f3e46ab66e9af13"><code>fe98ec2</code></a> Revert &quot;Run CI on 1.56.1 until next hashbrown release&quot;</li> <li>See full diff in <a href="https://github.com/bluss/indexmap/compare/1.9.1...1.9.2">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=indexmap&package-manager=cargo&previous-version=1.9.1&new-version=1.9.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>
2 years ago
indexmap = "1.9.2"
serde = { version = "1.0.152", features = ["derive"], optional = true }
arbitrary = { version = "1", features = ["derive"], optional = true }
hashbrown = { version = "0.13.2", default-features = false, features = ["inline-more"] }