Bug 1033654 - Rename GCGraphBuilder to CCGraphBuilder. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Wed, 09 Jul 2014 21:31:00 +0200
changeset 215476 2b7493acc2686b2e120ec3005959f6ed56d8576a
parent 215475 99bd46e9351759e6a4119c748a3182342eae4ee8
child 215477 cf85693280c77de186b5d1ce194615d91e6f430e
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1033654
milestone33.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 1033654 - Rename GCGraphBuilder to CCGraphBuilder. r=smaug
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -821,44 +821,44 @@ struct WeakMapping
 {
   // map and key will be null if the corresponding objects are GC marked
   PtrInfo* mMap;
   PtrInfo* mKey;
   PtrInfo* mKeyDelegate;
   PtrInfo* mVal;
 };
 
-class GCGraphBuilder;
-
-struct GCGraph
+class CCGraphBuilder;
+
+struct CCGraph
 {
   NodePool mNodes;
   EdgePool mEdges;
   nsTArray<WeakMapping> mWeakMaps;
   uint32_t mRootCount;
 
 private:
   PLDHashTable mPtrToNodeMap;
 
 public:
-  GCGraph() : mRootCount(0)
+  CCGraph() : mRootCount(0)
   {
     mPtrToNodeMap.ops = nullptr;
   }
 
-  ~GCGraph()
+  ~CCGraph()
   {
     if (mPtrToNodeMap.ops) {
       PL_DHashTableFinish(&mPtrToNodeMap);
     }
   }
 
   void Init()
   {
-    MOZ_ASSERT(IsEmpty(), "Failed to call GCGraph::Clear");
+    MOZ_ASSERT(IsEmpty(), "Failed to call CCGraph::Clear");
     PL_DHashTableInit(&mPtrToNodeMap, &PtrNodeOps, nullptr,
                       sizeof(PtrToNodeEntry), 32768);
   }
 
   void Clear()
   {
     mNodes.Clear();
     mEdges.Clear();
@@ -895,42 +895,42 @@ public:
 
     // We don't measure what the WeakMappings point to, because the
     // pointers are non-owning.
     *aWeakMapsSize = mWeakMaps.SizeOfExcludingThis(aMallocSizeOf);
   }
 };
 
 PtrInfo*
-GCGraph::FindNode(void* aPtr)
+CCGraph::FindNode(void* aPtr)
 {
   PtrToNodeEntry* e =
     static_cast<PtrToNodeEntry*>(PL_DHashTableOperate(&mPtrToNodeMap, aPtr,
                                                       PL_DHASH_LOOKUP));
   if (!PL_DHASH_ENTRY_IS_BUSY(e)) {
     return nullptr;
   }
   return e->mNode;
 }
 
 PtrToNodeEntry*
-GCGraph::AddNodeToMap(void* aPtr)
+CCGraph::AddNodeToMap(void* aPtr)
 {
   PtrToNodeEntry* e =
     static_cast<PtrToNodeEntry*>(PL_DHashTableOperate(&mPtrToNodeMap, aPtr,
                                                       PL_DHASH_ADD));
   if (!e) {
     // Caller should track OOMs
     return nullptr;
   }
   return e;
 }
 
 void
-GCGraph::RemoveNodeFromMap(void* aPtr)
+CCGraph::RemoveNodeFromMap(void* aPtr)
 {
   PL_DHashTableOperate(&mPtrToNodeMap, aPtr, PL_DHASH_REMOVE);
 }
 
 
 static nsISupports*
 CanonicalizeXPCOMParticipant(nsISupports* aIn)
 {
@@ -1089,17 +1089,17 @@ public:
   };
 
   void UnmarkRemainingPurple(Block* aBlock)
   {
     UnmarkRemainingPurpleVisitor visitor;
     aBlock->VisitEntries(*this, visitor);
   }
 
