v8/test
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
..
benchmarks Reland "[build] Remove legacy isolate configurations" 2018-03-28 12:36:55 +00:00
cctest [tracing] Custom tag for the traceEvents array 2018-05-07 16:54:59 +00:00
common [wasm] Make wasm::ValueType independent of the MachineRepresentation 2018-05-07 11:54:56 +00:00
debugger Convert all CRLF to LF 2018-05-07 18:55:09 +00:00
fuzzer [wasm] Make wasm::ValueType independent of the MachineRepresentation 2018-05-07 11:54:56 +00:00
inspector [inspector] do not resume on agent disable if there is other agents 2018-05-03 06:23:12 +00:00
intl Fix the fast path for locale canonicalization 2018-04-26 18:10:04 +00:00
js-perf-test Gracefully fail BigInt TypedArray.p.sort benchmarks. 2018-04-19 12:21:10 +00:00
memory [snapshot] Track deserialization time in Memory benchmark 2018-05-02 13:34:47 +00:00
message Convert all CRLF to LF 2018-05-07 18:55:09 +00:00
mjsunit [proxies] Add missing stack overflow check. 2018-05-07 18:50:09 +00:00
mkgrokdump [builtins] Re-enable embedded builtins 2018-04-17 08:27:48 +00:00
mozilla [test] Skip flaky test 2018-04-06 15:19:34 +00:00
preparser Reland "[build] Remove legacy isolate configurations" 2018-03-28 12:36:55 +00:00
test262 [ES6] Ship array.prototype.values 2018-05-07 15:49:58 +00:00
unittests [turbofan] Optimize array destructuring 2018-05-08 06:21:37 +00:00
wasm-spec-tests [wasm] Update spec tests 2018-04-25 12:02:21 +00:00
webkit [builtins] Properly reject immediately throwing thenables. 2018-04-24 07:55:00 +00:00
BUILD.gn Reland "[build] Remove legacy isolate configurations" 2018-03-28 12:36:55 +00:00