changeset 10594:e928b4b9e4ea

8151604: Rely on options range checking rather than explict checks Reviewed-by: jwilhelm, drwhite, sangheki
author brutisso
date Sun, 13 Mar 2016 13:26:47 +0100
parents 85bb1e6db5cb
children 1b136ffa8a67
files src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp src/share/vm/gc/g1/g1CollectorPolicy.cpp
diffstat 2 files changed, 11 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Fri Mar 11 17:02:04 2016 +0100
+++ b/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Sun Mar 13 13:26:47 2016 +0100
@@ -2286,17 +2286,16 @@
     // all marking, then check if the new marks-vector is
     // a subset of the CMS marks-vector.
     verify_after_remark_work_1();
-  } else if (CMSRemarkVerifyVariant == 2) {
+  } else {
+    guarantee(CMSRemarkVerifyVariant == 2, "Range checking for CMSRemarkVerifyVariant should guarantee 1 or 2");
     // In this second variant of verification, we flag an error
     // (i.e. an object reachable in the new marks-vector not reachable
     // in the CMS marks-vector) immediately, also indicating the
     // identify of an object (A) that references the unmarked object (B) --
     // presumably, a mutation to A failed to be picked up by preclean/remark?
     verify_after_remark_work_2();
-  } else {
-    warning("Unrecognized value " UINTX_FORMAT " for CMSRemarkVerifyVariant",
-            CMSRemarkVerifyVariant);
-  }
+  }
+
   return true;
 }
 
--- a/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Fri Mar 11 17:02:04 2016 +0100
+++ b/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Sun Mar 13 13:26:47 2016 +0100
@@ -180,18 +180,7 @@
 
   // First make sure that, if either parameter is set, its value is
   // reasonable.
-  if (!FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
-    if (MaxGCPauseMillis < 1) {
-      vm_exit_during_initialization("MaxGCPauseMillis should be "
-                                    "greater than 0");
-    }
-  }
-  if (!FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
-    if (GCPauseIntervalMillis < 1) {
-      vm_exit_during_initialization("GCPauseIntervalMillis should be "
-                                    "greater than 0");
-    }
-  }
+  guarantee(MaxGCPauseMillis >= 1, "Range checking for MaxGCPauseMillis should guarantee that value is >= 1");
 
   // Then, if the pause time target parameter was not set, set it to
   // the default value.
@@ -213,16 +202,8 @@
   if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) {
     FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1);
   }
-
-  // Finally, make sure that the two parameters are consistent.
-  if (MaxGCPauseMillis >= GCPauseIntervalMillis) {
-    char buffer[256];
-    jio_snprintf(buffer, 256,
-                 "MaxGCPauseMillis (%u) should be less than "
-                 "GCPauseIntervalMillis (%u)",
-                 MaxGCPauseMillis, GCPauseIntervalMillis);
-    vm_exit_during_initialization(buffer);
-  }
+  guarantee(GCPauseIntervalMillis >= 1, "Constraint for GCPauseIntervalMillis should guarantee that value is >= 1");
+  guarantee(GCPauseIntervalMillis > MaxGCPauseMillis, "Constraint for GCPauseIntervalMillis should guarantee that GCPauseIntervalMillis > MaxGCPauseMillis");
 
   double max_gc_time = (double) MaxGCPauseMillis / 1000.0;
   double time_slice  = (double) GCPauseIntervalMillis / 1000.0;
@@ -238,14 +219,8 @@
          "if a user set it to 0");
   _gc_overhead_perc = 100.0 * (1.0 / (1.0 + GCTimeRatio));
 
-  uintx reserve_perc = G1ReservePercent;
-  // Put an artificial ceiling on this so that it's not set to a silly value.
-  if (reserve_perc > 50) {
-    reserve_perc = 50;
-    warning("G1ReservePercent is set to a value that is too large, "
-            "it's been updated to " UINTX_FORMAT, reserve_perc);
-  }
-  _reserve_factor = (double) reserve_perc / 100.0;
+  guarantee(G1ReservePercent <= 50, "Range checking should not allow values over 50.");
+  _reserve_factor = (double) G1ReservePercent / 100.0;
   // This will be set when the heap is expanded
   // for the first time during initialization.
   _reserve_regions = 0;
@@ -287,9 +262,8 @@
     FLAG_SET_ERGO(size_t, G1HeapRegionSize, HeapRegion::GrainBytes);
   }
 
-  if (SurvivorRatio < 1) {
-    vm_exit_during_initialization("Invalid survivor ratio specified");
-  }
+  guarantee(SurvivorRatio >= 1, "Range checking for SurvivorRatio should guarantee that value is >= 1");
+
   CollectorPolicy::initialize_flags();
   _young_gen_sizer = new G1YoungGenSizer(); // Must be after call to initialize_flags
 }