Commit 35c57a98 authored by Paul Bone's avatar Paul Bone
Browse files

Bug 1540670 - Forbid a nursery size of 0 r=jonco

The nursery uses capacity_ == 0 to determine if it is disabled.  This patch
avoids setting the capacity to zero by requring the minimum size to be at
least ArenaSize (usually 1 page).

Differential Revision: https://phabricator.services.mozilla.com/D25717

--HG--
extra : moz-landing-system : lando
parent 1c472b4e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1403,7 +1403,8 @@ bool GCSchedulingTunables::setParameter(JSGCParamKey key, uint32_t value,
      gcMaxBytes_ = value;
      break;
    case JSGC_MIN_NURSERY_BYTES:
      if (value > gcMaxNurseryBytes_ && gcMaxNurseryBytes_ != 0) {
      if ((value > gcMaxNurseryBytes_ && gcMaxNurseryBytes_ != 0) ||
          value < ArenaSize) {
        // We make an exception for gcMaxNurseryBytes_ == 0 since that special
        // value is used to disable generational GC.
        return false;
+5 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ bool js::Nursery::init(uint32_t maxNurseryBytes, AutoLockGCBgAlloc& lock) {
    return false;
  }
  capacity_ = roundSize(tunables().gcMinNurseryBytes());
  MOZ_ASSERT(capacity_ >= ArenaSize);
  /* After this point the Nursery has been enabled */

  setCurrentChunk(0, true);
@@ -195,6 +196,7 @@ void js::Nursery::enable() {
      return;
    }
    capacity_ = roundSize(tunables().gcMinNurseryBytes());
    MOZ_ASSERT(capacity_ >= ArenaSize);
  }

  setCurrentChunk(0, true);
@@ -1193,6 +1195,7 @@ void js::Nursery::maybeResizeNursery(JS::GCReason reason) {
  size_t newCapacity = size_t(float(capacity()) * factor);

  const size_t minNurseryBytes = roundSize(tunables().gcMinNurseryBytes());
  MOZ_ASSERT(minNurseryBytes >= ArenaSize);

  // If one of these conditions is true then we always shrink or grow the
  // nursery.  This way the thresholds still have an effect even if the goal
@@ -1252,6 +1255,7 @@ bool js::Nursery::maybeResizeExact(JS::GCReason reason) {
  }

  const size_t minNurseryBytes = roundSize(tunables().gcMinNurseryBytes());
  MOZ_ASSERT(minNurseryBytes >= ArenaSize);

  if (minNurseryBytes > capacity()) {
    /*
@@ -1317,6 +1321,7 @@ void js::Nursery::shrinkAllocableSpace(size_t newCapacity) {
  }

  capacity_ = newCapacity;
  MOZ_ASSERT(capacity_ >= ArenaSize);
  setCurrentEnd();
}