Bug 1381921, part 1 - Remove nsIXPConnect::CurrentNativeCallContext. r=mrbkap
authorAndrew McCreight <continuation@gmail.com>
Tue, 18 Jul 2017 10:36:05 -0700
changeset 418772 034a44ef2565fffa48a75fcdb6036ca6cdba32be
parent 418771 e357672c1dd1b9723a55188d8be3bbecac7d7902
child 418773 a2c953a33338eeed468c74744a75e7b330beaf0e
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1381921
milestone56.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 1381921, part 1 - Remove nsIXPConnect::CurrentNativeCallContext. r=mrbkap It is only called in a single place, and can't be called from JS, so inline it and eliminate it. MozReview-Commit-ID: DWfyfoO5Zht
js/xpconnect/idl/nsIXPConnect.idl
js/xpconnect/src/Sandbox.cpp
js/xpconnect/src/nsXPConnect.cpp
--- a/js/xpconnect/idl/nsIXPConnect.idl
+++ b/js/xpconnect/idl/nsIXPConnect.idl
@@ -12,32 +12,30 @@
 #include "jspubtd.h"
 #include "js/TypeDecls.h"
 #include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
 
 struct JSFreeOp;
 
 class nsWrapperCache;
-class nsAXPCNativeCallContext;
 %}
 
 /***************************************************************************/
 
 // NB: jsval and jsid are declared in nsrootidl.idl
 
 [ptr] native JSContextPtr(JSContext);
 [ptr] native JSClassPtr(JSClass);
 [ptr] native JSFreeOpPtr(JSFreeOp);
 [ptr] native JSObjectPtr(JSObject);
 [ptr] native JSValConstPtr(const JS::Value);
       native JSEqualityOp(JSEqualityOp);
 [ptr] native JSScriptPtr(JSScript);
 [ptr] native voidPtrPtr(void*);
-[ptr] native nsAXPCNativeCallContextPtr(nsAXPCNativeCallContext);
 [ptr] native nsWrapperCachePtr(nsWrapperCache);
 [ref] native JSCompartmentOptions(JS::CompartmentOptions);
 [ref] native JSCallArgsRef(const JS::CallArgs);
       native JSHandleId(JS::Handle<jsid>);
 
 /***************************************************************************/
 
 // forward declarations...
@@ -410,17 +408,16 @@ interface nsIXPConnect : nsISupports
     * A new wrapper is *never* constructed.
     */
     nsIXPConnectWrappedNative
     getWrappedNativeOfJSObject(in JSContextPtr aJSContext,
                                in JSObjectPtr  aJSObj);
 
     // Will return null if there is no JS stack right now.
     readonly attribute nsIStackFrame                CurrentJSStack;
-    readonly attribute nsAXPCNativeCallContextPtr   CurrentNativeCallContext;
 
     void debugDump(in short depth);
     void debugDumpObject(in nsISupports aCOMObj, in short depth);
     void debugDumpJSStack(in boolean showArgs,
                           in boolean showLocals,
                           in boolean showThisProps);
 
     /**
--- a/js/xpconnect/src/Sandbox.cpp
+++ b/js/xpconnect/src/Sandbox.cpp
@@ -1698,25 +1698,23 @@ SandboxOptions::Parse()
 
 static nsresult
 AssembleSandboxMemoryReporterName(JSContext* cx, nsCString& sandboxName)
 {
     // Use a default name when the caller did not provide a sandboxName.
     if (sandboxName.IsEmpty())
         sandboxName = NS_LITERAL_CSTRING("[anonymous sandbox]");
 
-    nsXPConnect* xpc = nsXPConnect::XPConnect();
     // Get the xpconnect native call context.
-    nsAXPCNativeCallContext* cc = nullptr;
-    xpc->GetCurrentNativeCallContext(&cc);
+    XPCCallContext* cc = XPCJSContext::Get()->GetCallContext();
     NS_ENSURE_TRUE(cc, NS_ERROR_INVALID_ARG);
 
     // Get the current source info from xpc.
     nsCOMPtr<nsIStackFrame> frame;
-    xpc->GetCurrentJSStack(getter_AddRefs(frame));
+    nsXPConnect::XPConnect()->GetCurrentJSStack(getter_AddRefs(frame));
 
     // Append the caller's location information.
     if (frame) {
         nsString location;
         int32_t lineNumber = 0;
         frame->GetFilename(cx, location);
         frame->GetLineNumber(cx, &lineNumber);
 
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -832,25 +832,16 @@ nsXPConnect::GetCurrentJSStack(nsIStackF
 
     nsCOMPtr<nsIStackFrame> currentStack = dom::GetCurrentJSStack();
     currentStack.forget(aCurrentJSStack);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsXPConnect::GetCurrentNativeCallContext(nsAXPCNativeCallContext * *aCurrentNativeCallContext)
-{
-    MOZ_ASSERT(aCurrentNativeCallContext, "bad param");
-
-    *aCurrentNativeCallContext = XPCJSContext::Get()->GetCallContext();
-    return NS_OK;
-}
-
-NS_IMETHODIMP
 nsXPConnect::SetFunctionThisTranslator(const nsIID & aIID,
                                        nsIXPCFunctionThisTranslator* aTranslator)
 {
     XPCJSRuntime* rt = GetRuntimeInstance();
     IID2ThisTranslatorMap* map = rt->GetThisTranslatorMap();
     map->Add(aIID, aTranslator);
     return NS_OK;
 }