diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 0c131d1336c..2c56df11aa1 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -144,6 +144,17 @@ js::PrepareForFullGC(JSRuntime *rt) c->scheduleGC(); } +JS_FRIEND_API(bool) +js::IsGCScheduled(JSRuntime *rt) +{ + for (CompartmentsIter c(rt); !c.done(); c.next()) { + if (c->isGCScheduled()) + return true; + } + + return false; +} + JS_FRIEND_API(void) js::GCForReason(JSRuntime *rt, gcreason::Reason reason) { diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index c3e119b0e6e..88687ac665f 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -651,6 +651,9 @@ PrepareCompartmentForGC(JSCompartment *comp); extern JS_FRIEND_API(void) PrepareForFullGC(JSRuntime *rt); +extern JS_FRIEND_API(bool) +IsGCScheduled(JSRuntime *rt); + /* * When triggering a GC using one of the functions below, it is first necessary * to select the compartments to be collected. To do this, you can call