diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp index 378c5e66436a9a542a563fa01944a1c9c6aadbb9..aaa5a1bb770f29dd0517a7d17f386da828488497 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp @@ -27,7 +27,7 @@ #include "memory/collectorPolicy.hpp" -class ConcurrentMarkSweepPolicy : public TwoGenerationCollectorPolicy { +class ConcurrentMarkSweepPolicy : public GenCollectorPolicy { protected: void initialize_alignments(); void initialize_generations(); diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index 40ff7b30e4005bc552bec6954657d4ee17e72ea9..011c47377b7d315fcb63d33610aefb3aaba709e3 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -1560,7 +1560,7 @@ bool CMSCollector::shouldConcurrentCollect() { // this is not likely to be productive in practice because it's probably too // late anyway. GenCollectedHeap* gch = GenCollectedHeap::heap(); - assert(gch->collector_policy()->is_two_generation_policy(), + assert(gch->collector_policy()->is_generation_policy(), "You may want to check the correctness of the following"); if (gch->incremental_collection_will_fail(true /* consult_young */)) { if (Verbose && PrintGCDetails) { @@ -1964,7 +1964,7 @@ void CMSCollector::decide_foreground_collection_type( // has exceeded the threshold set by CMSFullGCsBeforeCompaction, // or if an incremental collection has failed GenCollectedHeap* gch = GenCollectedHeap::heap(); - assert(gch->collector_policy()->is_two_generation_policy(), + assert(gch->collector_policy()->is_generation_policy(), "You may want to check the correctness of the following"); // Inform cms gen if this was due to partial collection failing. // The CMS gen may use this fact to determine its expansion policy. diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp index e417cd4959962d1df3a2ec2e1d0da820305fd7ea..fd8b1332c7a2a8cb1c367c4c3231b00888d0cc02 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp @@ -45,7 +45,7 @@ void GenerationSizer::initialize_alignments() { void GenerationSizer::initialize_flags() { // Do basic sizing work - TwoGenerationCollectorPolicy::initialize_flags(); + GenCollectorPolicy::initialize_flags(); assert(UseSerialGC || !FLAG_IS_DEFAULT(ParallelGCThreads) || @@ -79,7 +79,7 @@ void GenerationSizer::initialize_size_info() { // Redo everything from the start initialize_flags(); } - TwoGenerationCollectorPolicy::initialize_size_info(); + GenCollectorPolicy::initialize_size_info(); trace_gen_sizes("ps heap rnd"); } diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.hpp index eb8c78a8c81e9b61f652760ce9a374a121f3228b..70309a7fd59ef21d62c6e1471889d967cf4dc44f 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.hpp @@ -28,9 +28,9 @@ #include "memory/collectorPolicy.hpp" // There is a nice batch of tested generation sizing code in -// TwoGenerationCollectorPolicy. Lets reuse it! +// GenCollectorPolicy. Lets reuse it! -class GenerationSizer : public TwoGenerationCollectorPolicy { +class GenerationSizer : public GenCollectorPolicy { private: void trace_gen_sizes(const char* const str); diff --git a/hotspot/src/share/vm/memory/collectorPolicy.cpp b/hotspot/src/share/vm/memory/collectorPolicy.cpp index 772a6df4aff371a2627a07733854a9bbdd5913fc..69d39e4d431374224b097dff0862b1d43bd85256 100644 --- a/hotspot/src/share/vm/memory/collectorPolicy.cpp +++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp @@ -200,6 +200,9 @@ GenCollectorPolicy::GenCollectorPolicy() : _initial_gen0_size(0), _max_gen0_size(0), _gen_alignment(0), + _min_gen1_size(0), + _initial_gen1_size(0), + _max_gen1_size(0), _generations(NULL) {} @@ -238,10 +241,6 @@ void GenCollectorPolicy::assert_flags() { assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young gen and heap sizes"); assert(NewSize % _gen_alignment == 0, "NewSize alignment"); assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize % _gen_alignment == 0, "MaxNewSize alignment"); -} - -void TwoGenerationCollectorPolicy::assert_flags() { - GenCollectorPolicy::assert_flags(); assert(OldSize + NewSize <= MaxHeapSize, "Ergonomics decided on incompatible generation and heap sizes"); assert(OldSize % _gen_alignment == 0, "OldSize alignment"); } @@ -252,6 +251,7 @@ void GenCollectorPolicy::assert_size_info() { assert(MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young and heap sizes"); assert(NewSize == _initial_gen0_size, "Discrepancy between NewSize flag and local storage"); assert(MaxNewSize == _max_gen0_size, "Discrepancy between MaxNewSize flag and local storage"); + assert(OldSize == _initial_gen1_size, "Discrepancy between OldSize flag and local storage"); assert(_min_gen0_size <= _initial_gen0_size, "Ergonomics decided on incompatible minimum and initial young gen sizes"); assert(_initial_gen0_size <= _max_gen0_size, "Ergonomics decided on incompatible initial and maximum young gen sizes"); assert(_min_gen0_size % _gen_alignment == 0, "_min_gen0_size alignment"); @@ -263,11 +263,6 @@ void GenCollectorPolicy::assert_size_info() { "Ergonomics made initial young generation larger than initial heap"); assert(_max_gen0_size <= bound_minus_alignment(_max_gen0_size, _max_heap_byte_size), "Ergonomics made maximum young generation lager than maximum heap"); -} - -void TwoGenerationCollectorPolicy::assert_size_info() { - GenCollectorPolicy::assert_size_info(); - assert(OldSize == _initial_gen1_size, "Discrepancy between OldSize flag and local storage"); assert(_min_gen1_size <= _initial_gen1_size, "Ergonomics decided on incompatible minimum and initial old gen sizes"); assert(_initial_gen1_size <= _max_gen1_size, "Ergonomics decided on incompatible initial and maximum old gen sizes"); assert(_max_gen1_size % _gen_alignment == 0, "_max_gen1_size alignment"); @@ -369,12 +364,6 @@ void GenCollectorPolicy::initialize_flags() { vm_exit_during_initialization("Invalid young gen ratio specified"); } - DEBUG_ONLY(GenCollectorPolicy::assert_flags();) -} - -void TwoGenerationCollectorPolicy::initialize_flags() { - GenCollectorPolicy::initialize_flags(); - if (!is_size_aligned(OldSize, _gen_alignment)) { // Setting OldSize directly to preserve information about the possible // setting of OldSize on the command line. @@ -433,7 +422,7 @@ void TwoGenerationCollectorPolicy::initialize_flags() { always_do_update_barrier = UseConcMarkSweepGC; - DEBUG_ONLY(TwoGenerationCollectorPolicy::assert_flags();) + DEBUG_ONLY(GenCollectorPolicy::assert_flags();) } // Values set on the command line win over any ergonomically @@ -445,6 +434,13 @@ void TwoGenerationCollectorPolicy::initialize_flags() { // themselves and with overall heap sizings. // In the absence of explicitly set command line flags, policies // such as the use of NewRatio are used to size the generation. + +// Minimum sizes of the generations may be different than +// the initial sizes. An inconsistency is permitted here +// in the total size that can be specified explicitly by +// command line specification of OldSize and NewSize and +// also a command line specification of -Xms. Issue a warning +// but allow the values to pass. void GenCollectorPolicy::initialize_size_info() { CollectorPolicy::initialize_size_info(); @@ -520,19 +516,6 @@ void GenCollectorPolicy::initialize_size_info() { _min_gen0_size, _initial_gen0_size, _max_gen0_size); } - DEBUG_ONLY(GenCollectorPolicy::assert_size_info();) -} - -// Minimum sizes of the generations may be different than -// the initial sizes. An inconsistency is permitted here -// in the total size that can be specified explicitly by -// command line specification of OldSize and NewSize and -// also a command line specification of -Xms. Issue a warning -// but allow the values to pass. - -void TwoGenerationCollectorPolicy::initialize_size_info() { - GenCollectorPolicy::initialize_size_info(); - // At this point the minimum, initial and maximum sizes // of the overall heap and of gen0 have been determined. // The maximum gen1 size can be determined from the maximum gen0 @@ -625,7 +608,7 @@ void TwoGenerationCollectorPolicy::initialize_size_info() { _min_gen1_size, _initial_gen1_size, _max_gen1_size); } - DEBUG_ONLY(TwoGenerationCollectorPolicy::assert_size_info();) + DEBUG_ONLY(GenCollectorPolicy::assert_size_info();) } HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size, diff --git a/hotspot/src/share/vm/memory/collectorPolicy.hpp b/hotspot/src/share/vm/memory/collectorPolicy.hpp index 36f74b5a01645bd14fd43e7d3e5a624660292c4d..1fc62b06c43fe18d9ea635bdfd21389b2bb97eb1 100644 --- a/hotspot/src/share/vm/memory/collectorPolicy.hpp +++ b/hotspot/src/share/vm/memory/collectorPolicy.hpp @@ -47,7 +47,6 @@ // Forward declarations. class GenCollectorPolicy; -class TwoGenerationCollectorPolicy; class AdaptiveSizePolicy; #if INCLUDE_ALL_GCS class ConcurrentMarkSweepPolicy; @@ -114,7 +113,7 @@ class CollectorPolicy : public CHeapObj { enum Name { CollectorPolicyKind, - TwoGenerationCollectorPolicyKind, + GenCollectorPolicyKind, ConcurrentMarkSweepPolicyKind, ASConcurrentMarkSweepPolicyKind, G1CollectorPolicyKind @@ -135,7 +134,6 @@ class CollectorPolicy : public CHeapObj { // Identification methods. virtual GenCollectorPolicy* as_generation_policy() { return NULL; } - virtual TwoGenerationCollectorPolicy* as_two_generation_policy() { return NULL; } virtual MarkSweepPolicy* as_mark_sweep_policy() { return NULL; } #if INCLUDE_ALL_GCS virtual ConcurrentMarkSweepPolicy* as_concurrent_mark_sweep_policy() { return NULL; } @@ -143,7 +141,6 @@ class CollectorPolicy : public CHeapObj { #endif // INCLUDE_ALL_GCS // Note that these are not virtual. bool is_generation_policy() { return as_generation_policy() != NULL; } - bool is_two_generation_policy() { return as_two_generation_policy() != NULL; } bool is_mark_sweep_policy() { return as_mark_sweep_policy() != NULL; } #if INCLUDE_ALL_GCS bool is_concurrent_mark_sweep_policy() { return as_concurrent_mark_sweep_policy() != NULL; } @@ -225,6 +222,9 @@ friend class TestGenCollectorPolicy; size_t _min_gen0_size; size_t _initial_gen0_size; size_t _max_gen0_size; + size_t _min_gen1_size; + size_t _initial_gen1_size; + size_t _max_gen1_size; // _gen_alignment and _space_alignment will have the same value most of the // time. When using large pages they can differ. @@ -264,8 +264,11 @@ friend class TestGenCollectorPolicy; size_t initial_gen0_size() { return _initial_gen0_size; } size_t max_gen0_size() { return _max_gen0_size; } size_t gen_alignment() { return _gen_alignment; } + size_t min_gen1_size() { return _min_gen1_size; } + size_t initial_gen1_size() { return _initial_gen1_size; } + size_t max_gen1_size() { return _max_gen1_size; } - virtual int number_of_generations() = 0; + int number_of_generations() { return 2; } virtual GenerationSpec **generations() { assert(_generations != NULL, "Sanity check"); @@ -297,47 +300,15 @@ friend class TestGenCollectorPolicy; virtual void post_heap_initialize() { assert(_max_gen0_size == MaxNewSize, "Should be taken care of by initialize_size_info"); } -}; - -// All of hotspot's current collectors are subtypes of this -// class. Currently, these collectors all use the same gen[0], -// but have different gen[1] types. If we add another subtype -// of CollectorPolicy, this class should be broken out into -// its own file. - -class TwoGenerationCollectorPolicy : public GenCollectorPolicy { - protected: - size_t _min_gen1_size; - size_t _initial_gen1_size; - size_t _max_gen1_size; - - void initialize_flags(); - void initialize_size_info(); - - DEBUG_ONLY(void assert_flags();) - DEBUG_ONLY(void assert_size_info();) - - public: - TwoGenerationCollectorPolicy() : GenCollectorPolicy(), _min_gen1_size(0), - _initial_gen1_size(0), _max_gen1_size(0) {} - - // Accessors - size_t min_gen1_size() { return _min_gen1_size; } - size_t initial_gen1_size() { return _initial_gen1_size; } - size_t max_gen1_size() { return _max_gen1_size; } - - // Inherited methods - TwoGenerationCollectorPolicy* as_two_generation_policy() { return this; } - int number_of_generations() { return 2; } BarrierSet::Name barrier_set_name() { return BarrierSet::CardTableModRef; } virtual CollectorPolicy::Name kind() { - return CollectorPolicy::TwoGenerationCollectorPolicyKind; + return CollectorPolicy::GenCollectorPolicyKind; } }; -class MarkSweepPolicy : public TwoGenerationCollectorPolicy { +class MarkSweepPolicy : public GenCollectorPolicy { protected: void initialize_alignments(); void initialize_generations(); diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.cpp b/hotspot/src/share/vm/memory/genCollectedHeap.cpp index 168ea3714069a9d496b161bc2519cf97b86abd4e..f3b2a8ec88583d21f74eb5b1738fdc57907d36ea 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp @@ -197,9 +197,8 @@ char* GenCollectedHeap::allocate(size_t alignment, void GenCollectedHeap::post_initialize() { SharedHeap::post_initialize(); - TwoGenerationCollectorPolicy *policy = - (TwoGenerationCollectorPolicy *)collector_policy(); - guarantee(policy->is_two_generation_policy(), "Illegal policy type"); + GenCollectorPolicy *policy = (GenCollectorPolicy *)collector_policy(); + guarantee(policy->is_generation_policy(), "Illegal policy type"); DefNewGeneration* def_new_gen = (DefNewGeneration*) get_gen(0); assert(def_new_gen->kind() == Generation::DefNew || def_new_gen->kind() == Generation::ParNew || diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.hpp b/hotspot/src/share/vm/memory/genCollectedHeap.hpp index 4a62aa4b4117e6e99cedfdae0af60e0dbd229ce5..dcd389cc90d59c0da5a31f66b36387d33e46c8a7 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp @@ -453,7 +453,7 @@ public: // Assumes a 2-generation system; the first disjunct remembers if an // incremental collection failed, even when we thought (second disjunct) // that it would not. - assert(heap()->collector_policy()->is_two_generation_policy(), + assert(heap()->collector_policy()->is_generation_policy(), "the following definition may not be suitable for an n(>2)-generation system"); return incremental_collection_failed() || (consult_young && !get_gen(0)->collection_attempt_is_safe()); diff --git a/hotspot/src/share/vm/services/memoryService.cpp b/hotspot/src/share/vm/services/memoryService.cpp index 8115a3e2409e957207ad7543621406e095917d2c..ea9cb59873d937e03add80822c2df2414348d73c 100644 --- a/hotspot/src/share/vm/services/memoryService.cpp +++ b/hotspot/src/share/vm/services/memoryService.cpp @@ -123,12 +123,12 @@ void MemoryService::set_universe_heap(CollectedHeap* heap) { void MemoryService::add_gen_collected_heap_info(GenCollectedHeap* heap) { CollectorPolicy* policy = heap->collector_policy(); - assert(policy->is_two_generation_policy(), "Only support two generations"); + assert(policy->is_generation_policy(), "Only support two generations"); guarantee(heap->n_gens() == 2, "Only support two-generation heap"); - TwoGenerationCollectorPolicy* two_gen_policy = policy->as_two_generation_policy(); - if (two_gen_policy != NULL) { - GenerationSpec** specs = two_gen_policy->generations(); + GenCollectorPolicy* gen_policy = policy->as_generation_policy(); + if (gen_policy != NULL) { + GenerationSpec** specs = gen_policy->generations(); Generation::Name kind = specs[0]->name(); switch (kind) { case Generation::DefNew: