зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1360526 - Sweep runtime-wide weak caches as part of the weak cache sweeping task r=sfink
--HG-- extra : rebase_source : 47a957dba1707f06b17942c128823b9bc30eff21
This commit is contained in:
Родитель
fc496d2511
Коммит
c68fce716d
|
@ -5093,30 +5093,42 @@ GCRuntime::joinTask(GCParallelTask& task, gcstats::Phase phase, AutoLockHelperTh
|
|||
|
||||
using WeakCacheTaskVector = mozilla::Vector<SweepWeakCacheTask, 0, SystemAllocPolicy>;
|
||||
|
||||
static void
|
||||
SweepWeakCachesFromActiveCooperatingThread(JSRuntime* rt)
|
||||
template <typename Functor>
|
||||
static bool
|
||||
IterateWeakCaches(JSRuntime* rt, Functor f)
|
||||
{
|
||||
for (GCSweepGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
for (JS::WeakCache<void*>* cache : zone->weakCaches()) {
|
||||
SweepWeakCacheTask task(rt, *cache);
|
||||
task.runFromActiveCooperatingThread(rt);
|
||||
if (!f(cache))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (JS::WeakCache<void*>* cache : rt->weakCaches()) {
|
||||
if (!f(cache))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static WeakCacheTaskVector
|
||||
PrepareWeakCacheTasks(JSRuntime* rt)
|
||||
{
|
||||
// Build a vector of sweep tasks to run on a helper thread.
|
||||
WeakCacheTaskVector out;
|
||||
for (GCSweepGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||
for (JS::WeakCache<void*>* cache : zone->weakCaches()) {
|
||||
if (!out.append(SweepWeakCacheTask(rt, *cache))) {
|
||||
SweepWeakCachesFromActiveCooperatingThread(rt);
|
||||
return WeakCacheTaskVector();
|
||||
}
|
||||
}
|
||||
if (IterateWeakCaches(rt, [&] (JS::WeakCache<void*>* cache) {
|
||||
return out.emplaceBack(rt, *cache);
|
||||
})) {
|
||||
return out;
|
||||
}
|
||||
return out;
|
||||
|
||||
// If we ran out of memory, do all the work now and return an empty list.
|
||||
IterateWeakCaches(rt, [&] (JS::WeakCache<void*>* cache) {
|
||||
SweepWeakCacheTask(rt, *cache).runFromActiveCooperatingThread(rt);
|
||||
return true;
|
||||
});
|
||||
return WeakCacheTaskVector();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -5220,10 +5232,6 @@ GCRuntime::beginSweepingSweepGroup(AutoLockForExclusiveAccess& lock)
|
|||
// Sweep entries containing about-to-be-finalized JitCode and
|
||||
// update relocated TypeSet::Types inside the JitcodeGlobalTable.
|
||||
jit::JitRuntime::SweepJitcodeGlobalTable(rt);
|
||||
|
||||
// Sweep runtime-wide weak caches.
|
||||
for (JS::WeakCache<void*>* cache : rt->weakCaches())
|
||||
cache->sweep();
|
||||
}
|
||||
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче