621 "CMS Thread should refer to this gen"); |
621 "CMS Thread should refer to this gen"); |
622 assert(CGC_lock != NULL, "Where's the CGC_lock?"); |
622 assert(CGC_lock != NULL, "Where's the CGC_lock?"); |
623 |
623 |
624 // Support for parallelizing young gen rescan |
624 // Support for parallelizing young gen rescan |
625 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
625 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
626 _young_gen = gch->prev_gen(_cmsGen); |
626 assert(gch->prev_gen(_cmsGen)->kind() == Generation::ParNew, "CMS can only be used with ParNew"); |
|
627 _young_gen = (ParNewGeneration*)gch->prev_gen(_cmsGen); |
627 if (gch->supports_inline_contig_alloc()) { |
628 if (gch->supports_inline_contig_alloc()) { |
628 _top_addr = gch->top_addr(); |
629 _top_addr = gch->top_addr(); |
629 _end_addr = gch->end_addr(); |
630 _end_addr = gch->end_addr(); |
630 assert(_young_gen != NULL, "no _young_gen"); |
631 assert(_young_gen != NULL, "no _young_gen"); |
631 _eden_chunk_index = 0; |
632 _eden_chunk_index = 0; |
1631 } |
1632 } |
1632 |
1633 |
1633 do_compaction_work(clear_all_soft_refs); |
1634 do_compaction_work(clear_all_soft_refs); |
1634 |
1635 |
1635 // Has the GC time limit been exceeded? |
1636 // Has the GC time limit been exceeded? |
1636 DefNewGeneration* young_gen = _young_gen->as_DefNewGeneration(); |
1637 size_t max_eden_size = _young_gen->max_capacity() - |
1637 size_t max_eden_size = young_gen->max_capacity() - |
1638 _young_gen->to()->capacity() - |
1638 young_gen->to()->capacity() - |
1639 _young_gen->from()->capacity(); |
1639 young_gen->from()->capacity(); |
|
1640 GCCause::Cause gc_cause = gch->gc_cause(); |
1640 GCCause::Cause gc_cause = gch->gc_cause(); |
1641 size_policy()->check_gc_overhead_limit(_young_gen->used(), |
1641 size_policy()->check_gc_overhead_limit(_young_gen->used(), |
1642 young_gen->eden()->used(), |
1642 _young_gen->eden()->used(), |
1643 _cmsGen->max_capacity(), |
1643 _cmsGen->max_capacity(), |
1644 max_eden_size, |
1644 max_eden_size, |
1645 full, |
1645 full, |
1646 gc_cause, |
1646 gc_cause, |
1647 gch->collector_policy()); |
1647 gch->collector_policy()); |
1758 // For a mark-sweep-compact, compute_new_size() will be called |
1758 // For a mark-sweep-compact, compute_new_size() will be called |
1759 // in the heap's do_collection() method. |
1759 // in the heap's do_collection() method. |
1760 } |
1760 } |
1761 |
1761 |
1762 void CMSCollector::print_eden_and_survivor_chunk_arrays() { |
1762 void CMSCollector::print_eden_and_survivor_chunk_arrays() { |
1763 DefNewGeneration* dng = _young_gen->as_DefNewGeneration(); |
1763 ContiguousSpace* eden_space = _young_gen->eden(); |
1764 ContiguousSpace* eden_space = dng->eden(); |
1764 ContiguousSpace* from_space = _young_gen->from(); |
1765 ContiguousSpace* from_space = dng->from(); |
1765 ContiguousSpace* to_space = _young_gen->to(); |
1766 ContiguousSpace* to_space = dng->to(); |
|
1767 // Eden |
1766 // Eden |
1768 if (_eden_chunk_array != NULL) { |
1767 if (_eden_chunk_array != NULL) { |
1769 gclog_or_tty->print_cr("eden " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")", |
1768 gclog_or_tty->print_cr("eden " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")", |
1770 eden_space->bottom(), eden_space->top(), |
1769 eden_space->bottom(), eden_space->top(), |
1771 eden_space->end(), eden_space->capacity()); |
1770 eden_space->end(), eden_space->capacity()); |
4084 rp->is_alive_non_header(), &keep_alive, &complete_trace, &yield_cl, |
4083 rp->is_alive_non_header(), &keep_alive, &complete_trace, &yield_cl, |
4085 gc_timer, _gc_tracer_cm->gc_id()); |
4084 gc_timer, _gc_tracer_cm->gc_id()); |
4086 } |
4085 } |
4087 |
4086 |
4088 if (clean_survivor) { // preclean the active survivor space(s) |
4087 if (clean_survivor) { // preclean the active survivor space(s) |
4089 DefNewGeneration* dng = _young_gen->as_DefNewGeneration(); |
|
4090 PushAndMarkClosure pam_cl(this, _span, ref_processor(), |
4088 PushAndMarkClosure pam_cl(this, _span, ref_processor(), |
4091 &_markBitMap, &_modUnionTable, |
4089 &_markBitMap, &_modUnionTable, |
4092 &_markStack, true /* precleaning phase */); |
4090 &_markStack, true /* precleaning phase */); |
4093 stopTimer(); |
4091 stopTimer(); |
4094 CMSTokenSyncWithLocks ts(true /* is cms thread */, |
4092 CMSTokenSyncWithLocks ts(true /* is cms thread */, |
4097 unsigned int before_count = |
4095 unsigned int before_count = |
4098 GenCollectedHeap::heap()->total_collections(); |
4096 GenCollectedHeap::heap()->total_collections(); |
4099 SurvivorSpacePrecleanClosure |
4097 SurvivorSpacePrecleanClosure |
4100 sss_cl(this, _span, &_markBitMap, &_markStack, |
4098 sss_cl(this, _span, &_markBitMap, &_markStack, |
4101 &pam_cl, before_count, CMSYield); |
4099 &pam_cl, before_count, CMSYield); |
4102 dng->from()->object_iterate_careful(&sss_cl); |
4100 _young_gen->from()->object_iterate_careful(&sss_cl); |
4103 dng->to()->object_iterate_careful(&sss_cl); |
4101 _young_gen->to()->object_iterate_careful(&sss_cl); |
4104 } |
4102 } |
4105 MarkRefsIntoAndScanClosure |
4103 MarkRefsIntoAndScanClosure |
4106 mrias_cl(_span, ref_processor(), &_markBitMap, &_modUnionTable, |
4104 mrias_cl(_span, ref_processor(), &_markBitMap, &_modUnionTable, |
4107 &_markStack, this, CMSYield, |
4105 &_markStack, this, CMSYield, |
4108 true /* precleaning phase */); |
4106 true /* precleaning phase */); |
4683 _cm_klass_closure.do_klass(k); |
4681 _cm_klass_closure.do_klass(k); |
4684 } |
4682 } |
4685 }; |
4683 }; |
4686 |
4684 |
4687 void CMSParMarkTask::work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl) { |
4685 void CMSParMarkTask::work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl) { |
4688 DefNewGeneration* dng = _collector->_young_gen->as_DefNewGeneration(); |
4686 ParNewGeneration* young_gen = _collector->_young_gen; |
4689 ContiguousSpace* eden_space = dng->eden(); |
4687 ContiguousSpace* eden_space = young_gen->eden(); |
4690 ContiguousSpace* from_space = dng->from(); |
4688 ContiguousSpace* from_space = young_gen->from(); |
4691 ContiguousSpace* to_space = dng->to(); |
4689 ContiguousSpace* to_space = young_gen->to(); |
4692 |
4690 |
4693 HeapWord** eca = _collector->_eden_chunk_array; |
4691 HeapWord** eca = _collector->_eden_chunk_array; |
4694 size_t ect = _collector->_eden_chunk_index; |
4692 size_t ect = _collector->_eden_chunk_index; |
4695 HeapWord** sca = _collector->_survivor_chunk_array; |
4693 HeapWord** sca = _collector->_survivor_chunk_array; |
4696 size_t sct = _collector->_survivor_chunk_index; |
4694 size_t sct = _collector->_survivor_chunk_index; |
5155 // See ParRescanTask where this is currently used. |
5153 // See ParRescanTask where this is currently used. |
5156 void |
5154 void |
5157 CMSCollector:: |
5155 CMSCollector:: |
5158 initialize_sequential_subtasks_for_young_gen_rescan(int n_threads) { |
5156 initialize_sequential_subtasks_for_young_gen_rescan(int n_threads) { |
5159 assert(n_threads > 0, "Unexpected n_threads argument"); |
5157 assert(n_threads > 0, "Unexpected n_threads argument"); |
5160 DefNewGeneration* dng = _young_gen->as_DefNewGeneration(); |
|
5161 |
5158 |
5162 // Eden space |
5159 // Eden space |
5163 if (!dng->eden()->is_empty()) { |
5160 if (!_young_gen->eden()->is_empty()) { |
5164 SequentialSubTasksDone* pst = dng->eden()->par_seq_tasks(); |
5161 SequentialSubTasksDone* pst = _young_gen->eden()->par_seq_tasks(); |
5165 assert(!pst->valid(), "Clobbering existing data?"); |
5162 assert(!pst->valid(), "Clobbering existing data?"); |
5166 // Each valid entry in [0, _eden_chunk_index) represents a task. |
5163 // Each valid entry in [0, _eden_chunk_index) represents a task. |
5167 size_t n_tasks = _eden_chunk_index + 1; |
5164 size_t n_tasks = _eden_chunk_index + 1; |
5168 assert(n_tasks == 1 || _eden_chunk_array != NULL, "Error"); |
5165 assert(n_tasks == 1 || _eden_chunk_array != NULL, "Error"); |
5169 // Sets the condition for completion of the subtask (how many threads |
5166 // Sets the condition for completion of the subtask (how many threads |
5172 pst->set_n_tasks((int)n_tasks); |
5169 pst->set_n_tasks((int)n_tasks); |
5173 } |
5170 } |
5174 |
5171 |
5175 // Merge the survivor plab arrays into _survivor_chunk_array |
5172 // Merge the survivor plab arrays into _survivor_chunk_array |
5176 if (_survivor_plab_array != NULL) { |
5173 if (_survivor_plab_array != NULL) { |
5177 merge_survivor_plab_arrays(dng->from(), n_threads); |
5174 merge_survivor_plab_arrays(_young_gen->from(), n_threads); |
5178 } else { |
5175 } else { |
5179 assert(_survivor_chunk_index == 0, "Error"); |
5176 assert(_survivor_chunk_index == 0, "Error"); |
5180 } |
5177 } |
5181 |
5178 |
5182 // To space |
5179 // To space |
5183 { |
5180 { |
5184 SequentialSubTasksDone* pst = dng->to()->par_seq_tasks(); |
5181 SequentialSubTasksDone* pst = _young_gen->to()->par_seq_tasks(); |
5185 assert(!pst->valid(), "Clobbering existing data?"); |
5182 assert(!pst->valid(), "Clobbering existing data?"); |
5186 // Sets the condition for completion of the subtask (how many threads |
5183 // Sets the condition for completion of the subtask (how many threads |
5187 // need to finish in order to be done). |
5184 // need to finish in order to be done). |
5188 pst->set_n_threads(n_threads); |
5185 pst->set_n_threads(n_threads); |
5189 pst->set_n_tasks(1); |
5186 pst->set_n_tasks(1); |
5190 assert(pst->valid(), "Error"); |
5187 assert(pst->valid(), "Error"); |
5191 } |
5188 } |
5192 |
5189 |
5193 // From space |
5190 // From space |
5194 { |
5191 { |
5195 SequentialSubTasksDone* pst = dng->from()->par_seq_tasks(); |
5192 SequentialSubTasksDone* pst = _young_gen->from()->par_seq_tasks(); |
5196 assert(!pst->valid(), "Clobbering existing data?"); |
5193 assert(!pst->valid(), "Clobbering existing data?"); |
5197 size_t n_tasks = _survivor_chunk_index + 1; |
5194 size_t n_tasks = _survivor_chunk_index + 1; |
5198 assert(n_tasks == 1 || _survivor_chunk_array != NULL, "Error"); |
5195 assert(n_tasks == 1 || _survivor_chunk_array != NULL, "Error"); |
5199 // Sets the condition for completion of the subtask (how many threads |
5196 // Sets the condition for completion of the subtask (how many threads |
5200 // need to finish in order to be done). |
5197 // need to finish in order to be done). |