From 10f49d4180bb3d44fe0f7a48abaaa3025d88e893 Mon Sep 17 00:00:00 2001 From: Andi-Bogdan Postelnicu Date: Wed, 22 Mar 2023 11:35:33 +0000 Subject: [PATCH] Bug 1660405 - Move away from mozilla::IsNaN in favor of std::isnan. r=nbp,media-playback-reviewers,sergesanspaille,padenot Differential Revision: https://phabricator.services.mozilla.com/D173035 --- accessible/android/SessionAccessibility.cpp | 6 ++-- accessible/atk/nsMaiInterfaceValue.cpp | 8 ++--- accessible/generic/LocalAccessible.cpp | 12 +++---- accessible/html/HTMLFormControlAccessible.cpp | 36 +++++++++---------- accessible/ipc/RemoteAccessibleBase.cpp | 2 +- accessible/mac/mozActionElements.mm | 3 +- accessible/windows/ia2/ia2AccessibleValue.cpp | 6 ++-- accessible/xpcom/xpcAccessibleValue.cpp | 8 ++--- build/clang-plugin/NaNExprChecker.cpp | 4 +-- .../clang-plugin/tests/TestNANTestingExpr.cpp | 8 ++--- dom/animation/AnimationEffect.cpp | 2 +- dom/animation/TimingParams.h | 2 +- dom/bindings/PrimitiveConversions.h | 2 +- dom/canvas/CanvasRenderingContext2D.cpp | 2 +- dom/canvas/WebGLContextUtils.cpp | 2 +- dom/geolocation/GeolocationCoordinates.cpp | 2 +- dom/geolocation/GeolocationPosition.cpp | 3 +- dom/html/HTMLInputElement.cpp | 4 +-- dom/html/HTMLMediaElement.cpp | 2 +- dom/html/input/DateTimeInputTypes.cpp | 4 +-- dom/indexedDB/Key.cpp | 4 +-- dom/media/MediaDecoder.cpp | 4 +-- dom/media/TimeUnits.h | 6 ++-- dom/media/mediasource/MediaSource.cpp | 2 +- dom/media/mediasource/MediaSourceDecoder.cpp | 6 ++-- dom/media/mediasource/SourceBuffer.cpp | 6 ++-- dom/media/webaudio/AudioBufferSourceNode.cpp | 2 +- dom/media/webaudio/WebAudioUtils.h | 4 +-- .../blink/DynamicsCompressorKernel.cpp | 9 +++-- dom/media/webaudio/blink/IIRFilter.cpp | 2 +- dom/media/webaudio/blink/Reverb.cpp | 3 +- dom/system/linux/GeoclueLocationProvider.cpp | 2 +- dom/system/linux/GpsdLocationProvider.cpp | 18 +++++----- dom/xslt/base/txDouble.cpp | 2 +- dom/xslt/xpath/txCoreFunctionCall.cpp | 4 +-- dom/xslt/xpath/txNumberExpr.cpp | 4 +-- dom/xslt/xpath/txNumberResult.cpp | 2 +- dom/xslt/xslt/txEXSLTFunctions.cpp | 4 +-- dom/xslt/xslt/txFormatNumberFunctionCall.cpp | 2 +- dom/xslt/xslt/txStylesheet.cpp | 4 +-- dom/xslt/xslt/txStylesheetCompileHandlers.cpp | 2 +- dom/xslt/xslt/txXPathResultComparator.cpp | 4 +-- dom/xslt/xslt/txXSLTNumber.cpp | 2 +- gfx/layers/apz/src/AsyncPanZoomController.cpp | 4 +-- gfx/thebes/COLRFonts.cpp | 4 +-- gfx/thebes/gfxFont.cpp | 4 +-- intl/components/src/NumberFormat.cpp | 4 +-- intl/components/src/NumberFormatFields.cpp | 2 +- intl/components/src/NumberRangeFormat.cpp | 4 +-- intl/components/src/NumberRangeFormat.h | 4 +-- intl/components/src/RelativeTimeFormat.cpp | 2 +- js/public/Conversions.h | 4 +-- js/public/Date.h | 4 +-- js/public/Value.h | 2 +- js/src/builtin/Array.cpp | 4 +-- js/src/builtin/AtomicsObject.cpp | 2 +- js/src/builtin/MapObject.cpp | 1 - js/src/builtin/String.cpp | 3 +- js/src/builtin/TestingFunctions.cpp | 2 +- js/src/builtin/intl/NumberFormat.cpp | 6 ++-- js/src/builtin/intl/PluralRules.cpp | 4 +-- js/src/frontend/FoldConstants.cpp | 3 +- js/src/jit/MIR.cpp | 13 ++++--- js/src/jit/RangeAnalysis.cpp | 7 ++-- js/src/jit/RangeAnalysis.h | 4 +-- js/src/jit/Recover.cpp | 2 +- js/src/jit/arm/Simulator-arm.cpp | 6 ++-- js/src/jit/mips32/Simulator-mips32.cpp | 30 ++++++++-------- js/src/jit/mips64/Simulator-mips64.cpp | 30 ++++++++-------- js/src/jsdate.cpp | 19 +++++----- js/src/jslibmath.h | 2 +- js/src/jsmath.cpp | 12 +++---- js/src/jsnum.cpp | 6 ++-- js/src/shell/js.cpp | 4 +-- js/src/vm/BigIntType.cpp | 8 ++--- js/src/vm/EqualityOperations.cpp | 2 +- js/src/vm/Interpreter.cpp | 2 +- js/src/vm/TypedArrayObject-inl.h | 2 +- js/src/wasm/AsmJS.cpp | 7 ++-- js/src/wasm/WasmBuiltins.cpp | 8 ++--- layout/base/MobileViewportManager.cpp | 2 +- layout/base/nsLayoutUtils.cpp | 4 +-- layout/style/AnimationCommon.h | 2 +- layout/style/nsCSSValue.cpp | 8 ++--- layout/style/nsCSSValue.h | 2 +- layout/style/nsStyleStruct.cpp | 2 +- mfbt/FloatingPoint.h | 16 ++++----- modules/libpref/Preferences.cpp | 2 +- mozglue/tests/TestBaseProfiler.cpp | 2 +- xpcom/ds/nsVariant.cpp | 6 ++-- 90 files changed, 236 insertions(+), 253 deletions(-) diff --git a/accessible/android/SessionAccessibility.cpp b/accessible/android/SessionAccessibility.cpp index 47aecd75d89c..50a77b7c2322 100644 --- a/accessible/android/SessionAccessibility.cpp +++ b/accessible/android/SessionAccessibility.cpp @@ -785,13 +785,13 @@ mozilla::java::GeckoBundle::LocalRef SessionAccessibility::ToBundle( java::sdk::Integer::ValueOf(0)); // integer } - if (!IsNaN(aCurVal)) { + if (!std::isnan(aCurVal)) { GECKOBUNDLE_PUT(rangeInfo, "current", java::sdk::Double::New(aCurVal)); } - if (!IsNaN(aMinVal)) { + if (!std::isnan(aMinVal)) { GECKOBUNDLE_PUT(rangeInfo, "min", java::sdk::Double::New(aMinVal)); } - if (!IsNaN(aMaxVal)) { + if (!std::isnan(aMaxVal)) { GECKOBUNDLE_PUT(rangeInfo, "max", java::sdk::Double::New(aMaxVal)); } diff --git a/accessible/atk/nsMaiInterfaceValue.cpp b/accessible/atk/nsMaiInterfaceValue.cpp index 9a6546d7ae99..18e67b3c0eb4 100644 --- a/accessible/atk/nsMaiInterfaceValue.cpp +++ b/accessible/atk/nsMaiInterfaceValue.cpp @@ -25,7 +25,7 @@ static void getCurrentValueCB(AtkValue* obj, GValue* value) { memset(value, 0, sizeof(GValue)); double accValue = acc->CurValue(); - if (IsNaN(accValue)) return; + if (std::isnan(accValue)) return; g_value_init(value, G_TYPE_DOUBLE); g_value_set_double(value, accValue); @@ -39,7 +39,7 @@ static void getMaximumValueCB(AtkValue* obj, GValue* value) { memset(value, 0, sizeof(GValue)); double accValue = acc->MaxValue(); - if (IsNaN(accValue)) return; + if (std::isnan(accValue)) return; g_value_init(value, G_TYPE_DOUBLE); g_value_set_double(value, accValue); @@ -53,7 +53,7 @@ static void getMinimumValueCB(AtkValue* obj, GValue* value) { memset(value, 0, sizeof(GValue)); double accValue = acc->MinValue(); - if (IsNaN(accValue)) return; + if (std::isnan(accValue)) return; g_value_init(value, G_TYPE_DOUBLE); g_value_set_double(value, accValue); @@ -67,7 +67,7 @@ static void getMinimumIncrementCB(AtkValue* obj, GValue* minimumIncrement) { memset(minimumIncrement, 0, sizeof(GValue)); double accValue = acc->Step(); - if (IsNaN(accValue)) { + if (std::isnan(accValue)) { accValue = 0; // zero if the minimum increment is undefined } diff --git a/accessible/generic/LocalAccessible.cpp b/accessible/generic/LocalAccessible.cpp index 1087755a4e78..6e8e301651f7 100644 --- a/accessible/generic/LocalAccessible.cpp +++ b/accessible/generic/LocalAccessible.cpp @@ -1657,7 +1657,7 @@ void LocalAccessible::Value(nsString& aValue) const { nsGkAtoms::aria_valuetext, aValue)) { if (!NativeHasNumericValue()) { double checkValue = CurValue(); - if (!IsNaN(checkValue)) { + if (!std::isnan(checkValue)) { aValue.AppendFloat(checkValue); } } @@ -1699,7 +1699,7 @@ void LocalAccessible::Value(nsString& aValue) const { double LocalAccessible::MaxValue() const { double checkValue = AttrNumericValue(nsGkAtoms::aria_valuemax); - if (IsNaN(checkValue) && !NativeHasNumericValue()) { + if (std::isnan(checkValue) && !NativeHasNumericValue()) { // aria-valuemax isn't present and this element doesn't natively provide a // maximum value. Use the ARIA default. const nsRoleMapEntry* roleMap = ARIARoleMap(); @@ -1713,7 +1713,7 @@ double LocalAccessible::MaxValue() const { double LocalAccessible::MinValue() const { double checkValue = AttrNumericValue(nsGkAtoms::aria_valuemin); - if (IsNaN(checkValue) && !NativeHasNumericValue()) { + if (std::isnan(checkValue) && !NativeHasNumericValue()) { // aria-valuemin isn't present and this element doesn't natively provide a // minimum value. Use the ARIA default. const nsRoleMapEntry* roleMap = ARIARoleMap(); @@ -1731,7 +1731,7 @@ double LocalAccessible::Step() const { double LocalAccessible::CurValue() const { double checkValue = AttrNumericValue(nsGkAtoms::aria_valuenow); - if (IsNaN(checkValue) && !NativeHasNumericValue()) { + if (std::isnan(checkValue) && !NativeHasNumericValue()) { // aria-valuenow isn't present and this element doesn't natively provide a // current value. Use the ARIA default. const nsRoleMapEntry* roleMap = ARIARoleMap(); @@ -1753,10 +1753,10 @@ bool LocalAccessible::SetCurValue(double aValue) { if (State() & kValueCannotChange) return false; double checkValue = MinValue(); - if (!IsNaN(checkValue) && aValue < checkValue) return false; + if (!std::isnan(checkValue) && aValue < checkValue) return false; checkValue = MaxValue(); - if (!IsNaN(checkValue) && aValue > checkValue) return false; + if (!std::isnan(checkValue) && aValue > checkValue) return false; nsAutoString strValue; strValue.AppendFloat(aValue); diff --git a/accessible/html/HTMLFormControlAccessible.cpp b/accessible/html/HTMLFormControlAccessible.cpp index c6e610ca42be..75f55c400105 100644 --- a/accessible/html/HTMLFormControlAccessible.cpp +++ b/accessible/html/HTMLFormControlAccessible.cpp @@ -532,28 +532,28 @@ void HTMLSpinnerAccessible::Value(nsString& aValue) const { double HTMLSpinnerAccessible::MaxValue() const { double value = HTMLTextFieldAccessible::MaxValue(); - if (!IsNaN(value)) return value; + if (!std::isnan(value)) return value; return HTMLInputElement::FromNode(mContent)->GetMaximum().toDouble(); } double HTMLSpinnerAccessible::MinValue() const { double value = HTMLTextFieldAccessible::MinValue(); - if (!IsNaN(value)) return value; + if (!std::isnan(value)) return value; return HTMLInputElement::FromNode(mContent)->GetMinimum().toDouble(); } double HTMLSpinnerAccessible::Step() const { double value = HTMLTextFieldAccessible::Step(); - if (!IsNaN(value)) return value; + if (!std::isnan(value)) return value; return HTMLInputElement::FromNode(mContent)->GetStep().toDouble(); } double HTMLSpinnerAccessible::CurValue() const { double value = HTMLTextFieldAccessible::CurValue(); - if (!IsNaN(value)) return value; + if (!std::isnan(value)) return value; return HTMLInputElement::FromNode(mContent)->GetValueAsDecimal().toDouble(); } @@ -583,28 +583,28 @@ void HTMLRangeAccessible::Value(nsString& aValue) const { double HTMLRangeAccessible::MaxValue() const { double value = LeafAccessible::MaxValue(); - if (!IsNaN(value)) return value; + if (!std::isnan(value)) return value; return HTMLInputElement::FromNode(mContent)->GetMaximum().toDouble(); } double HTMLRangeAccessible::MinValue() const { double value = LeafAccessible::MinValue(); - if (!IsNaN(value)) return value; + if (!std::isnan(value)) return value; return HTMLInputElement::FromNode(mContent)->GetMinimum().toDouble(); } double HTMLRangeAccessible::Step() const { double value = LeafAccessible::Step(); - if (!IsNaN(value)) return value; + if (!std::isnan(value)) return value; return HTMLInputElement::FromNode(mContent)->GetStep().toDouble(); } double HTMLRangeAccessible::CurValue() const { double value = LeafAccessible::CurValue(); - if (!IsNaN(value)) return value; + if (!std::isnan(value)) return value; return HTMLInputElement::FromNode(mContent)->GetValueAsDecimal().toDouble(); } @@ -771,12 +771,12 @@ void HTMLProgressAccessible::Value(nsString& aValue) const { } double maxValue = MaxValue(); - if (IsNaN(maxValue) || maxValue == 0) { + if (std::isnan(maxValue) || maxValue == 0) { return; } double curValue = CurValue(); - if (IsNaN(curValue)) { + if (std::isnan(curValue)) { return; } @@ -790,7 +790,7 @@ void HTMLProgressAccessible::Value(nsString& aValue) const { double HTMLProgressAccessible::MaxValue() const { double value = LeafAccessible::MaxValue(); - if (!IsNaN(value)) { + if (!std::isnan(value)) { return value; } @@ -809,17 +809,17 @@ double HTMLProgressAccessible::MaxValue() const { double HTMLProgressAccessible::MinValue() const { double value = LeafAccessible::MinValue(); - return IsNaN(value) ? 0 : value; + return std::isnan(value) ? 0 : value; } double HTMLProgressAccessible::Step() const { double value = LeafAccessible::Step(); - return IsNaN(value) ? 0 : value; + return std::isnan(value) ? 0 : value; } double HTMLProgressAccessible::CurValue() const { double value = LeafAccessible::CurValue(); - if (!IsNaN(value)) { + if (!std::isnan(value)) { return value; } @@ -883,7 +883,7 @@ void HTMLMeterAccessible::Value(nsString& aValue) const { // If no inner text is found, use curValue double curValue = CurValue(); - if (IsNaN(curValue)) { + if (std::isnan(curValue)) { return; } @@ -894,7 +894,7 @@ double HTMLMeterAccessible::MaxValue() const { double max = LeafAccessible::MaxValue(); double min = MinValue(); - if (!IsNaN(max)) { + if (!std::isnan(max)) { return max > min ? max : min; } @@ -914,7 +914,7 @@ double HTMLMeterAccessible::MaxValue() const { double HTMLMeterAccessible::MinValue() const { double min = LeafAccessible::MinValue(); - if (!IsNaN(min)) { + if (!std::isnan(min)) { return min; } @@ -935,7 +935,7 @@ double HTMLMeterAccessible::CurValue() const { double value = LeafAccessible::CurValue(); double minValue = MinValue(); - if (IsNaN(value)) { + if (std::isnan(value)) { /* If we didn't find a value from the LeafAccessible call above, check * for a value attribute */ nsAutoString attrValue; diff --git a/accessible/ipc/RemoteAccessibleBase.cpp b/accessible/ipc/RemoteAccessibleBase.cpp index 0595518f1c56..9f0ba0e21ab4 100644 --- a/accessible/ipc/RemoteAccessibleBase.cpp +++ b/accessible/ipc/RemoteAccessibleBase.cpp @@ -243,7 +243,7 @@ void RemoteAccessibleBase::Value(nsString& aValue) const { if (HasNumericValue()) { double checkValue = CurValue(); - if (!IsNaN(checkValue)) { + if (!std::isnan(checkValue)) { aValue.AppendFloat(checkValue); } return; diff --git a/accessible/mac/mozActionElements.mm b/accessible/mac/mozActionElements.mm index 09ec8978bcf6..6d8df140ac22 100644 --- a/accessible/mac/mozActionElements.mm +++ b/accessible/mac/mozActionElements.mm @@ -218,8 +218,7 @@ using namespace mozilla::a11y; double min = mGeckoAccessible->MinValue(); double max = mGeckoAccessible->MaxValue(); - if ((mozilla::IsNaN(min) || value >= min) && - (mozilla::IsNaN(max) || value <= max)) { + if ((std::isnan(min) || value >= min) && (std::isnan(max) || value <= max)) { if (LocalAccessible* acc = mGeckoAccessible->AsLocal()) { acc->SetCurValue(value); } else { diff --git a/accessible/windows/ia2/ia2AccessibleValue.cpp b/accessible/windows/ia2/ia2AccessibleValue.cpp index ed8b7a4de288..e02e938db648 100644 --- a/accessible/windows/ia2/ia2AccessibleValue.cpp +++ b/accessible/windows/ia2/ia2AccessibleValue.cpp @@ -63,7 +63,7 @@ ia2AccessibleValue::get_currentValue(VARIANT* aCurrentValue) { currentValue = valueAcc->CurValue(); - if (IsNaN(currentValue)) return S_FALSE; + if (std::isnan(currentValue)) return S_FALSE; aCurrentValue->vt = VT_R8; aCurrentValue->dblVal = currentValue; @@ -96,7 +96,7 @@ ia2AccessibleValue::get_maximumValue(VARIANT* aMaximumValue) { maximumValue = valueAcc->MaxValue(); - if (IsNaN(maximumValue)) return S_FALSE; + if (std::isnan(maximumValue)) return S_FALSE; aMaximumValue->vt = VT_R8; aMaximumValue->dblVal = maximumValue; @@ -117,7 +117,7 @@ ia2AccessibleValue::get_minimumValue(VARIANT* aMinimumValue) { minimumValue = valueAcc->MinValue(); - if (IsNaN(minimumValue)) return S_FALSE; + if (std::isnan(minimumValue)) return S_FALSE; aMinimumValue->vt = VT_R8; aMinimumValue->dblVal = minimumValue; diff --git a/accessible/xpcom/xpcAccessibleValue.cpp b/accessible/xpcom/xpcAccessibleValue.cpp index 495e84184854..b5ed31c96567 100644 --- a/accessible/xpcom/xpcAccessibleValue.cpp +++ b/accessible/xpcom/xpcAccessibleValue.cpp @@ -24,7 +24,7 @@ xpcAccessibleValue::GetMaximumValue(double* aValue) { double value = Intl()->MaxValue(); - if (!IsNaN(value)) *aValue = value; + if (!std::isnan(value)) *aValue = value; return NS_OK; } @@ -42,7 +42,7 @@ xpcAccessibleValue::GetMinimumValue(double* aValue) { double value = Intl()->MinValue(); - if (!IsNaN(value)) *aValue = value; + if (!std::isnan(value)) *aValue = value; return NS_OK; } @@ -60,7 +60,7 @@ xpcAccessibleValue::GetCurrentValue(double* aValue) { double value = Intl()->CurValue(); - if (!IsNaN(value)) *aValue = value; + if (!std::isnan(value)) *aValue = value; return NS_OK; } @@ -95,7 +95,7 @@ xpcAccessibleValue::GetMinimumIncrement(double* aValue) { double value = Intl()->Step(); - if (!IsNaN(value)) *aValue = value; + if (!std::isnan(value)) *aValue = value; return NS_OK; } diff --git a/build/clang-plugin/NaNExprChecker.cpp b/build/clang-plugin/NaNExprChecker.cpp index 6532443f23fe..bacebc915597 100644 --- a/build/clang-plugin/NaNExprChecker.cpp +++ b/build/clang-plugin/NaNExprChecker.cpp @@ -20,8 +20,6 @@ void NaNExprChecker::registerMatchers(MatchFinder *AstMatcher) { void NaNExprChecker::check(const MatchFinder::MatchResult &Result) { if (!Result.Context->getLangOpts().CPlusPlus) { - // mozilla::IsNaN is not usable in C, so there is no point in issuing these - // warnings. return; } @@ -50,7 +48,7 @@ void NaNExprChecker::check(const MatchFinder::MatchResult &Result) { "comparing a floating point value to itself for " "NaN checking can lead to incorrect results", DiagnosticIDs::Error); - diag(Expression->getBeginLoc(), "consider using mozilla::IsNaN instead", + diag(Expression->getBeginLoc(), "consider using std::isnan instead", DiagnosticIDs::Note); } } diff --git a/build/clang-plugin/tests/TestNANTestingExpr.cpp b/build/clang-plugin/tests/TestNANTestingExpr.cpp index aee453274276..9aac46d03617 100644 --- a/build/clang-plugin/tests/TestNANTestingExpr.cpp +++ b/build/clang-plugin/tests/TestNANTestingExpr.cpp @@ -12,10 +12,10 @@ void foo() { typedef double mydouble; mydouble d; double d2; - test(f == f); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using mozilla::IsNaN instead}} - test(d == d); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using mozilla::IsNaN instead}} - test(f != f); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using mozilla::IsNaN instead}} - test(d != d); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using mozilla::IsNaN instead}} + test(f == f); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using std::isnan instead}} + test(d == d); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using std::isnan instead}} + test(f != f); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using std::isnan instead}} + test(d != d); // expected-error{{comparing a floating point value to itself for NaN checking can lead to incorrect results}} expected-note{{consider using std::isnan instead}} test(f != d); test(d == (d - f)); test(f == f2); diff --git a/dom/animation/AnimationEffect.cpp b/dom/animation/AnimationEffect.cpp index 8716bbf4f7db..d13a8201edf2 100644 --- a/dom/animation/AnimationEffect.cpp +++ b/dom/animation/AnimationEffect.cpp @@ -114,7 +114,7 @@ ComputedTiming AnimationEffect::GetComputedTimingAt( result.mDuration = aTiming.Duration().ref(); } - MOZ_ASSERT(aTiming.Iterations() >= 0.0 && !IsNaN(aTiming.Iterations()), + MOZ_ASSERT(aTiming.Iterations() >= 0.0 && !std::isnan(aTiming.Iterations()), "mIterations should be nonnegative & finite, as ensured by " "ValidateIterations or CSSParser"); result.mIterations = aTiming.Iterations(); diff --git a/dom/animation/TimingParams.h b/dom/animation/TimingParams.h index 67a1dade8f4c..474563100695 100644 --- a/dom/animation/TimingParams.h +++ b/dom/animation/TimingParams.h @@ -108,7 +108,7 @@ struct TimingParams { } static void ValidateIterations(double aIterations, ErrorResult& aRv) { - if (IsNaN(aIterations)) { + if (std::isnan(aIterations)) { aRv.ThrowTypeError("Iterations must not be NaN"); return; } diff --git a/dom/bindings/PrimitiveConversions.h b/dom/bindings/PrimitiveConversions.h index 3df797e30173..f03b44aabfc3 100644 --- a/dom/bindings/PrimitiveConversions.h +++ b/dom/bindings/PrimitiveConversions.h @@ -229,7 +229,7 @@ inline bool PrimitiveConversionTraits_Clamp(JSContext* cx, static_assert(std::numeric_limits::is_integer, "This can only be applied to integers!"); - if (mozilla::IsNaN(d)) { + if (std::isnan(d)) { *retval = 0; return true; } diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index fc0e21c6d265..ff71e42e263c 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -4195,7 +4195,7 @@ TextMetrics* CanvasRenderingContext2D::DrawOrMeasureText( // According to spec, the API should return an empty array if maxWidth was // provided but is less than or equal to zero or equal to NaN. if (aMaxWidth.WasPassed() && - (aMaxWidth.Value() <= 0 || IsNaN(aMaxWidth.Value()))) { + (aMaxWidth.Value() <= 0 || std::isnan(aMaxWidth.Value()))) { textToDraw.Truncate(); } diff --git a/dom/canvas/WebGLContextUtils.cpp b/dom/canvas/WebGLContextUtils.cpp index a82ac015b33e..5fb1d9907e2d 100644 --- a/dom/canvas/WebGLContextUtils.cpp +++ b/dom/canvas/WebGLContextUtils.cpp @@ -435,7 +435,7 @@ void WebGLContext::ErrorInvalidEnumInfo(const char* const info, #ifdef DEBUG // For NaNs, etc. static bool IsCacheCorrect(float cached, float actual) { - if (IsNaN(cached)) { + if (std::isnan(cached)) { // GL is allowed to do anything it wants for NaNs, so if we're shadowing // a NaN, then whatever `actual` is might be correct. return true; diff --git a/dom/geolocation/GeolocationCoordinates.cpp b/dom/geolocation/GeolocationCoordinates.cpp index 6054b2b79ab9..e3dc41964242 100644 --- a/dom/geolocation/GeolocationCoordinates.cpp +++ b/dom/geolocation/GeolocationCoordinates.cpp @@ -47,7 +47,7 @@ JSObject* GeolocationCoordinates::WrapObject( double value; \ mCoords->Get##name(&value); \ Nullable rv; \ - if (!IsNaN(value)) { \ + if (!std::isnan(value)) { \ rv.SetValue(value); \ } \ return rv; \ diff --git a/dom/geolocation/GeolocationPosition.cpp b/dom/geolocation/GeolocationPosition.cpp index 1a984e96de99..19ca68525198 100644 --- a/dom/geolocation/GeolocationPosition.cpp +++ b/dom/geolocation/GeolocationPosition.cpp @@ -11,7 +11,6 @@ #include "mozilla/dom/GeolocationPositionBinding.h" using mozilla::EqualOrBothNaN; -using mozilla::IsNaN; // NaN() is a more convenient function name. inline double NaN() { return mozilla::UnspecifiedNaN(); } @@ -28,7 +27,7 @@ nsGeoPositionCoords::nsGeoPositionCoords(double aLat, double aLong, double aAlt, mHError((aHError >= 0) ? aHError : 0) // altitudeAccuracy without an altitude doesn't make any sense. , - mVError((aVError >= 0 && !IsNaN(aAlt)) ? aVError : NaN()) + mVError((aVError >= 0 && !std::isnan(aAlt)) ? aVError : NaN()) // If the hosting device is stationary (i.e. the value of the speed // attribute is 0), then the value of the heading attribute must be NaN // (or null). diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 72a7bb962c91..a35decb4e36b 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -1832,7 +1832,7 @@ void HTMLInputElement::SetValueAsDate(JSContext* aCx, // At this point we know we're not a file input, so we can just pass "not // system" as the caller type, since the caller type only matters in the file // input case. - if (IsNaN(milliseconds)) { + if (std::isnan(milliseconds)) { SetValue(u""_ns, CallerType::NonSystem, aRv); return; } @@ -1846,7 +1846,7 @@ void HTMLInputElement::SetValueAsDate(JSContext* aCx, double year = JS::YearFromTime(milliseconds); double month = JS::MonthFromTime(milliseconds); - if (IsNaN(year) || IsNaN(month)) { + if (std::isnan(year) || std::isnan(month)) { SetValue(u""_ns, CallerType::NonSystem, aRv); return; } diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 4f3bb333fc91..fa8491fa5a6a 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -3174,7 +3174,7 @@ void HTMLMediaElement::Seek(double aTime, SeekTarget::Type aSeekType, // synchronous errors are returned using aRv, not promise rejections. // aTime should be non-NaN. - MOZ_ASSERT(!mozilla::IsNaN(aTime)); + MOZ_ASSERT(!std::isnan(aTime)); // Seeking step1, Set the media element's show poster flag to false. // https://html.spec.whatwg.org/multipage/media.html#dom-media-seek diff --git a/dom/html/input/DateTimeInputTypes.cpp b/dom/html/input/DateTimeInputTypes.cpp index 21f01f20e42c..57e896990154 100644 --- a/dom/html/input/DateTimeInputTypes.cpp +++ b/dom/html/input/DateTimeInputTypes.cpp @@ -192,7 +192,7 @@ bool DateInputType::ConvertNumberToString(Decimal aValue, double month = JS::MonthFromTime(aValue.toDouble()); double day = JS::DayFromTime(aValue.toDouble()); - if (IsNaN(year) || IsNaN(month) || IsNaN(day)) { + if (std::isnan(year) || std::isnan(month) || std::isnan(day)) { return false; } @@ -485,7 +485,7 @@ bool DateTimeLocalInputType::ConvertNumberToString( double month = JS::MonthFromTime(aValue.toDouble()); double day = JS::DayFromTime(aValue.toDouble()); - if (IsNaN(year) || IsNaN(month) || IsNaN(day)) { + if (std::isnan(year) || std::isnan(month) || std::isnan(day)) { return false; } diff --git a/dom/indexedDB/Key.cpp b/dom/indexedDB/Key.cpp index ae9b392a5f28..8b82e70e374b 100644 --- a/dom/indexedDB/Key.cpp +++ b/dom/indexedDB/Key.cpp @@ -387,7 +387,7 @@ IDBResult Key::EncodeJSValInternal( const auto number = aVal.toNumber(); // 1. If `input` is NaN then return invalid. - if (mozilla::IsNaN(number)) { + if (std::isnan(number)) { return Err(IDBError(SpecialValues::Invalid)); } @@ -425,7 +425,7 @@ IDBResult Key::EncodeJSValInternal( } // 2. If `ms` is NaN then return invalid. - if (mozilla::IsNaN(ms)) { + if (std::isnan(ms)) { return Err(IDBError(SpecialValues::Invalid)); } diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index ebefce9d2daa..0fd1af878f94 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -1038,7 +1038,7 @@ void MediaDecoder::DurationChanged() { mDuration = mStateMachineDuration.Ref().ref().ToSeconds(); } - if (mDuration == oldDuration || IsNaN(mDuration)) { + if (mDuration == oldDuration || std::isnan(mDuration)) { return; } @@ -1194,7 +1194,7 @@ bool MediaDecoder::IsMediaSeekable() { media::TimeIntervals MediaDecoder::GetSeekable() { MOZ_ASSERT(NS_IsMainThread()); - if (IsNaN(GetDuration())) { + if (std::isnan(GetDuration())) { // We do not have a duration yet, we can't determine the seekable range. return TimeIntervals(); } diff --git a/dom/media/TimeUnits.h b/dom/media/TimeUnits.h index 3d2560b91932..171c40f2522d 100644 --- a/dom/media/TimeUnits.h +++ b/dom/media/TimeUnits.h @@ -54,7 +54,7 @@ static const int64_t NSECS_PER_S = 1000000000; class TimeUnit final { public: static TimeUnit FromSeconds(double aValue) { - MOZ_ASSERT(!IsNaN(aValue)); + MOZ_ASSERT(!std::isnan(aValue)); if (mozilla::IsInfinite(aValue)) { return aValue > 0 ? FromInfinity() : FromNegativeInfinity(); @@ -154,7 +154,7 @@ class TimeUnit final { // +/-Inf, or NaN. So do the calculation in floating point for // simplicity. double result = ToSeconds() + aOther.ToSeconds(); - return IsNaN(result) ? TimeUnit::Invalid() : FromSeconds(result); + return std::isnan(result) ? TimeUnit::Invalid() : FromSeconds(result); } return TimeUnit(mValue + aOther.mValue); } @@ -165,7 +165,7 @@ class TimeUnit final { // +/-Inf, or NaN. So do the calculation in floating point for // simplicity. double result = ToSeconds() - aOther.ToSeconds(); - return IsNaN(result) ? TimeUnit::Invalid() : FromSeconds(result); + return std::isnan(result) ? TimeUnit::Invalid() : FromSeconds(result); } MOZ_ASSERT(!IsInfinite() && !aOther.IsInfinite()); return TimeUnit(mValue - aOther.mValue); diff --git a/dom/media/mediasource/MediaSource.cpp b/dom/media/mediasource/MediaSource.cpp index 79c8d737c632..1e33013533c3 100644 --- a/dom/media/mediasource/MediaSource.cpp +++ b/dom/media/mediasource/MediaSource.cpp @@ -248,7 +248,7 @@ double MediaSource::Duration() { void MediaSource::SetDuration(double aDuration, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread()); - if (aDuration < 0 || IsNaN(aDuration)) { + if (aDuration < 0 || std::isnan(aDuration)) { nsPrintfCString error("Invalid duration value %f", aDuration); MSE_API("SetDuration(aDuration=%f, invalid value)", aDuration); aRv.ThrowTypeError(error); diff --git a/dom/media/mediasource/MediaSourceDecoder.cpp b/dom/media/mediasource/MediaSourceDecoder.cpp index e40d15267c61..a9eb43b6f218 100644 --- a/dom/media/mediasource/MediaSourceDecoder.cpp +++ b/dom/media/mediasource/MediaSourceDecoder.cpp @@ -88,7 +88,7 @@ media::TimeIntervals MediaSourceDecoder::GetSeekable() { media::TimeIntervals seekable; double duration = mMediaSource->Duration(); - if (IsNaN(duration)) { + if (std::isnan(duration)) { // Return empty range. } else if (duration > 0 && mozilla::IsInfinite(duration)) { media::TimeIntervals buffered = GetBuffered(); @@ -207,7 +207,7 @@ void MediaSourceDecoder::SetInitialDuration(int64_t aDuration) { MOZ_ASSERT(NS_IsMainThread()); // Only use the decoded duration if one wasn't already // set. - if (!mMediaSource || !IsNaN(ExplicitDuration())) { + if (!mMediaSource || !std::isnan(ExplicitDuration())) { return; } double duration = aDuration; @@ -288,7 +288,7 @@ bool MediaSourceDecoder::CanPlayThroughImpl() { return false; } - if (IsNaN(mMediaSource->Duration())) { + if (std::isnan(mMediaSource->Duration())) { // Don't have any data yet. return false; } diff --git a/dom/media/mediasource/SourceBuffer.cpp b/dom/media/mediasource/SourceBuffer.cpp index dcdd2008b26a..e0a8afd5eacb 100644 --- a/dom/media/mediasource/SourceBuffer.cpp +++ b/dom/media/mediasource/SourceBuffer.cpp @@ -160,7 +160,7 @@ void SourceBuffer::SetAppendWindowEnd(double aAppendWindowEnd, aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } - if (IsNaN(aAppendWindowEnd) || + if (std::isnan(aAppendWindowEnd) || aAppendWindowEnd <= mCurrentAttributes.GetAppendWindowStart()) { aRv.ThrowTypeError("Invalid appendWindowEnd value"); return; @@ -306,7 +306,7 @@ void SourceBuffer::PrepareRemove(double aStart, double aEnd, ErrorResult& aRv) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } - if (IsNaN(mMediaSource->Duration())) { + if (std::isnan(mMediaSource->Duration())) { aRv.ThrowTypeError("Duration is NaN"); return; } @@ -314,7 +314,7 @@ void SourceBuffer::PrepareRemove(double aStart, double aEnd, ErrorResult& aRv) { aRv.ThrowTypeError("Invalid start value"); return; } - if (aEnd <= aStart || IsNaN(aEnd)) { + if (aEnd <= aStart || std::isnan(aEnd)) { aRv.ThrowTypeError("Invalid end value"); return; } diff --git a/dom/media/webaudio/AudioBufferSourceNode.cpp b/dom/media/webaudio/AudioBufferSourceNode.cpp index d4825ee38e4d..38e2ebfa965f 100644 --- a/dom/media/webaudio/AudioBufferSourceNode.cpp +++ b/dom/media/webaudio/AudioBufferSourceNode.cpp @@ -461,7 +461,7 @@ class AudioBufferSourceNodeEngine final : public AudioNodeEngine { } else { detune = mDetuneTimeline.GetValueAtTime(aTrackPosition); } - if (playbackRate <= 0 || mozilla::IsNaN(playbackRate)) { + if (playbackRate <= 0 || std::isnan(playbackRate)) { playbackRate = 1.0f; } diff --git a/dom/media/webaudio/WebAudioUtils.h b/dom/media/webaudio/WebAudioUtils.h index cbe7e79caa12..1977cbc05ee5 100644 --- a/dom/media/webaudio/WebAudioUtils.h +++ b/dom/media/webaudio/WebAudioUtils.h @@ -77,7 +77,7 @@ inline float ConvertDecibelToLinear(float aDecibel) { } inline void FixNaN(double& aDouble) { - if (IsNaN(aDouble) || IsInfinite(aDouble)) { + if (std::isnan(aDouble) || IsInfinite(aDouble)) { aDouble = 0.0; } } @@ -161,7 +161,7 @@ IntType TruncateFloatToInt(FloatType f) { static_assert(std::is_floating_point_v == true, "FloatType must be a floating point type"); - if (mozilla::IsNaN(f)) { + if (std::isnan(f)) { // It is the responsibility of the caller to deal with NaN values. // If we ever get to this point, we have a serious bug to fix. MOZ_CRASH("We should never see a NaN here"); diff --git a/dom/media/webaudio/blink/DynamicsCompressorKernel.cpp b/dom/media/webaudio/blink/DynamicsCompressorKernel.cpp index 9dae91136ec5..8197c3023395 100644 --- a/dom/media/webaudio/blink/DynamicsCompressorKernel.cpp +++ b/dom/media/webaudio/blink/DynamicsCompressorKernel.cpp @@ -37,7 +37,6 @@ using namespace mozilla::dom; // for WebAudioUtils using mozilla::IsInfinite; -using mozilla::IsNaN; using mozilla::MakeUnique; using mozilla::PositiveInfinity; @@ -293,7 +292,7 @@ void DynamicsCompressorKernel::process( // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Fix gremlins. - if (IsNaN(m_detectorAverage)) m_detectorAverage = 1; + if (std::isnan(m_detectorAverage)) m_detectorAverage = 1; if (IsInfinite(m_detectorAverage)) m_detectorAverage = 1; float desiredGain = m_detectorAverage; @@ -327,7 +326,7 @@ void DynamicsCompressorKernel::process( m_maxAttackCompressionDiffDb = -1; // Fix gremlins. - if (IsNaN(compressionDiffDb)) compressionDiffDb = -1; + if (std::isnan(compressionDiffDb)) compressionDiffDb = -1; if (IsInfinite(compressionDiffDb)) compressionDiffDb = -1; // Adaptive release - higher compression (lower compressionDiffDb) @@ -355,7 +354,7 @@ void DynamicsCompressorKernel::process( // Attack mode - compressionDiffDb should be positive dB // Fix gremlins. - if (IsNaN(compressionDiffDb)) compressionDiffDb = 1; + if (std::isnan(compressionDiffDb)) compressionDiffDb = 1; if (IsInfinite(compressionDiffDb)) compressionDiffDb = 1; // As long as we're still in attack mode, use a rate based off @@ -427,7 +426,7 @@ void DynamicsCompressorKernel::process( detectorAverage = std::min(1.0f, detectorAverage); // Fix gremlins. - if (IsNaN(detectorAverage)) detectorAverage = 1; + if (std::isnan(detectorAverage)) detectorAverage = 1; if (IsInfinite(detectorAverage)) detectorAverage = 1; // Exponential approach to desired gain. diff --git a/dom/media/webaudio/blink/IIRFilter.cpp b/dom/media/webaudio/blink/IIRFilter.cpp index 03eb52d1706e..8eaa461bc3bf 100644 --- a/dom/media/webaudio/blink/IIRFilter.cpp +++ b/dom/media/webaudio/blink/IIRFilter.cpp @@ -108,7 +108,7 @@ void IIRFilter::process(const float* sourceP, float* destP, // Avoid introducing a stream of subnormals destP[n] = WebCore::DenormalDisabler::flushDenormalFloatToZero(yn); MOZ_ASSERT(destP[n] == 0.0 || std::fabs(destP[n]) > FLT_MIN || - mozilla::IsNaN(destP[n]), + std::isnan(destP[n]), "output should not be subnormal, but can be NaN"); } } diff --git a/dom/media/webaudio/blink/Reverb.cpp b/dom/media/webaudio/blink/Reverb.cpp index 2a4416083f8d..e52bc4a622bf 100644 --- a/dom/media/webaudio/blink/Reverb.cpp +++ b/dom/media/webaudio/blink/Reverb.cpp @@ -61,7 +61,8 @@ static float calculateNormalizationScale(const nsTArray& response, power = sqrt(power / (numberOfChannels * aLength)); // Protect against accidental overload - if (!IsFinite(power) || IsNaN(power) || power < MinPower) power = MinPower; + if (!IsFinite(power) || std::isnan(power) || power < MinPower) + power = MinPower; float scale = 1 / power; diff --git a/dom/system/linux/GeoclueLocationProvider.cpp b/dom/system/linux/GeoclueLocationProvider.cpp index 7e5006141f2e..c9f5ef5dac02 100644 --- a/dom/system/linux/GeoclueLocationProvider.cpp +++ b/dom/system/linux/GeoclueLocationProvider.cpp @@ -789,7 +789,7 @@ void GCLocProviderPriv::ConnectLocationResponse(GObject* aObject, if (speed < 0) { speed = UnspecifiedNaN(); } - if (heading < 0 || IsNaN(speed) || speed == 0) { + if (heading < 0 || std::isnan(speed) || speed == 0) { heading = UnspecifiedNaN(); } diff --git a/dom/system/linux/GpsdLocationProvider.cpp b/dom/system/linux/GpsdLocationProvider.cpp index 47810165a710..34cd23c453ea 100644 --- a/dom/system/linux/GpsdLocationProvider.cpp +++ b/dom/system/linux/GpsdLocationProvider.cpp @@ -254,31 +254,31 @@ class GpsdLocationProvider::PollRunnable final : public Runnable { # else galt = gpsData.fix.altitude; # endif - if (!IsNaN(galt)) { + if (!std::isnan(galt)) { alt = galt; } [[fallthrough]]; case MODE_2D: - if (!IsNaN(gpsData.fix.latitude)) { + if (!std::isnan(gpsData.fix.latitude)) { lat = gpsData.fix.latitude; } - if (!IsNaN(gpsData.fix.longitude)) { + if (!std::isnan(gpsData.fix.longitude)) { lon = gpsData.fix.longitude; } - if (!IsNaN(gpsData.fix.epx) && !IsNaN(gpsData.fix.epy)) { + if (!std::isnan(gpsData.fix.epx) && !std::isnan(gpsData.fix.epy)) { hError = std::max(gpsData.fix.epx, gpsData.fix.epy); - } else if (!IsNaN(gpsData.fix.epx)) { + } else if (!std::isnan(gpsData.fix.epx)) { hError = gpsData.fix.epx; - } else if (!IsNaN(gpsData.fix.epy)) { + } else if (!std::isnan(gpsData.fix.epy)) { hError = gpsData.fix.epy; } - if (!IsNaN(gpsData.fix.epv)) { + if (!std::isnan(gpsData.fix.epv)) { vError = gpsData.fix.epv; } - if (!IsNaN(gpsData.fix.track)) { + if (!std::isnan(gpsData.fix.track)) { heading = gpsData.fix.track; } - if (!IsNaN(gpsData.fix.speed)) { + if (!std::isnan(gpsData.fix.speed)) { speed = gpsData.fix.speed; } break; diff --git a/dom/xslt/base/txDouble.cpp b/dom/xslt/base/txDouble.cpp index 57b8cada487f..302218f46ce1 100644 --- a/dom/xslt/base/txDouble.cpp +++ b/dom/xslt/base/txDouble.cpp @@ -116,7 +116,7 @@ double txDouble::toDouble(const nsAString& aSrc) { void txDouble::toString(double aValue, nsAString& aDest) { // check for special cases - if (mozilla::IsNaN(aValue)) { + if (std::isnan(aValue)) { aDest.AppendLiteral("NaN"); return; } diff --git a/dom/xslt/xpath/txCoreFunctionCall.cpp b/dom/xslt/xpath/txCoreFunctionCall.cpp index 9585944e9e43..c1c4a67ebf9c 100644 --- a/dom/xslt/xpath/txCoreFunctionCall.cpp +++ b/dom/xslt/xpath/txCoreFunctionCall.cpp @@ -329,7 +329,7 @@ nsresult txCoreFunctionCall::evaluate(txIEvalContext* aContext, NS_ENSURE_SUCCESS(rv, rv); // check for NaN or +/-Inf - if (mozilla::IsNaN(start) || mozilla::IsInfinite(start) || + if (std::isnan(start) || mozilla::IsInfinite(start) || start >= src.Length() + 0.5) { aContext->recycler()->getEmptyStringResult(aResult); @@ -344,7 +344,7 @@ nsresult txCoreFunctionCall::evaluate(txIEvalContext* aContext, NS_ENSURE_SUCCESS(rv, rv); end += start; - if (mozilla::IsNaN(end) || end < 0) { + if (std::isnan(end) || end < 0) { aContext->recycler()->getEmptyStringResult(aResult); return NS_OK; diff --git a/dom/xslt/xpath/txNumberExpr.cpp b/dom/xslt/xpath/txNumberExpr.cpp index beb64188549b..b2de40dde085 100644 --- a/dom/xslt/xpath/txNumberExpr.cpp +++ b/dom/xslt/xpath/txNumberExpr.cpp @@ -38,11 +38,11 @@ nsresult txNumberExpr::evaluate(txIEvalContext* aContext, if (rightDbl == 0) { #if defined(XP_WIN) /* XXX MSVC miscompiles such that (NaN == 0) */ - if (mozilla::IsNaN(rightDbl)) + if (std::isnan(rightDbl)) result = mozilla::UnspecifiedNaN(); else #endif - if (leftDbl == 0 || mozilla::IsNaN(leftDbl)) + if (leftDbl == 0 || std::isnan(leftDbl)) result = mozilla::UnspecifiedNaN(); else if (mozilla::IsNegative(leftDbl) != mozilla::IsNegative(rightDbl)) result = mozilla::NegativeInfinity(); diff --git a/dom/xslt/xpath/txNumberResult.cpp b/dom/xslt/xpath/txNumberResult.cpp index 3a543550beb5..370a7523d8e7 100644 --- a/dom/xslt/xpath/txNumberResult.cpp +++ b/dom/xslt/xpath/txNumberResult.cpp @@ -41,7 +41,7 @@ bool NumberResult::booleanValue() { // OG+ // As per the XPath spec, the boolean value of a number is true if and only if // it is neither positive 0 nor negative 0 nor NaN - return (bool)(value != 0.0 && !mozilla::IsNaN(value)); + return (bool)(value != 0.0 && !std::isnan(value)); // OG- } //-- booleanValue diff --git a/dom/xslt/xslt/txEXSLTFunctions.cpp b/dom/xslt/xslt/txEXSLTFunctions.cpp index 07a9c5e48b24..0ddd173cf43a 100644 --- a/dom/xslt/xslt/txEXSLTFunctions.cpp +++ b/dom/xslt/xslt/txEXSLTFunctions.cpp @@ -531,7 +531,7 @@ nsresult txEXSLTFunctionCall::evaluate(txIEvalContext* aContext, nsAutoString str; txXPathNodeUtils::appendNodeValue(nodes->get(i), str); double val = txDouble::toDouble(str); - if (mozilla::IsNaN(val)) { + if (std::isnan(val)) { res = UnspecifiedNaN(); break; } @@ -568,7 +568,7 @@ nsresult txEXSLTFunctionCall::evaluate(txIEvalContext* aContext, const txXPathNode& node = nodes->get(i); txXPathNodeUtils::appendNodeValue(node, str); double val = txDouble::toDouble(str); - if (mozilla::IsNaN(val)) { + if (std::isnan(val)) { resultSet->clear(); break; } diff --git a/dom/xslt/xslt/txFormatNumberFunctionCall.cpp b/dom/xslt/xslt/txFormatNumberFunctionCall.cpp index eee810ef1649..e851db2d7ecf 100644 --- a/dom/xslt/xslt/txFormatNumberFunctionCall.cpp +++ b/dom/xslt/xslt/txFormatNumberFunctionCall.cpp @@ -83,7 +83,7 @@ nsresult txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext, } // Special cases - if (mozilla::IsNaN(value)) { + if (std::isnan(value)) { return aContext->recycler()->getStringResult(format->mNaN, aResult); } diff --git a/dom/xslt/xslt/txStylesheet.cpp b/dom/xslt/xslt/txStylesheet.cpp index 08aa532981a1..5226ef5e0811 100644 --- a/dom/xslt/xslt/txStylesheet.cpp +++ b/dom/xslt/xslt/txStylesheet.cpp @@ -373,9 +373,9 @@ nsresult txStylesheet::addTemplate(txTemplateItem* aTemplate, uint32_t unionPos = 1; // only used when unionPattern is set while (simple) { double priority = aTemplate->mPrio; - if (mozilla::IsNaN(priority)) { + if (std::isnan(priority)) { priority = simple->getDefaultPriority(); - NS_ASSERTION(!mozilla::IsNaN(priority), + NS_ASSERTION(!std::isnan(priority), "simple pattern without default priority"); } diff --git a/dom/xslt/xslt/txStylesheetCompileHandlers.cpp b/dom/xslt/xslt/txStylesheetCompileHandlers.cpp index 34bce1d293e4..ddc9f6fb381d 100644 --- a/dom/xslt/xslt/txStylesheetCompileHandlers.cpp +++ b/dom/xslt/xslt/txStylesheetCompileHandlers.cpp @@ -236,7 +236,7 @@ static nsresult getNumberAttr(txStylesheetAttr* aAttributes, int32_t aAttrCount, } aNumber = txDouble::toDouble(attr->mValue); - if (mozilla::IsNaN(aNumber) && (aRequired || !aState.fcp())) { + if (std::isnan(aNumber) && (aRequired || !aState.fcp())) { // XXX ErrorReport: number parse failure return NS_ERROR_XSLT_PARSE_FAILURE; } diff --git a/dom/xslt/xslt/txXPathResultComparator.cpp b/dom/xslt/xslt/txXPathResultComparator.cpp index be85b89e2e6d..6320a06b8e2a 100644 --- a/dom/xslt/xslt/txXPathResultComparator.cpp +++ b/dom/xslt/xslt/txXPathResultComparator.cpp @@ -163,9 +163,9 @@ int txResultNumberComparator::compareValues(txObject* aVal1, txObject* aVal2) { double dval1 = ((NumberValue*)aVal1)->mVal; double dval2 = ((NumberValue*)aVal2)->mVal; - if (mozilla::IsNaN(dval1)) return mozilla::IsNaN(dval2) ? 0 : -mAscending; + if (std::isnan(dval1)) return std::isnan(dval2) ? 0 : -mAscending; - if (mozilla::IsNaN(dval2)) return mAscending; + if (std::isnan(dval2)) return mAscending; if (dval1 == dval2) return 0; diff --git a/dom/xslt/xslt/txXSLTNumber.cpp b/dom/xslt/xslt/txXSLTNumber.cpp index f48ca5f7d518..93798c4b22fb 100644 --- a/dom/xslt/xslt/txXSLTNumber.cpp +++ b/dom/xslt/xslt/txXSLTNumber.cpp @@ -94,7 +94,7 @@ nsresult txXSLTNumber::getValueList(Expr* aValueExpr, txPattern* aCountPattern, double value = result->numberValue(); - if (mozilla::IsInfinite(value) || mozilla::IsNaN(value) || value < 0.5) { + if (mozilla::IsInfinite(value) || std::isnan(value) || value < 0.5) { txDouble::toString(value, aValueString); return NS_OK; } diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 8757fbe3b1f2..3d0408cb890d 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -6225,8 +6225,8 @@ void AsyncPanZoomController::UpdateZoomConstraints( aConstraints.mMinZoom.scale, aConstraints.mMaxZoom.scale); } - if (IsNaN(aConstraints.mMinZoom.scale) || - IsNaN(aConstraints.mMaxZoom.scale)) { + if (std::isnan(aConstraints.mMinZoom.scale) || + std::isnan(aConstraints.mMaxZoom.scale)) { NS_WARNING("APZC received zoom constraints with NaN values; dropping..."); return; } diff --git a/gfx/thebes/COLRFonts.cpp b/gfx/thebes/COLRFonts.cpp index 254e924fe7dc..fe9ba3a33f24 100644 --- a/gfx/thebes/COLRFonts.cpp +++ b/gfx/thebes/COLRFonts.cpp @@ -1646,8 +1646,8 @@ struct PaintVarRotateAroundCenter : public PaintRotateAroundCenter { static inline Matrix SkewMatrix(float aSkewX, float aSkewY) { float xy = tanf(aSkewX * float(M_PI)); float yx = tanf(aSkewY * float(M_PI)); - return IsNaN(xy) || IsNaN(yx) ? Matrix() - : Matrix(1.0, -yx, xy, 1.0, 0.0, 0.0); + return std::isnan(xy) || std::isnan(yx) ? Matrix() + : Matrix(1.0, -yx, xy, 1.0, 0.0, 0.0); } struct PaintSkew : public PaintTransformBase { diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 1f0b82ea1cb8..736d916fff7b 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -4485,7 +4485,7 @@ gfxFontStyle::gfxFontStyle(FontSlantStyle aStyle, FontWeight aWeight, allowSyntheticStyle(aAllowStyleSynthesis), allowSyntheticSmallCaps(aAllowSmallCapsSynthesis), noFallbackVariantFeatures(true) { - MOZ_ASSERT(!mozilla::IsNaN(size)); + MOZ_ASSERT(!std::isnan(size)); switch (aSizeAdjust.tag) { case FontSizeAdjust::Tag::None: @@ -4507,7 +4507,7 @@ gfxFontStyle::gfxFontStyle(FontSlantStyle aStyle, FontWeight aWeight, sizeAdjust = aSizeAdjust.AsIcHeight(); break; } - MOZ_ASSERT(!mozilla::IsNaN(sizeAdjust)); + MOZ_ASSERT(!std::isnan(sizeAdjust)); sizeAdjustBasis = uint8_t(aSizeAdjust.tag); // sizeAdjustBasis is currently a small bitfield, so let's assert that the diff --git a/intl/components/src/NumberFormat.cpp b/intl/components/src/NumberFormat.cpp index cbbf7278c94b..6575c7a032b4 100644 --- a/intl/components/src/NumberFormat.cpp +++ b/intl/components/src/NumberFormat.cpp @@ -53,7 +53,7 @@ Result NumberFormat::formatToParts( return Err(ICUError::InternalError); } - bool isNegative = !IsNaN(number) && IsNegative(number); + bool isNegative = !std::isnan(number) && IsNegative(number); return FormatResultToParts(mFormattedNumber, Some(number), isNegative, mFormatForUnit, parts); @@ -110,7 +110,7 @@ bool NumberFormat::formatInternal(double number) const { // ICU incorrectly formats NaN values with the sign bit set, as if they // were negative. Replace all NaNs with a single pattern with sign bit // unset ("positive", that is) until ICU is fixed. - if (MOZ_UNLIKELY(IsNaN(number))) { + if (MOZ_UNLIKELY(std::isnan(number))) { number = SpecificNaN(0, 1); } diff --git a/intl/components/src/NumberFormatFields.cpp b/intl/components/src/NumberFormatFields.cpp index 654d936bf300..8ce84a1a17cf 100644 --- a/intl/components/src/NumberFormatFields.cpp +++ b/intl/components/src/NumberFormatFields.cpp @@ -336,7 +336,7 @@ Maybe GetPartTypeForNumberField(UNumberFormatFields fieldName, switch (fieldName) { case UNUM_INTEGER_FIELD: if (number.isSome()) { - if (IsNaN(*number)) { + if (std::isnan(*number)) { return Some(NumberPartType::Nan); } if (!IsFinite(*number)) { diff --git a/intl/components/src/NumberRangeFormat.cpp b/intl/components/src/NumberRangeFormat.cpp index 844f633bc4c7..bf82e36c3365 100644 --- a/intl/components/src/NumberRangeFormat.cpp +++ b/intl/components/src/NumberRangeFormat.cpp @@ -73,10 +73,10 @@ bool NumberRangeFormat::formatInternal(double start, double end) const { // ICU incorrectly formats NaN values with the sign bit set, as if they // were negative. Replace all NaNs with a single pattern with sign bit // unset ("positive", that is) until ICU is fixed. - if (MOZ_UNLIKELY(IsNaN(start))) { + if (MOZ_UNLIKELY(std::isnan(start))) { start = SpecificNaN(0, 1); } - if (MOZ_UNLIKELY(IsNaN(end))) { + if (MOZ_UNLIKELY(std::isnan(end))) { end = SpecificNaN(0, 1); } diff --git a/intl/components/src/NumberRangeFormat.h b/intl/components/src/NumberRangeFormat.h index 60de8399ec4c..40bb85d6d254 100644 --- a/intl/components/src/NumberRangeFormat.h +++ b/intl/components/src/NumberRangeFormat.h @@ -130,8 +130,8 @@ class NumberRangeFormat final { return Err(ICUError::InternalError); } - bool isNegativeStart = !IsNaN(start) && IsNegative(start); - bool isNegativeEnd = !IsNaN(end) && IsNegative(end); + bool isNegativeStart = !std::isnan(start) && IsNegative(start); + bool isNegativeEnd = !std::isnan(end) && IsNegative(end); return formatResultToParts(Some(start), isNegativeStart, Some(end), isNegativeEnd, parts); diff --git a/intl/components/src/RelativeTimeFormat.cpp b/intl/components/src/RelativeTimeFormat.cpp index 8fe62d0d593a..da67f7587d5b 100644 --- a/intl/components/src/RelativeTimeFormat.cpp +++ b/intl/components/src/RelativeTimeFormat.cpp @@ -139,7 +139,7 @@ Result, ICUError> RelativeTimeFormat::formatToParts( return Err(ToICUError(status)); } - bool isNegative = !IsNaN(aNumber) && IsNegative(aNumber); + bool isNegative = !std::isnan(aNumber) && IsNegative(aNumber); // Necessary until all of intl is using Span (Bug 1709880) return FormatResultToParts(formattedValue, Nothing(), isNegative, diff --git a/js/public/Conversions.h b/js/public/Conversions.h index abe7917e70b3..a3620bbb6b61 100644 --- a/js/public/Conversions.h +++ b/js/public/Conversions.h @@ -118,7 +118,7 @@ MOZ_ALWAYS_INLINE bool ToBoolean(HandleValue v) { } if (v.isDouble()) { double d = v.toDouble(); - return !mozilla::IsNaN(d) && d != 0; + return !std::isnan(d) && d != 0; } if (v.isSymbol()) { return true; @@ -149,7 +149,7 @@ inline double ToInteger(double d) { } if (!mozilla::IsFinite(d)) { - if (mozilla::IsNaN(d)) { + if (std::isnan(d)) { return 0; } return d; diff --git a/js/public/Date.h b/js/public/Date.h index cd641a54d9f9..9f6a226b17be 100644 --- a/js/public/Date.h +++ b/js/public/Date.h @@ -29,7 +29,7 @@ * of accessor methods to the various aspects of the represented date. */ -#include "mozilla/FloatingPoint.h" // mozilla::{IsFinite,IsNaN}, mozilla::UnspecifiedNaN +#include "mozilla/FloatingPoint.h" // mozilla::{IsFinite,}, mozilla::UnspecifiedNaN #include "mozilla/MathAlgorithms.h" // mozilla::Abs #include "js/Conversions.h" // JS::ToInteger @@ -90,7 +90,7 @@ class ClippedTime { double toDouble() const { return t; } - bool isValid() const { return !mozilla::IsNaN(t); } + bool isValid() const { return !std::isnan(t); } }; // ES6 20.3.1.15. diff --git a/js/public/Value.h b/js/public/Value.h index 369bbfbf6a2e..e3579da8e99e 100644 --- a/js/public/Value.h +++ b/js/public/Value.h @@ -466,7 +466,7 @@ static MOZ_ALWAYS_INLINE double GenericNaN() { // Convert an arbitrary double to one compatible with JS::Value representation // by replacing any NaN value with a canonical one. static MOZ_ALWAYS_INLINE double CanonicalizeNaN(double d) { - if (MOZ_UNLIKELY(mozilla::IsNaN(d))) { + if (MOZ_UNLIKELY(std::isnan(d))) { return GenericNaN(); } return d; diff --git a/js/src/builtin/Array.cpp b/js/src/builtin/Array.cpp index 6223e301c4db..7b10f6aa74dd 100644 --- a/js/src/builtin/Array.cpp +++ b/js/src/builtin/Array.cpp @@ -4117,9 +4117,9 @@ static bool SearchElementDense(JSContext* cx, HandleValue val, Iter iterator, double dval = val.toNumber(); // For |includes|, two NaN values are considered equal, so we use a // different implementation for NaN. - if (Kind == SearchKind::Includes && mozilla::IsNaN(dval)) { + if (Kind == SearchKind::Includes && std::isnan(dval)) { auto cmp = [](JSContext*, const Value& element, bool* equal) { - *equal = (element.isDouble() && mozilla::IsNaN(element.toDouble())); + *equal = (element.isDouble() && std::isnan(element.toDouble())); return true; }; return iterator(cx, cmp, rval); diff --git a/js/src/builtin/AtomicsObject.cpp b/js/src/builtin/AtomicsObject.cpp index cecd89b16cdb..8a3204c376a6 100644 --- a/js/src/builtin/AtomicsObject.cpp +++ b/js/src/builtin/AtomicsObject.cpp @@ -633,7 +633,7 @@ static bool DoAtomicsWait(JSContext* cx, } // Step 7. - if (!mozilla::IsNaN(timeout_ms)) { + if (!std::isnan(timeout_ms)) { if (timeout_ms < 0) { timeout = mozilla::Some(mozilla::TimeDuration::FromSeconds(0.0)); } else if (!mozilla::IsInfinite(timeout_ms)) { diff --git a/js/src/builtin/MapObject.cpp b/js/src/builtin/MapObject.cpp index 435bc098ad41..8698fcec1af0 100644 --- a/js/src/builtin/MapObject.cpp +++ b/js/src/builtin/MapObject.cpp @@ -36,7 +36,6 @@ using namespace js; -using mozilla::IsNaN; using mozilla::NumberEqualsInt32; /*** HashableValue **********************************************************/ diff --git a/js/src/builtin/String.cpp b/js/src/builtin/String.cpp index 0e82ce541ab1..241e1adaf54f 100644 --- a/js/src/builtin/String.cpp +++ b/js/src/builtin/String.cpp @@ -67,7 +67,6 @@ using JS::SymbolCode; using mozilla::AsciiAlphanumericToNumber; using mozilla::CheckedInt; using mozilla::IsAsciiHexDigit; -using mozilla::IsNaN; using mozilla::PodCopy; using mozilla::RangedPtr; using mozilla::SIMD; @@ -2250,7 +2249,7 @@ static bool str_lastIndexOf(JSContext* cx, unsigned argc, Value* vp) { if (!ToNumber(cx, args[1], &d)) { return false; } - if (!IsNaN(d)) { + if (!std::isnan(d)) { d = JS::ToInteger(d); if (d <= 0) { start = 0; diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 1bb1c6b10846..56702c6960b9 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -2814,7 +2814,7 @@ static bool SaveStack(JSContext* cx, unsigned argc, Value* vp) { if (!ToNumber(cx, args[0], &maxDouble)) { return false; } - if (mozilla::IsNaN(maxDouble) || maxDouble < 0 || maxDouble > UINT32_MAX) { + if (std::isnan(maxDouble) || maxDouble < 0 || maxDouble > UINT32_MAX) { ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, args[0], nullptr, "not a valid maximum frame count"); return false; diff --git a/js/src/builtin/intl/NumberFormat.cpp b/js/src/builtin/intl/NumberFormat.cpp index 21b0db030e3f..0a6a10b5c7e4 100644 --- a/js/src/builtin/intl/NumberFormat.cpp +++ b/js/src/builtin/intl/NumberFormat.cpp @@ -1021,7 +1021,7 @@ static bool ToIntlMathematicalValue(JSContext* cx, MutableHandleValue value) { double number = LinearStringToNumber(str); bool exponentTooLarge = false; - if (mozilla::IsNaN(number)) { + if (std::isnan(number)) { // Set to NaN if the input can't be parsed as a number. value.setNaN(); } else if (IsNonDecimalNumber(str)) { @@ -1269,13 +1269,13 @@ bool js::intl_FormatNumberRange(JSContext* cx, unsigned argc, Value* vp) { } // PartitionNumberRangePattern, step 1. - if (start.isDouble() && mozilla::IsNaN(start.toDouble())) { + if (start.isDouble() && std::isnan(start.toDouble())) { JS_ReportErrorNumberASCII( cx, GetErrorMessage, nullptr, JSMSG_NAN_NUMBER_RANGE, "start", "NumberFormat", formatToParts ? "formatRangeToParts" : "formatRange"); return false; } - if (end.isDouble() && mozilla::IsNaN(end.toDouble())) { + if (end.isDouble() && std::isnan(end.toDouble())) { JS_ReportErrorNumberASCII( cx, GetErrorMessage, nullptr, JSMSG_NAN_NUMBER_RANGE, "end", "NumberFormat", formatToParts ? "formatRangeToParts" : "formatRange"); diff --git a/js/src/builtin/intl/PluralRules.cpp b/js/src/builtin/intl/PluralRules.cpp index b7f9d3c6ca06..480c18176532 100644 --- a/js/src/builtin/intl/PluralRules.cpp +++ b/js/src/builtin/intl/PluralRules.cpp @@ -350,13 +350,13 @@ bool js::intl_SelectPluralRuleRange(JSContext* cx, unsigned argc, Value* vp) { double y = args[2].toNumber(); // Step 5. - if (mozilla::IsNaN(x)) { + if (std::isnan(x)) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NAN_NUMBER_RANGE, "start", "PluralRules", "selectRange"); return false; } - if (mozilla::IsNaN(y)) { + if (std::isnan(y)) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NAN_NUMBER_RANGE, "end", "PluralRules", "selectRange"); diff --git a/js/src/frontend/FoldConstants.cpp b/js/src/frontend/FoldConstants.cpp index d5a466e13181..1bec3ea0a731 100644 --- a/js/src/frontend/FoldConstants.cpp +++ b/js/src/frontend/FoldConstants.cpp @@ -27,7 +27,6 @@ using namespace js::frontend; using JS::GenericNaN; using JS::ToInt32; using JS::ToUint32; -using mozilla::IsNaN; using mozilla::IsNegative; using mozilla::NegativeInfinity; using mozilla::PositiveInfinity; @@ -529,7 +528,7 @@ static Truthiness Boolish(ParseNode* pn) { switch (pn->getKind()) { case ParseNodeKind::NumberExpr: return (pn->as().value() != 0 && - !IsNaN(pn->as().value())) + !std::isnan(pn->as().value())) ? Truthy : Falsy; diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index cdd6123c2f78..1fd13f69a8e5 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -48,7 +48,6 @@ using JS::ToInt32; using mozilla::CheckedInt; using mozilla::DebugOnly; using mozilla::IsFloat32Representable; -using mozilla::IsNaN; using mozilla::IsPowerOfTwo; using mozilla::Maybe; using mozilla::NumbersAreIdentical; @@ -975,7 +974,7 @@ MConstant* MConstant::New(TempAllocator::Fallible alloc, const Value& v) { } MConstant* MConstant::NewFloat32(TempAllocator& alloc, double d) { - MOZ_ASSERT(IsNaN(d) || d == double(float(d))); + MOZ_ASSERT(std::isnan(d) || d == double(float(d))); return new (alloc) MConstant(float(d)); } @@ -1328,10 +1327,10 @@ bool MConstant::valueToBoolean(bool* res) const { *res = toInt64() != 0; return true; case MIRType::Double: - *res = !mozilla::IsNaN(toDouble()) && toDouble() != 0.0; + *res = !std::isnan(toDouble()) && toDouble() != 0.0; return true; case MIRType::Float32: - *res = !mozilla::IsNaN(toFloat32()) && toFloat32() != 0.0f; + *res = !std::isnan(toFloat32()) && toFloat32() != 0.0f; return true; case MIRType::Null: case MIRType::Undefined: @@ -3785,7 +3784,7 @@ MDefinition* MWasmTruncateToInt32::foldsTo(TempAllocator& alloc) { if (input->type() == MIRType::Double && input->isConstant()) { double d = input->toConstant()->toDouble(); - if (IsNaN(d)) { + if (std::isnan(d)) { return this; } @@ -3800,7 +3799,7 @@ MDefinition* MWasmTruncateToInt32::foldsTo(TempAllocator& alloc) { if (input->type() == MIRType::Float32 && input->isConstant()) { double f = double(input->toConstant()->toFloat32()); - if (IsNaN(f)) { + if (std::isnan(f)) { return this; } @@ -4269,7 +4268,7 @@ bool MCompare::evaluateConstantOperands(TempAllocator& alloc, bool* result) { } // Optimize comparison against NaN. - if (mozilla::IsNaN(cte)) { + if (std::isnan(cte)) { switch (jsop_) { case JSOp::Lt: case JSOp::Le: diff --git a/js/src/jit/RangeAnalysis.cpp b/js/src/jit/RangeAnalysis.cpp index 2fdcdba77563..897064ff08fe 100644 --- a/js/src/jit/RangeAnalysis.cpp +++ b/js/src/jit/RangeAnalysis.cpp @@ -37,7 +37,6 @@ using mozilla::CountLeadingZeroes32; using mozilla::ExponentComponent; using mozilla::FloorLog2; using mozilla::IsInfinite; -using mozilla::IsNaN; using mozilla::IsNegativeZero; using mozilla::NegativeInfinity; using mozilla::NumberEqualsInt32; @@ -676,7 +675,7 @@ Range::Range(const MDefinition* def) static uint16_t ExponentImpliedByDouble(double d) { // Handle the special values. - if (IsNaN(d)) { + if (std::isnan(d)) { return Range::IncludesInfinityAndNaN; } if (IsInfinite(d)) { @@ -726,8 +725,8 @@ void Range::setDouble(double l, double h) { // won't have a fractional value if the value is always beyond the point at // which double precision can't represent fractional values. uint16_t minExp = std::min(lExp, hExp); - bool includesNegative = IsNaN(l) || l < 0; - bool includesPositive = IsNaN(h) || h > 0; + bool includesNegative = std::isnan(l) || l < 0; + bool includesPositive = std::isnan(h) || h > 0; bool crossesZero = includesNegative && includesPositive; if (crossesZero || minExp < MaxTruncatableExponent) { canHaveFractionalPart_ = IncludesFractionalParts; diff --git a/js/src/jit/RangeAnalysis.h b/js/src/jit/RangeAnalysis.h index aa085130370f..a6700db318b7 100644 --- a/js/src/jit/RangeAnalysis.h +++ b/js/src/jit/RangeAnalysis.h @@ -439,7 +439,7 @@ class Range : public TempObject { // function treats negative zero as equal to zero, as >= and <= do. If the // range includes zero, it is assumed to include negative zero too. static Range* NewDoubleRange(TempAllocator& alloc, double l, double h) { - if (mozilla::IsNaN(l) && mozilla::IsNaN(h)) { + if (std::isnan(l) && std::isnan(h)) { return nullptr; } @@ -453,7 +453,7 @@ class Range : public TempObject { // makes the strictest possible range containin zero a range which // contains one value rather than two. static Range* NewDoubleSingletonRange(TempAllocator& alloc, double d) { - if (mozilla::IsNaN(d)) { + if (std::isnan(d)) { return nullptr; } diff --git a/js/src/jit/Recover.cpp b/js/src/jit/Recover.cpp index 8eab95253e63..98d5165a2036 100644 --- a/js/src/jit/Recover.cpp +++ b/js/src/jit/Recover.cpp @@ -1405,7 +1405,7 @@ RNaNToZero::RNaNToZero(CompactBufferReader& reader) {} bool RNaNToZero::recover(JSContext* cx, SnapshotIterator& iter) const { double v = iter.read().toNumber(); - if (mozilla::IsNaN(v) || mozilla::IsNegativeZero(v)) { + if (std::isnan(v) || mozilla::IsNegativeZero(v)) { v = 0.0; } diff --git a/js/src/jit/arm/Simulator-arm.cpp b/js/src/jit/arm/Simulator-arm.cpp index dc207a6e51ea..2afd6cb0de85 100644 --- a/js/src/jit/arm/Simulator-arm.cpp +++ b/js/src/jit/arm/Simulator-arm.cpp @@ -1995,7 +1995,7 @@ bool Simulator::overflowFrom(int32_t alu_out, int32_t left, int32_t right, // Support for VFP comparisons. void Simulator::compute_FPSCR_Flags(double val1, double val2) { - if (mozilla::IsNaN(val1) || mozilla::IsNaN(val2)) { + if (std::isnan(val1) || std::isnan(val2)) { n_flag_FPSCR_ = false; z_flag_FPSCR_ = false; c_flag_FPSCR_ = true; @@ -4567,7 +4567,7 @@ void Simulator::decodeVCMP(SimInstruction* instr) { // Raise exceptions for quiet NaNs if necessary. if (instr->bit(7) == 1) { - if (mozilla::IsNaN(dd_value)) { + if (std::isnan(dd_value)) { inv_op_vfp_flag_ = true; } } @@ -4582,7 +4582,7 @@ void Simulator::decodeVCMP(SimInstruction* instr) { // Raise exceptions for quiet NaNs if necessary. if (instr->bit(7) == 1) { - if (mozilla::IsNaN(fd_value)) { + if (std::isnan(fd_value)) { inv_op_vfp_flag_ = true; } } diff --git a/js/src/jit/mips32/Simulator-mips32.cpp b/js/src/jit/mips32/Simulator-mips32.cpp index 5efc0f20db9c..ed5d30eaf1f2 100644 --- a/js/src/jit/mips32/Simulator-mips32.cpp +++ b/js/src/jit/mips32/Simulator-mips32.cpp @@ -2593,32 +2593,31 @@ void Simulator::decodeTypeRegister(SimInstruction* instr) { setFpuRegisterFloat(fd_reg, sqrtf(fs_value)); break; case ff_c_un_fmt: - setFCSRBit(fcsr_cc, - mozilla::IsNaN(fs_value) || mozilla::IsNaN(ft_value)); + setFCSRBit(fcsr_cc, std::isnan(fs_value) || std::isnan(ft_value)); break; case ff_c_eq_fmt: setFCSRBit(fcsr_cc, (fs_value == ft_value)); break; case ff_c_ueq_fmt: setFCSRBit(fcsr_cc, - (fs_value == ft_value) || (mozilla::IsNaN(fs_value) || - mozilla::IsNaN(ft_value))); + (fs_value == ft_value) || + (std::isnan(fs_value) || std::isnan(ft_value))); break; case ff_c_olt_fmt: setFCSRBit(fcsr_cc, (fs_value < ft_value)); break; case ff_c_ult_fmt: setFCSRBit(fcsr_cc, - (fs_value < ft_value) || (mozilla::IsNaN(fs_value) || - mozilla::IsNaN(ft_value))); + (fs_value < ft_value) || + (std::isnan(fs_value) || std::isnan(ft_value))); break; case ff_c_ole_fmt: setFCSRBit(fcsr_cc, (fs_value <= ft_value)); break; case ff_c_ule_fmt: setFCSRBit(fcsr_cc, - (fs_value <= ft_value) || (mozilla::IsNaN(fs_value) || - mozilla::IsNaN(ft_value))); + (fs_value <= ft_value) || + (std::isnan(fs_value) || std::isnan(ft_value))); break; case ff_cvt_d_fmt: f = getFpuRegisterFloat(fs_reg); @@ -2741,8 +2740,7 @@ void Simulator::decodeTypeRegister(SimInstruction* instr) { break; case ff_c_un_fmt: dt_value = getFpuRegisterDouble(ft_reg); - setFCSRBit(fcsr_cc, - mozilla::IsNaN(ds_value) || mozilla::IsNaN(dt_value)); + setFCSRBit(fcsr_cc, std::isnan(ds_value) || std::isnan(dt_value)); break; case ff_c_eq_fmt: dt_value = getFpuRegisterDouble(ft_reg); @@ -2751,8 +2749,8 @@ void Simulator::decodeTypeRegister(SimInstruction* instr) { case ff_c_ueq_fmt: dt_value = getFpuRegisterDouble(ft_reg); setFCSRBit(fcsr_cc, - (ds_value == dt_value) || (mozilla::IsNaN(ds_value) || - mozilla::IsNaN(dt_value))); + (ds_value == dt_value) || + (std::isnan(ds_value) || std::isnan(dt_value))); break; case ff_c_olt_fmt: dt_value = getFpuRegisterDouble(ft_reg); @@ -2761,8 +2759,8 @@ void Simulator::decodeTypeRegister(SimInstruction* instr) { case ff_c_ult_fmt: dt_value = getFpuRegisterDouble(ft_reg); setFCSRBit(fcsr_cc, - (ds_value < dt_value) || (mozilla::IsNaN(ds_value) || - mozilla::IsNaN(dt_value))); + (ds_value < dt_value) || + (std::isnan(ds_value) || std::isnan(dt_value))); break; case ff_c_ole_fmt: dt_value = getFpuRegisterDouble(ft_reg); @@ -2771,8 +2769,8 @@ void Simulator::decodeTypeRegister(SimInstruction* instr) { case ff_c_ule_fmt: dt_value = getFpuRegisterDouble(ft_reg); setFCSRBit(fcsr_cc, - (ds_value <= dt_value) || (mozilla::IsNaN(ds_value) || - mozilla::IsNaN(dt_value))); + (ds_value <= dt_value) || + (std::isnan(ds_value) || std::isnan(dt_value))); break; case ff_cvt_w_fmt: // Convert double to word. // Rounding modes are not yet supported. diff --git a/js/src/jit/mips64/Simulator-mips64.cpp b/js/src/jit/mips64/Simulator-mips64.cpp index 45dd71485b7f..0cdac183652d 100644 --- a/js/src/jit/mips64/Simulator-mips64.cpp +++ b/js/src/jit/mips64/Simulator-mips64.cpp @@ -3218,32 +3218,31 @@ void Simulator::decodeTypeRegister(SimInstruction* instr) { setFpuRegisterFloat(fd_reg, sqrtf(fs_value)); break; case ff_c_un_fmt: - setFCSRBit(fcsr_cc, - mozilla::IsNaN(fs_value) || mozilla::IsNaN(ft_value)); + setFCSRBit(fcsr_cc, std::isnan(fs_value) || std::isnan(ft_value)); break; case ff_c_eq_fmt: setFCSRBit(fcsr_cc, (fs_value == ft_value)); break; case ff_c_ueq_fmt: setFCSRBit(fcsr_cc, - (fs_value == ft_value) || (mozilla::IsNaN(fs_value) || - mozilla::IsNaN(ft_value))); + (fs_value == ft_value) || + (std::isnan(fs_value) || std::isnan(ft_value))); break; case ff_c_olt_fmt: setFCSRBit(fcsr_cc, (fs_value < ft_value)); break; case ff_c_ult_fmt: setFCSRBit(fcsr_cc, - (fs_value < ft_value) || (mozilla::IsNaN(fs_value) || - mozilla::IsNaN(ft_value))); + (fs_value < ft_value) || + (std::isnan(fs_value) || std::isnan(ft_value))); break; case ff_c_ole_fmt: setFCSRBit(fcsr_cc, (fs_value <= ft_value)); break; case ff_c_ule_fmt: setFCSRBit(fcsr_cc, - (fs_value <= ft_value) || (mozilla::IsNaN(fs_value) || - mozilla::IsNaN(ft_value))); + (fs_value <= ft_value) || + (std::isnan(fs_value) || std::isnan(ft_value))); break; case ff_cvt_d_fmt: f = getFpuRegisterFloat(fs_reg); @@ -3395,32 +3394,31 @@ void Simulator::decodeTypeRegister(SimInstruction* instr) { setFpuRegisterDouble(fd_reg, sqrt(ds_value)); break; case ff_c_un_fmt: - setFCSRBit(fcsr_cc, - mozilla::IsNaN(ds_value) || mozilla::IsNaN(dt_value)); + setFCSRBit(fcsr_cc, std::isnan(ds_value) || std::isnan(dt_value)); break; case ff_c_eq_fmt: setFCSRBit(fcsr_cc, (ds_value == dt_value)); break; case ff_c_ueq_fmt: setFCSRBit(fcsr_cc, - (ds_value == dt_value) || (mozilla::IsNaN(ds_value) || - mozilla::IsNaN(dt_value))); + (ds_value == dt_value) || + (std::isnan(ds_value) || std::isnan(dt_value))); break; case ff_c_olt_fmt: setFCSRBit(fcsr_cc, (ds_value < dt_value)); break; case ff_c_ult_fmt: setFCSRBit(fcsr_cc, - (ds_value < dt_value) || (mozilla::IsNaN(ds_value) || - mozilla::IsNaN(dt_value))); + (ds_value < dt_value) || + (std::isnan(ds_value) || std::isnan(dt_value))); break; case ff_c_ole_fmt: setFCSRBit(fcsr_cc, (ds_value <= dt_value)); break; case ff_c_ule_fmt: setFCSRBit(fcsr_cc, - (ds_value <= dt_value) || (mozilla::IsNaN(ds_value) || - mozilla::IsNaN(dt_value))); + (ds_value <= dt_value) || + (std::isnan(ds_value) || std::isnan(dt_value))); break; case ff_cvt_w_fmt: // Convert double to word. // Rounding modes are not yet supported. diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp index fd4542efdd4a..979629fcd917 100644 --- a/js/src/jsdate.cpp +++ b/js/src/jsdate.cpp @@ -66,7 +66,6 @@ using mozilla::IsAsciiAlpha; using mozilla::IsAsciiDigit; using mozilla::IsAsciiLowercaseAlpha; using mozilla::IsFinite; -using mozilla::IsNaN; using mozilla::NumbersAreIdentical; using mozilla::Relaxed; @@ -714,7 +713,7 @@ static bool date_UTC(JSContext* cx, unsigned argc, Value* vp) { // Step 8. double yr = y; - if (!IsNaN(y)) { + if (!std::isnan(y)) { double yint = ToInteger(y); if (0 <= yint && yint <= 99) { yr = 1900 + yint; @@ -1920,7 +1919,7 @@ static bool date_getHours(JSContext* cx, unsigned argc, Value* vp) { // int32 or NaN after the call to fillLocalTimeSlots. Value yearSeconds = unwrapped->localSecondsIntoYear(); if (yearSeconds.isDouble()) { - MOZ_ASSERT(IsNaN(yearSeconds.toDouble())); + MOZ_ASSERT(std::isnan(yearSeconds.toDouble())); args.rval().set(yearSeconds); } else { args.rval().setInt32((yearSeconds.toInt32() / int(SecondsPerHour)) % @@ -1960,7 +1959,7 @@ static bool date_getMinutes(JSContext* cx, unsigned argc, Value* vp) { // int32 or NaN after the call to fillLocalTimeSlots. Value yearSeconds = unwrapped->localSecondsIntoYear(); if (yearSeconds.isDouble()) { - MOZ_ASSERT(IsNaN(yearSeconds.toDouble())); + MOZ_ASSERT(std::isnan(yearSeconds.toDouble())); args.rval().set(yearSeconds); } else { args.rval().setInt32((yearSeconds.toInt32() / int(SecondsPerMinute)) % @@ -2001,7 +2000,7 @@ static bool date_getSeconds(JSContext* cx, unsigned argc, Value* vp) { // int32 or NaN after the call to fillLocalTimeSlots. Value yearSeconds = unwrapped->localSecondsIntoYear(); if (yearSeconds.isDouble()) { - MOZ_ASSERT(IsNaN(yearSeconds.toDouble())); + MOZ_ASSERT(std::isnan(yearSeconds.toDouble())); args.rval().set(yearSeconds); } else { args.rval().setInt32(yearSeconds.toInt32() % int(SecondsPerMinute)); @@ -2606,7 +2605,7 @@ static bool date_setUTCMonth(JSContext* cx, unsigned argc, Value* vp) { static double ThisLocalTimeOrZero(DateTimeInfo::ShouldRFP shouldRFP, Handle dateObj) { double t = dateObj->UTCTime().toNumber(); - if (IsNaN(t)) { + if (std::isnan(t)) { return +0; } return LocalTime(shouldRFP, t); @@ -2614,7 +2613,7 @@ static double ThisLocalTimeOrZero(DateTimeInfo::ShouldRFP shouldRFP, static double ThisUTCTimeOrZero(Handle dateObj) { double t = dateObj->as().UTCTime().toNumber(); - return IsNaN(t) ? +0 : t; + return std::isnan(t) ? +0 : t; } /* ES5 15.9.5.40. */ @@ -2721,7 +2720,7 @@ static bool date_setYear(JSContext* cx, unsigned argc, Value* vp) { } /* Step 3. */ - if (IsNaN(y)) { + if (std::isnan(y)) { unwrapped->setUTCTime(ClippedTime::invalid(), args.rval()); return true; } @@ -3498,7 +3497,7 @@ static bool DateMultipleArguments(JSContext* cx, const CallArgs& args) { // Step 3o. double yr = y; - if (!IsNaN(y)) { + if (!std::isnan(y)) { double yint = ToInteger(y); if (0 <= yint && yint <= 99) { yr = 1900 + yint; @@ -3607,7 +3606,7 @@ JS_PUBLIC_API bool js::DateIsValid(JSContext* cx, HandleObject obj, return false; } - *isValid = !IsNaN(unboxed.toNumber()); + *isValid = !std::isnan(unboxed.toNumber()); return true; } diff --git a/js/src/jslibmath.h b/js/src/jslibmath.h index f7790540df60..5c6416ef36e7 100644 --- a/js/src/jslibmath.h +++ b/js/src/jslibmath.h @@ -19,7 +19,7 @@ namespace js { inline double NumberDiv(double a, double b) { AutoUnsafeCallWithABI unsafe; if (b == 0) { - if (a == 0 || mozilla::IsNaN(a)) { + if (a == 0 || std::isnan(a)) { return JS::GenericNaN(); } if (mozilla::IsNegative(a) != mozilla::IsNegative(b)) { diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp index c9e71ed296c8..5cea725de897 100644 --- a/js/src/jsmath.cpp +++ b/js/src/jsmath.cpp @@ -41,7 +41,6 @@ using mozilla::ExponentComponent; using mozilla::FloatingPoint; using mozilla::IsFinite; using mozilla::IsInfinite; -using mozilla::IsNaN; using mozilla::IsNegative; using mozilla::IsNegativeZero; using mozilla::Maybe; @@ -318,7 +317,7 @@ double js::math_max_impl(double x, double y) { AutoUnsafeCallWithABI unsafe; // Math.max(num, NaN) => NaN, Math.max(-0, +0) => +0 - if (x > y || IsNaN(x) || (x == y && IsNegative(y))) { + if (x > y || std::isnan(x) || (x == y && IsNegative(y))) { return x; } return y; @@ -343,7 +342,7 @@ double js::math_min_impl(double x, double y) { AutoUnsafeCallWithABI unsafe; // Math.min(num, NaN) => NaN, Math.min(-0, +0) => -0 - if (x < y || IsNaN(x) || (x == y && IsNegativeZero(x))) { + if (x < y || std::isnan(x) || (x == y && IsNegativeZero(x))) { return x; } return y; @@ -770,8 +769,7 @@ double js::hypot4(double x, double y, double z, double w) { return mozilla::PositiveInfinity(); } - if (mozilla::IsNaN(x) || mozilla::IsNaN(y) || mozilla::IsNaN(z) || - mozilla::IsNaN(w)) { + if (std::isnan(x) || std::isnan(y) || std::isnan(z) || std::isnan(w)) { return GenericNaN(); } @@ -827,7 +825,7 @@ bool js::math_hypot_handle(JSContext* cx, HandleValueArray args, } isInfinite |= mozilla::IsInfinite(x); - isNaN |= mozilla::IsNaN(x); + isNaN |= std::isnan(x); if (isInfinite || isNaN) { continue; } @@ -871,7 +869,7 @@ bool js::math_trunc(JSContext* cx, unsigned argc, Value* vp) { double js::math_sign_impl(double x) { AutoUnsafeCallWithABI unsafe; - if (mozilla::IsNaN(x)) { + if (std::isnan(x)) { return GenericNaN(); } diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index b229476e300b..b11975334831 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -1233,7 +1233,7 @@ static bool num_toFixed(JSContext* cx, unsigned argc, Value* vp) { } // Step 6. - if (mozilla::IsNaN(d)) { + if (std::isnan(d)) { args.rval().setString(cx->names().NaN); return true; } @@ -1305,7 +1305,7 @@ static bool num_toExponential(JSContext* cx, unsigned argc, Value* vp) { MOZ_ASSERT_IF(!args.hasDefined(0), prec == 0); // Step 4. - if (mozilla::IsNaN(d)) { + if (std::isnan(d)) { args.rval().setString(cx->names().NaN); return true; } @@ -1368,7 +1368,7 @@ static bool num_toPrecision(JSContext* cx, unsigned argc, Value* vp) { } // Step 4. - if (mozilla::IsNaN(d)) { + if (std::isnan(d)) { args.rval().setString(cx->names().NaN); return true; } diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index f14695a8a4b0..8f86b9aa80d2 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -4361,7 +4361,7 @@ static bool Sleep_fn(JSContext* cx, unsigned argc, Value* vp) { if (!ToNumber(cx, args[0], &t_secs)) { return false; } - if (mozilla::IsNaN(t_secs)) { + if (std::isnan(t_secs)) { JS_ReportErrorASCII(cx, "sleep interval is not a number"); return false; } @@ -4519,7 +4519,7 @@ static void CancelExecution(JSContext* cx) { } static bool SetTimeoutValue(JSContext* cx, double t) { - if (mozilla::IsNaN(t)) { + if (std::isnan(t)) { JS_ReportErrorASCII(cx, "timeout is not a number"); return false; } diff --git a/js/src/vm/BigIntType.cpp b/js/src/vm/BigIntType.cpp index 5059aa6833e0..f41d91939c3d 100644 --- a/js/src/vm/BigIntType.cpp +++ b/js/src/vm/BigIntType.cpp @@ -3275,7 +3275,7 @@ bool BigInt::equal(BigInt* lhs, BigInt* rhs) { } int8_t BigInt::compare(BigInt* x, double y) { - MOZ_ASSERT(!mozilla::IsNaN(y)); + MOZ_ASSERT(!std::isnan(y)); constexpr int LessThan = -1, Equal = 0, GreaterThan = 1; @@ -3406,7 +3406,7 @@ int8_t BigInt::compare(BigInt* x, double y) { } bool BigInt::equal(BigInt* lhs, double rhs) { - if (mozilla::IsNaN(rhs)) { + if (std::isnan(rhs)) { return false; } return compare(lhs, rhs) == 0; @@ -3462,14 +3462,14 @@ JS::Result BigInt::looselyEqual(JSContext* cx, HandleBigInt lhs, bool BigInt::lessThan(BigInt* x, BigInt* y) { return compare(x, y) < 0; } Maybe BigInt::lessThan(BigInt* lhs, double rhs) { - if (mozilla::IsNaN(rhs)) { + if (std::isnan(rhs)) { return Maybe(Nothing()); } return Some(compare(lhs, rhs) < 0); } Maybe BigInt::lessThan(double lhs, BigInt* rhs) { - if (mozilla::IsNaN(lhs)) { + if (std::isnan(lhs)) { return Maybe(Nothing()); } return Some(-compare(rhs, lhs) < 0); diff --git a/js/src/vm/EqualityOperations.cpp b/js/src/vm/EqualityOperations.cpp index 2fa1abb4ecdc..66438879ce9c 100644 --- a/js/src/vm/EqualityOperations.cpp +++ b/js/src/vm/EqualityOperations.cpp @@ -254,7 +254,7 @@ static inline bool IsNegativeZero(const JS::Value& v) { } static inline bool IsNaN(const JS::Value& v) { - return v.isDouble() && mozilla::IsNaN(v.toDouble()); + return v.isDouble() && std::isnan(v.toDouble()); } bool js::SameValue(JSContext* cx, JS::Handle v1, diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 168ab93a2b2d..78365fe1038b 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -1740,7 +1740,7 @@ static MOZ_ALWAYS_INLINE bool LessThanImpl(JSContext* cx, double lhsNum = lhs.toNumber(); double rhsNum = rhs.toNumber(); - if (mozilla::IsNaN(lhsNum) || mozilla::IsNaN(rhsNum)) { + if (std::isnan(lhsNum) || std::isnan(rhsNum)) { res = mozilla::Maybe(mozilla::Nothing()); return true; } diff --git a/js/src/vm/TypedArrayObject-inl.h b/js/src/vm/TypedArrayObject-inl.h index 167f5bf88b95..f7318116ab54 100644 --- a/js/src/vm/TypedArrayObject-inl.h +++ b/js/src/vm/TypedArrayObject-inl.h @@ -740,7 +740,7 @@ class ElementSpecific { } return T(d); } - if (MOZ_UNLIKELY(mozilla::IsNaN(d))) { + if (MOZ_UNLIKELY(std::isnan(d))) { return T(0); } if (TypeIDOfType::id == Scalar::Uint8Clamped) { diff --git a/js/src/wasm/AsmJS.cpp b/js/src/wasm/AsmJS.cpp index 74772b224835..e81283b17bc4 100644 --- a/js/src/wasm/AsmJS.cpp +++ b/js/src/wasm/AsmJS.cpp @@ -90,7 +90,6 @@ using mozilla::Abs; using mozilla::AsVariant; using mozilla::CeilingLog2; using mozilla::HashGeneric; -using mozilla::IsNaN; using mozilla::IsNegativeZero; using mozilla::IsPositiveZero; using mozilla::IsPowerOfTwo; @@ -2335,7 +2334,7 @@ static NumLit ExtractNumericLiteral(ModuleValidatorShared& m, ParseNode* pn) { // The syntactic checks above rule out these double values. MOZ_ASSERT(!IsNegativeZero(d)); - MOZ_ASSERT(!IsNaN(d)); + MOZ_ASSERT(!std::isnan(d)); // Although doubles can only *precisely* represent 53-bit integers, they // can *imprecisely* represent integers much bigger than an int64_t. @@ -6767,8 +6766,8 @@ static bool ValidateConstant(JSContext* cx, const AsmJSGlobal& global, } // NaN != NaN - if (IsNaN(global.constantValue())) { - if (!IsNaN(v.toNumber())) { + if (std::isnan(global.constantValue())) { + if (!std::isnan(v.toNumber())) { return LinkFail(cx, "global constant value needs to be NaN"); } } else { diff --git a/js/src/wasm/WasmBuiltins.cpp b/js/src/wasm/WasmBuiltins.cpp index cf85fb5e1a40..8f26db96bfba 100644 --- a/js/src/wasm/WasmBuiltins.cpp +++ b/js/src/wasm/WasmBuiltins.cpp @@ -54,7 +54,6 @@ using namespace jit; using namespace wasm; using mozilla::HashGeneric; -using mozilla::IsNaN; using mozilla::MakeEnumeratedRange; static const unsigned BUILTIN_THUNK_LIFO_SIZE = 64 * 1024; @@ -934,7 +933,8 @@ static int64_t UModI64(uint32_t x_hi, uint32_t x_lo, uint32_t y_hi, static int64_t TruncateDoubleToInt64(double input) { // Note: INT64_MAX is not representable in double. It is actually // INT64_MAX + 1. Therefore also sending the failure value. - if (input >= double(INT64_MAX) || input < double(INT64_MIN) || IsNaN(input)) { + if (input >= double(INT64_MAX) || input < double(INT64_MIN) || + std::isnan(input)) { return int64_t(0x8000000000000000); } return int64_t(input); @@ -943,7 +943,7 @@ static int64_t TruncateDoubleToInt64(double input) { static uint64_t TruncateDoubleToUint64(double input) { // Note: UINT64_MAX is not representable in double. It is actually // UINT64_MAX + 1. Therefore also sending the failure value. - if (input >= double(UINT64_MAX) || input <= -1.0 || IsNaN(input)) { + if (input >= double(UINT64_MAX) || input <= -1.0 || std::isnan(input)) { return int64_t(0x8000000000000000); } return uint64_t(input); @@ -955,7 +955,7 @@ static int64_t SaturatingTruncateDoubleToInt64(double input) { return int64_t(input); } // Handle NaN. - if (IsNaN(input)) { + if (std::isnan(input)) { return 0; } // Handle positive overflow. diff --git a/layout/base/MobileViewportManager.cpp b/layout/base/MobileViewportManager.cpp index 298e8ce267bb..0b37430d39c5 100644 --- a/layout/base/MobileViewportManager.cpp +++ b/layout/base/MobileViewportManager.cpp @@ -204,7 +204,7 @@ void MobileViewportManager::SetInitialViewport() { CSSToScreenScale MobileViewportManager::ClampZoom( const CSSToScreenScale& aZoom, const nsViewportInfo& aViewportInfo) const { CSSToScreenScale zoom = aZoom; - if (IsNaN(zoom.scale)) { + if (std::isnan(zoom.scale)) { NS_ERROR("Don't pass NaN to ClampZoom; check caller for 0/0 division"); zoom = CSSToScreenScale(1.0); } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 368ecd1e7a83..8f2625acbeb4 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4067,10 +4067,10 @@ already_AddRefed nsLayoutUtils::GetFontMetricsForComputedStyle( } nsFont font = styleFont->mFont; - MOZ_ASSERT(!IsNaN(float(font.size.ToCSSPixels())), + MOZ_ASSERT(!std::isnan(float(font.size.ToCSSPixels())), "Style font should never be NaN"); font.size.ScaleBy(aInflation); - if (MOZ_UNLIKELY(IsNaN(float(font.size.ToCSSPixels())))) { + if (MOZ_UNLIKELY(std::isnan(float(font.size.ToCSSPixels())))) { font.size = {0}; } font.variantWidth = aVariantWidth; diff --git a/layout/style/AnimationCommon.h b/layout/style/AnimationCommon.h index f4ab3a0d0013..0035d9221766 100644 --- a/layout/style/AnimationCommon.h +++ b/layout/style/AnimationCommon.h @@ -170,7 +170,7 @@ inline TimingParams TimingParamsFromCSSParams(float aDuration, float aDelay, float aIterationCount, dom::PlaybackDirection aDirection, dom::FillMode aFillMode) { - MOZ_ASSERT(aIterationCount >= 0.0 && !IsNaN(aIterationCount), + MOZ_ASSERT(aIterationCount >= 0.0 && !std::isnan(aIterationCount), "aIterations should be nonnegative & finite, as ensured by " "CSSParser"); diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index 114939b03a67..97740d098e57 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -46,7 +46,7 @@ nsCSSValue::nsCSSValue(float aValue, nsCSSUnit aUnit) : mUnit(aUnit) { MOZ_ASSERT(eCSSUnit_Percent <= aUnit, "not a float value"); if (eCSSUnit_Percent <= aUnit) { mValue.mFloat = aValue; - MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat)); + MOZ_ASSERT(!std::isnan(mValue.mFloat)); } else { mUnit = eCSSUnit_Null; mValue.mInt = 0; @@ -56,7 +56,7 @@ nsCSSValue::nsCSSValue(float aValue, nsCSSUnit aUnit) : mUnit(aUnit) { nsCSSValue::nsCSSValue(const nsCSSValue& aCopy) : mUnit(aCopy.mUnit) { if (eCSSUnit_Percent <= mUnit) { mValue.mFloat = aCopy.mValue.mFloat; - MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat)); + MOZ_ASSERT(!std::isnan(mValue.mFloat)); } else if (eCSSUnit_Integer <= mUnit && mUnit <= eCSSUnit_Enumerated) { mValue.mInt = aCopy.mValue.mInt; } else { @@ -148,7 +148,7 @@ void nsCSSValue::SetPercentValue(float aValue) { Reset(); mUnit = eCSSUnit_Percent; mValue.mFloat = aValue; - MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat)); + MOZ_ASSERT(!std::isnan(mValue.mFloat)); } void nsCSSValue::SetFloatValue(float aValue, nsCSSUnit aUnit) { @@ -157,6 +157,6 @@ void nsCSSValue::SetFloatValue(float aValue, nsCSSUnit aUnit) { if (IsFloatUnit(aUnit)) { mUnit = aUnit; mValue.mFloat = aValue; - MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat)); + MOZ_ASSERT(!std::isnan(mValue.mFloat)); } } diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h index db54f0a0134d..7dc4e2fa6d79 100644 --- a/layout/style/nsCSSValue.h +++ b/layout/style/nsCSSValue.h @@ -172,7 +172,7 @@ class nsCSSValue { float GetFloatValue() const { MOZ_ASSERT(eCSSUnit_Number <= mUnit, "not a float value"); - MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat)); + MOZ_ASSERT(!std::isnan(mValue.mFloat)); return mValue.mFloat; } diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 9cebc7e571a9..f548cf196314 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -3733,7 +3733,7 @@ template <> CSSCoord StyleCalcNode::ResolveToCSSPixels(CSSCoord aBasis) const { CSSCoord result = ResolveInternal(aBasis, [](CSSCoord aPercent) { return aPercent; }); - if (IsNaN(float(result))) { + if (std::isnan(float(result))) { return 0.0f; // This matches style::values::normalize } return result; diff --git a/mfbt/FloatingPoint.h b/mfbt/FloatingPoint.h index fcc62afaa292..d4128fcabf51 100644 --- a/mfbt/FloatingPoint.h +++ b/mfbt/FloatingPoint.h @@ -198,7 +198,7 @@ static MOZ_ALWAYS_INLINE bool IsFinite(T aValue) { */ template static MOZ_ALWAYS_INLINE bool IsNegative(T aValue) { - MOZ_ASSERT(!IsNaN(aValue), "NaN does not have a sign"); + MOZ_ASSERT(!std::isnan(aValue), "NaN does not have a sign"); /* The sign bit is set if the double is negative. */ typedef FloatingPoint Traits; @@ -335,7 +335,7 @@ static MOZ_ALWAYS_INLINE void SpecificNaN( BitwiseCast( (signbit ? Traits::kSignBit : 0) | Traits::kExponentBits | significand, result); - MOZ_ASSERT(IsNaN(*result)); + MOZ_ASSERT(std::isnan(*result)); } template @@ -525,8 +525,8 @@ static MOZ_ALWAYS_INLINE T UnspecifiedNaN() { template static inline bool NumbersAreIdentical(T aValue1, T aValue2) { using Bits = typename FloatingPoint::Bits; - if (IsNaN(aValue1)) { - return IsNaN(aValue2); + if (std::isnan(aValue1)) { + return std::isnan(aValue2); } return BitwiseCast(aValue1) == BitwiseCast(aValue2); } @@ -546,8 +546,8 @@ static inline bool NumbersAreBitwiseIdentical(T aValue1, T aValue2) { */ template static inline bool EqualOrBothNaN(T aValue1, T aValue2) { - if (IsNaN(aValue1)) { - return IsNaN(aValue2); + if (std::isnan(aValue1)) { + return std::isnan(aValue2); } return aValue1 == aValue2; } @@ -558,7 +558,7 @@ static inline bool EqualOrBothNaN(T aValue1, T aValue2) { */ template static inline T NaNSafeMin(T aValue1, T aValue2) { - if (IsNaN(aValue1) || IsNaN(aValue2)) { + if (std::isnan(aValue1) || std::isnan(aValue2)) { return UnspecifiedNaN(); } return std::min(aValue1, aValue2); @@ -570,7 +570,7 @@ static inline T NaNSafeMin(T aValue1, T aValue2) { */ template static inline T NaNSafeMax(T aValue1, T aValue2) { - if (IsNaN(aValue1) || IsNaN(aValue2)) { + if (std::isnan(aValue1) || std::isnan(aValue2)) { return UnspecifiedNaN(); } return std::max(aValue1, aValue2); diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 071cf27142ad..a2ce392a8edb 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -463,7 +463,7 @@ static float ParsePrefFloat(const nsCString& aString, nsresult* aError) { // Defensively avoid potential breakage caused by returning NaN into // unsuspecting code. AFAIK this should never happen as PR_strtod cannot // return NaN as currently configured. - if (mozilla::IsNaN(result)) { + if (std::isnan(result)) { MOZ_ASSERT_UNREACHABLE("PR_strtod shouldn't return NaN"); *aError = NS_ERROR_ILLEGAL_VALUE; return 0.f; diff --git a/mozglue/tests/TestBaseProfiler.cpp b/mozglue/tests/TestBaseProfiler.cpp index 6b372187ec5a..215a74a62b65 100644 --- a/mozglue/tests/TestBaseProfiler.cpp +++ b/mozglue/tests/TestBaseProfiler.cpp @@ -835,7 +835,7 @@ void TestProportionValue() { } // Invalid construction, conversion to double NaN. - MOZ_RELEASE_ASSERT(mozilla::IsNaN(ProportionValue::MakeInvalid().ToDouble())); + MOZ_RELEASE_ASSERT(std::isnan(ProportionValue::MakeInvalid().ToDouble())); using namespace mozilla::literals::ProportionValue_literals; diff --git a/xpcom/ds/nsVariant.cpp b/xpcom/ds/nsVariant.cpp index 266182779ca3..f8a40431c7ea 100644 --- a/xpcom/ds/nsVariant.cpp +++ b/xpcom/ds/nsVariant.cpp @@ -463,7 +463,7 @@ static nsresult CloneArray(uint16_t aInType, const nsIID* aInIID, #define CASE__NUMERIC_CONVERSION_DOUBLE_MIN_MAX_INT(Ctype_, min_, max_) \ case nsIDataType::VTYPE_DOUBLE: { \ double value = tempData.u.mDoubleValue; \ - if (mozilla::IsNaN(value) || value < (min_) || value > (max_)) { \ + if (std::isnan(value) || value < (min_) || value > (max_)) { \ return NS_ERROR_LOSS_OF_SIGNIFICANT_DATA; \ } \ *aResult = (Ctype_)value; \ @@ -557,7 +557,7 @@ nsresult nsDiscriminatedUnion::ConvertToBool(bool* aResult) const { return rv; } // NaN is falsy in JS, so we might as well make it false here. - if (mozilla::IsNaN(val)) { + if (std::isnan(val)) { *aResult = false; } else { *aResult = 0.0 != val; @@ -585,7 +585,7 @@ nsresult nsDiscriminatedUnion::ConvertToInt64(int64_t* aResult) const { return rv; case nsIDataType::VTYPE_DOUBLE: { double value = tempData.u.mDoubleValue; - if (mozilla::IsNaN(value)) { + if (std::isnan(value)) { return NS_ERROR_LOSS_OF_SIGNIFICANT_DATA; } // XXX should check for data loss here!