| Index: test/mjsunit/math-round-minus-zero.js
|
| diff --git a/test/mjsunit/regress/regress-3976.js b/test/mjsunit/math-round-minus-zero.js
|
| similarity index 50%
|
| copy from test/mjsunit/regress/regress-3976.js
|
| copy to test/mjsunit/math-round-minus-zero.js
|
| index efa3ac03bc05a5b1018eb1bdd0db761154f2b664..a82d91063c3d2d01d51de6d87df75f3e9835c40b 100644
|
| --- a/test/mjsunit/regress/regress-3976.js
|
| +++ b/test/mjsunit/math-round-minus-zero.js
|
| @@ -25,56 +25,50 @@
|
| // (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.round(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(0, noDeoptLoop(0.4));
|
| +assertEquals(0, noDeoptLoop(0.4));
|
| +assertEquals(0, noDeoptLoop(0.4));
|
| +%OptimizeFunctionOnNextCall(noDeoptLoop);
|
| +assertEquals(0, noDeoptLoop(0.4));
|
| +assertEquals(0, noDeoptLoop(0.4));
|
| +assertEquals(-Infinity, 1/noDeoptLoop(-0.4));
|
| +assertUnoptimized(noDeoptLoop);
|
| +assertEquals(-Infinity, 1/noDeoptLoop(-0.4));
|
| +assertEquals(-Infinity, 1/noDeoptLoop(-0.4));
|
| +assertEquals(-Infinity, 1/noDeoptLoop(-0.4));
|
| +%OptimizeFunctionOnNextCall(noDeoptLoop);
|
| +assertEquals(-Infinity, 1/noDeoptLoop(-0.4));
|
| +assertEquals(-Infinity, 1/noDeoptLoop(-0.4));
|
| +assertOptimized(noDeoptLoop);
|
| +%ClearFunctionTypeFeedback(noDeoptLoop);
|
| +%DeoptimizeFunction(noDeoptLoop);
|
| +
|
| +// Test that round that goes megamorphic is handled correctly.
|
| +function notRound(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(7, testMega(Math.round, 7.4));
|
| +assertEquals(7, testMega(Math.round, 7.4));
|
| +assertEquals(7, testMega(Math.round, 7.4));
|
| +assertEquals(-7.4, testMega(notRound, 7.4));
|
| +
|
| +// Make sure that we can learn about round specialization from Cranskhaft, which
|
| +// doesn't insert soft deopts for CallICs.
|
| +function crankRoundLearn(x) {
|
| + return Math.round(x);
|
| }
|
| -
|
| -
|
| -print("generating");
|
| -
|
| -var str = generate(50000);
|
| -
|
| -print("parsing " + str.length);
|
| -JSON.parse(str);
|
| -
|
| -print("done");
|
| +%OptimizeFunctionOnNextCall(crankRoundLearn);
|
| +assertEquals(12, crankRoundLearn(12.3));
|
| +assertOptimized(crankRoundLearn);
|
| +assertEquals(-Infinity, 1/crankRoundLearn(-0.4));
|
| +assertOptimized(crankRoundLearn);
|
| +assertEquals(-Infinity, 1/crankRoundLearn(-0.4));
|
|
|