Fix for bug 584048 (Clean up cycle collection code) - rename RootAndUnlinkJSObjects to Root. r=bent.
authorPeter Van der Beken <peterv@propagandism.org>
Thu, 16 Dec 2010 16:30:13 +0100
changeset 67681 8ad9f3559f4383d66ce72c71a37d7e831acac0f5
parent 67680 92c7b48558d51624e4c9b077100197b45be2d911
child 67682 9158c75748f8f72eddb86e56b50636c8313352c4
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs584048
milestone2.2a1pre
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 584048 (Clean up cycle collection code) - rename RootAndUnlinkJSObjects to Root. r=bent.
js/src/xpconnect/src/nsXPConnect.cpp
js/src/xpconnect/src/xpcprivate.h
xpcom/base/nsCycleCollector.cpp
xpcom/glue/nsCycleCollectionParticipant.cpp
xpcom/glue/nsCycleCollectionParticipant.h
--- a/js/src/xpconnect/src/nsXPConnect.cpp
+++ b/js/src/xpconnect/src/nsXPConnect.cpp
@@ -533,17 +533,17 @@ nsCycleCollectionParticipant *
 nsXPConnect::ToParticipant(void *p)
 {
     if (!ADD_TO_CC(js_GetGCThingTraceKind(p)))
         return NULL;
     return this;
 }
 
 NS_IMETHODIMP
-nsXPConnect::RootAndUnlinkJSObjects(void *p)
+nsXPConnect::Root(void *p)
 {
     return NS_OK;
 }
 
 #ifdef DEBUG_CC
 void
 nsXPConnect::PrintAllReferencesTo(void *p)
 {
@@ -859,17 +859,17 @@ nsXPConnect::GetOutstandingRequests(JSCo
         --n;
     }
     return n;
 }
 
 class JSContextParticipant : public nsCycleCollectionParticipant
 {
 public:
-    NS_IMETHOD RootAndUnlinkJSObjects(void *n)
+    NS_IMETHOD Root(void *n)
     {
         return NS_OK;
     }
     NS_IMETHOD Unlink(void *n)
     {
         JSContext *cx = static_cast<JSContext*>(n);
         NS_ASSERTION(cx->globalObject, "global object NULL before unlinking");
         cx->globalObject = nsnull;
--- a/js/src/xpconnect/src/xpcprivate.h
+++ b/js/src/xpconnect/src/xpcprivate.h
@@ -549,17 +549,17 @@ public:
 
     static nsresult Base64Decode(const nsAString &aBinaryData,
                                  nsAString &aString);
 
     // If this returns JS_FALSE then an exception will be set on cx.
     static JSBool Base64Decode(JSContext *cx, jsval val, jsval *out);
 
     // nsCycleCollectionParticipant
-    NS_IMETHOD RootAndUnlinkJSObjects(void *p);
+    NS_IMETHOD Root(void *p);
     NS_IMETHOD Unlink(void *p);
     NS_IMETHOD Unroot(void *p);
     NS_IMETHOD Traverse(void *p,
                         nsCycleCollectionTraversalCallback &cb);
     
     // nsCycleCollectionLanguageRuntime
     virtual nsresult BeginCycleCollection(nsCycleCollectionTraversalCallback &cb,
                                           bool explainExpectedLiveGarbage);
@@ -2449,17 +2449,17 @@ public:
     // root/unrooting the JS objects from addrefing/releasing the
     // XPCWrappedNative during unlinking, which would make the JS objects
     // uncollectable to the JS GC.
     class NS_CYCLE_COLLECTION_INNERCLASS
      : public nsXPCOMCycleCollectionParticipant
     {
       NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(XPCWrappedNative,
                                                     XPCWrappedNative)
-      NS_IMETHOD RootAndUnlinkJSObjects(void *p) { return NS_OK; }
+      NS_IMETHOD Root(void *p) { return NS_OK; }
       NS_IMETHOD Unlink(void *p);
       NS_IMETHOD Unroot(void *p) { return NS_OK; }
     };
     NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
     NS_DECL_CYCLE_COLLECTION_UNMARK_PURPLE_STUB(XPCWrappedNative)
 
 #ifndef XPCONNECT_STANDALONE
     nsIPrincipal* GetObjectPrincipal() const;
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -1892,17 +1892,17 @@ nsCycleCollector::RootWhite()
 
     mWhiteNodes->SetCapacity(mWhiteNodeCount);
 
     NodePool::Enumerator etor(mGraph.mNodes);
     while (!etor.IsDone())
     {
         PtrInfo *pinfo = etor.GetNext();
         if (pinfo->mColor == white && mWhiteNodes->AppendElement(pinfo)) {
-            rv = pinfo->mParticipant->RootAndUnlinkJSObjects(pinfo->mPointer);
+            rv = pinfo->mParticipant->Root(pinfo->mPointer);
             if (NS_FAILED(rv)) {
                 Fault("Failed root call while unlinking", pinfo);
                 mWhiteNodes->RemoveElementAt(mWhiteNodes->Length() - 1);
             }
         }
     }
 }
 
--- a/xpcom/glue/nsCycleCollectionParticipant.cpp
+++ b/xpcom/glue/nsCycleCollectionParticipant.cpp
@@ -49,17 +49,17 @@ NoteChild(PRUint32 aLangID, void *aScrip
 void
 nsScriptObjectTracer::TraverseScriptObjects(void *p,
                                         nsCycleCollectionTraversalCallback &cb)
 {
   Trace(p, NoteChild, &cb);
 }
 
 nsresult
-nsXPCOMCycleCollectionParticipant::RootAndUnlinkJSObjects(void *p)
+nsXPCOMCycleCollectionParticipant::Root(void *p)
 {
     nsISupports *s = static_cast<nsISupports*>(p);
     NS_ADDREF(s);
     return NS_OK;
 }
 
 nsresult
 nsXPCOMCycleCollectionParticipant::Unlink(void *p)
--- a/xpcom/glue/nsCycleCollectionParticipant.h
+++ b/xpcom/glue/nsCycleCollectionParticipant.h
@@ -131,17 +131,17 @@ protected:
 
 class NS_NO_VTABLE nsCycleCollectionParticipant
 {
 public:
     NS_DECLARE_STATIC_IID_ACCESSOR(NS_CYCLECOLLECTIONPARTICIPANT_IID)
 
     NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb) = 0;
 
-    NS_IMETHOD RootAndUnlinkJSObjects(void *p) = 0;
+    NS_IMETHOD Root(void *p) = 0;
     NS_IMETHOD Unlink(void *p) = 0;
     NS_IMETHOD Unroot(void *p) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsCycleCollectionParticipant, 
                               NS_CYCLECOLLECTIONPARTICIPANT_IID)
 
 #undef IMETHOD_VISIBILITY
@@ -159,17 +159,17 @@ public:
 };
 
 class NS_COM_GLUE nsXPCOMCycleCollectionParticipant
     : public nsScriptObjectTracer
 {
 public:
     NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb);
 
