Loading js/src/jit-test/tests/asm.js/testExpressions.js +1 −1 Original line number Diff line number Diff line Loading @@ -253,8 +253,8 @@ 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"); new Float64Array(BUF_64KB)[0] = 2.3; 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] / 2.0) } return f"), this, null, BUF_64KB)(), 2.3/2); Loading js/src/jit/AsmJS.cpp +12 −21 Original line number Diff line number Diff line Loading @@ -4157,29 +4157,20 @@ CheckAddOrSub(FunctionCompiler &f, ParseNode *expr, MDefinition **def, Type *typ if (numAddOrSub > (1<<20)) return f.fail(expr, "too many + or - without intervening coercion"); if (expr->isKind(PNK_ADD)) { if (lhsType.isInt() && rhsType.isInt()) { *def = f.binary<MAdd>(lhsDef, rhsDef, MIRType_Int32); *type = Type::Intish; } else if (lhsType.isDouble() && rhsType.isDouble()) { *def = f.binary<MAdd>(lhsDef, rhsDef, MIRType_Double); *type = Type::Double; } else { return f.failf(expr, "operands to + must both be int or double, got %s and %s", lhsType.toChars(), rhsType.toChars()); } } else { if (lhsType.isInt() && rhsType.isInt()) { *def = f.binary<MSub>(lhsDef, rhsDef, MIRType_Int32); *def = expr->isKind(PNK_ADD) ? f.binary<MAdd>(lhsDef, rhsDef, MIRType_Int32) : f.binary<MSub>(lhsDef, rhsDef, MIRType_Int32); *type = Type::Intish; } else if (lhsType.isDoublish() && rhsType.isDoublish()) { *def = f.binary<MSub>(lhsDef, rhsDef, MIRType_Double); *def = expr->isKind(PNK_ADD) ? f.binary<MAdd>(lhsDef, rhsDef, MIRType_Double) : f.binary<MSub>(lhsDef, rhsDef, MIRType_Double); *type = Type::Double; } else { return f.failf(expr, "operands to - must both be int or doublish, got %s and %s", return f.failf(expr, "operands to +/- must both be int or doublish, got %s and %s", lhsType.toChars(), rhsType.toChars()); } } if (numAddOrSubOut) *numAddOrSubOut = numAddOrSub; Loading Loading
js/src/jit-test/tests/asm.js/testExpressions.js +1 −1 Original line number Diff line number Diff line Loading @@ -253,8 +253,8 @@ 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"); new Float64Array(BUF_64KB)[0] = 2.3; 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] / 2.0) } return f"), this, null, BUF_64KB)(), 2.3/2); Loading
js/src/jit/AsmJS.cpp +12 −21 Original line number Diff line number Diff line Loading @@ -4157,29 +4157,20 @@ CheckAddOrSub(FunctionCompiler &f, ParseNode *expr, MDefinition **def, Type *typ if (numAddOrSub > (1<<20)) return f.fail(expr, "too many + or - without intervening coercion"); if (expr->isKind(PNK_ADD)) { if (lhsType.isInt() && rhsType.isInt()) { *def = f.binary<MAdd>(lhsDef, rhsDef, MIRType_Int32); *type = Type::Intish; } else if (lhsType.isDouble() && rhsType.isDouble()) { *def = f.binary<MAdd>(lhsDef, rhsDef, MIRType_Double); *type = Type::Double; } else { return f.failf(expr, "operands to + must both be int or double, got %s and %s", lhsType.toChars(), rhsType.toChars()); } } else { if (lhsType.isInt() && rhsType.isInt()) { *def = f.binary<MSub>(lhsDef, rhsDef, MIRType_Int32); *def = expr->isKind(PNK_ADD) ? f.binary<MAdd>(lhsDef, rhsDef, MIRType_Int32) : f.binary<MSub>(lhsDef, rhsDef, MIRType_Int32); *type = Type::Intish; } else if (lhsType.isDoublish() && rhsType.isDoublish()) { *def = f.binary<MSub>(lhsDef, rhsDef, MIRType_Double); *def = expr->isKind(PNK_ADD) ? f.binary<MAdd>(lhsDef, rhsDef, MIRType_Double) : f.binary<MSub>(lhsDef, rhsDef, MIRType_Double); *type = Type::Double; } else { return f.failf(expr, "operands to - must both be int or doublish, got %s and %s", return f.failf(expr, "operands to +/- must both be int or doublish, got %s and %s", lhsType.toChars(), rhsType.toChars()); } } if (numAddOrSubOut) *numAddOrSubOut = numAddOrSub; Loading