8198530: Move _gc_policy_counters from GenCollectorPolicy to GenCollectedHeap
authorstefank
Thu, 22 Feb 2018 18:37:48 +0100
changeset 49050 170c7b36aea6
parent 49049 effb50eeea4e
child 49051 f05f4b5cea20
8198530: Move _gc_policy_counters from GenCollectorPolicy to GenCollectedHeap Reviewed-by: kbarrett, sjohanss
src/hotspot/share/gc/cms/cmsCollectorPolicy.cpp
src/hotspot/share/gc/cms/cmsCollectorPolicy.hpp
src/hotspot/share/gc/cms/cmsHeap.cpp
src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp
src/hotspot/share/gc/parallel/generationSizer.hpp
src/hotspot/share/gc/serial/defNewGeneration.cpp
src/hotspot/share/gc/serial/serialHeap.cpp
src/hotspot/share/gc/shared/collectorPolicy.cpp
src/hotspot/share/gc/shared/collectorPolicy.hpp
src/hotspot/share/gc/shared/genCollectedHeap.cpp
src/hotspot/share/gc/shared/genCollectedHeap.hpp
--- a/src/hotspot/share/gc/cms/cmsCollectorPolicy.cpp	Thu Feb 22 18:37:23 2018 +0100
+++ b/src/hotspot/share/gc/cms/cmsCollectorPolicy.cpp	Thu Feb 22 18:37:48 2018 +0100
@@ -51,8 +51,3 @@
   _space_alignment = _gen_alignment = (uintx)Generation::GenGrain;
   _heap_alignment = compute_heap_alignment();
 }
-
-void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() {
-  // initialize the policy counters - 2 collectors, 2 generations
-  _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 2);
-}
--- a/src/hotspot/share/gc/cms/cmsCollectorPolicy.hpp	Thu Feb 22 18:37:23 2018 +0100
+++ b/src/hotspot/share/gc/cms/cmsCollectorPolicy.hpp	Thu Feb 22 18:37:48 2018 +0100
@@ -33,8 +33,6 @@
 
  public:
   ConcurrentMarkSweepPolicy() {}
-
-  void initialize_gc_policy_counters();
 };
 
 #endif // SHARE_VM_GC_CMS_CMSCOLLECTORPOLICY_HPP
--- a/src/hotspot/share/gc/cms/cmsHeap.cpp	Thu Feb 22 18:37:23 2018 +0100
+++ b/src/hotspot/share/gc/cms/cmsHeap.cpp	Thu Feb 22 18:37:48 2018 +0100
@@ -66,7 +66,8 @@
 CMSHeap::CMSHeap(GenCollectorPolicy *policy) :
     GenCollectedHeap(policy,
                      Generation::ParNew,
-                     Generation::ConcurrentMarkSweep),
+                     Generation::ConcurrentMarkSweep,
+                     "ParNew::CMS"),
     _eden_pool(NULL),
     _survivor_pool(NULL),
     _old_pool(NULL) {
--- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Thu Feb 22 18:37:23 2018 +0100
+++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Thu Feb 22 18:37:48 2018 +0100
@@ -1887,7 +1887,7 @@
   }
 
   // Should this be in gc_epilogue?
-  collector_policy()->counters()->update_counters();
+  heap->counters()->update_counters();
 
   {
     // Clear _foregroundGCShouldWait and, in the event that the
--- a/src/hotspot/share/gc/parallel/generationSizer.hpp	Thu Feb 22 18:37:23 2018 +0100
+++ b/src/hotspot/share/gc/parallel/generationSizer.hpp	Thu Feb 22 18:37:48 2018 +0100
@@ -41,11 +41,5 @@
   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/src/hotspot/share/gc/serial/defNewGeneration.cpp	Thu Feb 22 18:37:23 2018 +0100
+++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp	Thu Feb 22 18:37:48 2018 +0100
@@ -565,7 +565,7 @@
   _tenuring_threshold = age_table()->compute_tenuring_threshold(desired_survivor_size);
 
   if (UsePerfData) {
-    GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->gen_policy()->counters();
+    GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->counters();
     gc_counters->tenuring_threshold()->set_value(_tenuring_threshold);
     gc_counters->desired_survivor_size()->set_value(desired_survivor_size * oopSize);
   }
@@ -951,7 +951,7 @@
 
   // update the generation and space performance counters
   update_counters();
-  gch->gen_policy()->counters()->update_counters();
+  gch->counters()->update_counters();
 }
 
 void DefNewGeneration::record_spaces_top() {
--- a/src/hotspot/share/gc/serial/serialHeap.cpp	Thu Feb 22 18:37:23 2018 +0100
+++ b/src/hotspot/share/gc/serial/serialHeap.cpp	Thu Feb 22 18:37:48 2018 +0100
@@ -31,7 +31,8 @@
 SerialHeap::SerialHeap(GenCollectorPolicy* policy) :
     GenCollectedHeap(policy,
                      Generation::DefNew,
-                     Generation::MarkSweepCompact),
+                     Generation::MarkSweepCompact,
+                     "Copy:MSC"),
     _eden_pool(NULL),
     _survivor_pool(NULL),
     _old_pool(NULL) {
--- a/src/hotspot/share/gc/shared/collectorPolicy.cpp	Thu Feb 22 18:37:23 2018 +0100
+++ b/src/hotspot/share/gc/shared/collectorPolicy.cpp	Thu Feb 22 18:37:48 2018 +0100
@@ -546,8 +546,3 @@
   _space_alignment = _gen_alignment = (size_t)Generation::GenGrain;
   _heap_alignment = compute_heap_alignment();
 }
