Bug 720941 - Remove JSDOUBLE_COMPARE (and DOUBLE_COMPARE, outside SpiderMonkey), as tinderbox's Windows compilers seem not to need it any more. r=dmandelin
authorJeff Walden <jwalden@mit.edu>
Mon, 23 Jan 2012 11:52:28 -0800
changeset 86626 c1321dc798b7c7d14678ab156a9d9aa19a010e1c
parent 86625 92da4726d122354f6f82ae2510aa23e0ad83b31d
child 86627 051a19214251af08890cfabc6f3197eb625e9162
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmandelin
bugs720941
milestone12.0a1
Bug 720941 - Remove JSDOUBLE_COMPARE (and DOUBLE_COMPARE, outside SpiderMonkey), as tinderbox's Windows compilers seem not to need it any more. r=dmandelin
content/base/public/nsContentUtils.h
content/xslt/src/xpath/txRelationalExpr.cpp
js/src/jsinterp.cpp
js/src/jsnum.h
js/src/jsxml.cpp
js/src/methodjit/StubCalls.cpp
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -2119,23 +2119,16 @@ public:
 #ifdef IS_BIG_ENDIAN
 #define DOUBLE_NaN {{DOUBLE_HI32_EXPMASK | DOUBLE_HI32_MANTMASK,   \
                         0xffffffff}}
 #else
 #define DOUBLE_NaN {{0xffffffff,                                         \
                         DOUBLE_HI32_EXPMASK | DOUBLE_HI32_MANTMASK}}
 #endif
 
