Skip to content

Commit

Permalink
Merge 5de9828 into 3e2e566
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican authored Jul 15, 2020
2 parents 3e2e566 + 5de9828 commit fa950d4
Show file tree
Hide file tree
Showing 72 changed files with 4,084 additions and 1,984 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "test262"]
path = test262
url = https://github.com/tc39/test262.git
55 changes: 51 additions & 4 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ members = [
"boa",
"boa_cli",
"boa_wasm",
"tester",
]

# The release profile, used for `cargo build --release`.
Expand Down
126 changes: 35 additions & 91 deletions boa/benches/exec.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::{exec::Interpreter, realm::Realm, Executable, Lexer, Parser};
use boa::{exec::Interpreter, realm::Realm, Executable, Parser};
use criterion::{black_box, criterion_group, criterion_main, Criterion};

#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))]
Expand All @@ -25,12 +25,8 @@ fn symbol_creation(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

// Lex all the tokens.
let mut lexer = Lexer::new(SYMBOL_CREATION);
lexer.lex().expect("failed to lex");

// Parse the AST nodes.
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(SYMBOL_CREATION.as_bytes()).parse_all().unwrap();

// Execute the parsed nodes, passing them through a black box, to avoid over-optimizing by the compiler
c.bench_function("Symbols (Execution)", move |b| {
Expand All @@ -56,12 +52,8 @@ fn for_loop_execution(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

// Lex all the tokens.
let mut lexer = Lexer::new(FOR_LOOP);
lexer.lex().expect("failed to lex");

// Parse the AST nodes.
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(FOR_LOOP.as_bytes()).parse_all().unwrap();

// Execute the parsed nodes, passing them through a black box, to avoid over-optimizing by the compiler
c.bench_function("For loop (Execution)", move |b| {
Expand All @@ -87,12 +79,8 @@ fn fibonacci(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

// Lex all the tokens.
let mut lexer = Lexer::new(FIBONACCI);
lexer.lex().expect("failed to lex");

// Parse the AST nodes.
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(FIBONACCI.as_bytes()).parse_all().unwrap();

// Execute the parsed nodes, passing them through a black box, to avoid over-optimizing by the compiler
c.bench_function("Fibonacci (Execution)", move |b| {
Expand All @@ -116,12 +104,8 @@ fn object_creation(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

// Lex all the tokens.
let mut lexer = Lexer::new(OBJECT_CREATION);
lexer.lex().expect("failed to lex");

// Parse the AST nodes.
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(OBJECT_CREATION.as_bytes()).parse_all().unwrap();

// Execute the parsed nodes, passing them through a black box, to avoid over-optimizing by the compiler
c.bench_function("Object Creation (Execution)", move |b| {
Expand All @@ -145,12 +129,10 @@ fn object_prop_access_const(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

// Lex all the tokens.
let mut lexer = Lexer::new(OBJECT_PROP_ACCESS_CONST);
lexer.lex().expect("failed to lex");

// Parse the AST nodes.
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(OBJECT_PROP_ACCESS_CONST.as_bytes())
.parse_all()
.unwrap();

// Execute the parsed nodes, passing them through a black box, to avoid over-optimizing by the compiler
c.bench_function("Static Object Property Access (Execution)", move |b| {
Expand All @@ -174,12 +156,10 @@ fn object_prop_access_dyn(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

// Lex all the tokens.
let mut lexer = Lexer::new(OBJECT_PROP_ACCESS_DYN);
lexer.lex().expect("failed to lex");

// Parse the AST nodes.
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(OBJECT_PROP_ACCESS_DYN.as_bytes())
.parse_all()
.unwrap();

// Execute the parsed nodes, passing them through a black box, to avoid over-optimizing by the compiler
c.bench_function("Dynamic Object Property Access (Execution)", move |b| {
Expand All @@ -200,12 +180,10 @@ fn regexp_literal_creation(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

// Lex all the tokens.
let mut lexer = Lexer::new(REGEXP_LITERAL_CREATION);
lexer.lex().expect("failed to lex");

// Parse the AST nodes.
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(REGEXP_LITERAL_CREATION.as_bytes())
.parse_all()
.unwrap();

// Execute the parsed nodes, passing them through a black box, to avoid over-optimizing by the compiler
c.bench_function("RegExp Literal Creation (Execution)", move |b| {
Expand All @@ -226,12 +204,8 @@ fn regexp_creation(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

// Lex all the tokens.
let mut lexer = Lexer::new(REGEXP_CREATION);
lexer.lex().expect("failed to lex");

// Parse the AST nodes.
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(REGEXP_CREATION.as_bytes()).parse_all().unwrap();

// Execute the parsed nodes, passing them through a black box, to avoid over-optimizing by the compiler
c.bench_function("RegExp (Execution)", move |b| {
Expand All @@ -252,12 +226,8 @@ fn regexp_literal(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

// Lex all the tokens.
let mut lexer = Lexer::new(REGEXP_LITERAL);
lexer.lex().expect("failed to lex");

// Parse the AST nodes.
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(REGEXP_LITERAL.as_bytes()).parse_all().unwrap();

// Execute the parsed nodes, passing them through a black box, to avoid over-optimizing by the compiler
c.bench_function("RegExp Literal (Execution)", move |b| {
Expand All @@ -278,12 +248,8 @@ fn regexp(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

// Lex all the tokens.
let mut lexer = Lexer::new(REGEXP);
lexer.lex().expect("failed to lex");

// Parse the AST nodes.
let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(REGEXP.as_bytes()).parse_all().unwrap();

// Execute the parsed nodes, passing them through a black box, to avoid over-optimizing by the compiler
c.bench_function("RegExp (Execution)", move |b| {
Expand All @@ -305,10 +271,7 @@ fn array_access(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

let mut lexer = Lexer::new(ARRAY_ACCESS);
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(ARRAY_ACCESS.as_bytes()).parse_all().unwrap();

c.bench_function("Array access (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand All @@ -330,10 +293,7 @@ fn array_creation(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

let mut lexer = Lexer::new(ARRAY_CREATE);
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(ARRAY_CREATE.as_bytes()).parse_all().unwrap();

c.bench_function("Array creation (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand Down Expand Up @@ -371,10 +331,7 @@ fn array_pop(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

let mut lexer = Lexer::new(ARRAY_POP);
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(ARRAY_POP.as_bytes()).parse_all().unwrap();

c.bench_function("Array pop (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand All @@ -394,10 +351,7 @@ fn string_concat(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

let mut lexer = Lexer::new(STRING_CONCAT);
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(STRING_CONCAT.as_bytes()).parse_all().unwrap();

c.bench_function("String concatenation (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand All @@ -420,10 +374,7 @@ fn string_compare(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

let mut lexer = Lexer::new(STRING_COMPARE);
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(STRING_COMPARE.as_bytes()).parse_all().unwrap();

c.bench_function("String comparison (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand All @@ -441,10 +392,7 @@ fn string_copy(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

let mut lexer = Lexer::new(STRING_COPY);
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(STRING_COPY.as_bytes()).parse_all().unwrap();

c.bench_function("String copy (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand All @@ -465,10 +413,9 @@ fn number_object_access(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

let mut lexer = Lexer::new(NUMBER_OBJECT_ACCESS);
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(NUMBER_OBJECT_ACCESS.as_bytes())
.parse_all()
.unwrap();

c.bench_function("Number Object Access (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand All @@ -489,10 +436,9 @@ fn boolean_object_access(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

let mut lexer = Lexer::new(BOOLEAN_OBJECT_ACCESS);
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(BOOLEAN_OBJECT_ACCESS.as_bytes())
.parse_all()
.unwrap();

c.bench_function("Boolean Object Access (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand All @@ -513,10 +459,9 @@ fn string_object_access(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

let mut lexer = Lexer::new(STRING_OBJECT_ACCESS);
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(STRING_OBJECT_ACCESS.as_bytes())
.parse_all()
.unwrap();

c.bench_function("String Object Access (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand All @@ -531,10 +476,9 @@ fn arithmetic_operations(c: &mut Criterion) {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

let mut lexer = Lexer::new(ARITHMETIC_OPERATIONS);
lexer.lex().expect("failed to lex");

let nodes = Parser::new(&lexer.tokens).parse_all().unwrap();
let nodes = Parser::new(ARITHMETIC_OPERATIONS.as_bytes())
.parse_all()
.unwrap();

c.bench_function("Arithmetic operations (Execution)", move |b| {
b.iter(|| black_box(&nodes).run(&mut engine).unwrap())
Expand Down
Loading

0 comments on commit fa950d4

Please sign in to comment.