Bug 1562550 - (part 4) We don't need to poison the start chunk here r=jonco
authorPaul Bone <pbone@mozilla.com>
Thu, 11 Jul 2019 02:26:15 +0000
changeset 482334 89feefb6541ea7a4a18875c4153c8f03b8774b32
parent 482333 0e662f79db6c8c33dc99714b15a0d6367693578f
child 482335 6cc26a5b9fe20bd8b0d7bee9ad10c285be16da98
push id89701
push userpbone@mozilla.com
push dateThu, 11 Jul 2019 04:30:54 +0000
treeherderautoland@6cc26a5b9fe2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1562550
milestone70.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 1562550 - (part 4) We don't need to poison the start chunk here r=jonco Differential Revision: https://phabricator.services.mozilla.com/D37349
js/src/gc/Nursery.cpp
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -1192,23 +1192,39 @@ void js::Nursery::sweep(JSTracer* trc) {
   }
 
   sweepDictionaryModeObjects();
   sweepMapAndSetObjects();
 }
 
 void js::Nursery::clear() {
 #if defined(JS_GC_ZEAL) || defined(JS_CRASH_DIAGNOSTICS)
-  /* Poison the nursery contents so touching a freed object will crash. */
-  for (unsigned i = currentStartChunk_; i < currentChunk_; ++i) {
+  // Poison the nursery contents so touching a freed object will crash.
+  unsigned firstClearChunk;
+  if (runtime()->hasZealMode(ZealMode::GenerationalGC)) {
+    // Poison all the chunks used in this cycle. The new start chunk is
+    // reposioned in Nursery::collect() but there's no point optimising that in
+    // this case.
+    firstClearChunk = currentStartChunk_;
+  } else {
+    // In normal mode we start at the second chunk, the first one will be used
+    // in the next cycle and poisoned in Nusery::collect();
+    MOZ_ASSERT(currentStartChunk_ == 0);
+    firstClearChunk = 1;
+  }
+  for (unsigned i = firstClearChunk; i < currentChunk_; ++i) {
     chunk(i).poisonAfterEvict();
   }
+  // Clear only the used part of the chunk because that's the part we touched,
+  // but only if it's not going to be re-used immediately (>= firstClearChunk).
+  if (currentChunk_ >= firstClearChunk) {
+    chunk(currentChunk_)
+        .poisonAfterEvict(position() - chunk(currentChunk_).start());
+  }
   MOZ_ASSERT(maxChunkCount() > 0);
-  chunk(currentChunk_)
-      .poisonAfterEvict(position() - chunk(currentChunk_).start());
 #endif
 
   /*
    * Reset the start chunk & position if we're not in this zeal mode, or we're
    * in it and close to the end of the nursery.
    */
   if (!runtime()->hasZealMode(ZealMode::GenerationalGC) ||
       (runtime()->hasZealMode(ZealMode::GenerationalGC) &&