-  void SelectPointers(GCGraphBuilder& aBuilder);
+  void SelectPointers(CCGraphBuilder& aBuilder);
 
   // RemoveSkippable removes entries from the purple buffer synchronously
   // (1) if aAsyncSnowWhiteFreeing is false and nsPurpleBufferEntry::mRefCnt is 0 or
   // (2) if the object's nsXPCOMCycleCollectionParticipant::CanSkip() returns true or
   // (3) if nsPurpleBufferEntry::mRefCnt->IsPurple() is false.
   // (4) If removeChildlessNodes is true, then any nodes in the purple buffer
   //     that will have no children in the cycle collector graph will also be
   //     removed. CanSkip() may be run on these children.
@@ -1174,22 +1174,22 @@ public:
     // We also don't measure the things pointed to by mEntries[] because
     // those pointers are non-owning.
 
     return n;
   }
 };
 
 static bool
-AddPurpleRoot(GCGraphBuilder& aBuilder, void* aRoot,
+AddPurpleRoot(CCGraphBuilder& aBuilder, void* aRoot,
               nsCycleCollectionParticipant* aParti);
 
 struct SelectPointersVisitor
 {
-  SelectPointersVisitor(GCGraphBuilder& aBuilder)
+  SelectPointersVisitor(CCGraphBuilder& aBuilder)
     : mBuilder(aBuilder)
   {
   }
 
   void
   Visit(nsPurpleBuffer& aBuffer, nsPurpleBufferEntry* aEntry)
   {
     MOZ_ASSERT(aEntry->mObject, "Null object in purple buffer");
@@ -1197,21 +1197,21 @@ struct SelectPointersVisitor
                "SelectPointersVisitor: snow-white object in the purple buffer");
     if (!aEntry->mRefCnt->IsPurple() ||
         AddPurpleRoot(mBuilder, aEntry->mObject, aEntry->mParticipant)) {
       aBuffer.Remove(aEntry);
     }
   }
 
 private:
-  GCGraphBuilder& mBuilder;
+  CCGraphBuilder& mBuilder;
 };
 
 void
-nsPurpleBuffer::SelectPointers(GCGraphBuilder& aBuilder)
+nsPurpleBuffer::SelectPointers(CCGraphBuilder& aBuilder)
 {
   SelectPointersVisitor visitor(aBuilder);
   VisitEntries(visitor);
 
   NS_ASSERTION(mCount == 0, "AddPurpleRoot failed");
   if (mCount == 0) {
     FreeBlocks();
     InitBlocks();
@@ -1253,18 +1253,18 @@ class nsCycleCollector : public nsIMemor
   // mScanInProgress should be false when we're collecting white objects.
   bool mScanInProgress;
   CycleCollectorResults mResults;
   TimeStamp mCollectionStart;
 
   CycleCollectedJSRuntime* mJSRuntime;
 
   ccPhase mIncrementalPhase;
-  GCGraph mGraph;
-  nsAutoPtr<GCGraphBuilder> mBuilder;
+  CCGraph mGraph;
+  nsAutoPtr<CCGraphBuilder> mBuilder;
   nsAutoPtr<NodePool::Enumerator> mCurrNode;
   nsCOMPtr<nsICycleCollectorListener> mListener;
 
   nsIThread* mThread;
 
   nsCycleCollectorParams mParams;
 
   uint32_t mWhiteNodeCount;
@@ -1370,17 +1370,17 @@ private:
     }
     if (!aQueue.Push(aPi, fallible_t())) {
       mVisitor.Failed();
     }
   }
 
 public:
   void Walk(PtrInfo* aPi);
-  void WalkFromRoots(GCGraph& aGraph);
+  void WalkFromRoots(CCGraph& aGraph);
   // copy-constructing the visitor should be cheap, and less
   // indirection than using a reference
   GraphWalker(const Visitor aVisitor) : mVisitor(aVisitor)
   {
   }
 };
 
 
@@ -1434,17 +1434,17 @@ GraphWalker<Visitor>::Walk(PtrInfo* aPi)
 {
   nsDeque queue;
   CheckedPush(queue, aPi);
   DoWalk(queue);
 }
 
 template <class Visitor>
 MOZ_NEVER_INLINE void
