Bug 997440 - Stop associating XPCWrappedNativeScopes with an XPCContext. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Tue, 20 May 2014 22:52:20 -0700
changeset 184064 f22f1c4043f91edc0470836e39f2f91f8176a5ea
parent 184063 e55153ae25397010e9eab1b8211e65ca6414a459
child 184065 f135d712226282c51ec27973dfc344a16421ecbe
push id26810
push usercbook@mozilla.com
push dateWed, 21 May 2014 11:46:36 +0000
treeherdermozilla-central@50fb8c4db2fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs997440
milestone32.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 997440 - Stop associating XPCWrappedNativeScopes with an XPCContext. r=bz
js/xpconnect/src/XPCContext.cpp
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/xpcprivate.h
--- a/js/xpconnect/src/XPCContext.cpp
+++ b/js/xpconnect/src/XPCContext.cpp
@@ -17,36 +17,25 @@ XPCContext::XPCContext(XPCJSRuntime* aRu
     :   mRuntime(aRuntime),
         mJSContext(aJSContext),
         mLastResult(NS_OK),
         mPendingResult(NS_OK),
         mCallingLangType(LANG_UNKNOWN)
 {
     MOZ_COUNT_CTOR(XPCContext);
 
-    PR_INIT_CLIST(&mScopes);
-
     MOZ_ASSERT(!JS_GetSecondContextPrivate(mJSContext), "Must be null");
     JS_SetSecondContextPrivate(mJSContext, this);
 }
 
 XPCContext::~XPCContext()
 {
     MOZ_COUNT_DTOR(XPCContext);
     MOZ_ASSERT(JS_GetSecondContextPrivate(mJSContext) == this, "Must match this");
     JS_SetSecondContextPrivate(mJSContext, nullptr);
-
-    // Iterate over our scopes and tell them that we have been destroyed
-    for (PRCList *scopeptr = PR_NEXT_LINK(&mScopes);
-         scopeptr != &mScopes;
-         scopeptr = PR_NEXT_LINK(scopeptr)) {
-        XPCWrappedNativeScope *scope =
-            static_cast<XPCWrappedNativeScope*>(scopeptr);
-        scope->ClearContext();
-    }
 }
 
 void
 XPCContext::DebugDump(int16_t depth)
 {
 #ifdef DEBUG
     depth--;
     XPC_LOG_ALWAYS(("XPCContext @ %x", this));
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -84,20 +84,16 @@ XPCWrappedNativeScope::XPCWrappedNativeS
                    mozilla::dom::IsDOMClass(clasp));
 #ifdef DEBUG
         for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext)
             MOZ_ASSERT(aGlobal != cur->GetGlobalJSObjectPreserveColor(), "dup object");
 #endif
 
         mNext = gScopes;
         gScopes = this;
-
-        // Grab the XPCContext associated with our context.
-        mContext = XPCContext::GetXPCContext(cx);
-        mContext->AddScope(this);
     }
 
     MOZ_COUNT_CTOR(XPCWrappedNativeScope);
 
     // Attach ourselves to the compartment private.
     CompartmentPrivate *priv = EnsureCompartmentPrivate(aGlobal);
     priv->scope = this;
 
@@ -287,19 +283,16 @@ XPCWrappedNativeScope::~XPCWrappedNative
         delete mWrappedNativeMap;
     }
 
     if (mWrappedNativeProtoMap) {
         MOZ_ASSERT(0 == mWrappedNativeProtoMap->Count(), "scope has non-empty map");
         delete mWrappedNativeProtoMap;
     }
 
-    if (mContext)
-        mContext->RemoveScope(this);
-
     // This should not be necessary, since the Components object should die
     // with the scope but just in case.
     if (mComponents)
         mComponents->mScope = nullptr;
 
     // XXX we should assert that we are dead or that xpconnect has shutdown
     // XXX might not want to do this at xpconnect shutdown time???
     mComponents = nullptr;
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -667,18 +667,16 @@ public:
 
     nsresult GetLastResult() {return mLastResult;}
     void SetLastResult(nsresult rc) {mLastResult = rc;}
 
     nsresult GetPendingResult() {return mPendingResult;}
     void SetPendingResult(nsresult rc) {mPendingResult = rc;}
 
     void DebugDump(int16_t depth);
-    void AddScope(PRCList *scope) { PR_INSERT_AFTER(scope, &mScopes); }
-    void RemoveScope(PRCList *scope) { PR_REMOVE_LINK(scope); }
 
     void MarkErrorUnreported() { mErrorUnreported = true; }
     void ClearUnreportedError() { mErrorUnreported = false; }
     bool WasErrorReported() { return !mErrorUnreported; }
 
     ~XPCContext();
 
 private:
@@ -690,19 +688,16 @@ private:
 private:
     XPCJSRuntime* mRuntime;
     JSContext*  mJSContext;
     nsresult mLastResult;
     nsresult mPendingResult;
     nsCOMPtr<nsIException> mException;
     LangType mCallingLangType;
     bool mErrorUnreported;
-
-    // A linked list of scopes to notify when we are destroyed.
-    PRCList mScopes;
 };
 
 /***************************************************************************/
 
 #define NATIVE_CALLER  XPCContext::LANG_NATIVE
 #define JS_CALLER      XPCContext::LANG_JS
 
 // No virtuals
@@ -1075,19 +1070,16 @@ public:
     AddSizeOfIncludingThis(ScopeSizeInfo* scopeSizeInfo);
 
     bool
     IsValid() const {return mRuntime != nullptr;}
 
     static bool
     IsDyingScope(XPCWrappedNativeScope *scope);
 
-    XPCContext *GetContext() { return mContext; }
-    void ClearContext() { mContext = nullptr; }
-
     typedef js::HashSet<JSObject *,
                         js::PointerHasher<JSObject *, 3>,
                         js::SystemAllocPolicy> DOMExpandoSet;
 
     bool RegisterDOMExpandoObject(JSObject *expando) {
         // Expandos are proxy objects, and proxies are always tenured.
         JS::AssertGCThingMustBeTenured(expando);
         if (!mDOMExpandoSet) {
@@ -1136,18 +1128,16 @@ private:
     // constructor).
     JS::ObjectPtr                    mGlobalJSObject;
 
     // XBL Scope. This is is a lazily-created sandbox for non-system scopes.
     // EnsureXBLScope() decides whether it needs to be created or not.
     // This reference is wrapped into the compartment of mGlobalJSObject.
     JS::ObjectPtr                    mXBLScope;
 
-    XPCContext*                      mContext;
-
     nsAutoPtr<DOMExpandoSet> mDOMExpandoSet;
 
     JS::WeakMapPtr<JSObject*, JSObject*> mXrayExpandos;
 
     bool mIsXBLScope;
 
     // For remote XUL domains, we run all XBL in the content scope for compat
     // reasons (though we sometimes pref this off for automation). We separately