v8/test/mjsunit/compiler/deopt-numberoroddball-binop.js
bmeurer 8a15026270 [turbofan] Properly support Number feedback for binary operators.
Previously Ignition would collect precise Number feedback for binary
operators, but TurboFan would just ignore that and treat it the same as
NumberOrOddball. That however generates a lot of unnecessary code, plus
it defeats redundancy elimination if the same input is also used by
compare operations, which do properly distinguish feedback Number and
NumberOrOddball.

This CL adds the missing bits to connect the existing functionality
properly, i.e. adding the missing BinaryOperationHint and using the
NumberOperationHint::kNumber in the representation selection for tagged
inputs.

R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2923543003
Cr-Commit-Position: refs/heads/master@{#45732}
2017-06-06 14:06:11 +00:00

156 lines
3.1 KiB
JavaScript

// Copyright 2016 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.
// Flags: --allow-natives-syntax --opt
(function() {
function foo(x, y) { return x << y; }
foo(1.1, 0.1);
foo(0.1, 1.1);
foo(true, false);
%OptimizeFunctionOnNextCall(foo);
foo(undefined, 1.1);
assertOptimized(foo);
foo(1.1, undefined);
assertOptimized(foo);
foo(null, 1.1);
assertOptimized(foo);
foo(1.1, null);
assertOptimized(foo);
foo(true, 1.1);
assertOptimized(foo);
foo(1.1, true);
assertOptimized(foo);
foo(false, 1.1);
assertOptimized(foo);
foo(1.1, false);
assertOptimized(foo);
})();
(function() {
function foo(x, y) { return x >> y; }
foo(1.1, 0.1);
foo(0.1, 1.1);
foo(true, false);
%OptimizeFunctionOnNextCall(foo);
foo(undefined, 1.1);
assertOptimized(foo);
foo(1.1, undefined);
assertOptimized(foo);
foo(null, 1.1);
assertOptimized(foo);
foo(1.1, null);
assertOptimized(foo);
foo(true, 1.1);
assertOptimized(foo);
foo(1.1, true);
assertOptimized(foo);
foo(false, 1.1);
assertOptimized(foo);
foo(1.1, false);
assertOptimized(foo);
})();
(function() {
function foo(x, y) { return x >>> y; }
foo(1.1, 0.1);
foo(0.1, 1.1);
foo(true, false);
%OptimizeFunctionOnNextCall(foo);
foo(undefined, 1.1);
assertOptimized(foo);
foo(1.1, undefined);
assertOptimized(foo);
foo(null, 1.1);
assertOptimized(foo);
foo(1.1, null);
assertOptimized(foo);
foo(true, 1.1);
assertOptimized(foo);
foo(1.1, true);
assertOptimized(foo);
foo(false, 1.1);
assertOptimized(foo);
foo(1.1, false);
assertOptimized(foo);
})();
(function() {
function foo(x, y) { return x ^ y; }
foo(1.1, 0.1);
foo(0.1, 1.1);
foo(true, false);
%OptimizeFunctionOnNextCall(foo);
foo(undefined, 1.1);
assertOptimized(foo);
foo(1.1, undefined);
assertOptimized(foo);
foo(null, 1.1);
assertOptimized(foo);
foo(1.1, null);
assertOptimized(foo);
foo(true, 1.1);
assertOptimized(foo);
foo(1.1, true);
assertOptimized(foo);
foo(false, 1.1);
assertOptimized(foo);
foo(1.1, false);
assertOptimized(foo);
})();
(function() {
function foo(x, y) { return x | y; }
foo(1.1, 0.1);
foo(0.1, 1.1);
foo(true, false);
%OptimizeFunctionOnNextCall(foo);
foo(undefined, 1.1);
assertOptimized(foo);
foo(1.1, undefined);
assertOptimized(foo);
foo(null, 1.1);
assertOptimized(foo);
foo(1.1, null);
assertOptimized(foo);
foo(true, 1.1);
assertOptimized(foo);
foo(1.1, true);
assertOptimized(foo);
foo(false, 1.1);
assertOptimized(foo);
foo(1.1, false);
assertOptimized(foo);
})();
(function() {
function foo(x, y) { return x & y; }
foo(1.1, 0.1);
foo(0.1, 1.1);
foo(true, false);
%OptimizeFunctionOnNextCall(foo);
foo(undefined, 1.1);
assertOptimized(foo);
foo(1.1, undefined);
assertOptimized(foo);
foo(null, 1.1);
assertOptimized(foo);
foo(1.1, null);
assertOptimized(foo);
foo(true, 1.1);
assertOptimized(foo);
foo(1.1, true);
assertOptimized(foo);
foo(false, 1.1);
assertOptimized(foo);
foo(1.1, false);
assertOptimized(foo);
})();