From 4f50fb67821e267aeeddeb97eb3e3c3198a3ac49 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Tue, 24 Feb 2015 15:11:08 -0500 Subject: [PATCH] Backed out changeset cd6461410a7a (bug 1130439) for frequent SM test timeouts/failures. CLOSED TREE --- dom/base/nsJSEnvironment.cpp | 92 +++++++----------------------------- dom/base/nsJSEnvironment.h | 3 -- js/public/GCAPI.h | 3 +- js/src/jsfriendapi.cpp | 4 +- js/src/jsgc.cpp | 5 +- js/src/vm/Runtime.cpp | 3 +- js/src/vm/Runtime.h | 3 -- modules/libpref/init/all.js | 1 - 8 files changed, 20 insertions(+), 94 deletions(-) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index e9e7b97ab3f..35bc0df9233 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -107,10 +107,6 @@ const size_t gStackSize = 8192; #define NS_FULL_GC_DELAY 60000 // ms -// The amount of time to wait from the user being idle to starting a shrinking -// GC. -#define NS_SHRINKING_GC_DELAY 15000 // ms - // Maximum amount of time that should elapse between incremental GC slices #define NS_INTERSLICE_GC_DELAY 100 // ms @@ -152,7 +148,6 @@ static const uint32_t kMaxICCDuration = 2000; // ms static nsITimer *sGCTimer; static nsITimer *sShrinkGCBuffersTimer; -static nsITimer *sShrinkingGCTimer; static nsITimer *sCCTimer; static nsITimer *sICCTimer; static nsITimer *sFullGCTimer; @@ -217,7 +212,6 @@ static nsIScriptSecurityManager *sSecurityManager; // the appropriate pref is set. static bool sGCOnMemoryPressure; -static bool sCompactOnUserInactive; // In testing, we call RunNextCollectorTimer() to ensure that the collectors are run more // aggressively than they would be in regular browsing. sExpensiveCollectorPokes keeps @@ -240,7 +234,6 @@ static void KillTimers() { nsJSContext::KillGCTimer(); - nsJSContext::KillShrinkingGCTimer(); nsJSContext::KillShrinkGCBuffersTimer(); nsJSContext::KillCCTimer(); nsJSContext::KillICCTimer(); @@ -273,30 +266,22 @@ NS_IMETHODIMP nsJSEnvironmentObserver::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) { - if (!nsCRT::strcmp(aTopic, "memory-pressure")) { - if (sGCOnMemoryPressure) { - if(StringBeginsWith(nsDependentString(aData), - NS_LITERAL_STRING("low-memory-ongoing"))) { - // Don't GC/CC if we are in an ongoing low-memory state since its very - // slow and it likely won't help us anyway. - return NS_OK; - } + if (sGCOnMemoryPressure && !nsCRT::strcmp(aTopic, "memory-pressure")) { + if(StringBeginsWith(nsDependentString(aData), + NS_LITERAL_STRING("low-memory-ongoing"))) { + // Don't GC/CC if we are in an ongoing low-memory state since its very + // slow and it likely won't help us anyway. + return NS_OK; + } + nsJSContext::GarbageCollectNow(JS::gcreason::MEM_PRESSURE, + nsJSContext::NonIncrementalGC, + nsJSContext::ShrinkingGC); + nsJSContext::CycleCollectNow(); + if (NeedsGCAfterCC()) { nsJSContext::GarbageCollectNow(JS::gcreason::MEM_PRESSURE, nsJSContext::NonIncrementalGC, nsJSContext::ShrinkingGC); - nsJSContext::CycleCollectNow(); - if (NeedsGCAfterCC()) { - nsJSContext::GarbageCollectNow(JS::gcreason::MEM_PRESSURE, - nsJSContext::NonIncrementalGC, - nsJSContext::ShrinkingGC); - } } - } else if (!nsCRT::strcmp(aTopic, "user-interaction-inactive")) { - if (sCompactOnUserInactive) { - nsJSContext::PokeShrinkingGC(); - } - } else if (!nsCRT::strcmp(aTopic, "user-interaction-active")) { - nsJSContext::KillShrinkingGCTimer(); } else if (!nsCRT::strcmp(aTopic, "quit-application") || !nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { sShuttingDown = true; @@ -1299,11 +1284,12 @@ nsJSContext::GarbageCollectNow(JS::gcreason::Reason aReason, return; } - JSGCInvocationKind gckind = aShrinking == ShrinkingGC ? GC_SHRINK : GC_NORMAL; JS::PrepareForFullGC(sRuntime); if (aIncremental == IncrementalGC) { - JS::StartIncrementalGC(sRuntime, gckind, aReason, aSliceMillis); + MOZ_ASSERT(aShrinking == NonShrinkingGC); + JS::StartIncrementalGC(sRuntime, GC_NORMAL, aReason, aSliceMillis); } else { + JSGCInvocationKind gckind = aShrinking == ShrinkingGC ? GC_SHRINK : GC_NORMAL; JS::GCForReason(sRuntime, gckind, aReason); } } @@ -1812,16 +1798,6 @@ ShrinkGCBuffersTimerFired(nsITimer *aTimer, void *aClosure) nsJSContext::ShrinkGCBuffersNow(); } -// static -void -ShrinkingGCTimerFired(nsITimer* aTimer, void* aClosure) -{ - nsJSContext::KillShrinkingGCTimer(); - nsJSContext::GarbageCollectNow(JS::gcreason::USER_INACTIVE, - nsJSContext::IncrementalGC, - nsJSContext::ShrinkingGC); -} - static bool ShouldTriggerCC(uint32_t aSuspected) { @@ -2054,26 +2030,6 @@ nsJSContext::PokeShrinkGCBuffers() nsITimer::TYPE_ONE_SHOT); } -// static -void -nsJSContext::PokeShrinkingGC() -{ - if (sShrinkingGCTimer || sShuttingDown) { - return; - } - - CallCreateInstance("@mozilla.org/timer;1", &sShrinkingGCTimer); - - if (!sShrinkingGCTimer) { - // Failed to create timer (probably because we're in XPCOM shutdown) - return; - } - - sShrinkingGCTimer->InitWithFuncCallback(ShrinkingGCTimerFired, nullptr, - NS_SHRINKING_GC_DELAY, - nsITimer::TYPE_ONE_SHOT); -} - // static void nsJSContext::MaybePokeCC() @@ -2135,16 +2091,6 @@ nsJSContext::KillShrinkGCBuffersTimer() } } -//static -void -nsJSContext::KillShrinkingGCTimer() -{ - if (sShrinkingGCTimer) { - sShrinkingGCTimer->Cancel(); - NS_RELEASE(sShrinkingGCTimer); - } -} - //static void nsJSContext::KillCCTimer() @@ -2336,7 +2282,7 @@ void mozilla::dom::StartupJSEnvironment() { // initialize all our statics, so that we can restart XPCOM - sGCTimer = sShrinkingGCTimer = sFullGCTimer = sCCTimer = sICCTimer = nullptr; + sGCTimer = sFullGCTimer = sCCTimer = sICCTimer = nullptr; sCCLockedOut = false; sCCLockedOutTime = 0; sLastCCEndTime = TimeStamp(); @@ -2741,14 +2687,8 @@ nsJSContext::EnsureStatics() "javascript.options.gc_on_memory_pressure", true); - Preferences::AddBoolVarCache(&sCompactOnUserInactive, - "javascript.options.compact_on_user_inactive", - true); - nsIObserver* observer = new nsJSEnvironmentObserver(); obs->AddObserver(observer, "memory-pressure", false); - obs->AddObserver(observer, "user-interaction-inactive", false); - obs->AddObserver(observer, "user-interaction-active", false); obs->AddObserver(observer, "quit-application", false); obs->AddObserver(observer, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); diff --git a/dom/base/nsJSEnvironment.h b/dom/base/nsJSEnvironment.h index 3ebf50f5727..17bf0335a6c 100644 --- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -116,9 +116,6 @@ public: static void PokeShrinkGCBuffers(); static void KillShrinkGCBuffersTimer(); - static void PokeShrinkingGC(); - static void KillShrinkingGCTimer(); - static void MaybePokeCC(); static void KillCCTimer(); static void KillICCTimer(); diff --git a/js/public/GCAPI.h b/js/public/GCAPI.h index 6d67dc18ad1..1c49d348737 100644 --- a/js/public/GCAPI.h +++ b/js/public/GCAPI.h @@ -99,8 +99,7 @@ namespace JS { D(REFRESH_FRAME) \ D(FULL_GC_TIMER) \ D(SHUTDOWN_CC) \ - D(FINISH_LARGE_EVALUATE) \ - D(USER_INACTIVE) + D(FINISH_LARGE_EVALUATE) namespace gcreason { diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 9cd0b8f3ed1..d32af161d38 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -356,9 +356,7 @@ js::AssertSameCompartment(JSObject *objA, JSObject *objB) JS_FRIEND_API(void) js::NotifyAnimationActivity(JSObject *obj) { - int64_t timeNow = PRMJ_Now(); - obj->compartment()->lastAnimationTime = timeNow; - obj->runtimeFromMainThread()->lastAnimationTime = timeNow; + obj->compartment()->lastAnimationTime = PRMJ_Now(); } JS_FRIEND_API(uint32_t) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 0fcd96193f2..ecb51ebbb37 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -1887,10 +1887,7 @@ ArenaLists::allocateFromArenaInner(JS::Zone *zone, ArenaHeader *aheader, AllocKi bool GCRuntime::shouldCompact() { - // Compact on shrinking GC if enabled, but skip compacting in incremental - // GCs if we are currently animating. - return invocationKind == GC_SHRINK && isCompactingGCEnabled() && - (!isIncremental || rt->lastAnimationTime + PRMJ_USEC_PER_SEC < PRMJ_Now()); + return invocationKind == GC_SHRINK && isCompactingGCEnabled(); } void diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 932e5927070..a8e92133e65 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -210,8 +210,7 @@ JSRuntime::JSRuntime(JSRuntime *parentRuntime) #endif largeAllocationFailureCallback(nullptr), oomCallback(nullptr), - debuggerMallocSizeOf(ReturnZeroSize), - lastAnimationTime(0) + debuggerMallocSizeOf(ReturnZeroSize) { setGCStoreBufferPtr(&gc.storeBuffer); diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index a0f545c38c1..494ef255f34 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -1375,9 +1375,6 @@ struct JSRuntime : public JS::shadow::Runtime, * function to assess the size of malloc'd blocks of memory. */ mozilla::MallocSizeOf debuggerMallocSizeOf; - - /* Last time at which an animation was played for this runtime. */ - int64_t lastAnimationTime; }; namespace js { diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index e56d9c1a074..0f47f36b1ce 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1081,7 +1081,6 @@ pref("javascript.options.mem.gc_compacting", true); pref("javascript.options.mem.log", false); pref("javascript.options.mem.notify", false); pref("javascript.options.gc_on_memory_pressure", true); -pref("javascript.options.compact_on_user_inactive", true); pref("javascript.options.mem.gc_high_frequency_time_limit_ms", 1000); pref("javascript.options.mem.gc_high_frequency_low_limit_mb", 100);