Bug 779073 - Don't treat GC verifier as an incremental GC (r=terrence)
authorBill McCloskey <wmccloskey@mozilla.com>
Tue, 25 Sep 2012 17:04:17 -0700
changeset 108198 7dfbdeb9f9ca4c2d6e327c3bd0e2b07bfa03d6c6
parent 108197 ac6eab3c5aa70e6524608f1a10038f5a56e51bc7
child 108199 c0f65614b0e048fc92de4d2d12df20b9825fca73
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersterrence
bugs779073
milestone18.0a1
Bug 779073 - Don't treat GC verifier as an incremental GC (r=terrence)
js/src/jsapi.cpp
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/src/jsscript.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1544,17 +1544,17 @@ JS_TransplantObject(JSContext *cx, JSObj
     JS_ASSERT(!IsCrossCompartmentWrapper(target));
 
     /*
      * Transplantation typically allocates new wrappers in every compartment. If
      * an incremental GC is active, this causes every compartment to be leaked
      * for that GC. Hence, we finish any ongoing incremental GC before the
      * transplant to avoid leaks.
      */
-    if (cx->runtime->gcIncrementalState != NO_INCREMENTAL) {
+    if (IsIncrementalGCInProgress(cx->runtime)) {
         PrepareForIncrementalGC(cx->runtime);
         FinishIncrementalGC(cx->runtime, gcreason::TRANSPLANT);
     }
 
     JSCompartment *destination = target->compartment();
     WrapperMap &map = destination->crossCompartmentWrappers;
     Value origv = ObjectValue(*origobj);
     JSObject *newIdentity;
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -122,17 +122,17 @@ js::PrepareForFullGC(JSRuntime *rt)
 {
     for (CompartmentsIter c(rt); !c.done(); c.next())
         c->scheduleGC();
 }
 
 JS_FRIEND_API(void)
 js::PrepareForIncrementalGC(JSRuntime *rt)
 {
-    if (rt->gcIncrementalState == gc::NO_INCREMENTAL)
+    if (!IsIncrementalGCInProgress(rt))
         return;
 
     for (CompartmentsIter c(rt); !c.done(); c.next()) {
         if (c->wasGCStarted())
             PrepareCompartmentForGC(c);
     }
 }
 
@@ -790,30 +790,36 @@ NotifyDidPaint(JSRuntime *rt)
     }
 
     if (rt->gcZeal() == gc::ZealFrameGCValue) {
         PrepareForFullGC(rt);
         GCSlice(rt, GC_NORMAL, gcreason::REFRESH_FRAME);
         return;
     }
 
-    if (rt->gcIncrementalState != gc::NO_INCREMENTAL && !rt->gcInterFrameGC) {
+    if (IsIncrementalGCInProgress(rt) && !rt->gcInterFrameGC) {
         PrepareForIncrementalGC(rt);
         GCSlice(rt, GC_NORMAL, gcreason::REFRESH_FRAME);
     }
 
     rt->gcInterFrameGC = false;
 }
 
 extern JS_FRIEND_API(bool)
 IsIncrementalGCEnabled(JSRuntime *rt)
 {
     return rt->gcIncrementalEnabled && rt->gcMode == JSGC_MODE_INCREMENTAL;
 }
 
+JS_FRIEND_API(bool)
+IsIncrementalGCInProgress(JSRuntime *rt)
+{
+    return (rt->gcIncrementalState != gc::NO_INCREMENTAL && !rt->gcVerifyPreData);
+}
+
 extern JS_FRIEND_API(void)
 DisableIncrementalGC(JSRuntime *rt)
 {
     rt->gcIncrementalEnabled = false;
 }
 
 JS_FRIEND_API(bool)
 IsIncrementalBarrierNeeded(JSRuntime *rt)
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -804,16 +804,19 @@ GetDOMCallbacks(JSRuntime *rt);
  * drawing a frame.
  */
 extern JS_FRIEND_API(void)
 NotifyDidPaint(JSRuntime *rt);
 
 extern JS_FRIEND_API(bool)
 IsIncrementalGCEnabled(JSRuntime *rt);
 
+JS_FRIEND_API(bool)
+IsIncrementalGCInProgress(JSRuntime *rt);
+
 extern JS_FRIEND_API(void)
 DisableIncrementalGC(JSRuntime *rt);
 
 extern JS_FRIEND_API(bool)
 IsIncrementalBarrierNeeded(JSRuntime *rt);
 
 extern JS_FRIEND_API(bool)
 IsIncrementalBarrierNeeded(JSContext *cx);
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -1334,17 +1334,17 @@ js::SaveScriptFilename(JSContext *cx, co
     ScriptFilenameEntry *sfe = *p;
 #ifdef JSGC_INCREMENTAL
     /*
      * During the IGC we need to ensure that filename is marked whenever it is
      * accessed even if the name was already in the table. At this point old
      * scripts or exceptions pointing to the filename may no longer be
      * reachable.
      */
-    if (rt->gcIncrementalState != NO_INCREMENTAL && rt->gcIsFull)
+    if (IsIncrementalGCInProgress(rt) && rt->gcIsFull)
         sfe->marked = true;
 #endif
 
     return sfe->filename;
 }
 
 void
 js::SweepScriptFilenames(JSRuntime *rt)