Commit 9f9f36f8 authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[call reducer] inline Array.prototype.indexOf/includes in js-call-reducer.

- inline Array.prototype.indexOf in js-call-reducer
- inline Array.prototype.includes in js-call-reducer

Bug: v8:12390
Change-Id: Idb5669da3019f0f56af0084fccd1d616d4c5098e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3473994Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79461}
parent 8a0d1b6f
This diff is collapsed.
// 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.
(() => {
function make_includes() {
return new Function('result = array.includes(target)');
}
createSuite('SmiIncludes', 1000, make_includes(), SmiIncludesSetup);
createSuite('SparseSmiIncludes', 1000, make_includes(), SparseSmiIncludesSetup);
createSuite('DoubleIncludes', 1000, make_includes(), SmiIncludesSetup);
createSuite('SparseDoubleIncludes', 1000, make_includes(), SparseSmiIncludesSetup);
createSuite('ObjectIncludes', 1000, make_includes(), SmiIncludesSetup);
createSuite('SparseObjectIncludes', 1000, make_includes(), SparseSmiIncludesSetup);
createSuite('StringIncludes', 1000, make_includes(), StringIncludesSetup);
createSuite('SparseStringIncludes', 1000, make_includes(), SparseStringIncludesSetup);
function SmiIncludesSetup() {
array = new Array();
for (let i = 0; i < array_size; ++i) array[i] = i;
target = array[array_size-1];
}
function SparseSmiIncludesSetup() {
SmiIncludesSetup();
array.length = array.length * 2;
target = array[array_size-1];
}
function StringIncludesSetup() {
array = new Array();
for (let i = 0; i < array_size; ++i) array[i] = `Item no. ${i}`;
target = array[array_size-1];
}
function SparseStringIncludesSetup() {
StringIncludesSetup();
array.length = array.length * 2;
target = array[array_size-1];
}
function DoubleIncludesSetup() {
array = new Array();
for (let i = 0; i < array_size; ++i) array[i] = i;
target = array[array_size-1];
}
function SparseDoubleIncludesSetup() {
DoubleIncludesSetup();
array.length = array.length * 2;
target = array[array_size-1];
}
function ObjectIncludesSetup() {
array = new Array();
for (let i = 0; i < array_size; ++i) array[i] = {i};
target = array[array_size-1];
}
function SparseObjectIncludesSetup() {
ObjectIncludesSetup();
array.length = array.length * 2;
target = array[array_size-1];
}
})();
// 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.
(() => {
function make_indexOf() {
return new Function('result = array.indexOf(target)');
}
createSuite('SmiIndexOf', 1000, make_indexOf(), SmiIndexOfSetup);
createSuite('SparseSmiIndexOf', 1000, make_indexOf(), SparseSmiIndexOfSetup);
createSuite('DoubleIndexOf', 1000, make_indexOf(), SmiIndexOfSetup);
createSuite('SparseDoubleIndexOf', 1000, make_indexOf(), SparseSmiIndexOfSetup);
createSuite('ObjectIndexOf', 1000, make_indexOf(), SmiIndexOfSetup);
createSuite('SparseObjectIndexOf', 1000, make_indexOf(), SparseSmiIndexOfSetup);
createSuite('StringIndexOf', 1000, make_indexOf(), StringIndexOfSetup);
createSuite('SparseStringIndexOf', 1000, make_indexOf(), SparseStringIndexOfSetup);
function SmiIndexOfSetup() {
array = new Array();
for (let i = 0; i < array_size; ++i) array[i] = i;
target = array[array_size-1];
}
function SparseSmiIndexOfSetup() {
SmiIndexOfSetup();
array.length = array.length * 2;
target = array[array_size-1];
}
function StringIndexOfSetup() {
array = new Array();
for (let i = 0; i < array_size; ++i) array[i] = `Item no. ${i}`;
target = array[array_size-1];
}
function SparseStringIndexOfSetup() {
StringIndexOfSetup();
array.length = array.length * 2;
target = array[array_size-1];
}
function DoubleIndexOfSetup() {
array = new Array();
for (let i = 0; i < array_size; ++i) array[i] = i;
target = array[array_size-1];
}
function SparseDoubleIndexOfSetup() {
DoubleIndexOfSetup();
array.length = array.length * 2;
target = array[array_size-1];
}
function ObjectIndexOfSetup() {
array = new Array();
for (let i = 0; i < array_size; ++i) array[i] = {i};
target = array[array_size-1];
}
function SparseObjectIndexOfSetup() {
ObjectIndexOfSetup();
array.length = array.length * 2;
target = array[array_size-1];
}
})();
......@@ -10,6 +10,7 @@ let array;
let func = 0;
let this_arg;
let result;
let target;
const array_size = 100;
const max_index = array_size - 1;
// Matches what {FastSetup} below produces.
......@@ -141,6 +142,8 @@ 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('index-of.js')
d8.file.execute('includes.js')
var success = true;
......
......@@ -60,7 +60,8 @@
"resources": [
"filter.js", "map.js", "every.js", "join.js", "some.js", "reduce.js",
"reduce-right.js", "to-string.js", "find.js", "find-index.js",
"from.js", "of.js", "for-each.js", "slice.js", "copy-within.js"
"from.js", "of.js", "for-each.js", "slice.js", "copy-within.js",
"index-of.js", "includes.js"
],
"flags": [
"--allow-natives-syntax"
......@@ -181,7 +182,23 @@
{"name": "SmiCopyWithin"},
{"name": "StringCopyWithin"},
{"name": "SparseSmiCopyWithin"},
{"name": "SparseStringCopyWithin"}
{"name": "SparseStringCopyWithin"},
{"name": "SmiIndexOf"},
{"name": "SparseSmiIndexOf"},
{"name": "DoubleIndexOf"},
{"name": "SparseDoubleIndexOf"},
{"name": "ObjectIndexOf"},
{"name": "SparseObjectIndexOf"},
{"name": "StringIndexOf"},
{"name": "SparseStringIncludes"},
{"name": "SmiIncludes"},
{"name": "SparseSmiIncludes"},
{"name": "DoubleIncludes"},
{"name": "SparseDoubleIncludes"},
{"name": "ObjectIncludes"},
{"name": "SparseObjectIncludes"},
{"name": "StringIncludes"},
{"name": "SparseStringIncludes"}
]
}
]
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment