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.

161 lines
5.3 KiB

[package]
name = "boa_engine"
keywords = ["javascript", "js", "compiler", "lexer", "parser"]
categories = ["parser-implementations", "compilers"]
readme = "../../README.md"
description.workspace = true
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
[features]
profiler = ["boa_profiler/profiler"]
deser = ["boa_interner/serde", "boa_ast/serde"]
either = ["dep:either"]
# Enables the `Intl` builtin object and bundles a default ICU4X data provider.
# Prefer this over `intl` if you just want to enable `Intl` without dealing with the
# generation of ICU4X data.
intl_bundled = ["intl", "dep:boa_icu_provider"]
# Enables Boa's `Intl` builtin implementation.
# Prefer this over `intl_bundled` if you want to reduce the size of the final binary
# by providing a smaller ICU4X data provider.
intl = [
"boa_gc/icu",
"icu_normalizer/serde",
"icu_normalizer/std",
"dep:icu_locid_transform",
"dep:icu_locid",
"dep:icu_datetime",
"dep:icu_plurals",
"dep:icu_provider",
"dep:icu_calendar",
"dep:icu_collator",
"dep:icu_casemap",
"dep:icu_list",
"dep:icu_segmenter",
"dep:icu_decimal",
"dep:writeable",
"dep:sys-locale",
"dep:yoke",
"dep:zerofrom",
"dep:fixed_decimal",
"dep:tinystr",
]
fuzz = ["boa_ast/arbitrary", "boa_interner/arbitrary"]
Implement instruction flowgraph generator (#2422) This PR is a WIP implementation of a vm instruction flowgraph generator This aims to make the vm easier to debug and understand for both newcomers and experienced devs. For example if we have the following code: ```js let i = 0; while (i < 10) { if (i == 3) { break; } i++; } ``` It generates the following instructions (which is hard to read, especially jumps): <details> ``` ----------------------Compiled Output: '<main>'----------------------- Location Count Opcode Operands 000000 0000 PushZero 000001 0001 DefInitLet 0000: 'i' 000006 0002 LoopStart 000007 0003 LoopContinue 000008 0004 GetName 0000: 'i' 000013 0005 PushInt8 10 000015 0006 LessThan 000016 0007 JumpIfFalse 78 000021 0008 PushDeclarativeEnvironment 0, 1 000030 0009 GetName 0000: 'i' 000035 0010 PushInt8 3 000037 0011 Eq 000038 0012 JumpIfFalse 58 000043 0013 PushDeclarativeEnvironment 0, 0 000052 0014 Jump 78 000057 0015 PopEnvironment 000058 0016 GetName 0000: 'i' 000063 0017 IncPost 000064 0018 RotateRight 2 000066 0019 SetName 0000: 'i' 000071 0020 Pop 000072 0021 PopEnvironment 000073 0022 Jump 7 000078 0023 LoopEnd Literals: <empty> Bindings: 0000: i Functions: <empty> ``` </details> And the flow graph is generated: ![flowgraph](https://user-images.githubusercontent.com/8566042/200589387-40b36ad7-d2f2-4918-a3e4-5a8fa5eee89b.png) The beginning of the function is marked by the `start` node (in green) and end (in red). In branching the "yes" branch is marked in green and "no" in red. ~~This only generates in [graphviz format](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) (a widely used format) but it would be nice to also generate to a format that `mermaid.js` can understand and that could be put in articles https://github.com/boa-dev/boa-dev.github.io/issues/26~~ TODO: - [x] Generate graphviz format - [x] Generate mermaid format - [x] Programmatically generate colors push and pop env instructions - [x] Display nested functions in sub-sub-graphs. - [x] Put under a feature (`"flowgraph"`) - [x] Handle try/catch, switch instructions - [x] CLI option for configuring direction of flow (by default it is top down) - [x] Handle `Throw` instruction (requires keeping track of try blocks) - [x] Documentation - [x] Prevent node name collisions (functions with the same name)
2 years ago
# Enable Boa's VM instruction flowgraph generator.
flowgraph = []
# Enable Boa's VM instruction tracing.
trace = ["js"]
# Enable Boa's additional ECMAScript features for web browsers.
annex-b = ["boa_parser/annex-b"]
# Enable Boa's Temporal proposal implementation
temporal = ["dep:icu_calendar", "dep:temporal_rs"]
# Enable experimental features, like Stage 3 proposals.
experimental = ["temporal"]
# Enable binding to JS APIs for system related utilities.
js = ["dep:web-time"]
[dependencies]
boa_interner.workspace = true
boa_gc = { workspace = true, features = ["thin-vec", "boa_string"] }
boa_profiler.workspace = true
boa_macros.workspace = true
boa_ast.workspace = true
boa_parser.workspace = true
boa_string.workspace = true
serde = { workspace = true, features = ["derive", "rc"] }
serde_json.workspace = true
rand.workspace = true
num-traits.workspace = true
regress.workspace = true
rustc-hash = { workspace = true, features = ["std"] }
num-bigint = { workspace = true, features = ["serde"] }
num-integer.workspace = true
bitflags.workspace = true
indexmap = { workspace = true, features = ["std"] }
ryu-js.workspace = true
fast-float.workspace = true
once_cell = { workspace = true, features = ["std"] }
tap.workspace = true
sptr.workspace = true
thiserror.workspace = true
dashmap.workspace = true
num_enum.workspace = true
pollster.workspace = true
thin-vec.workspace = true
itertools = { workspace = true, default-features = false }
icu_normalizer = { workspace = true, features = ["compiled_data"] }
portable-atomic.workspace = true
bytemuck = { workspace = true, features = ["derive"] }
arrayvec.workspace = true
intrusive-collections.workspace = true
cfg-if.workspace = true
time.workspace = true
hashbrown.workspace = true
either = { workspace = true, optional = true }
static_assertions.workspace = true
# intl deps
boa_icu_provider = { workspace = true, features = ["std"], optional = true }
sys-locale = { workspace = true, optional = true }
icu_provider = { workspace = true, optional = true }
icu_locid = { workspace = true, features = ["serde"], optional = true }
icu_locid_transform = { workspace = true, default-features = false, features = ["std", "serde"], optional = true }
icu_datetime = { workspace = true, default-features = false, features = ["serde", "experimental"], optional = true }
icu_calendar = { workspace = true, default-features = false, optional = true }
icu_collator = { workspace = true, default-features = false, features = ["serde"], optional = true }
icu_plurals = { workspace = true, default-features = false, features = ["serde", "experimental"], optional = true }
icu_list = { workspace = true, default-features = false, features = ["serde"], optional = true }
icu_casemap = { workspace = true, default-features = false, features = ["serde"], optional = true }
icu_segmenter = { workspace = true, default-features = false, features = ["auto", "serde"], optional = true }
icu_decimal = { workspace = true, default-features = false, features = ["serde"], optional = true }
writeable = { workspace = true, optional = true }
yoke = { workspace = true, optional = true }
zerofrom = { workspace = true, optional = true }
fixed_decimal = { workspace = true, features = ["ryu", "experimental"], optional = true }
tinystr = { workspace = true, optional = true }
# temporal deps
temporal_rs = { workspace = true, optional = true }
[target.'cfg(all(target_family = "wasm", not(any(target_os = "emscripten", target_os = "wasi"))))'.dependencies]
web-time = { workspace = true, optional = true }
[dev-dependencies]
criterion.workspace = true
float-cmp.workspace = true
indoc.workspace = true
textwrap.workspace = true
futures-lite.workspace = true
test-case.workspace = true
[target.x86_64-unknown-linux-gnu.dev-dependencies]
jemallocator.workspace = true
[lib]
crate-type = ["cdylib", "lib"]
name = "boa_engine"
bench = false
[[bench]]
name = "full"
harness = false
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true