Bug 692342 - Simplify cleanup code in ConvertIndependentParameter(). r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Fri, 25 Nov 2011 17:09:07 -0800
changeset 81587 8790687685ee53327539a05ae6636c6f6ddfcb29
parent 81586 e8df70ae53e2b693d2a16b2bda022cbb7e7eef47
child 81588 4d417032d8878ed97c1093544e9ae13aa964999d
push id628
push userclegnitto@mozilla.com
push dateWed, 21 Dec 2011 14:41:57 +0000
treeherdermozilla-aurora@24a61ad789e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs692342
milestone11.0a1
Bug 692342 - Simplify cleanup code in ConvertIndependentParameter(). r=mrbkap We're not dealing with dependent parameters here. So as far as I can tell, the only behavior change that this introduces is that we flag for cleanup on T_WCHAR_STR in addition to T_CHAR_STR. This seems like something we probably want.
js/xpconnect/src/XPCWrappedNative.cpp
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -2632,68 +2632,38 @@ CallMethodHelper::ConvertIndependentPara
     // Handle dipper types separately.
     if (paramInfo.IsDipper())
         return HandleDipperParam(dp, paramInfo);
 
     // Specify the correct storage/calling semantics.
     if (paramInfo.IsIndirect())
         dp->SetIndirect();
 
-    if (type_tag == nsXPTType::T_INTERFACE) {
-        dp->SetValNeedsCleanup();
-    }
-
     jsval src;
 
     if (!GetOutParamSource(i, &src))
         return JS_FALSE;
 
     // The JSVal proper is always stored within the 'val' union and passed
     // indirectly, regardless of in/out-ness.
     if (type_tag == nsXPTType::T_JSVAL) {
         // Root the value.
         dp->val.j = JSVAL_VOID;
         if (!JS_AddValueRoot(mCallContext, &dp->val.j))
             return JS_FALSE;
+    }
+
+    // Flag cleanup for anything that isn't self-contained.
+    if (!type.IsArithmetic())
         dp->SetValNeedsCleanup();
-    }
 
     if (paramInfo.IsOut()) {
-        if (type.IsPointer() &&
-            type_tag != nsXPTType::T_INTERFACE) {
-            dp->SetValNeedsCleanup();
-        }
-
-        if (!paramInfo.IsIn())
+        if(!paramInfo.IsIn())
             return JS_TRUE;
-
     } else {
-        switch (type_tag) {
-        case nsXPTType::T_IID:
-            dp->SetValNeedsCleanup();
-            break;
-        case nsXPTType::T_CHAR_STR:
-            dp->SetValNeedsCleanup();
-            break;
-        case nsXPTType::T_ASTRING:
-            // Fall through to the T_DOMSTRING case
-        case nsXPTType::T_DOMSTRING:
-            dp->SetValNeedsCleanup();
-            break;
-
-        case nsXPTType::T_UTF8STRING:
-            // Fall through to the C string case for now...
-        case nsXPTType::T_CSTRING:
-            dp->SetValNeedsCleanup();
-            break;
-        }
-
-        // Do this *after* the above because in the case where we have a
-        // "T_DOMSTRING && IsDipper()" then arg might be null since this
-        // is really an 'out' param masquerading as an 'in' param.
         NS_ASSERTION(i < mArgc || paramInfo.IsOptional(),
                      "Expected either enough arguments or an optional argument");
         if (i < mArgc)
             src = mArgv[i];
         else if (type_tag == nsXPTType::T_JSVAL)
             src = JSVAL_VOID;
         else
             src = JSVAL_NULL;