Bug 1084651 - Part 5: Simplify Cycle Collector logic now that SliceBudget makes more sense. r=mccr8

This commit is contained in:
Emanuel Hoogeveen 2014-11-06 10:14:00 +01:00
Родитель 29ff200005
Коммит fbc3e91445
3 изменённых файлов: 13 добавлений и 37 удалений

Просмотреть файл

@ -45,6 +45,7 @@
#include "jsapi.h"
#include "jswrapper.h"
#include "js/SliceBudget.h"
#include "nsIArray.h"
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
@ -1692,24 +1693,24 @@ nsJSContext::RunCycleCollectorSlice()
// Decide how long we want to budget for this slice. By default,
// use an unlimited budget.
int64_t sliceBudget = -1;
js::SliceBudget budget;
if (sIncrementalCC) {
if (gCCStats.mBeginTime.IsNull()) {
// If no CC is in progress, use the standard slice time.
sliceBudget = kICCSliceBudget;
budget = js::SliceBudget(js::TimeBudget(kICCSliceBudget));
} else {
TimeStamp now = TimeStamp::Now();
// Only run a limited slice if we're within the max running time.
if (TimeBetween(gCCStats.mBeginTime, now) < kMaxICCDuration) {
float sliceMultiplier = std::max(TimeBetween(gCCStats.mEndSliceTime, now) / (float)kICCIntersliceDelay, 1.0f);
sliceBudget = kICCSliceBudget * sliceMultiplier;
budget = js::SliceBudget(js::TimeBudget(kICCSliceBudget * sliceMultiplier));
}
}
}
nsCycleCollector_collectSlice(sliceBudget);
nsCycleCollector_collectSlice(budget);
gCCStats.FinishCycleCollectionSlice();
}
@ -1726,7 +1727,10 @@ nsJSContext::RunCycleCollectorWorkSlice(int64_t aWorkBudget)
js::ProfileEntry::Category::CC);
gCCStats.PrepareForCycleCollectionSlice();
nsCycleCollector_collectSliceWork(aWorkBudget);
js::SliceBudget budget = js::SliceBudget(js::WorkBudget(aWorkBudget));
nsCycleCollector_collectSlice(budget);
gCCStats.FinishCycleCollectionSlice();
}

Просмотреть файл

@ -177,7 +177,6 @@
#include "nsDumpUtils.h"
#include "xpcpublic.h"
#include "GeckoProfiler.h"
#include "js/SliceBudget.h"
#include <stdint.h>
#include <stdio.h>
@ -4210,7 +4209,7 @@ nsCycleCollector_collect(nsICycleCollectorListener* aManualListener)
}
void
nsCycleCollector_collectSlice(int64_t aSliceTime)
nsCycleCollector_collectSlice(SliceBudget& budget)
{
CollectorData* data = sCollectorData.get();
@ -4221,29 +4220,6 @@ nsCycleCollector_collectSlice(int64_t aSliceTime)
PROFILER_LABEL("nsCycleCollector", "collectSlice",
js::ProfileEntry::Category::CC);
SliceBudget budget;
if (aSliceTime >= 0) {
budget = SliceBudget(js::TimeBudget(aSliceTime));
}
data->mCollector->Collect(SliceCC, budget, nullptr);
}
void
nsCycleCollector_collectSliceWork(int64_t aSliceWork)
{
CollectorData* data = sCollectorData.get();
// We should have started the cycle collector by now.
MOZ_ASSERT(data);
MOZ_ASSERT(data->mCollector);
PROFILER_LABEL("nsCycleCollector", "collectSliceWork",
js::ProfileEntry::Category::CC);
SliceBudget budget;
if (aSliceWork >= 0) {
budget = SliceBudget(js::WorkBudget(aSliceWork));
}
data->mCollector->Collect(SliceCC, budget, nullptr);
}

Просмотреть файл

@ -15,6 +15,8 @@ template<class T> struct already_AddRefed;
#include "nsError.h"
#include "nsID.h"
#include "js/SliceBudget.h"
namespace mozilla {
class CycleCollectedJSRuntime;
@ -56,13 +58,7 @@ already_AddRefed<nsICycleCollectorLogSink> nsCycleCollector_createLogSink();
void nsCycleCollector_collect(nsICycleCollectorListener* aManualListener);
// If aSliceTime is negative, the CC will run to completion. Otherwise,
// aSliceTime will be used as the time budget for the slice, in ms.
void nsCycleCollector_collectSlice(int64_t aSliceTime);
// If aSliceTime is negative, the CC will run to completion. Otherwise,
// aSliceTime will be used as the work budget for the slice.
void nsCycleCollector_collectSliceWork(int64_t aSliceWork);
void nsCycleCollector_collectSlice(js::SliceBudget& budget);
uint32_t nsCycleCollector_suspectedCount();
void nsCycleCollector_shutdown();