Fix for bug 814821 (Dromaeo dom-traverse regression from bug 812333) - part 4: inline xpc_qsUnwrapObj. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 27 Nov 2012 10:20:05 +0100
changeset 114344 7d678d658159f4ebe557072e1510ffc097949f80
parent 114343 ae93793daecd682d55996f9fe6140daf74d181c7
child 114345 9d18ded603301309aaebc9261db21dd941e16762
push id18708
push userpvanderbeken@mozilla.com
push dateWed, 28 Nov 2012 09:02:49 +0000
treeherdermozilla-inbound@7d678d658159 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs814821, 812333
milestone20.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
Fix for bug 814821 (Dromaeo dom-traverse regression from bug 812333) - part 4: inline xpc_qsUnwrapObj. r=bz.
dom/bindings/BindingUtils.h
js/xpconnect/src/XPCQuickStubs.cpp
js/xpconnect/src/XPCQuickStubs.h
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -182,17 +182,17 @@ IsDOMObject(JSObject* obj)
   return IsDOMClass(clasp) || IsDOMProxy(obj, clasp);
 }
 
 // Some callers don't want to set an exception when unwrapping fails
 // (for example, overload resolution uses unwrapping to tell what sort
 // of thing it's looking at).
 // U must be something that a T* can be assigned to (e.g. T* or an nsRefPtr<T>).
 template <prototypes::ID PrototypeID, class T, typename U>
-inline nsresult
+MOZ_ALWAYS_INLINE nsresult
 UnwrapObject(JSContext* cx, JSObject* obj, U& value)
 {
   /* First check to see whether we have a DOM object */
   const DOMClass* domClass;
   DOMObjectSlot slot = GetDOMClass(obj, domClass);
   if (slot == eNonDOMObject) {
     /* Maybe we have a security wrapper or outer window? */
     if (!js::IsWrapper(obj)) {
--- a/js/xpconnect/src/XPCQuickStubs.cpp
+++ b/js/xpconnect/src/XPCQuickStubs.cpp
@@ -793,37 +793,16 @@ xpc_qsUnwrapThisFromCcxImpl(XPCCallConte
     nsresult rv = getNative(native, GetOffsets(native, ccx.GetProto()),
                             ccx.GetFlattenedJSObject(), iid, ppThis, pThisRef,
                             vp);
     if (NS_FAILED(rv))
         return xpc_qsThrow(ccx.GetJSContext(), rv);
     return true;
 }
 
-JSObject*
-xpc_qsUnwrapObj(JS::Value v, nsISupports **ppArgRef, nsresult *rv)
-{
-    if (v.isNullOrUndefined()) {
-        *ppArgRef = nullptr;
-        *rv = NS_OK;
-        return nullptr;
-    }
-
-    if (!v.isObject()) {
-        *ppArgRef = nullptr;
-        *rv = ((v.isInt32() && v.toInt32() == 0)
-               ? NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL
-               : NS_ERROR_XPC_BAD_CONVERT_JS);
-        return nullptr;
-    }
-
-    *rv = NS_OK;
-    return &v.toObject();
-}
-
 nsresult
 xpc_qsUnwrapArgImpl(JSContext *cx,
                     jsval v,
                     const nsIID &iid,
                     void **ppArg,
                     nsISupports **ppArgRef,
                     jsval *vp)
 {
--- a/js/xpconnect/src/XPCQuickStubs.h
+++ b/js/xpconnect/src/XPCQuickStubs.h
@@ -495,18 +495,33 @@ xpc_qsUnwrapThisFromCcx(XPCCallContext &
 {
     return xpc_qsUnwrapThisFromCcxImpl(ccx,
                                        NS_GET_TEMPLATE_IID(T),
                                        reinterpret_cast<void **>(ppThis),
                                        pThisRef,
                                        pThisVal);
 }
 
-JSObject*
-xpc_qsUnwrapObj(jsval v, nsISupports **ppArgRef, nsresult *rv);
+MOZ_ALWAYS_INLINE JSObject*
+xpc_qsUnwrapObj(jsval v, nsISupports **ppArgRef, nsresult *rv)
+{
+    *rv = NS_OK;
+    if (v.isObject()) {
+        return &v.toObject();
+    }
+
+    if (!v.isNullOrUndefined()) {
+        *rv = ((v.isInt32() && v.toInt32() == 0)
+               ? NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL
+               : NS_ERROR_XPC_BAD_CONVERT_JS);
+    }
+
+    *ppArgRef = nullptr;
+    return nullptr;
+}
 
 nsresult
 xpc_qsUnwrapArgImpl(JSContext *cx, jsval v, const nsIID &iid, void **ppArg,
                     nsISupports **ppArgRef, jsval *vp);
 
 /** Convert a jsval to an XPCOM pointer. */
 template <class Interface, class StrongRefType>
 inline nsresult