Bug 864600 - OdinMonkey: change doublish to double in overload set of ~~ and - (r=sstangl)
authorLuke Wagner <luke@mozilla.com>
Mon, 29 Apr 2013 16:42:53 -0700
changeset 141622 66964658a09767946931b40cccfc30a28c6916e9
parent 141612 dffb1419bb198be2ac10d056a1bce42f9ec0dd9e
child 141623 42bcb974cfdd0ec7bee8d7a9839908e165f0ffff
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl
bugs864600
milestone23.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 864600 - OdinMonkey: change doublish to double in overload set of ~~ and - (r=sstangl)
js/src/ion/AsmJS.cpp
js/src/jit-test/tests/asm.js/testExpressions.js
js/src/jit-test/tests/asm.js/testHeapAccess.js
--- a/js/src/ion/AsmJS.cpp
+++ b/js/src/ion/AsmJS.cpp
@@ -3509,24 +3509,24 @@ CheckCoerceToInt(FunctionCompiler &f, Pa
     JS_ASSERT(expr->isKind(PNK_BITNOT));
     ParseNode *operand = UnaryKid(expr);
 
     MDefinition *operandDef;
     Type operandType;
     if (!CheckExpr(f, operand, Use::ToInt32, &operandDef, &operandType))
         return false;
 
-    if (operandType.isDoublish()) {
+    if (operandType.isDouble()) {
         *def = f.unary<MTruncateToInt32>(operandDef);
         *type = Type::Signed;
         return true;
     }
 
     if (!operandType.isIntish())
-        return f.fail("Operand to ~ must be intish or doublish", operand);
+        return f.fail("Operand to ~ must be intish or double", operand);
 
     *def = operandDef;
     *type = Type::Signed;
     return true;
 }
 
 static bool
 CheckBitNot(FunctionCompiler &f, ParseNode *neg, MDefinition **def, Type *type)
@@ -3703,29 +3703,24 @@ CheckAddOrSub(FunctionCompiler &f, Parse
                : f.binary<MSub>(lhsDef, rhsDef, MIRType_Int32);
         if (use.which() == Use::AddOrSub)
             *type = Type::Int;
         else
             *type = Type::Intish;
         return true;
     }
 
-    if (expr->isKind(PNK_ADD) && lhsType.isDouble() && rhsType.isDouble()) {
-        *def = f.binary<MAdd>(lhsDef, rhsDef, MIRType_Double);
-        *type = Type::Double;
-        return true;
-    }
-
-    if (expr->isKind(PNK_SUB) && lhsType.isDoublish() && rhsType.isDoublish()) {
-        *def = f.binary<MSub>(lhsDef, rhsDef, MIRType_Double);
-        *type = Type::Double;
-        return true;
-    }
-
-    return f.fail("Arguments to + or - must both be ints or doubles", expr);
+    if (!lhsType.isDouble() || !rhsType.isDouble())
+        return f.fail("Arguments to + or - must both be ints or doubles", expr);
+
+    *def = expr->isKind(PNK_ADD)
+           ? f.binary<MAdd>(lhsDef, rhsDef, MIRType_Double)
+           : f.binary<MSub>(lhsDef, rhsDef, MIRType_Double);
+    *type = Type::Double;
+    return true;
 }
 
 static bool
 CheckDivOrMod(FunctionCompiler &f, ParseNode *expr, MDefinition **def, Type *type)
 {
     JS_ASSERT(expr->isKind(PNK_DIV) || expr->isKind(PNK_MOD));
     ParseNode *lhs = BinaryLeft(expr);
     ParseNode *rhs = BinaryRight(expr);
--- a/js/src/jit-test/tests/asm.js/testExpressions.js
+++ b/js/src/jit-test/tests/asm.js/testExpressions.js
@@ -242,18 +242,18 @@ assertEq(f(1,true), 1);
 assertEq(f(-1,true), 0);
 assertEq(f(-5,true), 1);
 assertEq(f(1,false), 0);
 assertEq(f(-1,false), 0);
 assertEq(f(-5,false), 1);
 
 assertAsmTypeFail('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return (i32[0]+1)|0 } return f");
 assertAsmTypeFail('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] + 1.0); } return f");
+assertAsmTypeFail('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] - 1.0); } return f");
 new Float64Array(BUF_64KB)[0] = 2.3;
-assertEq(asmLink(asmCompile('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] - 1.0) } return f"), this, null, BUF_64KB)(), 2.3-1);
 assertEq(asmLink(asmCompile('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] * 2.0) } return f"), this, null, BUF_64KB)(), 2.3*2);
 assertEq(asmLink(asmCompile('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] / 2.0) } return f"), this, null, BUF_64KB)(), 2.3/2);
 assertEq(asmLink(asmCompile('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +(f64[0] % 2.0) } return f"), this, null, BUF_64KB)(), 2.3%2);
 assertEq(asmLink(asmCompile('glob','imp','b', USE_ASM + HEAP_IMPORTS + "function f() { return +-f64[0] } return f"), this, null, BUF_64KB)(), -2.3);
 assertEq(asmLink(asmCompile('glob','imp','b', USE_ASM + HEAP_IMPORTS + "var sqrt=glob.Math.sqrt; function f() { return +sqrt(f64[0]) } return f"), this, null, BUF_64KB)(), Math.sqrt(2.3));
 new Int32Array(BUF_64KB)[0] = 42;
 assertEq(asmLink(asmCompile('glob','imp','b', USE_ASM + HEAP_IMPORTS + "var imul=glob.Math.imul; function f() { return imul(i32[0], 2)|0 } return f"), this, null, BUF_64KB)(), 84);
 
--- a/js/src/jit-test/tests/asm.js/testHeapAccess.js
+++ b/js/src/jit-test/tests/asm.js/testHeapAccess.js
@@ -77,17 +77,17 @@ assertEq(f(0x100),0);
 
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; i8[0] = i; return u8[0]|0}; return f');
 var f = asmLink(code, this, null, new ArrayBuffer(4096));
 assertEq(f(0),0);
 assertEq(f(0x7f),0x7f);
 assertEq(f(0xff),0xff);
 assertEq(f(0x100),0);
 
-var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=+j; f64[i>>3] = j; return (~~f64[i>>3])|0}; return f');
+var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=+j; f64[i>>3] = j; return (~~+f64[i>>3])|0}; return f');
 var f = asmLink(code, this, null, new ArrayBuffer(4096));
 assertEq(f(0, 1.3), 1);
 assertEq(f(4088, 2.5), 2);
 assertEq(f(4096, 3.8), 0);
 
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=+j; f64[i>>3] = j; return +f64[i>>3]}; return f');
 var f = asmLink(code, this, null, new ArrayBuffer(4096));
 assertEq(f(0, 1.3), 1.3);