Bug 496441 - Random cleanup: only calculate the callee once. r+sr=jst
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 01 Jul 2009 12:12:04 -0700
changeset 29947 a334624fc37ed006643f9fd6c90085975671d231
parent 29946 e7c62fc3b92bc0ecefaeefd7db0db76dbf23c7ea
child 29948 b5bdefc2cac7e4ea1598294ce6afa2035a19dca7
push idunknown
push userunknown
push dateunknown
bugs496441
milestone1.9.2a1pre
Bug 496441 - Random cleanup: only calculate the callee once. r+sr=jst
js/src/xpconnect/src/xpcwrappedjsclass.cpp
--- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp
+++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp
@@ -1429,16 +1429,51 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
 
     // this is a function call, so push function and 'this'
     if(stack_size != argc)
     {
         *sp++ = fval;
         *sp++ = OBJECT_TO_JSVAL(thisObj);
     }
 
+    // Figure out what our callee is
+    if(XPT_MD_IS_GETTER(info->flags) || XPT_MD_IS_SETTER(info->flags))
+    {
+        // Pull the getter or setter off of |obj|
+        uintN attrs;
+        JSBool found;
+        JSPropertyOp getter;
+        JSPropertyOp setter;
+        if(!JS_GetPropertyAttrsGetterAndSetter(cx, obj, name,
+                                               &attrs, &found,
+                                               &getter, &setter))
+        {
+            // XXX Do we want to report this exception?
+            JS_ClearPendingException(cx);
+            goto pre_call_clean_up;
+        }
+
+        if(XPT_MD_IS_GETTER(info->flags) && (attrs & JSPROP_GETTER))
+        {
+            // JSPROP_GETTER means the getter is actually a
+            // function object.
+            ccx.SetCallee(JS_FUNC_TO_DATA_PTR(JSObject*, getter));
+        }
+        else if(XPT_MD_IS_SETTER(info->flags) && (attrs & JSPROP_SETTER))
+        {
+            // JSPROP_SETTER means the setter is actually a
+            // function object.
+            ccx.SetCallee(JS_FUNC_TO_DATA_PTR(JSObject*, setter));
+        }
+    }
+    else if(JSVAL_IS_OBJECT(fval))
+    {
+        ccx.SetCallee(JSVAL_TO_OBJECT(fval));
+    }
+
     // build the args
     for(i = 0; i < argc; i++)
     {
         const nsXPTParamInfo& param = info->params[i];
         const nsXPTType& type = param.GetType();
         nsXPTType datum_type;
         JSUint32 array_count;
         PRBool isArray = type.IsArray();
@@ -1484,49 +1519,16 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
             if(isArray || isSizedString)
             {
                 if(!GetArraySizeFromParam(cx, info, param, methodIndex,
                                           i, GET_LENGTH, nativeParams,
                                           &array_count))
                     goto pre_call_clean_up;
             }
 
-            // Figure out what our callee is
-            if(XPT_MD_IS_GETTER(info->flags) || XPT_MD_IS_SETTER(info->flags))
-            {
-                // Pull the getter or setter off of |obj|
-                uintN attrs;
-                JSBool found;
-                JSPropertyOp getter;
-                JSPropertyOp setter;
-                JSBool ok =
-                    JS_GetPropertyAttrsGetterAndSetter(cx, obj, name,
-                                                       &attrs, &found,
-                                                       &getter, &setter);
-                if(ok)
-                {
-                    if(XPT_MD_IS_GETTER(info->flags) && (attrs & JSPROP_GETTER))
-                    {
-                        // JSPROP_GETTER means the getter is actually a
-                        // function object.
-                        ccx.SetCallee(JS_FUNC_TO_DATA_PTR(JSObject*, getter));
-                    }
-                    else if(XPT_MD_IS_SETTER(info->flags) && (attrs & JSPROP_SETTER))
-                    {
-                        // JSPROP_SETTER means the setter is actually a
-                        // function object.
-                        ccx.SetCallee(JS_FUNC_TO_DATA_PTR(JSObject*, setter));
-                    }
-                }
-            }
-            else if(JSVAL_IS_OBJECT(fval))
-            {
-                ccx.SetCallee(JSVAL_TO_OBJECT(fval));
-            }
-
             if(isArray)
             {
 
                 if(!XPCConvert::NativeArray2JS(ccx, &val, (const void**)&pv->val,
                                                datum_type, &param_iid,
                                                array_count, obj, nsnull))
                     goto pre_call_clean_up;
             }