Bug 728962 - Always use a safe JSContext during GC (r=igor)
authorBill McCloskey <wmccloskey@mozilla.com>
Sun, 26 Feb 2012 10:03:44 -0800
changeset 87762 f09084db292c942dcb0b017b8e6ca88be9e546c3
parent 87761 f9e8468f70f09d4f2985ffc5ddcc2d8d8c2f03d8
child 87763 5ee59d0f5848f8b22f85057d79cb511b5ff6592f
push id22143
push userphilringnalda@gmail.com
push dateSun, 26 Feb 2012 23:12:35 +0000
treeherdermozilla-central@b98fc24ac54b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersigor
bugs728962
milestone13.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 728962 - Always use a safe JSContext during GC (r=igor)
js/src/jsgc.cpp
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -2150,16 +2150,17 @@ gc_root_traversal(JSTracer *trc, const R
 
     if (ptr && !trc->runtime->gcCurrentCompartment) {
         /*
          * Use conservative machinery to find if ptr is a valid GC thing.
          * We only do this during global GCs, to preserve the invariant
          * that mark callbacks are not in place during compartment GCs.
          */
         JSTracer checker;
+        JS_ASSERT(trc->runtime == trc->context->runtime);
         JS_TracerInit(&checker, trc->context, EmptyMarkCallback);
         ConservativeGCTest test = MarkIfGCThingWord(&checker, reinterpret_cast<uintptr_t>(ptr));
         if (test != CGCT_VALID && entry.value.name) {
             fprintf(stderr,
 "JS API usage error: the address passed to JS_AddNamedRoot currently holds an\n"
 "invalid gcthing.  This is usually caused by a missing call to JS_RemoveRoot.\n"
 "The root's name is \"%s\".\n",
                     entry.value.name);
@@ -3492,16 +3493,17 @@ IncrementalGCSlice(JSContext *cx, int64_
     if (rt->gcIncrementalState == MARK) {
         gcstats::AutoPhase ap(rt->gcStats, gcstats::PHASE_MARK);
         SliceBudget sliceBudget(budget);
 
         /* If we needed delayed marking for gray roots, then collect until done. */
         if (!rt->gcMarker.hasBufferedGrayRoots())
             sliceBudget.reset();
 
+        rt->gcMarker.context = cx;
         bool finished = rt->gcMarker.drainMarkStack(sliceBudget);
 
         for (GCCompartmentsIter c(rt); !c.done(); c.next()) {
             c->barrierMarker_.context = cx;
             finished &= c->barrierMarker_.drainMarkStack(sliceBudget);
             c->barrierMarker_.context = NULL;
         }