Bug 1515648 - Part 1: Assert read barriers won't fire during collection. r=jonco
authorYoshi Cheng-Hao Huang <allstars.chh@gmail.com>
Thu, 20 Dec 2018 15:34:25 +0100
changeset 452173 3d706269aea5497195d14c53e65067c05a6d9ad0
parent 452171 32810619d6b3fb498cba043bc19da2c62c878845
child 452174 8fe391c74c656692ab176faf453ede4f5e387fc2
push id35291
push userncsoregi@mozilla.com
push dateMon, 31 Dec 2018 16:09:23 +0000
treeherdermozilla-central@83d06ab87e74 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1515648
milestone66.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 1515648 - Part 1: Assert read barriers won't fire during collection. r=jonco
js/src/gc/Cell.h
--- a/js/src/gc/Cell.h
+++ b/js/src/gc/Cell.h
@@ -346,23 +346,19 @@ bool TenuredCell::isInsideZone(JS::Zone*
   return zone == arena()->zone;
 }
 
 /* static */ MOZ_ALWAYS_INLINE void TenuredCell::readBarrier(
     TenuredCell* thing) {
   MOZ_ASSERT(!CurrentThreadIsIonCompiling());
   MOZ_ASSERT(thing);
   MOZ_ASSERT(CurrentThreadCanAccessZone(thing->zoneFromAnyThread()));
-
-  // It would be good if barriers were never triggered during collection, but
-  // at the moment this can happen e.g. when rekeying tables containing
-  // read-barriered GC things after a moving GC.
-  //
-  // TODO: Fix this and assert we're not collecting if we're on the active
-  // thread.
+  // Barriers should not be triggered on main thread while collecting.
+  MOZ_ASSERT_IF(CurrentThreadCanAccessRuntime(thing->runtimeFromAnyThread()),
+                !JS::RuntimeHeapIsCollecting());
 
   JS::shadow::Zone* shadowZone = thing->shadowZoneFromAnyThread();
   if (shadowZone->needsIncrementalBarrier()) {
     // Barriers are only enabled on the main thread and are disabled while
     // collecting.
     MOZ_ASSERT(!RuntimeFromMainThreadIsHeapMajorCollecting(shadowZone));
     Cell* tmp = thing;
     TraceManuallyBarrieredGenericPointerEdge(shadowZone->barrierTracer(), &tmp,