From e75fcfb043bca10ffb54f02de00f8a7746ad63e5 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Sun, 4 Jan 2015 21:12:19 -0800 Subject: [PATCH] Backed out 4 changesets (bug 1116821, bug 1110928) for Windows OOMs CLOSED TREE Backed out changeset 9d593597df5f (bug 1110928) Backed out changeset d68c75986335 (bug 1110928) Backed out changeset 21d807074550 (bug 1110928) Backed out changeset ca77252e50dd (bug 1116821) --- dom/base/nsGlobalWindow.cpp | 3 ++- dom/base/nsJSEnvironment.cpp | 32 +++++++++----------------------- dom/base/nsJSEnvironment.h | 3 +-- layout/base/nsDocumentViewer.cpp | 14 +++----------- 4 files changed, 15 insertions(+), 37 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 7fd39ce5a345..7bb08d31ed18 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2680,6 +2680,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, newInnerWindow->mChromeEventHandler = mChromeEventHandler; } + nsJSContext::PokeGC(JS::gcreason::SET_NEW_DOCUMENT); mContext->DidInitializeContext(); // We wait to fire the debugger hook until the window is all set up and hooked @@ -2902,7 +2903,7 @@ nsGlobalWindow::DetachFromDocShell() mChromeEventHandler = nullptr; // force release now if (mContext) { - nsJSContext::PokeGC(JS::gcreason::SET_DOC_SHELL, GetWrapperPreserveColor()); + nsJSContext::PokeGC(JS::gcreason::SET_DOC_SHELL); mContext = nullptr; } diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index c00e1af349ee..fa422ff87088 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -654,7 +654,7 @@ nsJSContext::DestroyJSContext() js_options_dot_str, this); if (mGCOnDestruction) { - PokeGC(JS::gcreason::NSJSCONTEXT_DESTROY, mWindowProxy); + PokeGC(JS::gcreason::NSJSCONTEXT_DESTROY); } JS_DestroyContextNoGC(mContext); @@ -1463,11 +1463,8 @@ nsJSContext::GarbageCollectNow(JS::gcreason::Reason aReason, return; } - if (aIncremental == NonIncrementalGC || aReason == JS::gcreason::FULL_GC_TIMER) { - sNeedsFullGC = true; - } - - if (sNeedsFullGC) { + if (sNeedsFullGC || aReason != JS::gcreason::CC_WAITING) { + sNeedsFullGC = false; JS::PrepareForFullGC(sRuntime); } else { CycleCollectedJSRuntime::Get()->PrepareWaitingZonesForGC(); @@ -1828,7 +1825,7 @@ nsJSContext::EndCycleCollectionCallback(CycleCollectorResults &aResults) uint32_t ccNowDuration = TimeBetween(gCCStats.mBeginTime, endCCTimeStamp); if (NeedsGCAfterCC()) { - PokeGC(JS::gcreason::CC_WAITING, nullptr, + PokeGC(JS::gcreason::CC_WAITING, NS_GC_DELAY - std::min(ccNowDuration, kMaxICCDuration)); } @@ -2092,7 +2089,9 @@ nsJSContext::LoadEnd() return; } + // Its probably a good idea to GC soon since we have finished loading. sLoadingInProgress = false; + PokeGC(JS::gcreason::LOAD_END); } // Only trigger expensive timers when they have been checked a number of times. @@ -2155,20 +2154,11 @@ nsJSContext::RunNextCollectorTimer() // static void -nsJSContext::PokeGC(JS::gcreason::Reason aReason, JSObject* aObj, int aDelay) +nsJSContext::PokeGC(JS::gcreason::Reason aReason, int aDelay) { - if (sShuttingDown) { - return; - } + sNeedsFullGC = sNeedsFullGC || aReason != JS::gcreason::CC_WAITING; - if (aObj) { - JS::Zone* zone = JS::GetTenuredGCThingZone(aObj); - CycleCollectedJSRuntime::Get()->AddZoneWaitingForGC(zone); - } else if (aReason != JS::gcreason::CC_WAITING) { - sNeedsFullGC = true; - } - - if (sGCTimer || sInterSliceGCTimer) { + if (sGCTimer || sInterSliceGCTimer || sShuttingDown) { // There's already a timer for GC'ing, just return return; } @@ -2351,10 +2341,6 @@ DOMGCSliceCallback(JSRuntime *aRt, JS::GCProgress aProgress, const JS::GCDescrip nsJSContext::KillShrinkGCBuffersTimer(); - if (!aDesc.isCompartment_) { - sNeedsFullGC = false; - } - break; } diff --git a/dom/base/nsJSEnvironment.h b/dom/base/nsJSEnvironment.h index 9b0bd6c26964..d090549d3604 100644 --- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -110,8 +110,7 @@ public: static void RunNextCollectorTimer(); - // 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 PokeGC(JS::gcreason::Reason aReason, int aDelay = 0); static void KillGCTimer(); static void PokeShrinkGCBuffers(); diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 6f40db81fcaa..4b32c6397e2f 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1039,10 +1039,6 @@ nsDocumentViewer::LoadComplete(nsresult aStatus) nsJSContext::LoadEnd(); - // It's probably a good idea to GC soon since we have finished loading. - nsJSContext::PokeGC(JS::gcreason::LOAD_END, - mDocument ? mDocument->GetWrapperPreserveColor() : nullptr); - #ifdef NS_PRINTING // Check to see if someone tried to print during the load if (mPrintIsPending) { @@ -1315,13 +1311,6 @@ nsDocumentViewer::PageHide(bool aIsUnload) return NS_ERROR_NULL_POINTER; } - if (aIsUnload) { - // Poke the GC. The window might be collectable garbage now. - nsJSContext::PokeGC(JS::gcreason::PAGE_HIDE, - mDocument->GetWrapperPreserveColor(), - NS_GC_DELAY * 2); - } - mDocument->OnPageHide(!aIsUnload, nullptr); // inform the window so that the focus state is reset. @@ -1331,6 +1320,9 @@ nsDocumentViewer::PageHide(bool aIsUnload) window->PageHidden(); if (aIsUnload) { + // Poke the GC. The window might be collectable garbage now. + nsJSContext::PokeGC(JS::gcreason::PAGE_HIDE, NS_GC_DELAY * 2); + // if Destroy() was called during OnPageHide(), mDocument is nullptr. NS_ENSURE_STATE(mDocument);