v8/test/mjsunit/maglev/add-smi.js
Victor Gomes 3eeea13cf7 [maglev] Addition Smi nodes
If we have a smi operation in the feedback vector, we emit SmiTag
Int32AddWithOverflow and SmiUntag nodes, instead of a generic
operation binary node.


Change-Id: Idb9ce2b60289fbe492bf269793660b32de23e2b3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3560641
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79775}
2022-04-05 12:34:42 +00:00

42 lines
1015 B
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 add operation and deopt while untagging.
(function() {
function add(x, y) {
return x + y;
}
%PrepareFunctionForOptimization(add);
assertEquals(3, add(1, 2));
%OptimizeMaglevOnNextCall(add);
assertEquals(3, add(1, 2));
assertTrue(isMaglevved(add));
// We should deopt here in SmiUntag.
assertEquals(0x40000000, add(1, 0x3FFFFFFF));
assertFalse(isMaglevved(add));
})();
// Checks when we deopt due to tagging.
(function() {
function add(x, y) {
return x + y;
}
%PrepareFunctionForOptimization(add);
assertEquals(3, add(1, 2));
%OptimizeMaglevOnNextCall(add);
assertEquals(3, add(1, 2));
assertTrue(isMaglevved(add));
// We should deopt here in SmiTag.
assertEquals(3.2, add(1.2, 2));
assertFalse(isMaglevved(add));
})();