Bug 579273 - Remove JSObject*-to-jsval union-cast in jswrapper.cpp; use CastAsObjectJsval (r=dmandelin)
authorLuke Wagner <lw@mozilla.com>
Fri, 16 Jul 2010 11:47:29 -0700
changeset 48484 946ac3ca890e04f3e148f6560603b019b8677568
parent 48483 8956606e0b49e4a44d843e4c28b7912ed8deb9d4
child 48485 03f0b64560bd91b82391a91190084a570edc6ca2
push id14748
push userrsayre@mozilla.com
push dateSun, 01 Aug 2010 00:33:23 +0000
treeherdermozilla-central@f0df797bb2a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmandelin
bugs579273
milestone2.0b2pre
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 579273 - Remove JSObject*-to-jsval union-cast in jswrapper.cpp; use CastAsObjectJsval (r=dmandelin)
js/src/jswrapper.cpp
js/src/jsxdrapi.cpp
--- a/js/src/jswrapper.cpp
+++ b/js/src/jswrapper.cpp
@@ -416,24 +416,20 @@ JSCompartment::wrapId(JSContext *cx, jsi
     if (!wrap(cx, tvr.addr()))
         return false;
     return ValueToId(cx, tvr.value(), idp);
 }
 
 bool
 JSCompartment::wrap(JSContext *cx, PropertyOp *propp)
 {
-    union {
-        PropertyOp op;
-        jsval v;
-    } u;
-    u.op = *propp;
-    if (!wrap(cx, &Valueify(u.v)))
+    Value v = CastAsObjectJsval(*propp);
+    if (!wrap(cx, &v))
         return false;
-    *propp = u.op;
+    *propp = CastAsPropertyOp(v.toObjectOrNull());
     return true;
 }
 
 bool
 JSCompartment::wrap(JSContext *cx, PropertyDescriptor *desc) {
     return wrap(cx, &desc->obj) &&
            (!(desc->attrs & JSPROP_GETTER) || wrap(cx, &desc->getter)) &&
            (!(desc->attrs & JSPROP_SETTER) || wrap(cx, &desc->setter)) &&
--- a/js/src/jsxdrapi.cpp
+++ b/js/src/jsxdrapi.cpp
@@ -513,96 +513,96 @@ JS_XDRDouble(JSXDRState *xdr, jsdouble *
     if (!XDRDoubleValue(xdr, &d))
         return JS_FALSE;
     if (xdr->mode == JSXDR_DECODE)
         *dp = d;
     return JS_TRUE;
 }
 
 enum XDRValueTag {
-    JSVAL_OBJECT  =             0x0,
-    JSVAL_INT     =             0x1,
-    JSVAL_DOUBLE  =             0x2,
-    JSVAL_STRING  =             0x4,
-    JSVAL_SPECIAL =             0x6,
-    JSVAL_XDRNULL =             0x8,
-    JSVAL_XDRVOID =             0xA
+    XDRTAG_OBJECT  =             0x0,
+    XDRTAG_INT     =             0x1,
+    XDRTAG_DOUBLE  =             0x2,
+    XDRTAG_STRING  =             0x4,
+    XDRTAG_SPECIAL =             0x6,
+    XDRTAG_XDRNULL =             0x8,
+    XDRTAG_XDRVOID =             0xA
 };
 
 static XDRValueTag
 GetXDRTag(jsval v)
 {
     if (JSVAL_IS_NULL(v))
-        return JSVAL_XDRNULL;
+        return XDRTAG_XDRNULL;
     if (JSVAL_IS_VOID(v))
-        return JSVAL_XDRVOID;
+        return XDRTAG_XDRVOID;
     if (JSVAL_IS_OBJECT(v))
-        return JSVAL_OBJECT;
+        return XDRTAG_OBJECT;
     if (JSVAL_IS_INT(v))
-        return JSVAL_INT;
+        return XDRTAG_INT;
     if (JSVAL_IS_DOUBLE(v))
-        return JSVAL_DOUBLE;
+        return XDRTAG_DOUBLE;
     if (JSVAL_IS_STRING(v))
-        return JSVAL_STRING;
+        return XDRTAG_STRING;
     JS_ASSERT(JSVAL_IS_BOOLEAN(v));
-    return JSVAL_SPECIAL;
+    return XDRTAG_SPECIAL;
 }
 
 static JSBool
 XDRValueBody(JSXDRState *xdr, uint32 type, jsval *vp)
 {
     switch (type) {
-      case JSVAL_XDRNULL:
+      case XDRTAG_XDRNULL:
         *vp = JSVAL_NULL;
         break;
-      case JSVAL_XDRVOID:
+      case XDRTAG_XDRVOID:
         *vp = JSVAL_VOID;
         break;
-      case JSVAL_STRING: {
+      case XDRTAG_STRING: {
         JSString *str;
         if (xdr->mode == JSXDR_ENCODE)
             str = JSVAL_TO_STRING(*vp);
         if (!JS_XDRString(xdr, &str))
             return JS_FALSE;
         if (xdr->mode == JSXDR_DECODE)
             *vp = STRING_TO_JSVAL(str);
         break;
       }
-      case JSVAL_DOUBLE: {
+      case XDRTAG_DOUBLE: {
         double d = xdr->mode == JSXDR_ENCODE ? JSVAL_TO_DOUBLE(*vp) : 0;
         if (!JS_XDRDouble(xdr, &d))
             return JS_FALSE;
         if (xdr->mode == JSXDR_DECODE)
             *vp = DOUBLE_TO_JSVAL(d);
         break;
       }
-      case JSVAL_OBJECT: {
+      case XDRTAG_OBJECT: {
         JSObject *obj;
         if (xdr->mode == JSXDR_ENCODE)
             obj = JSVAL_TO_OBJECT(*vp);
         if (!js_XDRObject(xdr, &obj))
             return JS_FALSE;
         if (xdr->mode == JSXDR_DECODE)
             *vp = OBJECT_TO_JSVAL(obj);
         break;
       }
-      case JSVAL_SPECIAL: {
+      case XDRTAG_SPECIAL: {
         uint32 b;
         if (xdr->mode == JSXDR_ENCODE)
             b = (uint32) JSVAL_TO_BOOLEAN(*vp);
         if (!JS_XDRUint32(xdr, &b))
             return JS_FALSE;
         if (xdr->mode == JSXDR_DECODE)
             *vp = BOOLEAN_TO_JSVAL(!!b);
         break;
       }
       default: {
         uint32 i;
 
-        JS_ASSERT(type == JSVAL_INT);
+        JS_ASSERT(type == XDRTAG_INT);
         if (xdr->mode == JSXDR_ENCODE)
             i = (uint32) JSVAL_TO_INT(*vp);
         if (!JS_XDRUint32(xdr, &i))
             return JS_FALSE;
         if (xdr->mode == JSXDR_DECODE)
             *vp = INT_TO_JSVAL((int32) i);
         break;
       }