зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1114351 - Use mozilla::IsNaN() in DOUBLE_TO_JSVAL(); r=Waldo
Note that this requires making sure that IsNaN is constexpr because it needs to be passed to the constexpr IMPL_TO_JSVALUE() function in DOUBLE_TO_JSVAL(). --HG-- extra : amend_source : dbd8bb0659b53e7d36d2600ac97f0a753ef772c7
This commit is contained in:
Родитель
8daffda8e5
Коммит
d803a0513e
|
@ -1922,7 +1922,7 @@ DOUBLE_TO_JSVAL(double d)
|
|||
* because GCC from XCode 3.1.4 miscompiles the above code.
|
||||
*/
|
||||
#if defined(JS_VALUE_IS_CONSTEXPR)
|
||||
return IMPL_TO_JSVAL(MOZ_UNLIKELY(d != d)
|
||||
return IMPL_TO_JSVAL(MOZ_UNLIKELY(mozilla::IsNaN(d))
|
||||
? (jsval_layout) { .asBits = 0x7FF8000000000000LL }
|
||||
: (jsval_layout) { .asDouble = d });
|
||||
#else
|
||||
|
|
|
@ -115,9 +115,9 @@ struct FloatingPoint : public SelectTrait<T>
|
|||
static_assert(sizeof(T) == sizeof(Bits), "Bits must be same size as T");
|
||||
};
|
||||
|
||||
/** Determines whether a double is NaN. */
|
||||
/** Determines whether a float/double is NaN. */
|
||||
template<typename T>
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
static MOZ_ALWAYS_INLINE MOZ_CONSTEXPR bool
|
||||
IsNaN(T aValue)
|
||||
{
|
||||
/*
|
||||
|
@ -126,9 +126,8 @@ IsNaN(T aValue)
|
|||
*/
|
||||
typedef FloatingPoint<T> Traits;
|
||||
typedef typename Traits::Bits Bits;
|
||||
Bits bits = BitwiseCast<Bits>(aValue);
|
||||
return (bits & Traits::kExponentBits) == Traits::kExponentBits &&
|
||||
(bits & Traits::kSignificandBits) != 0;
|
||||
return (BitwiseCast<Bits>(aValue) & Traits::kExponentBits) == Traits::kExponentBits &&
|
||||
(BitwiseCast<Bits>(aValue) & Traits::kSignificandBits) != 0;
|
||||
}
|
||||
|
||||
/** Determines whether a float/double is +Infinity or -Infinity. */
|
||||
|
|
Загрузка…
Ссылка в новой задаче