mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1359245 - Remove references to context from the cycle collector (r=mccr8)
MozReview-Commit-ID: 1QoNEiZMvBf
This commit is contained in:
parent
9862d9c932
commit
34a4f034bb
@ -61,7 +61,7 @@
|
||||
#include "mozilla/dom/DOMExceptionBinding.h"
|
||||
#include "mozilla/dom/ErrorEvent.h"
|
||||
#include "nsAXPCNativeCallContext.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
#include "mozilla/SystemGroup.h"
|
||||
|
||||
#include "nsJSPrincipals.h"
|
||||
@ -81,7 +81,6 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/asmjscache/AsmJSCache.h"
|
||||
#include "mozilla/dom/CanvasRenderingContext2DBinding.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/ContentEvents.h"
|
||||
|
||||
#include "nsCycleCollectionNoteRootCallback.h"
|
||||
@ -1220,7 +1219,7 @@ nsJSContext::GarbageCollectNow(JS::gcreason::Reason aReason,
|
||||
if (sNeedsFullGC) {
|
||||
JS::PrepareForFullGC(sContext);
|
||||
} else {
|
||||
CycleCollectedJSContext::Get()->PrepareWaitingZonesForGC();
|
||||
CycleCollectedJSRuntime::Get()->PrepareWaitingZonesForGC();
|
||||
}
|
||||
|
||||
if (aIncremental == IncrementalGC) {
|
||||
@ -1941,7 +1940,7 @@ nsJSContext::PokeGC(JS::gcreason::Reason aReason,
|
||||
|
||||
if (aObj) {
|
||||
JS::Zone* zone = JS::GetObjectZone(aObj);
|
||||
CycleCollectedJSContext::Get()->AddZoneWaitingForGC(zone);
|
||||
CycleCollectedJSRuntime::Get()->AddZoneWaitingForGC(zone);
|
||||
} else if (aReason != JS::gcreason::CC_WAITING) {
|
||||
sNeedsFullGC = true;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "js/Class.h"
|
||||
#include "js/Proxy.h"
|
||||
#include "mozilla/dom/DOMJSProxyHandler.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "nsCycleCollectionTraversalCallback.h"
|
||||
#include "nsCycleCollector.h"
|
||||
@ -31,7 +31,7 @@ nsWrapperCache::HoldJSObjects(void* aScriptObjectHolder,
|
||||
{
|
||||
cyclecollector::HoldJSObjectsImpl(aScriptObjectHolder, aTracer);
|
||||
if (mWrapper && !JS::ObjectIsTenured(mWrapper)) {
|
||||
CycleCollectedJSContext::Get()->NurseryWrapperPreserved(mWrapper);
|
||||
CycleCollectedJSRuntime::Get()->NurseryWrapperPreserved(mWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ nsWrapperCache::SetWrapperJSObject(JSObject* aWrapper)
|
||||
UnsetWrapperFlags(kWrapperFlagsMask & ~WRAPPER_IS_NOT_DOM_BINDING);
|
||||
|
||||
if (aWrapper && !JS::ObjectIsTenured(aWrapper)) {
|
||||
CycleCollectedJSContext::Get()->NurseryWrapperAdded(this);
|
||||
CycleCollectedJSRuntime::Get()->NurseryWrapperAdded(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@
|
||||
#include "nsFontMetrics.h"
|
||||
#include "Units.h"
|
||||
#include "CanvasUtils.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
#include "mozilla/StyleSetHandle.h"
|
||||
#include "mozilla/StyleSetHandleInlines.h"
|
||||
#include "mozilla/layers/CanvasClient.h"
|
||||
@ -1799,7 +1799,7 @@ CanvasRenderingContext2D::RegisterAllocation()
|
||||
|
||||
JSObject* wrapper = GetWrapperPreserveColor();
|
||||
if (wrapper) {
|
||||
CycleCollectedJSContext::Get()->
|
||||
CycleCollectedJSRuntime::Get()->
|
||||
AddZoneWaitingForGC(JS::GetObjectZone(wrapper));
|
||||
}
|
||||
}
|
||||
|
@ -7407,8 +7407,8 @@ AutoAssertNoNurseryAlloc::~AutoAssertNoNurseryAlloc()
|
||||
TlsContext.get()->allowNurseryAlloc();
|
||||
}
|
||||
|
||||
JS::AutoEnterCycleCollection::AutoEnterCycleCollection(JSContext* cx)
|
||||
: runtime(cx->runtime())
|
||||
JS::AutoEnterCycleCollection::AutoEnterCycleCollection(JSRuntime* rt)
|
||||
: runtime(rt)
|
||||
{
|
||||
MOZ_ASSERT(!JS::CurrentThreadIsHeapBusy());
|
||||
TlsContext.get()->heapState = HeapState::CycleCollecting;
|
||||
|
@ -204,11 +204,11 @@ class MOZ_STACK_CLASS JS_PUBLIC_API(AutoEnterCycleCollection)
|
||||
JSRuntime* runtime;
|
||||
|
||||
public:
|
||||
explicit AutoEnterCycleCollection(JSContext* cx);
|
||||
explicit AutoEnterCycleCollection(JSRuntime* rt);
|
||||
~AutoEnterCycleCollection();
|
||||
#else
|
||||
public:
|
||||
explicit AutoEnterCycleCollection(JSContext* cx) {}
|
||||
explicit AutoEnterCycleCollection(JSRuntime* rt) {}
|
||||
~AutoEnterCycleCollection() {}
|
||||
#endif
|
||||
};
|
||||
|
@ -430,154 +430,4 @@ CycleCollectedJSContext::DispatchToMicroTask(already_AddRefed<nsIRunnable> aRunn
|
||||
mPromiseMicroTaskQueue.push(runnable.forget());
|
||||
}
|
||||
|
||||
// All these functions just delegate to the runtime.
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::FinalizeDeferredThings(DeferredFinalizeType aType)
|
||||
{
|
||||
Runtime()->FinalizeDeferredThings(aType);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer)
|
||||
{
|
||||
Runtime()->AddJSHolder(aHolder, aTracer);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::RemoveJSHolder(void* aHolder)
|
||||
{
|
||||
Runtime()->RemoveJSHolder(aHolder);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
bool
|
||||
CycleCollectedJSContext::IsJSHolder(void* aHolder)
|
||||
{
|
||||
return Runtime()->IsJSHolder(aHolder);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::AssertNoObjectsToTrace(void* aPossibleJSHolder)
|
||||
{
|
||||
Runtime()->AssertNoObjectsToTrace(aPossibleJSHolder);
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCycleCollectionParticipant*
|
||||
CycleCollectedJSContext::GCThingParticipant()
|
||||
{
|
||||
return Runtime()->GCThingParticipant();
|
||||
}
|
||||
|
||||
nsCycleCollectionParticipant*
|
||||
CycleCollectedJSContext::ZoneParticipant()
|
||||
{
|
||||
return Runtime()->ZoneParticipant();
|
||||
}
|
||||
|
||||
nsresult
|
||||
CycleCollectedJSContext::TraverseRoots(nsCycleCollectionNoteRootCallback& aCb)
|
||||
{
|
||||
return Runtime()->TraverseRoots(aCb);
|
||||
}
|
||||
|
||||
bool
|
||||
CycleCollectedJSContext::UsefulToMergeZones() const
|
||||
{
|
||||
return Runtime()->UsefulToMergeZones();
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::FixWeakMappingGrayBits() const
|
||||
{
|
||||
Runtime()->FixWeakMappingGrayBits();
|
||||
}
|
||||
|
||||
bool
|
||||
CycleCollectedJSContext::AreGCGrayBitsValid() const
|
||||
{
|
||||
return Runtime()->AreGCGrayBitsValid();
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::GarbageCollect(uint32_t aReason) const
|
||||
{
|
||||
Runtime()->GarbageCollect(aReason);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::NurseryWrapperAdded(nsWrapperCache* aCache)
|
||||
{
|
||||
Runtime()->NurseryWrapperAdded(aCache);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::NurseryWrapperPreserved(JSObject* aWrapper)
|
||||
{
|
||||
Runtime()->NurseryWrapperPreserved(aWrapper);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::JSObjectsTenured()
|
||||
{
|
||||
Runtime()->JSObjectsTenured();
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
|
||||
DeferredFinalizeFunction aFunc,
|
||||
void* aThing)
|
||||
{
|
||||
Runtime()->DeferredFinalize(aAppendFunc, aFunc, aThing);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::DeferredFinalize(nsISupports* aSupports)
|
||||
{
|
||||
Runtime()->DeferredFinalize(aSupports);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::DumpJSHeap(FILE* aFile)
|
||||
{
|
||||
Runtime()->DumpJSHeap(aFile);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::AddZoneWaitingForGC(JS::Zone* aZone)
|
||||
{
|
||||
Runtime()->AddZoneWaitingForGC(aZone);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::PrepareWaitingZonesForGC()
|
||||
{
|
||||
Runtime()->PrepareWaitingZonesForGC();
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::PrepareForForgetSkippable()
|
||||
{
|
||||
Runtime()->PrepareForForgetSkippable();
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::BeginCycleCollectionCallback()
|
||||
{
|
||||
Runtime()->BeginCycleCollectionCallback();
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::EndCycleCollectionCallback(CycleCollectorResults& aResults)
|
||||
{
|
||||
Runtime()->EndCycleCollectionCallback(aResults);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSContext::DispatchDeferredDeletion(bool aContinuation, bool aPurge)
|
||||
{
|
||||
Runtime()->DispatchDeferredDeletion(aContinuation, aPurge);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -118,9 +118,6 @@ public:
|
||||
FinalizeNow,
|
||||
};
|
||||
|
||||
void FinalizeDeferredThings(DeferredFinalizeType aType);
|
||||
|
||||
public:
|
||||
CycleCollectedJSRuntime* Runtime() const
|
||||
{
|
||||
MOZ_ASSERT(mRuntime);
|
||||
@ -133,11 +130,6 @@ public:
|
||||
std::queue<nsCOMPtr<nsIRunnable>>& GetPromiseMicroTaskQueue();
|
||||
std::queue<nsCOMPtr<nsIRunnable>>& GetDebuggerPromiseMicroTaskQueue();
|
||||
|
||||
void PrepareForForgetSkippable();
|
||||
void BeginCycleCollectionCallback();
|
||||
void EndCycleCollectionCallback(CycleCollectorResults& aResults);
|
||||
void DispatchDeferredDeletion(bool aContinuation, bool aPurge = false);
|
||||
|
||||
JSContext* Context() const
|
||||
{
|
||||
MOZ_ASSERT(mJSContext);
|
||||
@ -179,42 +171,6 @@ public:
|
||||
bool mOldValue;
|
||||
};
|
||||
|
||||
void AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer);
|
||||
void RemoveJSHolder(void* aHolder);
|
||||
#ifdef DEBUG
|
||||
bool IsJSHolder(void* aHolder);
|
||||
void AssertNoObjectsToTrace(void* aPossibleJSHolder);
|
||||
#endif
|
||||
|
||||
nsCycleCollectionParticipant* GCThingParticipant();
|
||||
nsCycleCollectionParticipant* ZoneParticipant();
|
||||
|
||||
nsresult TraverseRoots(nsCycleCollectionNoteRootCallback& aCb);
|
||||
virtual bool UsefulToMergeZones() const;
|
||||
void FixWeakMappingGrayBits() const;
|
||||
bool AreGCGrayBitsValid() const;
|
||||
void GarbageCollect(uint32_t aReason) const;
|
||||
|
||||
void NurseryWrapperAdded(nsWrapperCache* aCache);
|
||||
void NurseryWrapperPreserved(JSObject* aWrapper);
|
||||
void JSObjectsTenured();
|
||||
|
||||
void DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
|
||||
DeferredFinalizeFunction aFunc,
|
||||
void* aThing);
|
||||
void DeferredFinalize(nsISupports* aSupports);
|
||||
|
||||
void DumpJSHeap(FILE* aFile);
|
||||
|
||||
// Add aZone to the set of zones waiting for a GC.
|
||||
void AddZoneWaitingForGC(JS::Zone* aZone);
|
||||
|
||||
// Prepare any zones for GC that have been passed to AddZoneWaitingForGC()
|
||||
// since the last GC or since the last call to PrepareWaitingZonesForGC(),
|
||||
// whichever was most recent. If there were no such zones, prepare for a
|
||||
// full GC.
|
||||
void PrepareWaitingZonesForGC();
|
||||
|
||||
protected:
|
||||
JSContext* MaybeContext() const { return mJSContext; }
|
||||
|
||||
|
@ -240,6 +240,8 @@ public:
|
||||
void OnOutOfMemory();
|
||||
void OnLargeAllocationFailure();
|
||||
|
||||
JSRuntime* Runtime() { return mJSRuntime; }
|
||||
|
||||
public:
|
||||
void AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer);
|
||||
void RemoveJSHolder(void* aHolder);
|
||||
|
@ -7,14 +7,14 @@
|
||||
#include "mozilla/DeferredFinalize.h"
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
|
||||
void
|
||||
mozilla::DeferredFinalize(nsISupports* aSupports)
|
||||
{
|
||||
CycleCollectedJSContext* cx = CycleCollectedJSContext::Get();
|
||||
MOZ_ASSERT(cx, "Should have a CycleCollectedJSContext by now");
|
||||
cx->DeferredFinalize(aSupports);
|
||||
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
|
||||
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
|
||||
rt->DeferredFinalize(aSupports);
|
||||
}
|
||||
|
||||
void
|
||||
@ -22,7 +22,7 @@ mozilla::DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
|
||||
DeferredFinalizeFunction aFunc,
|
||||
void* aThing)
|
||||
{
|
||||
CycleCollectedJSContext* cx = CycleCollectedJSContext::Get();
|
||||
MOZ_ASSERT(cx, "Should have a CycleCollectedJSContext by now");
|
||||
cx->DeferredFinalize(aAppendFunc, aFunc, aThing);
|
||||
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
|
||||
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
|
||||
rt->DeferredFinalize(aAppendFunc, aFunc, aThing);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace cyclecollector {
|
||||
@ -15,9 +15,9 @@ namespace cyclecollector {
|
||||
void
|
||||
HoldJSObjectsImpl(void* aHolder, nsScriptObjectTracer* aTracer)
|
||||
{
|
||||
CycleCollectedJSContext* cx = CycleCollectedJSContext::Get();
|
||||
MOZ_ASSERT(cx, "Should have a CycleCollectedJSContext by now");
|
||||
cx->AddJSHolder(aHolder, aTracer);
|
||||
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
|
||||
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
|
||||
rt->AddJSHolder(aHolder, aTracer);
|
||||
}
|
||||
|
||||
void
|
||||
@ -35,9 +35,9 @@ HoldJSObjectsImpl(nsISupports* aHolder)
|
||||
void
|
||||
DropJSObjectsImpl(void* aHolder)
|
||||
{
|
||||
CycleCollectedJSContext* cx = CycleCollectedJSContext::Get();
|
||||
MOZ_ASSERT(cx, "Should have a CycleCollectedJSContext by now");
|
||||
cx->RemoveJSHolder(aHolder);
|
||||
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
|
||||
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
|
||||
rt->RemoveJSHolder(aHolder);
|
||||
}
|
||||
|
||||
void
|
||||
@ -59,9 +59,9 @@ DropJSObjectsImpl(nsISupports* aHolder)
|
||||
bool
|
||||
IsJSHolder(void* aHolder)
|
||||
{
|
||||
CycleCollectedJSContext* cx = CycleCollectedJSContext::Get();
|
||||
MOZ_ASSERT(cx, "Should have a CycleCollectedJSContext by now");
|
||||
return cx->IsJSHolder(aHolder);
|
||||
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
|
||||
MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
|
||||
return rt->IsJSHolder(aHolder);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1269,7 +1269,7 @@ private:
|
||||
CycleCollectorResults mResults;
|
||||
TimeStamp mCollectionStart;
|
||||
|
||||
CycleCollectedJSContext* mJSContext;
|
||||
CycleCollectedJSRuntime* mCCJSRuntime;
|
||||
|
||||
ccPhase mIncrementalPhase;
|
||||
CCGraph mGraph;
|
||||
@ -1300,8 +1300,8 @@ private:
|
||||
public:
|
||||
nsCycleCollector();
|
||||
|
||||
void RegisterJSContext(CycleCollectedJSContext* aJSContext);
|
||||
void ForgetJSContext();
|
||||
void SetCCJSRuntime(CycleCollectedJSRuntime* aCCRuntime);
|
||||
void ClearCCJSRuntime();
|
||||
|
||||
void SetBeforeUnlinkCallback(CC_BeforeUnlinkCallback aBeforeUnlinkCB)
|
||||
{
|
||||
@ -1342,7 +1342,7 @@ public:
|
||||
|
||||
JSPurpleBuffer* GetJSPurpleBuffer();
|
||||
|
||||
CycleCollectedJSContext* Context() { return mJSContext; }
|
||||
CycleCollectedJSRuntime* Runtime() { return mCCJSRuntime; }
|
||||
|
||||
private:
|
||||
void CheckThreadSafety();
|
||||
@ -1835,7 +1835,7 @@ public:
|
||||
// Dump the JS heap.
|
||||
CollectorData* data = sCollectorData.get();
|
||||
if (data && data->mContext) {
|
||||
data->mContext->DumpJSHeap(gcLog);
|
||||
data->mContext->Runtime()->DumpJSHeap(gcLog);
|
||||
}
|
||||
rv = mLogSink->CloseGCLog();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -2077,7 +2077,7 @@ private:
|
||||
public:
|
||||
CCGraphBuilder(CCGraph& aGraph,
|
||||
CycleCollectorResults& aResults,
|
||||
CycleCollectedJSContext* aJSContext,
|
||||
CycleCollectedJSRuntime* aCCRuntime,
|
||||
nsCycleCollectorLogger* aLogger,
|
||||
bool aMergeZones);
|
||||
virtual ~CCGraphBuilder();
|
||||
@ -2174,7 +2174,7 @@ private:
|
||||
|
||||
CCGraphBuilder::CCGraphBuilder(CCGraph& aGraph,
|
||||
CycleCollectorResults& aResults,
|
||||
CycleCollectedJSContext* aJSContext,
|
||||
CycleCollectedJSRuntime* aCCRuntime,
|
||||
nsCycleCollectorLogger* aLogger,
|
||||
bool aMergeZones)
|
||||
: mGraph(aGraph)
|
||||
@ -2186,9 +2186,9 @@ CCGraphBuilder::CCGraphBuilder(CCGraph& aGraph,
|
||||
, mLogger(aLogger)
|
||||
, mMergeZones(aMergeZones)
|
||||
{
|
||||
if (aJSContext) {
|
||||
mJSParticipant = aJSContext->GCThingParticipant();
|
||||
mJSZoneParticipant = aJSContext->ZoneParticipant();
|
||||
if (aCCRuntime) {
|
||||
mJSParticipant = aCCRuntime->GCThingParticipant();
|
||||
mJSZoneParticipant = aCCRuntime->ZoneParticipant();
|
||||
}
|
||||
|
||||
if (mLogger) {
|
||||
@ -2659,7 +2659,7 @@ public:
|
||||
mCollector->RemoveObjectFromGraph(o.mPointer);
|
||||
o.mRefCnt->stabilizeForDeletion();
|
||||
{
|
||||
JS::AutoEnterCycleCollection autocc(mCollector->Context()->Context());
|
||||
JS::AutoEnterCycleCollection autocc(mCollector->Runtime()->Runtime());
|
||||
o.mParticipant->Trace(o.mPointer, *this, nullptr);
|
||||
}
|
||||
o.mParticipant->DeleteCycleCollectable(o.mPointer);
|
||||
@ -2856,8 +2856,8 @@ nsCycleCollector::ForgetSkippable(bool aRemoveChildlessNodes,
|
||||
// lose track of an object that was mutated during graph building.
|
||||
MOZ_ASSERT(IsIdle());
|
||||
|
||||
if (mJSContext) {
|
||||
mJSContext->PrepareForForgetSkippable();
|
||||
if (mCCJSRuntime) {
|
||||
mCCJSRuntime->PrepareForForgetSkippable();
|
||||
}
|
||||
MOZ_ASSERT(!mScanInProgress,
|
||||
"Don't forget skippable or free snow-white while scan is in progress.");
|
||||
@ -2875,7 +2875,7 @@ nsCycleCollector::MarkRoots(SliceBudget& aBudget)
|
||||
mScanInProgress = true;
|
||||
MOZ_ASSERT(mIncrementalPhase == GraphBuildingPhase);
|
||||
|
||||
JS::AutoEnterCycleCollection autocc(Context()->Context());
|
||||
JS::AutoEnterCycleCollection autocc(Runtime()->Runtime());
|
||||
bool doneBuilding = mBuilder->BuildGraph(aBudget);
|
||||
|
||||
if (!doneBuilding) {
|
||||
@ -3042,11 +3042,11 @@ nsCycleCollector::ScanIncrementalRoots()
|
||||
mPurpleBuf.VisitEntries(purpleScanBlackVisitor);
|
||||
timeLog.Checkpoint("ScanIncrementalRoots::fix purple");
|
||||
|
||||
bool hasJSContext = !!mJSContext;
|
||||
bool hasJSRuntime = !!mCCJSRuntime;
|
||||
nsCycleCollectionParticipant* jsParticipant =
|
||||
hasJSContext ? mJSContext->GCThingParticipant() : nullptr;
|
||||
hasJSRuntime ? mCCJSRuntime->GCThingParticipant() : nullptr;
|
||||
nsCycleCollectionParticipant* zoneParticipant =
|
||||
hasJSContext ? mJSContext->ZoneParticipant() : nullptr;
|
||||
hasJSRuntime ? mCCJSRuntime->ZoneParticipant() : nullptr;
|
||||
bool hasLogger = !!mLogger;
|
||||
|
||||
NodePool::Enumerator etor(mGraph.mNodes);
|
||||
@ -3065,7 +3065,7 @@ nsCycleCollector::ScanIncrementalRoots()
|
||||
// now marked black by the GC, it was probably gray before and was exposed
|
||||
// to active JS, so it may have been stored somewhere, so it needs to be
|
||||
// treated as live.
|
||||
if (pi->IsGrayJS() && MOZ_LIKELY(hasJSContext)) {
|
||||
if (pi->IsGrayJS() && MOZ_LIKELY(hasJSRuntime)) {
|
||||
// If the object is still marked gray by the GC, nothing could have gotten
|
||||
// hold of it, so it isn't an incremental root.
|
||||
if (pi->mParticipant == jsParticipant) {
|
||||
@ -3197,7 +3197,7 @@ nsCycleCollector::ScanRoots(bool aFullySynchGraphBuild)
|
||||
mWhiteNodeCount = 0;
|
||||
MOZ_ASSERT(mIncrementalPhase == ScanAndCollectWhitePhase);
|
||||
|
||||
JS::AutoEnterCycleCollection autocc(Context()->Context());
|
||||
JS::AutoEnterCycleCollection autocc(Runtime()->Runtime());
|
||||
|
||||
if (!aFullySynchGraphBuild) {
|
||||
ScanIncrementalRoots();
|
||||
@ -3282,16 +3282,16 @@ nsCycleCollector::CollectWhite()
|
||||
|
||||
{
|
||||
JS::AutoAssertNoGC nogc;
|
||||
bool hasJSContext = !!mJSContext;
|
||||
bool hasJSRuntime = !!mCCJSRuntime;
|
||||
nsCycleCollectionParticipant* zoneParticipant =
|
||||
hasJSContext ? mJSContext->ZoneParticipant() : nullptr;
|
||||
hasJSRuntime ? mCCJSRuntime->ZoneParticipant() : nullptr;
|
||||
|
||||
NodePool::Enumerator etor(mGraph.mNodes);
|
||||
while (!etor.IsDone()) {
|
||||
PtrInfo* pinfo = etor.GetNext();
|
||||
if (pinfo->mColor == white && pinfo->mParticipant) {
|
||||
if (pinfo->IsGrayJS()) {
|
||||
MOZ_ASSERT(mJSContext);
|
||||
MOZ_ASSERT(mCCJSRuntime);
|
||||
++numWhiteGCed;
|
||||
JS::Zone* zone;
|
||||
if (MOZ_UNLIKELY(pinfo->mParticipant == zoneParticipant)) {
|
||||
@ -3301,7 +3301,7 @@ nsCycleCollector::CollectWhite()
|
||||
JS::GCCellPtr ptr(pinfo->mPointer, JS::GCThingTraceKind(pinfo->mPointer));
|
||||
zone = JS::GetTenuredGCThingZone(ptr);
|
||||
}
|
||||
mJSContext->AddZoneWaitingForGC(zone);
|
||||
mCCJSRuntime->AddZoneWaitingForGC(zone);
|
||||
} else {
|
||||
whiteNodes.InfallibleAppend(pinfo);
|
||||
pinfo->mParticipant->Root(pinfo->mPointer);
|
||||
@ -3331,8 +3331,8 @@ nsCycleCollector::CollectWhite()
|
||||
"Unlink shouldn't see objects removed from graph.");
|
||||
pinfo->mParticipant->Unlink(pinfo->mPointer);
|
||||
#ifdef DEBUG
|
||||
if (mJSContext) {
|
||||
mJSContext->AssertNoObjectsToTrace(pinfo->mPointer);
|
||||
if (mCCJSRuntime) {
|
||||
mCCJSRuntime->AssertNoObjectsToTrace(pinfo->mPointer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -3405,7 +3405,7 @@ nsCycleCollector::nsCycleCollector() :
|
||||
mActivelyCollecting(false),
|
||||
mFreeingSnowWhite(false),
|
||||
mScanInProgress(false),
|
||||
mJSContext(nullptr),
|
||||
mCCJSRuntime(nullptr),
|
||||
mIncrementalPhase(IdlePhase),
|
||||
#ifdef DEBUG
|
||||
mThread(NS_GetCurrentThread()),
|
||||
@ -3424,10 +3424,10 @@ nsCycleCollector::~nsCycleCollector()
|
||||
}
|
||||
|
||||
void
|
||||
nsCycleCollector::RegisterJSContext(CycleCollectedJSContext* aJSContext)
|
||||
nsCycleCollector::SetCCJSRuntime(CycleCollectedJSRuntime* aCCRuntime)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(!mJSContext, "Multiple registrations of JS context in cycle collector");
|
||||
mJSContext = aJSContext;
|
||||
MOZ_RELEASE_ASSERT(!mCCJSRuntime, "Multiple registrations of CycleCollectedJSRuntime in cycle collector");
|
||||
mCCJSRuntime = aCCRuntime;
|
||||
|
||||
if (!NS_IsMainThread()) {
|
||||
return;
|
||||
@ -3440,10 +3440,10 @@ nsCycleCollector::RegisterJSContext(CycleCollectedJSContext* aJSContext)
|
||||
}
|
||||
|
||||
void
|
||||
nsCycleCollector::ForgetJSContext()
|
||||
nsCycleCollector::ClearCCJSRuntime()
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(mJSContext, "Forgetting JS context in cycle collector before a JS context was registered");
|
||||
mJSContext = nullptr;
|
||||
MOZ_RELEASE_ASSERT(mCCJSRuntime, "Clearing CycleCollectedJSRuntime in cycle collector before a runtime was registered");
|
||||
mCCJSRuntime = nullptr;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -3503,15 +3503,15 @@ nsCycleCollector::FixGrayBits(bool aForceGC, TimeLog& aTimeLog)
|
||||
{
|
||||
CheckThreadSafety();
|
||||
|
||||
if (!mJSContext) {
|
||||
if (!mCCJSRuntime) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aForceGC) {
|
||||
mJSContext->FixWeakMappingGrayBits();
|
||||
mCCJSRuntime->FixWeakMappingGrayBits();
|
||||
aTimeLog.Checkpoint("FixWeakMappingGrayBits");
|
||||
|
||||
bool needGC = !mJSContext->AreGCGrayBitsValid();
|
||||
bool needGC = !mCCJSRuntime->AreGCGrayBitsValid();
|
||||
// Only do a telemetry ping for non-shutdown CCs.
|
||||
CC_TELEMETRY(_NEED_GC, needGC);
|
||||
if (!needGC) {
|
||||
@ -3522,16 +3522,16 @@ nsCycleCollector::FixGrayBits(bool aForceGC, TimeLog& aTimeLog)
|
||||
|
||||
uint32_t count = 0;
|
||||
do {
|
||||
mJSContext->GarbageCollect(aForceGC ? JS::gcreason::SHUTDOWN_CC :
|
||||
mCCJSRuntime->GarbageCollect(aForceGC ? JS::gcreason::SHUTDOWN_CC :
|
||||
JS::gcreason::CC_FORCED);
|
||||
|
||||
mJSContext->FixWeakMappingGrayBits();
|
||||
mCCJSRuntime->FixWeakMappingGrayBits();
|
||||
|
||||
// It's possible that FixWeakMappingGrayBits will hit OOM when unmarking
|
||||
// gray and we will have to go round again. The second time there should not
|
||||
// be any weak mappings to fix up so the loop body should run at most twice.
|
||||
MOZ_RELEASE_ASSERT(count++ < 2);
|
||||
} while (!mJSContext->AreGCGrayBitsValid());
|
||||
} while (!mCCJSRuntime->AreGCGrayBitsValid());
|
||||
|
||||
aTimeLog.Checkpoint("FixGrayBits");
|
||||
}
|
||||
@ -3539,7 +3539,7 @@ nsCycleCollector::FixGrayBits(bool aForceGC, TimeLog& aTimeLog)
|
||||
bool
|
||||
nsCycleCollector::IsIncrementalGCInProgress()
|
||||
{
|
||||
return mJSContext && JS::IsIncrementalGCInProgress(mJSContext->Context());
|
||||
return mCCJSRuntime && JS::IsIncrementalGCInProgress(mCCJSRuntime->Runtime());
|
||||
}
|
||||
|
||||
void
|
||||
@ -3547,8 +3547,9 @@ nsCycleCollector::FinishAnyIncrementalGCInProgress()
|
||||
{
|
||||
if (IsIncrementalGCInProgress()) {
|
||||
NS_WARNING("Finishing incremental GC in progress during CC");
|
||||
JS::PrepareForIncrementalGC(mJSContext->Context());
|
||||
JS::FinishIncrementalGC(mJSContext->Context(), JS::gcreason::CC_FORCED);
|
||||
JSContext* cx = CycleCollectedJSContext::Get()->Context();
|
||||
JS::PrepareForIncrementalGC(cx);
|
||||
JS::FinishIncrementalGC(cx, JS::gcreason::CC_FORCED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3582,11 +3583,11 @@ nsCycleCollector::CleanupAfterCollection()
|
||||
CC_TELEMETRY(_COLLECTED, mWhiteNodeCount);
|
||||
timeLog.Checkpoint("CleanupAfterCollection::telemetry");
|
||||
|
||||
if (mJSContext) {
|
||||
mJSContext->FinalizeDeferredThings(mResults.mAnyManual
|
||||
if (mCCJSRuntime) {
|
||||
mCCJSRuntime->FinalizeDeferredThings(mResults.mAnyManual
|
||||
? CycleCollectedJSContext::FinalizeNow
|
||||
: CycleCollectedJSContext::FinalizeIncrementally);
|
||||
mJSContext->EndCycleCollectionCallback(mResults);
|
||||
mCCJSRuntime->EndCycleCollectionCallback(mResults);
|
||||
timeLog.Checkpoint("CleanupAfterCollection::EndCycleCollectionCallback()");
|
||||
}
|
||||
mIncrementalPhase = IdlePhase;
|
||||
@ -3764,7 +3765,7 @@ static const uint32_t kMaxConsecutiveMerged = 3;
|
||||
bool
|
||||
nsCycleCollector::ShouldMergeZones(ccType aCCType)
|
||||
{
|
||||
if (!mJSContext) {
|
||||
if (!mCCJSRuntime) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3782,7 +3783,7 @@ nsCycleCollector::ShouldMergeZones(ccType aCCType)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aCCType == SliceCC && mJSContext->UsefulToMergeZones()) {
|
||||
if (aCCType == SliceCC && mCCJSRuntime->UsefulToMergeZones()) {
|
||||
mMergedInARow++;
|
||||
return true;
|
||||
} else {
|
||||
@ -3800,8 +3801,8 @@ nsCycleCollector::BeginCollection(ccType aCCType,
|
||||
|
||||
mCollectionStart = TimeStamp::Now();
|
||||
|
||||
if (mJSContext) {
|
||||
mJSContext->BeginCycleCollectionCallback();
|
||||
if (mCCJSRuntime) {
|
||||
mCCJSRuntime->BeginCycleCollectionCallback();
|
||||
timeLog.Checkpoint("BeginCycleCollectionCallback()");
|
||||
}
|
||||
|
||||
@ -3833,8 +3834,8 @@ nsCycleCollector::BeginCollection(ccType aCCType,
|
||||
timeLog.Checkpoint("Pre-FixGrayBits finish IGC");
|
||||
|
||||
FixGrayBits(forceGC, timeLog);
|
||||
if (mJSContext) {
|
||||
mJSContext->Runtime()->CheckGrayBits();
|
||||
if (mCCJSRuntime) {
|
||||
mCCJSRuntime->CheckGrayBits();
|
||||
}
|
||||
|
||||
FreeSnowWhite(true);
|
||||
@ -3851,7 +3852,7 @@ nsCycleCollector::BeginCollection(ccType aCCType,
|
||||
|
||||
// Set up the data structures for building the graph.
|
||||
JS::AutoAssertNoGC nogc;
|
||||
JS::AutoEnterCycleCollection autocc(mJSContext->Context());
|
||||
JS::AutoEnterCycleCollection autocc(mCCJSRuntime->Runtime());
|
||||
mGraph.Init();
|
||||
mResults.Init();
|
||||
mResults.mAnyManual = (aCCType != SliceCC);
|
||||
@ -3859,12 +3860,12 @@ nsCycleCollector::BeginCollection(ccType aCCType,
|
||||
mResults.mMergedZones = mergeZones;
|
||||
|
||||
MOZ_ASSERT(!mBuilder, "Forgot to clear mBuilder");
|
||||
mBuilder = new CCGraphBuilder(mGraph, mResults, mJSContext, mLogger,
|
||||
mBuilder = new CCGraphBuilder(mGraph, mResults, mCCJSRuntime, mLogger,
|
||||
mergeZones);
|
||||
timeLog.Checkpoint("BeginCollection prepare graph builder");
|
||||
|
||||
if (mJSContext) {
|
||||
mJSContext->TraverseRoots(*mBuilder);
|
||||
if (mCCJSRuntime) {
|
||||
mCCJSRuntime->TraverseRoots(*mBuilder);
|
||||
timeLog.Checkpoint("mJSContext->TraverseRoots()");
|
||||
}
|
||||
|
||||
@ -3921,7 +3922,7 @@ nsCycleCollector::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
*aPurpleBufferSize = mPurpleBuf.SizeOfExcludingThis(aMallocSizeOf);
|
||||
|
||||
// These fields are deliberately not measured:
|
||||
// - mJSContext: because it's non-owning and measured by JS reporters.
|
||||
// - mCCJSRuntime: because it's non-owning and measured by JS reporters.
|
||||
// - mParams: because it only contains scalars.
|
||||
}
|
||||
|
||||
@ -3956,7 +3957,7 @@ nsCycleCollector_registerJSContext(CycleCollectedJSContext* aCx)
|
||||
MOZ_ASSERT(!data->mContext);
|
||||
|
||||
data->mContext = aCx;
|
||||
data->mCollector->RegisterJSContext(aCx);
|
||||
data->mCollector->SetCCJSRuntime(aCx->Runtime());
|
||||
}
|
||||
|
||||
void
|
||||
@ -3971,7 +3972,7 @@ nsCycleCollector_forgetJSContext()
|
||||
|
||||
// But it may have shutdown already.
|
||||
if (data->mCollector) {
|
||||
data->mCollector->ForgetJSContext();
|
||||
data->mCollector->ClearCCJSRuntime();
|
||||
data->mContext = nullptr;
|
||||
} else {
|
||||
data->mContext = nullptr;
|
||||
@ -4156,9 +4157,9 @@ nsCycleCollector_forgetSkippable(bool aRemoveChildlessNodes,
|
||||
void
|
||||
nsCycleCollector_dispatchDeferredDeletion(bool aContinuation, bool aPurge)
|
||||
{
|
||||
CycleCollectedJSContext* cx = CycleCollectedJSContext::Get();
|
||||
if (cx) {
|
||||
cx->DispatchDeferredDeletion(aContinuation, aPurge);
|
||||
CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
|
||||
if (rt) {
|
||||
rt->DispatchDeferredDeletion(aContinuation, aPurge);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user