Bug 674522 - Fix jsval_layout on 64-bit big-endian platforms (r=waldo)
authorLuke Wagner <luke@mozilla.com>
Thu, 04 Aug 2011 14:49:35 -0700
changeset 73895 1d186a5f3a96e938a253726ac48ecaf00e80c712
parent 73894 cd0106ceb8ce337636875ef7b1f0d143cb33b7a4
child 73896 ba19e1cd3f918d684ad8d71551254631c8d23870
push id20923
push usermak77@bonardo.net
push dateFri, 05 Aug 2011 15:10:34 +0000
treeherdermozilla-central@c7931e07dd4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs674522
milestone8.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 674522 - Fix jsval_layout on 64-bit big-endian platforms (r=waldo)
js/src/jsval.h
js/src/jsvalue.h
--- a/js/src/jsval.h
+++ b/js/src/jsval.h
@@ -308,17 +308,16 @@ typedef union jsval_layout
         JSValueTag         tag : 17;
     } debugView;
 #endif
     struct {
         union {
             int32          i32;
             uint32         u32;
             JSWhyMagic     why;
-            jsuword        word;
         } payload;
     } s;
     double asDouble;
     void *asPtr;
 } jsval_layout;
 # endif  /* JS_BITS_PER_WORD */
 #else   /* defined(IS_LITTLE_ENDIAN) */
 # if JS_BITS_PER_WORD == 32
@@ -345,29 +344,31 @@ typedef union jsval_layout
 typedef union jsval_layout
 {
     uint64 asBits;
     struct {
         JSValueTag         tag : 17;
         uint64             payload47 : 47;
     } debugView;
     struct {
+        uint32             padding;
         union {
             int32          i32;
             uint32         u32;
             JSWhyMagic     why;
-            jsuword        word;
         } payload;
     } s;
     double asDouble;
     void *asPtr;
 } jsval_layout;
 # endif /* JS_BITS_PER_WORD */
 #endif  /* defined(IS_LITTLE_ENDIAN) */
 
+JS_STATIC_ASSERT(sizeof(jsval_layout) == 8);
+
 #if JS_BITS_PER_WORD == 32
 
 /*
  * N.B. GCC, in some but not all cases, chooses to emit signed comparison of
  * JSValueTag even though its underlying type has been forced to be uint32.
  * Thus, all comparisons should explicitly cast operands to uint32.
  */
 
--- a/js/src/jsvalue.h
+++ b/js/src/jsvalue.h
@@ -738,17 +738,21 @@ class Value
     }
 
     JS_ALWAYS_INLINE
     void *toUnmarkedPtr() const {
         return data.asPtr;
     }
 
     const jsuword *payloadWord() const {
-        return &data.s.payload.word;
+#if JS_BITS_PER_WORD == 32
+        return reinterpret_cast<const jsuword *>(&data.s.payload.word);
+#elif JS_BITS_PER_WORD == 64
+        return reinterpret_cast<const jsuword *>(&data.asBits);
+#endif
     }
 
   private:
     void staticAssertions() {
         JS_STATIC_ASSERT(sizeof(JSValueType) == 1);
         JS_STATIC_ASSERT(sizeof(JSValueTag) == 4);
         JS_STATIC_ASSERT(sizeof(JSBool) == 4);
         JS_STATIC_ASSERT(sizeof(JSWhyMagic) <= 4);