aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/test/js-perf-test/Array
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-09-21 09:14:51 +0200
committerMichaël Zasso <targos@protonmail.com>2018-09-22 18:29:25 +0200
commit0e7ddbd3d7e9439c67573b854c49cf82c398ae82 (patch)
tree2afe372acde921cb57ddb3444ff00c5adef8848c /deps/v8/test/js-perf-test/Array
parent13245dc50da4cb7443c39ef6c68d419d5e6336d4 (diff)
downloadandroid-node-v8-0e7ddbd3d7e9439c67573b854c49cf82c398ae82.tar.gz
android-node-v8-0e7ddbd3d7e9439c67573b854c49cf82c398ae82.tar.bz2
android-node-v8-0e7ddbd3d7e9439c67573b854c49cf82c398ae82.zip
deps: update V8 to 7.0.276.20
PR-URL: https://github.com/nodejs/node/pull/22754 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/test/js-perf-test/Array')
-rw-r--r--deps/v8/test/js-perf-test/Array/copy-within.js43
-rw-r--r--deps/v8/test/js-perf-test/Array/every.js10
-rw-r--r--deps/v8/test/js-perf-test/Array/filter.js20
-rw-r--r--deps/v8/test/js-perf-test/Array/find-index.js23
-rw-r--r--deps/v8/test/js-perf-test/Array/find.js14
-rw-r--r--deps/v8/test/js-perf-test/Array/for-each.js26
-rw-r--r--deps/v8/test/js-perf-test/Array/map.js18
-rw-r--r--deps/v8/test/js-perf-test/Array/reduce-right.js22
-rw-r--r--deps/v8/test/js-perf-test/Array/reduce.js13
-rw-r--r--deps/v8/test/js-perf-test/Array/run.js62
-rw-r--r--deps/v8/test/js-perf-test/Array/slice.js7
-rw-r--r--deps/v8/test/js-perf-test/Array/some.js10
12 files changed, 196 insertions, 72 deletions
diff --git a/deps/v8/test/js-perf-test/Array/copy-within.js b/deps/v8/test/js-perf-test/Array/copy-within.js
new file mode 100644
index 0000000000..c3cf33b481
--- /dev/null
+++ b/deps/v8/test/js-perf-test/Array/copy-within.js
@@ -0,0 +1,43 @@
+// Copyright 2018 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+(() => {
+
+const kArraySize = 1000;
+const kQuarterSize = kArraySize / 4;
+
+let array = [];
+
+// Copy a quarter of the elements from the middle to the front.
+function CopyWithin() {
+ return new Function(
+ 'array.copyWithin(0, kQuarterSize * 2, kQuarterSize * 3);');
+}
+
+createSuite('SmiCopyWithin', 1000, CopyWithin, SmiCopyWithinSetup);
+createSuite('StringCopyWithin', 1000, CopyWithin, StringCopyWithinSetup);
+createSuite('SparseSmiCopyWithin', 1000, CopyWithin, SparseSmiCopyWithinSetup);
+createSuite(
+ 'SparseStringCopyWithin', 1000, CopyWithin, SparseStringCopyWithinSetup);
+
+function SmiCopyWithinSetup() {
+ array = [];
+ for (let i = 0; i < kArraySize; ++i) array[i] = i;
+}
+
+function StringCopyWithinSetup() {
+ array = [];
+ for (let i = 0; i < kArraySize; ++i) array[i] = `Item no. ${i}`;
+}
+
+function SparseSmiCopyWithinSetup() {
+ array = [];
+ for (let i = 0; i < kArraySize; i += 10) array[i] = i;
+}
+
+function SparseStringCopyWithinSetup() {
+ array = [];
+ for (let i = 0; i < kArraySize; i += 10) array[i] = `Item no. ${i}`;
+}
+
+})();
diff --git a/deps/v8/test/js-perf-test/Array/every.js b/deps/v8/test/js-perf-test/Array/every.js
index 5a29f44e41..6e9425543a 100644
--- a/deps/v8/test/js-perf-test/Array/every.js
+++ b/deps/v8/test/js-perf-test/Array/every.js
@@ -27,11 +27,11 @@ function OptUnreliableEvery() {
DefineHigherOrderTests([
// name, test function, setup function, user callback
- "DoubleEvery", mc("every"), DoubleSetup, v => v > 0.0,
- "SmiEvery", mc("every"), SmiSetup, v => v != 34343,
- "FastEvery", mc("every"), FastSetup, v => v !== 'hi',
- "OptFastEvery", OptFastEvery, FastSetup, v => true,
- "OptUnreliableEvery", OptUnreliableEvery, FastSetup, v => true
+ ['DoubleEvery', newClosure('every'), DoubleSetup, v => v > 0.0],
+ ['SmiEvery', newClosure('every'), SmiSetup, v => v != 34343],
+ ['FastEvery', newClosure('every'), FastSetup, v => v !== 'hi'],
+ ['OptFastEvery', OptFastEvery, FastSetup, v => true],
+ ['OptUnreliableEvery', OptUnreliableEvery, FastSetup, v => true]
]);
})();
diff --git a/deps/v8/test/js-perf-test/Array/filter.js b/deps/v8/test/js-perf-test/Array/filter.js
index e0d4327dd6..4ceaf5cce2 100644
--- a/deps/v8/test/js-perf-test/Array/filter.js
+++ b/deps/v8/test/js-perf-test/Array/filter.js
@@ -54,13 +54,19 @@ function OptUnreliableFilter() {
DefineHigherOrderTests([
// name, test function, setup function, user callback
- "NaiveFilterReplacement", NaiveFilter, NaiveFilterSetup, v => true,
- "DoubleFilter", mc("filter"), DoubleSetup, v => Math.floor(v) % 2 === 0,
- "SmiFilter", mc("filter"), SmiSetup, v => v % 2 === 0,
- "FastFilter", mc("filter"), FastSetup, (_, i) => i % 2 === 0,
- "GenericFilter", mc("filter", true), ObjectSetup, (_, i) => i % 2 === 0,
- "OptFastFilter", OptFastFilter, FastSetup, undefined,
- "OptUnreliableFilter", OptUnreliableFilter, FastSetup, v => true
+ ['NaiveFilterReplacement', NaiveFilter, NaiveFilterSetup, v => true],
+ [
+ 'DoubleFilter', newClosure('filter'), DoubleSetup,
+ v => Math.floor(v) % 2 === 0
+ ],
+ ['SmiFilter', newClosure('filter'), SmiSetup, v => v % 2 === 0],
+ ['FastFilter', newClosure('filter'), FastSetup, (_, i) => i % 2 === 0],
+ [
+ 'GenericFilter', newClosure('filter', true), ObjectSetup,
+ (_, i) => i % 2 === 0
+ ],
+ ['OptFastFilter', OptFastFilter, FastSetup, undefined],
+ ['OptUnreliableFilter', OptUnreliableFilter, FastSetup, v => true]
]);
})();
diff --git a/deps/v8/test/js-perf-test/Array/find-index.js b/deps/v8/test/js-perf-test/Array/find-index.js
index 716aa710bb..1029b26124 100644
--- a/deps/v8/test/js-perf-test/Array/find-index.js
+++ b/deps/v8/test/js-perf-test/Array/find-index.js
@@ -51,13 +51,22 @@ function NaiveSetup() {
DefineHigherOrderTests([
// name, test function, setup function, user callback
- "NaiveFindIndexReplacement", Naive, NaiveSetup, v => v === max_index,
- "DoubleFindIndex", mc("findIndex"), DoubleSetup, v => v === max_index + 0.5,
- "SmiFindIndex", mc("findIndex"), SmiSetup, v => v === max_index,
- "FastFindIndex", mc("findIndex"), FastSetup, v => v === `value ${max_index}`,
- "GenericFindIndex", mc("findIndex", true), ObjectSetup, v => v === max_index,
- "OptFastFindIndex", OptFast, FastSetup, undefined,
- "OptUnreliableFindIndex", OptUnreliable, FastSetup, v => v === max_index
+ ['NaiveFindIndexReplacement', Naive, NaiveSetup, v => v === max_index],
+ [
+ 'DoubleFindIndex', newClosure('findIndex'), DoubleSetup,
+ v => v === max_index + 0.5
+ ],
+ ['SmiFindIndex', newClosure('findIndex'), SmiSetup, v => v === max_index],
+ [
+ 'FastFindIndex', newClosure('findIndex'), FastSetup,
+ v => v === `value ${max_index}`
+ ],
+ [
+ 'GenericFindIndex', newClosure('findIndex', true), ObjectSetup,
+ v => v === max_index
+ ],
+ ['OptFastFindIndex', OptFast, FastSetup, undefined],
+ ['OptUnreliableFindIndex', OptUnreliable, FastSetup, v => v === max_index]
]);
})();
diff --git a/deps/v8/test/js-perf-test/Array/find.js b/deps/v8/test/js-perf-test/Array/find.js
index 9b9a19f1c4..580d646a30 100644
--- a/deps/v8/test/js-perf-test/Array/find.js
+++ b/deps/v8/test/js-perf-test/Array/find.js
@@ -51,13 +51,13 @@ function NaiveSetup() {
DefineHigherOrderTests([
// name, test function, setup function, user callback
- "NaiveFindReplacement", Naive, NaiveSetup, v => v === max_index,
- "DoubleFind", mc("find"), DoubleSetup, v => v === max_index + 0.5,
- "SmiFind", mc("find"), SmiSetup, v => v === max_index,
- "FastFind", mc("find"), FastSetup, v => v === `value ${max_index}`,
- "GenericFind", mc("find", true), ObjectSetup, v => v === max_index,
- "OptFastFind", OptFast, FastSetup, undefined,
- "OptUnreliableFind", OptUnreliable, FastSetup, v => v === max_index
+ ['NaiveFindReplacement', Naive, NaiveSetup, v => v === max_index],
+ ['DoubleFind', newClosure('find'), DoubleSetup, v => v === max_index + 0.5],
+ ['SmiFind', newClosure('find'), SmiSetup, v => v === max_index],
+ ['FastFind', newClosure('find'), FastSetup, v => v === `value ${max_index}`],
+ ['GenericFind', newClosure('find', true), ObjectSetup, v => v === max_index],
+ ['OptFastFind', OptFast, FastSetup, undefined],
+ ['OptUnreliableFind', OptUnreliable, FastSetup, v => v === max_index]
]);
})();
diff --git a/deps/v8/test/js-perf-test/Array/for-each.js b/deps/v8/test/js-perf-test/Array/for-each.js
index 79d279894b..c87d5406e0 100644
--- a/deps/v8/test/js-perf-test/Array/for-each.js
+++ b/deps/v8/test/js-perf-test/Array/for-each.js
@@ -50,13 +50,25 @@ function OptUnreliable() {
}
DefineHigherOrderTests([
- "NaiveForEachReplacement", Naive, NaiveSetup, v => v === max_index,
- "DoubleForEach", mc("forEach"), DoubleSetup, v => v === max_index + 0.5,
- "SmiForEach", mc("forEach"), SmiSetup, v => v === max_index,
- "FastForEach", mc("forEach"), FastSetup, v => v === `value ${max_index}`,
- "GenericForEach", mc("forEach", true), ObjectSetup, v => v === max_index,
- "OptFastForEach", OptFast, FastSetup, undefined,
- "OptUnreliableForEach", OptUnreliable, FastSetup, v => v === `value ${max_index}`
+ ['NaiveForEachReplacement', Naive, NaiveSetup, v => v === max_index],
+ [
+ 'DoubleForEach', newClosure('forEach'), DoubleSetup,
+ v => v === max_index + 0.5
+ ],
+ ['SmiForEach', newClosure('forEach'), SmiSetup, v => v === max_index],
+ [
+ 'FastForEach', newClosure('forEach'), FastSetup,
+ v => v === `value ${max_index}`
+ ],
+ [
+ 'GenericForEach', newClosure('forEach', true), ObjectSetup,
+ v => v === max_index
+ ],
+ ['OptFastForEach', OptFast, FastSetup, undefined],
+ [
+ 'OptUnreliableForEach', OptUnreliable, FastSetup,
+ v => v === `value ${max_index}`
+ ]
]);
})();
diff --git a/deps/v8/test/js-perf-test/Array/map.js b/deps/v8/test/js-perf-test/Array/map.js
index 9179aa3c88..4b278b8882 100644
--- a/deps/v8/test/js-perf-test/Array/map.js
+++ b/deps/v8/test/js-perf-test/Array/map.js
@@ -49,15 +49,15 @@ function OptUnreliableMap() {
DefineHigherOrderTests([
// name, test function, setup function, user callback
- "NaiveMapReplacement", NaiveMap, NaiveMapSetup, v => v,
- "SmiMap", mc("map"), SmiSetup, v => v,
- "DoubleMap", mc("map"), DoubleSetup, v => v,
- "FastMap", mc("map"), FastSetup, v => v,
- "SmallSmiToDoubleMap", mc("map"), SmiSetup, v => v + 0.5,
- "SmallSmiToFastMap", mc("map"), SmiSetup, v => "hi" + v,
- "GenericMap", mc("map", true), ObjectSetup, v => v,
- "OptFastMap", OptFastMap, FastSetup, undefined,
- "OptUnreliableMap", OptUnreliableMap, FastSetup, v => v
+ ['NaiveMapReplacement', NaiveMap, NaiveMapSetup, v => v],
+ ['SmiMap', newClosure('map'), SmiSetup, v => v],
+ ['DoubleMap', newClosure('map'), DoubleSetup, v => v],
+ ['FastMap', newClosure('map'), FastSetup, v => v],
+ ['SmallSmiToDoubleMap', newClosure('map'), SmiSetup, v => v + 0.5],
+ ['SmallSmiToFastMap', newClosure('map'), SmiSetup, v => 'hi' + v],
+ ['GenericMap', newClosure('map', true), ObjectSetup, v => v],
+ ['OptFastMap', OptFastMap, FastSetup, undefined],
+ ['OptUnreliableMap', OptUnreliableMap, FastSetup, v => v]
]);
})();
diff --git a/deps/v8/test/js-perf-test/Array/reduce-right.js b/deps/v8/test/js-perf-test/Array/reduce-right.js
index ed00f5ac27..c643c2b383 100644
--- a/deps/v8/test/js-perf-test/Array/reduce-right.js
+++ b/deps/v8/test/js-perf-test/Array/reduce-right.js
@@ -27,12 +27,22 @@ function OptUnreliableReduceRight() {
DefineHigherOrderTests([
// name, test function, setup function, user callback
- "DoubleReduceRight", mc("reduceRight"), DoubleSetup, (p, v, i, o) => p + v,
- "SmiReduceRight", mc("reduceRight"), SmiSetup, (p, v, i, a) => p + 1,
- "FastReduceRight", mc("reduceRight"), FastSetup, (p, v, i, a) => p + v,
- "OptFastReduceRight", OptFastReduceRight, FastSetup, undefined,
- "OptUnreliableReduceRight", OptUnreliableReduceRight, FastSetup,
- (p, v, i, a) => p + v
+ [
+ 'DoubleReduceRight', newClosure('reduceRight'), DoubleSetup,
+ (p, v, i, o) => p + v
+ ],
+ [
+ 'SmiReduceRight', newClosure('reduceRight'), SmiSetup, (p, v, i, a) => p + 1
+ ],
+ [
+ 'FastReduceRight', newClosure('reduceRight'), FastSetup,
+ (p, v, i, a) => p + v
+ ],
+ ['OptFastReduceRight', OptFastReduceRight, FastSetup, undefined],
+ [
+ 'OptUnreliableReduceRight', OptUnreliableReduceRight, FastSetup,
+ (p, v, i, a) => p + v
+ ]
]);
})();
diff --git a/deps/v8/test/js-perf-test/Array/reduce.js b/deps/v8/test/js-perf-test/Array/reduce.js
index 02d689f7c4..2b9a28f098 100644
--- a/deps/v8/test/js-perf-test/Array/reduce.js
+++ b/deps/v8/test/js-perf-test/Array/reduce.js
@@ -27,12 +27,13 @@ function OptUnreliableReduce() {
DefineHigherOrderTests([
// name, test function, setup function, user callback
- "DoubleReduce", mc("reduce"), DoubleSetup, (p, v, i, o) => p + v,
- "SmiReduce", mc("reduce"), SmiSetup, (p, v, i, a) => p + 1,
- "FastReduce", mc("reduce"), FastSetup, (p, v, i, a) => p + v,
- "OptFastReduce", OptFastReduce, FastSetup, undefined,
- "OptUnreliableReduce", OptUnreliableReduce, FastSetup,
- (p, v, i, a) => p = v
+ ['DoubleReduce', newClosure('reduce'), DoubleSetup, (p, v, i, o) => p + v],
+ ['SmiReduce', newClosure('reduce'), SmiSetup, (p, v, i, a) => p + 1],
+ ['FastReduce', newClosure('reduce'), FastSetup, (p, v, i, a) => p + v],
+ ['OptFastReduce', OptFastReduce, FastSetup, undefined],
+ [
+ 'OptUnreliableReduce', OptUnreliableReduce, FastSetup, (p, v, i, a) => p = v
+ ]
]);
})();
diff --git a/deps/v8/test/js-perf-test/Array/run.js b/deps/v8/test/js-perf-test/Array/run.js
index 52de9c3809..e8b6ef0024 100644
--- a/deps/v8/test/js-perf-test/Array/run.js
+++ b/deps/v8/test/js-perf-test/Array/run.js
@@ -13,10 +13,10 @@ let result;
const array_size = 100;
const max_index = array_size - 1;
-// mc stands for "Make Closure," it's a handy function to get a fresh
+// newClosure is a handy function to get a fresh
// closure unpolluted by IC feedback for a 2nd-order array builtin
// test.
-function mc(name, generic = false) {
+function newClosure(name, generic = false) {
if (generic) {
return new Function(
`result = Array.prototype.${name}.call(array, func, this_arg);`);
@@ -24,16 +24,55 @@ function mc(name, generic = false) {
return new Function(`result = array.${name}(func, this_arg);`);
}
+function MakeHoley(array) {
+ for (let i =0; i < array.length; i+=2) {
+ delete array[i];
+ }
+ assert(%HasHoleyElements(array));
+}
+
function SmiSetup() {
array = Array.from({ length: array_size }, (_, i) => i);
+ assert(%HasSmiElements(array));
+}
+
+function HoleySmiSetup() {
+ SmiSetup();
+ MakeHoley(array);
+ assert(%HasSmiElements(array));
}
function DoubleSetup() {
array = Array.from({ length: array_size }, (_, i) => i + 0.5);
+ assert(%HasDoubleElements(array));
+}
+
+function HoleyDoubleSetup() {
+ DoubleSetup();
+ MakeHoley(array);
+ assert(%HasDoubleElements(array));
}
function FastSetup() {
array = Array.from({ length: array_size }, (_, i) => `value ${i}`);
+ assert(%HasObjectElements(array));
+}
+
+function HoleyFastSetup() {
+ FastSetup();
+ MakeHoley(array);
+ assert(%HasObjectElements(array));
+}
+
+function DictionarySetup() {
+ array = [];
+ // Add a large index to force dictionary elements.
+ array[2**30] = 10;
+ // Spread out {array_size} elements.
+ for (var i = 0; i < array_size-1; i++) {
+ array[i*101] = i;
+ }
+ assert(%HasDictionaryElements(array));
}
function ObjectSetup() {
@@ -41,15 +80,25 @@ function ObjectSetup() {
for (var i = 0; i < array_size; i++) {
array[i] = i;
}
+ assert(%HasObjectElements(array));
+ assert(%HasHoleyElements(array));
+}
+
+
+const ARRAY_SETUP = {
+ PACKED_SMI: SmiSetup,
+ HOLEY_SMI: HoleySmiSetup,
+ PACKED_DOUBLE: DoubleSetup,
+ HOLEY_DOUBLE: HoleyDoubleSetup,
+ PACKED: FastSetup,
+ HOLEY: HoleyFastSetup,
+ DICTIONARY: DictionarySetup,
}
function DefineHigherOrderTests(tests) {
let i = 0;
while (i < tests.length) {
- const name = tests[i++];
- const testFunc = tests[i++];
- const setupFunc = tests[i++];
- const callback = tests[i++];
+ const [name, testFunc, setupFunc, callback] = tests[i++];
let setupFuncWrapper = () => {
func = callback;
@@ -77,6 +126,7 @@ load('of.js');
load('join.js');
load('to-string.js');
load('slice.js');
+load('copy-within.js');
var success = true;
diff --git a/deps/v8/test/js-perf-test/Array/slice.js b/deps/v8/test/js-perf-test/Array/slice.js
index c9e60930f3..af99c092b1 100644
--- a/deps/v8/test/js-perf-test/Array/slice.js
+++ b/deps/v8/test/js-perf-test/Array/slice.js
@@ -43,13 +43,6 @@
})();
(() => {
-
- function assert(condition, message) {
- if (!condition) {
- throw Error(message);
- }
- }
-
const A = new Array(1000);
for (let i = 0; i < A.length; i++) {
diff --git a/deps/v8/test/js-perf-test/Array/some.js b/deps/v8/test/js-perf-test/Array/some.js
index ea820e9801..d7d5efa908 100644
--- a/deps/v8/test/js-perf-test/Array/some.js
+++ b/deps/v8/test/js-perf-test/Array/some.js
@@ -27,11 +27,11 @@ function OptUnreliableSome() {
DefineHigherOrderTests([
// name, test function, setup function, user callback
- "DoubleSome", mc("some"), DoubleSetup, v => v < 0.0,
- "SmiSome", mc("some"), SmiSetup, v => v === 34343,
- "FastSome", mc("some"), FastSetup, v => v === 'hi',
- "OptFastSome", OptFastSome, FastSetup, undefined,
- "OptUnreliableSome", OptUnreliableSome, FastSetup, v => v === 'hi'
+ ['DoubleSome', newClosure('some'), DoubleSetup, v => v < 0.0],
+ ['SmiSome', newClosure('some'), SmiSetup, v => v === 34343],
+ ['FastSome', newClosure('some'), FastSetup, v => v === 'hi'],
+ ['OptFastSome', OptFastSome, FastSetup, undefined],
+ ['OptUnreliableSome', OptUnreliableSome, FastSetup, v => v === 'hi']
]);
})();