Bug 1452114 part 1 - Fix GCRuntime::tryNewTenuredThing to report OOM on helper threads as well. r=jonco

--HG--
extra : rebase_source : cb34d5741d697c3fb5cb6dbbdd4f28cb50e3d231
This commit is contained in:
Jan de Mooij 2018-04-26 09:58:42 +02:00
Родитель 4da56c6d15
Коммит d124a65730
1 изменённых файлов: 10 добавлений и 8 удалений

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

@ -244,15 +244,17 @@ GCRuntime::tryNewTenuredThing(JSContext* cx, AllocKind kind, size_t thingSize)
// chunks available it may also allocate new memory directly. // chunks available it may also allocate new memory directly.
t = reinterpret_cast<T*>(refillFreeListFromAnyThread(cx, kind)); t = reinterpret_cast<T*>(refillFreeListFromAnyThread(cx, kind));
if (MOZ_UNLIKELY(!t && allowGC && !cx->helperThread())) { if (MOZ_UNLIKELY(!t && allowGC)) {
// We have no memory available for a new chunk; perform an if (!cx->helperThread()) {
// all-compartments, non-incremental, shrinking GC and wait for // We have no memory available for a new chunk; perform an
// sweeping to finish. // all-compartments, non-incremental, shrinking GC and wait for
JS::PrepareForFullGC(cx); // sweeping to finish.
cx->runtime()->gc.gc(GC_SHRINK, JS::gcreason::LAST_DITCH); JS::PrepareForFullGC(cx);
cx->runtime()->gc.waitBackgroundSweepOrAllocEnd(); cx->runtime()->gc.gc(GC_SHRINK, JS::gcreason::LAST_DITCH);
cx->runtime()->gc.waitBackgroundSweepOrAllocEnd();
t = tryNewTenuredThing<T, NoGC>(cx, kind, thingSize); t = tryNewTenuredThing<T, NoGC>(cx, kind, thingSize);
}
if (!t) if (!t)
ReportOutOfMemory(cx); ReportOutOfMemory(cx);
} }