Title: [133493] trunk/Source/_javascript_Core
Revision
133493
Author
[email protected]
Date
2012-11-05 10:15:23 -0800 (Mon, 05 Nov 2012)

Log Message

Reduce the verbosity of referring to QNaN in _javascript_Core
https://bugs.webkit.org/show_bug.cgi?id=101174

Reviewed by Geoffrey Garen.

Introduces a #define QNaN in JSValue.h, and replaces all previous uses of
std::numeric_limits<double>::quiet_NaN() with QNaN.

* API/JSValueRef.cpp:
(JSValueMakeNumber):
(JSValueToNumber):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileGetByValOnFloatTypedArray):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emitFloatTypedArrayGetByVal):
* runtime/CachedTranscendentalFunction.h:
(JSC::CachedTranscendentalFunction::initialize):
* runtime/DateConstructor.cpp:
(JSC::constructDate):
* runtime/DateInstanceCache.h:
(JSC::DateInstanceData::DateInstanceData):
(JSC::DateInstanceCache::reset):
* runtime/ExceptionHelpers.cpp:
(JSC::InterruptedExecutionError::defaultValue):
(JSC::TerminatedExecutionError::defaultValue):
* runtime/JSCell.h:
(JSC::JSValue::getPrimitiveNumber):
* runtime/JSDateMath.cpp:
(JSC::parseDateFromNullTerminatedCharacters):
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
(JSC::JSGlobalData::resetDateCache):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::parseInt):
(JSC::jsStrDecimalLiteral):
(JSC::toDouble):
(JSC::jsToNumber):
(JSC::parseFloat):
* runtime/JSValue.cpp:
(JSC::JSValue::toNumberSlowCase):
* runtime/JSValue.h:
(JSC):
* runtime/JSValueInlineMethods.h:
(JSC::jsNaN):
* runtime/MathObject.cpp:
(JSC::mathProtoFuncMax):
(JSC::mathProtoFuncMin):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSValueRef.cpp (133492 => 133493)


--- trunk/Source/_javascript_Core/API/JSValueRef.cpp	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/API/JSValueRef.cpp	2012-11-05 18:15:23 UTC (rev 133493)
@@ -217,7 +217,7 @@
     // generated internally to _javascript_Core naturally have that representation,
     // but an external NaN might not.
     if (isnan(value))
-        value = std::numeric_limits<double>::quiet_NaN();
+        value = QNaN;
 
     return toRef(exec, jsNumber(value));
 }
@@ -282,7 +282,7 @@
         if (exception)
             *exception = toRef(exec, exec->exception());
         exec->clearException();
-        number = std::numeric_limits<double>::quiet_NaN();
+        number = QNaN;
     }
     return number;
 }

Modified: trunk/Source/_javascript_Core/ChangeLog (133492 => 133493)


