v8/test/unittests
Jaroslav Sevcik 3fe7d698b8 [turbofan] Optimize array destructuring
This CL introduces type narrowing and constant folding reducers
to constant fold code that comes out of inlined destructuring
of arrays. In particular, array iterator introduces code that
contains a phi of a temporary array that blocks escape analysis.
The phi comes from conditional that can be evaluated statically
(i.e., constant folded), so with better constant folding we
allow escape analysis to get rid of the temporary array.

On a quick micro-benchmark below, we see more than 6x improvement.
This is close to the hand-optimized version - if we replace
body of f with 'return b + a', we get 220ms (versus 218ms with
destructuring).

function f(a, b) {
  [b, a] = [a, b];
  return a + b;
}

function sum(count) {
  let s = 0;
  for (let i = 0; i < count; i++) {
    s += f(1, 2);
  }
  return s;
}

// Warm up
sum(1e5); sum(1e5);
console.time("destructure array");
sum(1e8);
console.timeEnd("destructure array");

console.timeEnd: destructure array, 213.526000

console.timeEnd: destructure array, 1503.537000

Bug: v8:7728
Change-Id: Ib7aec1d5897989e6adb1af1eddd516d8b3866db5
Reviewed-on: https://chromium-review.googlesource.com/1047672
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53048}
2018-05-08 06:21:37 +00:00
..
api [V8 Platform] Make CallOnWorkerThread use std::unique_ptr 2018-03-26 17:43:22 +00:00
asmjs Normalize casing of hexadecimal digits 2017-12-02 01:24:40 +00:00
base Fix ThreadTicks.ThreadNow test on windows 2018-03-06 17:02:48 +00:00
compiler [turbofan] Optimize array destructuring 2018-05-08 06:21:37 +00:00
compiler-dispatcher [V8 Platform] Better WorkerThreads APIs. 2018-04-30 19:05:40 +00:00
heap [ubsan] Change Address typedef to uintptr_t 2018-04-14 01:25:28 +00:00
interpreter Remove the catch variable name from the extension field of catch contexts 2018-05-04 10:12:08 +00:00
libplatform [V8 Platform] Better WorkerThreads APIs. 2018-04-30 19:05:40 +00:00
parser Normalize casing of hexadecimal digits 2017-12-02 01:24:40 +00:00
wasm [wasm] Make wasm::ValueType independent of the MachineRepresentation 2018-05-07 11:54:56 +00:00
zone [data structures] Fix ZoneChunkList some more. 2018-02-23 14:20:07 +00:00
allocation-unittest.cc [heap] Add a read-only permission 2018-04-17 08:26:43 +00:00
bigint-unittest.cc Reland: [cleanup] Refactor the Factory 2018-04-09 19:52:22 +00:00
BUILD.gn [turbofan] Optimize array destructuring 2018-05-08 06:21:37 +00:00
cancelable-tasks-unittest.cc Make CancelableTask ids unique 2017-08-02 16:10:42 +00:00
char-predicates-unittest.cc Use ICU for ID_START, ID_CONTINUE and WhiteSpace check 2017-06-14 20:32:49 +00:00
code-stub-assembler-unittest.cc Replace array index masking with the poisoning approach. 2018-04-30 13:22:44 +00:00
code-stub-assembler-unittest.h [csa] Add constant folding more universally to CodeAssembler operators 2017-09-12 10:03:10 +00:00
counters-unittest.cc [test] Allow two timing output to be the same 2018-02-12 16:37:46 +00:00
DEPS
detachable-vector-unittest.cc [cleanup] Replace List with std::vector in api. 2017-09-28 09:32:18 +00:00
eh-frame-iterator-unittest.cc Normalize casing of hexadecimal digits 2017-12-02 01:24:40 +00:00
eh-frame-writer-unittest.cc Normalize casing of hexadecimal digits 2017-12-02 01:24:40 +00:00
locked-queue-unittest.cc Add lock-based unbounded queue 2015-11-18 10:54:13 +00:00
object-unittest.cc [runtime] Do not refer directly to the closure stored in the context 2018-04-25 17:24:02 +00:00
register-configuration-unittest.cc [Turbofan] Add concept of FP register aliasing on ARM 32. 2016-10-26 16:04:33 +00:00
run-all-unittests.cc [cleanup] use unique_ptr for the DefaultPlatform 2017-11-14 09:57:18 +00:00
source-position-table-unittest.cc Decouple SourcePositionTableBuilder from Zone 2017-11-21 12:56:13 +00:00
strings-storage-unittest.cc [tests] Add unit tests for StringsStorage and document the API. 2018-05-07 14:02:48 +00:00
test-helpers.cc [objects] Merge SFI outer_scope_info and feedback_metadata 2018-04-06 15:06:04 +00:00
test-helpers.h [unittests] Add TestWithIsolate::RunJS helper method 2017-11-13 14:27:51 +00:00
test-utils.cc Reland "[bigint] Add BigInt64Array, BigUint64Array" 2018-02-19 10:23:18 +00:00
test-utils.h [RCS] Add explicit tests for function callbacks 2017-11-14 09:48:08 +00:00
testcfg.py [test] Remove dead code from suites and tests 2018-02-01 14:12:49 +00:00
unicode-unittest.cc Consolidate UTF-8 Vector<char> to uc16 decoding into Iterator 2018-02-20 20:04:41 +00:00
unittests.status [test] Skip death-tests for mac64 asan 2018-03-19 14:13:59 +00:00
utils-unittest.cc Reland "MIPS[64] Implementation of MSA instructions on builtin simulator" 2017-11-28 13:43:23 +00:00
value-serializer-unittest.cc Ensure ArrayBuffers are not neutered twice 2018-03-12 22:55:59 +00:00