Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

104
deps/v8/test/js-perf-test/Array/at.js vendored Normal file
View File

@ -0,0 +1,104 @@
// Copyright 2022 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 array_at_size = 100;
// SMI array
(() => {
const A = new Array(array_at_size);
for (let i = 0; i < A.length; i++) {
A[i] = i;
}
assert(%HasSmiElements(A), "A should have SMI elements for this test");
// Commonly used to get the last item.
function testArrayAtNeg1() {
return A.at(-1);
}
function testArrayAt0() {
return A.at(0);
}
function testArrayAt20() {
return A.at(20);
}
function testArrayAt80() {
return A.at(80);
}
createSuiteWithWarmup("Array.at(-1)-smi", 1, testArrayAtNeg1);
createSuiteWithWarmup("Array.at(0)-smi", 1, testArrayAt0);
createSuiteWithWarmup("Array.at(20)-smi", 1, testArrayAt20);
createSuiteWithWarmup("Array.at(80)-smi", 1, testArrayAt80);
})();
// Double array
(() => {
const A = new Array(array_at_size);
for (let i = 0; i < A.length; i++) {
A[i] = i + 0.5;
}
assert(%HasDoubleElements(A), "A should have Double elements for this test");
// Commonly used to get the last item.
function testArrayAtNeg1() {
return A.at(-1);
}
function testArrayAt0() {
return A.at(0);
}
function testArrayAt20() {
return A.at(20);
}
function testArrayAt80() {
return A.at(80);
}
createSuiteWithWarmup("Array.at(-1)-double", 1, testArrayAtNeg1);
createSuiteWithWarmup("Array.at(0)-double", 1, testArrayAt0);
createSuiteWithWarmup("Array.at(20)-double", 1, testArrayAt20);
createSuiteWithWarmup("Array.at(80)-double", 1, testArrayAt80);
})();
// Object array
(() => {
const A = new Array(array_at_size);
for (let i = 0; i < A.length; i++) {
A[i] = { ["p" + i] : i};
}
assert(%HasObjectElements(A), "A should have Object elements for this test");
// Commonly used to get the last item.
function testArrayAtNeg1() {
return A.at(-1);
}
function testArrayAt0() {
return A.at(0);
}
function testArrayAt20() {
return A.at(20);
}
function testArrayAt80() {
return A.at(80);
}
createSuiteWithWarmup("Array.at(-1)-object", 1, testArrayAtNeg1);
createSuiteWithWarmup("Array.at(0)-object", 1, testArrayAt0);
createSuiteWithWarmup("Array.at(20)-object", 1, testArrayAt20);
createSuiteWithWarmup("Array.at(80)-object", 1, testArrayAt80);
})();

View File