--- trunk/Source/_javascript_Core/ChangeLog	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-11-05 18:15:23 UTC (rev 133493)
@@ -1,3 +1,53 @@
+2012-11-04  Filip Pizlo  <[email protected]>
+
+        Reduce the verbosity of referring to QNaN in _javascript_Core
+        https://bugs.webkit.org/show_bug.cgi?id=101174
+
+        Reviewed by Geoffrey Garen.
+
+        Introduces a #define QNaN in JSValue.h, and replaces all previous uses of
+        std::numeric_limits<double>::quiet_NaN() with QNaN.
+
+        * API/JSValueRef.cpp:
+        (JSValueMakeNumber):
+        (JSValueToNumber):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileGetByValOnFloatTypedArray):
+        * jit/JITPropertyAccess.cpp:
+        (JSC::JIT::emitFloatTypedArrayGetByVal):
+        * runtime/CachedTranscendentalFunction.h:
+        (JSC::CachedTranscendentalFunction::initialize):
+        * runtime/DateConstructor.cpp:
+        (JSC::constructDate):
+        * runtime/DateInstanceCache.h:
+        (JSC::DateInstanceData::DateInstanceData):
+        (JSC::DateInstanceCache::reset):
+        * runtime/ExceptionHelpers.cpp:
+        (JSC::InterruptedExecutionError::defaultValue):
+        (JSC::TerminatedExecutionError::defaultValue):
+        * runtime/JSCell.h:
+        (JSC::JSValue::getPrimitiveNumber):
+        * runtime/JSDateMath.cpp:
+        (JSC::parseDateFromNullTerminatedCharacters):
+        * runtime/JSGlobalData.cpp:
+        (JSC::JSGlobalData::JSGlobalData):
+        (JSC::JSGlobalData::resetDateCache):
+        * runtime/JSGlobalObjectFunctions.cpp:
+        (JSC::parseInt):
+        (JSC::jsStrDecimalLiteral):
+        (JSC::toDouble):
+        (JSC::jsToNumber):
+        (JSC::parseFloat):
+        * runtime/JSValue.cpp:
+        (JSC::JSValue::toNumberSlowCase):
+        * runtime/JSValue.h:
+        (JSC):
+        * runtime/JSValueInlineMethods.h:
+        (JSC::jsNaN):
+        * runtime/MathObject.cpp:
+        (JSC::mathProtoFuncMax):
+        (JSC::mathProtoFuncMin):
+
 2012-11-03  Filip Pizlo  <[email protected]>
 
         Baseline JIT should use structure watchpoints whenever possible

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (133492 => 133493)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2012-11-05 18:15:23 UTC (rev 133493)
@@ -2416,7 +2416,7 @@
     case 8: {
         m_jit.loadDouble(MacroAssembler::BaseIndex(storageReg, propertyReg, MacroAssembler::TimesEight), resultReg);
         MacroAssembler::Jump notNaN = m_jit.branchDouble(MacroAssembler::DoubleEqual, resultReg, resultReg);
-        static const double NaN = std::numeric_limits<double>::quiet_NaN();
+        static const double NaN = QNaN;
         m_jit.loadDouble(&NaN, resultReg);
         notNaN.link(&m_jit);
         break;

Modified: trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp (133492 => 133493)


--- trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp	2012-11-05 18:15:23 UTC (rev 133493)
@@ -1612,7 +1612,7 @@
     case 8: {
         loadDouble(BaseIndex(base, property, TimesEight), fpRegT0);
         Jump notNaN = branchDouble(DoubleEqual, fpRegT0, fpRegT0);
-        static const double NaN = std::numeric_limits<double>::quiet_NaN();
+        static const double NaN = QNaN;
         loadDouble(&NaN, fpRegT0);
         notNaN.link(this);
         break;

Modified: trunk/Source/_javascript_Core/runtime/CachedTranscendentalFunction.h (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/CachedTranscendentalFunction.h	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/CachedTranscendentalFunction.h	2012-11-05 18:15:23 UTC (rev 133493)
@@ -74,8 +74,8 @@
         // Lazily allocate the table, populate with NaN->NaN mapping.
         m_cache = static_cast<CacheEntry*>(fastMalloc(s_cacheSize * sizeof(CacheEntry)));
         for (unsigned x = 0; x < s_cacheSize; ++x) {
-            m_cache[x].operand = std::numeric_limits<double>::quiet_NaN();
-            m_cache[x].result = std::numeric_limits<double>::quiet_NaN();
+            m_cache[x].operand = QNaN;
+            m_cache[x].result = QNaN;
         }
     }
 

Modified: trunk/Source/_javascript_Core/runtime/DateConstructor.cpp (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/DateConstructor.cpp	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/DateConstructor.cpp	2012-11-05 18:15:23 UTC (rev 133493)
@@ -131,7 +131,7 @@
             || (numArgs >= 5 && !isfinite(doubleArguments[4]))
             || (numArgs >= 6 && !isfinite(doubleArguments[5]))
             || (numArgs >= 7 && !isfinite(doubleArguments[6])))
-            value = std::numeric_limits<double>::quiet_NaN();
+            value = QNaN;
         else {
             GregorianDateTime t;
             int year = JSC::toInt32(doubleArguments[0]);

Modified: trunk/Source/_javascript_Core/runtime/DateInstanceCache.h (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/DateInstanceCache.h	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/DateInstanceCache.h	2012-11-05 18:15:23 UTC (rev 133493)
@@ -45,8 +45,8 @@
 
     private:
         DateInstanceData()
-            : m_gregorianDateTimeCachedForMS(std::numeric_limits<double>::quiet_NaN())
-            , m_gregorianDateTimeUTCCachedForMS(std::numeric_limits<double>::quiet_NaN())
+            : m_gregorianDateTimeCachedForMS(QNaN)
+            , m_gregorianDateTimeUTCCachedForMS(QNaN)
         {
         }
     };
@@ -61,7 +61,7 @@
         void reset()
         {
             for (size_t i = 0; i < cacheSize; ++i)
-                m_cache[i].key = std::numeric_limits<double>::quiet_NaN();
+                m_cache[i].key = QNaN;
         }
         
         DateInstanceData* add(double d)

Modified: trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/ExceptionHelpers.cpp	2012-11-05 18:15:23 UTC (rev 133493)
@@ -48,7 +48,7 @@
 {
     if (hint == PreferString)
         return jsNontrivialString(exec, String(ASCIILiteral("_javascript_ execution exceeded timeout.")));
-    return JSValue(std::numeric_limits<double>::quiet_NaN());
+    return JSValue(QNaN);
 }
 
 JSObject* createInterruptedExecutionException(JSGlobalData* globalData)
@@ -75,7 +75,7 @@
 {
     if (hint == PreferString)
         return jsNontrivialString(exec, String(ASCIILiteral("_javascript_ execution terminated.")));
-    return JSValue(std::numeric_limits<double>::quiet_NaN());
+    return JSValue(QNaN);
 }
 
 JSObject* createTerminatedExecutionException(JSGlobalData* globalData)

Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/JSCell.h	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h	2012-11-05 18:15:23 UTC (rev 133493)
@@ -279,7 +279,7 @@
             return true;
         }
         ASSERT(isUndefined());
-        number = std::numeric_limits<double>::quiet_NaN();
+        number = QNaN;
         value = *this;
         return true;
     }

Modified: trunk/Source/_javascript_Core/runtime/JSDateMath.cpp (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/JSDateMath.cpp	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/JSDateMath.cpp	2012-11-05 18:15:23 UTC (rev 133493)
@@ -247,7 +247,7 @@
     int offset;
     double ms = WTF::parseDateFromNullTerminatedCharacters(dateString, haveTZ, offset);
     if (isnan(ms))
-        return std::numeric_limits<double>::quiet_NaN();
+        return QNaN;
 
     // fall back to local timezone
     if (!haveTZ) {

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp	2012-11-05 18:15:23 UTC (rev 133493)
@@ -170,7 +170,7 @@
     , sizeOfLastScratchBuffer(0)
 #endif
     , dynamicGlobalObject(0)
-    , cachedUTCOffset(std::numeric_limits<double>::quiet_NaN())
+    , cachedUTCOffset(QNaN)
     , m_enabledProfiler(0)
     , m_regExpCache(new RegExpCache(this))
 #if ENABLE(REGEXP_TRACING)
@@ -400,10 +400,10 @@
 
 void JSGlobalData::resetDateCache()
 {
-    cachedUTCOffset = std::numeric_limits<double>::quiet_NaN();
+    cachedUTCOffset = QNaN;
     dstOffsetCache.reset();
     cachedDateString = String();
-    cachedDateStringValue = std::numeric_limits<double>::quiet_NaN();
+    cachedDateStringValue = QNaN;
     dateInstanceCache.reset();
 }
 

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp	2012-11-05 18:15:23 UTC (rev 133493)
@@ -276,7 +276,7 @@
 
     // 8.a If R < 2 or R > 36, then return NaN.
     if (radix < 2 || radix > 36)
-        return std::numeric_limits<double>::quiet_NaN();
+        return QNaN;
 
     // 13. Let mathInt be the mathematical integer value that is represented by Z in radix-R notation, using the letters
     //     A-Z and a-z for digits with values 10 through 35. (However, if R is 10 and Z contains more than 20 significant
@@ -299,7 +299,7 @@
 
     // 12. If Z is empty, return NaN.
     if (!sawDigit)
-        return std::numeric_limits<double>::quiet_NaN();
+        return QNaN;
 
     // Alternate code path for certain large numbers.
     if (number >= mantissaOverflowLowerBound) {
@@ -397,7 +397,7 @@
     }
 
     // Not a number.
-    return std::numeric_limits<double>::quiet_NaN();
+    return QNaN;
 }
 
 template <typename CharType>
@@ -427,7 +427,7 @@
             break;
     }
     if (characters != endCharacters)
-        return std::numeric_limits<double>::quiet_NaN();
+        return QNaN;
     
     return number;
 }
