[X2Go-Commits] [pale-moon] 23/102: Consolidate tracing and traversing.

git-admin at x2go.org git-admin at x2go.org
Mon Feb 25 23:25:45 CET 2019


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch upstream/28.4.0
in repository pale-moon.

commit 978f50dda9e6f0ff6c6cb21d4caa273f3260ebc8
Author: wolfbeast <mcwerewolf at wolfbeast.com>
Date:   Fri Jan 18 20:41:42 2019 +0100

    Consolidate tracing and traversing.
---
 dom/base/nsWrapperCache.cpp                   |  2 +-
 xpcom/base/nsCycleCollector.cpp               |  4 +--
 xpcom/base/nsCycleCollectorTraceJSHelpers.cpp |  5 ++--
 xpcom/glue/nsCycleCollectionParticipant.h     | 43 ++++++++++++++++++++-------
 4 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/dom/base/nsWrapperCache.cpp b/dom/base/nsWrapperCache.cpp
index b91d865..c5993fe 100644
--- a/dom/base/nsWrapperCache.cpp
+++ b/dom/base/nsWrapperCache.cpp
@@ -133,7 +133,7 @@ nsWrapperCache::CheckCCWrapperTraversal(void* aScriptObjectHolder,
   // see through the COM layer, so we use a suppression to help it.
   JS::AutoSuppressGCAnalysis suppress;
 
-  aTracer->Traverse(aScriptObjectHolder, callback);
+  aTracer->TraverseNativeAndJS(aScriptObjectHolder, callback);
   MOZ_ASSERT(callback.mFound,
              "Cycle collection participant didn't traverse to preserved "
              "wrapper! This will probably crash.");
diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp
index d6dc269..01e6794 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();
 }
 
diff --git a/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp b/xpcom/base/nsCycleCollectorTraceJSHelpers.cpp
index 7c48002..f65a92e 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 2dfbb67..7af6985 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
@@ -441,10 +466,6 @@ DowncastCCParticipant(void* aPtr)
   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;                                                                 \

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/pale-moon.git


More information about the x2go-commits mailing list