|
|
|
[package]
|
|
|
|
name = "boa_engine"
|
|
|
|
version = "0.14.0"
|
|
|
|
edition = "2021"
|
|
|
|
rust-version = "1.58"
|
|
|
|
authors = ["boa-dev"]
|
|
|
|
description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language."
|
|
|
|
repository = "https://github.com/boa-dev/boa"
|
|
|
|
keywords = ["javascript", "js", "compiler", "lexer", "parser"]
|
|
|
|
categories = ["parser-implementations", "compilers"]
|
|
|
|
license = "Unlicense/MIT"
|
|
|
|
readme = "../README.md"
|
|
|
|
|
|
|
|
[features]
|
|
|
|
profiler = ["boa_profiler/profiler"]
|
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
|
|
|
deser = ["boa_interner/serde"]
|
|
|
|
|
|
|
|
# Enable Boa's WHATWG console object implementation.
|
|
|
|
console = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
boa_unicode = { path = "../boa_unicode", version = "0.14.0" }
|
|
|
|
boa_interner = { path = "../boa_interner", version = "0.14.0" }
|
|
|
|
boa_gc = { path = "../boa_gc", version = "0.14.0" }
|
|
|
|
gc = "0.4.1"
|
|
|
|
boa_profiler = { path = "../boa_profiler", version = "0.14.0" }
|
|
|
|
serde = { version = "1.0.136", features = ["derive", "rc"] }
|
|
|
|
serde_json = "1.0.79"
|
|
|
|
rand = "0.8.5"
|
|
|
|
num-traits = "0.2.14"
|
|
|
|
regress = "0.4.1"
|
|
|
|
rustc-hash = "1.1.0"
|
|
|
|
num-bigint = { version = "0.4.3", features = ["serde"] }
|
|
|
|
num-integer = "0.1.45"
|
|
|
|
bitflags = "1.3.2"
|
|
|
|
indexmap = "1.8.1"
|
|
|
|
ryu-js = "0.2.2"
|
|
|
|
chrono = "0.4.19"
|
|
|
|
fast-float = "0.2.0"
|
|
|
|
unicode-normalization = "0.1.19"
|
|
|
|
dyn-clone = "1.0.5"
|
|
|
|
once_cell = "1.10.0"
|
|
|
|
tap = "1.0.1"
|
|
|
|
|
|
|
|
[dev-dependencies]
|
|
|
|
criterion = "0.3.5"
|
|
|
|
float-cmp = "0.9.0"
|
|
|
|
|
|
|
|
[target.x86_64-unknown-linux-gnu.dev-dependencies]
|
|
|
|
jemallocator = "0.3.2"
|
|
|
|
|
|
|
|
[lib]
|
|
|
|
crate-type = ["cdylib", "lib"]
|
|
|
|
name = "boa_engine"
|
|
|
|
bench = false
|
|
|
|
|
|
|
|
[[bench]]
|
|
|
|
name = "full"
|
|
|
|
harness = false
|