Bug 1301301, part 3 - Implement Begin and EndCycleCollectionCallback in CCJSContext. r=smaug draft
authorAndrew McCreight <continuation@gmail.com>
Tue, 20 Sep 2016 10:51:15 -0700
changeset 416239 de59145ee9354492529e69aa3cfea749827df0dc
parent 416238 ecb426227bc148ffd85ecdde08e3099757cbf350
child 416240 e2a5a84c90c6bac52164309929b8a353134b092d
child 417104 21ddb51f72fe3271d9cc3684fe763ca4abe14f18
push id30069
push userbmo:continuation@gmail.com
push dateWed, 21 Sep 2016 18:14:08 +0000
reviewerssmaug
bugs1301301
milestone52.0a1
Bug 1301301, part 3 - Implement Begin and EndCycleCollectionCallback in CCJSContext. r=smaug This will let my later patch run code at the start and end of each CC. This patch should not change any behavior. MozReview-Commit-ID: Fu6v3wo8qKB
dom/workers/RuntimeService.cpp
js/xpconnect/src/XPCJSContext.cpp
xpcom/base/CycleCollectedJSContext.cpp
xpcom/base/CycleCollectedJSContext.h
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -1094,26 +1094,16 @@ public:
     return NS_OK;
   }
 
   virtual void
   PrepareForForgetSkippable() override
   {
   }
 
-  virtual void
-  BeginCycleCollectionCallback() override
-  {
-  }
-
-  virtual void
-  EndCycleCollectionCallback(CycleCollectorResults &aResults) override
-  {
-  }
-
   void
   DispatchDeferredDeletion(bool aContinuation, bool aPurge) override
   {
     MOZ_ASSERT(!aContinuation);
 
     // Do it immediately, no need for asynchronous behavior here.
     nsCycleCollector_doDeferredDeletion();
   }
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -660,27 +660,29 @@ XPCJSContext::PrepareForForgetSkippable(
     if (obs) {
         obs->NotifyObservers(nullptr, "cycle-collector-forget-skippable", nullptr);
     }
 }
 
 void
 XPCJSContext::BeginCycleCollectionCallback()
 {
+    CycleCollectedJSContext::BeginCycleCollectionCallback();
     nsJSContext::BeginCycleCollectionCallback();
 
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
         obs->NotifyObservers(nullptr, "cycle-collector-begin", nullptr);
     }
 }
 
 void
 XPCJSContext::EndCycleCollectionCallback(CycleCollectorResults& aResults)
 {
+    CycleCollectedJSContext::EndCycleCollectionCallback(aResults);
     nsJSContext::EndCycleCollectionCallback(aResults);
 
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
         obs->NotifyObservers(nullptr, "cycle-collector-end", nullptr);
     }
 }
 
--- a/xpcom/base/CycleCollectedJSContext.cpp
+++ b/xpcom/base/CycleCollectedJSContext.cpp
@@ -1324,16 +1324,26 @@ CycleCollectedJSContext::DeferredFinaliz
 
 void
 CycleCollectedJSContext::DumpJSHeap(FILE* aFile)
 {
   js::DumpHeap(Context(), aFile, js::CollectNurseryBeforeDump);
 }
 
 void
+CycleCollectedJSContext::BeginCycleCollectionCallback()
+{
+}
+
+void
+CycleCollectedJSContext::EndCycleCollectionCallback(CycleCollectorResults& aResults)
+{
+}
+
+void
 CycleCollectedJSContext::ProcessStableStateQueue()
 {
   MOZ_ASSERT(mJSContext);
   MOZ_RELEASE_ASSERT(!mDoingStableStates);
   mDoingStableStates = true;
 
   for (uint32_t i = 0; i < mStableStateEvents.Length(); ++i) {
     nsCOMPtr<nsIRunnable> event = mStableStateEvents[i].forget();
--- a/xpcom/base/CycleCollectedJSContext.h
+++ b/xpcom/base/CycleCollectedJSContext.h
@@ -315,18 +315,18 @@ public:
   void DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
                         DeferredFinalizeFunction aFunc,
                         void* aThing);
   void DeferredFinalize(nsISupports* aSupports);
 
   void DumpJSHeap(FILE* aFile);
 
   virtual void PrepareForForgetSkippable() = 0;
-  virtual void BeginCycleCollectionCallback() = 0;
-  virtual void EndCycleCollectionCallback(CycleCollectorResults& aResults) = 0;
+  virtual void BeginCycleCollectionCallback();
+  virtual void EndCycleCollectionCallback(CycleCollectorResults& aResults);
   virtual void DispatchDeferredDeletion(bool aContinuation, bool aPurge = false) = 0;
 
   JSContext* Context() const
   {
     MOZ_ASSERT(mJSContext);
     return mJSContext;
   }