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 77414 41e4d29fb76d1924c7415d5fda73c9437697b89a
parent 77413 5ddec215cf627896ba0d52b3585de652caf39af4
child 77415 c0b96cb41fc1f4a808afbe5278320f18429e0f7a
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersjimb
bugs653056
milestone9.0a1
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;
 }