v8/test/unittests/compiler
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
..
arm [arm][arm64] Implement {kSpeculationFence} operator. 2018-01-29 13:43:53 +00:00
arm64 [arm][arm64] Implement {kSpeculationFence} operator. 2018-01-29 13:43:53 +00:00
ia32 [turbofan] Remove unused instruction continuation handling for stack checks. 2018-01-29 09:07:07 +00:00
mips [MIPS] Add Sreten Kovacevic as owner of MIPS files 2018-02-09 15:35:49 +00:00
mips64 [MIPS] Add Sreten Kovacevic as owner of MIPS files 2018-02-09 15:35:49 +00:00
ppc PPC/s390: [iwyu] Remove illegal inline include from "macro-assembler.h" 2017-09-14 12:23:51 +00:00
regalloc Revert "[compiler] Temporarily turn some DCHECKs into CHECKs." 2018-04-19 08:00:27 +00:00
s390 PPC/s390: [iwyu] Remove illegal inline include from "macro-assembler.h" 2017-09-14 12:23:51 +00:00
x64 [turbofan] Remove unused instruction continuation handling for stack checks. 2018-01-29 09:07:07 +00:00
branch-elimination-unittest.cc Revert "[TurboFan] Diagnostic code to track down bug in representation selection" 2017-11-14 09:26:51 +00:00
bytecode-analysis-unittest.cc [turbofan] Fix accumulator liveness on suspends 2018-03-22 13:46:04 +00:00
checkpoint-elimination-unittest.cc [turbofan] Rename {CheckPoint} to {Checkpoint} everywhere. 2016-06-01 09:07:19 +00:00
code-assembler-unittest.cc Replace array index masking with the poisoning approach. 2018-04-30 13:22:44 +00:00
code-assembler-unittest.h [csa] Add constant folding more universally to CodeAssembler operators 2017-09-12 10:03:10 +00:00
common-operator-reducer-unittest.cc [turbofan] Eliminate switch operations with constant input. 2018-02-01 13:23:52 +00:00
common-operator-unittest.cc Reland "[turbofan] Preserve order of compares in switches" 2018-03-02 12:03:42 +00:00
compiler-test-utils.h [turbofan] Drop V8_TURBOFAN_BACKEND and V8_TURBOFAN_TARGET defines. 2015-08-10 07:17:34 +00:00
constant-folding-reducer-unittest.cc [turbofan] Optimize array destructuring 2018-05-08 06:21:37 +00:00
control-equivalence-unittest.cc This CL enables precise source positions for all V8 compilers. It merges compiler::SourcePosition and internal::SourcePosition to a single class used throughout the codebase. The new internal::SourcePosition instances store an id identifying an inlined function in addition to a script offset. 2016-11-14 17:22:32 +00:00
control-flow-optimizer-unittest.cc Reland "[turbofan] Preserve order of compares in switches" 2018-03-02 12:03:42 +00:00
dead-code-elimination-unittest.cc Reland^6 "[turbofan] eagerly prune None types and deadness from the graph" 2017-11-16 20:01:22 +00:00
diamond-unittest.cc [cleanup] [compiler] Fix (D)CHECK macros 2017-09-25 10:21:34 +00:00
effect-control-linearizer-unittest.cc [compiler] Introduce a new node for array index masking. 2017-12-20 12:30:26 +00:00
graph-reducer-unittest.cc [jumbo] add unittests jumbo support 2017-09-28 22:19:40 +00:00
graph-reducer-unittest.h [turbofan] Add AdvancedReducer::ReplaceWithValue() method and convert JSInlining to an AdvancedReducer. 2015-05-12 12:41:36 +00:00
graph-trimmer-unittest.cc [turbofan] Proper dead code elimination as regular reducer. 2015-06-19 12:07:26 +00:00
graph-unittest.cc [turbofan] Stop mis-using Type* to represent integers. 2018-04-28 06:38:46 +00:00
graph-unittest.h [turbofan] Stop mis-using Type* to represent integers. 2018-04-28 06:38:46 +00:00
instruction-selector-unittest.cc Replace array index masking with the poisoning approach. 2018-04-30 13:22:44 +00:00
instruction-selector-unittest.h [turbofan] Remove ToFloat64AsInt and make ToFloat64 return a Double 2017-07-14 15:01:02 +00:00
instruction-sequence-unittest.cc Replace CHECK(false) by UNREACHABLE() 2017-12-19 18:58:07 +00:00
instruction-sequence-unittest.h MIPS: Reland of Fix bad RegisterConfiguration usage in InstructionSequence unit tests 2016-12-23 10:51:08 +00:00
instruction-unittest.cc [jumbo] add unittests jumbo support 2017-09-28 22:19:40 +00:00
int64-lowering-unittest.cc [wasm] Make wasm::ValueType independent of the MachineRepresentation 2018-05-07 11:54:56 +00:00
js-call-reducer-unittest.cc [turbofan] Move Number.parseInt to JSCallReducer 2018-04-26 07:06:24 +00:00
js-create-lowering-unittest.cc Remove the catch variable name from the extension field of catch contexts 2018-05-04 10:12:08 +00:00
js-intrinsic-lowering-unittest.cc [TurboFan] Broken effect chain in IsInstanceType reduction 2017-10-18 13:50:41 +00:00
js-operator-unittest.cc [TurboFan] Model TypeOf as a simplified operator 2017-10-16 19:15:00 +00:00
js-typed-lowering-unittest.cc [turbofan] Stop mis-using Type* to represent integers. 2018-04-28 06:38:46 +00:00
linkage-tail-call-unittest.cc Reland "[arm64] Preparation for padding of arguments" 2017-12-20 13:50:36 +00:00
live-range-builder.h [turbofan] Make MachineType a pair of enums. 2015-12-10 09:03:53 +00:00
load-elimination-unittest.cc [turbofan] Fix introduction of contradicting {TypeGuard}. 2017-08-08 11:54:51 +00:00
loop-peeling-unittest.cc [turbofan] maintain source positions in loop peeling and polymorphic inlining 2017-12-13 09:51:46 +00:00
machine-operator-reducer-unittest.cc [ubsan] Fix many static_cast<int32_t> with undefined behavior 2018-04-17 02:02:18 +00:00
machine-operator-unittest.cc [cleanup] Remove more OpParameter 2018-03-21 17:02:39 +00:00
node-cache-unittest.cc [jumbo] add unittests jumbo support 2017-09-28 22:19:40 +00:00
node-matchers-unittest.cc [turbofan] Relax limitation for using BaseWithIndexAndDisplacement for load/stores 2017-02-24 06:38:14 +00:00
node-properties-unittest.cc [jumbo] add unittests jumbo support 2017-09-28 22:19:40 +00:00
node-test-utils.cc Replace array index masking with the poisoning approach. 2018-04-30 13:22:44 +00:00
node-test-utils.h [turbofan] Move Number.parseInt to JSCallReducer 2018-04-26 07:06:24 +00:00
node-unittest.cc [jumbo] fix another set of unittest compilation errors 2017-10-19 09:15:44 +00:00
opcodes-unittest.cc [unittests] Reduce compilation overhead of opcodes-unittest.cc. 2016-09-13 05:16:18 +00:00
persistent-unittest.cc [turbofan] PersistentMap: Allow hash values larger than 32bit and some cleanup 2018-01-18 13:58:15 +00:00
schedule-unittest.cc [jumbo] fix android/windows kDummyOperator collision 2017-10-20 12:43:57 +00:00
scheduler-rpo-unittest.cc Replace SmartPointer<T> with unique_ptr<T> 2016-07-25 11:14:34 +00:00
scheduler-unittest.cc This CL enables precise source positions for all V8 compilers. It merges compiler::SourcePosition and internal::SourcePosition to a single class used throughout the codebase. The new internal::SourcePosition instances store an id identifying an inlined function in addition to a script offset. 2016-11-14 17:22:32 +00:00
simplified-lowering-unittest.cc Replace array index masking with the poisoning approach. 2018-04-30 13:22:44 +00:00
simplified-operator-reducer-unittest.cc [turbofan] Add feedback to CheckSmi 2017-12-18 15:52:38 +00:00
simplified-operator-unittest.cc [jumbo] fix another set of unittest compilation errors 2017-10-19 09:15:44 +00:00
state-values-utils-unittest.cc Enable clang's -Wunreachable-code warning. 2017-12-04 13:09:25 +00:00
typed-optimization-unittest.cc [turbofan] Optimize array destructuring 2018-05-08 06:21:37 +00:00
typer-unittest.cc [turbofan] Remove the hacky Type::operator-> overload 2018-04-30 09:39:12 +00:00
value-numbering-reducer-unittest.cc [jumbo] fix another set of unittest compilation errors 2017-10-19 09:15:44 +00:00
zone-stats-unittest.cc Named all zones in the project 2016-10-17 12:12:42 +00:00