8198530: Move _gc_policy_counters from GenCollectorPolicy to GenCollectedHeap

Reviewed-by: kbarrett, sjohanss
This commit is contained in:
Stefan Karlsson 2018-02-22 18:37:48 +01:00
parent 5671589a10
commit 3ad60c1bd2
11 changed files with 19 additions and 38 deletions

View File

@ -51,8 +51,3 @@ void ConcurrentMarkSweepPolicy::initialize_alignments() {
_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);
}

View File

@ -33,8 +33,6 @@ class ConcurrentMarkSweepPolicy : public GenCollectorPolicy {
public:
ConcurrentMarkSweepPolicy() {}
void initialize_gc_policy_counters();
};
#endif // SHARE_VM_GC_CMS_CMSCOLLECTORPOLICY_HPP

View File

@ -66,7 +66,8 @@ public:
CMSHeap::CMSHeap(GenCollectorPolicy *policy) :
GenCollectedHeap(policy,
Generation::ParNew,
Generation::ConcurrentMarkSweep),
Generation::ConcurrentMarkSweep,
"ParNew::CMS"),
_eden_pool(NULL),
_survivor_pool(NULL),
_old_pool(NULL) {

View File

@ -1887,7 +1887,7 @@ void CMSCollector::collect_in_background(GCCause::Cause cause) {
}
// Should this be in gc_epilogue?
collector_policy()->counters()->update_counters();
heap->counters()->update_counters();
{
// Clear _foregroundGCShouldWait and, in the event that the

View File

@ -41,11 +41,5 @@ class GenerationSizer : public GenCollectorPolicy {
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

View File

@ -565,7 +565,7 @@ void DefNewGeneration::adjust_desired_tenuring_threshold() {
_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 @@ void DefNewGeneration::gc_epilogue(bool full) {
// update the generation and space performance counters
update_counters();
gch->gen_policy()->counters()->update_counters();
gch->counters()->update_counters();
}
void DefNewGeneration::record_spaces_top() {

View File

@ -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) {

View File

@ -546,8 +546,3 @@ void MarkSweepPolicy::initialize_alignments() {
_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);
}

View File

@ -53,7 +53,6 @@ class ConcurrentMarkSweepPolicy;
class G1CollectorPolicy;
#endif // INCLUDE_ALL_GCS
class GCPolicyCounters;
class MarkSweepPolicy;
class CollectorPolicy : public CHeapObj<mtGC> {
@ -108,8 +107,6 @@ protected:
// 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 @@ protected:
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 @@ class MarkSweepPolicy : public GenCollectorPolicy {
public:
MarkSweepPolicy() {}
void initialize_gc_policy_counters();
};
#endif // SHARE_VM_GC_SHARED_COLLECTORPOLICY_HPP

View File

@ -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 @@ GenCollectedHeap::GenCollectedHeap(GenCollectorPolicy *policy,
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 @@ void GenCollectedHeap::post_initialize() {
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() {

View File

@ -31,6 +31,7 @@
#include "gc/shared/softRefGenPolicy.hpp"
class AdaptiveSizePolicy;
class GCPolicyCounters;
class GenerationSpec;
class StrongRootsScope;
class SubTasksDone;
@ -80,6 +81,8 @@ private:
// 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 @@ protected:
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 @@ public:
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;