Skip to content

Commit

Permalink
Merge ab08c75 into bb2b6f6
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwilliams authored Jun 4, 2020
2 parents bb2b6f6 + ab08c75 commit 11baf79
Show file tree
Hide file tree
Showing 68 changed files with 645 additions and 177 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ yarn-error.log

# tests/js/test.js is used for testing changes locally
tests/js/test.js

# Profiling
*.string_data
*.string_index
*.events
chrome_profiler.json
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@
"clear": true
}
},
{
"type": "process",
"label": "Cargo Run (Profiler)",
"command": "cargo",
"args": ["run", "--features", "Boa/profiler", "../tests/js/test.js"],
"problemMatcher": ["$rustc"],
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"env": { "RUST_BACKTRACE": "full" },
"cwd": "${workspaceFolder}/boa_cli"
},
"presentation": {
"clear": true
}
},
{
"type": "process",
"label": "Get Tokens",
Expand Down
89 changes: 89 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ See [CHANGELOG.md](./CHANGELOG.md).
- Run with `cargo run -- test.js` where `test.js` is an existing JS file.
- If any JS doesn't work then it's a bug. Please raise an issue!

## Profiling

See [Profiling](./docs/profiling.md)

## Command-line Options

```
Expand Down
7 changes: 6 additions & 1 deletion boa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ license = "Unlicense/MIT"
exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"]
edition = "2018"

[features]
profiler = ["measureme", "once_cell"]

[dependencies]
gc = { version = "0.3.5", features = ["derive"] }
serde_json = "1.0.53"
Expand All @@ -18,10 +21,12 @@ num-traits = "0.2.11"
regex = "1.3.7"
rustc-hash = "1.1.0"
num-bigint = { version = "0.2.6", features = ["serde"] }
bitflags = "1.2.1"

# Optional Dependencies
serde = { version = "1.0.110", features = ["derive"], optional = true }
bitflags = "1.2.1"
measureme = { version = "0.7.1", optional = true }
once_cell = { version = "1.4.0", optional = true }

[dev-dependencies]
criterion = "0.3.2"
Expand Down
2 changes: 2 additions & 0 deletions boa/src/builtins/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::{
value::{same_value_zero, ResultValue, Value, ValueData},
},
exec::Interpreter,
BoaProfiler,
};
use std::{
borrow::Borrow,
Expand Down Expand Up @@ -1041,6 +1042,7 @@ impl Array {
/// Initialise the `Array` object on the global object.
#[inline]
pub(crate) fn init(global: &Value) {
let _timer = BoaProfiler::global().start_event("array", "init");
global.set_field("Array", Self::create(global));
}
}
2 changes: 2 additions & 0 deletions boa/src/builtins/bigint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
},
exec::Interpreter,
syntax::ast::bigint::BigInt as AstBigInt,
BoaProfiler,
};

#[cfg(test)]
Expand Down Expand Up @@ -138,6 +139,7 @@ impl BigInt {
/// Initialise the `BigInt` object on the global object.
#[inline]
pub(crate) fn init(global: &Value) {
let _timer = BoaProfiler::global().start_event("bigint", "init");
global.set_field("BigInt", Self::create(global));
}
}
2 changes: 2 additions & 0 deletions boa/src/builtins/boolean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
value::{ResultValue, Value, ValueData},
},
exec::Interpreter,
BoaProfiler,
};
use std::{borrow::Borrow, ops::Deref};

Expand Down Expand Up @@ -128,6 +129,7 @@ impl Boolean {
/// Initialise the `Boolean` object on the global object.
#[inline]
pub(crate) fn init(global: &Value) {
let _timer = BoaProfiler::global().start_event("boolean", "init");
global.set_field("Boolean", Self::create(global));
}
}
2 changes: 2 additions & 0 deletions boa/src/builtins/console/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::{
value::{display_obj, ResultValue, Value},
},
exec::Interpreter,
BoaProfiler,
};
use rustc_hash::FxHashMap;
use std::time::SystemTime;
Expand Down Expand Up @@ -554,5 +555,6 @@ pub fn create(global: &Value) -> Value {
/// Initialise the `console` object on the global object.
#[inline]
pub fn init(global: &Value) {
let _timer = BoaProfiler::global().start_event("console", "init");
global.set_field("console", create(global));
}
2 changes: 2 additions & 0 deletions boa/src/builtins/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::{
value::{ResultValue, Value},
},
exec::Interpreter,
profiler::BoaProfiler,
};

// mod eval;
Expand Down Expand Up @@ -81,6 +82,7 @@ impl Error {

/// Initialise the global object with the `Error` object.
pub(crate) fn init(global: &Value) {
let _timer = BoaProfiler::global().start_event("error", "init");
global.set_field("Error", Self::create(global));
}
}
2 changes: 2 additions & 0 deletions boa/src/builtins/error/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::{
value::{ResultValue, Value},
},
exec::Interpreter,
profiler::BoaProfiler,
};

/// JavaScript `RangeError` impleentation.
Expand Down Expand Up @@ -71,6 +72,7 @@ impl RangeError {

/// Initialise the global object with the `RangeError` object.
pub(crate) fn init(global: &Value) {
let _timer = BoaProfiler::global().start_event("rangeerror", "init");
global.set_field("RangeError", Self::create(global));
}
}
9 changes: 8 additions & 1 deletion boa/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::{
environment::lexical_environment::{new_function_environment, Environment},
exec::{Executable, Interpreter},
syntax::ast::node::{FormalParameter, StatementList},
BoaProfiler,
};
use gc::{unsafe_empty_trace, Finalize, Trace};
use std::fmt::{self, Debug};
Expand Down Expand Up @@ -142,6 +143,7 @@ impl Function {
where
P: Into<Box<[FormalParameter]>>,
{
let _timer = BoaProfiler::global().start_event("function::builtin", "function");
Self::new(
parameter_list.into(),
None,
Expand All @@ -163,6 +165,7 @@ impl Function {
interpreter: &mut Interpreter,
this_obj: &mut Value,
) -> ResultValue {
let _timer = BoaProfiler::global().start_event("function::call", "function");
if self.callable {
match self.body {
FunctionBody::BuiltIn(func) => func(this_obj, args_list, interpreter),
Expand Down Expand Up @@ -433,6 +436,9 @@ pub fn make_builtin_fn<N>(function: NativeFunctionData, name: N, parent: &Value,
where
N: Into<String>,
{
let name_copy: String = name.into();
let label = format!("{}{}", String::from("make_builtin_fn: "), &name_copy);
let _timer = BoaProfiler::global().start_event(&label, "init");
let func = Function::builtin(Vec::new(), function);

let mut new_func = Object::function();
Expand All @@ -441,11 +447,12 @@ where
let new_func_obj = Value::from(new_func);
new_func_obj.set_field("length", length);

parent.set_field(name.into(), new_func_obj);
parent.set_field(Value::from(name_copy), new_func_obj);
}

/// Initialise the `Function` object on the global object.
#[inline]
pub fn init(global: &Value) {
let _timer = BoaProfiler::global().start_event("function", "init");
global.set_field("Function", create(global));
}
3 changes: 2 additions & 1 deletion boa/src/builtins/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::builtins::{
property::Property,
value::{ResultValue, Value},
};
use crate::exec::Interpreter;
use crate::{exec::Interpreter, BoaProfiler};
use serde_json::{self, Value as JSONValue};

#[cfg(test)]
Expand Down Expand Up @@ -174,5 +174,6 @@ pub fn create(global: &Value) -> Value {
/// Initialise the `JSON` object on the global object.
#[inline]
pub fn init(global: &Value) {
let _timer = BoaProfiler::global().start_event("json", "init");
global.set_field("JSON", create(global));
}
Loading

0 comments on commit 11baf79

Please sign in to comment.