From d73c01f2df8ec595957b82897ef3e9283a40dfac Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 22 Oct 2014 11:40:51 -0400 Subject: [PATCH] Bug 1019191 part 22. Eliminate the effectively unused vp argument of xpc_qsUnwrapArgImpl. r=peterv --- dom/bindings/BindingUtils.cpp | 6 ++---- dom/bindings/BindingUtils.h | 7 +++---- dom/bindings/Codegen.py | 20 ++++++-------------- js/xpconnect/src/XPCQuickStubs.cpp | 4 +--- js/xpconnect/src/XPCQuickStubs.h | 2 +- 5 files changed, 13 insertions(+), 26 deletions(-) diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 0ca1c6207d1..12835b87a12 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -827,12 +827,10 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp) // Switch this to UnwrapDOMObjectToISupports once our global objects are // using new bindings. - JS::Rooted unusedVal(cx); nsISupports* native = nullptr; nsCOMPtr nativeRef; UnwrapArg(cx, obj, &native, - static_cast(getter_AddRefs(nativeRef)), - &unusedVal); + static_cast(getter_AddRefs(nativeRef))); if (!native) { return Throw(cx, NS_ERROR_FAILURE); } @@ -848,7 +846,7 @@ QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp) nsIJSID* iid; SelfRef iidRef; obj = &args[0].toObject(); - if (NS_FAILED(UnwrapArg(cx, obj, &iid, &iidRef.ptr, &unusedVal))) { + if (NS_FAILED(UnwrapArg(cx, obj, &iid, &iidRef.ptr))) { return Throw(cx, NS_ERROR_XPC_BAD_CONVERT_JS); } MOZ_ASSERT(iid); diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index f6ad2b442e5..e1368a20e85 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -41,7 +41,7 @@ class nsPIDOMWindow; extern nsresult xpc_qsUnwrapArgImpl(JSContext* cx, JS::Handle src, const nsIID& iid, void** ppArg, - nsISupports** ppArgRef, JS::MutableHandle vp); + nsISupports** ppArgRef); namespace mozilla { namespace dom { @@ -60,12 +60,11 @@ struct SelfRef template inline nsresult UnwrapArg(JSContext* cx, JS::Handle src, Interface** ppArg, - StrongRefType** ppArgRef, JS::MutableHandle vp) + StrongRefType** ppArgRef) { nsISupports* argRef = *ppArgRef; nsresult rv = xpc_qsUnwrapArgImpl(cx, src, NS_GET_TEMPLATE_IID(Interface), - reinterpret_cast(ppArg), &argRef, - vp); + reinterpret_cast(ppArg), &argRef); *ppArgRef = static_cast(argRef); return rv; } diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 4d911f00fa4..4ce155f1f5b 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -3677,8 +3677,7 @@ class CastableObjectUnwrapper(): // want to be in that compartment for the UnwrapArg call. JS::Rooted source(cx, ${source}); JSAutoCompartment ac(cx, ${source}); - JS::Rooted unused(cx); - rv = UnwrapArg<${type}>(cx, source, &objPtr, &objRef.ptr, &unused); + rv = UnwrapArg<${type}>(cx, source, &objPtr, &objRef.ptr); } """) else: @@ -3686,8 +3685,7 @@ class CastableObjectUnwrapper(): self.substitution["source"] = source xpconnectUnwrap = ( "JS::Rooted source(cx, ${source});\n" - "JS::Rooted unused(cx);\n" - "nsresult rv = UnwrapArg<${type}>(cx, source, &objPtr, &objRef.ptr, &unused);\n") + "nsresult rv = UnwrapArg<${type}>(cx, source, &objPtr, &objRef.ptr);\n") if descriptor.hasXPConnectImpls: self.substitution["codeOnFailure"] = string.Template( @@ -4767,24 +4765,18 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, else: holderType = "nsRefPtr<" + typeName + ">" templateBody += ( - "JS::Rooted source(cx, &${val}.toObject());\n" - "JS::Rooted tmpVal(cx);\n" + + "JS::Rooted source(cx, &${val}.toObject());\n" + typePtr + " tmp;\n" - "if (NS_FAILED(UnwrapArg<" + typeName + ">(cx, source, &tmp, static_cast<" + typeName + "**>(getter_AddRefs(${holderName})), &tmpVal))) {\n") + "if (NS_FAILED(UnwrapArg<" + typeName + ">(cx, source, &tmp, static_cast<" + typeName + "**>(getter_AddRefs(${holderName}))))) {\n") templateBody += CGIndenter(onFailureBadType(failureCode, descriptor.interface.identifier.name)).define() templateBody += ("}\n" "MOZ_ASSERT(tmp);\n") if not isDefinitelyObject and not forceOwningType: - # Our tmpVal will go out of scope, so we can't rely on it - # for rooting templateBody += dedent(""" - if (tmpVal != ${val} && !${holderName}) { - // We have to have a strong ref, because we got this off - // some random object that might get GCed - ${holderName} = tmp; - } + // UnwrapArg never sets **ppArg without also setting *ppArgRef + MOZ_ASSERT(${holderName}); """) # And store our tmp, before it goes out of scope. diff --git a/js/xpconnect/src/XPCQuickStubs.cpp b/js/xpconnect/src/XPCQuickStubs.cpp index c93190756bd..d20df99f833 100644 --- a/js/xpconnect/src/XPCQuickStubs.cpp +++ b/js/xpconnect/src/XPCQuickStubs.cpp @@ -24,8 +24,7 @@ xpc_qsUnwrapArgImpl(JSContext *cx, HandleObject src, const nsIID &iid, void **ppArg, - nsISupports **ppArgRef, - MutableHandleValue vp) + nsISupports **ppArgRef) { nsISupports *iface = xpc::UnwrapReflectorToISupports(src); if (iface) { @@ -59,7 +58,6 @@ xpc_qsUnwrapArgImpl(JSContext *cx, rv = wrappedJS->QueryInterface(iid, ppArg); if (NS_SUCCEEDED(rv)) { *ppArgRef = static_cast(*ppArg); - vp.setObjectOrNull(wrappedJS->GetJSObject()); } return rv; } diff --git a/js/xpconnect/src/XPCQuickStubs.h b/js/xpconnect/src/XPCQuickStubs.h index 33371419636..585965a3d93 100644 --- a/js/xpconnect/src/XPCQuickStubs.h +++ b/js/xpconnect/src/XPCQuickStubs.h @@ -13,6 +13,6 @@ nsresult xpc_qsUnwrapArgImpl(JSContext *cx, JS::HandleObject src, const nsIID &iid, void **ppArg, - nsISupports **ppArgRef, JS::MutableHandleValue vp); + nsISupports **ppArgRef); #endif /* xpcquickstubs_h___ */