Skip to content

Commit dd472fe

Browse files
Merge 5b51ed0 into 87aea64
2 parents 87aea64 + 5b51ed0 commit dd472fe

File tree

68 files changed

+650
-177
lines changed

Some content is hidden

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

68 files changed

+650
-177
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

.vscode/tasks.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@
2020
"clear": true
2121
}
2222
},
23+
{
24+
"type": "process",
25+
"label": "Cargo Run (Profiler)",
26+
"command": "cargo",
27+
"args": ["run", "--features", "Boa/profiler", "../tests/js/test.js"],
28+
"problemMatcher": ["$rustc"],
29+
"group": {
30+
"kind": "build",
31+
"isDefault": true
32+
},
33+
"options": {
34+
"env": { "RUST_BACKTRACE": "full" },
35+
"cwd": "${workspaceFolder}/boa_cli"
36+
},
37+
"presentation": {
38+
"clear": true
39+
}
40+
},
2341
{
2442
"type": "process",
2543
"label": "Get Tokens",

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.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ See [CHANGELOG.md](./CHANGELOG.md).
6666
- Run with `cargo run -- test.js` where `test.js` is an existing JS file.
6767
- If any JS doesn't work then it's a bug. Please raise an issue!
6868

69+
## Profiling
70+
71+
See [Profiling](./docs/profiling.md)
72+
6973
## Command-line Options
7074

7175
```

boa/Cargo.toml

Lines changed: 6 additions & 1 deletion
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"
@@ -18,10 +21,12 @@ num-traits = "0.2.11"
1821
regex = "1.3.7"
1922
rustc-hash = "1.1.0"
2023
num-bigint = { version = "0.2.6", features = ["serde"] }
24+
bitflags = "1.2.1"
2125

2226
# Optional Dependencies
2327
serde = { version = "1.0.110", features = ["derive"], optional = true }
24-
bitflags = "1.2.1"
28+
measureme = { version = "0.7.1", optional = true }
29+
once_cell = { version = "1.4.0", optional = true }
2530

2631
[dev-dependencies]
2732
criterion = "0.3.2"

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
}

0 commit comments

Comments
 (0)