diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-03-07 08:54:53 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-03-07 16:48:52 +0100 |
commit | 88786fecff336342a56e6f2e7ff3b286be716e47 (patch) | |
tree | 92e6ba5b8ac8dae1a058988d20c9d27bfa654390 /deps/v8/test/js-perf-test/Array/map.js | |
parent | 4e86f9b5ab83cbabf43839385bf383e6a7ef7d19 (diff) | |
download | node-new-88786fecff336342a56e6f2e7ff3b286be716e47.tar.gz |
deps: update V8 to 6.5.254.31
PR-URL: https://github.com/nodejs/node/pull/18453
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yang Guo <yangguo@chromium.org>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'deps/v8/test/js-perf-test/Array/map.js')
-rw-r--r-- | deps/v8/test/js-perf-test/Array/map.js | 128 |
1 files changed, 35 insertions, 93 deletions
diff --git a/deps/v8/test/js-perf-test/Array/map.js b/deps/v8/test/js-perf-test/Array/map.js index f4ab95b065..9179aa3c88 100644 --- a/deps/v8/test/js-perf-test/Array/map.js +++ b/deps/v8/test/js-perf-test/Array/map.js @@ -1,58 +1,7 @@ // 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 benchy(name, test, testSetup) { - new BenchmarkSuite(name, [1000], - [ - new Benchmark(name, false, false, 0, test, testSetup, ()=>{}) - ]); -} - -benchy('NaiveMapReplacement', NaiveMap, NaiveMapSetup); -benchy('DoubleMap', DoubleMap, DoubleMapSetup); -benchy('SmallSmiToDoubleMap', SmiMap, SmiToDoubleMapSetup); -benchy('SmallSmiToFastMap', SmiMap, SmiToFastMapSetup); -benchy('SmiMap', SmiMap, SmiMapSetup); -benchy('FastMap', FastMap, FastMapSetup); -benchy('GenericMap', GenericMap, ObjectMapSetup); -benchy('OptFastMap', OptFastMap, FastMapSetup); - -var array; -// Initialize func variable to ensure the first test doesn't benefit from -// global object property tracking. -var func = 0; -var this_arg; -var result; -var array_size = 100; - -// Although these functions have the same code, they are separated for -// clean IC feedback. -function DoubleMap() { - result = array.map(func, this_arg); -} -function SmiMap() { - result = array.map(func, this_arg); -} -function FastMap() { - result = array.map(func, this_arg); -} - -// Make sure we inline the callback, pick up all possible TurboFan -// optimizations. -function RunOptFastMap(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.map((v, i, a) => v + ' ' + multiple); -} - -// 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 NaiveMap() { let index = -1 @@ -65,57 +14,50 @@ function NaiveMap() { return result } - -function GenericMap() { - result = Array.prototype.map.call(array, func, this_arg); -} - function NaiveMapSetup() { // Prime NaiveMap with polymorphic cases. array = [1, 2, 3]; - func = (v, i, a) => v; NaiveMap(); NaiveMap(); array = [3.4]; NaiveMap(); array = new Array(10); array[0] = 'hello'; NaiveMap(); - SmiMapSetup(); + SmiSetup(); delete array[1]; } -function SmiMapSetup() { - array = new Array(); - for (var i = 0; i < array_size; i++) array[i] = i; - func = (value, index, object) => { return value; }; -} - -function SmiToDoubleMapSetup() { - array = new Array(); - for (var i = 0; i < 1; i++) array[i] = i; - func = (value, index, object) => { return value + 0.5; }; -} - -function SmiToFastMapSetup() { - array = new Array(); - for (var i = 0; i < 1; i++) array[i] = i; - func = (value, index, object) => { return "hi" + value; }; -} - -function DoubleMapSetup() { - array = new Array(); - for (var i = 0; i < array_size; i++) array[i] = (i + 0.5); - func = (value, index, object) => { return value; }; +// Make sure we inline the callback, pick up all possible TurboFan +// optimizations. +function RunOptFastMap(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.map((v, i, a) => v + ' ' + multiple); } -function FastMapSetup() { - array = new Array(); - for (var i = 0; i < array_size; i++) array[i] = 'value ' + i; - func = (value, index, object) => { return 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 ObjectMapSetup() { - array = { length: array_size }; - for (var i = 0; i < array_size; i++) { - array[i] = i; - } - func = (value, index, object) => { return value; }; -} +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", 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 +]); + +})(); |