Bug 878433 - OdinMonkey: (signed % signed) should be intish, not int (r=bbouvier)
authorLuke Wagner <luke@mozilla.com>
Thu, 20 Jun 2013 20:11:01 -0700
changeset 136021 cbcb8cb1a86859812cd481c7129b5c1bc42724dc
parent 136020 97ff13b79e53ad33741f598fd0ea606a834a0306
child 136022 b5a63a038980b2e330d18f8ca513be866a4d9232
push id29927
push userlwagner@mozilla.com
push dateSat, 22 Jun 2013 01:07:30 +0000
treeherdermozilla-inbound@b5a63a038980 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs878433
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 878433 - OdinMonkey: (signed % signed) should be intish, not int (r=bbouvier)
js/src/ion/AsmJS.cpp
js/src/jit-test/tests/asm.js/testExpressions.js
--- a/js/src/ion/AsmJS.cpp
+++ b/js/src/ion/AsmJS.cpp
@@ -4031,34 +4031,30 @@ CheckDivOrMod(FunctionCompiler &f, Parse
         *def = expr->isKind(PNK_DIV)
                ? f.binary<MDiv>(lhsDef, rhsDef, MIRType_Double)
                : f.binary<MMod>(lhsDef, rhsDef, MIRType_Double);
         *type = Type::Double;
         return true;
     }
 
     if (lhsType.isSigned() && rhsType.isSigned()) {
-        if (expr->isKind(PNK_DIV)) {
+        if (expr->isKind(PNK_DIV))
             *def = f.binary<MDiv>(lhsDef, rhsDef, MIRType_Int32);
-            *type = Type::Intish;
-        } else {
+        else
             *def = f.binary<MMod>(lhsDef, rhsDef, MIRType_Int32);
-            *type = Type::Int;
-        }
+        *type = Type::Intish;
         return true;
     }
 
     if (lhsType.isUnsigned() && rhsType.isUnsigned()) {
-        if (expr->isKind(PNK_DIV)) {
+        if (expr->isKind(PNK_DIV))
             *def = f.binary<MAsmJSUDiv>(lhsDef, rhsDef);
-            *type = Type::Intish;
-        } else {
+        else
             *def = f.binary<MAsmJSUMod>(lhsDef, rhsDef);
-            *type = Type::Int;
-        }
+        *type = Type::Intish;
         return true;
     }
 
     return f.failf(expr, "arguments to / or %% must both be double, signed, or unsigned; "
                    "%s and %s are given", lhsType.toChars(), rhsType.toChars());
 }
 
 static bool
