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 73877 373e6bd2705d1d1cf19fc60a87a2fc98609c6c78
parent 73876 c69f76d027b2d4fadd19596830248face3611a0e
child 73878 a22fad398472a3a79d80a7aeb8e9ca5ad4c8ca73
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewerswaldo
bugs674522
milestone8.0a1
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 {
+#if JS_BITS_PER_WORD == 32
         return &data.s.payload.word;
+#elif JS_BITS_PER_WORD == 64
+        return &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);