-GraphWalker<Visitor>::WalkFromRoots(GCGraph& aGraph)
+GraphWalker<Visitor>::WalkFromRoots(CCGraph& aGraph)
 {
   nsDeque queue;
   NodePool::Enumerator etor(aGraph.mNodes);
   for (uint32_t i = 0; i < aGraph.mRootCount; ++i) {
     CheckedPush(queue, etor.GetNext());
   }
   DoWalk(queue);
 }
@@ -2011,39 +2011,39 @@ nsCycleCollectorLoggerConstructor(nsISup
 
   return logger->QueryInterface(aIID, aInstancePtr);
 }
 
 ////////////////////////////////////////////////////////////////////////
 // Bacon & Rajan's |MarkRoots| routine.
 ////////////////////////////////////////////////////////////////////////
 
-class GCGraphBuilder : public nsCycleCollectionTraversalCallback,
+class CCGraphBuilder : public nsCycleCollectionTraversalCallback,
   public nsCycleCollectionNoteRootCallback
 {
 private:
-  GCGraph& mGraph;
+  CCGraph& mGraph;
   CycleCollectorResults& mResults;
   NodePool::Builder mNodeBuilder;
   EdgePool::Builder mEdgeBuilder;
   PtrInfo* mCurrPi;
   nsCycleCollectionParticipant* mJSParticipant;
   nsCycleCollectionParticipant* mJSZoneParticipant;
   nsCString mNextEdgeName;
   nsICycleCollectorListener* mListener;
   bool mMergeZones;
   bool mRanOutOfMemory;
 
 public:
-  GCGraphBuilder(GCGraph& aGraph,
+  CCGraphBuilder(CCGraph& aGraph,
                  CycleCollectorResults& aResults,
                  CycleCollectedJSRuntime* aJSRuntime,
                  nsICycleCollectorListener* aListener,
                  bool aMergeZones);
-  virtual ~GCGraphBuilder();
+  virtual ~CCGraphBuilder();
 
   bool WantAllTraces() const
   {
     return nsCycleCollectionNoteRootCallback::WantAllTraces();
   }
 
   PtrInfo* AddNode(void* aPtr, nsCycleCollectionParticipant* aParticipant);
   PtrInfo* AddWeakMapNode(void* aNode);
@@ -2116,17 +2116,17 @@ private:
     JS::Zone* zone = JS::GetGCThingZone(aGcthing);
     if (js::IsSystemZone(zone)) {
       return nullptr;
     }
     return zone;
   }
 };
 
