Bug 953270 - Canonicalize NaN on lane access r=till

This commit is contained in:
Nicholas D. Matsakis 2014-01-08 05:00:05 -05:00
parent 7ad0d371c9
commit b050660309
2 changed files with 32 additions and 1 deletions

View File

@ -12,9 +12,13 @@
*/
#include "builtin/SIMD.h"
#include "jsapi.h"
#include "jsfriendapi.h"
#include "builtin/TypedObject.h"
#include "js/Value.h"
#include "jsobjinlines.h"
using namespace js;
@ -48,7 +52,7 @@ struct Float32x4 {
*out = v.toNumber();
}
static void setReturn(CallArgs &args, float value) {
args.rval().setDouble(value);
args.rval().setDouble(JS::CanonicalizeNaN(value));
}
};

View File

@ -0,0 +1,27 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
var BUGNUMBER = 953270;
var summary = 'Handles';
// Check that NaN normalization is applied when extracting the x lane
// out, after bit conversion has occurred.
var int32x4 = SIMD.int32x4;
var a = int32x4((4294967295), 200, 300, 400);
var c = SIMD.int32x4.bitsToFloat32x4(a);
// NaN canonicalization occurs when extracting out x lane:
assertEq(c.x, NaN);
// but underlying bits are faithfully transmitted
// (though reinterpreted as a signed integer):
var d = SIMD.float32x4.bitsToInt32x4(c);
assertEq(d.x, -1);
reportCompare(true, true);
print("Tests complete");