Bug 815707 - clean up cycle collector Traverse/Unlink in parser/ r=smaug
authorAndrew McCreight <amccreight@mozilla.com>
Tue, 27 Nov 2012 15:08:22 -0800
changeset 114303 b412fee450e2857387bc2d596aa8976d12c5673a
parent 114302 53c6c1be81cfb5ffce611b8509687a7c08b4686b
child 114304 795294e974850ca4abe9574072ea3677dc71776a
push id23913
push useremorley@mozilla.com
push dateWed, 28 Nov 2012 17:11:31 +0000
treeherdermozilla-central@17c267a881cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs815707
milestone20.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 815707 - clean up cycle collector Traverse/Unlink in parser/ r=smaug
parser/html/nsHtml5StreamParser.cpp
parser/html/nsHtml5TreeOpExecutor.cpp
parser/xml/src/nsSAXXMLReader.cpp
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -78,44 +78,40 @@ NS_INTERFACE_TABLE_HEAD(nsHtml5StreamPar
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsHtml5StreamParser)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsHtml5StreamParser)
   tmp->DropTimer();
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mObserver)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mRequest)
-  tmp->mOwner = nullptr;
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner)
   tmp->mExecutorFlusher = nullptr;
   tmp->mLoadFlusher = nullptr;
   tmp->mExecutor = nullptr;
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mChardet)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsHtml5StreamParser)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mObserver)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRequest)
-  if (tmp->mOwner) {
-    NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mOwner");
-    cb.NoteXPCOMChild(static_cast<nsIParser*> (tmp->mOwner));
-  }
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
   // hack: count the strongly owned edge wrapped in the runnable
   if (tmp->mExecutorFlusher) {
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExecutorFlusher->mExecutor");
     cb.NoteXPCOMChild(static_cast<nsIContentSink*> (tmp->mExecutor));
   }
   // hack: count the strongly owned edge wrapped in the runnable
   if (tmp->mLoadFlusher) {
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mLoadFlusher->mExecutor");
     cb.NoteXPCOMChild(static_cast<nsIContentSink*> (tmp->mExecutor));
   }
   // hack: count self if held by mChardet
   if (tmp->mChardet) {
-    NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, 
-      "mChardet->mObserver");
+    NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mChardet->mObserver");
     cb.NoteXPCOMChild(static_cast<nsIStreamListener*>(tmp));
   }
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 class nsHtml5ExecutorFlusher : public nsRunnable
 {
   private:
     nsRefPtr<nsHtml5TreeOpExecutor> mExecutor;
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -30,35 +30,28 @@
 #include "nsIScriptError.h"
 #include "nsIScriptContext.h"
 #include "mozilla/Preferences.h"
 #include "nsIHTMLDocument.h"
 #include "mozilla/Likely.h"
 
 using namespace mozilla;
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsHtml5TreeOpExecutor)
+NS_IMPL_CYCLE_COLLECTION_INHERITED_1(nsHtml5TreeOpExecutor, nsContentSink,
+                                     mOwnedElements)
 
 NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHtml5TreeOpExecutor)
   NS_INTERFACE_TABLE_INHERITED1(nsHtml5TreeOpExecutor, 
                                 nsIContentSink)
 NS_INTERFACE_TABLE_TAIL_INHERITING(nsContentSink)
 
 NS_IMPL_ADDREF_INHERITED(nsHtml5TreeOpExecutor, nsContentSink)
 
 NS_IMPL_RELEASE_INHERITED(nsHtml5TreeOpExecutor, nsContentSink)
 
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHtml5TreeOpExecutor, nsContentSink)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwnedElements)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHtml5TreeOpExecutor, nsContentSink)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwnedElements)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
 class nsHtml5ExecutorReflusher : public nsRunnable
 {
   private:
     nsRefPtr<nsHtml5TreeOpExecutor> mExecutor;
   public:
     nsHtml5ExecutorReflusher(nsHtml5TreeOpExecutor* aExecutor)
       : mExecutor(aExecutor)
     {}
--- a/parser/xml/src/nsSAXXMLReader.cpp
+++ b/parser/xml/src/nsSAXXMLReader.cpp
@@ -19,35 +19,24 @@
 #include "mozilla/dom/EncodingUtils.h"
 
 using mozilla::dom::EncodingUtils;
 
 #define XMLNS_URI "http://www.w3.org/2000/xmlns/"
 
 static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsSAXXMLReader)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsSAXXMLReader)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mContentHandler)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mDTDHandler)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mErrorHandler)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mLexicalHandler)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mBaseURI)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mListener)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mParserObserver)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsSAXXMLReader)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContentHandler)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDTDHandler)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mErrorHandler)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLexicalHandler)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBaseURI)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mListener)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParserObserver)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+NS_IMPL_CYCLE_COLLECTION_7(nsSAXXMLReader,
+                           mContentHandler,
+                           mDTDHandler,
+                           mErrorHandler,
+                           mLexicalHandler,
+                           mBaseURI,
+                           mListener,
+                           mParserObserver)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSAXXMLReader)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSAXXMLReader)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSAXXMLReader)
   NS_INTERFACE_MAP_ENTRY(nsISAXXMLReader)
   NS_INTERFACE_MAP_ENTRY(nsIExpatSink)
   NS_INTERFACE_MAP_ENTRY(nsIExtendedExpatSink)
   NS_INTERFACE_MAP_ENTRY(nsIContentSink)
   NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)