Backout changeset d29e1e37e7c2 from bug 640494 because of jsreftest orange on Win opt builds
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 23 Apr 2011 13:06:48 +0200
changeset 68474 296792b874b9ed81c7517a8dd2aa76f5e9323bbc
parent 68473 5794bcf0f85edeaa6e9d33e5a4cb7cf046d81c30
child 68475 26ba14209541b2574d423db589ebf11a87cc2129
push id19655
push usermh@glandium.org
push dateSat, 23 Apr 2011 11:07:52 +0000
treeherdermozilla-central@296792b874b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs640494
milestone6.0a1
backs outd29e1e37e7c2088195a973515a144c80ad6ac814
first release with
nightly linux32
296792b874b9 / 6.0a1 / 20110423042738 / files
nightly linux64
296792b874b9 / 6.0a1 / 20110423042738 / files
nightly mac
296792b874b9 / 6.0a1 / 20110423042738 / files
nightly win32
296792b874b9 / 6.0a1 / 20110423042612 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Backout changeset d29e1e37e7c2 from bug 640494 because of jsreftest orange on Win opt builds
js/src/jsnum.h
js/src/jsvalue.h
--- a/js/src/jsnum.h
+++ b/js/src/jsnum.h
@@ -36,16 +36,22 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef jsnum_h___
 #define jsnum_h___
 
 #include <math.h>
+#if defined(XP_WIN) || defined(XP_OS2)
+#include <float.h>
+#endif
+#ifdef SOLARIS
+#include <ieeefp.h>
+#endif
 #include "jsvalue.h"
 
 #include "jsstdint.h"
 #include "jsstr.h"
 #include "jsobj.h"
 
 /*
  * JS number (IEEE double) interface.
@@ -74,56 +80,65 @@ typedef union jsdpun {
 #else
         uint32 hi, lo;
 #endif
     } s;
     uint64   u64;
     jsdouble d;
 } jsdpun;
 
-/* Low-level floating-point predicates. See bug 640494. */
-
 static inline int
 JSDOUBLE_IS_NaN(jsdouble d)
 {
-    jsdpun u;
-    u.d = d;
-    return (u.u64 & JSDOUBLE_EXPMASK) == JSDOUBLE_EXPMASK &&
-           (u.u64 & JSDOUBLE_MANTMASK) != 0;
+#ifdef WIN32
+    return _isnan(d);
+#else
+    return isnan(d);
+#endif
 }
 
 static inline int
 JSDOUBLE_IS_FINITE(jsdouble d)
 {
-    /* -0 is finite. NaNs are not. */
-    jsdpun u;
-    u.d = d;
-    return (u.u64 & JSDOUBLE_EXPMASK) != JSDOUBLE_EXPMASK;
+#ifdef WIN32
+    return _finite(d);
+#else
+    return finite(d);
+#endif
 }
 
 static inline int
 JSDOUBLE_IS_INFINITE(jsdouble d)
 {
-    jsdpun u;
-    u.d = d;
-    return (u.u64 & ~JSDOUBLE_SIGNBIT) == JSDOUBLE_EXPMASK;
+#ifdef WIN32
+    int c = _fpclass(d);
+    return c == _FPCLASS_NINF || c == _FPCLASS_PINF;
+#elif defined(SOLARIS)
+    return !finite(d) && !isnan(d);
+#else
+    return isinf(d);
+#endif
 }
 
 #define JSDOUBLE_HI32_SIGNBIT   0x80000000
 #define JSDOUBLE_HI32_EXPMASK   0x7ff00000
 #define JSDOUBLE_HI32_MANTMASK  0x000fffff
 #define JSDOUBLE_HI32_NAN       0x7ff80000
 #define JSDOUBLE_LO32_NAN       0x00000000
 
 static inline bool
 JSDOUBLE_IS_NEG(jsdouble d)
 {
-    jsdpun u;
-    u.d = d;
-    return (u.s.hi & JSDOUBLE_HI32_SIGNBIT) != 0;
+#ifdef WIN32
+    return JSDOUBLE_IS_NEGZERO(d) || d < 0;
+#elif defined(SOLARIS)
+    return copysign(1, d) < 0;
+#else
+    return signbit(d);
+#endif
 }
 
 static inline uint32
 JS_HASH_DOUBLE(jsdouble d)
 {
     jsdpun u;
     u.d = d;
     return u.s.lo ^ u.s.hi;
--- a/js/src/jsvalue.h
+++ b/js/src/jsvalue.h
@@ -84,29 +84,34 @@
  *   avoid copying jsval/js::Value as much as possible, preferring to pass by
  *   const Value &.
  */
 
 /******************************************************************************/
 
 /* To avoid a circular dependency, pull in the necessary pieces of jsnum.h. */
 
-#define JSDOUBLE_SIGNBIT (((uint64) 1) << 63)
-#define JSDOUBLE_EXPMASK (((uint64) 0x7ff) << 52)
-#define JSDOUBLE_MANTMASK ((((uint64) 1) << 52) - 1)
+#include <math.h>
+#if defined(XP_WIN) || defined(XP_OS2)
+#include <float.h>
+#endif
+#ifdef SOLARIS
+#include <ieeefp.h>
+#endif
 
-static JS_ALWAYS_INLINE JSBool
+static inline int
 JSDOUBLE_IS_NEGZERO(jsdouble d)
 {
-    union {
-        jsdouble d;
-        uint64 bits;
-    } x;
-    x.d = d;
-    return x.bits == JSDOUBLE_SIGNBIT;
+#ifdef WIN32
+    return (d == 0 && (_fpclass(d) & _FPCLASS_NZ));
+#elif defined(SOLARIS)
+    return (d == 0 && copysign(1, d) < 0);
+#else
+    return (d == 0 && signbit(d));
+#endif
 }
 
 static inline bool
 JSDOUBLE_IS_INT32(jsdouble d, int32_t* pi)
 {
     if (JSDOUBLE_IS_NEGZERO(d))
         return false;
     return d == (*pi = int32_t(d));