Diff
Modified: trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h (88586 => 88587)
--- trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/API/JSCallbackObjectFunctions.h 2011-06-11 02:03:00 UTC (rev 88587)
@@ -444,7 +444,7 @@
// a binary _expression_ where lhs threw an exception in its conversion to
// primitive
if (exec->hadException())
- return NaN;
+ return std::numeric_limits<double>::quiet_NaN();
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(this);
@@ -463,7 +463,7 @@
double dValue;
if (value)
- return toJS(exec, value).getNumber(dValue) ? dValue : NaN;
+ return toJS(exec, value).getNumber(dValue) ? dValue : std::numeric_limits<double>::quiet_NaN();
}
return Base::toNumber(exec);
Modified: trunk/Source/_javascript_Core/API/JSValueRef.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/API/JSValueRef.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/API/JSValueRef.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -217,7 +217,7 @@
// generated internally to _javascript_Core naturally have that representation,
// but an external NaN might not.
if (isnan(value))
- value = NaN;
+ value = std::numeric_limits<double>::quiet_NaN();
return toRef(exec, jsNumber(value));
}
@@ -276,7 +276,7 @@
if (exception)
*exception = toRef(exec, exec->exception());
exec->clearException();
- number = NaN;
+ number = std::numeric_limits<double>::quiet_NaN();
}
return number;
}
Modified: trunk/Source/_javascript_Core/ChangeLog (88586 => 88587)
--- trunk/Source/_javascript_Core/ChangeLog 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-06-11 02:03:00 UTC (rev 88587)
@@ -1,3 +1,62 @@
+2011-06-10 Gavin Barraclough <[email protected]>
+
+ Reviewed by Sam Weinig.
+
+ https://bugs.webkit.org/show_bug.cgi?id=16777
+ Eliminate JSC::NaN and JSC::Inf
+
+ There's no good reason for -K-J-S- JSC to have its own NAN and infinity constants.
+ The ones in std::numeric_limits are perfectly good.
+ Remove JSC::Inf, JSC::NaN, switch some cases of (isnan || isinf) to !isfinite.
+
+ * API/JSCallbackObjectFunctions.h:
+ (JSC::::toNumber):
+ * API/JSValueRef.cpp:
+ (JSValueMakeNumber):
+ (JSValueToNumber):
+ * _javascript_Core.exp:
+ * runtime/CachedTranscendentalFunction.h:
+ (JSC::CachedTranscendentalFunction::initialize):
+ * runtime/DateConstructor.cpp:
+ (JSC::constructDate):
+ * runtime/DateInstanceCache.h:
+ (JSC::DateInstanceData::DateInstanceData):
+ (JSC::DateInstanceCache::reset):
+ * runtime/JSCell.cpp:
+ * runtime/JSCell.h:
+ (JSC::JSCell::JSValue::getPrimitiveNumber):
+ (JSC::JSCell::JSValue::toNumber):
+ * runtime/JSGlobalData.cpp:
+ (JSC::JSGlobalData::JSGlobalData):
+ (JSC::JSGlobalData::resetDateCache):
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::reset):
+ * runtime/JSGlobalObjectFunctions.cpp:
+ (JSC::globalFuncParseInt):
+ (JSC::globalFuncIsFinite):
+ * runtime/JSNotAnObject.cpp:
+ (JSC::JSNotAnObject::toNumber):
+ * runtime/JSValue.cpp:
+ * runtime/JSValue.h:
+ * runtime/JSValueInlineMethods.h:
+ (JSC::jsNaN):
+ * runtime/MathObject.cpp:
+ (JSC::mathProtoFuncMax):
+ (JSC::mathProtoFuncMin):
+ * runtime/NumberConstructor.cpp:
+ (JSC::numberConstructorNegInfinity):
+ (JSC::numberConstructorPosInfinity):
+ * runtime/NumberPrototype.cpp:
+ (JSC::numberProtoFuncToExponential):
+ (JSC::numberProtoFuncToFixed):
+ (JSC::numberProtoFuncToPrecision):
+ (JSC::numberProtoFuncToString):
+ * runtime/UString.cpp:
+ * wtf/DecimalNumber.h:
+ (WTF::DecimalNumber::DecimalNumber):
+ * wtf/dtoa.cpp:
+ (WTF::dtoa):
+
2011-06-10 Tony Chang <[email protected]>
Reviewed by Ojan Vafai.
Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (88586 => 88587)
--- trunk/Source/_javascript_Core/_javascript_Core.exp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -148,7 +148,6 @@
__ZN3JSC12StringObject3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
__ZN3JSC12StringObject6s_infoE
__ZN3JSC12StringObjectC2EPNS_9ExecStateEPNS_9StructureERKNS_7UStringE
-__ZN3JSC12nonInlineNaNEv
__ZN3JSC13SamplingFlags4stopEv
__ZN3JSC13SamplingFlags5startEv
__ZN3JSC13SamplingFlags7s_flagsE
@@ -219,7 +218,6 @@
__ZN3JSC24createStackOverflowErrorEPNS_9ExecStateE
__ZN3JSC25evaluateInGlobalCallFrameERKNS_7UStringERNS_7JSValueEPNS_14JSGlobalObjectE
__ZN3JSC35createInterruptedExecutionExceptionEPNS_12JSGlobalDataE
-__ZN3JSC3NaNE
__ZN3JSC41constructFunctionSkippingEvalEnabledCheckEPNS_9ExecStateEPNS_14JSGlobalObjectERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
__ZN3JSC4Heap11objectCountEv
__ZN3JSC4Heap16activityCallbackEv
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (88586 => 88587)
--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2011-06-11 02:03:00 UTC (rev 88587)
@@ -43,7 +43,6 @@
??2JSGlobalObject@JSC@@SAPAXIPAVJSGlobalData@1@@Z
??8JSC@@YA_NABVUString@0@0@Z
??8WTF@@YA_NABVCString@0@0@Z
- ?NaN@JSC@@3NB
?absoluteTimeToWaitTimeoutInterval@WTF@@YAKN@Z
?activityCallback@Heap@JSC@@QAEPAVGCActivityCallback@2@XZ
?add@Identifier@JSC@@SA?AV?$PassRefPtr@VStringImpl@WTF@@@WTF@@PAVExecState@2@PBD@Z
@@ -247,7 +246,6 @@
?name@InternalFunction@JSC@@QAEABVUString@2@PAVExecState@2@@Z
?name@JSFunction@JSC@@QAEABVUString@2@PAVExecState@2@@Z
?newUninitialized@CString@WTF@@SA?AV12@IAAPAD@Z
- ?nonInlineNaN@JSC@@YANXZ
?nullptr@@3Vnullptr_t@std@@A
?number@UString@JSC@@SA?AV12@H@Z
?number@UString@JSC@@SA?AV12@I@Z
Modified: trunk/Source/_javascript_Core/runtime/CachedTranscendentalFunction.h (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/CachedTranscendentalFunction.h 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/CachedTranscendentalFunction.h 2011-06-11 02:03:00 UTC (rev 88587)
@@ -30,8 +30,6 @@
namespace JSC {
-extern const double NaN;
-
typedef double (*TranscendentalFunctionPtr)(double);
// CachedTranscendentalFunction provides a generic mechanism to cache results
@@ -76,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 = NaN;
- m_cache[x].result = NaN;
+ m_cache[x].operand = std::numeric_limits<double>::quiet_NaN();
+ m_cache[x].result = std::numeric_limits<double>::quiet_NaN();
}
}
Modified: trunk/Source/_javascript_Core/runtime/DateConstructor.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/DateConstructor.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/DateConstructor.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -126,7 +126,7 @@
|| (numArgs >= 5 && isnan(doubleArguments[4]))
|| (numArgs >= 6 && isnan(doubleArguments[5]))
|| (numArgs >= 7 && isnan(doubleArguments[6])))
- value = NaN;
+ value = std::numeric_limits<double>::quiet_NaN();
else {
GregorianDateTime t;
int year = JSC::toInt32(doubleArguments[0]);
Modified: trunk/Source/_javascript_Core/runtime/DateInstanceCache.h (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/DateInstanceCache.h 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/DateInstanceCache.h 2011-06-11 02:03:00 UTC (rev 88587)
@@ -33,8 +33,6 @@
namespace JSC {
- extern const double NaN;
-
class DateInstanceData : public RefCounted<DateInstanceData> {
public:
static PassRefPtr<DateInstanceData> create() { return adoptRef(new DateInstanceData); }
@@ -46,8 +44,8 @@
private:
DateInstanceData()
- : m_gregorianDateTimeCachedForMS(NaN)
- , m_gregorianDateTimeUTCCachedForMS(NaN)
+ : m_gregorianDateTimeCachedForMS(std::numeric_limits<double>::quiet_NaN())
+ , m_gregorianDateTimeUTCCachedForMS(std::numeric_limits<double>::quiet_NaN())
{
}
};
@@ -62,7 +60,7 @@
void reset()
{
for (size_t i = 0; i < cacheSize; ++i)
- m_cache[i].key = NaN;
+ m_cache[i].key = std::numeric_limits<double>::quiet_NaN();
}
DateInstanceData* add(double d)
Modified: trunk/Source/_javascript_Core/runtime/JSCell.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/JSCell.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/JSCell.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -30,52 +30,6 @@
namespace JSC {
-#if defined NAN && defined INFINITY
-
-extern const double NaN = NAN;
-extern const double Inf = INFINITY;
-
-#else // !(defined NAN && defined INFINITY)
-
-// The trick is to define the NaN and Inf globals with a different type than the declaration.
-// This trick works because the mangled name of the globals does not include the type, although
-// I'm not sure that's guaranteed. There could be alignment issues with this, since arrays of
-// characters don't necessarily need the same alignment doubles do, but for now it seems to work.
-// It would be good to figure out a 100% clean way that still avoids code that runs at init time.
-
-// Note, we have to use union to ensure alignment. Otherwise, NaN_Bytes can start anywhere,
-// while NaN_double has to be 4-byte aligned for 32-bits.
-// With -fstrict-aliasing enabled, unions are the only safe way to do type masquerading.
-
-static const union {
- struct {
- unsigned char NaN_Bytes[8];
- unsigned char Inf_Bytes[8];
- } bytes;
-
- struct {
- double NaN_Double;
- double Inf_Double;
- } doubles;
-
-} NaNInf = { {
-#if CPU(BIG_ENDIAN)
- { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 },
- { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
-#elif CPU(MIDDLE_ENDIAN)
- { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 },
- { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 }
-#else
- { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f },
- { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
-#endif
-} } ;
-
-extern const double NaN = NaNInf.doubles.NaN_Double;
-extern const double Inf = NaNInf.doubles.Inf_Double;
-
-#endif // !(defined NAN && defined INFINITY)
-
const ClassInfo JSCell::s_dummyCellInfo = { "DummyCell", 0, 0, 0 };
bool JSCell::getUInt32(uint32_t&) const
Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/JSCell.h 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h 2011-06-11 02:03:00 UTC (rev 88587)
@@ -294,7 +294,7 @@
return true;
}
ASSERT(isUndefined());
- number = nonInlineNaN();
+ number = std::numeric_limits<double>::quiet_NaN();
value = *this;
return true;
}
@@ -320,7 +320,7 @@
return asCell()->toNumber(exec);
if (isTrue())
return 1.0;
- return isUndefined() ? nonInlineNaN() : 0; // null and false both convert to 0.
+ return isUndefined() ? std::numeric_limits<double>::quiet_NaN() : 0; // null and false both convert to 0.
}
inline JSValue JSValue::getJSNumber()
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -187,7 +187,7 @@
, interpreter(0)
, heap(this)
, dynamicGlobalObject(0)
- , cachedUTCOffset(NaN)
+ , cachedUTCOffset(std::numeric_limits<double>::quiet_NaN())
, maxReentryDepth(threadStackType == ThreadStackTypeSmall ? MaxSmallThreadReentryDepth : MaxLargeThreadReentryDepth)
, m_regExpCache(new RegExpCache(this))
#if ENABLE(REGEXP_TRACING)
@@ -419,10 +419,10 @@
void JSGlobalData::resetDateCache()
{
- cachedUTCOffset = NaN;
+ cachedUTCOffset = std::numeric_limits<double>::quiet_NaN();
dstOffsetCache.reset();
cachedDateString = UString();
- cachedDateStringValue = NaN;
+ cachedDateStringValue = std::numeric_limits<double>::quiet_NaN();
dateInstanceCache.reset();
}
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -287,7 +287,7 @@
GlobalPropertyInfo staticGlobals[] = {
GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, this, MathObject::createStructure(exec->globalData(), m_objectPrototype.get())), DontEnum | DontDelete),
GlobalPropertyInfo(Identifier(exec, "NaN"), jsNaN(), DontEnum | DontDelete | ReadOnly),
- GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber(Inf), DontEnum | DontDelete | ReadOnly),
+ GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber(std::numeric_limits<double>::infinity()), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(Identifier(exec, "undefined"), jsUndefined(), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(Identifier(exec, "JSON"), new (exec) JSONObject(this, JSONObject::createStructure(exec->globalData(), m_objectPrototype.get())), DontEnum | DontDelete)
};
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -49,6 +49,9 @@
namespace JSC {
+#define NaN std::numeric_limits<double>::quiet_NaN()
+#define Inf std::numeric_limits<double>::infinity()
+
static JSValue encode(ExecState* exec, const char* doNotEscape)
{
UString str = exec->argument(0).toString(exec);
@@ -472,9 +475,7 @@
double d = value.asDouble();
if (isfinite(d))
return JSValue::encode(jsNumber((d > 0) ? floor(d) : ceil(d)));
- if (isnan(d) || isinf(d))
- return JSValue::encode(jsNaN());
- return JSValue::encode(jsNumber(0));
+ return JSValue::encode(jsNaN());
}
return JSValue::encode(jsNumber(parseInt(value.toString(exec), radix)));
@@ -493,7 +494,7 @@
EncodedJSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec)
{
double n = exec->argument(0).toNumber(exec);
- return JSValue::encode(jsBoolean(!isnan(n) && !isinf(n)));
+ return JSValue::encode(jsBoolean(isfinite(n)));
}
EncodedJSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec)
Modified: trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/JSNotAnObject.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -58,7 +58,7 @@
double JSNotAnObject::toNumber(ExecState* exec) const
{
ASSERT_UNUSED(exec, exec->hadException());
- return NaN;
+ return std::numeric_limits<double>::quiet_NaN();
}
UString JSNotAnObject::toString(ExecState* exec) const
Modified: trunk/Source/_javascript_Core/runtime/JSValue.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/JSValue.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/JSValue.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -180,15 +180,6 @@
return bits < 0 ? -result : result;
}
-NEVER_INLINE double nonInlineNaN()
-{
-#if OS(SYMBIAN)
- return nanval();
-#else
- return std::numeric_limits<double>::quiet_NaN();
-#endif
-}
-
bool JSValue::isValidCallee()
{
return asObject(asObject(asCell())->getAnonymousValue(0))->isGlobalObject();
Modified: trunk/Source/_javascript_Core/runtime/JSValue.h (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/JSValue.h 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/JSValue.h 2011-06-11 02:03:00 UTC (rev 88587)
@@ -34,9 +34,6 @@
namespace JSC {
- extern const double NaN;
- extern const double Inf;
-
class ExecState;
class Identifier;
class JSCell;
@@ -83,8 +80,6 @@
#endif
};
- double nonInlineNaN();
-
// This implements ToInt32, defined in ECMA-262 9.5.
int32_t toInt32(double);
Modified: trunk/Source/_javascript_Core/runtime/JSValueInlineMethods.h (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/JSValueInlineMethods.h 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/JSValueInlineMethods.h 2011-06-11 02:03:00 UTC (rev 88587)
@@ -67,7 +67,7 @@
inline JSValue jsNaN()
{
- return JSValue(nonInlineNaN());
+ return JSValue(std::numeric_limits<double>::quiet_NaN());
}
inline bool JSValue::getNumber(double& result) const
Modified: trunk/Source/_javascript_Core/runtime/MathObject.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/MathObject.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/MathObject.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -166,11 +166,11 @@
EncodedJSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec)
{
unsigned argsCount = exec->argumentCount();
- double result = -Inf;
+ double result = -std::numeric_limits<double>::infinity();
for (unsigned k = 0; k < argsCount; ++k) {
double val = exec->argument(k).toNumber(exec);
if (isnan(val)) {
- result = NaN;
+ result = std::numeric_limits<double>::quiet_NaN();
break;
}
if (val > result || (val == 0 && result == 0 && !signbit(val)))
@@ -182,11 +182,11 @@
EncodedJSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec)
{
unsigned argsCount = exec->argumentCount();
- double result = +Inf;
+ double result = +std::numeric_limits<double>::infinity();
for (unsigned k = 0; k < argsCount; ++k) {
double val = exec->argument(k).toNumber(exec);
if (isnan(val)) {
- result = NaN;
+ result = std::numeric_limits<double>::quiet_NaN();
break;
}
if (val < result || (val == 0 && result == 0 && signbit(val)))
Modified: trunk/Source/_javascript_Core/runtime/NumberConstructor.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/NumberConstructor.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/NumberConstructor.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -83,12 +83,12 @@
static JSValue numberConstructorNegInfinity(ExecState*, JSValue, const Identifier&)
{
- return jsNumber(-Inf);
+ return jsNumber(-std::numeric_limits<double>::infinity());
}
static JSValue numberConstructorPosInfinity(ExecState*, JSValue, const Identifier&)
{
- return jsNumber(Inf);
+ return jsNumber(std::numeric_limits<double>::infinity());
}
static JSValue numberConstructorMaxValue(ExecState*, JSValue, const Identifier&)
Modified: trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/NumberPrototype.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -129,7 +129,7 @@
return throwVMError(exec, createRangeError(exec, "toExponential() argument must be between 0 and 20"));
// Handle NaN and Infinity.
- if (isnan(x) || isinf(x))
+ if (!isfinite(x))
return JSValue::encode(jsString(exec, UString::number(x)));
// Round if the argument is not undefined, always format as exponential.
@@ -168,7 +168,7 @@
// The check above will return false for NaN or Infinity, these will be
// handled by numberToString.
- ASSERT(!isnan(x) && !isinf(x));
+ ASSERT(isfinite(x));
// Convert to decimal with rounding, and format as decimal.
NumberToStringBuffer buffer;
@@ -203,7 +203,7 @@
return JSValue::encode(jsString(exec, UString::number(x)));
// Handle NaN and Infinity.
- if (isnan(x) || isinf(x))
+ if (!isfinite(x))
return JSValue::encode(jsString(exec, UString::number(x)));
// Convert to decimal with rounding.
@@ -260,7 +260,7 @@
char s[2048 + 3];
const char* lastCharInString = s + sizeof(s) - 1;
double x = v.uncheckedGetNumber();
- if (isnan(x) || isinf(x))
+ if (!isfinite(x))
return JSValue::encode(jsString(exec, UString::number(x)));
bool isNegative = x < 0.0;
Modified: trunk/Source/_javascript_Core/runtime/UString.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/runtime/UString.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/runtime/UString.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -51,9 +51,6 @@
namespace JSC {
-extern const double NaN;
-extern const double Inf;
-
COMPILE_ASSERT(sizeof(UString) == sizeof(void*), UString_should_stay_small);
// Construct a string with UTF-16 data.
Modified: trunk/Source/_javascript_Core/wtf/DecimalNumber.h (88586 => 88587)
--- trunk/Source/_javascript_Core/wtf/DecimalNumber.h 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/wtf/DecimalNumber.h 2011-06-11 02:03:00 UTC (rev 88587)
@@ -40,7 +40,7 @@
public:
DecimalNumber(double d)
{
- ASSERT(!isnan(d) && !isinf(d));
+ ASSERT(isfinite(d));
dtoa(m_significand, d, m_sign, m_exponent, m_precision);
ASSERT(m_precision);
@@ -54,7 +54,7 @@
DecimalNumber(double d, RoundingSignificantFiguresType, unsigned significantFigures)
{
- ASSERT(!isnan(d) && !isinf(d));
+ ASSERT(isfinite(d));
dtoaRoundSF(m_significand, d, significantFigures, m_sign, m_exponent, m_precision);
ASSERT(significantFigures && significantFigures <= sizeof(DtoaBuffer));
@@ -68,7 +68,7 @@
DecimalNumber(double d, RoundingDecimalPlacesType, unsigned decimalPlaces)
{
- ASSERT(!isnan(d) && !isinf(d));
+ ASSERT(isfinite(d));
dtoaRoundDP(m_significand, d, decimalPlaces, m_sign, m_exponent, m_precision);
unsigned significantFigures = 1 + m_exponent + decimalPlaces;
Modified: trunk/Source/_javascript_Core/wtf/dtoa.cpp (88586 => 88587)
--- trunk/Source/_javascript_Core/wtf/dtoa.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/_javascript_Core/wtf/dtoa.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -1317,7 +1317,7 @@
// roundingNone only allowed (only sensible?) with leftright set.
ASSERT(!roundingNone || leftright);
- ASSERT(!isnan(dd) && !isinf(dd));
+ ASSERT(isfinite(dd));
int bbits, b2, b5, be, dig, i, ieps, ilim = 0, ilim0, ilim1 = 0,
j, j1, k, k0, k_check, m2, m5, s2, s5,
@@ -1811,7 +1811,7 @@
unsigned numberToString(double d, NumberToStringBuffer buffer)
{
// Handle NaN and Infinity.
- if (isnan(d) || isinf(d)) {
+ if (!isfinite(d)) {
if (isnan(d)) {
copyAsciiToUTF16(buffer, "NaN", 3);
return 3;
Modified: trunk/Source/WebCore/ChangeLog (88586 => 88587)
--- trunk/Source/WebCore/ChangeLog 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/WebCore/ChangeLog 2011-06-11 02:03:00 UTC (rev 88587)
@@ -1,3 +1,17 @@
+2011-06-10 Gavin Barraclough <[email protected]>
+
+ Reviewed by Sam Weinig.
+
+ https://bugs.webkit.org/show_bug.cgi?id=16777
+ Eliminate JSC::NaN and JSC::Inf
+
+ There's no good reason for -K-J-S- JSC to have its own NAN and infinity constants.
+ The ones in std::numeric_limits are perfectly good.
+ Remove JSC::Inf, JSC::NaN, switch some cases of (isnan || isinf) to !isfinite.
+
+ * bindings/js/JSDataViewCustom.cpp:
+ (WebCore::getDataViewMember):
+
2011-06-10 James Simonsen <[email protected]>
Reviewed by Eric Seidel.
Modified: trunk/Source/WebCore/bindings/js/JSDataViewCustom.cpp (88586 => 88587)
--- trunk/Source/WebCore/bindings/js/JSDataViewCustom.cpp 2011-06-11 01:56:26 UTC (rev 88586)
+++ trunk/Source/WebCore/bindings/js/JSDataViewCustom.cpp 2011-06-11 02:03:00 UTC (rev 88587)
@@ -89,7 +89,7 @@
case AccessDataViewMemberAsFloat32:
case AccessDataViewMemberAsFloat64: {
double value = (type == AccessDataViewMemberAsFloat32) ? imp->getFloat32(byteOffset, littleEndian, ec) : imp->getFloat64(byteOffset, littleEndian, ec);
- result = isnan(value) ? JSValue(nonInlineNaN()) : jsNumber(value);
+ result = isnan(value) ? jsNaN() : jsNumber(value);
break;
} default:
ASSERT_NOT_REACHED();