@@ -443,7 +443,7 @@
             return c - '0';
         if (isStrWhiteSpace(c))
             return 0;
-        return std::numeric_limits<double>::quiet_NaN();
+        return QNaN;
     }
 
     if (s.is8Bit())
@@ -459,7 +459,7 @@
         UChar c = s[0];
         if (isASCIIDigit(c))
             return c - '0';
-        return std::numeric_limits<double>::quiet_NaN();
+        return QNaN;
     }
 
     if (s.is8Bit()) {
@@ -474,7 +474,7 @@
 
         // Empty string.
         if (data == end)
-            return std::numeric_limits<double>::quiet_NaN();
+            return QNaN;
 
         return jsStrDecimalLiteral(data, end);
     }
@@ -490,7 +490,7 @@
 
     // Empty string.
     if (data == end)
-        return std::numeric_limits<double>::quiet_NaN();
+        return QNaN;
 
     return jsStrDecimalLiteral(data, end);
 }

Modified: trunk/Source/_javascript_Core/runtime/JSValue.cpp (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/JSValue.cpp	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/JSValue.cpp	2012-11-05 18:15:23 UTC (rev 133493)
@@ -62,7 +62,7 @@
         return asCell()->toNumber(exec);
     if (isTrue())
         return 1.0;
-    return isUndefined() ? std::numeric_limits<double>::quiet_NaN() : 0; // null and false both convert to 0.
+    return isUndefined() ? QNaN : 0; // null and false both convert to 0.
 }
 
 JSObject* JSValue::toObjectSlowCase(ExecState* exec, JSGlobalObject* globalObject) const

