Fixing bug 585787. Compare compartments instead of global objects in quickstubs when deteremining whether we need to wrap the return value or not. r=mrbkap@gmail.com, a=bzbarsky
authorJohnny Stenback <jst@mozilla.com>
Fri, 22 Oct 2010 09:32:09 -0700
changeset 57575 410c9f17f0fc4edba06909012cbe4db38d0d8eea
parent 57574 f9e32506519f880bf8f548cd285f813da12d1d8c
child 57576 a1e24da8518f24c18c48222d4e7429cabfd45d8d
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersmrbkap, bzbarsky
bugs585787
milestone2.0b8pre
Fixing bug 585787. Compare compartments instead of global objects in quickstubs when deteremining whether we need to wrap the return value or not. r=mrbkap@gmail.com, a=bzbarsky
js/src/xpconnect/src/qsgen.py
--- a/js/src/xpconnect/src/qsgen.py
+++ b/js/src/xpconnect/src/qsgen.py
@@ -703,22 +703,22 @@ def writeResultConv(f, type, jsvalPtr, j
         if isVariantType(type):
             f.write("    return xpc_qsVariantToJsval(lccx, result, %s);\n"
                     % jsvalPtr)
             return
         else:
             f.write("    nsWrapperCache* cache = xpc_qsGetWrapperCache(result);\n"
                     "    if (cache) {\n"
                     "      JSObject* wrapper = cache->GetWrapper();\n"
+                    "      NS_ASSERTION(cx->compartment == obj->compartment(),\n"
+                    "                   \"wrong compartment in object or context!\");\n"
                     "      if (wrapper &&\n"
                     # FIXME: Bug 585786, this check should go away
                     "          IS_SLIM_WRAPPER_OBJECT(wrapper) &&\n"
-                    # FIXME: Bug 585787 this should compare compartments
-                    "          xpc_GetGlobalForObject(wrapper) ==\n"
-                    "            xpc_GetGlobalForObject(obj)) {\n"
+                    "          cx->compartment == wrapper->compartment()) {\n"
                     "        *%s = OBJECT_TO_JSVAL(wrapper);\n"
                     "        return JS_TRUE;\n"
                     "      }\n"
                     "    }\n"
                     "    // After this point do not use 'result'!\n"
                     "    qsObjectHelper helper(result, cache);\n"
                     "    return xpc_qsXPCOMObjectToJsval(lccx, "
                     "helper, &NS_GET_IID(%s), &interfaces[k_%s], %s);\n"
@@ -1255,22 +1255,22 @@ def writeTraceableResultConv(f, type):
     elif isInterfaceType(type):
         if isVariantType(type):
             f.write("    JSBool ok = xpc_qsVariantToJsval(lccx, result, "
                     "&vp.array[0]);\n")
         else:
             f.write("    nsWrapperCache* cache = xpc_qsGetWrapperCache(result);\n"
                     "    if (cache) {\n"
                     "      JSObject* wrapper = cache->GetWrapper();\n"
+                    "      NS_ASSERTION(cx->compartment == obj->compartment(),\n"
+                    "                   \"wrong compartment in object or context!\");\n"
                     "      if (wrapper &&\n"
                     # FIXME: Bug 585786, this check should go away
                     "          IS_SLIM_WRAPPER_OBJECT(wrapper) &&\n"
-                    # FIXME: Bug 585787 this should compare compartments
-                    "          xpc_GetGlobalForObject(wrapper) ==\n"
-                    "            xpc_GetGlobalForObject(obj)) {\n"
+                    "          cx->compartment == wrapper->compartment()) {\n"
                     "        vp.array[0] = OBJECT_TO_JSVAL(wrapper);\n"
                     "        return wrapper;\n"
                     "      }\n"
                     "    }\n"
                     "    // After this point do not use 'result'!\n"
                     "    qsObjectHelper helper(result, cache);\n"
                     "    JSBool ok = xpc_qsXPCOMObjectToJsval(lccx, "
                     "helper, &NS_GET_IID(%s), &interfaces[k_%s], "