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 Dec 25, 2021
1 parent dfb3df5 commit a90a690
Show file tree
Hide file tree
Showing 120 changed files with 3,157 additions and 1,797 deletions.
26 changes: 26 additions & 0 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 boa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ once_cell = "1.9.0"

# Optional Dependencies
measureme = { version = "10.0.0", optional = true }
string-interner = "0.14.0"

[target.wasm32-unknown-unknown.dependencies]
getrandom = { version = "0.2.3", features = ["js"] }
Expand Down
13 changes: 8 additions & 5 deletions boa/benches/full.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Benchmarks of the whole execution engine in Boa.

use boa::{parse, realm::Realm, Context};
use boa::{interner::Interner, realm::Realm, syntax::Parser, Context};
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 +20,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 +31,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 +45,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 a90a690

Please sign in to comment.