OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 testFloor(0, 0); | 86 testFloor(0, 0); |
87 testFloor(0, zero()); | 87 testFloor(0, zero()); |
88 testFloor(-0, -0); | 88 testFloor(-0, -0); |
89 testFloor(Infinity, Infinity); | 89 testFloor(Infinity, Infinity); |
90 testFloor(-Infinity, -Infinity); | 90 testFloor(-Infinity, -Infinity); |
91 testFloor(NaN, NaN); | 91 testFloor(NaN, NaN); |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 // Test in a loop to cover the custom IC and GC-related issues. | 95 // Test in a loop to cover the custom IC and GC-related issues. |
96 for (var i = 0; i < 100; i++) { | 96 for (var i = 0; i < 10; i++) { |
97 test(); | 97 test(); |
| 98 new Array(i * 10000); |
98 } | 99 } |
99 | 100 |
100 | |
101 // Regression test for a bug where a negative zero coming from Math.floor | 101 // Regression test for a bug where a negative zero coming from Math.floor |
102 // was not properly handled by other operations. | 102 // was not properly handled by other operations. |
103 function floorsum(i, n) { | 103 function floorsum(i, n) { |
104 var ret = Math.floor(n); | 104 var ret = Math.floor(n); |
105 while (--i > 0) { | 105 while (--i > 0) { |
106 ret += Math.floor(n); | 106 ret += Math.floor(n); |
107 } | 107 } |
108 return ret; | 108 return ret; |
109 } | 109 } |
110 assertEquals(-0, floorsum(1, -0)); | 110 assertEquals(-0, floorsum(1, -0)); |
111 %OptimizeFunctionOnNextCall(floorsum); | 111 %OptimizeFunctionOnNextCall(floorsum); |
112 // The optimized function will deopt. Run it with enough iterations to try | 112 // The optimized function will deopt. Run it with enough iterations to try |
113 // to optimize via OSR (triggering the bug). | 113 // to optimize via OSR (triggering the bug). |
114 assertEquals(-0, floorsum(100000, -0)); | 114 assertEquals(-0, floorsum(100000, -0)); |
OLD | NEW |