Skip to content

Commit

Permalink
benchmark: avoid TurboFan deopt in arrays bench
Browse files Browse the repository at this point in the history
Something unidentified at the moment is causing the arrays benchmarks to
deopt when run with the TurboFan compiler. Refactor the test to use an
inner function that can be correctly optimized by TurboFan and
Crankshaft.

PR-URL: #11894
Ref: #11851 (comment)
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
targos authored and jasnell committed Apr 4, 2017
1 parent e9f2ec4 commit eefdf45
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion benchmark/arrays/var-int.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ function main(conf) {
bench.start();
var arr = new clazz(n * 1e6);
for (var i = 0; i < 10; ++i) {
run();
}
bench.end(n);

function run() {
for (var j = 0, k = arr.length; j < k; ++j) {
arr[j] = (j ^ k) & 127;
}
}
bench.end(n);
}
6 changes: 5 additions & 1 deletion benchmark/arrays/zero-float.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ function main(conf) {
bench.start();
var arr = new clazz(n * 1e6);
for (var i = 0; i < 10; ++i) {
run();
}
bench.end(n);

function run() {
for (var j = 0, k = arr.length; j < k; ++j) {
arr[j] = 0.0;
}
}
bench.end(n);
}
6 changes: 5 additions & 1 deletion benchmark/arrays/zero-int.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ function main(conf) {
bench.start();
var arr = new clazz(n * 1e6);
for (var i = 0; i < 10; ++i) {
run();
}
bench.end(n);

function run() {
for (var j = 0, k = arr.length; j < k; ++j) {
arr[j] = 0;
}
}
bench.end(n);
}

0 comments on commit eefdf45

Please sign in to comment.