Bug 1335117 - Don't report that cells are gray in uncollected zones during incremental GC r=sfink a=gchang
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 31 Jan 2017 10:15:17 +0000
changeset 378216 2e221577245fb866c3221b1d3c63bd6166d24182
parent 378215 b6b1c659a33994ac2f2913f64b9f06be8b42ee66
child 378217 673d97776e64b8084064e59bca9cac760b7a11f9
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink, gchang
bugs1335117
milestone53.0a2
Bug 1335117 - Don't report that cells are gray in uncollected zones during incremental GC r=sfink a=gchang
js/public/HeapAPI.h
js/src/jsgc.cpp
--- a/js/public/HeapAPI.h
+++ b/js/public/HeapAPI.h
@@ -318,23 +318,18 @@ CellIsMarkedGray(const Cell* cell)
     if (js::gc::IsInsideNursery(cell))
         return false;
 
     uintptr_t* word, mask;
     js::gc::detail::GetGCThingMarkWordAndMask(uintptr_t(cell), js::gc::GRAY, &word, &mask);
     return *word & mask;
 }
 
-static MOZ_ALWAYS_INLINE bool
-CellIsMarkedGrayIfKnown(const Cell* cell)
-{
-    MOZ_ASSERT(cell);
-    auto rt = js::gc::detail::GetCellRuntime(cell);
-    return rt->areGCGrayBitsValid() && CellIsMarkedGray(cell);
-}
+extern JS_PUBLIC_API(bool)
+CellIsMarkedGrayIfKnown(const Cell* cell);
 
 } /* namespace detail */
 
 MOZ_ALWAYS_INLINE bool
 IsInsideNursery(const js::gc::Cell* cell)
 {
     if (!cell)
         return false;
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -7670,8 +7670,33 @@ js::gc::Cell::dump(FILE* fp) const
 
 // For use in a debugger.
 void
 js::gc::Cell::dump() const
 {
     dump(stderr);
 }
 #endif
+
+JS_PUBLIC_API(bool)
+js::gc::detail::CellIsMarkedGrayIfKnown(const Cell* cell)
+{
+    MOZ_ASSERT(cell);
+    if (!cell->isTenured())
+        return false;
+
+    // We ignore the gray marking state of cells and return false in two cases:
+    //
+    // 1) When OOM has caused us to clear the gcGrayBitsValid_ flag.
+    //
+    // 2) When we are in an incremental GC and examine a cell that is in a zone
+    // that is not being collected. Gray targets of CCWs that are marked black
+    // by a barrier will eventually be marked black in the next GC slice.
+    auto tc = &cell->asTenured();
+    auto rt = tc->runtimeFromMainThread();
+    if (!rt->areGCGrayBitsValid() ||
+        (rt->gc.isIncrementalGCInProgress() && !tc->zone()->wasGCStarted()))
+    {
+        return false;
+    }
+
+    return detail::CellIsMarkedGray(tc);
+}