Bug 1542279 - Fix a problem with rounding down to zero r=jonco
authorPaul Bone <pbone@mozilla.com>
Tue, 09 Apr 2019 10:00:31 +0000
changeset 468531 8e4e52017c5db76281bf002a7230680ffc9e97c6
parent 468530 142748fa228edd66a60ca5e38f1b63cda018a165
child 468532 113a287cfb7f8badb75d17bcc51731cedb64e03a
push id112733
push usercsabou@mozilla.com
push dateTue, 09 Apr 2019 16:30:22 +0000
treeherdermozilla-inbound@e14dba56bbfd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1542279
milestone68.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 1542279 - Fix a problem with rounding down to zero r=jonco Differential Revision: https://phabricator.services.mozilla.com/D26463
js/src/gc/Nursery.cpp
js/src/jit-test/tests/gc/bug-1542279.js
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -1243,17 +1243,20 @@ bool js::Nursery::maybeResizeExact(JS::G
        ChunkSize)
           .toChecked<unsigned>();
   if (!newMaxNurseryChunksChecked.isValid()) {
     // The above calculation probably overflowed (I don't think it can
     // underflow).
     newMaxNurseryChunksChecked = 1;
   }
   unsigned newMaxNurseryChunks = newMaxNurseryChunksChecked.value();
-  MOZ_ASSERT(newMaxNurseryChunks > 0);
+  if (newMaxNurseryChunks == 0) {
+    // The above code rounded down, but don't round down all the way to zero.
+    newMaxNurseryChunks = 1;
+  }
   if (newMaxNurseryChunks != chunkCountLimit_) {
     chunkCountLimit_ = newMaxNurseryChunks;
     /* The configured maximum nursery size is changing */
     if (JS_HOWMANY(capacity_, gc::ChunkSize) > newMaxNurseryChunks) {
       /* We need to shrink the nursery */
       static_assert(NurseryChunkUsableSize < ChunkSize,
                     "Usable size must be smaller than total size or this "
                     "calculation might overflow");
--- a/js/src/jit-test/tests/gc/bug-1542279.js
+++ b/js/src/jit-test/tests/gc/bug-1542279.js
@@ -1,3 +1,8 @@
 
 gcparam('maxNurseryBytes', 2 ** 32 - 1);
+gc()
 
+gcparam('minNurseryBytes', 32*1024);
+gcparam('maxNurseryBytes', 64*1024);
+gc()
+