Skip to content

Commit

Permalink
Separated GC and Profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican committed Feb 17, 2022
1 parent 748465d commit c595aa5
Show file tree
Hide file tree
Showing 318 changed files with 853 additions and 779 deletions.
82 changes: 49 additions & 33 deletions Cargo.lock

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

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[workspace]
members = [
"boa",
"boa_cli",
"boa_wasm",
"boa_engine",
"boa_gc",
"boa_interner",
"boa_profiler",
"boa_tester",
"boa_unicode",
"boa_interner",
"boa_wasm",

]

# The release profile, used for `cargo build --release`.
Expand Down
10 changes: 0 additions & 10 deletions boa/src/gc.rs

This file was deleted.

25 changes: 21 additions & 4 deletions boa_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
[package]
name = "boa_cli"
version = "0.13.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", "compiler", "lexer", "parser", "js", "cli"]
categories = ["command-line-utilities"]
license = "Unlicense/MIT"
exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"]
edition = "2021"
rust-version = "1.58"
default-run = "boa"
exclude = [
"../.vscode/*",
"../.editorconfig",
"../test262/*",
"../node_modules/*",
"../target/*",
"../dist/*",
"../.github/*",
"../assets/*",
"../docs/*",
"../*.js",
"../test_ignore.txt",
"../yarn.lock",
"../package.json",
"../index.html",
"../tests/*",
"../.github/*",
]

[dependencies]
Boa = { path = "../boa", features = ["deser", "console"] }
boa_engine = { path = "../boa_engine", features = ["deser", "console"] }
rustyline = "9.1.2"
rustyline-derive = "0.6.0"
structopt = "0.3.26"
Expand Down
4 changes: 2 additions & 2 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
rustdoc::missing_doc_code_examples
)]

use boa::{syntax::ast::node::StatementList, Context, Interner};
use boa_engine::{syntax::ast::node::StatementList, Context, Interner};
use colored::{Color, Colorize};
use rustyline::{config::Config, error::ReadlineError, EditMode, Editor};
use std::{fs::read, io, path::PathBuf};
Expand Down Expand Up @@ -146,7 +146,7 @@ fn parse_tokens<S>(src: S, interner: &mut Interner) -> Result<StatementList, Str
where
S: AsRef<[u8]>,
{
use boa::syntax::parser::Parser;
use boa_engine::syntax::parser::Parser;

let src_bytes = src.as_ref();
Parser::new(src_bytes, false)
Expand Down
40 changes: 28 additions & 12 deletions boa/Cargo.toml → boa_engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
[package]
name = "Boa"
name = "boa_engine"
version = "0.13.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", "compiler", "lexer", "parser", "js"]
categories = ["parser-implementations", "wasm"]
keywords = ["javascript", "js", "compiler", "lexer", "parser"]
categories = ["parser-implementations", "compilers"]
license = "Unlicense/MIT"
exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"]
edition = "2021"
rust-version = "1.58"
exclude = [
"../.vscode/*",
"../.editorconfig",
"../test262/*",
"../node_modules/*",
"../target/*",
"../dist/*",
"../.github/*",
"../assets/*",
"../docs/*",
"../*.js",
"../test_ignore.txt",
"../yarn.lock",
"../package.json",
"../index.html",
"../tests/*",
"../.github/*",
]

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

# Enable Boa's WHATWG console object implementation.
Expand All @@ -21,7 +38,9 @@ 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"] }
boa_gc = { path = "../boa_gc", version = "0.13.0" }
gc = { version = "0.4.1" }
boa_profiler = { path = "../boa_profiler", version = "0.13.0" }
serde = { version = "1.0.136", features = ["derive", "rc"] }
serde_json = "1.0.79"
rand = "0.8.5"
Expand All @@ -39,9 +58,6 @@ unicode-normalization = "0.1.19"
dyn-clone = "1.0.4"
once_cell = "1.9.0"

# Optional Dependencies
measureme = { version = "10.0.0", optional = true }

[target.wasm32-unknown-unknown.dependencies]
getrandom = { version = "0.2.4", features = ["js"] }

