Skip to content

Commit

Permalink
First version of the interner
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican committed Jan 2, 2022
1 parent d831ff3 commit 6d63566
Show file tree
Hide file tree
Showing 125 changed files with 3,317 additions and 1,819 deletions.
58 changes: 46 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"boa_wasm",
"boa_tester",
"boa_unicode",
"boa_interner",
]

# The release profile, used for `cargo build --release`.
Expand Down
3 changes: 2 additions & 1 deletion boa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ rust-version = "1.57"

[features]
profiler = ["measureme"]
deser = []
deser = ["boa_interner/serde"]

# Enable Boa's WHATWG console object implementation.
console = []

[dependencies]
boa_unicode = { path = "../boa_unicode", version = "0.13.0" }
boa_interner = { path = "../boa_interner", version = "0.13.0" }
gc = { version = "0.4.1", features = ["derive"] }
serde = { version = "1.0.132", features = ["derive", "rc"] }
serde_json = "1.0.73"
Expand Down
14 changes: 9 additions & 5 deletions boa/benches/full.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Benchmarks of the whole execution engine in Boa.

use boa::{parse, realm::Realm, Context};
use boa::{realm::Realm, syntax::Parser, Context};
use boa_interner::Interner;
use criterion::{black_box, criterion_group, criterion_main, Criterion};

#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))]
Expand All @@ -20,8 +21,9 @@ macro_rules! full_benchmarks {
$(
{
static CODE: &str = include_str!(concat!("bench_scripts/", stringify!($name), ".js"));
let mut interner = Interner::new();
c.bench_function(concat!($id, " (Parser)"), move |b| {
b.iter(|| parse(black_box(CODE), false))
b.iter(|| Parser::new(black_box(CODE.as_bytes()), false).parse_all(&mut interner))
});
}
)*
Expand All @@ -30,7 +32,8 @@ macro_rules! full_benchmarks {
$(
{
static CODE: &str = include_str!(concat!("bench_scripts/", stringify!($name), ".js"));
let statement_list = parse(CODE, false).unwrap();
let mut interner = Interner::new();
let statement_list = Parser::new(CODE.as_bytes(), false).parse_all( &mut interner).expect("parsing failed");
c.bench_function(concat!($id, " (Compiler)"), move |b| {
b.iter(|| {
Context::compile(black_box(statement_list.clone()));
Expand All @@ -43,9 +46,10 @@ macro_rules! full_benchmarks {
$(
{
static CODE: &str = include_str!(concat!("bench_scripts/", stringify!($name), ".js"));
let statement_list = parse(CODE, false).unwrap();
let mut interner = Interner::new();
let statement_list = Parser::new(CODE.as_bytes(), false).parse_all( &mut interner).expect("parsing failed");
let code_block = Context::compile(statement_list);
let mut context = Context::new();
let mut context = Context::default();
c.bench_function(concat!($id, " (Execution)"), move |b| {
b.iter(|| {
context.execute(black_box(code_block.clone())).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion boa/examples/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Class for Person {

fn main() {
// First we need to create a Javascript context.
let mut context = Context::new();
let mut context = Context::default();

// Then we need to register the global class `Person` inside `context`.
context.register_global_class::<Person>().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion boa/examples/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use boa::{

fn main() -> Result<(), JsValue> {
// We create a new `Context` to create a new Javascript executor.
let mut context = Context::new();
let mut context = Context::default();

// We make some operations in Rust that return a `Copy` value that we want
// to pass to a Javascript function.
Expand Down

0 comments on commit 6d63566

Please sign in to comment.