From 9a588376e3cad1d91bb6224b6f72279de2bc4bb1 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Thu, 1 Apr 2010 09:37:26 -0700 Subject: [PATCH] Backed out changeset 13819d2e9bd8 (Bug 551298) due to Linux debug mochitest-5 orange --- content/smil/nsSMILInstanceTime.h | 34 +++++++++++++- content/xbl/src/nsXBLBinding.h | 21 ++++++++- content/xbl/src/nsXBLInsertionPoint.cpp | 13 ++++++ content/xbl/src/nsXBLInsertionPoint.h | 11 ++++- content/xbl/src/nsXBLPrototypeBinding.cpp | 17 ++++++- .../src/xslt/txMozillaStylesheetCompiler.cpp | 44 +++++++++++++++++-- .../xslt/txStandaloneStylesheetCompiler.cpp | 21 ++++++++- content/xslt/src/xslt/txStylesheet.h | 20 +++++++-- .../xslt/src/xslt/txStylesheetCompiler.cpp | 21 +++++++++ content/xslt/src/xslt/txStylesheetCompiler.h | 19 +++++--- content/xul/templates/src/nsRDFBinding.h | 21 +++++++-- 11 files changed, 220 insertions(+), 22 deletions(-) diff --git a/content/smil/nsSMILInstanceTime.h b/content/smil/nsSMILInstanceTime.h index b76e87641720..6b05ace864d6 100644 --- a/content/smil/nsSMILInstanceTime.h +++ b/content/smil/nsSMILInstanceTime.h @@ -124,7 +124,36 @@ public: PRUint32 Serial() const { return mSerial; } void SetSerial(PRUint32 aIndex) { mSerial = aIndex; } - NS_INLINE_DECL_REFCOUNTING(nsSMILInstanceTime) + nsrefcnt AddRef() + { + if (mRefCnt == PR_UINT32_MAX) { + NS_WARNING("refcount overflow, leaking nsSMILInstanceTime"); + return mRefCnt; + } + NS_ASSERT_OWNINGTHREAD(_class); + NS_ABORT_IF_FALSE(_mOwningThread.GetThread() == PR_GetCurrentThread(), + "nsSMILInstanceTime addref isn't thread-safe!"); + ++mRefCnt; + NS_LOG_ADDREF(this, mRefCnt, "nsSMILInstanceTime", sizeof(*this)); + return mRefCnt; + } + + nsrefcnt Release() + { + if (mRefCnt == PR_UINT32_MAX) { + NS_WARNING("refcount overflow, leaking nsSMILInstanceTime"); + return mRefCnt; + } + NS_ABORT_IF_FALSE(_mOwningThread.GetThread() == PR_GetCurrentThread(), + "nsSMILInstanceTime release isn't thread-safe!"); + --mRefCnt; + NS_LOG_RELEASE(this, mRefCnt, "nsSMILInstanceTime"); + if (mRefCnt == 0) { + delete this; + return 0; + } + return mRefCnt; + } protected: void SetBaseInterval(nsSMILInterval* aBaseInterval); @@ -133,6 +162,9 @@ protected: nsSMILTimeValue mTime; + nsAutoRefCnt mRefCnt; + NS_DECL_OWNINGTHREAD + // Internal flags used for represent behaviour of different instance times` enum { // Indicates if this instance time should be removed when the owning timed diff --git a/content/xbl/src/nsXBLBinding.h b/content/xbl/src/nsXBLBinding.h index d88633a70899..492c9757ee5d 100644 --- a/content/xbl/src/nsXBLBinding.h +++ b/content/xbl/src/nsXBLBinding.h @@ -46,7 +46,6 @@ #include "nsClassHashtable.h" #include "nsTArray.h" #include "nsCycleCollectionParticipant.h" -#include "nsISupportsImpl.h" class nsXBLPrototypeBinding; class nsIContent; @@ -78,7 +77,24 @@ public: * which are queued to fire their constructors. */ - NS_INLINE_DECL_REFCOUNTING(nsXBLBinding) + nsrefcnt AddRef() + { + ++mRefCnt; + NS_LOG_ADDREF(this, mRefCnt, "nsXBLBinding", sizeof(nsXBLBinding)); + return mRefCnt; + } + + nsrefcnt Release() + { + --mRefCnt; + NS_LOG_RELEASE(this, mRefCnt, "nsXBLBinding"); + if (mRefCnt == 0) { + mRefCnt = 1; + delete this; + return 0; + } + return mRefCnt; + } NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsXBLBinding) @@ -156,6 +172,7 @@ public: // MEMBER VARIABLES protected: + nsAutoRefCnt mRefCnt; nsXBLPrototypeBinding* mPrototypeBinding; // Weak, but we're holding a ref to the docinfo nsCOMPtr mContent; // Strong. Our anonymous content stays around with us. nsRefPtr mNextBinding; // Strong. The derived binding owns the base class bindings. diff --git a/content/xbl/src/nsXBLInsertionPoint.cpp b/content/xbl/src/nsXBLInsertionPoint.cpp index d3d0dc582fa8..62e703195086 100644 --- a/content/xbl/src/nsXBLInsertionPoint.cpp +++ b/content/xbl/src/nsXBLInsertionPoint.cpp @@ -57,6 +57,19 @@ nsXBLInsertionPoint::~nsXBLInsertionPoint() } } +nsrefcnt +nsXBLInsertionPoint::Release() +{ + --mRefCnt; + NS_LOG_RELEASE(this, mRefCnt, "nsXBLInsertionPoint"); + if (mRefCnt == 0) { + mRefCnt = 1; + delete this; + return 0; + } + return mRefCnt; +} + NS_IMPL_CYCLE_COLLECTION_CLASS(nsXBLInsertionPoint) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_NATIVE(nsXBLInsertionPoint) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mElements) diff --git a/content/xbl/src/nsXBLInsertionPoint.h b/content/xbl/src/nsXBLInsertionPoint.h index 5ec9239bd3f3..c1f05045a4df 100644 --- a/content/xbl/src/nsXBLInsertionPoint.h +++ b/content/xbl/src/nsXBLInsertionPoint.h @@ -50,7 +50,15 @@ public: nsXBLInsertionPoint(nsIContent* aParentElement, PRUint32 aIndex, nsIContent* aDefContent); ~nsXBLInsertionPoint(); - NS_INLINE_DECL_REFCOUNTING(nsXBLInsertionPoint) + nsrefcnt AddRef() + { + ++mRefCnt; + NS_LOG_ADDREF(this, mRefCnt, "nsXBLInsertionPoint", + sizeof(nsXBLInsertionPoint)); + return mRefCnt; + } + + nsrefcnt Release(); NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsXBLInsertionPoint) @@ -82,6 +90,7 @@ public: void UnbindDefaultContent(); protected: + nsAutoRefCnt mRefCnt; nsIContent* mParentElement; // This ref is weak. The parent of the element. PRInt32 mIndex; // The index of this insertion point. -1 is a pseudo-point. nsCOMArray mElements; // An array of elements present at the insertion point. diff --git a/content/xbl/src/nsXBLPrototypeBinding.cpp b/content/xbl/src/nsXBLPrototypeBinding.cpp index 4f417c8e1c60..8b6e97d2b036 100644 --- a/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -207,12 +207,27 @@ public: nsXBLInsertionPointEntry::ReleasePool(); } - NS_INLINE_DECL_REFCOUNTING(nsXBLInsertionPointEntry) + nsrefcnt AddRef() { + ++mRefCnt; + NS_LOG_ADDREF(this, mRefCnt, "nsXBLInsertionPointEntry", sizeof(nsXBLInsertionPointEntry)); + return mRefCnt; + } + + nsrefcnt Release() { + --mRefCnt; + NS_LOG_RELEASE(this, mRefCnt, "nsXBLInsertionPointEntry"); + if (mRefCnt == 0) { + Destroy(this); + return 0; + } + return mRefCnt; + } protected: nsCOMPtr mInsertionParent; nsCOMPtr mDefaultContent; PRUint32 mInsertionIndex; + nsAutoRefCnt mRefCnt; nsXBLInsertionPointEntry(nsIContent* aParent) : mInsertionParent(aParent), diff --git a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp index 2ab7c3f11795..daf934456161 100644 --- a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp +++ b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp @@ -404,12 +404,14 @@ public: txCompileObserver(txMozillaXSLTProcessor* aProcessor, nsILoadGroup* aLoadGroup); - TX_DECL_ACOMPILEOBSERVER - NS_INLINE_DECL_REFCOUNTING(txCompileObserver) + TX_DECL_ACOMPILEOBSERVER; nsresult startLoad(nsIURI* aUri, txStylesheetCompiler* aCompiler, nsIPrincipal* aSourcePrincipal); +protected: + nsAutoRefCnt mRefCnt; + private: nsRefPtr mProcessor; nsCOMPtr mLoadGroup; @@ -427,6 +429,23 @@ txCompileObserver::txCompileObserver(txMozillaXSLTProcessor* aProcessor, { } +nsrefcnt +txCompileObserver::AddRef() +{ + return ++mRefCnt; +} + +nsrefcnt +txCompileObserver::Release() +{ + if (--mRefCnt == 0) { + mRefCnt = 1; //stabilize + delete this; + return 0; + } + return mRefCnt; +} + nsresult txCompileObserver::loadURI(const nsAString& aUri, const nsAString& aReferrerUri, @@ -639,11 +658,11 @@ class txSyncCompileObserver : public txACompileObserver public: txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor); - TX_DECL_ACOMPILEOBSERVER - NS_INLINE_DECL_REFCOUNTING(txSyncCompileObserver) + TX_DECL_ACOMPILEOBSERVER; protected: nsRefPtr mProcessor; + nsAutoRefCnt mRefCnt; }; txSyncCompileObserver::txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor) @@ -651,6 +670,23 @@ txSyncCompileObserver::txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor) { } +nsrefcnt +txSyncCompileObserver::AddRef() +{ + return ++mRefCnt; +} + +nsrefcnt +txSyncCompileObserver::Release() +{ + if (--mRefCnt == 0) { + mRefCnt = 1; //stabilize + delete this; + return 0; + } + return mRefCnt; +} + nsresult txSyncCompileObserver::loadURI(const nsAString& aUri, const nsAString& aReferrerUri, diff --git a/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp b/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp index f68ad544ccad..11347fbbfd06 100644 --- a/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp +++ b/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp @@ -64,8 +64,7 @@ class txDriver : public txACompileObserver const XML_Char *aSystemId, const XML_Char *aPublicId); - TX_DECL_ACOMPILEOBSERVER - NS_INLINE_DECL_REFCOUNTING(txDriver) + TX_DECL_ACOMPILEOBSERVER; nsRefPtr mCompiler; protected: @@ -74,6 +73,7 @@ class txDriver : public txACompileObserver // keep track of the nsresult returned by the handlers, expat forgets them nsresult mRV; XML_Parser mExpatParser; + nsAutoRefCnt mRefCnt; }; nsresult @@ -338,6 +338,23 @@ txDriver::createErrorString() * txACompileObserver implementation */ +nsrefcnt +txDriver::AddRef() +{ + return ++mRefCnt; +} + +nsrefcnt +txDriver::Release() +{ + if (--mRefCnt == 0) { + mRefCnt = 1; //stabilize + delete this; + return 0; + } + return mRefCnt; +} + void txDriver::onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult aResult, const PRUnichar *aErrorText, const PRUnichar *aParam) diff --git a/content/xslt/src/xslt/txStylesheet.h b/content/xslt/src/xslt/txStylesheet.h index cd159e8f7306..5f6228f1fbe9 100644 --- a/content/xslt/src/xslt/txStylesheet.h +++ b/content/xslt/src/xslt/txStylesheet.h @@ -44,7 +44,6 @@ #include "txList.h" #include "txXSLTPatterns.h" #include "nsTPtrArray.h" -#include "nsISupportsImpl.h" class txInstruction; class txToplevelItem; @@ -68,8 +67,20 @@ public: txStylesheet(); ~txStylesheet(); nsresult init(); - - NS_INLINE_DECL_REFCOUNTING(txStylesheet) + + nsrefcnt AddRef() + { + return ++mRefCnt; + } + nsrefcnt Release() + { + if (--mRefCnt == 0) { + mRefCnt = 1; //stabilize + delete this; + return 0; + } + return mRefCnt; + } txInstruction* findTemplate(const txXPathNode& aNode, const txExpandedName& aMode, @@ -148,6 +159,9 @@ private: nsTPtrArray& aFrameStripSpaceTests); nsresult addAttributeSet(txAttributeSetItem* aAttributeSetItem); + // Refcount + nsAutoRefCnt mRefCnt; + // List of ImportFrames txList mImportFrames; diff --git a/content/xslt/src/xslt/txStylesheetCompiler.cpp b/content/xslt/src/xslt/txStylesheetCompiler.cpp index d0050683fd0b..759c5cb4306d 100644 --- a/content/xslt/src/xslt/txStylesheetCompiler.cpp +++ b/content/xslt/src/xslt/txStylesheetCompiler.cpp @@ -69,6 +69,27 @@ txStylesheetCompiler::txStylesheetCompiler(const nsAString& aStylesheetURI, mStatus = init(aStylesheetURI, aStylesheet, aInsertPosition); } +nsrefcnt +txStylesheetCompiler::AddRef() +{ + ++mRefCnt; + NS_LOG_ADDREF(this, mRefCnt, "txStylesheetCompiler", sizeof(*this)); + return mRefCnt; +} + +nsrefcnt +txStylesheetCompiler::Release() +{ + --mRefCnt; + NS_LOG_RELEASE(this, mRefCnt, "txStylesheetCompiler"); + if (mRefCnt == 0) { + mRefCnt = 1; //stabilize + delete this; + return 0; + } + return mRefCnt; +} + void txStylesheetCompiler::setBaseURI(const nsString& aBaseURI) { diff --git a/content/xslt/src/xslt/txStylesheetCompiler.h b/content/xslt/src/xslt/txStylesheetCompiler.h index 4d71484af266..fc23fb4d3d89 100644 --- a/content/xslt/src/xslt/txStylesheetCompiler.h +++ b/content/xslt/src/xslt/txStylesheetCompiler.h @@ -77,8 +77,8 @@ public: class txACompileObserver { public: - virtual void AddRef() = 0; - virtual void Release() = 0; + virtual nsrefcnt AddRef() = 0; + virtual nsrefcnt Release() = 0; virtual nsresult loadURI(const nsAString& aUri, const nsAString& aReferrerUri, @@ -90,11 +90,13 @@ public: }; #define TX_DECL_ACOMPILEOBSERVER \ + nsrefcnt AddRef(); \ + nsrefcnt Release(); \ nsresult loadURI(const nsAString& aUri, const nsAString& aReferrerUri, \ txStylesheetCompiler* aCompiler); \ void onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult aResult, \ const PRUnichar *aErrorText = nsnull, \ - const PRUnichar *aParam = nsnull); + const PRUnichar *aParam = nsnull) class txStylesheetCompilerState : public txIParseContext { @@ -213,6 +215,8 @@ public: txStylesheet* aStylesheet, txListIterator* aInsertPosition, txACompileObserver* aObserver); + virtual nsrefcnt AddRef(); + virtual nsrefcnt Release(); void setBaseURI(const nsString& aBaseURI); @@ -231,8 +235,12 @@ public: txStylesheet* getStylesheet(); - TX_DECL_ACOMPILEOBSERVER - NS_INLINE_DECL_REFCOUNTING(txStylesheetCompiler) + // txACompileObserver + nsresult loadURI(const nsAString& aUri, const nsAString& aReferrerUri, + txStylesheetCompiler* aCompiler); + void onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult aResult, + const PRUnichar *aErrorText = nsnull, + const PRUnichar *aParam = nsnull); private: nsresult startElementInternal(PRInt32 aNamespaceID, nsIAtom* aLocalName, @@ -245,6 +253,7 @@ private: nsresult ensureNewElementContext(); nsresult maybeDoneCompiling(); + nsAutoRefCnt mRefCnt; nsString mCharacters; nsresult mStatus; }; diff --git a/content/xul/templates/src/nsRDFBinding.h b/content/xul/templates/src/nsRDFBinding.h index 82ad20068ddf..2a8ab79973fc 100644 --- a/content/xul/templates/src/nsRDFBinding.h +++ b/content/xul/templates/src/nsRDFBinding.h @@ -40,7 +40,6 @@ #include "nsAutoPtr.h" #include "nsIAtom.h" #include "nsIRDFResource.h" -#include "nsISupportsImpl.h" class nsXULTemplateResultRDF; class nsBindingValues; @@ -96,6 +95,9 @@ class RDFBindingSet { protected: + // results hold a reference to a binding set in their nsBindingValues fields + PRInt32 mRefCnt; + // the number of bindings PRInt32 mCount; @@ -105,7 +107,8 @@ protected: public: RDFBindingSet() - : mCount(0), + : mRefCnt(0), + mCount(0), mFirst(nsnull) { MOZ_COUNT_CTOR(RDFBindingSet); @@ -113,7 +116,19 @@ public: ~RDFBindingSet(); - NS_INLINE_DECL_REFCOUNTING(RDFBindingSet) + PRInt32 AddRef() { + mRefCnt++; + NS_LOG_ADDREF(this, mRefCnt, "RDFBindingSet", sizeof(*this)); + return mRefCnt; + } + + PRInt32 Release() + { + PRInt32 refcnt = --mRefCnt; + NS_LOG_RELEASE(this, refcnt, "RDFBindingSet"); + if (refcnt == 0) delete this; + return refcnt; + } PRInt32 Count() const { return mCount; }