src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp

Print this page
rev 7622 : 8068739: G1CollectorPolicy uses uninitialized field '_sigma' in the constructor
Reviewed-by: simonis
Contributed-by: johannes.scheerer@sap.com

@@ -151,26 +151,34 @@
   _inc_cset_recorded_rs_lengths(0),
   _inc_cset_recorded_rs_lengths_diffs(0),
   _inc_cset_predicted_elapsed_time_ms(0.0),
   _inc_cset_predicted_elapsed_time_ms_diffs(0.0),
 
-#ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
-#pragma warning( disable:4355 ) // 'this' : used in base member initializer list
-#endif // _MSC_VER
-
-  _short_lived_surv_rate_group(new SurvRateGroup(this, "Short Lived",
-                                                 G1YoungSurvRateNumRegionsSummary)),
-  _survivor_surv_rate_group(new SurvRateGroup(this, "Survivor",
-                                              G1YoungSurvRateNumRegionsSummary)),
   // add here any more surv rate groups
   _recorded_survivor_regions(0),
   _recorded_survivor_head(NULL),
   _recorded_survivor_tail(NULL),
   _survivors_age_table(true),
 
   _gc_overhead_perc(0.0) {
 
+  uintx confidence_perc = G1ConfidencePercent;
+  // Put an artificial ceiling on this so that it's not set to a silly value.
+  if (confidence_perc > 100) {
+    confidence_perc = 100;
+    warning("G1ConfidencePercent is set to a value that is too large, "
+            "it's been updated to %u", confidence_perc);
+  }
+  // '_sigma' must be initialized before the SurvRateGroups below because they
+  // indirecty access '_sigma' trough the 'this' pointer in their constructor.
+  _sigma = (double) confidence_perc / 100.0;
+
+  _short_lived_surv_rate_group =
+    new SurvRateGroup(this, "Short Lived", G1YoungSurvRateNumRegionsSummary);
+  _survivor_surv_rate_group =
+    new SurvRateGroup(this, "Survivor", G1YoungSurvRateNumRegionsSummary);
+
   // Set up the region size and associated fields. Given that the
   // policy is created before the heap, we have to set this up here,
   // so it's done as soon as possible.
 
   // It would have been natural to pass initial_heap_byte_size() and

@@ -281,19 +289,10 @@
 
   double max_gc_time = (double) MaxGCPauseMillis / 1000.0;
   double time_slice  = (double) GCPauseIntervalMillis / 1000.0;
   _mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time);
 
-  uintx confidence_perc = G1ConfidencePercent;
-  // Put an artificial ceiling on this so that it's not set to a silly value.
-  if (confidence_perc > 100) {
-    confidence_perc = 100;
-    warning("G1ConfidencePercent is set to a value that is too large, "
-            "it's been updated to %u", confidence_perc);
-  }
-  _sigma = (double) confidence_perc / 100.0;
-
   // start conservatively (around 50ms is about right)
   _concurrent_mark_remark_times_ms->add(0.05);
   _concurrent_mark_cleanup_times_ms->add(0.20);
   _tenuring_threshold = MaxTenuringThreshold;
   // _max_survivor_regions will be calculated by