Bug 1527225 - Use mozilla::Clamp in maybeResizeNursery() r=sfink
authorPaul Bone <pbone@mozilla.com>
Fri, 15 Feb 2019 01:51:15 +0000
changeset 459360 632b98194776ef99a62fafde12cf8329dedc9248
parent 459359 2f15c7ef4a7f73f85b6e3e199f80c3c633ef1c25
child 459361 df73bbe3586098edbd6b011c973f316f4ebf3083
push id35559
push userrmaries@mozilla.com
push dateFri, 15 Feb 2019 09:55:16 +0000
treeherdermozilla-central@fc01e86f7e80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1527225
milestone67.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 1527225 - Use mozilla::Clamp in maybeResizeNursery() r=sfink Differential Revision: https://phabricator.services.mozilla.com/D19743
js/src/gc/Nursery.cpp
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -1165,26 +1165,26 @@ void js::Nursery::maybeResizeNursery(JS:
    * advance doesn't exist.
    */
   const float factor = promotionRate / PromotionGoal;
   const unsigned newChunkCount = round(float(maxChunkCount()) * factor);
 
   // 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
   // seeking says the current size is ideal.
-  if (promotionRate > GrowThreshold) {
+  if (maxChunkCount() < chunkCountLimit() && promotionRate > GrowThreshold) {
     unsigned lowLimit = maxChunkCount() + 1;
     unsigned highLimit = Min(chunkCountLimit(), maxChunkCount() * 2);
 
-    growAllocableSpace(Min(Max(newChunkCount, lowLimit), highLimit));
+    growAllocableSpace(mozilla::Clamp(newChunkCount, lowLimit, highLimit));
   } else if (maxChunkCount() > 1 && promotionRate < ShrinkThreshold) {
     unsigned lowLimit = Max(1u, maxChunkCount() / 2);
     unsigned highLimit = maxChunkCount() - 1u;
 
-    shrinkAllocableSpace(Max(Min(newChunkCount, highLimit), lowLimit));
+    shrinkAllocableSpace(mozilla::Clamp(newChunkCount, lowLimit, highLimit));
   }
 }
 
 void js::Nursery::growAllocableSpace(unsigned newCount) {
   MOZ_ASSERT(newCount >= currentChunk_);
   maxChunkCount_ = newCount;
 }