Bug 906286 - Canonicalize NaN values stored to float arrays in JS_MORE_DETERMINISTIC builds. r=luke

This commit is contained in:
Jan de Mooij 2013-08-21 08:40:17 +02:00
Родитель 32900daa61
Коммит d190818dc9
2 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -579,8 +579,12 @@ class MacroAssembler : public MacroAssemblerSpecific
}
}
template<typename S, typename T>
void storeToTypedFloatArray(int arrayType, const S &value, const T &dest) {
template<typename T>
void storeToTypedFloatArray(int arrayType, FloatRegister value, const T &dest) {
#ifdef JS_MORE_DETERMINISTIC
// See the comment in ToDoubleForTypedArray.
canonicalizeDouble(value);
#endif
switch (arrayType) {
case TypedArrayObject::TYPE_FLOAT32:
convertDoubleToFloat(value, ScratchFloatReg);

Просмотреть файл

@ -1357,6 +1357,14 @@ js::ToDoubleForTypedArray(JSContext *cx, JS::HandleValue vp, double *d)
*d = js_NaN;
}
#ifdef JS_MORE_DETERMINISTIC
// It's possible to have a NaN value with the sign bit set. The spec allows
// this but it can confuse differential testing when this value is stored
// to a float array and then read back as integer. To work around this, we
// always canonicalize NaN values in more-deterministic builds.
*d = JS_CANONICALIZE_NAN(*d);
#endif
return true;
}