| Index: test/mjsunit/math-ceil-minus-zero.js
|
| diff --git a/test/mjsunit/regress/regress-3976.js b/test/mjsunit/math-ceil-minus-zero.js
|
| similarity index 50%
|
| copy from test/mjsunit/regress/regress-3976.js
|
| copy to test/mjsunit/math-ceil-minus-zero.js
|
| index efa3ac03bc05a5b1018eb1bdd0db761154f2b664..660497c59e51735a853aa80661d993fb788d0e3d 100644
|
| --- a/test/mjsunit/regress/regress-3976.js
|
| +++ b/test/mjsunit/math-ceil-minus-zero.js
|
| @@ -25,56 +25,51 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -// Flags: --max-old-space-size=60 --check-handle-count
|
| +// Flags: --allow-natives-syntax --noalways-opt
|
|
|
| -table = [];
|
| -
|
| -for (var i = 0; i < 32; i++) {
|
| - table[i] = String.fromCharCode(i + 0x410);
|
| +// Test that a -0 result doesn't cause deopt loops
|
| +function noDeoptLoop(x) {
|
| + return Math.ceil(x);
|
| }
|
| -
|
| -
|
| -var random = (function() {
|
| - var seed = 10;
|
| - return function() {
|
| - seed = (seed * 1009) % 8831;
|
| - return seed;
|
| - };
|
| -})();
|
| -
|
| -
|
| -function key(length) {
|
| - var s = "";
|
| - for (var i = 0; i < length; i++) {
|
| - s += table[random() % 32];
|
| - }
|
| - return '"' + s + '"';
|
| +assertEquals(1, noDeoptLoop(0.4));
|
| +assertEquals(1, noDeoptLoop(0.4));
|
| +assertEquals(1, noDeoptLoop(0.4));
|
| +%OptimizeFunctionOnNextCall(noDeoptLoop);
|
| +assertEquals(1, noDeoptLoop(0.4));
|
| +assertEquals(1, noDeoptLoop(0.4));
|
| +assertEquals(-Infinity, 1/noDeoptLoop(-0.0));
|
| +assertEquals(-Infinity, 1/noDeoptLoop(-0.0));
|
| +assertUnoptimized(noDeoptLoop);
|
| +assertEquals(-Infinity, 1/noDeoptLoop(-0.0));
|
| +assertEquals(-1.0, 1/noDeoptLoop(-1.0));
|
| +assertEquals(Infinity, 1/noDeoptLoop(0));
|
| +%OptimizeFunctionOnNextCall(noDeoptLoop);
|
| +assertEquals(-Infinity, 1/noDeoptLoop(-0.0));
|
| +assertEquals(-Infinity, 1/noDeoptLoop(-0.1));
|
| +assertOptimized(noDeoptLoop);
|
| +%ClearFunctionTypeFeedback(noDeoptLoop);
|
| +%DeoptimizeFunction(noDeoptLoop);
|
| +
|
| +// Test that ceil that goes megamorphic is handled correctly.
|
| +function notCeil(x) {
|
| + return -x;
|
| }
|
| -
|
| -
|
| -function value() {
|
| - return '[{' + '"field1" : ' + random() + ', "field2" : ' + random() + '}]';
|
| +function testMega(f, x) {
|
| + return f(x);
|
| }
|
| -
|
| -
|
| -function generate(n) {
|
| - var s = '{';
|
| - for (var i = 0; i < n; i++) {
|
| - if (i > 0) s += ', ';
|
| - s += key(random() % 10 + 7);
|
| - s += ':';
|
| - s += value();
|
| - }
|
| - s += '}';
|
| - return s;
|
| +assertEquals(8, testMega(Math.ceil, 7.4));
|
| +assertEquals(8, testMega(Math.ceil, 7.4));
|
| +assertEquals(8, testMega(Math.ceil, 7.4));
|
| +assertEquals(-7.4, testMega(notCeil, 7.4));
|
| +
|
| +// Make sure that we can learn about ceil specialization from Cranskhaft, which
|
| +// doesn't insert soft deopts for CallICs.
|
| +function crankCeilLearn(x) {
|
| + return Math.ceil(x);
|
| }
|
| -
|
| -
|
| -print("generating");
|
| -
|
| -var str = generate(50000);
|
| -
|
| -print("parsing " + str.length);
|
| -JSON.parse(str);
|
| -
|
| -print("done");
|
| +%OptimizeFunctionOnNextCall(crankCeilLearn);
|
| +assertEquals(12, crankCeilLearn(11.3));
|
| +assertOptimized(crankCeilLearn);
|
| +assertEquals(-Infinity, 1/crankCeilLearn(-0.0));
|
| +assertOptimized(crankCeilLearn);
|
| +assertEquals(-Infinity, 1/crankCeilLearn(-0.75));
|
|
|