-#if defined(XP_WIN)
-#define DOUBLE_COMPARE(LVAL, OP, RVAL)                                  \
-    (!DOUBLE_IS_NaN(LVAL) && !DOUBLE_IS_NaN(RVAL) && (LVAL) OP (RVAL))
-#else
-#define DOUBLE_COMPARE(LVAL, OP, RVAL) ((LVAL) OP (RVAL))
-#endif
-
 /*
  * In the following helper macros we exploit the fact that the result of a
  * series of additions will not be finite if any one of the operands in the
  * series is not finite.
  */
 #define NS_ENSURE_FINITE(f, rv)                                               \
   if (!NS_finite(f)) {                                                        \
     return (rv);                                                              \
--- a/content/xslt/src/xpath/txRelationalExpr.cpp
+++ b/content/xslt/src/xpath/txRelationalExpr.cpp
@@ -114,17 +114,17 @@ RelationalExpr::compareResults(txIEvalCo
             result = aLeft->booleanValue() == aRight->booleanValue();
         }
 
         // If either is a number, compare as numbers.
         else if (ltype == txAExprResult::NUMBER ||
                  rtype == txAExprResult::NUMBER) {
             double lval = aLeft->numberValue();
             double rval = aRight->numberValue();
-            result = DOUBLE_COMPARE(lval, ==, rval);
+            result = (lval == rval);
         }
 
         // Otherwise compare as strings. Try to use the stringobject in
         // StringResult if possible since that is a common case.
         else if ((lString = aLeft->stringValuePointer())) {
             if ((rString = aRight->stringValuePointer())) {
                 result = lString->Equals(*rString);
             }
@@ -149,29 +149,29 @@ RelationalExpr::compareResults(txIEvalCo
         return mOp == EQUAL ? result : !result;
     }
 
     double leftDbl = aLeft->numberValue();
     double rightDbl = aRight->numberValue();
     switch (mOp) {
         case LESS_THAN:
         {
-            return DOUBLE_COMPARE(leftDbl, <, rightDbl);
+            return (leftDbl < rightDbl);
         }
         case LESS_OR_EQUAL:
         {
-            return DOUBLE_COMPARE(leftDbl, <=, rightDbl);
+            return (leftDbl <= rightDbl);
         }
         case GREATER_THAN:
         {
-            return DOUBLE_COMPARE(leftDbl, >, rightDbl);
+            return (leftDbl > rightDbl);
         }
         case GREATER_OR_EQUAL:
         {
-            return DOUBLE_COMPARE(leftDbl, >=, rightDbl);
+            return (leftDbl >= rightDbl);
         }
         default:
         {
             NS_NOTREACHED("We should have caught all cases");
         }
     }
 
     return false;
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -819,17 +819,17 @@ js::LooselyEqual(JSContext *cx, const Va
         if (lval.isString()) {
             JSString *l = lval.toString();
             JSString *r = rval.toString();
             return EqualStrings(cx, l, r, result);
         }
 
         if (lval.isDouble()) {
             double l = lval.toDouble(), r = rval.toDouble();
-            *result = JSDOUBLE_COMPARE(l, ==, r, false);
+            *result = (l == r);
             return true;
         }
 
         if (lval.isObject()) {
             JSObject *l = &lval.toObject();
             JSObject *r = &rval.toObject();
 
             if (JSEqualityOp eq = l->getClass()->ext.equality) {
@@ -870,29 +870,29 @@ js::LooselyEqual(JSContext *cx, const Va
         JSString *l = lvalue.toString();
         JSString *r = rvalue.toString();
         return EqualStrings(cx, l, r, result);
     }
 
     double l, r;
     if (!ToNumber(cx, lvalue, &l) || !ToNumber(cx, rvalue, &r))
         return false;
-    *result = JSDOUBLE_COMPARE(l, ==, r, false);
+    *result = (l == r);
     return true;
 }
 
 bool
 js::StrictlyEqual(JSContext *cx, const Value &lref, const Value &rref, bool *equal)
 {
     Value lval = lref, rval = rref;
     if (SameType(lval, rval)) {
         if (lval.isString())
             return EqualStrings(cx, lval.toString(), rval.toString(), equal);
         if (lval.isDouble()) {
-            *equal = JSDOUBLE_COMPARE(lval.toDouble(), ==, rval.toDouble(), JS_FALSE);
+            *equal = (lval.toDouble() == rval.toDouble());
             return true;
         }
         if (lval.isObject()) {
             *equal = lval.toObject() == rval.toObject();
             return true;
         }
         if (lval.isUndefined()) {
             *equal = true;
@@ -900,23 +900,23 @@ js::StrictlyEqual(JSContext *cx, const V
         }
         *equal = lval.payloadAsRawUint32() == rval.payloadAsRawUint32();
         return true;
     }
 
     if (lval.isDouble() && rval.isInt32()) {
         double ld = lval.toDouble();
         double rd = rval.toInt32();
-        *equal = JSDOUBLE_COMPARE(ld, ==, rd, JS_FALSE);
+        *equal = (ld == rd);
         return true;
     }
     if (lval.isInt32() && rval.isDouble()) {
         double ld = lval.toInt32();
         double rd = rval.toDouble();
-        *equal = JSDOUBLE_COMPARE(ld, ==, rd, JS_FALSE);
+        *equal = (ld == rd);
         return true;
     }
 
     *equal = false;
     return true;
 }
 
 static inline bool
@@ -2320,17 +2320,17 @@ END_CASE(JSOP_CASE)
                 int32_t result;                                               \
                 if (!CompareStrings(cx, l, r, &result))                       \
                     goto error;                                               \
                 cond = result OP 0;                                           \
             } else {                                                          \
                 double l, r;                                                  \
                 if (!ToNumber(cx, lval, &l) || !ToNumber(cx, rval, &r))       \
                     goto error;                                               \
-                cond = JSDOUBLE_COMPARE(l, OP, r, false);                     \
+                cond = (l OP r);                                              \
             }                                                                 \
         }                                                                     \
         TRY_BRANCH_AFTER_COND(cond, 2);                                       \
         regs.sp[-2].setBoolean(cond);                                         \
         regs.sp--;                                                            \
     JS_END_MACRO
 
 BEGIN_CASE(JSOP_LT)
--- a/js/src/jsnum.h
+++ b/js/src/jsnum.h
@@ -124,25 +124,16 @@ JSDOUBLE_IS_NEG(jsdouble d)
 static inline uint32_t
 JS_HASH_DOUBLE(jsdouble d)
 {
     jsdpun u;
     u.d = d;
     return u.s.lo ^ u.s.hi;
 }
 
-#if defined(XP_WIN)
-#define JSDOUBLE_COMPARE(LVAL, OP, RVAL, IFNAN)                               \
-    ((JSDOUBLE_IS_NaN(LVAL) || JSDOUBLE_IS_NaN(RVAL))                         \
-     ? (IFNAN)                                                                \
-     : (LVAL) OP (RVAL))
-#else
-#define JSDOUBLE_COMPARE(LVAL, OP, RVAL, IFNAN) ((LVAL) OP (RVAL))
-#endif
-
 extern jsdouble js_NaN;
 extern jsdouble js_PositiveInfinity;
 extern jsdouble js_NegativeInfinity;
 
 namespace js {
 
 extern bool
 InitRuntimeNumberState(JSRuntime *rt);
--- a/js/src/jsxml.cpp
+++ b/js/src/jsxml.cpp
@@ -5310,17 +5310,17 @@ js_TestXMLEquality(JSContext *cx, const 
                     ok = EqualStrings(cx, str, JSVAL_TO_STRING(v), &equal);
                     if (ok)
                         *bp = equal;
                 } else {
                     ok = JS_ValueToNumber(cx, STRING_TO_JSVAL(str), &d);
                     if (ok) {
                         d2 = JSVAL_IS_INT(v) ? JSVAL_TO_INT(v)
                                              : JSVAL_TO_DOUBLE(v);
-                        *bp = JSDOUBLE_COMPARE(d, ==, d2, JS_FALSE);
+                        *bp = (d == d2);
                     }
                 }
             } else {
                 *bp = JS_FALSE;
             }
             js_LeaveLocalRootScope(cx);
         }
     }
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -520,17 +520,17 @@ template void JS_FASTCALL stubs::DefFun<
             int32_t cmp;                                                      \
             if (!CompareStrings(cx, l, r, &cmp))                              \
                 THROWV(JS_FALSE);                                             \
             cond = cmp OP 0;                                                  \
         } else {                                                              \
             double l, r;                                                      \
             if (!ToNumber(cx, lval, &l) || !ToNumber(cx, rval, &r))           \
                 THROWV(JS_FALSE);                                             \
-            cond = JSDOUBLE_COMPARE(l, OP, r, false);                         \
+            cond = (l OP r);                                                  \
         }                                                                     \
         regs.sp[-2].setBoolean(cond);                                         \
         return cond;                                                          \
     JS_END_MACRO
 
 JSBool JS_FASTCALL
 stubs::LessThan(VMFrame &f)
 {
@@ -563,17 +563,17 @@ stubs::ValueToBoolean(VMFrame &f)
 
 void JS_FASTCALL
 stubs::Not(VMFrame &f)
 {
     JSBool b = !js_ValueToBoolean(f.regs.sp[-1]);
     f.regs.sp[-1].setBoolean(b);
 }
 
-template <bool EQ, bool IFNAN>
+template <bool EQ>
 static inline bool
 StubEqualityOp(VMFrame &f)
 {
     JSContext *cx = f.cx;
     FrameRegs &regs = f.regs;
 
     Value rval = regs.sp[-1];
     Value lval = regs.sp[-2];
@@ -601,19 +601,19 @@ StubEqualityOp(VMFrame &f)
 #endif
 
     if (SameType(lval, rval)) {
         JS_ASSERT(!lval.isString());    /* this case is handled above */
         if (lval.isDouble()) {
             double l = lval.toDouble();
             double r = rval.toDouble();
             if (EQ)
-                cond = JSDOUBLE_COMPARE(l, ==, r, IFNAN);
+                cond = (l == r);
             else
-                cond = JSDOUBLE_COMPARE(l, !=, r, IFNAN);
+                cond = (l != r);
         } else if (lval.isObject()) {
             JSObject *l = &lval.toObject(), *r = &rval.toObject();
             if (JSEqualityOp eq = l->getClass()->ext.equality) {
                 JSBool equal;
                 if (!eq(cx, l, &rval, &equal))
                     return false;
                 cond = !!equal == EQ;
             } else {
@@ -647,39 +647,39 @@ StubEqualityOp(VMFrame &f)
                     return false;
                 cond = equal == EQ;
             } else {
                 double l, r;
                 if (!ToNumber(cx, lval, &l) || !ToNumber(cx, rval, &r))
                     return false;
 
                 if (EQ)
-                    cond = JSDOUBLE_COMPARE(l, ==, r, false);
+                    cond = (l == r);
                 else
-                    cond = JSDOUBLE_COMPARE(l, !=, r, true);
+                    cond = (l != r);
             }
         }
     }
 
     regs.sp[-2].setBoolean(cond);
     return true;
 }
 
 JSBool JS_FASTCALL
 stubs::Equal(VMFrame &f)
 {
-    if (!StubEqualityOp<true, false>(f))
+    if (!StubEqualityOp<true>(f))
         THROWV(JS_FALSE);
     return f.regs.sp[-2].toBoolean();
 }
 
 JSBool JS_FASTCALL
 stubs::NotEqual(VMFrame &f)
 {
-    if (!StubEqualityOp<false, true>(f))
+    if (!StubEqualityOp<false>(f))
         THROWV(JS_FALSE);
     return f.regs.sp[-2].toBoolean();
 }
 
 void JS_FASTCALL
 stubs::Add(VMFrame &f)
 {
     JSContext *cx = f.cx;