2016-11-04 15:08:00 +00:00
|
|
|
// 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.
|
|
|
|
|
2017-07-13 11:22:37 +00:00
|
|
|
// Flags: --allow-natives-syntax
|
2016-11-04 15:08:00 +00:00
|
|
|
|
|
|
|
var zero = 0;
|
|
|
|
|
2016-11-10 14:27:23 +00:00
|
|
|
(function ConstantFoldZeroDivZero() {
|
|
|
|
function f() {
|
|
|
|
return 0 / zero;
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(f);
|
2016-11-10 14:27:23 +00:00
|
|
|
assertTrue(isNaN(f()));
|
|
|
|
assertTrue(isNaN(f()));
|
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
assertTrue(isNaN(f()));
|
|
|
|
})();
|
2016-11-04 15:08:00 +00:00
|
|
|
|
2016-11-10 14:27:23 +00:00
|
|
|
(function ConstantFoldMinusZeroDivZero() {
|
|
|
|
function f() {
|
|
|
|
return -0 / zero;
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(f);
|
2016-11-10 14:27:23 +00:00
|
|
|
assertTrue(isNaN(f()));
|
|
|
|
assertTrue(isNaN(f()));
|
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
assertTrue(isNaN(f()));
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function ConstantFoldNaNDivZero() {
|
|
|
|
function f() {
|
|
|
|
return NaN / 0;
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(f);
|
2016-11-10 14:27:23 +00:00
|
|
|
assertTrue(isNaN(f()));
|
|
|
|
assertTrue(isNaN(f()));
|
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
assertTrue(isNaN(f()));
|
|
|
|
})();
|