зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1110928, part 4 - Try to pass a relevant zone to PokeGC. r=smaug
--HG-- extra : rebase_source : 839ac8ef6e0de1a69240f2986c07e1793e750b21
This commit is contained in:
Родитель
a407d25b5e
Коммит
3c54dab20c
|
@ -3144,7 +3144,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
|||
newInnerWindow->mChromeEventHandler = mChromeEventHandler;
|
||||
}
|
||||
|
||||
nsJSContext::PokeGC(JS::gcreason::SET_NEW_DOCUMENT);
|
||||
nsJSContext::PokeGC(JS::gcreason::SET_NEW_DOCUMENT, nullptr);
|
||||
kungFuDeathGrip->DidInitializeContext();
|
||||
|
||||
// We wait to fire the debugger hook until the window is all set up and hooked
|
||||
|
@ -3374,7 +3374,8 @@ nsGlobalWindow::DetachFromDocShell()
|
|||
mChromeEventHandler = nullptr; // force release now
|
||||
|
||||
if (mContext) {
|
||||
nsJSContext::PokeGC(JS::gcreason::SET_DOC_SHELL);
|
||||
nsJSContext::PokeGC(JS::gcreason::SET_DOC_SHELL,
|
||||
GetWrapperPreserveColor());
|
||||
mContext = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -604,7 +604,7 @@ void
|
|||
nsJSContext::Destroy()
|
||||
{
|
||||
if (mGCOnDestruction) {
|
||||
PokeGC(JS::gcreason::NSJSCONTEXT_DESTROY);
|
||||
PokeGC(JS::gcreason::NSJSCONTEXT_DESTROY, mWindowProxy);
|
||||
}
|
||||
|
||||
DropJSObjects(this);
|
||||
|
@ -1202,8 +1202,11 @@ nsJSContext::GarbageCollectNow(JS::gcreason::Reason aReason,
|
|||
|
||||
JSGCInvocationKind gckind = aShrinking == ShrinkingGC ? GC_SHRINK : GC_NORMAL;
|
||||
|
||||
if (sNeedsFullGC || aReason != JS::gcreason::CC_WAITING) {
|
||||
sNeedsFullGC = false;
|
||||
if (aIncremental == NonIncrementalGC || aReason == JS::gcreason::FULL_GC_TIMER) {
|
||||
sNeedsFullGC = true;
|
||||
}
|
||||
|
||||
if (sNeedsFullGC) {
|
||||
JS::PrepareForFullGC(sContext);
|
||||
} else {
|
||||
CycleCollectedJSContext::Get()->PrepareWaitingZonesForGC();
|
||||
|
@ -1580,7 +1583,7 @@ nsJSContext::EndCycleCollectionCallback(CycleCollectorResults &aResults)
|
|||
uint32_t ccNowDuration = TimeBetween(gCCStats.mBeginTime, endCCTimeStamp);
|
||||
|
||||
if (NeedsGCAfterCC()) {
|
||||
PokeGC(JS::gcreason::CC_WAITING,
|
||||
PokeGC(JS::gcreason::CC_WAITING, nullptr,
|
||||
NS_GC_DELAY - std::min(ccNowDuration, kMaxICCDuration));
|
||||
}
|
||||
|
||||
|
@ -1913,11 +1916,22 @@ nsJSContext::RunNextCollectorTimer()
|
|||
|
||||
// static
|
||||
void
|
||||
nsJSContext::PokeGC(JS::gcreason::Reason aReason, int aDelay)
|
||||
nsJSContext::PokeGC(JS::gcreason::Reason aReason,
|
||||
JSObject* aObj,
|
||||
int aDelay)
|
||||
{
|
||||
sNeedsFullGC = sNeedsFullGC || aReason != JS::gcreason::CC_WAITING;
|
||||
if (sShuttingDown) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sGCTimer || sInterSliceGCTimer || sShuttingDown) {
|
||||
if (aObj) {
|
||||
JS::Zone* zone = JS::GetObjectZone(aObj);
|
||||
CycleCollectedJSContext::Get()->AddZoneWaitingForGC(zone);
|
||||
} else if (aReason != JS::gcreason::CC_WAITING) {
|
||||
sNeedsFullGC = true;
|
||||
}
|
||||
|
||||
if (sGCTimer || sInterSliceGCTimer) {
|
||||
// There's already a timer for GC'ing, just return
|
||||
return;
|
||||
}
|
||||
|
@ -2160,6 +2174,10 @@ DOMGCSliceCallback(JSContext* aCx, JS::GCProgress aProgress, const JS::GCDescrip
|
|||
nsCycleCollector_dispatchDeferredDeletion();
|
||||
}
|
||||
|
||||
if (!aDesc.isZone_) {
|
||||
sNeedsFullGC = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,8 @@ public:
|
|||
|
||||
static void RunNextCollectorTimer();
|
||||
|
||||
static void PokeGC(JS::gcreason::Reason aReason, int aDelay = 0);
|
||||
// The GC should probably run soon, in the zone of object aObj (if given).
|
||||
static void PokeGC(JS::gcreason::Reason aReason, JSObject* aObj, int aDelay = 0);
|
||||
static void KillGCTimer();
|
||||
|
||||
static void PokeShrinkingGC();
|
||||
|
|
|
@ -1086,7 +1086,8 @@ nsDocumentViewer::LoadComplete(nsresult aStatus)
|
|||
nsJSContext::LoadEnd();
|
||||
|
||||
// It's probably a good idea to GC soon since we have finished loading.
|
||||
PokeGC(JS::gcreason::LOAD_END);
|
||||
nsJSContext::PokeGC(JS::gcreason::LOAD_END,
|
||||
mDocument ? mDocument->GetWrapperPreserveColor() : nullptr);
|
||||
|
||||
#ifdef NS_PRINTING
|
||||
// Check to see if someone tried to print during the load
|
||||
|
@ -1339,7 +1340,9 @@ nsDocumentViewer::PageHide(bool aIsUnload)
|
|||
|
||||
if (aIsUnload) {
|
||||
// Poke the GC. The window might be collectable garbage now.
|
||||
nsJSContext::PokeGC(JS::gcreason::PAGE_HIDE, NS_GC_DELAY * 2);
|
||||
nsJSContext::PokeGC(JS::gcreason::PAGE_HIDE,
|
||||
mDocument->GetWrapperPreserveColor(),
|
||||
NS_GC_DELAY * 2);
|
||||
}
|
||||
|
||||
mDocument->OnPageHide(!aIsUnload, nullptr);
|
||||
|
|
Загрузка…
Ссылка в новой задаче