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.

17 lines
481 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"
version = "0.15.0"
edition = "2021"
rust-version = "1.60"
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
authors = ["boa-dev"]
description = "String interner used in Boa."
repository = "https://github.com/boa-dev/boa"
keywords = ["javascript", "js", "string", "interner"]
categories = ["data-structures"]
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
license = "Unlicense/MIT"
[dependencies]
string-interner = "0.14.0"
Bump serde from 1.0.136 to 1.0.137 (#2052) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.136 to 1.0.137. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/serde-rs/serde/releases">serde's releases</a>.</em></p> <blockquote> <h2>v1.0.137</h2> <ul> <li>Update documentation links to some data formats whose repos have moved (<a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2201">#2201</a>, thanks <a href="https://github.com/atouchet"><code>@​atouchet</code></a>)</li> <li>Fix declared <code>rust-version</code> of serde and serde_test (<a href="https://github-redirect.dependabot.com/serde-rs/serde/issues/2168">#2168</a>)</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/serde-rs/serde/commit/17c3c0cf863080477c10a52d289d8712173b0d36"><code>17c3c0c</code></a> Release 1.0.137</li> <li><a href="https://github.com/serde-rs/serde/commit/210e6c354e22ba348b3a26c5e3ffe7978db2b306"><code>210e6c3</code></a> Clean up clippy allows which are superseded by msrv in clippy.toml</li> <li><a href="https://github.com/serde-rs/serde/commit/41823a96df37ae62f688628a270aa570ae519bef"><code>41823a9</code></a> Ignore more type_repetition_in_bounds</li> <li><a href="https://github.com/serde-rs/serde/commit/7ca13ff240d748f459d6439563af492a05c27046"><code>7ca13ff</code></a> Ignore type_repetition_in_bounds lint that is incompatible with msrv</li> <li><a href="https://github.com/serde-rs/serde/commit/52391fd8683638d56fd16deaed5634ef535a54e9"><code>52391fd</code></a> Inform clippy of supported compiler version in clippy.toml</li> <li><a href="https://github.com/serde-rs/serde/commit/9b2d8dfc6b0b2c389d6a123e3e9152e0bd4c28ea"><code>9b2d8df</code></a> Add a miri test job in CI</li> <li><a href="https://github.com/serde-rs/serde/commit/07ba7ea8dd66fe240aff82456c01e9aeda47509c"><code>07ba7ea</code></a> Update workflows to actions/checkout@v3</li> <li><a href="https://github.com/serde-rs/serde/commit/9f29f6bb4ad5ec7db6b1b1ad787f668bd74c104e"><code>9f29f6b</code></a> Disable expandtest on miri</li> <li><a href="https://github.com/serde-rs/serde/commit/f6c104fd1da0a330a425c0344c1cf027f68f2b20"><code>f6c104f</code></a> Ignore unused ignore attribute warning in some configurations</li> <li><a href="https://github.com/serde-rs/serde/commit/8a3a6fb1013e9e15bbb085091c4cc65f87d58f5a"><code>8a3a6fb</code></a> Disable ui test on miri</li> <li>Additional commits viewable in <a href="https://github.com/serde-rs/serde/compare/v1.0.136...v1.0.137">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=serde&package-manager=cargo&previous-version=1.0.136&new-version=1.0.137)](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>
3 years ago
serde = { version = "1.0.137", features = ["derive"], optional = true }
gc = { version = "0.4.1", features = ["derive"] }