Bug 653056 - Use a bitwise version of JSDOUBLE_IS_NaN that Visual Studio PGO doesn't miscompile. r=jimb
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 23 Sep 2011 14:27:21 +0200
changeset 78725 41e4d29fb76d1924c7415d5fda73c9437697b89a
parent 78724 5ddec215cf627896ba0d52b3585de652caf39af4
child 78726 c0b96cb41fc1f4a808afbe5278320f18429e0f7a
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb
bugs653056
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 653056 - Use a bitwise version of JSDOUBLE_IS_NaN that Visual Studio PGO doesn't miscompile. r=jimb
js/src/jsnum.h
--- a/js/src/jsnum.h
+++ b/js/src/jsnum.h
@@ -36,19 +36,16 @@
  * 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>
-#ifdef WIN32
-#include <float.h>
-#endif
 
 #include "jsstdint.h"
 #include "jsobj.h"
 
 /*
  * JS number (IEEE double) interface.
  *
  * JS numbers are optimistically stored in the top 31 bits of 32-bit integers,
@@ -76,29 +73,28 @@ typedef union jsdpun {
         uint32 hi, lo;
 #endif
     } s;
     uint64   u64;
     jsdouble d;
 } jsdpun;
 
 /* Low-level floating-point predicates. See bug 640494. */
+#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 int
 JSDOUBLE_IS_NaN(jsdouble d)
 {
-/* Visual Studio PGO miscompiles the bitwise version, so keep using _isnan
- * from float.h until we figure out what's going on. */
-#ifdef WIN32
-    return _isnan(d);
-#else
     jsdpun u;
     u.d = d;
-    return (u.u64 & ~JSDOUBLE_SIGNBIT) > JSDOUBLE_EXPMASK;
-#endif
+    return (u.s.hi & JSDOUBLE_HI32_NAN) == JSDOUBLE_HI32_NAN;
 }
 
 static inline int
 JSDOUBLE_IS_FINITE(jsdouble d)
 {
     /* -0 is finite. NaNs are not. */
     jsdpun u;
     u.d = d;
@@ -108,22 +104,16 @@ JSDOUBLE_IS_FINITE(jsdouble d)
 static inline int
 JSDOUBLE_IS_INFINITE(jsdouble d)
 {
     jsdpun u;
     u.d = d;
     return (u.u64 & ~JSDOUBLE_SIGNBIT) == JSDOUBLE_EXPMASK;
 }
 
-#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;
 }