Bug 1105089, try to have shorter ICC slices during animations, r=mccr8

--HG--
extra : rebase_source : bfe8cc2825b7cb2ec86f6e8f5ba590593e1c378b
This commit is contained in:
Olli Pettay 2014-11-27 13:47:51 +02:00
parent 7c9eb1363a
commit 702d381ada
5 changed files with 25 additions and 9 deletions

View File

@ -187,6 +187,7 @@ static uint32_t sCleanupsSinceLastGC = UINT32_MAX;
static bool sNeedsFullCC = false;
static bool sNeedsGCAfterCC = false;
static bool sIncrementalCC = false;
static bool sDidPaintAfterPreviousICCSlice = false;
static nsScriptNameSpaceManager *gNameSpaceManager;
@ -1708,7 +1709,8 @@ nsJSContext::RunCycleCollectorSlice()
}
}
nsCycleCollector_collectSlice(budget);
nsCycleCollector_collectSlice(budget, sDidPaintAfterPreviousICCSlice);
sDidPaintAfterPreviousICCSlice = false;
gCCStats.FinishCycleCollectionSlice();
}
@ -2856,6 +2858,12 @@ nsJSContext::EnsureStatics()
sIsInitialized = true;
}
void
nsJSContext::NotifyDidPaint()
{
sDidPaintAfterPreviousICCSlice = true;
}
nsScriptNameSpaceManager*
mozilla::dom::GetNameSpaceManager()
{

View File

@ -136,6 +136,8 @@ public:
JSObject* global = GetWindowProxy();
return global ? mGlobalObjectRef.get() : nullptr;
}
static void NotifyDidPaint();
protected:
virtual ~nsJSContext();

View File

@ -50,7 +50,7 @@
#include "mozilla/dom/ScriptSettings.h"
#include "nsDocShell.h"
#include "nsISimpleEnumerator.h"
#include "nsJSEnvironment.h"
#include "mozilla/Telemetry.h"
using namespace mozilla;
@ -1369,6 +1369,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
if (nsContentUtils::XPConnect()) {
nsContentUtils::XPConnect()->NotifyDidPaint();
nsJSContext::NotifyDidPaint();
}
}

View File

@ -1312,7 +1312,8 @@ public:
bool Collect(ccType aCCType,
SliceBudget& aBudget,
nsICycleCollectorListener* aManualListener);
nsICycleCollectorListener* aManualListener,
bool aPreferShorterSlices = false);
void Shutdown();
void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
@ -3600,7 +3601,8 @@ PrintPhase(const char* aPhase)
bool
nsCycleCollector::Collect(ccType aCCType,
SliceBudget& aBudget,
nsICycleCollectorListener* aManualListener)
nsICycleCollectorListener* aManualListener,
bool aPreferShorterSlices)
{
CheckThreadSafety();
@ -3623,7 +3625,7 @@ nsCycleCollector::Collect(ccType aCCType,
++mResults.mNumSlices;
bool continueSlice = true;
bool continueSlice = aBudget.isUnlimited() || !aPreferShorterSlices;
do {
switch (mIncrementalPhase) {
case IdlePhase:
@ -3640,7 +3642,8 @@ nsCycleCollector::Collect(ccType aCCType,
// (There's no need to check if we've finished graph building, because
// if we haven't, we've already exceeded our budget, and will finish
// this slice anyways.)
continueSlice = aBudget.isUnlimited() || mResults.mNumSlices < 3;
continueSlice = aBudget.isUnlimited() ||
(mResults.mNumSlices < 3 && !aPreferShorterSlices);
break;
case ScanAndCollectWhitePhase:
// We do ScanRoots and CollectWhite in a single slice to ensure
@ -4225,7 +4228,8 @@ nsCycleCollector_collect(nsICycleCollectorListener* aManualListener)
}
void
nsCycleCollector_collectSlice(SliceBudget& budget)
nsCycleCollector_collectSlice(SliceBudget& budget,
bool aPreferShorterSlices)
{
CollectorData* data = sCollectorData.get();
@ -4236,7 +4240,7 @@ nsCycleCollector_collectSlice(SliceBudget& budget)
PROFILER_LABEL("nsCycleCollector", "collectSlice",
js::ProfileEntry::Category::CC);
data->mCollector->Collect(SliceCC, budget, nullptr);
data->mCollector->Collect(SliceCC, budget, nullptr, aPreferShorterSlices);
}
void

View File

@ -58,7 +58,8 @@ already_AddRefed<nsICycleCollectorLogSink> nsCycleCollector_createLogSink();
void nsCycleCollector_collect(nsICycleCollectorListener* aManualListener);
void nsCycleCollector_collectSlice(js::SliceBudget& budget);
void nsCycleCollector_collectSlice(js::SliceBudget& budget,
bool aPreferShorterSlices = false);
uint32_t nsCycleCollector_suspectedCount();
void nsCycleCollector_shutdown();