diff --git a/js/src/gc/GCInternals.h b/js/src/gc/GCInternals.h index 9b34a3207b14..723636f41925 100644 --- a/js/src/gc/GCInternals.h +++ b/js/src/gc/GCInternals.h @@ -8,6 +8,7 @@ #define gc_GCInternals_h #include "mozilla/ArrayUtils.h" +#include "mozilla/Maybe.h" #include "mozilla/PodOperations.h" #include "jscntxt.h" @@ -19,10 +20,7 @@ namespace js { namespace gc { -struct MOZ_RAII AutoFinishGC -{ - explicit AutoFinishGC(JSRuntime* rt); -}; +void FinishGC(JSRuntime* rt); /* * This class should be used by any code that needs to exclusive access to the @@ -48,8 +46,7 @@ class MOZ_RAII AutoTraceSession struct MOZ_RAII AutoPrepareForTracing { - AutoFinishGC finish; - AutoTraceSession session; + mozilla::Maybe session; AutoPrepareForTracing(JSRuntime* rt, ZoneSelector selector); }; diff --git a/js/src/jsapi-tests/testGCAllocator.cpp b/js/src/jsapi-tests/testGCAllocator.cpp index f9c8058ec20a..025ff307d5df 100644 --- a/js/src/jsapi-tests/testGCAllocator.cpp +++ b/js/src/jsapi-tests/testGCAllocator.cpp @@ -48,7 +48,7 @@ BEGIN_TEST(testGCAllocator) #endif /* Finish any ongoing background free activity. */ - js::gc::AutoFinishGC finishGC(rt); + js::gc::FinishGC(rt); bool growUp; CHECK(addressesGrowUp(&growUp)); diff --git a/js/src/jsapi-tests/testGCUniqueId.cpp b/js/src/jsapi-tests/testGCUniqueId.cpp index 40feadf1018f..09f2fac8eb34 100644 --- a/js/src/jsapi-tests/testGCUniqueId.cpp +++ b/js/src/jsapi-tests/testGCUniqueId.cpp @@ -18,7 +18,7 @@ MinimizeHeap(JSRuntime* rt) // sweeping that the first GC started to finish. JS_GC(rt); JS_GC(rt); - js::gc::AutoFinishGC finish(rt); + js::gc::FinishGC(rt); } BEGIN_TEST(testGCUID) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 57103a041ed7..8ed28268689b 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -2007,7 +2007,7 @@ AutoDisableCompactingGC::AutoDisableCompactingGC(JSRuntime* rt) { gc.disableCompactingGC(); if (gc.isIncrementalGCInProgress() && gc.isCompactingGc()) - AutoFinishGC finishGC(rt); + FinishGC(rt); } AutoDisableCompactingGC::~AutoDisableCompactingGC() @@ -6726,21 +6726,20 @@ GCRuntime::gcIfRequested(JSContext* cx /* = nullptr */) return false; } -AutoFinishGC::AutoFinishGC(JSRuntime* rt) +void js::gc::FinishGC(JSRuntime* rt) { if (JS::IsIncrementalGCInProgress(rt)) { JS::PrepareForIncrementalGC(rt); JS::FinishIncrementalGC(rt, JS::gcreason::API); } - rt->gc.waitBackgroundSweepEnd(); rt->gc.nursery.waitBackgroundFreeEnd(); } AutoPrepareForTracing::AutoPrepareForTracing(JSRuntime* rt, ZoneSelector selector) - : finish(rt), - session(rt) { + js::gc::FinishGC(rt); + session.emplace(rt); } JSCompartment* diff --git a/js/src/jsgc.h b/js/src/jsgc.h index 4845665d24cb..c9c5b964f2a8 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -789,12 +789,6 @@ const size_t MAX_EMPTY_CHUNK_AGE = 4; } /* namespace gc */ -extern bool -InitGC(JSRuntime* rt, uint32_t maxbytes); - -extern void -FinishGC(JSRuntime* rt); - class InterpreterFrame; extern void diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 5d3cd1cafbaa..ecb61d45bbb4 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -3812,7 +3812,7 @@ runOffThreadScript(JSContext* cx, unsigned argc, Value* vp) JSRuntime* rt = cx->runtime(); if (OffThreadParsingMustWaitForGC(rt)) - gc::AutoFinishGC finishgc(rt); + gc::FinishGC(rt); void* token = offThreadState.waitUntilDone(cx, ScriptKind::Script); if (!token) { @@ -3914,7 +3914,7 @@ FinishOffThreadModule(JSContext* cx, unsigned argc, Value* vp) JSRuntime* rt = cx->runtime(); if (OffThreadParsingMustWaitForGC(rt)) - gc::AutoFinishGC finishgc(rt); + gc::FinishGC(rt); void* token = offThreadState.waitUntilDone(cx, ScriptKind::Module); if (!token) { diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp index 0a297207d905..de4fbeb04f20 100644 --- a/js/src/vm/HelperThreads.cpp +++ b/js/src/vm/HelperThreads.cpp @@ -1240,7 +1240,7 @@ GlobalHelperThreadState::mergeParseTaskCompartment(JSRuntime* rt, ParseTask* par // finished merging the contents of the parse task's compartment into the // destination compartment. Finish any ongoing incremental GC first and // assert that no allocation can occur. - gc::AutoFinishGC finishGC(rt); + gc::FinishGC(rt); JS::AutoAssertNoAlloc noAlloc(rt); LeaveParseTaskZone(rt, parseTask);