Index: test/mjsunit/smi-mul.js |
diff --git a/test/mjsunit/regress/regress-2132.js b/test/mjsunit/smi-mul.js |
similarity index 70% |
copy from test/mjsunit/regress/regress-2132.js |
copy to test/mjsunit/smi-mul.js |
index 9eb2dc5b073e6e3c2ce46362903d07d727de3d27..6f23d5e3a0bba23407b9db94539fb8ed7922bc11 100644 |
--- a/test/mjsunit/regress/regress-2132.js |
+++ b/test/mjsunit/smi-mul.js |
@@ -25,24 +25,43 @@ |
// (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: --allow-natives-syntax |
+// Flags: --allow-natives-syntax --noalways-opt |
-function mul(x, y) { |
- return (x * y) | 0; |
+function mul(a, b) { |
+ return a * b; |
} |
-mul(0, 0); |
-mul(0, 0); |
+ |
+mul(-1, 2); |
+mul(-1, 2); |
%OptimizeFunctionOnNextCall(mul); |
-assertEquals(0, mul(0, -1)); |
+assertEquals(-2, mul(-1, 2)); |
assertOptimized(mul); |
-function div(x, y) { |
- return (x / y) | 0; |
+// Deopt on minus zero. |
+assertEquals(-0, mul(-1, 0)); |
+assertUnoptimized(mul); |
+ |
+ |
+function mul2(a, b) { |
+ return a * b; |
} |
-div(4, 2); |
-div(4, 2); |
-%OptimizeFunctionOnNextCall(div); |
-assertEquals(1, div(5, 3)); |
-assertOptimized(div); |
+mul2(-1, 2); |
+mul2(-1, 2); |
+%OptimizeFunctionOnNextCall(mul2); |
+ |
+// 2^30 is a smi boundary on arm and ia32. |
+var two_30 = 1 << 30; |
+// 2^31 is a smi boundary on x64. |
+var two_31 = 2 * two_30; |
+ |
+if (%IsValidSmi(two_31)) { |
+ // Deopt on two_31 on x64. |
+ assertEquals(two_31, mul2(-two_31, -1)); |
+ assertUnoptimized(mul2); |
+} else { |
+ // Deopt on two_30 on ia32. |
+ assertEquals(two_30, mul2(-two_30, -1)); |
+ assertUnoptimized(mul2); |
+} |