Loading js/src/jit-test/tests/asm.js/testHeapAccess.js +6 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,12 @@ 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])|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); Loading js/src/jit/AsmJS.cpp +5 −8 Original line number Diff line number Diff line Loading @@ -387,8 +387,7 @@ class Type Signed, Unsigned, Intish, Void, Unknown Void }; private: Loading @@ -414,7 +413,7 @@ class Type } bool isIntish() const { return isInt() || which_ == Intish || which_ == Unknown; return isInt() || which_ == Intish; } bool isDouble() const { Loading @@ -422,7 +421,7 @@ class Type } bool isDoublish() const { return isDouble() || which_ == Doublish || which_ == Unknown; return isDouble() || which_ == Doublish; } bool isVoid() const { Loading @@ -449,7 +448,6 @@ class Type case Intish: return MIRType_Int32; case Void: case Unknown: return MIRType_None; } MOZ_ASSUME_UNREACHABLE("Invalid Type"); Loading @@ -465,7 +463,6 @@ class Type case Unsigned: return "unsigned"; case Intish: return "intish"; case Void: return "void"; case Unknown: return "unknown"; } MOZ_ASSUME_UNREACHABLE("Invalid Type"); } Loading Loading @@ -3947,14 +3944,14 @@ CheckCoerceToInt(FunctionCompiler &f, ParseNode *expr, MDefinition **def, Type * if (!CheckExpr(f, operand, &operandDef, &operandType)) return false; if (operandType.isDouble()) { if (operandType.isDoublish()) { *def = f.unary<MTruncateToInt32>(operandDef); *type = Type::Signed; return true; } if (!operandType.isIntish()) return f.failf(operand, "%s is not a subtype of double or intish", operandType.toChars()); return f.failf(operand, "%s is not a subtype of doublish or intish", operandType.toChars()); *def = operandDef; *type = Type::Signed; Loading Loading
js/src/jit-test/tests/asm.js/testHeapAccess.js +6 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,12 @@ 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])|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); Loading
js/src/jit/AsmJS.cpp +5 −8 Original line number Diff line number Diff line Loading @@ -387,8 +387,7 @@ class Type Signed, Unsigned, Intish, Void, Unknown Void }; private: Loading @@ -414,7 +413,7 @@ class Type } bool isIntish() const { return isInt() || which_ == Intish || which_ == Unknown; return isInt() || which_ == Intish; } bool isDouble() const { Loading @@ -422,7 +421,7 @@ class Type } bool isDoublish() const { return isDouble() || which_ == Doublish || which_ == Unknown; return isDouble() || which_ == Doublish; } bool isVoid() const { Loading @@ -449,7 +448,6 @@ class Type case Intish: return MIRType_Int32; case Void: case Unknown: return MIRType_None; } MOZ_ASSUME_UNREACHABLE("Invalid Type"); Loading @@ -465,7 +463,6 @@ class Type case Unsigned: return "unsigned"; case Intish: return "intish"; case Void: return "void"; case Unknown: return "unknown"; } MOZ_ASSUME_UNREACHABLE("Invalid Type"); } Loading Loading @@ -3947,14 +3944,14 @@ CheckCoerceToInt(FunctionCompiler &f, ParseNode *expr, MDefinition **def, Type * if (!CheckExpr(f, operand, &operandDef, &operandType)) return false; if (operandType.isDouble()) { if (operandType.isDoublish()) { *def = f.unary<MTruncateToInt32>(operandDef); *type = Type::Signed; return true; } if (!operandType.isIntish()) return f.failf(operand, "%s is not a subtype of double or intish", operandType.toChars()); return f.failf(operand, "%s is not a subtype of doublish or intish", operandType.toChars()); *def = operandDef; *type = Type::Signed; Loading