зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1548908: Clean up JS::CanonicalizedDoubleValue r=tcampbell
1. CanonicalizedDoubleValue should reuse the logic in CanonicalizeNaN. 2. Places that call DoubleValue(CanonicalizeNaN(d)) should just use CanonicalizedDoubleValue(d). Differential Revision: https://phabricator.services.mozilla.com/D29867 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b99235e484
Коммит
5a8c83aeaa
|
@ -114,7 +114,7 @@ inline ClippedTime TimeClip(double time) {
|
|||
// Produce a double Value from the given time. Because times may be NaN,
|
||||
// prefer using this to manual canonicalization.
|
||||
inline Value TimeValue(ClippedTime time) {
|
||||
return DoubleValue(CanonicalizeNaN(time.toDouble()));
|
||||
return CanonicalizedDoubleValue(time.toDouble());
|
||||
}
|
||||
|
||||
// Create a new Date object whose [[DateValue]] internal slot contains the
|
||||
|
|
|
@ -1030,19 +1030,8 @@ static inline Value DoubleValue(double dbl) {
|
|||
return v;
|
||||
}
|
||||
|
||||
static constexpr Value CanonicalNaNValue() {
|
||||
uint64_t rawBits = detail::CanonicalizedNaNBits;
|
||||
#if defined(JS_PUNBOX64)
|
||||
rawBits += JSVAL_PUN64_DOUBLE_ADJUST;
|
||||
#endif
|
||||
return Value::fromRawBits(rawBits);
|
||||
}
|
||||
|
||||
static inline Value CanonicalizedDoubleValue(double d) {
|
||||
if (MOZ_UNLIKELY(mozilla::IsNaN(d))) {
|
||||
return CanonicalNaNValue();
|
||||
}
|
||||
return Value::fromDouble(d);
|
||||
return Value::fromDouble(CanonicalizeNaN(d));
|
||||
}
|
||||
|
||||
static inline bool IsCanonicalized(double d) {
|
||||
|
|
|
@ -46,13 +46,12 @@ bool HashableValue::setValue(JSContext* cx, HandleValue v) {
|
|||
int32_t i;
|
||||
if (NumberEqualsInt32(d, &i)) {
|
||||
// Normalize int32_t-valued doubles to int32_t for faster hashing and
|
||||
// testing.
|
||||
// testing. Note: we use NumberEqualsInt32 here instead of NumberIsInt32
|
||||
// because we want -0 and 0 to be normalized to the same thing.
|
||||
value = Int32Value(i);
|
||||
} else if (IsNaN(d)) {
|
||||
// NaNs with different bits must hash and test identically.
|
||||
value = DoubleNaNValue();
|
||||
} else {
|
||||
value = v;
|
||||
// Normalize the sign bit of a NaN.
|
||||
value = JS::CanonicalizedDoubleValue(d);
|
||||
}
|
||||
} else {
|
||||
value = v;
|
||||
|
|
|
@ -1977,7 +1977,7 @@ bool TypedArrayObjectTemplate<float>::getElementPure(TypedArrayObject* tarray,
|
|||
* This could be removed for platforms/compilers known to convert a 32-bit
|
||||
* non-canonical nan to a 64-bit canonical nan.
|
||||
*/
|
||||
*vp = DoubleValue(CanonicalizeNaN(dval));
|
||||
*vp = JS::CanonicalizedDoubleValue(dval);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1994,7 +1994,7 @@ bool TypedArrayObjectTemplate<double>::getElementPure(TypedArrayObject* tarray,
|
|||
* confuse the engine into interpreting a double-typed jsval as an
|
||||
* object-typed jsval.
|
||||
*/
|
||||
*vp = DoubleValue(CanonicalizeNaN(val));
|
||||
*vp = JS::CanonicalizedDoubleValue(val);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -208,9 +208,9 @@ static Value ToJSValue(const Val& val) {
|
|||
case ValType::I32:
|
||||
return Int32Value(val.i32());
|
||||
case ValType::F32:
|
||||
return DoubleValue(JS::CanonicalizeNaN(double(val.f32())));
|
||||
return JS::CanonicalizedDoubleValue(double(val.f32()));
|
||||
case ValType::F64:
|
||||
return DoubleValue(JS::CanonicalizeNaN(val.f64()));
|
||||
return JS::CanonicalizedDoubleValue(val.f64());
|
||||
case ValType::FuncRef:
|
||||
case ValType::AnyRef:
|
||||
return UnboxAnyRef(val.ref());
|
||||
|
|
Загрузка…
Ссылка в новой задаче