Bug 1126251: Force float32 coercion of Float AsmJSNumLit input; r=luke

This commit is contained in:
Benjamin Bouvier 2015-01-28 10:24:06 +01:00
parent ea7c16928c
commit 462648786d
2 changed files with 39 additions and 0 deletions

View File

@ -147,6 +147,9 @@ class AsmJSNumLit
static AsmJSNumLit Create(Which w, Value v) {
AsmJSNumLit lit;
lit.which_ = w;
// Force float32 coercion, as the caller may have not done it.
if (w == Float)
v = Float32Value(v.toNumber());
lit.value.scalar_ = v;
MOZ_ASSERT(!lit.isSimd());
return lit;

View File

@ -0,0 +1,36 @@
load(libdir + "asm.js");
var v = asmLink(asmCompile('global', `
"use asm";
var frd = global.Math.fround;
function e() {
var x = frd(.1e+71);
x = frd(x / x);
return +x;
}
return e;
`), this)();
assertEq(v, NaN);
if (!isSimdAvailable() || typeof SIMD === 'undefined') {
quit(0);
}
var v = asmLink(asmCompile('global', `
"use asm";
var frd = global.Math.fround;
var float32x4 = global.SIMD.float32x4;
var splat = float32x4.splat;
function e() {
var v = float32x4(0,0,0,0);
var x = frd(0.);
v = splat(.1e+71);
x = v.x;
x = frd(x / x);
return +x;
}
return e;
`), this)();
assertEq(v, NaN);