6904a8120b
.. mostly mentions in mjsunit `Flags:` lines and in comments. Bug: v8:10386 Change-Id: If79dfdc448d0a3f19883ef1f816e77e750cb4061 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3865964 Commit-Queue: Jakob Linke <jgruber@chromium.org> Reviewed-by: Michael Achenbach <machenbach@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/main@{#82852}
89 lines
2.0 KiB
JavaScript
89 lines
2.0 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
|
|
|
|
(function() {
|
|
function add(x, y) {
|
|
return x + y;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(add);
|
|
assertEquals(4.2, add(2.1, 2.1));
|
|
|
|
%OptimizeMaglevOnNextCall(add);
|
|
assertEquals(4.2, add(2.1, 2.1));
|
|
assertTrue(isMaglevved(add));
|
|
|
|
// We don't deopt if we use smis.
|
|
assertEquals(42, add(22, 20));
|
|
assertTrue(isMaglevved(add));
|
|
|
|
// We deopt if not a number.
|
|
assertEquals("42", add("4", "2"));
|
|
assertFalse(isMaglevved(add));
|
|
})();
|
|
|
|
// Deopt in the second Float64Unbox when the first argument is a Smi.
|
|
(function() {
|
|
function add(x, y) {
|
|
return x + y;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(add);
|
|
assertEquals(4.2, add(2.1, 2.1));
|
|
|
|
%OptimizeMaglevOnNextCall(add);
|
|
assertEquals(4.2, add(2.1, 2.1));
|
|
assertTrue(isMaglevved(add));
|
|
|
|
// We deopt if not a number.
|
|
assertEquals("42", add(4, "2"));
|
|
assertFalse(isMaglevved(add));
|
|
})();
|
|
|
|
// Deopt in the second Float64Unbox when the first argument is a double.
|
|
(function() {
|
|
function add(x, y) {
|
|
return x + y;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(add);
|
|
assertEquals(4.2, add(2.1, 2.1));
|
|
|
|
%OptimizeMaglevOnNextCall(add);
|
|
assertEquals(4.2, add(2.1, 2.1));
|
|
assertTrue(isMaglevved(add));
|
|
|
|
// We deopt if not a number.
|
|
assertEquals("4.2!", add(4.2, "!"));
|
|
assertFalse(isMaglevved(add));
|
|
})();
|
|
|
|
// Emit FloatAdd through SmiAdd bytecode.
|
|
(function() {
|
|
function inc(x) {
|
|
return x + 1
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(inc);
|
|
assertEquals(4.2, inc(3.2));
|
|
|
|
%OptimizeMaglevOnNextCall(inc);
|
|
assertEquals(4.2, inc(3.2));
|
|
})();
|
|
|
|
// Force the input of FloatAdd to be int32.
|
|
(function() {
|
|
function add(x, y, z) {
|
|
return (x + y) + z;
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(add);
|
|
assertEquals(4.2, add(1, 3, 0.2));
|
|
|
|
%OptimizeMaglevOnNextCall(add);
|
|
assertEquals(4.2, add(1, 3, 0.2));
|
|
})();
|