| 1 |
setJitCompilerOption("baseline.warmup.trigger", 10); |
| 2 |
setJitCompilerOption("ion.warmup.trigger", 20); |
| 3 |
|
| 4 |
function myFloor(x) { |
| 5 |
if(x >= 0) |
| 6 |
return x - Math.abs(x % 1); |
| 7 |
else |
| 8 |
return x - Math.abs(1 + (x % 1)); |
| 9 |
} |
| 10 |
|
| 11 |
function floorRangeTest(x) { |
| 12 |
if(10 < x) { |
| 13 |
if(x < 100) { |
| 14 |
assertEq(Math.floor(x), myFloor(x)); |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
if(-100 < x) { |
| 19 |
if(x < -10) { |
| 20 |
assertEq(Math.floor(x), myFloor(x)); |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
if (-(4294967296 - 1) < x) { |
| 25 |
if(x < 10) { |
| 26 |
assertEq(Math.floor(x), myFloor(x)); |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
if (-10 < x) { |
| 31 |
if(x < 4294967296) { |
| 32 |
assertEq(Math.floor(x), myFloor(x)); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
if (-2147483648 < x) { |
| 37 |
if(x < 10) { |
| 38 |
assertEq(Math.floor(x), myFloor(x)); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
if ((-2147483648 -1) < x) { |
| 43 |
if(x < 10) { |
| 44 |
assertEq(Math.floor(x), myFloor(x)); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
if (10 < x) { |
| 49 |
if(x < 2147483648) { |
| 50 |
assertEq(Math.floor(x), myFloor(x)); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
if (10 < x) { |
| 55 |
if(x < 2147483649) { |
| 56 |
assertEq(Math.floor(x), myFloor(x)); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
if (Math.pow(2,31) < x) { |
| 61 |
if(x < Math.pow(2,33)) { |
| 62 |
assertEq(Math.floor(x), myFloor(x)); |
| 63 |
} |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
var a = [Math.pow(2,31), Math.pow(2,33), -4294967296.4, 214748364.2, -50.4, 50.4]; |
| 68 |
|
| 69 |
for(var i = 0; i < 10; i++) { |
| 70 |
for (var j = 0; j < a.length; j++) { |
| 71 |
floorRangeTest(a[j]); |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
for (var j = 0; j < 30; j++) { |
| 76 |
(function() { |
| 77 |
Math.floor(1.5); |
| 78 |
})() |
| 79 |
} |
| 80 |
|
| 81 |
for (var j = 0; j < 30; j++) { |
| 82 |
(function() { |
| 83 |
Math.floor(-1.5); |
| 84 |
})() |
| 85 |
} |
| 86 |
|
| 87 |
for (var j = 0; j < 30; j++) { |
| 88 |
(function() { |
| 89 |
Math.floor(-127.5); |
| 90 |
})() |
| 91 |
} |