8154467: Cleanup initialization of GCPolicyCounters

Reviewed-by: ehelin, sjohanss
This commit is contained in:
Mikael Gerdin 2016-04-21 10:18:50 +02:00
parent fdd7fde740
commit 39b43a87e7
7 changed files with 21 additions and 23 deletions

View file

@ -103,7 +103,3 @@ void G1CollectorPolicy::initialize_flags() {
CollectorPolicy::initialize_flags(); CollectorPolicy::initialize_flags();
} }
// Create the jstat counters for the policy.
void G1CollectorPolicy::initialize_gc_policy_counters() {
_gc_policy_counters = new GCPolicyCounters("GarbageFirst", 1, 3);
}

View file

@ -44,8 +44,6 @@ public:
void post_heap_initialize() {} // Nothing needed. 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 #endif // SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP

View file

@ -52,6 +52,7 @@ G1Policy::G1Policy() :
_bytes_allocated_in_old_since_last_gc(0), _bytes_allocated_in_old_since_last_gc(0),
_ihop_control(NULL), _ihop_control(NULL),
_policy_counters(new GCPolicyCounters("GarbageFirst", 1, 3)),
_initial_mark_to_mixed() { _initial_mark_to_mixed() {
// SurvRateGroups below must be initialized after the predictor because they // SurvRateGroups below must be initialized after the predictor because they
@ -92,8 +93,6 @@ void G1Policy::init() {
assert(Heap_lock->owned_by_self(), "Locking discipline."); assert(Heap_lock->owned_by_self(), "Locking discipline.");
_g1->collector_policy()->initialize_gc_policy_counters();
if (adaptive_young_list_length()) { if (adaptive_young_list_length()) {
_young_list_fixed_length = 0; _young_list_fixed_length = 0;
} else { } else {
@ -970,9 +969,8 @@ void G1Policy::update_survivors_policy() {
// smaller than 1.0) we'll get 1. // smaller than 1.0) we'll get 1.
_max_survivor_regions = (uint) ceil(max_survivor_regions_d); _max_survivor_regions = (uint) ceil(max_survivor_regions_d);
GCPolicyCounters* counters = _g1->collector_policy()->counters();
_tenuring_threshold = _survivors_age_table.compute_tenuring_threshold( _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) { bool G1Policy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) {

View file

@ -46,6 +46,7 @@ class CollectionSetChooser;
class G1IHOPControl; class G1IHOPControl;
class G1Analytics; class G1Analytics;
class G1YoungGenSizer; class G1YoungGenSizer;
class GCPolicyCounters;
class G1Policy: public CHeapObj<mtGC> { class G1Policy: public CHeapObj<mtGC> {
private: private:
@ -62,6 +63,8 @@ class G1Policy: public CHeapObj<mtGC> {
G1Analytics* _analytics; G1Analytics* _analytics;
G1MMUTracker* _mmu_tracker; G1MMUTracker* _mmu_tracker;
GCPolicyCounters* _policy_counters;
double _full_collection_start_sec; double _full_collection_start_sec;
uint _young_list_target_length; uint _young_list_target_length;

View file

@ -41,5 +41,11 @@ class GenerationSizer : public GenCollectorPolicy {
void initialize_alignments(); void initialize_alignments();
void initialize_flags(); void initialize_flags();
void initialize_size_info(); 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 #endif // SHARE_VM_GC_PARALLEL_GENERATIONSIZER_HPP

View file

@ -564,7 +564,7 @@ HeapWord* DefNewGeneration::expand_and_allocate(size_t size,
void DefNewGeneration::adjust_desired_tenuring_threshold() { void DefNewGeneration::adjust_desired_tenuring_threshold() {
// Set the desired survivor size to half the real survivor space // 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 = _tenuring_threshold =
age_table()->compute_tenuring_threshold(to()->capacity()/HeapWordSize, gc_counters); age_table()->compute_tenuring_threshold(to()->capacity()/HeapWordSize, gc_counters);
} }
@ -945,7 +945,7 @@ void DefNewGeneration::gc_epilogue(bool full) {
// update the generation and space performance counters // update the generation and space performance counters
update_counters(); update_counters();
gch->collector_policy()->counters()->update_counters(); gch->gen_policy()->counters()->update_counters();
} }
void DefNewGeneration::record_spaces_top() { void DefNewGeneration::record_spaces_top() {

View file

@ -58,8 +58,6 @@ class MarkSweepPolicy;
class CollectorPolicy : public CHeapObj<mtGC> { class CollectorPolicy : public CHeapObj<mtGC> {
protected: protected:
GCPolicyCounters* _gc_policy_counters;
virtual void initialize_alignments() = 0; virtual void initialize_alignments() = 0;
virtual void initialize_flags(); virtual void initialize_flags();
virtual void initialize_size_info(); virtual void initialize_size_info();
@ -149,15 +147,6 @@ class CollectorPolicy : public CHeapObj<mtGC> {
size_t size, size_t size,
Metaspace::MetadataType mdtype); 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 // Do any updates required to global flags that are due to heap initialization
// changes // changes
virtual void post_heap_initialize() = 0; virtual void post_heap_initialize() = 0;
@ -197,6 +186,8 @@ class GenCollectorPolicy : public CollectorPolicy {
GenerationSpec* _young_gen_spec; GenerationSpec* _young_gen_spec;
GenerationSpec* _old_gen_spec; GenerationSpec* _old_gen_spec;
GCPolicyCounters* _gc_policy_counters;
// Return true if an allocation should be attempted in the older generation // Return true if an allocation should be attempted in the older generation
// if it fails in the younger generation. Return false, otherwise. // if it fails in the younger generation. Return false, otherwise.
virtual bool should_try_older_generation_allocation(size_t word_size) const; virtual bool should_try_older_generation_allocation(size_t word_size) const;
@ -243,6 +234,12 @@ class GenCollectorPolicy : public CollectorPolicy {
return _old_gen_spec; 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 GenCollectorPolicy* as_generation_policy() { return this; }
virtual void initialize_generations() { }; virtual void initialize_generations() { };