diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-02-03 08:34:08 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-02-03 08:34:08 +0100 |
commit | 9a8a050294414a7d248a4ec872744b43e1b9bfb1 (patch) | |
tree | 15da5ed8e56d99d3061cba56b9c253895af1849b /xpcom | |
parent | fa311a4cae5ea526e848adc4f49c6aa0b700702c (diff) | |
parent | e4a3b28c805e9419a076e1cdbe54056cfdcd3b41 (diff) | |
download | UXP-9a8a050294414a7d248a4ec872744b43e1b9bfb1.tar UXP-9a8a050294414a7d248a4ec872744b43e1b9bfb1.tar.gz UXP-9a8a050294414a7d248a4ec872744b43e1b9bfb1.tar.lz UXP-9a8a050294414a7d248a4ec872744b43e1b9bfb1.tar.xz UXP-9a8a050294414a7d248a4ec872744b43e1b9bfb1.zip |
Merge branch 'cycle_collector-work'
Diffstat (limited to 'xpcom')
-rw-r--r-- | xpcom/base/nsCycleCollector.cpp | 5 | ||||
-rw-r--r-- | xpcom/base/nsCycleCollectorTraceJSHelpers.cpp | 5 | ||||
-rw-r--r-- | xpcom/glue/nsCycleCollectionParticipant.h | 45 |
3 files changed, 37 insertions, 18 deletions
diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index d6dc26954..06ed42326 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -2265,7 +2265,7 @@ CCGraphBuilder::BuildGraph(SliceBudget& aBudget) SetFirstChild(); if (pi->mParticipant) { - nsresult rv = pi->mParticipant->Traverse(pi->mPointer, *this); + nsresult rv = pi->mParticipant->TraverseNativeAndJS(pi->mPointer, *this); MOZ_RELEASE_ASSERT(!NS_FAILED(rv), "Cycle collector Traverse method failed"); } @@ -2539,7 +2539,7 @@ static bool MayHaveChild(void* aObj, nsCycleCollectionParticipant* aCp) { ChildFinder cf; - aCp->Traverse(aObj, cf); + aCp->TraverseNativeAndJS(aObj, cf); return cf.MayHaveChild(); } @@ -2596,7 +2596,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(JSPurpleBuffer) CycleCollectionNoteChild(cb, tmp, "self"); - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END #define NS_TRACE_SEGMENTED_ARRAY(_field, _type) \ diff --git a/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp b/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp index 7c48002e3..f65a92e61 100644 --- a/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp +++ b/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp @@ -21,8 +21,9 @@ CycleCollectionNoteEdgeNameImpl(nsCycleCollectionTraversalCallback& aCallback, } void -nsScriptObjectTracer::NoteJSChild(JS::GCCellPtr aGCThing, const char* aName, - void* aClosure) +nsCycleCollectionParticipant::NoteJSChild(JS::GCCellPtr aGCThing, + const char* aName, + void* aClosure) { nsCycleCollectionTraversalCallback* cb = static_cast<nsCycleCollectionTraversalCallback*>(aClosure); diff --git a/xpcom/glue/nsCycleCollectionParticipant.h b/xpcom/glue/nsCycleCollectionParticipant.h index 2dfbb6750..5d03acd26 100644 --- a/xpcom/glue/nsCycleCollectionParticipant.h +++ b/xpcom/glue/nsCycleCollectionParticipant.h @@ -113,11 +113,38 @@ private: class NS_NO_VTABLE nsCycleCollectionParticipant { public: - constexpr nsCycleCollectionParticipant() : mMightSkip(false) {} - constexpr explicit nsCycleCollectionParticipant(bool aSkip) : mMightSkip(aSkip) {} + constexpr nsCycleCollectionParticipant() + : mMightSkip(false) + , mTraverseShouldTrace(false) + { + } + + constexpr explicit nsCycleCollectionParticipant(bool aSkip, + bool aTraverseShouldTrace = false) + : mMightSkip(aSkip) + , mTraverseShouldTrace(aTraverseShouldTrace) + { + } NS_IMETHOD Traverse(void* aPtr, nsCycleCollectionTraversalCallback& aCb) = 0; + nsresult TraverseNativeAndJS(void* aPtr, + nsCycleCollectionTraversalCallback& aCb) + { + nsresult rv = Traverse(aPtr, aCb); + if (mTraverseShouldTrace) { + // Note, we always call Trace, even if Traverse returned + // NS_SUCCESS_INTERRUPTED_TRAVERSE. + TraceCallbackFunc noteJsChild(&nsCycleCollectionParticipant::NoteJSChild); + Trace(aPtr, noteJsChild, &aCb); + } + return rv; + } + + // Implemented in nsCycleCollectorTraceJSHelpers.cpp. + static void NoteJSChild(JS::GCCellPtr aGCThing, const char* aName, + void* aClosure); + NS_IMETHOD_(void) Root(void* aPtr) = 0; NS_IMETHOD_(void) Unlink(void* aPtr) = 0; NS_IMETHOD_(void) Unroot(void* aPtr) = 0; @@ -172,26 +199,24 @@ protected: private: const bool mMightSkip; + const bool mTraverseShouldTrace; }; class NS_NO_VTABLE nsScriptObjectTracer : public nsCycleCollectionParticipant { public: constexpr nsScriptObjectTracer() - : nsCycleCollectionParticipant(false) + : nsCycleCollectionParticipant(false, true) { } constexpr explicit nsScriptObjectTracer(bool aSkip) - : nsCycleCollectionParticipant(aSkip) + : nsCycleCollectionParticipant(aSkip, true) { } NS_IMETHOD_(void) Trace(void* aPtr, const TraceCallbacks& aCb, void* aClosure) override = 0; - // Implemented in nsCycleCollectorTraceJSHelpers.cpp. - static void NoteJSChild(JS::GCCellPtr aGCThing, const char* aName, - void* aClosure); }; class NS_NO_VTABLE nsXPCOMCycleCollectionParticipant : public nsScriptObjectTracer @@ -440,12 +465,6 @@ DowncastCCParticipant(void* aPtr) #define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(_field) \ CycleCollectionNoteChild(cb, tmp->_field, #_field); -#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS \ - { \ - TraceCallbackFunc noteJsChild(&nsScriptObjectTracer::NoteJSChild); \ - Trace(p, noteJsChild, &cb); \ - } - #define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END \ (void)tmp; \ return NS_OK; \ |