diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/ion/ceil.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/jit-test/tests/ion/ceil.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/ceil.js b/js/src/jit-test/tests/ion/ceil.js new file mode 100644 index 0000000000..1f058cf073 --- /dev/null +++ b/js/src/jit-test/tests/ion/ceil.js @@ -0,0 +1,65 @@ +setJitCompilerOption("baseline.warmup.trigger", 10); +setJitCompilerOption("ion.warmup.trigger", 20); + +//var log = print; +var log = function(x){} + +function ceil(x) { + // A nice but not always efficient polyfill. + return -Math.floor(-x); +} + +function doubleCheck(g) { + for (var j = 0; j < 200; j++) { + var i = j; + assertEq(g(i), i); + assertEq(g(i+.5), i+1); + assertEq(g(-i), -i); + assertEq(g(-i-.5), -i); + } +} + +function floatCheck(g, val) { + for (var j = 0; j < 200; j++) { + var i = Math.fround(j); + assertEq(g(i), i); + assertEq(g(i+.5), i+1); + assertEq(g(-i), -i); + assertEq(g(-i-.5), -i); + } +} + +function testBailout(value) { + var dceil = eval('(function(x) { return Math.ceil(x) })'); + log('start double'); + doubleCheck(dceil); + log('bailout'); + // At this point, the compiled code should bailout, if 'value' is in the + // edge case set. + assertEq(dceil(value), ceil(value)); + + var fceil = eval('(function(x) { return Math.ceil(Math.fround(x)) })'); + log('start float'); + floatCheck(fceil, value); + log('bailout'); + assertEq(fceil(Math.fround(value)), ceil(Math.fround(value))); +} + +var INT_MAX = Math.pow(2, 31) - 1; +var INT_MIN = INT_MAX + 1 | 0; +var UINT_MAX = Math.pow(2, 32) - 1; + +// Values in ]-1; -0] +testBailout(-0); +testBailout(-.5); +// Values outside the INT32 range, when represented in either double or +// single precision +testBailout(INT_MAX + .5); +testBailout(INT_MIN - 129); +// (UINT_MAX; +inf] have special behavior on ARM +testBailout(UINT_MAX); +testBailout(UINT_MAX + .5); +testBailout(UINT_MAX + 1); +testBailout(UINT_MAX + 2); +// BatNaN +testBailout(NaN); |