Modified: trunk/Source/_javascript_Core/runtime/JSValue.h (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/JSValue.h	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/JSValue.h	2012-11-05 18:15:23 UTC (rev 133493)
@@ -35,6 +35,10 @@
 
 namespace JSC {
 
+// This is used a lot throughout _javascript_Core for everything from value boxing to marking
+// values as being missing, so it is useful to have it abbreviated.
+#define QNaN (std::numeric_limits<double>::quiet_NaN())
+
     class ExecState;
     class JSCell;
     class JSGlobalData;

Modified: trunk/Source/_javascript_Core/runtime/JSValueInlineMethods.h (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/JSValueInlineMethods.h	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/JSValueInlineMethods.h	2012-11-05 18:15:23 UTC (rev 133493)
@@ -62,7 +62,7 @@
 
     inline JSValue jsNaN()
     {
-        return JSValue(std::numeric_limits<double>::quiet_NaN());
+        return JSValue(QNaN);
     }
 
     inline JSValue::JSValue(char i)

Modified: trunk/Source/_javascript_Core/runtime/MathObject.cpp (133492 => 133493)


--- trunk/Source/_javascript_Core/runtime/MathObject.cpp	2012-11-05 18:06:23 UTC (rev 133492)
+++ trunk/Source/_javascript_Core/runtime/MathObject.cpp	2012-11-05 18:15:23 UTC (rev 133493)
@@ -175,7 +175,7 @@
     for (unsigned k = 0; k < argsCount; ++k) {
         double val = exec->argument(k).toNumber(exec);
         if (isnan(val)) {
-            result = std::numeric_limits<double>::quiet_NaN();
+            result = QNaN;
             break;
         }
         if (val > result || (val == 0 && result == 0 && !signbit(val)))
@@ -191,7 +191,7 @@
     for (unsigned k = 0; k < argsCount; ++k) {
         double val = exec->argument(k).toNumber(exec);
         if (isnan(val)) {
-            result = std::numeric_limits<double>::quiet_NaN();
+            result = QNaN;
             break;
         }
         if (val < result || (val == 0 && result == 0 && signbit(val)))
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to