7d383be9da
For inputs to truncating binary operations like <<, | or >>>, support all Oddballs not just undefined, true and false. This unifies treatment of these truncations in Crankshaft and TurboFan, and is very easy nowadays, since the memory layout of Oddball and HeapNumber is compatible. R=yangguo@chromium.org BUG=v8:5400 Review-Url: https://codereview.chromium.org/2452193003 Cr-Commit-Position: refs/heads/master@{#40608}
156 lines
3.2 KiB
JavaScript
156 lines
3.2 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
|
|
|
|
(function() {
|
|
function foo(x, y) { return x << y; }
|
|
|
|
foo(1.1, 0.1);
|
|
%BaselineFunctionOnNextCall(foo);
|
|
foo(0.1, 1.1);
|
|
%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);
|
|
%BaselineFunctionOnNextCall(foo);
|
|
foo(0.1, 1.1);
|
|
%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);
|
|
%BaselineFunctionOnNextCall(foo);
|
|
foo(0.1, 1.1);
|
|
%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);
|
|
%BaselineFunctionOnNextCall(foo);
|
|
foo(0.1, 1.1);
|
|
%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);
|
|
%BaselineFunctionOnNextCall(foo);
|
|
foo(0.1, 1.1);
|
|
%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);
|
|
%BaselineFunctionOnNextCall(foo);
|
|
foo(0.1, 1.1);
|
|
%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);
|
|
})();
|