Bug 692342 - Coalesce cleanup flagging within ConvertDependentParam. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Fri, 25 Nov 2011 17:09:07 -0800
changeset 80795 d7e55d8251a62eb606c64cae0dfe07eef0320cec
parent 80794 74a834deb8a22ab5b9d9bd5c25983b7381b7cf39
child 80796 c1bc4c0988143a2d8933b43018fb6ce7747c4871
push id21530
push userbmo@edmorley.co.uk
push dateSat, 26 Nov 2011 08:27:28 +0000
treeherdermozilla-central@c58bad0b4640 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs692342
milestone11.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 692342 - Coalesce cleanup flagging within ConvertDependentParam. r=mrbkap The only change in functionality here is that we flag for cleanup on 'inout' sized strings in addition to 'in' sized strings. I'm pretty sure we want that.
js/xpconnect/src/XPCWrappedNative.cpp
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -2741,21 +2741,32 @@ CallMethodHelper::ConvertDependentParam(
     } else {
         datum_type = type;
     }
 
     // Specify the correct storage/calling semantics.
     if (paramInfo.IsIndirect())
         dp->SetIndirect();
 
-    if (isArray && datum_type.IsPointer())
+    // Flag cleanup as necessary for each type.
+    if (isArray) {
+        // Case 1 - Arrays.
+        if (datum_type.IsPointer())
+            dp->SetValNeedsCleanup();
+
+    } else if (isSizedString) {
+        // Case 2 - Sized strings.
         dp->SetValNeedsCleanup();
 
-    if (datum_type.IsInterfacePointer())
+    } else {
+        // Case 3 - Dependent interface pointer.
+        NS_ABORT_IF_FALSE(type.TagPart() == nsXPTType::T_INTERFACE_IS,
+                          "Unknown dependent type.");
         dp->SetValNeedsCleanup();
+    }
 
     // Even if there's nothing to convert, we still need to examine the
     // JSObject container for out-params. If it's null or otherwise invalid,
     // we want to know before the call, rather than after.
     //
     // This is a no-op for 'in' params.
     jsval src;
     if (!GetOutParamSource(i, &src))
@@ -2770,23 +2781,16 @@ CallMethodHelper::ConvertDependentParam(
     // convert. The source value for conversion depends on whether we're
     // dealing with an 'in' or an 'inout' parameter. 'inout' was handled above,
     // so all that's left is 'in'.
     if (!paramInfo.IsOut()) {
         // Handle the 'in' case.
         NS_ASSERTION(i < mArgc || paramInfo.IsOptional(),
                      "Expected either enough arguments or an optional argument");
         src = i < mArgc ? mArgv[i] : JSVAL_NULL;
-
-        if (datum_type.TagPart() == nsXPTType::T_IID ||
-            datum_type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS ||
-            datum_type.TagPart() == nsXPTType::T_PWSTRING_SIZE_IS ||
-            (isArray && datum_type.TagPart() == nsXPTType::T_CHAR_STR)) {
-            dp->SetValNeedsCleanup();
-        }
     }
 
     nsID param_iid;
     if (datum_type.IsInterfacePointer() &&
         !GetInterfaceTypeFromParam(i, datum_type, &param_iid))
         return JS_FALSE;
 
     uintN err;