Bug 1369712 - Fix removing the gray roots tracer r=mccr8
☠☠ backed out by 5df249f4aee1 ☠ ☠
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 06 Jun 2017 11:25:58 +0100
changeset 410673 8adc00c59534ca1ad6c30908d1e166c679bcf4fc
parent 410672 711a50eff7d819795570f82d2e9a696659a592d5
child 410674 75b700c7225a91ac77bf92d71bb83c92d30baa2b
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1369712
milestone55.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 1369712 - Fix removing the gray roots tracer r=mccr8
js/src/jsapi.cpp
js/src/jsgc.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1325,17 +1325,17 @@ JS_PUBLIC_API(bool)
 JS_AddExtraGCRootsTracer(JSContext* cx, JSTraceDataOp traceOp, void* data)
 {
     return cx->runtime()->gc.addBlackRootsTracer(traceOp, data);
 }
 
 JS_PUBLIC_API(void)
 JS_RemoveExtraGCRootsTracer(JSContext* cx, JSTraceDataOp traceOp, void* data)
 {
-    return cx->runtime()->gc.removeBlackRootsTracer(traceOp, data);
+    cx->runtime()->gc.removeBlackRootsTracer(traceOp, data);
 }
 
 JS_PUBLIC_API(void)
 JS_GC(JSContext* cx)
 {
     AssertHeapIsIdle();
     JS::PrepareForFullGC(cx);
     cx->runtime()->gc.gc(GC_NORMAL, JS::gcreason::API);
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1431,22 +1431,26 @@ GCRuntime::addBlackRootsTracer(JSTraceDa
     AssertHeapIsIdle();
     return !!blackRootTracers.ref().append(Callback<JSTraceDataOp>(traceOp, data));
 }
 
 void
 GCRuntime::removeBlackRootsTracer(JSTraceDataOp traceOp, void* data)
 {
     // Can be called from finalizers
+    mozilla::DebugOnly<bool> removed = false;
     for (size_t i = 0; i < blackRootTracers.ref().length(); i++) {
         Callback<JSTraceDataOp>* e = &blackRootTracers.ref()[i];
         if (e->op == traceOp && e->data == data) {
             blackRootTracers.ref().erase(e);
+            removed = true;
+            break;
         }
     }
+    MOZ_ASSERT(removed);
 }
 
 void
 GCRuntime::setGrayRootsTracer(JSTraceDataOp traceOp, void* data)
 {
     AssertHeapIsIdle();
     grayRootTracer.op = traceOp;
     grayRootTracer.data = data;
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -552,17 +552,17 @@ CycleCollectedJSRuntime::CycleCollectedJ
 
   JS::dbg::SetDebuggerMallocSizeOf(aCx, moz_malloc_size_of);
 }
 
 void
 CycleCollectedJSRuntime::Shutdown(JSContext* cx)
 {
   JS_RemoveExtraGCRootsTracer(cx, TraceBlackJS, this);
-  JS_RemoveExtraGCRootsTracer(cx, TraceGrayJS, this);
+  JS_SetGrayGCRootsTracer(cx, nullptr, nullptr);
 }
 
 CycleCollectedJSRuntime::~CycleCollectedJSRuntime()
 {
   MOZ_COUNT_DTOR(CycleCollectedJSRuntime);
   MOZ_ASSERT(!mDeferredFinalizerTable.Count());
 }