mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 882893: Move observer notifications out of the cycle collector and into the runtime. r=smaug
This commit is contained in:
parent
635eb60606
commit
7d893e1ec2
@ -15,6 +15,7 @@
|
||||
#include "dom_quickstubs.h"
|
||||
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "amIAddonManager.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPrintfCString.h"
|
||||
@ -532,6 +533,24 @@ XPCJSRuntime::UnmarkSkippableJSHolders()
|
||||
CycleCollectedJSRuntime::UnmarkSkippableJSHolders();
|
||||
}
|
||||
|
||||
void
|
||||
XPCJSRuntime::PrepareForForgetSkippable()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->NotifyObservers(nullptr, "cycle-collector-forget-skippable", nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
XPCJSRuntime::PrepareForCollection()
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->NotifyObservers(nullptr, "cycle-collector-begin", nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xpc_UnmarkSkippableJSHolders()
|
||||
{
|
||||
|
@ -742,6 +742,8 @@ public:
|
||||
void TraceAdditionalNativeGrayRoots(JSTracer* aTracer);
|
||||
void TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& cb);
|
||||
void UnmarkSkippableJSHolders();
|
||||
void PrepareForForgetSkippable() MOZ_OVERRIDE;
|
||||
void PrepareForCollection() MOZ_OVERRIDE;
|
||||
|
||||
static void GCCallback(JSRuntime *rt, JSGCStatus status);
|
||||
static void GCSliceCallback(JSRuntime *rt,
|
||||
|
@ -171,6 +171,9 @@ public:
|
||||
bool NeedCollect() const;
|
||||
void Collect(uint32_t reason) const;
|
||||
|
||||
virtual void PrepareForForgetSkippable() {}
|
||||
virtual void PrepareForCollection() {}
|
||||
|
||||
private:
|
||||
typedef const CCParticipantVTable<JSGCThingParticipant>::Type GCThingParticipantVTable;
|
||||
const GCThingParticipantVTable mGCThingCycleCollectorGlobal;
|
||||
|
@ -116,12 +116,10 @@
|
||||
#include "plstr.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsICycleCollectorListener.h"
|
||||
#include "nsIXPConnect.h"
|
||||
@ -2191,9 +2189,8 @@ nsCycleCollector::SelectPurple(GCGraphBuilder &builder)
|
||||
void
|
||||
nsCycleCollector::ForgetSkippable(bool removeChildlessNodes)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->NotifyObservers(nullptr, "cycle-collector-forget-skippable", nullptr);
|
||||
if (mJSRuntime) {
|
||||
mJSRuntime->PrepareForForgetSkippable();
|
||||
}
|
||||
mPurpleBuf.RemoveSkippable(removeChildlessNodes);
|
||||
if (mForgetSkippableCB) {
|
||||
@ -2695,10 +2692,9 @@ nsCycleCollector::PrepareForCollection(nsCycleCollectorResults *aResults,
|
||||
|
||||
mCollectionInProgress = true;
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
mozilla::services::GetObserverService();
|
||||
if (obs)
|
||||
obs->NotifyObservers(nullptr, "cycle-collector-begin", nullptr);
|
||||
if (mJSRuntime) {
|
||||
mJSRuntime->PrepareForCollection();
|
||||
}
|
||||
|
||||
mFollowupCollection = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user