changeset 9291:abc9e76c520d

8134797: Remove explicit casts in CollectorPolicy hierarchy Summary: Removed the explicit casts. Reviewed-by: jwilhelm, tschatzl, pliden
author kbarrett
date Tue, 08 Sep 2015 16:00:34 -0400
parents 3b914aea509b
children 9810d3869392
files src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp src/share/vm/gc/g1/g1CollectedHeap.cpp src/share/vm/gc/g1/g1CollectedHeap.hpp src/share/vm/gc/parallel/parallelScavengeHeap.hpp src/share/vm/gc/serial/defNewGeneration.cpp src/share/vm/gc/serial/tenuredGeneration.cpp src/share/vm/gc/shared/genCollectedHeap.cpp src/share/vm/gc/shared/genCollectedHeap.hpp
diffstat 8 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Tue Sep 08 16:10:37 2015 +0200
+++ b/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Tue Sep 08 16:00:34 2015 -0400
@@ -304,8 +304,7 @@
 void ConcurrentMarkSweepGeneration::initialize_performance_counters() {
 
   const char* gen_name = "old";
-  GenCollectorPolicy* gcp = (GenCollectorPolicy*) GenCollectedHeap::heap()->collector_policy();
-
+  GenCollectorPolicy* gcp = GenCollectedHeap::heap()->gen_policy();
   // Generation Counters - generation 1, 1 subspace
   _gen_counters = new GenerationCounters(gen_name, 1, 1,
       gcp->min_old_size(), gcp->max_old_size(), &_virtual_space);
--- a/src/share/vm/gc/g1/g1CollectedHeap.cpp	Tue Sep 08 16:10:37 2015 +0200
+++ b/src/share/vm/gc/g1/g1CollectedHeap.cpp	Tue Sep 08 16:00:34 2015 -0400
@@ -2397,6 +2397,10 @@
                                 // (for efficiency/performance)
 }
 
+CollectorPolicy* G1CollectedHeap::collector_policy() const {
+  return g1_policy();
+}
+
 size_t G1CollectedHeap::capacity() const {
   return _hrm.length() * HeapRegion::GrainBytes;
 }
--- a/src/share/vm/gc/g1/g1CollectedHeap.hpp	Tue Sep 08 16:10:37 2015 +0200
+++ b/src/share/vm/gc/g1/g1CollectedHeap.hpp	Tue Sep 08 16:00:34 2015 -0400
@@ -1057,7 +1057,7 @@
   // The current policy object for the collector.
   G1CollectorPolicy* g1_policy() const { return _g1_policy; }
 
-  virtual CollectorPolicy* collector_policy() const { return (CollectorPolicy*) g1_policy(); }
+  virtual CollectorPolicy* collector_policy() const;
 
   // Adaptive size policy.  No such thing for g1.
   virtual AdaptiveSizePolicy* size_policy() { return NULL; }
--- a/src/share/vm/gc/parallel/parallelScavengeHeap.hpp	Tue Sep 08 16:10:37 2015 +0200
+++ b/src/share/vm/gc/parallel/parallelScavengeHeap.hpp	Tue Sep 08 16:00:34 2015 -0400
@@ -87,7 +87,7 @@
     return CollectedHeap::ParallelScavengeHeap;
   }
 
-  virtual CollectorPolicy* collector_policy() const { return (CollectorPolicy*) _collector_policy; }
+  virtual CollectorPolicy* collector_policy() const { return _collector_policy; }
 
   static PSYoungGen* young_gen() { return _young_gen; }
   static PSOldGen* old_gen()     { return _old_gen; }
--- a/src/share/vm/gc/serial/defNewGeneration.cpp	Tue Sep 08 16:10:37 2015 +0200
+++ b/src/share/vm/gc/serial/defNewGeneration.cpp	Tue Sep 08 16:00:34 2015 -0400
@@ -213,7 +213,7 @@
   _max_eden_size = size - (2*_max_survivor_size);
 
   // allocate the performance counters