-    NS_IMETHOD RootAndUnlinkJSObjects(void *p);
+    NS_IMETHOD Root(void *p);
     NS_IMETHOD Unlink(void *p);
     NS_IMETHOD Unroot(void *p);
 
     NS_IMETHOD_(void) Trace(void *p, TraceCallback cb, void *closure);
 
     NS_IMETHOD_(void) UnmarkPurple(nsISupports *p);
 
     PRBool CheckForRightISupports(nsISupports *s);
@@ -239,41 +239,16 @@ public:
       return NS_OK;                                                           \
     }                                                                         \
     nsresult rv;
 
 #define NS_CYCLE_COLLECTION_UPCAST(obj, clazz)                                 \
   NS_CYCLE_COLLECTION_CLASSNAME(clazz)::Upcast(obj)
 
 ///////////////////////////////////////////////////////////////////////////////
-// Helpers for implementing nsCycleCollectionParticipant::RootAndUnlinkJSObjects
-///////////////////////////////////////////////////////////////////////////////
-
-#define NS_IMPL_CYCLE_COLLECTION_ROOT_BEGIN(_class)                            \
-  NS_IMETHODIMP                                                                \
-  NS_CYCLE_COLLECTION_CLASSNAME(_class)::RootAndUnlinkJSObjects(void *p)       \
-  {                                                                            \
-    nsISupports *s = static_cast<nsISupports*>(p);                             \
-    NS_ASSERTION(CheckForRightISupports(s),                                    \
-                 "not the nsISupports pointer we expect");                     \
-    nsXPCOMCycleCollectionParticipant::RootAndUnlinkJSObjects(s);              \
-    _class *tmp = Downcast(s);
-
-#define NS_IMPL_CYCLE_COLLECTION_ROOT_BEGIN_NATIVE(_class, _root_function)     \
-  NS_IMETHODIMP                                                                \
-  NS_CYCLE_COLLECTION_CLASSNAME(_class)::RootAndUnlinkJSObjects(void *p)       \
-  {                                                                            \
-    _class *tmp = static_cast<_class*>(p);                                     \
-    tmp->_root_function();
-
-#define NS_IMPL_CYCLE_COLLECTION_ROOT_END                                      \
-    return NS_OK;                                                              \
-  }
-
-///////////////////////////////////////////////////////////////////////////////
 // Helpers for implementing nsCycleCollectionParticipant::Unlink
 ///////////////////////////////////////////////////////////////////////////////
 
 #define NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class)                          \
   NS_IMETHODIMP                                                                \
   NS_CYCLE_COLLECTION_CLASSNAME(_class)::Unlink(void *p)                       \
   {                                                                            \
     nsISupports *s = static_cast<nsISupports*>(p);                             \
@@ -517,23 +492,23 @@ class NS_CYCLE_COLLECTION_INNERCLASS    
 };                                                                             \
 NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
 
 #define NS_DECL_CYCLE_COLLECTION_CLASS(_class)                                 \
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(_class, _class)
 
 // Cycle collector helper for classes that don't want to unlink anything.
 // Note: if this is used a lot it might make sense to have a base class that
-//       doesn't do anything in RootAndUnlinkJSObjects/Unlink/Unroot.
+//       doesn't do anything in Root/Unlink/Unroot.
 #define NS_DECL_CYCLE_COLLECTION_CLASS_NO_UNLINK(_class)                       \
 class NS_CYCLE_COLLECTION_INNERCLASS                                           \
  : public nsXPCOMCycleCollectionParticipant                                    \
 {                                                                              \
   NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _class)                \
-  NS_IMETHOD RootAndUnlinkJSObjects(void *p)                                   \
+  NS_IMETHOD Root(void *p)                                                     \
   {                                                                            \
     return NS_OK;                                                              \
   }                                                                            \
   NS_IMETHOD Unlink(void *p)                                                   \
   {                                                                            \
     return NS_OK;                                                              \
   }                                                                            \
   NS_IMETHOD Unroot(void *p)                                                   \
@@ -611,17 +586,17 @@ NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
   {                                                                            \
   }                                                                            \
 
 #define NS_IMPL_CYCLE_COLLECTION_CLASS(_class)                                 \
   NS_CYCLE_COLLECTION_CLASSNAME(_class) NS_CYCLE_COLLECTION_NAME(_class);
 
 #define NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY                             \
   public:                                                                      \
-    NS_IMETHOD RootAndUnlinkJSObjects(void *n);                                \
+    NS_IMETHOD Root(void *n);                                                  \
     NS_IMETHOD Unlink(void *n);                                                \
     NS_IMETHOD Unroot(void *n);                                                \
     NS_IMETHOD Traverse(void *n,                                               \
                       nsCycleCollectionTraversalCallback &cb);
 
 #define NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(_class)                          \
   class NS_CYCLE_COLLECTION_INNERCLASS                                         \
    : public nsCycleCollectionParticipant                                       \
@@ -636,17 +611,17 @@ NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
   {                                                                            \
     NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS_BODY                                 \
     NS_IMETHOD_(void) Trace(void *p, TraceCallback cb, void *closure);         \
   };                                                                           \
   NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
 
 #define NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(_class, _root_function)           \
   NS_IMETHODIMP                                                                \
-  NS_CYCLE_COLLECTION_CLASSNAME(_class)::RootAndUnlinkJSObjects(void *p)       \
+  NS_CYCLE_COLLECTION_CLASSNAME(_class)::Root(void *p)                         \
   {                                                                            \
     _class *tmp = static_cast<_class*>(p);                                     \
     tmp->_root_function();                                                     \
     return NS_OK;                                                              \
   }
 
 #define NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(_class, _unroot_function)       \
   NS_IMETHODIMP                                                                \