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 509276 3d706269aea5497195d14c53e65067c05a6d9ad0
parent 509274 32810619d6b3fb498cba043bc19da2c62c878845
child 509277 8fe391c74c656692ab176faf453ede4f5e387fc2
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [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,