-
-void MarkSweepPolicy::initialize_gc_policy_counters() {
-  // Initialize the policy counters - 2 collectors, 2 generations.
-  _gc_policy_counters = new GCPolicyCounters("Copy:MSC", 2, 2);
-}
--- a/src/hotspot/share/gc/shared/collectorPolicy.hpp	Thu Feb 22 18:37:23 2018 +0100
+++ b/src/hotspot/share/gc/shared/collectorPolicy.hpp	Thu Feb 22 18:37:48 2018 +0100
@@ -53,7 +53,6 @@
 class G1CollectorPolicy;
 #endif // INCLUDE_ALL_GCS
 
-class GCPolicyCounters;
 class MarkSweepPolicy;
 
 class CollectorPolicy : public CHeapObj<mtGC> {
@@ -108,8 +107,6 @@
   // time. When using large pages they can differ.
   size_t _gen_alignment;
 
-  GCPolicyCounters* _gc_policy_counters;
-
   void initialize_flags();
   void initialize_size_info();
 
@@ -139,12 +136,6 @@
   size_t initial_old_size()   { return _initial_old_size; }
   size_t max_old_size()       { return _max_old_size; }
 
-  // Performance Counter support
-  GCPolicyCounters* counters()     { return _gc_policy_counters; }
-
-  // Create the jstat counters for the GC policy.
-  virtual void initialize_gc_policy_counters() = 0;
-
   size_t young_gen_size_lower_bound();
 
   size_t old_gen_size_lower_bound();
@@ -156,8 +147,6 @@
 
  public:
   MarkSweepPolicy() {}
-
-  void initialize_gc_policy_counters();
 };
 
 #endif // SHARE_VM_GC_SHARED_COLLECTORPOLICY_HPP
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp	Thu Feb 22 18:37:23 2018 +0100
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp	Thu Feb 22 18:37:48 2018 +0100
@@ -36,6 +36,7 @@
 #include "gc/shared/collectorCounters.hpp"
 #include "gc/shared/gcId.hpp"
 #include "gc/shared/gcLocker.inline.hpp"
+#include "gc/shared/gcPolicyCounters.hpp"
 #include "gc/shared/gcTrace.hpp"
 #include "gc/shared/gcTraceTime.inline.hpp"
 #include "gc/shared/genCollectedHeap.hpp"
@@ -64,7 +65,8 @@
 
 GenCollectedHeap::GenCollectedHeap(GenCollectorPolicy *policy,
                                    Generation::Name young,
-                                   Generation::Name old) :
+                                   Generation::Name old,
+                                   const char* policy_counters_name) :
   CollectedHeap(),
   _rem_set(NULL),
   _young_gen_spec(new GenerationSpec(young,
@@ -77,6 +79,7 @@
                                    policy->gen_alignment())),
   _gen_policy(policy),
   _soft_ref_gen_policy(),
+  _gc_policy_counters(new GCPolicyCounters(policy_counters_name, 2, 2)),
   _process_strong_tasks(new SubTasksDone(GCH_PS_NumElements)),
   _full_collections_completed(0) {
 }
@@ -168,8 +171,6 @@
   initialize_size_policy(def_new_gen->eden()->capacity(),
                          _old_gen->capacity(),
                          def_new_gen->from()->capacity());
-
-  _gen_policy->initialize_gc_policy_counters();
 }
 
 void GenCollectedHeap::ref_processing_init() {
--- a/src/hotspot/share/gc/shared/genCollectedHeap.hpp	Thu Feb 22 18:37:23 2018 +0100
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.hpp	Thu Feb 22 18:37:48 2018 +0100
@@ -31,6 +31,7 @@
 #include "gc/shared/softRefGenPolicy.hpp"
 
 class AdaptiveSizePolicy;
+class GCPolicyCounters;
 class GenerationSpec;
 class StrongRootsScope;
 class SubTasksDone;
@@ -80,6 +81,8 @@
   // The sizing of the heap is controlled by a sizing policy.
   AdaptiveSizePolicy* _size_policy;
 
+  GCPolicyCounters* _gc_policy_counters;
+
   // Indicates that the most recent previous incremental collection failed.
   // The flag is cleared when an action is taken that might clear the
   // condition that caused that incremental collection to fail.
@@ -155,7 +158,8 @@
 
   GenCollectedHeap(GenCollectorPolicy *policy,
                    Generation::Name young,
-                   Generation::Name old);
+                   Generation::Name old,
+                   const char* policy_counters_name);
 
   virtual void check_gen_kinds() = 0;
 
@@ -192,6 +196,9 @@
     return _size_policy;
   }
 
+  // Performance Counter support
+  GCPolicyCounters* counters()     { return _gc_policy_counters; }
+
   // Return the (conservative) maximum heap alignment
   static size_t conservative_max_heap_alignment() {
     return Generation::GenGrain;