-GCGraphBuilder::GCGraphBuilder(GCGraph& aGraph,
+CCGraphBuilder::CCGraphBuilder(CCGraph& aGraph,
                                CycleCollectorResults& aResults,
                                CycleCollectedJSRuntime* aJSRuntime,
                                nsICycleCollectorListener* aListener,
                                bool aMergeZones)
   : mGraph(aGraph)
   , mResults(aResults)
   , mNodeBuilder(aGraph.mNodes)
   , mEdgeBuilder(aGraph.mEdges)
@@ -2155,22 +2155,22 @@ GCGraphBuilder::GCGraphBuilder(GCGraph& 
   mFlags |= flags;
 
   mMergeZones = mMergeZones && MOZ_LIKELY(!WantAllTraces());
 
   MOZ_ASSERT(nsCycleCollectionNoteRootCallback::WantAllTraces() ==
              nsCycleCollectionTraversalCallback::WantAllTraces());
 }
 
-GCGraphBuilder::~GCGraphBuilder()
+CCGraphBuilder::~CCGraphBuilder()
 {
 }
 
 PtrInfo*
-GCGraphBuilder::AddNode(void* aPtr, nsCycleCollectionParticipant* aParticipant)
+CCGraphBuilder::AddNode(void* aPtr, nsCycleCollectionParticipant* aParticipant)
 {
   PtrToNodeEntry* e = mGraph.AddNodeToMap(aPtr);
   if (!e) {
     mRanOutOfMemory = true;
     return nullptr;
   }
 
   PtrInfo* result;
@@ -2183,70 +2183,70 @@ GCGraphBuilder::AddNode(void* aPtr, nsCy
     result = e->mNode;
     MOZ_ASSERT(result->mParticipant == aParticipant,
                "nsCycleCollectionParticipant shouldn't change!");
   }
   return result;
 }
 
 MOZ_NEVER_INLINE void
-GCGraphBuilder::Traverse(PtrInfo* aPtrInfo)
+CCGraphBuilder::Traverse(PtrInfo* aPtrInfo)
 {
   mCurrPi = aPtrInfo;
 
   mCurrPi->SetFirstChild(mEdgeBuilder.Mark());
 
   if (!aPtrInfo->mParticipant) {
     return;
   }
 
   nsresult rv = aPtrInfo->mParticipant->Traverse(aPtrInfo->mPointer, *this);
   if (NS_FAILED(rv)) {
     Fault("script pointer traversal failed", aPtrInfo);
   }
 }
 
 void
-GCGraphBuilder::SetLastChild()
+CCGraphBuilder::SetLastChild()
 {
   mCurrPi->SetLastChild(mEdgeBuilder.Mark());
 }
 
 NS_IMETHODIMP_(void)
-GCGraphBuilder::NoteXPCOMRoot(nsISupports* aRoot)
+CCGraphBuilder::NoteXPCOMRoot(nsISupports* aRoot)
 {
   aRoot = CanonicalizeXPCOMParticipant(aRoot);
   NS_ASSERTION(aRoot,
                "Don't add objects that don't participate in collection!");
 
   nsXPCOMCycleCollectionParticipant* cp;
   ToParticipant(aRoot, &cp);
 
   NoteRoot(aRoot, cp);
 }
 
 NS_IMETHODIMP_(void)
-GCGraphBuilder::NoteJSRoot(void* aRoot)
+CCGraphBuilder::NoteJSRoot(void* aRoot)
 {
   if (JS::Zone* zone = MergeZone(aRoot)) {
     NoteRoot(zone, mJSZoneParticipant);
   } else {
     NoteRoot(aRoot, mJSParticipant);
   }
 }
 
 NS_IMETHODIMP_(void)
-GCGraphBuilder::NoteNativeRoot(void* aRoot,
+CCGraphBuilder::NoteNativeRoot(void* aRoot,
                                nsCycleCollectionParticipant* aParticipant)
 {
   NoteRoot(aRoot, aParticipant);
 }
 
 NS_IMETHODIMP_(void)
-GCGraphBuilder::DescribeRefCountedNode(nsrefcnt aRefCount, const char* aObjName)
+CCGraphBuilder::DescribeRefCountedNode(nsrefcnt aRefCount, const char* aObjName)
 {
   if (aRefCount == 0) {
     Fault("zero refcount", mCurrPi);
   }
   if (aRefCount == UINT32_MAX) {
     Fault("overflowing refcount", mCurrPi);
   }
   mResults.mVisitedRefCounted++;
@@ -2255,32 +2255,32 @@ GCGraphBuilder::DescribeRefCountedNode(n
     mListener->NoteRefCountedObject((uint64_t)mCurrPi->mPointer, aRefCount,
                                     aObjName);
   }
 
   DescribeNode(aRefCount, aObjName);
 }
 
 NS_IMETHODIMP_(void)
-GCGraphBuilder::DescribeGCedNode(bool aIsMarked, const char* aObjName,
+CCGraphBuilder::DescribeGCedNode(bool aIsMarked, const char* aObjName,
                                  uint64_t aCompartmentAddress)
 {
   uint32_t refCount = aIsMarked ? UINT32_MAX : 0;
   mResults.mVisitedGCed++;
 
   if (mListener) {
     mListener->NoteGCedObject((uint64_t)mCurrPi->mPointer, aIsMarked,
                               aObjName, aCompartmentAddress);
   }
 
   DescribeNode(refCount, aObjName);
 }
 
 NS_IMETHODIMP_(void)
-GCGraphBuilder::NoteXPCOMChild(nsISupports* aChild)
+CCGraphBuilder::NoteXPCOMChild(nsISupports* aChild)
 {
   nsCString edgeName;
   if (WantDebugInfo()) {
     edgeName.Assign(mNextEdgeName);
     mNextEdgeName.Truncate();
   }
   if (!aChild || !(aChild = CanonicalizeXPCOMParticipant(aChild))) {
     return;
@@ -2289,34 +2289,34 @@ GCGraphBuilder::NoteXPCOMChild(nsISuppor
   nsXPCOMCycleCollectionParticipant* cp;
   ToParticipant(aChild, &cp);
   if (cp && (!cp->CanSkipThis(aChild) || WantAllTraces())) {
     NoteChild(aChild, cp, edgeName);
   }
 }
 
 NS_IMETHODIMP_(void)
-GCGraphBuilder::NoteNativeChild(void* aChild,
+CCGraphBuilder::NoteNativeChild(void* aChild,
                                 nsCycleCollectionParticipant* aParticipant)
 {
   nsCString edgeName;
   if (WantDebugInfo()) {
     edgeName.Assign(mNextEdgeName);
     mNextEdgeName.Truncate();
   }
   if (!aChild) {
     return;
   }
 
   MOZ_ASSERT(aParticipant, "Need a nsCycleCollectionParticipant!");
   NoteChild(aChild, aParticipant, edgeName);
 }
 
 NS_IMETHODIMP_(void)
-GCGraphBuilder::NoteJSChild(void* aChild)
+CCGraphBuilder::NoteJSChild(void* aChild)
 {
   if (!aChild) {
     return;
   }
 
   nsCString edgeName;
   if (MOZ_UNLIKELY(WantDebugInfo())) {
     edgeName.Assign(mNextEdgeName);
@@ -2328,57 +2328,57 @@ GCGraphBuilder::NoteJSChild(void* aChild
       NoteChild(zone, mJSZoneParticipant, edgeName);
     } else {
       NoteChild(aChild, mJSParticipant, edgeName);
     }
   }
 }
 
 NS_IMETHODIMP_(void)
-GCGraphBuilder::NoteNextEdgeName(const char* aName)
+CCGraphBuilder::NoteNextEdgeName(const char* aName)
 {
   if (WantDebugInfo()) {
     mNextEdgeName = aName;
   }
 }
 
 PtrInfo*
-GCGraphBuilder::AddWeakMapNode(void* aNode)
+CCGraphBuilder::AddWeakMapNode(void* aNode)
 {
   MOZ_ASSERT(aNode, "Weak map node should be non-null.");
 
   if (!xpc_GCThingIsGrayCCThing(aNode) && !WantAllTraces()) {
     return nullptr;
   }
 
   if (JS::Zone* zone = MergeZone(aNode)) {
     return AddNode(zone, mJSZoneParticipant);
   }
   return AddNode(aNode, mJSParticipant);
 }
 
 NS_IMETHODIMP_(void)
-GCGraphBuilder::NoteWeakMapping(void* aMap, void* aKey, void* aKdelegate, void* aVal)
+CCGraphBuilder::NoteWeakMapping(void* aMap, void* aKey, void* aKdelegate, void* aVal)
 {
   // Don't try to optimize away the entry here, as we've already attempted to
   // do that in TraceWeakMapping in nsXPConnect.
   WeakMapping* mapping = mGraph.mWeakMaps.AppendElement();
   mapping->mMap = aMap ? AddWeakMapNode(aMap) : nullptr;
   mapping->mKey = aKey ? AddWeakMapNode(aKey) : nullptr;
   mapping->mKeyDelegate = aKdelegate ? AddWeakMapNode(aKdelegate) : mapping->mKey;
   mapping->mVal = aVal ? AddWeakMapNode(aVal) : nullptr;
 
   if (mListener) {
     mListener->NoteWeakMapEntry((uint64_t)aMap, (uint64_t)aKey,
                                 (uint64_t)aKdelegate, (uint64_t)aVal);
   }
 }
 
 static bool
-AddPurpleRoot(GCGraphBuilder& aBuilder, void* aRoot,
+AddPurpleRoot(CCGraphBuilder& aBuilder, void* aRoot,
               nsCycleCollectionParticipant* aParti)
 {
   CanonicalizeParticipant(&aRoot, &aParti);
 
   if (aBuilder.WantAllTraces() || !aParti->CanSkipInCC(aRoot)) {
     PtrInfo* pinfo = aBuilder.AddNode(aRoot, aParti);
     if (!pinfo) {
       return false;
@@ -2393,17 +2393,17 @@ AddPurpleRoot(GCGraphBuilder& aBuilder, 
 class ChildFinder : public nsCycleCollectionTraversalCallback
 {
 public:
   ChildFinder() : mMayHaveChild(false)
   {
   }
 
   // The logic of the Note*Child functions must mirror that of their
-  // respective functions in GCGraphBuilder.
+  // respective functions in CCGraphBuilder.
   NS_IMETHOD_(void) NoteXPCOMChild(nsISupports* aChild);
   NS_IMETHOD_(void) NoteNativeChild(void* aChild,
                                     nsCycleCollectionParticipant* aHelper);
   NS_IMETHOD_(void) NoteJSChild(void* aChild);
 
   NS_IMETHOD_(void) DescribeRefCountedNode(nsrefcnt aRefcount,
                                            const char* aObjname)
   {
@@ -2939,17 +2939,17 @@ nsCycleCollector::ScanWeakMaps()
     CC_TELEMETRY(_OOM, true);
   }
 }
 
 // Flood black from any objects in the purple buffer that are in the CC graph.
 class PurpleScanBlackVisitor
 {
 public:
-  PurpleScanBlackVisitor(GCGraph& aGraph, nsICycleCollectorListener* aListener,
+  PurpleScanBlackVisitor(CCGraph& aGraph, nsICycleCollectorListener* aListener,
                          uint32_t& aCount, bool& aFailed)
     : mGraph(aGraph), mListener(aListener), mCount(aCount), mFailed(aFailed)
   {
   }
 
   void
   Visit(nsPurpleBuffer& aBuffer, nsPurpleBufferEntry* aEntry)
   {
@@ -2974,17 +2974,17 @@ public:
     }
     if (pi->mColor == black) {
       return;
     }
     FloodBlackNode(mCount, mFailed, pi);
   }
 
 private:
-  GCGraph& mGraph;
+  CCGraph& mGraph;
   nsICycleCollectorListener* mListener;
   uint32_t& mCount;
   bool& mFailed;
 };
 
 // Objects that have been stored somewhere since the start of incremental graph building must
 // be treated as live for this cycle collection, because we may not have accurate information
 // about who holds references to them.
@@ -3730,17 +3730,17 @@ nsCycleCollector::BeginCollection(ccType
 
   // Set up the data structures for building the graph.
   mGraph.Init();
   mResults.Init();
   bool mergeZones = ShouldMergeZones(aCCType);
   mResults.mMergedZones = mergeZones;
 
   MOZ_ASSERT(!mBuilder, "Forgot to clear mBuilder");
-  mBuilder = new GCGraphBuilder(mGraph, mResults, mJSRuntime, mListener, mergeZones);
+  mBuilder = new CCGraphBuilder(mGraph, mResults, mJSRuntime, mListener, mergeZones);
 
   if (mJSRuntime) {
     mJSRuntime->TraverseRoots(*mBuilder);
     timeLog.Checkpoint("mJSRuntime->TraverseRoots()");
   }
 
   AutoRestore<bool> ar(mScanInProgress);
   MOZ_ASSERT(!mScanInProgress);