Bug 904674 - GC: Don't trace additional roots from the embedding on minor GC r=billm
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 14 Aug 2013 11:08:26 +0100
changeset 142519 5d04a4f5ff6fd90267120347ff922434f54c6f96
parent 142518 e84ced5321bed6ee6047f17f12c24edc7b8a0baf
child 142520 9d3fa47e4dcbb8574df60bcc428e5402e5f56228
push id32438
push userjcoppeard@mozilla.com
push dateWed, 14 Aug 2013 10:40:14 +0000
treeherdermozilla-inbound@5d04a4f5ff6f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs904674
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 904674 - GC: Don't trace additional roots from the embedding on minor GC r=billm
js/src/gc/RootMarking.cpp
--- a/js/src/gc/RootMarking.cpp
+++ b/js/src/gc/RootMarking.cpp
@@ -746,34 +746,40 @@ js::gc::MarkRuntime(JSTracer *trc, bool 
     MarkInterpreterActivations(rt, trc);
 
 #ifdef JS_ION
     ion::MarkJitActivations(rt, trc);
 #endif
 
     if (!rt->isHeapMinorCollecting()) {
         /*
-         * All JSCompartment::mark does is mark the globals for compartements
+         * All JSCompartment::mark does is mark the globals for compartments
          * which have been entered. Globals aren't nursery allocated so there's
          * no need to do this for minor GCs.
          */
         for (CompartmentsIter c(rt); !c.done(); c.next())
             c->mark(trc);
-    }
 
-    /* The embedding can register additional roots here. */
-    for (size_t i = 0; i < rt->gcBlackRootTracers.length(); i++) {
-        const JSRuntime::ExtraTracer &e = rt->gcBlackRootTracers[i];
-        (*e.op)(trc, e.data);
-    }
+        /*
+         * The embedding can register additional roots here.
+         *
+         * We don't need to trace these in a minor GC because all pointers into
+         * the nursery should be in the store buffer, and we want to avoid the
+         * time taken to trace all these roots.
+         */
+        for (size_t i = 0; i < rt->gcBlackRootTracers.length(); i++) {
+            const JSRuntime::ExtraTracer &e = rt->gcBlackRootTracers[i];
+            (*e.op)(trc, e.data);
+        }
 
-    /* During GC, we don't mark gray roots at this stage. */
-    if (JSTraceDataOp op = rt->gcGrayRootTracer.op) {
-        if (!IS_GC_MARKING_TRACER(trc) && !trc->runtime->isHeapMinorCollecting())
-            (*op)(trc, rt->gcGrayRootTracer.data);
+        /* During GC, we don't mark gray roots at this stage. */
+        if (JSTraceDataOp op = rt->gcGrayRootTracer.op) {
+            if (!IS_GC_MARKING_TRACER(trc))
+                (*op)(trc, rt->gcGrayRootTracer.data);
+        }
     }
 }
 
 void
 js::gc::BufferGrayRoots(GCMarker *gcmarker)
 {
     JSRuntime *rt = gcmarker->runtime;
     if (JSTraceDataOp op = rt->gcGrayRootTracer.op) {