--- a/js/src/jit-test/tests/asm.js/testExpressions.js
+++ b/js/src/jit-test/tests/asm.js/testExpressions.js
@@ -17,16 +17,21 @@ assertAsmTypeFail(USE_ASM + "function f(
 assertAsmTypeFail(USE_ASM + "function f() { var i=0,j=0.0; return (i%j)|0 } return f");
 assertAsmTypeFail(USE_ASM + "function f() { var i=0.0,j=0; return (i%j)|0 } return f");
 assertAsmTypeFail(USE_ASM + "function f() { var i=0.0,j=0; return (i<j)|0 } return f");
 assertAsmTypeFail(USE_ASM + "function f() { var i=0,j=0.0; return (i<j)|0 } return f");
 assertAsmTypeFail(USE_ASM + "function f() { var i=0,j=0; return (i<j)|0 } return f");
 assertAsmTypeFail(USE_ASM + "function f() { var i=0.0; return (-i)|0 } return f");
 assertAsmTypeFail(USE_ASM + "function f() { var i=0,j=0; return (-(i+j))|0 } return f");
 
+assertAsmTypeFail(USE_ASM + "function f() { var i=0,j=0,k=0; k = (i|0)/(k|0) } return f");
+assertAsmTypeFail(USE_ASM + "function f() { var i=0,j=0,k=0; k = (i>>>0)/(k>>>0) } return f");
+assertAsmTypeFail(USE_ASM + "function f() { var i=0,j=0,k=0; k = (i|0)%(k|0) } return f");
+assertAsmTypeFail(USE_ASM + "function f() { var i=0,j=0,k=0; k = (i>>>0)%(k>>>0) } return f");
+
 const UINT32_MAX = Math.pow(2,32)-1;
 const INT32_MIN = -Math.pow(2,31);
 const INT32_MAX = Math.pow(2,31)-1;
 
 var f = asmLink(asmCompile(USE_ASM + "function f(i) { i=i|0; return (i*2)|0 } return f"));
 assertEq(f(0), 0);
 assertEq(f(INT32_MIN), (2*INT32_MIN)|0);
 assertEq(f(INT32_MAX), (2*INT32_MAX)|0);
@@ -157,17 +162,17 @@ assertEq(f(INT32_MAX, INT32_MAX), 1);
 assertEq(f(INT32_MAX, INT32_MIN), 0);
 assertEq(f(UINT32_MAX, INT32_MAX), 2);
 assertEq(f(INT32_MAX, UINT32_MAX), 0);
 assertEq(f(UINT32_MAX, UINT32_MAX), 1);
 assertEq(f(INT32_MIN, INT32_MAX), 1);
 assertEq(f(INT32_MIN, UINT32_MAX), 0);
 assertEq(f(INT32_MIN, INT32_MIN), 1);
 
-var f = asmLink(asmCompile(USE_ASM + "function f(i,j) { i=i|0;j=j|0; var k = 0; k = (i|0)%(j|0); return k|0 } return f"));
+var f = asmLink(asmCompile(USE_ASM + "function f(i,j) { i=i|0;j=j|0; var k = 0; k = (i|0)%(j|0)|0; return k|0 } return f"));
 assertEq(f(4,2), 0);
 assertEq(f(3,2), 1);
 assertEq(f(3,-2), 1);
 assertEq(f(-3,-2), -1);
 assertEq(f(0, -1), 0);
 assertEq(f(0, INT32_MAX), 0);
 assertEq(f(0, INT32_MIN), 0);
 assertEq(f(INT32_MAX, 0), 0);
@@ -176,27 +181,27 @@ assertEq(f(-1, INT32_MAX), -1);
 assertEq(f(-1, INT32_MIN), -1);
 assertEq(f(INT32_MAX, -1), 0);
 assertEq(f(INT32_MIN, -1), 0); // !!
 assertEq(f(INT32_MAX, INT32_MAX), 0);
 assertEq(f(INT32_MAX, INT32_MIN), INT32_MAX);
 assertEq(f(INT32_MIN, INT32_MAX), -1);
 assertEq(f(INT32_MIN, INT32_MIN), 0);
 
-var f = asmLink(asmCompile(USE_ASM + "function f(i,j) { i=i|0;j=j|0; var k = 0; k = (i|0)%4; return k|0 } return f"));
+var f = asmLink(asmCompile(USE_ASM + "function f(i,j) { i=i|0;j=j|0; var k = 0; k = (i|0)%4|0; return k|0 } return f"));
 assertEq(f(0), 0);
 assertEq(f(-1), -1);
 assertEq(f(-3), -3);
 assertEq(f(-4), 0);
 assertEq(f(INT32_MIN), 0);
 assertEq(f(3), 3);
 assertEq(f(4), 0);
 assertEq(f(INT32_MAX), 3);
 
-var f = asmLink(asmCompile(USE_ASM + "function f(i,j) { i=i|0;j=j|0; var k = 0; k = (i>>>0)%(j>>>0); return k|0 } return f"));
+var f = asmLink(asmCompile(USE_ASM + "function f(i,j) { i=i|0;j=j|0; var k = 0; k = (i>>>0)%(j>>>0)|0; return k|0 } return f"));
 assertEq(f(4,2), 0);
 assertEq(f(3,2), 1);
 assertEq(f(3,-2), 3);
 assertEq(f(-3,-2), -3);
 assertEq(f(0, -1), 0);
 assertEq(f(0, INT32_MAX), 0);
 assertEq(f(0, INT32_MIN), 0);
 assertEq(f(0, UINT32_MAX), 0);