8134797: Remove explicit casts in CollectorPolicy hierarchy

Removed the explicit casts.

Reviewed-by: jwilhelm, tschatzl, pliden
This commit is contained in:
Kim Barrett 2015-09-08 16:00:34 -04:00
parent 30b987f6b7
commit 802664728f
8 changed files with 19 additions and 18 deletions

View File

@ -304,8 +304,7 @@ AdaptiveSizePolicy* CMSCollector::size_policy() {
void ConcurrentMarkSweepGeneration::initialize_performance_counters() { void ConcurrentMarkSweepGeneration::initialize_performance_counters() {
const char* gen_name = "old"; const char* gen_name = "old";
GenCollectorPolicy* gcp = (GenCollectorPolicy*) GenCollectedHeap::heap()->collector_policy(); GenCollectorPolicy* gcp = GenCollectedHeap::heap()->gen_policy();
// Generation Counters - generation 1, 1 subspace // Generation Counters - generation 1, 1 subspace
_gen_counters = new GenerationCounters(gen_name, 1, 1, _gen_counters = new GenerationCounters(gen_name, 1, 1,
gcp->min_old_size(), gcp->max_old_size(), &_virtual_space); gcp->min_old_size(), gcp->max_old_size(), &_virtual_space);

View File

@ -2397,6 +2397,10 @@ void G1CollectedHeap::ref_processing_init() {
// (for efficiency/performance) // (for efficiency/performance)
} }
CollectorPolicy* G1CollectedHeap::collector_policy() const {
return g1_policy();
}
size_t G1CollectedHeap::capacity() const { size_t G1CollectedHeap::capacity() const {
return _hrm.length() * HeapRegion::GrainBytes; return _hrm.length() * HeapRegion::GrainBytes;
} }

View File

@ -1057,7 +1057,7 @@ public:
// The current policy object for the collector. // The current policy object for the collector.
G1CollectorPolicy* g1_policy() const { return _g1_policy; } 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. // Adaptive size policy. No such thing for g1.
virtual AdaptiveSizePolicy* size_policy() { return NULL; } virtual AdaptiveSizePolicy* size_policy() { return NULL; }

View File

@ -87,7 +87,7 @@ class ParallelScavengeHeap : public CollectedHeap {
return CollectedHeap::ParallelScavengeHeap; 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 PSYoungGen* young_gen() { return _young_gen; }
static PSOldGen* old_gen() { return _old_gen; } static PSOldGen* old_gen() { return _old_gen; }

View File

@ -213,7 +213,7 @@ DefNewGeneration::DefNewGeneration(ReservedSpace rs,
_max_eden_size = size - (2*_max_survivor_size); _max_eden_size = size - (2*_max_survivor_size);
// allocate the performance counters // allocate the performance counters
GenCollectorPolicy* gcp = (GenCollectorPolicy*)gch->collector_policy(); GenCollectorPolicy* gcp = gch->gen_policy();
// Generation counters -- generation 0, 3 subspaces // Generation counters -- generation 0, 3 subspaces
_gen_counters = new GenerationCounters("new", 0, 3, _gen_counters = new GenerationCounters("new", 0, 3,

View File

@ -57,8 +57,7 @@ TenuredGeneration::TenuredGeneration(ReservedSpace rs,
// initialize performance counters // initialize performance counters
const char* gen_name = "old"; const char* gen_name = "old";
GenCollectorPolicy* gcp = (GenCollectorPolicy*) GenCollectedHeap::heap()->collector_policy(); GenCollectorPolicy* gcp = GenCollectedHeap::heap()->gen_policy();
// Generation Counters -- generation 1, 1 subspace // Generation Counters -- generation 1, 1 subspace
_gen_counters = new GenerationCounters(gen_name, 1, 1, _gen_counters = new GenerationCounters(gen_name, 1, 1,
gcp->min_old_size(), gcp->max_old_size(), &_virtual_space); gcp->min_old_size(), gcp->max_old_size(), &_virtual_space);

View File

@ -172,8 +172,6 @@ char* GenCollectedHeap::allocate(size_t alignment,
void GenCollectedHeap::post_initialize() { void GenCollectedHeap::post_initialize() {
CollectedHeap::post_initialize(); CollectedHeap::post_initialize();
ref_processing_init(); ref_processing_init();
GenCollectorPolicy *policy = (GenCollectorPolicy *)collector_policy();
guarantee(policy->is_generation_policy(), "Illegal policy type");
assert((_young_gen->kind() == Generation::DefNew) || assert((_young_gen->kind() == Generation::DefNew) ||
(_young_gen->kind() == Generation::ParNew), (_young_gen->kind() == Generation::ParNew),
"Wrong youngest generation type"); "Wrong youngest generation type");
@ -183,10 +181,10 @@ void GenCollectedHeap::post_initialize() {
_old_gen->kind() == Generation::MarkSweepCompact, _old_gen->kind() == Generation::MarkSweepCompact,
"Wrong generation kind"); "Wrong generation kind");
policy->initialize_size_policy(def_new_gen->eden()->capacity(), _gen_policy->initialize_size_policy(def_new_gen->eden()->capacity(),
_old_gen->capacity(), _old_gen->capacity(),
def_new_gen->from()->capacity()); def_new_gen->from()->capacity());
policy->initialize_gc_policy_counters(); _gen_policy->initialize_gc_policy_counters();
} }
void GenCollectedHeap::ref_processing_init() { void GenCollectedHeap::ref_processing_init() {
@ -822,10 +820,11 @@ bool GenCollectedHeap::create_cms_collector() {
"Unexpected generation kinds"); "Unexpected generation kinds");
// Skip two header words in the block content verification // Skip two header words in the block content verification
NOT_PRODUCT(_skip_header_HeapWords = CMSCollector::skip_header_HeapWords();) NOT_PRODUCT(_skip_header_HeapWords = CMSCollector::skip_header_HeapWords();)
CMSCollector* collector = new CMSCollector( assert(_gen_policy->is_concurrent_mark_sweep_policy(), "Unexpected policy type");
(ConcurrentMarkSweepGeneration*)_old_gen, CMSCollector* collector =
new CMSCollector((ConcurrentMarkSweepGeneration*)_old_gen,
_rem_set->as_CardTableRS(), _rem_set->as_CardTableRS(),
(ConcurrentMarkSweepPolicy*) collector_policy()); _gen_policy->as_concurrent_mark_sweep_policy());
if (collector == NULL || !collector->completed_initialization()) { if (collector == NULL || !collector->completed_initialization()) {
if (collector) { if (collector) {

View File

@ -153,7 +153,7 @@ public:
// The generational collector policy. // The generational collector policy.
GenCollectorPolicy* gen_policy() const { return _gen_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 // Adaptive size policy
virtual AdaptiveSizePolicy* size_policy() { virtual AdaptiveSizePolicy* size_policy() {