Bug 738769 - only unmark purple if purple. r=smaug
authorAndrew McCreight <amccreight@mozilla.com>
Mon, 26 Mar 2012 09:57:29 -0700
changeset 93635 f01aac7289844cf5f24a43c858e5cd027825dfeb
parent 93634 ffba0c9081bd55d06f3ecf0817e8a867dda2ca2c
child 93636 263150bd32bbd4e3696f246c717023b3ef52d675
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs738769
milestone14.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 738769 - only unmark purple if purple. r=smaug
xpcom/base/nsAgg.h
xpcom/base/nsCycleCollector.cpp
xpcom/glue/nsCycleCollectionParticipant.cpp
xpcom/glue/nsCycleCollectionParticipant.h
xpcom/glue/nsISupportsImpl.h
--- a/xpcom/base/nsAgg.h
+++ b/xpcom/base/nsAgg.h
@@ -102,19 +102,19 @@ public:                                 
 #define NS_DECL_AGGREGATED_CYCLE_COLLECTION_CLASS(_class)                   \
 class NS_CYCLE_COLLECTION_INNERCLASS                                        \
  : public nsXPCOMCycleCollectionParticipant                                 \
 {                                                                           \
 public:                                                                     \
   NS_IMETHOD Unlink(void *p);                                               \
   NS_IMETHOD Traverse(void *p,                                              \
                       nsCycleCollectionTraversalCallback &cb);              \
-  NS_IMETHOD_(void) UnmarkPurple(nsISupports *p)                            \
+  NS_IMETHOD_(void) UnmarkIfPurple(nsISupports *p)                          \
   {                                                                         \
-    Downcast(p)->UnmarkPurple();                                            \
+    Downcast(p)->UnmarkIfPurple();                                          \
   }                                                                         \
   static _class* Downcast(nsISupports* s)                                   \
   {                                                                         \
     return (_class*)((char*)(s) - offsetof(_class, fAggregated));           \
   }                                                                         \
   static nsISupports* Upcast(_class *p)                                     \
   {                                                                         \
     return p->InnerObject();                                                \
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -885,17 +885,17 @@ public:
              e != eEnd; ++e) {
             if (!(PRUword(e->mObject) & PRUword(1))) {
                 // This is a real entry (rather than something on the
                 // free list).
                 if (e->mObject) {
                     nsXPCOMCycleCollectionParticipant *cp;
                     ToParticipant(e->mObject, &cp);
 
-                    cp->UnmarkPurple(e->mObject);
+                    cp->UnmarkIfPurple(e->mObject);
                 }
 
                 if (--mCount == 0)
                     break;
             }
         }
     }
 
@@ -2138,17 +2138,17 @@ AddPurpleRoot(GCGraphBuilder &builder, n
     if (builder.WantAllTraces() || !cp->CanSkipInCC(root)) {
         PtrInfo *pinfo = builder.AddNode(root, cp,
                                          nsIProgrammingLanguage::CPLUSPLUS);
         if (!pinfo) {
             return false;
         }
     }
 
-    cp->UnmarkPurple(root);
+    cp->UnmarkIfPurple(root);
 
     return true;
 }
 
 static bool
 MayHaveChild(nsISupports *o, nsXPCOMCycleCollectionParticipant* cp)
 {
     ChildFinder cf;
@@ -2170,17 +2170,17 @@ nsPurpleBuffer::RemoveSkippable(bool rem
                 if (e->mObject) {
                     nsISupports* o = canonicalize(e->mObject);
                     nsXPCOMCycleCollectionParticipant* cp;
                     ToParticipant(o, &cp);
                     if (!cp->CanSkip(o, false) &&
                         (!removeChildlessNodes || MayHaveChild(o, cp))) {
                         continue;
                     }
-                    cp->UnmarkPurple(o);
+                    cp->UnmarkIfPurple(o);
                 }
                 Remove(e);
             }
         }
     }
 }
 
 #ifdef DEBUG_CC
--- a/xpcom/glue/nsCycleCollectionParticipant.cpp
+++ b/xpcom/glue/nsCycleCollectionParticipant.cpp
@@ -80,17 +80,17 @@ nsXPCOMCycleCollectionParticipant::Unroo
 nsresult
 nsXPCOMCycleCollectionParticipant::Traverse
     (void *p, nsCycleCollectionTraversalCallback &cb)
 {
   return NS_OK;
 }
 
 void
