8154467: Cleanup initialization of GCPolicyCounters
authormgerdin
Thu, 21 Apr 2016 10:18:50 +0200
changeset 38010 51fe205359f8
parent 38009 290ae73980f7
child 38011 74a6871d896b
8154467: Cleanup initialization of GCPolicyCounters Reviewed-by: ehelin, sjohanss
hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp
hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp
hotspot/src/share/vm/gc/g1/g1Policy.cpp
hotspot/src/share/vm/gc/g1/g1Policy.hpp
hotspot/src/share/vm/gc/parallel/generationSizer.hpp
hotspot/src/share/vm/gc/serial/defNewGeneration.cpp
hotspot/src/share/vm/gc/shared/collectorPolicy.hpp
--- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Thu Apr 21 09:08:33 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Thu Apr 21 10:18:50 2016 +0200
@@ -103,7 +103,3 @@
   CollectorPolicy::initialize_flags();
 }
 
-// Create the jstat counters for the policy.
-void G1CollectorPolicy::initialize_gc_policy_counters() {
-  _gc_policy_counters = new GCPolicyCounters("GarbageFirst", 1, 3);
-}
--- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp	Thu Apr 21 09:08:33 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp	Thu Apr 21 10:18:50 2016 +0200
@@ -44,8 +44,6 @@
 
   void post_heap_initialize() {} // Nothing needed.
 
-  // Create jstat counters for the policy.
-  virtual void initialize_gc_policy_counters();
 };
 
 #endif // SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP
--- a/hotspot/src/share/vm/gc/g1/g1Policy.cpp	Thu Apr 21 09:08:33 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1Policy.cpp	Thu Apr 21 10:18:50 2016 +0200
@@ -52,6 +52,7 @@
 
   _bytes_allocated_in_old_since_last_gc(0),
   _ihop_control(NULL),
+  _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 3)),
   _initial_mark_to_mixed() {
 
   // SurvRateGroups below must be initialized after the predictor because they
@@ -92,8 +93,6 @@
 
   assert(Heap_lock->owned_by_self(), "Locking discipline.");
 
-  _g1->collector_policy()->initialize_gc_policy_counters();
-
   if (adaptive_young_list_length()) {
     _young_list_fixed_length = 0;
   } else {
@@ -970,9 +969,8 @@
   // smaller than 1.0) we'll get 1.
   _max_survivor_regions = (uint) ceil(max_survivor_regions_d);
 
-  GCPolicyCounters* counters = _g1->collector_policy()->counters();
   _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold(
-        HeapRegion::GrainWords * _max_survivor_regions, counters);
+      HeapRegion::GrainWords * _max_survivor_regions, _policy_counters);
 }
 
 bool G1Policy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) {
--- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp	Thu Apr 21 09:08:33 2016 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp	Thu Apr 21 10:18:50 2016 +0200
@@ -46,6 +46,7 @@
 class G1IHOPControl;
 class G1Analytics;
 class G1YoungGenSizer;
+class GCPolicyCounters;
 
 class G1Policy: public CHeapObj<mtGC> {
  private:
@@ -62,6 +63,8 @@
   G1Analytics* _analytics;
   G1MMUTracker* _mmu_tracker;
 
+  GCPolicyCounters* _policy_counters;
+
   double _full_collection_start_sec;
 
   uint _young_list_target_length;
--- a/hotspot/src/share/vm/gc/parallel/generationSizer.hpp	Thu Apr 21 09:08:33 2016 +0200
+++ b/hotspot/src/share/vm/gc/parallel/generationSizer.hpp	Thu Apr 21 10:18:50 2016 +0200
@@ -41,5 +41,11 @@
   void initialize_alignments();
   void initialize_flags();
   void initialize_size_info();
+
+ public:
+  // We don't have associated counters and complain if this is invoked.
+  void initialize_gc_policy_counters() {
+    ShouldNotReachHere();
+  }
 };
 #endif // SHARE_VM_GC_PARALLEL_GENERATIONSIZER_HPP
--- a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp	Thu Apr 21 09:08:33 2016 +0200
+++ b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp	Thu Apr 21 10:18:50 2016 +0200
@@ -564,7 +564,7 @@
 
 void DefNewGeneration::adjust_desired_tenuring_threshold() {
   // Set the desired survivor size to half the real survivor space
-  GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->collector_policy()->counters();
+  GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->gen_policy()->counters();
   _tenuring_threshold =
     age_table()->compute_tenuring_threshold(to()->capacity()/HeapWordSize, gc_counters);
 }
@@ -945,7 +945,7 @@
 
   // update the generation and space performance counters
   update_counters();
-  gch->collector_policy()->counters()->update_counters();
+  gch->gen_policy()->counters()->update_counters();
 }
 
 void DefNewGeneration::record_spaces_top() {
--- a/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp	Thu Apr 21 09:08:33 2016 +0200
+++ b/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp	Thu Apr 21 10:18:50 2016 +0200
@@ -58,8 +58,6 @@
 
 class CollectorPolicy : public CHeapObj<mtGC> {
  protected:
-  GCPolicyCounters* _gc_policy_counters;
-
   virtual void initialize_alignments() = 0;
   virtual void initialize_flags();
   virtual void initialize_size_info();
@@ -149,15 +147,6 @@
                                                size_t size,
                                                Metaspace::MetadataType mdtype);
 
-  // Performance Counter support
-  GCPolicyCounters* counters()     { return _gc_policy_counters; }
-
-  // Create the jstat counters for the GC policy.  By default, policy's
-  // don't have associated counters, and we complain if this is invoked.
-  virtual void initialize_gc_policy_counters() {
-    ShouldNotReachHere();
-  }
-
   // Do any updates required to global flags that are due to heap initialization
   // changes
   virtual void post_heap_initialize() = 0;
@@ -197,6 +186,8 @@
   GenerationSpec* _young_gen_spec;
   GenerationSpec* _old_gen_spec;
 
+  GCPolicyCounters* _gc_policy_counters;
+
   // Return true if an allocation should be attempted in the older generation
   // if it fails in the younger generation.  Return false, otherwise.
   virtual bool should_try_older_generation_allocation(size_t word_size) const;
@@ -243,6 +234,12 @@
     return _old_gen_spec;
   }
 
+  // Performance Counter support
+  GCPolicyCounters* counters()     { return _gc_policy_counters; }
+
+  // Create the jstat counters for the GC policy.
+  virtual void initialize_gc_policy_counters() = 0;
+
   virtual GenCollectorPolicy* as_generation_policy() { return this; }
 
   virtual void initialize_generations() { };