Skip to content

Commit d526ee1

Browse files
Merge 6c29d64 into 82908df
2 parents 82908df + 6c29d64 commit d526ee1

File tree

61 files changed

+568
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+568
-170
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ yarn-error.log
1717

1818
# tests/js/test.js is used for testing changes locally
1919
tests/js/test.js
20+
21+
# Profiling
22+
*.string_data
23+
*.string_index
24+
*.events
25+
chrome_profiler.json

Cargo.lock

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

boa/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ license = "Unlicense/MIT"
1010
exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"]
1111
edition = "2018"
1212

13+
[features]
14+
profiler = ["measureme", "once_cell"]
15+
1316
[dependencies]
1417
gc = { version = "0.3.5", features = ["derive"] }
1518
serde_json = "1.0.53"
@@ -21,6 +24,8 @@ num-bigint = { version = "0.2.6", features = ["serde"] }
2124

2225
# Optional Dependencies
2326
serde = { version = "1.0.110", features = ["derive"], optional = true }
27+
measureme = { version = "0.7.1", optional = true }
28+
once_cell = { version = "1.4.0", optional = true }
2429
bitflags = "1.2.1"
2530

2631
[dev-dependencies]

boa/src/builtins/array/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use crate::{
2121
value::{same_value_zero, ResultValue, Value, ValueData},
2222
},
2323
exec::Interpreter,
24+
BoaProfiler,
2425
};
2526
use std::{
2627
borrow::Borrow,
@@ -1042,6 +1043,7 @@ impl Array {
10421043
/// Initialise the `Array` object on the global object.
10431044
#[inline]
10441045
pub(crate) fn init(global: &Value) {
1046+
let _timer = BoaProfiler::global().start_event("array", "init");
10451047
global.set_field("Array", Self::create(global));
10461048
}
10471049
}

boa/src/builtins/bigint/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use crate::{
2020
},
2121
exec::Interpreter,
2222
syntax::ast::bigint::BigInt as AstBigInt,
23+
BoaProfiler,
2324
};
2425

2526
#[cfg(test)]
@@ -130,6 +131,7 @@ impl BigInt {
130131
/// Initialise the `BigInt` object on the global object.
131132
#[inline]
132133
pub(crate) fn init(global: &Value) {
134+
let _timer = BoaProfiler::global().start_event("bigint", "init");
133135
global.set_field("BigInt", Self::create(global));
134136
}
135137
}

boa/src/builtins/boolean/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::{
1919
value::{ResultValue, Value, ValueData},
2020
},
2121
exec::Interpreter,
22+
BoaProfiler,
2223
};
2324
use std::{borrow::Borrow, ops::Deref};
2425

@@ -128,6 +129,7 @@ impl Boolean {
128129
/// Initialise the `Boolean` object on the global object.
129130
#[inline]
130131
pub(crate) fn init(global: &Value) {
132+
let _timer = BoaProfiler::global().start_event("boolean", "init");
131133
global.set_field("Boolean", Self::create(global));
132134
}
133135
}

boa/src/builtins/console/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use crate::{
2323
value::{display_obj, ResultValue, Value},
2424
},
2525
exec::Interpreter,
26+
BoaProfiler,
2627
};
2728
use rustc_hash::FxHashMap;
2829
use std::time::SystemTime;
@@ -520,5 +521,6 @@ pub fn create(global: &Value) -> Value {
520521
/// Initialise the `console` object on the global object.
521522
#[inline]
522523
pub fn init(global: &Value) {
524+
let _timer = BoaProfiler::global().start_event("console", "init");
523525
global.set_field("console", create(global));
524526
}

boa/src/builtins/error/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::{
1717
value::{ResultValue, Value},
1818
},
1919
exec::Interpreter,
20+
profiler::BoaProfiler,
2021
};
2122

2223
// mod eval;
@@ -80,6 +81,7 @@ impl Error {
8081

8182
/// Initialise the global object with the `Error` object.
8283
pub(crate) fn init(global: &Value) {
84+
let _timer = BoaProfiler::global().start_event("error", "init");
8385
global.set_field("Error", Self::create(global));
8486
}
8587
}

boa/src/builtins/error/range.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::{
1717
value::{ResultValue, Value},
1818
},
1919
exec::Interpreter,
20+
profiler::BoaProfiler,
2021
};
2122

2223
/// JavaScript `RangeError` impleentation.
@@ -91,6 +92,7 @@ impl RangeError {
9192

9293
/// Initialise the global object with the `RangeError` object.
9394
pub(crate) fn init(global: &Value) {
95+
let _timer = BoaProfiler::global().start_event("rangeerror", "init");
9496
global.set_field("RangeError", Self::create(global));
9597
}
9698
}

boa/src/builtins/function/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use crate::{
2222
environment::lexical_environment::{new_function_environment, Environment},
2323
exec::{Executable, Interpreter},
2424
syntax::ast::node::{FormalParameter, StatementList},
25+
BoaProfiler,
2526
};
2627
use gc::{unsafe_empty_trace, Finalize, Trace};
2728
use std::fmt::{self, Debug};
@@ -447,5 +448,6 @@ where
447448
/// Initialise the `Function` object on the global object.
448449
#[inline]
449450
pub fn init(global: &Value) {
451+
let _timer = BoaProfiler::global().start_event("function", "init");
450452
global.set_field("Function", create(global));
451453
}

0 commit comments

Comments
 (0)