8065992: Change CMSCollector::_young_gen to be a ParNewGeneration*

Reviewed-by: mgerdin, kbarrett
This commit is contained in:
Bengt Rutisson 2014-12-02 09:51:16 +01:00
parent 4fafece403
commit ca3e287e96
6 changed files with 29 additions and 39 deletions

View File

@ -623,7 +623,8 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen,
// Support for parallelizing young gen rescan
GenCollectedHeap* gch = GenCollectedHeap::heap();
_young_gen = gch->prev_gen(_cmsGen);
assert(gch->prev_gen(_cmsGen)->kind() == Generation::ParNew, "CMS can only be used with ParNew");
_young_gen = (ParNewGeneration*)gch->prev_gen(_cmsGen);
if (gch->supports_inline_contig_alloc()) {
_top_addr = gch->top_addr();
_end_addr = gch->end_addr();
@ -1633,13 +1634,12 @@ void CMSCollector::acquire_control_and_collect(bool full,
do_compaction_work(clear_all_soft_refs);
// Has the GC time limit been exceeded?
DefNewGeneration* young_gen = _young_gen->as_DefNewGeneration();
size_t max_eden_size = young_gen->max_capacity() -
young_gen->to()->capacity() -
young_gen->from()->capacity();
size_t max_eden_size = _young_gen->max_capacity() -
_young_gen->to()->capacity() -
_young_gen->from()->capacity();
GCCause::Cause gc_cause = gch->gc_cause();
size_policy()->check_gc_overhead_limit(_young_gen->used(),
young_gen->eden()->used(),
_young_gen->eden()->used(),
_cmsGen->max_capacity(),
max_eden_size,
full,
@ -1760,10 +1760,9 @@ void CMSCollector::do_compaction_work(bool clear_all_soft_refs) {
}
void CMSCollector::print_eden_and_survivor_chunk_arrays() {
DefNewGeneration* dng = _young_gen->as_DefNewGeneration();
ContiguousSpace* eden_space = dng->eden();
ContiguousSpace* from_space = dng->from();
ContiguousSpace* to_space = dng->to();
ContiguousSpace* eden_space = _young_gen->eden();
ContiguousSpace* from_space = _young_gen->from();
ContiguousSpace* to_space = _young_gen->to();
// Eden
if (_eden_chunk_array != NULL) {
gclog_or_tty->print_cr("eden " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
@ -4086,7 +4085,6 @@ size_t CMSCollector::preclean_work(bool clean_refs, bool clean_survivor) {
}
if (clean_survivor) { // preclean the active survivor space(s)
DefNewGeneration* dng = _young_gen->as_DefNewGeneration();
PushAndMarkClosure pam_cl(this, _span, ref_processor(),
&_markBitMap, &_modUnionTable,
&_markStack, true /* precleaning phase */);
@ -4099,8 +4097,8 @@ size_t CMSCollector::preclean_work(bool clean_refs, bool clean_survivor) {
SurvivorSpacePrecleanClosure
sss_cl(this, _span, &_markBitMap, &_markStack,
&pam_cl, before_count, CMSYield);
dng->from()->object_iterate_careful(&sss_cl);
dng->to()->object_iterate_careful(&sss_cl);
_young_gen->from()->object_iterate_careful(&sss_cl);
_young_gen->to()->object_iterate_careful(&sss_cl);
}
MarkRefsIntoAndScanClosure
mrias_cl(_span, ref_processor(), &_markBitMap, &_modUnionTable,
@ -4685,10 +4683,10 @@ class RemarkKlassClosure : public KlassClosure {
};
void CMSParMarkTask::work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl) {
DefNewGeneration* dng = _collector->_young_gen->as_DefNewGeneration();
ContiguousSpace* eden_space = dng->eden();
ContiguousSpace* from_space = dng->from();
ContiguousSpace* to_space = dng->to();
ParNewGeneration* young_gen = _collector->_young_gen;
ContiguousSpace* eden_space = young_gen->eden();
ContiguousSpace* from_space = young_gen->from();
ContiguousSpace* to_space = young_gen->to();
HeapWord** eca = _collector->_eden_chunk_array;
size_t ect = _collector->_eden_chunk_index;
@ -5157,11 +5155,10 @@ void
CMSCollector::
initialize_sequential_subtasks_for_young_gen_rescan(int n_threads) {
assert(n_threads > 0, "Unexpected n_threads argument");
DefNewGeneration* dng = _young_gen->as_DefNewGeneration();
// Eden space
if (!dng->eden()->is_empty()) {
SequentialSubTasksDone* pst = dng->eden()->par_seq_tasks();
if (!_young_gen->eden()->is_empty()) {
SequentialSubTasksDone* pst = _young_gen->eden()->par_seq_tasks();
assert(!pst->valid(), "Clobbering existing data?");
// Each valid entry in [0, _eden_chunk_index) represents a task.
size_t n_tasks = _eden_chunk_index + 1;
@ -5174,14 +5171,14 @@ initialize_sequential_subtasks_for_young_gen_rescan(int n_threads) {
// Merge the survivor plab arrays into _survivor_chunk_array
if (_survivor_plab_array != NULL) {
merge_survivor_plab_arrays(dng->from(), n_threads);
merge_survivor_plab_arrays(_young_gen->from(), n_threads);
} else {
assert(_survivor_chunk_index == 0, "Error");
}
// To space
{
SequentialSubTasksDone* pst = dng->to()->par_seq_tasks();
SequentialSubTasksDone* pst = _young_gen->to()->par_seq_tasks();
assert(!pst->valid(), "Clobbering existing data?");
// Sets the condition for completion of the subtask (how many threads
// need to finish in order to be done).
@ -5192,7 +5189,7 @@ initialize_sequential_subtasks_for_young_gen_rescan(int n_threads) {
// From space
{
SequentialSubTasksDone* pst = dng->from()->par_seq_tasks();
SequentialSubTasksDone* pst = _young_gen->from()->par_seq_tasks();
assert(!pst->valid(), "Clobbering existing data?");
size_t n_tasks = _survivor_chunk_index + 1;
assert(n_tasks == 1 || _survivor_chunk_array != NULL, "Error");

View File

@ -721,7 +721,8 @@ class CMSCollector: public CHeapObj<mtGC> {
private:
// Support for parallelizing young gen rescan in CMS remark phase
Generation* _young_gen; // the younger gen
ParNewGeneration* _young_gen; // the younger gen
HeapWord** _top_addr; // ... Top of Eden
HeapWord** _end_addr; // ... End of Eden
Mutex* _eden_chunk_lock;

View File

@ -29,8 +29,8 @@
#include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
#include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
#include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp"
#include "gc_implementation/parNew/parNewGeneration.hpp"
#include "gc_implementation/shared/gcUtil.hpp"
#include "memory/defNewGeneration.hpp"
inline void CMSBitMap::clear_all() {
assert_locked();
@ -257,11 +257,11 @@ inline bool CMSCollector::should_abort_preclean() const {
}
inline size_t CMSCollector::get_eden_used() const {
return _young_gen->as_DefNewGeneration()->eden()->used();
return _young_gen->eden()->used();
}
inline size_t CMSCollector::get_eden_capacity() const {
return _young_gen->as_DefNewGeneration()->eden()->capacity();
return _young_gen->eden()->capacity();
}
inline bool CMSStats::valid() const {

View File

@ -182,7 +182,10 @@ void GenCollectedHeap::post_initialize() {
SharedHeap::post_initialize();
GenCollectorPolicy *policy = (GenCollectorPolicy *)collector_policy();
guarantee(policy->is_generation_policy(), "Illegal policy type");
DefNewGeneration* def_new_gen = get_gen(0)->as_DefNewGeneration();
assert((get_gen(0)->kind() == Generation::DefNew) ||
(get_gen(0)->kind() == Generation::ParNew),
"Wrong youngest generation type");
DefNewGeneration* def_new_gen = (DefNewGeneration*)get_gen(0);
Generation* old_gen = get_gen(1);
assert(old_gen->kind() == Generation::ConcurrentMarkSweep ||

View File

@ -152,13 +152,6 @@ bool Generation::is_in(const void* p) const {
return blk.sp != NULL;
}
DefNewGeneration* Generation::as_DefNewGeneration() {
assert((kind() == Generation::DefNew) ||
(kind() == Generation::ParNew),
"Wrong youngest generation type");
return (DefNewGeneration*) this;
}
Generation* Generation::next_gen() const {
GenCollectedHeap* gch = GenCollectedHeap::heap();
int next = level() + 1;

View File

@ -229,10 +229,6 @@ class Generation: public CHeapObj<mtGC> {
return _reserved.contains(p);
}
// Check that the generation kind is DefNewGeneration or a sub
// class of DefNewGeneration and return a DefNewGeneration*
DefNewGeneration* as_DefNewGeneration();
// If some space in the generation contains the given "addr", return a
// pointer to that space, else return "NULL".
virtual Space* space_containing(const void* addr) const;