47090774a4
Add Int32/Float64 nodes for: * Subtract * Multiply * Divide and additionally Int32 nodes for * BitwiseOr/And/Xor * ShiftLeft/Right/RightLogical The latter ones don't have Float64 equivalents since they're implicitly Int32 operations. In the future we'll add support for Number feedback by adding Float64-to-Int32 conversions and using the Int32 nodes. The divide node does an Int32 division and deopts if there's a remainder to the division -- we may want to make it output a Float64 instead if we think that's more likely in real-world code. There's also no peephole optimisations for constant operations, which would generate much better code, especially for shifts. Bug: v8:7700 Change-Id: Ief1d24b46557cf4d2b7929ed50956df7b0d25992 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3652301 Commit-Queue: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/main@{#80670}
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
// Copyright 2022 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 --maglev --no-stress-opt
|
|
|
|
// Checks Smi shift_right operation and deopt while untagging.
|
|
(function() {
|
|
function shift_right(x, y) {
|
|
return x >> y;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(shift_right);
|
|
assertEquals(2, shift_right(8, 2));
|
|
assertEquals(-2, shift_right(-8, 2));
|
|
assertEquals(-8, shift_right(-8, 0));
|
|
assertEquals(0, shift_right(8, 10));
|
|
assertEquals(4, shift_right(8, 33));
|
|
|
|
%OptimizeMaglevOnNextCall(shift_right);
|
|
assertEquals(2, shift_right(8, 2));
|
|
assertTrue(isMaglevved(shift_right));
|
|
|
|
assertEquals(-2, shift_right(-8, 2));
|
|
assertTrue(isMaglevved(shift_right));
|
|
|
|
assertEquals(-8, shift_right(-8, 0));
|
|
assertTrue(isMaglevved(shift_right));
|
|
|
|
assertEquals(0, shift_right(8, 10));
|
|
assertTrue(isMaglevved(shift_right));
|
|
|
|
// Shifts are mod 32
|
|
assertEquals(4, shift_right(8, 33));
|
|
assertTrue(isMaglevved(shift_right));
|
|
|
|
// // We should deopt here in SmiUntag.
|
|
// assertEquals(0x40000000, shift_right(1, 0x3FFFFFFF));
|
|
// assertFalse(isMaglevved(shift_right));
|
|
})();
|
|
|
|
// // Checks when we deopt due to tagging.
|
|
// (function() {
|
|
// function shift_right(x, y) {
|
|
// return x + y;
|
|
// }
|
|
|
|
// %PrepareFunctionForOptimization(shift_right);
|
|
// assertEquals(3, shift_right(1, 2));
|
|
|
|
// %OptimizeMaglevOnNextCall(shift_right);
|
|
// assertEquals(3, shift_right(1, 2));
|
|
// assertTrue(isMaglevved(shift_right));
|
|
|
|
// // We should deopt here in SmiTag.
|
|
// assertEquals(3.2, shift_right(1.2, 2));
|
|
// assertFalse(isMaglevved(shift_right));
|
|
// })();
|