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
--- 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;
}