Skip to content

Commit

Permalink
Merge 78d542b into 87aea64
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwilliams authored May 30, 2020
2 parents 87aea64 + 78d542b commit be8e8f1
Show file tree
Hide file tree
Showing 65 changed files with 614 additions and 176 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.

5 changes: 5 additions & 0 deletions 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 @@ -21,6 +24,8 @@ num-bigint = { version = "0.2.6", features = ["serde"] }

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

[dev-dependencies]
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 @@ -21,6 +21,7 @@ use crate::{
value::{same_value_zero, ResultValue, Value, ValueData},
},
exec::Interpreter,
BoaProfiler,
};
use std::{
borrow::Borrow,
Expand Down Expand Up @@ -1042,6 +1043,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 @@ -20,6 +20,7 @@ use crate::{
},
exec::Interpreter,
syntax::ast::bigint::BigInt as AstBigInt,
BoaProfiler,
};

#[cfg(test)]
Expand Down Expand Up @@ -130,6 +131,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 @@ -520,5 +521,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 @@ -80,6 +81,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 @@ -91,6 +92,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 @@ -142,5 +142,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));
}
3 changes: 3 additions & 0 deletions boa/src/builtins/math/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,
BoaProfiler,
};
use rand::random;
use std::f64;
Expand Down Expand Up @@ -507,6 +508,7 @@ pub fn trunc(_: &mut Value, args: &[Value], _: &mut Interpreter) -> ResultValue

/// Create a new `Math` object
pub fn create(global: &Value) -> Value {
let _timer = BoaProfiler::global().start_event("math:create", "init");
let math = Value::new_object(Some(global));

math.set_field("E", Value::from(f64::consts::E));
Expand Down Expand Up @@ -553,5 +555,6 @@ pub fn create(global: &Value) -> Value {
/// Initialise the `Math` object on the global object.
#[inline]
pub fn init(global: &Value) {
let _timer = BoaProfiler::global().start_event("math", "init");
global.set_field("Math", create(global));
}
Loading

0 comments on commit be8e8f1

Please sign in to comment.