-  GenCollectorPolicy* gcp = (GenCollectorPolicy*)gch->collector_policy();
+  GenCollectorPolicy* gcp = gch->gen_policy();
 
   // Generation counters -- generation 0, 3 subspaces
   _gen_counters = new GenerationCounters("new", 0, 3,
--- a/src/share/vm/gc/serial/tenuredGeneration.cpp	Tue Sep 08 16:10:37 2015 +0200
+++ b/src/share/vm/gc/serial/tenuredGeneration.cpp	Tue Sep 08 16:00:34 2015 -0400
@@ -57,8 +57,7 @@
   // initialize performance counters
 
   const char* gen_name = "old";
-  GenCollectorPolicy* gcp = (GenCollectorPolicy*) GenCollectedHeap::heap()->collector_policy();
-
+  GenCollectorPolicy* gcp = GenCollectedHeap::heap()->gen_policy();
   // Generation Counters -- generation 1, 1 subspace
   _gen_counters = new GenerationCounters(gen_name, 1, 1,
       gcp->min_old_size(), gcp->max_old_size(), &_virtual_space);
--- a/src/share/vm/gc/shared/genCollectedHeap.cpp	Tue Sep 08 16:10:37 2015 +0200
+++ b/src/share/vm/gc/shared/genCollectedHeap.cpp	Tue Sep 08 16:00:34 2015 -0400
@@ -172,8 +172,6 @@
 void GenCollectedHeap::post_initialize() {
   CollectedHeap::post_initialize();
   ref_processing_init();
-  GenCollectorPolicy *policy = (GenCollectorPolicy *)collector_policy();
-  guarantee(policy->is_generation_policy(), "Illegal policy type");
   assert((_young_gen->kind() == Generation::DefNew) ||
          (_young_gen->kind() == Generation::ParNew),
     "Wrong youngest generation type");
@@ -183,10 +181,10 @@
          _old_gen->kind() == Generation::MarkSweepCompact,
     "Wrong generation kind");
 
-  policy->initialize_size_policy(def_new_gen->eden()->capacity(),
-                                 _old_gen->capacity(),
-                                 def_new_gen->from()->capacity());
-  policy->initialize_gc_policy_counters();
+  _gen_policy->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() {
@@ -822,10 +820,11 @@
          "Unexpected generation kinds");
   // Skip two header words in the block content verification
   NOT_PRODUCT(_skip_header_HeapWords = CMSCollector::skip_header_HeapWords();)
-  CMSCollector* collector = new CMSCollector(
-    (ConcurrentMarkSweepGeneration*)_old_gen,
-    _rem_set->as_CardTableRS(),
-    (ConcurrentMarkSweepPolicy*) collector_policy());
+  assert(_gen_policy->is_concurrent_mark_sweep_policy(), "Unexpected policy type");
+  CMSCollector* collector =
+    new CMSCollector((ConcurrentMarkSweepGeneration*)_old_gen,
+                     _rem_set->as_CardTableRS(),
+                     _gen_policy->as_concurrent_mark_sweep_policy());
 
   if (collector == NULL || !collector->completed_initialization()) {
     if (collector) {
--- a/src/share/vm/gc/shared/genCollectedHeap.hpp	Tue Sep 08 16:10:37 2015 +0200
+++ b/src/share/vm/gc/shared/genCollectedHeap.hpp	Tue Sep 08 16:00:34 2015 -0400
@@ -153,7 +153,7 @@
   // The generational collector policy.
   GenCollectorPolicy* gen_policy() const { return _gen_policy; }
 
-  virtual CollectorPolicy* collector_policy() const { return (CollectorPolicy*) gen_policy(); }
+  virtual CollectorPolicy* collector_policy() const { return gen_policy(); }
 
   // Adaptive size policy
   virtual AdaptiveSizePolicy* size_policy() {