-nsXPCOMCycleCollectionParticipant::UnmarkPurple(nsISupports *n)
+nsXPCOMCycleCollectionParticipant::UnmarkIfPurple(nsISupports *n)
 {
 }
 
 NS_IMETHODIMP_(void)
 nsXPCOMCycleCollectionParticipant::Trace(void *p, TraceCallback cb,
                                          void *closure)
 {
 }
--- a/xpcom/glue/nsCycleCollectionParticipant.h
+++ b/xpcom/glue/nsCycleCollectionParticipant.h
@@ -221,17 +221,17 @@ public:
     NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb);
 
     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);
+    NS_IMETHOD_(void) UnmarkIfPurple(nsISupports *p);
 
     bool CheckForRightISupports(nsISupports *s);
 };
 
 #undef IMETHOD_VISIBILITY
 #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -588,19 +588,19 @@ public:
 
 #define NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE                               \
   static NS_CYCLE_COLLECTION_INNERCLASS NS_CYCLE_COLLECTION_INNERNAME;
 
 #define NS_DECL_CYCLE_COLLECTION_CLASS_BODY_NO_UNLINK(_class, _base)           \
 public:                                                                        \
   NS_IMETHOD Traverse(void *p,                                                 \
                       nsCycleCollectionTraversalCallback &cb);                 \
-  NS_IMETHOD_(void) UnmarkPurple(nsISupports *s)                               \
+  NS_IMETHOD_(void) UnmarkIfPurple(nsISupports *s)                             \
   {                                                                            \
-    Downcast(s)->UnmarkPurple();                                               \
+    Downcast(s)->UnmarkIfPurple();                                             \
   }                                                                            \
   static _class* Downcast(nsISupports* s)                                      \
   {                                                                            \
     return static_cast<_class*>(static_cast<_base*>(s));                       \
   }                                                                            \
   static nsISupports* Upcast(_class *p)                                        \
   {                                                                            \
     return NS_ISUPPORTS_CAST(_base*, p);                                       \
@@ -753,23 +753,23 @@ class NS_CYCLE_COLLECTION_INNERCLASS    
 {                                                                              \
 public:                                                                        \
   NS_IMETHOD_(void) Trace(void *p, TraceCallback cb, void *closure);           \
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_BODY(_class, _base_class)           \
 };                                                                             \
 NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
 
 /**
- * This implements a stub UnmarkPurple function for classes that want to be
+ * This implements a stub UnmarkIfPurple function for classes that want to be
  * traversed but whose AddRef/Release functions don't add/remove them to/from
  * the purple buffer. If you're just using NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  * then you don't need this.
  */
 #define NS_DECL_CYCLE_COLLECTION_UNMARK_PURPLE_STUB(_class)                    \
-  NS_IMETHODIMP_(void) UnmarkPurple()                                          \
+  NS_IMETHODIMP_(void) UnmarkIfPurple()                                        \
   {                                                                            \
   }                                                                            \
 
 #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:                                                                      \
--- a/xpcom/glue/nsISupportsImpl.h
+++ b/xpcom/glue/nsISupportsImpl.h
@@ -303,19 +303,20 @@ protected:                              
 public:
 
 #define NS_DECL_CYCLE_COLLECTING_ISUPPORTS                                    \
 public:                                                                       \
   NS_IMETHOD QueryInterface(REFNSIID aIID,                                    \
                             void** aInstancePtr);                             \
   NS_IMETHOD_(nsrefcnt) AddRef(void);                                         \
   NS_IMETHOD_(nsrefcnt) Release(void);                                        \
-  void UnmarkPurple()                                                         \
+  void UnmarkIfPurple()                                                       \
   {                                                                           \
-    mRefCnt.unmarkPurple();                                                   \
+    if (NS_LIKELY(mRefCnt.IsPurple()))                                        \
+      mRefCnt.unmarkPurple();                                                 \
   }                                                                           \
 protected:                                                                    \
   nsCycleCollectingAutoRefCnt mRefCnt;                                        \
   NS_DECL_OWNINGTHREAD                                                        \
 public:
 
 
 ///////////////////////////////////////////////////////////////////////////////