Bug 899367 - Add an API to determine if we're marking gray. r=billm
authorBobby Holley <bobbyholley@gmail.com>
Wed, 04 Sep 2013 14:06:54 -0700
changeset 158483 001f423a94e8fedf82591e2f7cb9e225cf679cd6
parent 158482 6490e2abb8b3a3aec14cdf39f657b60b7052cb32
child 158484 c800b53263d221923333191d3e1933af1bac6112
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs899367
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 899367 - Add an API to determine if we're marking gray. r=billm This allows us to assert that certain callbacks get invoked during the gray phase of a marking GC.
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -2374,16 +2374,25 @@ JS_DumpHeap(JSRuntime *rt, FILE *fp, voi
 #endif /* DEBUG */
 
 extern JS_PUBLIC_API(bool)
 JS_IsGCMarkingTracer(JSTracer *trc)
 {
     return IS_GC_MARKING_TRACER(trc);
 }
 
+#ifdef DEBUG
+extern JS_PUBLIC_API(bool)
+JS_IsMarkingGray(JSTracer *trc)
+{
+    JS_ASSERT(JS_IsGCMarkingTracer(trc));
+    return trc->callback == GCMarker::GrayCallback;
+}
+#endif
+
 JS_PUBLIC_API(void)
 JS_GC(JSRuntime *rt)
 {
     AssertHeapIsIdle(rt);
     JS::PrepareForFullGC(rt);
     GC(rt, GC_NORMAL, JS::gcreason::API);
 }
 
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2205,16 +2205,22 @@ extern JS_PUBLIC_API(void)
 JS_SetGCCallback(JSRuntime *rt, JSGCCallback cb, void *data);
 
 extern JS_PUBLIC_API(void)
 JS_SetFinalizeCallback(JSRuntime *rt, JSFinalizeCallback cb);
 
 extern JS_PUBLIC_API(bool)
 JS_IsGCMarkingTracer(JSTracer *trc);
 
+/* For assertions only. */
+#ifdef DEBUG
+extern JS_PUBLIC_API(bool)
+JS_IsMarkingGray(JSTracer *trc);
+#endif
+
 /*
  * JS_IsAboutToBeFinalized checks if the given object is going to be finalized
  * at the end of the current GC. When called outside of the context of a GC,
  * this function will return false. Typically this function is used on weak
  * references, where the reference should be nulled out or destroyed if the
  * given object is about to be finalized.
  *
  * The argument to JS_IsAboutToBeFinalized is an in-out param: when the