< prev index next >

src/hotspot/share/gc/shared/genArguments.cpp

Print this page
rev 56881 : imported patch 8233702-function-to-clamp-value-to-range

@@ -227,11 +227,11 @@
     // Bound the maximum size by NewSize below (since it historically
     // would have been NewSize and because the NewRatio calculation could
     // yield a size that is too small) and bound it by MaxNewSize above.
     // Ergonomics plays here by previously calculating the desired
     // NewSize and MaxNewSize.
-    max_young_size = MIN2(MAX2(max_young_size, NewSize), MaxNewSize);
+    max_young_size = clamp(max_young_size, NewSize, MaxNewSize);
   }
 
   // Given the maximum young size, determine the initial and
   // minimum young sizes.
   size_t initial_young_size = NewSize;

@@ -258,11 +258,11 @@
       // For the case where NewSize is not set on the command line, use
       // NewRatio to size the initial generation size. Use the current
       // NewSize as the floor, because if NewRatio is overly large, the resulting
       // size can be too small.
       initial_young_size =
-        MIN2(max_young_size, MAX2(scale_by_NewRatio_aligned(InitialHeapSize, GenAlignment), NewSize));
+        clamp(scale_by_NewRatio_aligned(InitialHeapSize, GenAlignment), NewSize, max_young_size);
     }
   }
 
   log_trace(gc, heap)("1: Minimum young " SIZE_FORMAT "  Initial young " SIZE_FORMAT "  Maximum young " SIZE_FORMAT,
                       MinNewSize, initial_young_size, max_young_size);

@@ -283,11 +283,11 @@
     // may have chosen a value (which may or may not be consistent
     // with the overall heap size).  In either case make
     // the minimum, maximum and initial sizes consistent
     // with the young sizes and the overall heap sizes.
     MinOldSize = GenAlignment;
-    initial_old_size = MIN2(MaxOldSize, MAX2(InitialHeapSize - initial_young_size, MinOldSize));
+    initial_old_size = clamp(InitialHeapSize - initial_young_size, MinOldSize, MaxOldSize);
     // MaxOldSize has already been made consistent above.
   } else {
     // OldSize has been explicitly set on the command line. Use it
     // for the initial size but make sure the minimum allow a young
     // generation to fit as well.
< prev index next >