Expand All @@ -54,7 +70,7 @@ jemallocator = "0.3.2"

[lib]
crate-type = ["cdylib", "lib"]
name = "boa"
name = "boa_engine"
bench = false

[[bench]]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion boa/benches/full.rs → boa_engine/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::{realm::Realm, Context};
use boa_engine::{realm::Realm, Context};
use criterion::{black_box, criterion_group, criterion_main, Criterion};

#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))]
Expand Down
4 changes: 2 additions & 2 deletions boa/examples/classes.rs → boa_engine/examples/classes.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// NOTE: this example requires the `console` feature to run correctly.

use boa::{
use boa_engine::{
class::{Class, ClassBuilder},
gc::{Finalize, Trace},
property::Attribute,
Context, JsResult, JsValue,
};
use boa_gc::{Finalize, Trace};

// We create a new struct that is going to represent a person.
//
Expand Down
4 changes: 2 additions & 2 deletions boa/examples/closures.rs → boa_engine/examples/closures.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This example goes into the details on how to pass closures as functions
// inside Rust and call them from Javascript.

use boa::{
gc::{Finalize, Trace},
use boa_engine::{
object::{FunctionBuilder, JsObject},
property::{Attribute, PropertyDescriptor},
Context, JsString, JsValue,
};
use boa_gc::{Finalize, Trace};

fn main() -> Result<(), JsValue> {
// We create a new `Context` to create a new Javascript executor.
Expand Down
18 changes: 6 additions & 12 deletions boa/src/bigint.rs → boa_engine/src/bigint.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
//! This module implements the JavaScript bigint primitive rust type.

use crate::{
builtins::Number,
gc::{empty_trace, Finalize, Trace},
Context, JsValue,
};

use crate::{builtins::Number, Context, JsValue};
use boa_gc::{unsafe_empty_trace, Finalize, Trace};
use num_integer::Integer;
use num_traits::pow::Pow;
use num_traits::{FromPrimitive, One, ToPrimitive, Zero};
use std::{
convert::TryFrom,
fmt::{self, Display},
ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub},
rc::Rc,
};

use num_integer::Integer;
use num_traits::pow::Pow;
use num_traits::{FromPrimitive, One, ToPrimitive, Zero};

/// The raw bigint type.
pub type RawBigInt = num_bigint::BigInt;

Expand All @@ -33,7 +27,7 @@ pub struct JsBigInt {
// Safety: BigInt does not contain any objects which needs to be traced,
// so this is safe.
unsafe impl Trace for JsBigInt {
empty_trace!();
unsafe_empty_trace!();
}

impl JsBigInt {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{
builtins::{function::make_builtin_fn, iterable::create_iter_result_object, Array, JsValue},
gc::{Finalize, Trace},
object::{JsObject, ObjectData},
property::{PropertyDescriptor, PropertyNameKind},
symbol::WellKnownSymbols,
BoaProfiler, Context, JsResult,
Profiler, Context, JsResult,
};
use boa_gc::{Finalize, Trace};

/// The Array Iterator object represents an iteration over an array. It implements the iterator protocol.
///
Expand Down Expand Up @@ -121,7 +121,7 @@ impl ArrayIterator {
iterator_prototype: JsObject,
context: &mut Context,
) -> JsObject {
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let _timer = Profiler::global().start_event(Self::NAME, "init");

// Create prototype
let array_iterator =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
property::{Attribute, PropertyDescriptor, PropertyNameKind},
symbol::WellKnownSymbols,
value::{IntegerOrInfinity, JsValue},
BoaProfiler, Context, JsResult, JsString,
Profiler, Context, JsResult, JsString,
};
use std::cmp::{max, min, Ordering};

Expand All @@ -43,7 +43,7 @@ impl BuiltIn for Array {
.union(Attribute::CONFIGURABLE);

fn init(context: &mut Context) -> JsValue {
let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let _timer = Profiler::global().start_event(Self::NAME, "init");

let symbol_iterator = WellKnownSymbols::iterator();

Expand Down
File renamed without changes.

0 comments on commit c595aa5

Please sign in to comment.