Bug 859892 - Rename JS_CANONICALIZE_NAN to JS::CanonicalizeNaN. r=Waldo

This commit is contained in:
Jan de Mooij 2013-10-17 10:16:17 +02:00
Родитель 2dcd8b769e
Коммит 6cecaaf71d
4 изменённых файлов: 18 добавлений и 29 удалений

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

@ -843,17 +843,6 @@ JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l)
#endif /* JS_BITS_PER_WORD */ #endif /* JS_BITS_PER_WORD */
static inline double
JS_CANONICALIZE_NAN(double d)
{
if (MOZ_UNLIKELY(d != d)) {
jsval_layout l;
l.asBits = 0x7FF8000000000000LL;
return l.asDouble;
}
return d;
}
static inline jsval_layout JSVAL_TO_IMPL(JS::Value v); static inline jsval_layout JSVAL_TO_IMPL(JS::Value v);
static inline JS_VALUE_CONSTEXPR JS::Value IMPL_TO_JSVAL(jsval_layout l); static inline JS_VALUE_CONSTEXPR JS::Value IMPL_TO_JSVAL(jsval_layout l);
@ -873,6 +862,14 @@ GenericNaN()
return mozilla::SpecificNaN(0, 0x8000000000000ULL); return mozilla::SpecificNaN(0, 0x8000000000000ULL);
} }
static inline double
CanonicalizeNaN(double d)
{
if (MOZ_UNLIKELY(mozilla::IsNaN(d)))
return GenericNaN();
return d;
}
/* /*
* JS::Value is the interface for a single JavaScript Engine value. A few * JS::Value is the interface for a single JavaScript Engine value. A few
* general notes on JS::Value: * general notes on JS::Value:

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

@ -847,7 +847,7 @@ static JS_ALWAYS_INLINE jsval
JS_NumberValue(double d) JS_NumberValue(double d)
{ {
int32_t i; int32_t i;
d = JS_CANONICALIZE_NAN(d); d = JS::CanonicalizeNaN(d);
if (mozilla::DoubleIsInt32(d, &i)) if (mozilla::DoubleIsInt32(d, &i))
return INT_TO_JSVAL(i); return INT_TO_JSVAL(i);
return DOUBLE_TO_JSVAL(d); return DOUBLE_TO_JSVAL(d);

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

@ -48,6 +48,7 @@ using namespace js;
using mozilla::IsNaN; using mozilla::IsNaN;
using mozilla::LittleEndian; using mozilla::LittleEndian;
using mozilla::NativeEndian; using mozilla::NativeEndian;
using JS::CanonicalizeNaN;
enum StructuredDataType { enum StructuredDataType {
/* Structured data types provided by the engine */ /* Structured data types provided by the engine */
@ -424,16 +425,6 @@ SCInput::replacePair(uint32_t tag, uint32_t data)
return replace(PairToUInt64(tag, data)); return replace(PairToUInt64(tag, data));
} }
/*
* The purpose of this never-inlined function is to avoid a strange g++ build
* error on OS X 10.5 (see bug 624080). :-(
*/
static JS_NEVER_INLINE double
CanonicalizeNan(double d)
{
return JS_CANONICALIZE_NAN(d);
}
bool bool
SCInput::readDouble(double *p) SCInput::readDouble(double *p)
{ {
@ -443,7 +434,7 @@ SCInput::readDouble(double *p)
} pun; } pun;
if (!read(&pun.u)) if (!read(&pun.u))
return false; return false;
*p = CanonicalizeNan(pun.d); *p = CanonicalizeNaN(pun.d);
return true; return true;
} }
@ -558,7 +549,7 @@ ReinterpretPairAsDouble(uint32_t tag, uint32_t data)
bool bool
SCOutput::writeDouble(double d) SCOutput::writeDouble(double d)
{ {
return write(ReinterpretDoubleAsUInt64(CanonicalizeNan(d))); return write(ReinterpretDoubleAsUInt64(CanonicalizeNaN(d)));
} }
template <typename T> template <typename T>

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

@ -53,6 +53,7 @@ using namespace js::types;
using mozilla::IsNaN; using mozilla::IsNaN;
using mozilla::PodCopy; using mozilla::PodCopy;
using JS::CanonicalizeNaN;
using JS::GenericNaN; using JS::GenericNaN;
/* /*
@ -1263,7 +1264,7 @@ js::ToDoubleForTypedArray(JSContext *cx, JS::HandleValue vp, double *d)
// this but it can confuse differential testing when this value is stored // 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 // to a float array and then read back as integer. To work around this, we
// always canonicalize NaN values in more-deterministic builds. // always canonicalize NaN values in more-deterministic builds.
*d = JS_CANONICALIZE_NAN(*d); *d = CanonicalizeNaN(*d);
#endif #endif
return true; return true;
@ -2633,7 +2634,7 @@ TypedArrayObjectTemplate<float>::copyIndexToValue(JSObject *tarray, uint32_t ind
* This could be removed for platforms/compilers known to convert a 32-bit * This could be removed for platforms/compilers known to convert a 32-bit
* non-canonical nan to a 64-bit canonical nan. * non-canonical nan to a 64-bit canonical nan.
*/ */
vp.setDouble(JS_CANONICALIZE_NAN(dval)); vp.setDouble(CanonicalizeNaN(dval));
} }
template<> template<>
@ -2650,7 +2651,7 @@ TypedArrayObjectTemplate<double>::copyIndexToValue(JSObject *tarray, uint32_t in
* confuse the engine into interpreting a double-typed jsval as an * confuse the engine into interpreting a double-typed jsval as an
* object-typed jsval. * object-typed jsval.
*/ */
vp.setDouble(JS_CANONICALIZE_NAN(val)); vp.setDouble(CanonicalizeNaN(val));
} }
} /* anonymous namespace */ } /* anonymous namespace */
@ -3111,7 +3112,7 @@ DataViewObject::getFloat32Impl(JSContext *cx, CallArgs args)
if (!read(cx, thisView, args, &val, "getFloat32")) if (!read(cx, thisView, args, &val, "getFloat32"))
return false; return false;
args.rval().setDouble(JS_CANONICALIZE_NAN(val)); args.rval().setDouble(CanonicalizeNaN(val));
return true; return true;
} }
@ -3133,7 +3134,7 @@ DataViewObject::getFloat64Impl(JSContext *cx, CallArgs args)
if (!read(cx, thisView, args, &val, "getFloat64")) if (!read(cx, thisView, args, &val, "getFloat64"))
return false; return false;
args.rval().setDouble(JS_CANONICALIZE_NAN(val)); args.rval().setDouble(CanonicalizeNaN(val));
return true; return true;
} }