@ -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}`;
}
})();

View File

@ -0,0 +1,37 @@
// Copyright 2017 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.
(() => {
// Make sure we inline the callback, pick up all possible TurboFan
// optimizations.
function RunOptFastEvery(multiple) {
// Use of variable multiple in the callback function forces
// context creation without escape analysis.
//
// Also, the arrow function requires inlining based on
// SharedFunctionInfo.
result = array.every((v, i, a) => multiple === 3);
}
// Don't optimize because I want to optimize RunOptFastMap with a parameter
// to be used in the callback.
%NeverOptimizeFunction(OptFastEvery);
function OptFastEvery() { RunOptFastEvery(3); }
function side_effect(a) { return a; }
%NeverOptimizeFunction(side_effect);
function OptUnreliableEvery() {
result = array.every(func, side_effect(array));
}
DefineHigherOrderTests([
// name, test function, setup function, user callback
['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]
]);
})();

View File

@ -0,0 +1,72 @@
// Copyright 2017 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.
(() => {
// From the lodash implementation.
function NaiveFilter() {
let index = -1
let resIndex = 0
const length = array == null ? 0 : array.length
const result = []
while (++index < length) {
const value = array[index]
if (func(value, index, array)) {
result[resIndex++] = value
}
}
return result
}
function NaiveFilterSetup() {
// Prime NaiveFilter with polymorphic cases.
array = [1, 2, 3];
NaiveFilter();
NaiveFilter();
array = [3.4]; NaiveFilter();
array = new Array(10); array[0] = 'hello'; NaiveFilter();
SmiSetup();
delete array[1];
}
// Make sure we inline the callback, pick up all possible TurboFan
// optimizations.
function RunOptFastFilter(multiple) {
// Use of variable multiple in the callback function forces
// context creation without escape analysis.
//
// Also, the arrow function requires inlining based on
// SharedFunctionInfo.
result = array.filter((v, i, a) => multiple === 3);
}
// Don't optimize because I want to optimize RunOptFastMap with a parameter
// to be used in the callback.
%NeverOptimizeFunction(OptFastFilter);
function OptFastFilter() { RunOptFastFilter(3); }
function side_effect(a) { return a; }
%NeverOptimizeFunction(side_effect);
function OptUnreliableFilter() {
result = array.filter(func, side_effect(array));
}
DefineHigherOrderTests([
// name, test function, setup function, user callback
['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]
]);
})();

View File

@ -0,0 +1,72 @@
// Copyright 2017 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.
(() => {
// Make sure we inline the callback, pick up all possible TurboFan
// optimizations.
function RunOptFast(value) {
// Use of variable {value} in the callback function forces
// context creation without escape analysis.
//
// Also, the arrow function requires inlining based on
// SharedFunctionInfo.
result = array.findIndex((v, i, a) => v === value);
}
// Don't optimize because I want to optimize RunOptFast with a parameter
// to be used in the callback.
%NeverOptimizeFunction(OptFast);
function OptFast() { RunOptFast(max_index_value); }
function side_effect(a) { return a; }
%NeverOptimizeFunction(side_effect);
function OptUnreliable() {
result = array.findIndex(func, side_effect(array));
}
function Naive() {
let index = -1;
const length = array == null ? 0 : array.length;
for (let index = 0; index < length; index++) {
const value = array[index];
if (func(value, index, array)) {
result = value;
break;
}
}
}
function NaiveSetup() {
// Prime Naive with polymorphic cases.
array = [1, 2, 3];
Naive();
Naive();
array = [3.4]; Naive();
array = new Array(10); array[0] = 'hello'; Naive();
SmiSetup();
delete array[1];
}
DefineHigherOrderTests([
// name, test function, setup function, user callback
['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 === max_index_value
],
[
'GenericFindIndex', newClosure('findIndex', true), ObjectSetup,
v => v === max_index
],
['OptFastFindIndex', OptFast, FastSetup, undefined],
['OptUnreliableFindIndex', OptUnreliable, FastSetup, v => v === max_index]
]);
})();

63
deps/v8/test/js-perf-test/Array/find.js vendored Normal file
View File

@ -0,0 +1,63 @@
// Copyright 2017 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.
(() => {
// Make sure we inline the callback, pick up all possible TurboFan
// optimizations.
function RunOptFast(value) {
// Use of variable {value} in the callback function forces
// context creation without escape analysis.
//
// Also, the arrow function requires inlining based on
// SharedFunctionInfo.
result = array.find((v, i, a) => v === value);
}
// Don't optimize because I want to optimize RunOptFast with a parameter
// to be used in the callback.
%NeverOptimizeFunction(OptFast);
function OptFast() { RunOptFast(max_index_value); }
function side_effect(a) { return a; }
%NeverOptimizeFunction(side_effect);
function OptUnreliable() {
result = array.find(func, side_effect(array));
}
function Naive() {
let index = -1;
const length = array == null ? 0 : array.length;
for (let index = 0; index < length; index++) {
const value = array[index];
if (func(value, index, array)) {
result = value;
break;
}
}
}
function NaiveSetup() {
// Prime Naive with polymorphic cases.
array = [1, 2, 3];
Naive();
Naive();
array = [3.4]; Naive();
array = new Array(10); array[0] = 'hello'; Naive();
SmiSetup();
delete array[1];
}
DefineHigherOrderTests([
// name, test function, setup function, user callback
['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 === max_index_value],
['GenericFind', newClosure('find', true), ObjectSetup, v => v === max_index],
['OptFastFind', OptFast, FastSetup, undefined],
['OptUnreliableFind', OptUnreliable, FastSetup, v => v === max_index]
]);
})();

View File

@ -0,0 +1,74 @@
// 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.
(() => {
function Naive() {
let index = -1;
const length = array == null ? 0 : array.length;
for (let index = 0; index < length; index++) {
const value = array[index];
if (func(value, index, array)) {
result = value;
break;
}
}
}
function NaiveSetup() {
// Prime Naive with polymorphic cases.
array = [1, 2, 3];
Naive();
Naive();
array = [3.4]; Naive();
array = new Array(10); array[0] = 'hello'; Naive();
SmiSetup();
delete array[1];
}
// Make sure we inline the callback, pick up all possible TurboFan
// optimizations.
function RunOptFast(value) {
// Use of variable {value} in the callback function forces
// context creation without escape analysis.
//
// Also, the arrow function requires inlining based on
// SharedFunctionInfo.
result = array.forEach((v, i, a) => v === value);
}
// Don't optimize because I want to optimize RunOptFast with a parameter
// to be used in the callback.
%NeverOptimizeFunction(OptFast);
function OptFast() { RunOptFast(max_index_value); }
function side_effect(a) { return a; }
%NeverOptimizeFunction(side_effect);
function OptUnreliable() {
result = array.forEach(func, side_effect(array));
}
DefineHigherOrderTests([
['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 === max_index_value
],
[
'GenericForEach', newClosure('forEach', true), ObjectSetup,
v => v === max_index
],
['OptFastForEach', OptFast, FastSetup, undefined],
[
'OptUnreliableForEach', OptUnreliable, FastSetup,
v => v === max_index_value
]
]);
})();

225
deps/v8/test/js-perf-test/Array/from.js vendored Normal file
View File

@ -0,0 +1,225 @@
// 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.
(() => {
createSuite('MixedFrom', 1000, MixedFrom, MixedFromSetup);
createSuite(
'MixedCowNoMapFrom', 1000, MixedCowNoMapFrom, MixedCowNoMapFromSetup);
createSuite('MixedNonCowNoMapFrom', 1000, MixedNonCowNoMapFrom,
MixedNonCowNoMapFromSetup);
createSuite('SmiFrom', 1000, SmiFrom, SmiFromSetup);
createSuite('SmallSmiFrom', 1000, SmallSmiFrom, SmallSmiFromSetup);
createSuite('SmiCowNoMapFrom', 1000, SmiCowNoMapFrom, SmiCowNoMapFromSetup);
createSuite(
'SmiNonCowNoMapFrom', 1000, SmiNonCowNoMapFrom, SmiNonCowNoMapFromSetup);
createSuite(
'SmiNoIteratorFrom', 1000, SmiNoIteratorFrom, SmiNoIteratorFromSetup);
createSuite(
'TransplantedFrom', 1000, TransplantedFrom, TransplantedFromSetup);
createSuite('DoubleFrom', 1000, DoubleFrom, DoubleFromSetup);
createSuite('DoubleNoMapFrom', 1000, DoubleNoMapFrom, DoubleNoMapFromSetup);
createSuite('StringFrom', 1000, StringFrom, StringFromSetup);
createSuite(
'StringCowNoMapFrom', 1000, StringCowNoMapFrom, StringCowNoMapFromSetup);
createSuite('StringNonCowNoMapFrom', 1000, StringNonCowNoMapFrom,
StringNonCowNoMapFromSetup);
function ArrayLike() {}
ArrayLike.from = Array.from;
var arg
var result;
var func
// This creates a COW array of smis. COWness does not affect the performance
// of Array.from calls with a callback function.
var smi_array_Cow = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
];
// This creates a non-COW array.
var smi_array = Array.from(smi_array_Cow);
smi_array[0] = 1;
// This creates an array of doubles. There is no COW array for doubles.
var double_array = [
1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, //
11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5,
1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, //
11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5,
1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, //
11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5,
1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, //
11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5,
1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, //
11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5,
];
// This creates a COW array of objects.
var string_array_Cow = [
'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'a', 'b', 'c', 'a', 'b',
'c', 'a', 'b', 'c', 'a', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a',
'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'a', 'b', 'c', 'a', 'b',
'c', 'a', 'b', 'c', 'a', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a',
'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'a', 'b', 'c', 'a', 'b',
'c', 'a', 'b', 'c', 'a', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a',
'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a',
];
// This creates a non-COW array.
var string_array = Array.from(string_array_Cow);
string_array[0] = 'a';
// This creates a COW array of objects.
var mixed_array_Cow = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, //
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, //
1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, //
1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, //
'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a',
'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a',
];
// This creates a non-COW array.
var mixed_array = Array.from(mixed_array_Cow);
mixed_array[0] = 1;
// Although these functions have the same code, they are separated for
// clean IC feedback.
function SmallSmiFrom() {
result = Array.from(arg, func);
}
function SmiCowNoMapFrom() {
result = Array.from(arg);
}
function SmiNonCowNoMapFrom() {
result = Array.from(arg);
}
function SmiFrom() {
result = Array.from(arg, func);
}
function SmiNoIteratorFrom() {
result = Array.from(arg, func);
}
function TransplantedFrom() {
result = ArrayLike.from(arg, func);
}
function DoubleFrom() {
result = Array.from(arg, func);
}
function DoubleNoMapFrom() {
result = Array.from(arg);
}
function StringFrom() {
result = Array.from(arg, func);
}
function StringCowNoMapFrom() {
result = Array.from(arg);
}
function StringNonCowNoMapFrom() {
result = Array.from(arg);
}
function MixedFrom() {
result = Array.from(arg, func);
}
function MixedCowNoMapFrom() {
result = Array.from(arg);
}
function MixedNonCowNoMapFrom() {
result = Array.from(arg);
}
function SmallSmiFromSetup() {
func = (v, i) => v + i;
arg = [1, 2, 3];
}
function SmiCowNoMapFromSetup() {
func = undefined;
arg = smi_array_Cow;
}
function SmiNonCowNoMapFromSetup() {
func = undefined;
arg = smi_array;
}
function SmiFromSetup() {
func = (v, i) => v + i;
arg = smi_array_Cow;
}
function SmiNoIteratorFromSetup() {
func = (v, i) => v + i;
array = smi_array_Cow;
arg = {length: array.length};
Object.assign(arg, array);
}
function TransplantedFromSetup() {
func = (v, i) => v + i;
arg = smi_array_Cow;
}
function DoubleFromSetup() {
func = (v, i) => v + i;
arg = double_array;
}
function DoubleNoMapFromSetup() {
func = undefined;
arg = double_array;
}
function StringFromSetup() {
func = (v, i) => v + i;
arg = string_array_Cow;
}
function StringCowNoMapFromSetup() {
func = undefined;
arg = string_array_Cow;
}
function StringNonCowNoMapFromSetup() {
func = undefined;
arg = string_array;
}
function MixedFromSetup() {
func = (v, i) => v + i;
arg = mixed_array_Cow;
}
function MixedCowNoMapFromSetup() {
func = undefined;
arg = mixed_array_Cow;
}
function MixedNonCowNoMapFromSetup() {
func = undefined;
arg = mixed_array;
}
})();

36
deps/v8/test/js-perf-test/Array/join.js vendored Normal file
View File

@ -0,0 +1,36 @@
// Copyright 2017 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.
(() => {
var array;
var result;
var array_size = 1000;
function make_join() {
return new Function('result = array.join();');
}
createSuite('SmiJoin', 1000, make_join(), SmiJoinSetup);
createSuite('StringJoin', 1000, make_join(), StringJoinSetup);
createSuite('SparseSmiJoin', 1000, make_join(), SparseSmiJoinSetup);
createSuite('SparseStringJoin', 1000, make_join(), SparseStringJoinSetup);
function SmiJoinSetup() {
array = new Array();
for (var i = 0; i < array_size; ++i) array[i] = i;
}
function StringJoinSetup() {
array = new Array();
for (var i = 0; i < array_size; ++i) array[i] = `Item no. ${i}`;
}
function SparseSmiJoinSetup() {
SmiJoinSetup();
array.length = array.length * 2;
}
function SparseStringJoinSetup() {
StringJoinSetup();
array.length = array.length * 2;
}
})();

63
deps/v8/test/js-perf-test/Array/map.js vendored Normal file
View File

@ -0,0 +1,63 @@
// Copyright 2017 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.
(() => {
function NaiveMap() {
let index = -1
const length = array == null ? 0 : array.length
const result = new Array(length)
while (++index < length) {
result[index] = func(array[index], index, array)
}
return result
}
function NaiveMapSetup() {
// Prime NaiveMap with polymorphic cases.
array = [1, 2, 3];
NaiveMap();
NaiveMap();
array = [3.4]; NaiveMap();
array = new Array(10); array[0] = 'hello'; NaiveMap();
SmiSetup();
delete array[1];
}
// Make sure we inline the callback, pick up all possible TurboFan
// optimizations.
function RunOptFastMap(value) {
// Use of variable {value} in the callback function forces
// context creation without escape analysis.
//
// Also, the arrow function requires inlining based on
// SharedFunctionInfo.
result = array.map((v, i, a) => v + value);
}
// Don't optimize because I want to optimize RunOptFastMap with a parameter
// to be used in the callback.
%NeverOptimizeFunction(OptFastMap);
function OptFastMap() { RunOptFastMap(" 3"); }
function side_effect(a) { return a; }
%NeverOptimizeFunction(side_effect);
function OptUnreliableMap() {
result = array.map(func, side_effect(array));
}
DefineHigherOrderTests([
// name, test function, setup function, user callback
['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]
]);
})();

121
deps/v8/test/js-perf-test/Array/of.js vendored Normal file
View File

@ -0,0 +1,121 @@
// 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.
(() => {
createSuite('EmptyArrayOf', 1000, EmptyArrayOf, EmptyArrayOfSetup);
createSuite(
'SmallTransplantedArrayOf', 1000, SmallTransplantedArrayOf,
SmallTransplantedArrayOfSetup);
createSuite('SmallSmiArrayOf', 1000, SmallSmiArrayOf, SmallSmiArrayOfSetup);
createSuite('LargeSmiArrayOf', 1000, LargeSmiArrayOf, LargeSmiArrayOfSetup);
createSuite(
'SmallDoubleArrayOf', 1000, SmallDoubleArrayOf, SmallDoubleArrayOfSetup);
createSuite(
'SmallStringArrayOf', 1000, SmallStringArrayOf, SmallStringArrayOfSetup);
createSuite(
'SmallMixedArrayOf', 1000, SmallMixedArrayOf, SmallMixedArrayOfSetup);
function ArrayLike() {}
ArrayLike.of = Array.of;
var arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10
var arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20
var result;
function EmptyArrayOf() {
result = Array.of();
}
function BaselineArray() {
result = [arg1, arg2, arg3];
}
function SmallSmiArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function LargeSmiArrayOf() {
result = Array.of(
arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20);
}
function SmallTransplantedArrayOf() {
result = ArrayLike.of(arg1, arg2, arg3);
}
function SmallDoubleArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function SmallStringArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function SmallMixedArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function EmptyArrayOfSetup() {}
function BaselineArraySetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
}
function SmallSmiArrayOfSetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
}
function SmallTransplantedArrayOfSetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
}
function SmallDoubleArrayOfSetup() {
arg1 = 1.5;
arg2 = 2.5;
arg3 = 3.5;
}
function SmallStringArrayOfSetup() {
arg1 = 'cat';
arg2 = 'dog';
arg3 = 'giraffe';
}
function SmallMixedArrayOfSetup() {
arg1 = 1;
arg2 = 2.5;
arg3 = 'giraffe';
}
function LargeSmiArrayOfSetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
arg4 = 4;
arg5 = 5;
arg6 = 6;
arg7 = 7;
arg8 = 8;
arg9 = 9;
arg10 = 10;
arg11 = 11;
arg12 = 12;
arg13 = 13;
arg14 = 14;
arg15 = 15;
arg16 = 16;
arg17 = 17;
arg18 = 18;
arg19 = 19;
arg20 = 20;
}
})();

View File

@ -0,0 +1,48 @@
// Copyright 2017 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.
(() => {
// Make sure we inline the callback, pick up all possible TurboFan
// optimizations.
function RunOptFastReduceRight(value) {
// Use of variable {value} in the callback function forces
// context creation without escape analysis.
//
// Also, the arrow function requires inlining based on
// SharedFunctionInfo.
result = array.reduceRight((p, v, i, a) => p + value);
}
// Don't optimize because I want to optimize RunOptFastMap with a parameter
// to be used in the callback.
%NeverOptimizeFunction(OptFastReduceRight);
function OptFastReduceRight() { RunOptFastReduceRight("3"); }
function side_effect(a) { return a; }
%NeverOptimizeFunction(side_effect);
function OptUnreliableReduceRight() {
result = array.reduceRight(func, side_effect(array));
}
DefineHigherOrderTests([
// name, test function, setup function, user callback
[
'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
]
]);
})();

View File

@ -0,0 +1,39 @@
// Copyright 2017 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.
(() => {
// Make sure we inline the callback, pick up all possible TurboFan
// optimizations.
function RunOptFastReduce(value) {
// Use of variable {value} in the callback function forces
// context creation without escape analysis.
//
// Also, the arrow function requires inlining based on
// SharedFunctionInfo.
result = array.reduce((p, v, i, a) => p + value);
}
// Don't optimize because I want to optimize RunOptFastMap with a parameter
// to be used in the callback.
%NeverOptimizeFunction(OptFastReduce);
function OptFastReduce() { RunOptFastReduce("3"); }
function side_effect(a) { return a; }
%NeverOptimizeFunction(side_effect);
function OptUnreliableReduce() {
result = array.reduce(func, side_effect(array));
}
DefineHigherOrderTests([
// name, test function, setup function, user callback
['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
]
]);
})();

165
deps/v8/test/js-perf-test/Array/run.js vendored Normal file
View File

@ -0,0 +1,165 @@
// Copyright 2014 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.
d8.file.execute('../base.js');
let array;
// Initialize func variable to ensure the first test doesn't benefit from
// global object property tracking.
let func = 0;
let this_arg;
let result;
const array_size = 100;
const max_index = array_size - 1;
// Matches what {FastSetup} below produces.
const max_index_value = `value ${max_index}`;
// newClosure is a handy function to get a fresh
// closure unpolluted by IC feedback for a 2nd-order array builtin
// test.
function newClosure(name, generic = false) {
if (generic) {
return new Function(
`result = Array.prototype.${name}.call(array, func, this_arg);`);
}
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 = [];
for (let i = 0; i < array_size; i++) array.push(i);
// TODO(v8:10105): May still create holey arrays (allocation sites?).
// assert(%HasFastPackedElements(array));
assert(%HasSmiElements(array));
}
function HoleySmiSetup() {
array = [];
for (let i = 0; i < array_size; i++) array.push(i);
MakeHoley(array);
assert(%HasSmiElements(array));
}
function DoubleSetup() {
array = [];
for (let i = 0; i < array_size; i++) array.push(i + 0.5);
// TODO(v8:10105): May still create holey arrays (allocation sites?).
// assert(%HasFastPackedElements(array));
assert(%HasDoubleElements(array));
}
function HoleyDoubleSetup() {
array = [];
for (let i = 0; i < array_size; i++) array.push(i + 0.5);
MakeHoley(array);
assert(%HasDoubleElements(array));
}
function FastSetup() {
array = [];
for (let i = 0; i < array_size; i++) array.push(`value ${i}`);
// TODO(v8:10105): May still create holey arrays (allocation sites?).
// assert(%HasFastPackedElements(array));
assert(%HasObjectElements(array));
}
function HoleyFastSetup() {
array = [];
for (let i = 0; i < array_size; i++) array.push(`value ${i}`);
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() {
array = { length: array_size };
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, testFunc, setupFunc, callback] = tests[i++];
let setupFuncWrapper = () => {
func = callback;
this_arg = undefined;
setupFunc();
};
createSuite(name, 1000, testFunc, setupFuncWrapper);
}
}
// Higher-order Array builtins.
d8.file.execute('filter.js');
d8.file.execute('map.js');
d8.file.execute('every.js');
d8.file.execute('some.js');
d8.file.execute('for-each.js');
d8.file.execute('reduce.js');
d8.file.execute('reduce-right.js');
d8.file.execute('find.js');
d8.file.execute('find-index.js');
// Other Array builtins.
d8.file.execute('from.js');
d8.file.execute('of.js');
d8.file.execute('join.js');
d8.file.execute('to-string.js');
d8.file.execute('slice.js');
d8.file.execute('copy-within.js');
d8.file.execute('at.js');
var success = true;
function PrintResult(name, result) {
print(name + '-Array(Score): ' + result);
}
function PrintStep(name) {}
function PrintError(name, error) {
PrintResult(name, error);
success = false;
}
BenchmarkSuite.config.doWarmup = undefined;
BenchmarkSuite.config.doDeterministic = undefined;
BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
NotifyError: PrintError,
NotifyStep: PrintStep });

211
deps/v8/test/js-perf-test/Array/slice.js vendored Normal file
View File

@ -0,0 +1,211 @@
// 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 A = new Array(kArraySize);
for (let i = 0; i < A.length; i++) {
A[i] = i;
}
assert(%HasSmiElements(A), "A should have SMI elements for this test");
// Commonly used to copy.
function testArraySlice0() {
return A.slice(0);
}
function testArraySlice500() {
return A.slice(500);
}
function testArraySlice500_999() {
return A.slice(500, 999);
}
function testArraySliceN500() {
return A.slice(-500);
}
function testArraySlice200_700() {
return A.slice(200, 700);
}
function testArraySlice200_N300() {
return A.slice(200, -300);
}
function testArraySlice4_1() {
return A.slice(200, -300);
}
createSuiteWithWarmup("Array.slice(0)", 1, testArraySlice0);
createSuiteWithWarmup("Array.slice(500)", 1, testArraySlice500);
createSuiteWithWarmup("Array.slice(500,999)", 1, testArraySlice500_999);
createSuiteWithWarmup("Array.slice(-500)", 1, testArraySliceN500);
createSuiteWithWarmup("Array.slice(200,700)", 1, testArraySlice200_700);
createSuiteWithWarmup("Array.slice(200,-300)", 1, testArraySlice200_N300);
createSuiteWithWarmup("Array.slice(4,1)", 1, testArraySlice4_1);
})();
(() => {
const A = new Array(kArraySize);
for (let i = 0; i < A.length; i++) {
A[i] = i;
}
A[100000] = 255;
assert(%HasDictionaryElements(A), "A should be in dictionary mode for this test");
function testArraySlice0() {
return A.slice(0);
}
function testArraySlice500_999() {
return A.slice(500, 999);
}
function testArraySlice200_700() {
return A.slice(200, 700);
}
function testArraySlice200_N300() {
return A.slice(200, -300);
}
function testArraySlice4_1() {
return A.slice(200, -300);
}
createSuiteWithWarmup("Array.slice(0)-dict", 1, testArraySlice0);
createSuiteWithWarmup("Array.slice(500,999)-dict", 1, testArraySlice500_999);
createSuiteWithWarmup("Array.slice(200,700)-dict", 1, testArraySlice200_700);
createSuiteWithWarmup("Array.slice(200,-300)-dict", 1, testArraySlice200_N300);
createSuiteWithWarmup("Array.slice(4,1)-dict", 1, testArraySlice4_1);
})();
(() => {
const A = new Array(kArraySize);
for (let i = 0; i < A.length; i++) {
A[i] = i + 0.5;
}
assert(%HasDoubleElements(A), "A should have double elements for this test");
function testArraySlice0() {
return A.slice(0);
}
function testArraySlice500_999() {
return A.slice(500, 999);
}
function testArraySlice200_700() {
return A.slice(200, 700);
}
function testArraySlice200_N300() {
return A.slice(200, -300);
}
function testArraySlice4_1() {
return A.slice(200, -300);
}
createSuiteWithWarmup("Array.slice(0)-double", 1, testArraySlice0);
createSuiteWithWarmup("Array.slice(500,999)-double", 1, testArraySlice500_999);
createSuiteWithWarmup("Array.slice(200,700)-double", 1, testArraySlice200_700);
createSuiteWithWarmup("Array.slice(200,-300)-double", 1, testArraySlice200_N300);
createSuiteWithWarmup("Array.slice(4,1)-double", 1, testArraySlice4_1);
})();
(() => {
const A = new Array(kArraySize);
for (let i = 0; i < A.length; i++) {
A[i] = new Object();
}
assert(%HasObjectElements(A), "A should have object elements for this test");
function testArraySlice0() {
return A.slice(0);
}
function testArraySlice500_999() {
return A.slice(500, 999);
}
function testArraySlice200_700() {
return A.slice(200, 700);
}
function testArraySlice200_N300() {
return A.slice(200, -300);
}
function testArraySlice4_1() {
return A.slice(200, -300);
}
createSuiteWithWarmup("Array.slice(0)-object", 1, testArraySlice0);
createSuiteWithWarmup("Array.slice(500,999)-object", 1, testArraySlice500_999);
createSuiteWithWarmup("Array.slice(200,700)-object", 1, testArraySlice200_700);
createSuiteWithWarmup("Array.slice(200,-300)-object", 1, testArraySlice200_N300);
createSuiteWithWarmup("Array.slice(4,1)-object", 1, testArraySlice4_1);
})();
(() => {
const A = new Array(kArraySize);
for (let i = 0; i < A.length; i++) {
A[i] = i;
}
assert(%HasSmiElements(A), "A should have SMI elements for this test");
let arguments_array;
function sloppy_aliased(a) {
arguments_array = arguments;
}
sloppy_aliased.apply(null, A);
assert(%HasSloppyArgumentsElements(arguments_array),
"arguments_array should have sloppy arguments elements for this test");
function testArraySlice0() {
return Array.prototype.slice.call(arguments_array, 0);
}
function testArraySlice500_999() {
return Array.prototype.slice.call(arguments_array, 500, 999);
}
function testArraySlice200_700() {
return Array.prototype.slice.call(arguments_array, 200, 700);
}
function testArraySlice200_N300() {
return Array.prototype.slice.call(arguments_array, 200, -300);
}
function testArraySlice4_1() {
return Array.prototype.slice.call(arguments_array, 200, -300);
}
createSuiteWithWarmup("Array.slice(0)-sloppy-args", 1, testArraySlice0);
createSuiteWithWarmup("Array.slice(500,999)-sloppy-args", 1, testArraySlice500_999);
createSuiteWithWarmup("Array.slice(200,700)-sloppy-args", 1, testArraySlice200_700);
createSuiteWithWarmup("Array.slice(200,-300)-sloppy-args", 1, testArraySlice200_N300);
createSuiteWithWarmup("Array.slice(4,1)-sloppy-args", 1, testArraySlice4_1);
})();

37
deps/v8/test/js-perf-test/Array/some.js vendored Normal file
View File

@ -0,0 +1,37 @@
// Copyright 2017 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.
(() => {
// Make sure we inline the callback, pick up all possible TurboFan
// optimizations.
function RunOptFastSome(multiple) {
// Use of variable multiple in the callback function forces
// context creation without escape analysis.
//
// Also, the arrow function requires inlining based on
// SharedFunctionInfo.
result = array.some((v, i, a) => multiple !== 3);
}
// Don't optimize because I want to optimize RunOptFastMap with a parameter
// to be used in the callback.
%NeverOptimizeFunction(OptFastSome);
function OptFastSome() { RunOptFastSome(3); }
function side_effect(a) { return a; }
%NeverOptimizeFunction(side_effect);
function OptUnreliableSome() {
result = array.some(func, side_effect(array));
}
DefineHigherOrderTests([
// name, test function, setup function, user callback
['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']
]);
})();

View File

@ -0,0 +1,40 @@
// Copyright 2017 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.
(() => {
function make_tostring() {
return new Function("result = array.toString();");
}
createSuite('SmiToString', 1000, make_tostring(), SmiToStringSetup);
createSuite('StringToString', 1000, make_tostring(), StringToStringSetup);
createSuite('SparseSmiToString', 1000, make_tostring(), SparseSmiToStringSetup);
createSuite(
'SparseStringToString', 1000, make_tostring(), SparseStringToStringSetup);
var array;
var result;
var array_size = 1000;
function SmiToStringSetup() {
array = new Array();
for (var i = 0; i < array_size; ++i) array[i] = i;
}
function StringToStringSetup() {
array = new Array();
for (var i = 0; i < array_size; ++i) array[i] = `Item no. ${i}`;
}
function SparseSmiToStringSetup() {
SmiToStringSetup();
array.length = array.length * 2;
}
function SparseStringToStringSetup() {
StringToStringSetup();
array.length = array.length * 2;
}
})();