Bug 837773 - Change private uint32_t Values to use the int32_t representation, for simplicity. r=luke
authorJeff Walden <jwalden@mit.edu>
Fri, 01 Feb 2013 18:41:35 -0800
changeset 120945 06fe741ec9538e7de9fc43a8a730b8d5a1782e78
parent 120944 f13e3cac0c1b058fa6880a50f618e288941dda85
child 120946 43a5c9890c22e54152c997f8800956b517819a3a
push id22497
push userjwalden@mit.edu
push dateTue, 05 Feb 2013 23:38:16 +0000
treeherdermozilla-inbound@43a5c9890c22 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs837773
milestone21.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 837773 - Change private uint32_t Values to use the int32_t representation, for simplicity. r=luke
js/public/Value.h
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -556,32 +556,16 @@ MAGIC_TO_JSVAL_IMPL(JSWhyMagic why)
 
 static MOZ_ALWAYS_INLINE JSBool
 JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs)
 {
     JSValueTag ltag = lhs.s.tag, rtag = rhs.s.tag;
     return ltag == rtag || (ltag < JSVAL_TAG_CLEAR && rtag < JSVAL_TAG_CLEAR);
 }
 
-static MOZ_ALWAYS_INLINE jsval_layout
-PRIVATE_UINT32_TO_JSVAL_IMPL(uint32_t ui)
-{
-    jsval_layout l;
-    l.s.tag = (JSValueTag)0;
-    l.s.payload.u32 = ui;
-    MOZ_ASSERT(JSVAL_IS_DOUBLE_IMPL(l));
-    return l;
-}
-
-static MOZ_ALWAYS_INLINE uint32_t
-JSVAL_TO_PRIVATE_UINT32_IMPL(jsval_layout l)
-{
-    return l.s.payload.u32;
-}
-
 static MOZ_ALWAYS_INLINE JSValueType
 JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l)
 {
     uint32_t type = l.s.tag & 0xF;
     MOZ_ASSERT(type > JSVAL_TYPE_DOUBLE);
     return (JSValueType)type;
 }
 
@@ -804,32 +788,16 @@ MAGIC_TO_JSVAL_IMPL(JSWhyMagic why)
 static MOZ_ALWAYS_INLINE JSBool
 JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs)
 {
     uint64_t lbits = lhs.asBits, rbits = rhs.asBits;
     return (lbits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE && rbits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE) ||
            (((lbits ^ rbits) & 0xFFFF800000000000LL) == 0);
 }
 
-static MOZ_ALWAYS_INLINE jsval_layout
-PRIVATE_UINT32_TO_JSVAL_IMPL(uint32_t ui)
-{
-    jsval_layout l;
-    l.asBits = (uint64_t)ui;
-    MOZ_ASSERT(JSVAL_IS_DOUBLE_IMPL(l));
-    return l;
-}
-
-static MOZ_ALWAYS_INLINE uint32_t
-JSVAL_TO_PRIVATE_UINT32_IMPL(jsval_layout l)
-{
-    MOZ_ASSERT((l.asBits >> 32) == 0);
-    return (uint32_t)l.asBits;
-}
-
 static MOZ_ALWAYS_INLINE JSValueType
 JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l)
 {
    uint64_t type = (l.asBits >> JSVAL_TAG_SHIFT) & 0xF;
    MOZ_ASSERT(type > JSVAL_TYPE_DOUBLE);
    return (JSValueType)type;
 }
 
@@ -1195,29 +1163,23 @@ class Value
     MOZ_ALWAYS_INLINE
     void *toPrivate() const {
         MOZ_ASSERT(JSVAL_IS_DOUBLE_IMPL(data));
         return JSVAL_TO_PRIVATE_PTR_IMPL(data);
     }
 
     MOZ_ALWAYS_INLINE
     void setPrivateUint32(uint32_t ui) {
-        data = PRIVATE_UINT32_TO_JSVAL_IMPL(ui);
+        MOZ_ASSERT(uint32_t(int32_t(ui)) == ui);
+        setInt32(int32_t(ui));
     }
 
     MOZ_ALWAYS_INLINE
     uint32_t toPrivateUint32() const {
-        MOZ_ASSERT(JSVAL_IS_DOUBLE_IMPL(data));
-        return JSVAL_TO_PRIVATE_UINT32_IMPL(data);
-    }
-
-    MOZ_ALWAYS_INLINE
-    uint32_t &getPrivateUint32Ref() {
-        MOZ_ASSERT(isDouble());
-        return data.s.payload.u32;
+        return uint32_t(toInt32());
     }
 
     /*
      * An unmarked value is just a void* cast as a Value. Thus, the Value is
      * not safe for GC and must not be marked. This API avoids raw casts
      * and the ensuing strict-aliasing warnings.
      */