Bug 1335117 - Don't report that cells are gray in uncollected zones during incremental GC r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 31 Jan 2017 10:15:17 +0000
changeset 331753 efe0d03a98f1992a093f4790078f8049b8404a78
parent 331752 00760a3476267947621896dcd2329791c196aaf4
child 331754 d326fb22d7be6a4249326779996c1c2ed0de7635
push id86351
push userjcoppeard@mozilla.com
push dateTue, 31 Jan 2017 10:22:46 +0000
treeherdermozilla-inbound@efe0d03a98f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1335117
milestone54.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 1335117 - Don't report that cells are gray in uncollected zones during incremental GC r=sfink
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
@@ -7667,8 +7667,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);
+}