From 56bc55bdfb3f3a8e0083ce9a3f25df43bc12548b Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Tue, 17 Dec 2013 19:29:57 -0800 Subject: [PATCH] Bug 937818, part 2 - Add js::ZoneGlobalsAreAllGray. r=jonco If all globals in a zone are gray, then all live objects in that zone should also be gray. --- js/src/jsfriendapi.cpp | 11 +++++++++++ js/src/jsfriendapi.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index e62b9dec3781..ff0a433c8033 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -647,6 +647,17 @@ js::AreGCGrayBitsValid(JSRuntime *rt) return rt->gcGrayBitsValid; } +JS_FRIEND_API(bool) +js::ZoneGlobalsAreAllGray(JS::Zone *zone) +{ + for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) { + JSObject *obj = comp->maybeGlobal(); + if (!obj || !JS::GCThingIsMarkedGray(obj)) + return false; + } + return true; +} + JS_FRIEND_API(JSGCTraceKind) js::GCThingTraceKind(void *thing) { diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index 6e41232400cb..4c5d113d2d34 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -339,6 +339,9 @@ TraceWeakMaps(WeakMapTracer *trc); extern JS_FRIEND_API(bool) AreGCGrayBitsValid(JSRuntime *rt); +extern JS_FRIEND_API(bool) +ZoneGlobalsAreAllGray(JS::Zone *zone); + typedef void (*GCThingCallback)(void *closure, void *gcthing);