8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
Reviewed-by: pliden, sjohanss
--- a/src/hotspot/share/gc/cms/cmsCollectorPolicy.cpp Thu Feb 22 18:36:07 2018 +0100
+++ b/src/hotspot/share/gc/cms/cmsCollectorPolicy.cpp Thu Feb 22 18:36:32 2018 +0100
@@ -59,17 +59,6 @@
_initial_old_size, _max_old_size, _gen_alignment);
}
-void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size,
- size_t init_promo_size,
- size_t init_survivor_size) {
- double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
- _size_policy = new AdaptiveSizePolicy(init_eden_size,
- init_promo_size,
- init_survivor_size,
- max_gc_pause_sec,
- GCTimeRatio);
-}
-
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:36:07 2018 +0100
+++ b/src/hotspot/share/gc/cms/cmsCollectorPolicy.hpp Thu Feb 22 18:36:32 2018 +0100
@@ -36,10 +36,6 @@
ConcurrentMarkSweepPolicy() {}
void initialize_gc_policy_counters();
-
- virtual void initialize_size_policy(size_t init_eden_size,
- size_t init_promo_size,
- size_t init_survivor_size);
};
#endif // SHARE_VM_GC_CMS_CMSCOLLECTORPOLICY_HPP
--- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp Thu Feb 22 18:36:07 2018 +0100
+++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp Thu Feb 22 18:36:32 2018 +0100
@@ -300,8 +300,7 @@
}
AdaptiveSizePolicy* CMSCollector::size_policy() {
- CMSHeap* heap = CMSHeap::heap();
- return heap->gen_policy()->size_policy();
+ return CMSHeap::heap()->size_policy();
}
void ConcurrentMarkSweepGeneration::initialize_performance_counters() {
--- a/src/hotspot/share/gc/cms/parNewGeneration.cpp Thu Feb 22 18:36:07 2018 +0100
+++ b/src/hotspot/share/gc/cms/parNewGeneration.cpp Thu Feb 22 18:36:32 2018 +0100
@@ -889,7 +889,7 @@
_gc_timer->register_gc_start();
- AdaptiveSizePolicy* size_policy = gch->gen_policy()->size_policy();
+ AdaptiveSizePolicy* size_policy = gch->size_policy();
WorkGang* workers = gch->workers();
assert(workers != NULL, "Need workgang for parallel work");
uint active_workers =
@@ -1490,4 +1490,3 @@
SharedRestorePreservedMarksTaskExecutor task_executor(CMSHeap::heap()->workers());
_preserved_marks_set.restore(&task_executor);
}
-
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Thu Feb 22 18:36:07 2018 +0100
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Thu Feb 22 18:36:32 2018 +0100
@@ -59,6 +59,7 @@
#include "gc/g1/heapRegionRemSet.hpp"
#include "gc/g1/heapRegionSet.inline.hpp"
#include "gc/g1/vm_operations_g1.hpp"
+#include "gc/shared/adaptiveSizePolicy.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/gcId.hpp"
#include "gc/shared/gcLocker.inline.hpp"
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Thu Feb 22 18:36:07 2018 +0100
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Thu Feb 22 18:36:32 2018 +0100
@@ -1003,9 +1003,6 @@
virtual SoftRefPolicy* soft_ref_policy();
- // Adaptive size policy. No such thing for g1.
- virtual AdaptiveSizePolicy* size_policy() { return NULL; }
-
virtual GrowableArray<GCMemoryManager*> memory_managers();
virtual GrowableArray<MemoryPool*> memory_pools();
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp Thu Feb 22 18:36:07 2018 +0100
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp Thu Feb 22 18:36:32 2018 +0100
@@ -38,6 +38,7 @@
#include "gc/g1/heapRegion.inline.hpp"
#include "gc/g1/heapRegionRemSet.hpp"
#include "gc/g1/heapRegionSet.inline.hpp"
+#include "gc/shared/adaptiveSizePolicy.hpp"
#include "gc/shared/gcId.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"
--- a/src/hotspot/share/gc/serial/defNewGeneration.cpp Thu Feb 22 18:36:07 2018 +0100
+++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp Thu Feb 22 18:36:32 2018 +0100
@@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "gc/serial/defNewGeneration.inline.hpp"
+#include "gc/shared/adaptiveSizePolicy.hpp"
#include "gc/shared/ageTable.inline.hpp"
#include "gc/shared/cardTableRS.hpp"
#include "gc/shared/collectorCounters.hpp"
@@ -685,7 +686,7 @@
// A successful scavenge should restart the GC time limit count which is
// for full GC's.
- AdaptiveSizePolicy* size_policy = gch->gen_policy()->size_policy();
+ AdaptiveSizePolicy* size_policy = gch->size_policy();
size_policy->reset_gc_overhead_limit_count();
assert(!gch->incremental_collection_failed(), "Should be clear");
} else {
--- a/src/hotspot/share/gc/shared/collectorPolicy.cpp Thu Feb 22 18:36:07 2018 +0100
+++ b/src/hotspot/share/gc/shared/collectorPolicy.cpp Thu Feb 22 18:36:32 2018 +0100
@@ -172,8 +172,7 @@
_max_old_size(0),
_gen_alignment(0),
_young_gen_spec(NULL),
- _old_gen_spec(NULL),
- _size_policy(NULL)
+ _old_gen_spec(NULL)
{}
size_t GenCollectorPolicy::scale_by_NewRatio_aligned(size_t base_size) {
@@ -186,18 +185,6 @@
return desired_size < max_minus ? desired_size : max_minus;
}
-
-void GenCollectorPolicy::initialize_size_policy(size_t init_eden_size,
- size_t init_promo_size,
- size_t init_survivor_size) {
- const double max_gc_pause_sec = ((double) MaxGCPauseMillis) / 1000.0;
- _size_policy = new AdaptiveSizePolicy(init_eden_size,
- init_promo_size,
- init_survivor_size,
- max_gc_pause_sec,
- GCTimeRatio);
-}
-
size_t GenCollectorPolicy::young_gen_size_lower_bound() {
// The young generation must be aligned and have room for eden + two survivors
return align_up(3 * _space_alignment, _gen_alignment);
--- a/src/hotspot/share/gc/shared/collectorPolicy.hpp Thu Feb 22 18:36:07 2018 +0100
+++ b/src/hotspot/share/gc/shared/collectorPolicy.hpp Thu Feb 22 18:36:32 2018 +0100
@@ -113,9 +113,6 @@
GCPolicyCounters* _gc_policy_counters;
- // The sizing of the heap is controlled by a sizing policy.
- AdaptiveSizePolicy* _size_policy;
-
void initialize_flags();
void initialize_size_info();
@@ -171,13 +168,6 @@
size_t young_gen_size_lower_bound();
size_t old_gen_size_lower_bound();
-
- // Adaptive size policy
- AdaptiveSizePolicy* size_policy() { return _size_policy; }
-
- virtual void initialize_size_policy(size_t init_eden_size,
- size_t init_promo_size,
- size_t init_survivor_size);
};
class MarkSweepPolicy : public GenCollectorPolicy {
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp Thu Feb 22 18:36:07 2018 +0100
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp Thu Feb 22 18:36:32 2018 +0100
@@ -30,6 +30,7 @@
#include "classfile/vmSymbols.hpp"
#include "code/codeCache.hpp"
#include "code/icBuffer.hpp"
+#include "gc/shared/adaptiveSizePolicy.hpp"
#include "gc/shared/cardTableRS.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/collectorCounters.hpp"
@@ -111,6 +112,17 @@
return JNI_OK;
}
+void GenCollectedHeap::initialize_size_policy(size_t init_eden_size,
+ size_t init_promo_size,
+ size_t init_survivor_size) {
+ const double max_gc_pause_sec = ((double) MaxGCPauseMillis) / 1000.0;
+ _size_policy = new AdaptiveSizePolicy(init_eden_size,
+ init_promo_size,
+ init_survivor_size,
+ max_gc_pause_sec,
+ GCTimeRatio);
+}
+
char* GenCollectedHeap::allocate(size_t alignment,
ReservedSpace* heap_rs){
// Now figure out the total size.
@@ -148,9 +160,9 @@
check_gen_kinds();
DefNewGeneration* def_new_gen = (DefNewGeneration*)_young_gen;
- _gen_policy->initialize_size_policy(def_new_gen->eden()->capacity(),
- _old_gen->capacity(),
- def_new_gen->from()->capacity());
+ initialize_size_policy(def_new_gen->eden()->capacity(),
+ _old_gen->capacity(),
+ def_new_gen->from()->capacity());
_gen_policy->initialize_gc_policy_counters();
}
@@ -332,12 +344,12 @@
// will be thrown. Clear gc_overhead_limit_exceeded
// so that the overhead exceeded does not persist.
- const bool limit_exceeded = gen_policy()->size_policy()->gc_overhead_limit_exceeded();
+ const bool limit_exceeded = size_policy()->gc_overhead_limit_exceeded();
const bool softrefs_clear = soft_ref_policy()->all_soft_refs_clear();
if (limit_exceeded && softrefs_clear) {
*gc_overhead_limit_was_exceeded = true;
- gen_policy()->size_policy()->set_gc_overhead_limit_exceeded(false);
+ size_policy()->set_gc_overhead_limit_exceeded(false);
if (op.result() != NULL) {
CollectedHeap::fill_with_object(op.result(), size);
}
--- a/src/hotspot/share/gc/shared/genCollectedHeap.hpp Thu Feb 22 18:36:07 2018 +0100
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.hpp Thu Feb 22 18:36:32 2018 +0100
@@ -25,12 +25,12 @@
#ifndef SHARE_VM_GC_SHARED_GENCOLLECTEDHEAP_HPP
#define SHARE_VM_GC_SHARED_GENCOLLECTEDHEAP_HPP
-#include "gc/shared/adaptiveSizePolicy.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/collectorPolicy.hpp"
#include "gc/shared/generation.hpp"
#include "gc/shared/softRefGenPolicy.hpp"
+class AdaptiveSizePolicy;
class StrongRootsScope;
class SubTasksDone;
class WorkGang;
@@ -73,6 +73,9 @@
SoftRefGenPolicy _soft_ref_gen_policy;
+ // The sizing of the heap is controlled by a sizing policy.
+ AdaptiveSizePolicy* _size_policy;
+
// 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,6 +158,10 @@
// Returns JNI_OK on success
virtual jint initialize();
+ void initialize_size_policy(size_t init_eden_size,
+ size_t init_promo_size,
+ size_t init_survivor_size);
+
// Does operations required after initialization has been done.
void post_initialize();
@@ -173,7 +180,7 @@
// Adaptive size policy
virtual AdaptiveSizePolicy* size_policy() {
- return gen_policy()->size_policy();
+ return _size_policy;
}
// Return the (conservative) maximum heap alignment