| Index: test/mjsunit/unary-minus-deopt.js
|
| diff --git a/test/mjsunit/omit-constant-mapcheck.js b/test/mjsunit/unary-minus-deopt.js
|
| similarity index 67%
|
| copy from test/mjsunit/omit-constant-mapcheck.js
|
| copy to test/mjsunit/unary-minus-deopt.js
|
| index ae6308f215e40ae22b9e9328c5f4e4ec3d0f3843..367ef75c8363af02b9446e4860022d12b8039e54 100644
|
| --- a/test/mjsunit/omit-constant-mapcheck.js
|
| +++ b/test/mjsunit/unary-minus-deopt.js
|
| @@ -27,44 +27,29 @@
|
|
|
| // Flags: --allow-natives-syntax
|
|
|
| -var g1 = { a:1 }
|
| -
|
| -function load() {
|
| - return g1.a;
|
| -}
|
| -
|
| -assertEquals(1, load());
|
| -assertEquals(1, load());
|
| -%OptimizeFunctionOnNextCall(load);
|
| -assertEquals(1, load());
|
| -delete g1.a;
|
| -assertEquals(undefined, load());
|
| -
|
| -var g2 = { a:2 }
|
| -
|
| -function load2() {
|
| - return g2.a;
|
| -}
|
| -
|
| -assertEquals(2, load2());
|
| -assertEquals(2, load2());
|
| -%OptimizeFunctionOnNextCall(load2);
|
| -assertEquals(2, load2());
|
| -g2.b = 10;
|
| -g2.a = 5;
|
| -assertEquals(5, load2());
|
| -
|
| -var g3 = { a:2, b:9, c:1 }
|
| -
|
| -function store(v) {
|
| - g3.a = v;
|
| - return g3.a;
|
| +// This is a boiled-down example happening in the Epic Citadel demo:
|
| +// After deopting, the multiplication for unary minus stayed in Smi
|
| +// mode instead of going to double mode, leading to deopt loops.
|
| +
|
| +function unaryMinusTest(x) {
|
| + var g = (1 << x) | 0;
|
| + // Optimized code will contain a LMulI with -1 as right operand.
|
| + return (g & -g) - 1 | 0;
|
| }
|
|
|
| -assertEquals(5, store(5));
|
| -assertEquals(8, store(8));
|
| -%OptimizeFunctionOnNextCall(store);
|
| -assertEquals(10, store(10));
|
| -delete g3.c;
|
| -store(7);
|
| -assertEquals({a:7, b:9}, g3);
|
| +unaryMinusTest(3);
|
| +unaryMinusTest(3);
|
| +%OptimizeFunctionOnNextCall(unaryMinusTest);
|
| +unaryMinusTest(3);
|
| +assertOptimized(unaryMinusTest);
|
| +
|
| +// Deopt on kMinInt
|
| +unaryMinusTest(31);
|
| +// The following is normally true, but not with --stress-opt. :-/
|
| +// assertUnoptimized(unaryMinusTest);
|
| +
|
| +// We should have learned something from the deopt.
|
| +unaryMinusTest(31);
|
| +%OptimizeFunctionOnNextCall(unaryMinusTest);
|
| +unaryMinusTest(31);
|
| +assertOptimized(unaryMinusTest);
|
|
|