# HG changeset patch # User brutisso # Date 1417510276 -3600 # Node ID 14c6e2f23fa0ce6436a6993ff82ab05504de1ce9 # Parent fe89161ff160c3f5c96d3168f2cf4c639f3883bb 8065992: Change CMSCollector::_young_gen to be a ParNewGeneration* Reviewed-by: mgerdin, kbarrett diff -r fe89161ff160 -r 14c6e2f23fa0 hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Mon Dec 01 12:11:11 2014 +0100 +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Tue Dec 02 09:51:16 2014 +0100 @@ -623,7 +623,8 @@ // 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 @@ 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::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 @@ } 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 @@ 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 @@ }; 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 @@ 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 @@ // 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 @@ // 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"); diff -r fe89161ff160 -r 14c6e2f23fa0 hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Mon Dec 01 12:11:11 2014 +0100 +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Tue Dec 02 09:51:16 2014 +0100 @@ -721,7 +721,8 @@ 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; diff -r fe89161ff160 -r 14c6e2f23fa0 hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp Mon Dec 01 12:11:11 2014 +0100 +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp Tue Dec 02 09:51:16 2014 +0100 @@ -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 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 { diff -r fe89161ff160 -r 14c6e2f23fa0 hotspot/src/share/vm/memory/genCollectedHeap.cpp --- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp Mon Dec 01 12:11:11 2014 +0100 +++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp Tue Dec 02 09:51:16 2014 +0100 @@ -182,7 +182,10 @@ 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 || diff -r fe89161ff160 -r 14c6e2f23fa0 hotspot/src/share/vm/memory/generation.cpp --- a/hotspot/src/share/vm/memory/generation.cpp Mon Dec 01 12:11:11 2014 +0100 +++ b/hotspot/src/share/vm/memory/generation.cpp Tue Dec 02 09:51:16 2014 +0100 @@ -152,13 +152,6 @@ 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; diff -r fe89161ff160 -r 14c6e2f23fa0 hotspot/src/share/vm/memory/generation.hpp --- a/hotspot/src/share/vm/memory/generation.hpp Mon Dec 01 12:11:11 2014 +0100 +++ b/hotspot/src/share/vm/memory/generation.hpp Tue Dec 02 09:51:16 2014 +0100 @@ -229,10 +229,6 @@ 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;