From d124a657306f64e590d4545d43332b01b8de34c2 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Thu, 26 Apr 2018 09:58:42 +0200 Subject: [PATCH] Bug 1452114 part 1 - Fix GCRuntime::tryNewTenuredThing to report OOM on helper threads as well. r=jonco --HG-- extra : rebase_source : cb34d5741d697c3fb5cb6dbbdd4f28cb50e3d231 --- js/src/gc/Allocator.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/js/src/gc/Allocator.cpp b/js/src/gc/Allocator.cpp index e1c74ec29cc2..5677018169c5 100644 --- a/js/src/gc/Allocator.cpp +++ b/js/src/gc/Allocator.cpp @@ -244,15 +244,17 @@ GCRuntime::tryNewTenuredThing(JSContext* cx, AllocKind kind, size_t thingSize) // chunks available it may also allocate new memory directly. t = reinterpret_cast(refillFreeListFromAnyThread(cx, kind)); - if (MOZ_UNLIKELY(!t && allowGC && !cx->helperThread())) { - // We have no memory available for a new chunk; perform an - // all-compartments, non-incremental, shrinking GC and wait for - // sweeping to finish. - JS::PrepareForFullGC(cx); - cx->runtime()->gc.gc(GC_SHRINK, JS::gcreason::LAST_DITCH); - cx->runtime()->gc.waitBackgroundSweepOrAllocEnd(); + if (MOZ_UNLIKELY(!t && allowGC)) { + if (!cx->helperThread()) { + // We have no memory available for a new chunk; perform an + // all-compartments, non-incremental, shrinking GC and wait for + // sweeping to finish. + JS::PrepareForFullGC(cx); + cx->runtime()->gc.gc(GC_SHRINK, JS::gcreason::LAST_DITCH); + cx->runtime()->gc.waitBackgroundSweepOrAllocEnd(); - t = tryNewTenuredThing(cx, kind, thingSize); + t = tryNewTenuredThing(cx, kind, thingSize); + } if (!t) ReportOutOfMemory(cx); }