865 } |
865 } |
866 |
866 |
867 size_t |
867 size_t |
868 ConcurrentMarkSweepGeneration::unsafe_max_alloc_nogc() const { |
868 ConcurrentMarkSweepGeneration::unsafe_max_alloc_nogc() const { |
869 return _cmsSpace->max_alloc_in_words() * HeapWordSize; |
869 return _cmsSpace->max_alloc_in_words() * HeapWordSize; |
|
870 } |
|
871 |
|
872 size_t ConcurrentMarkSweepGeneration::used_stable() const { |
|
873 return cmsSpace()->used_stable(); |
870 } |
874 } |
871 |
875 |
872 size_t ConcurrentMarkSweepGeneration::max_available() const { |
876 size_t ConcurrentMarkSweepGeneration::max_available() const { |
873 return free() + _virtual_space.uncommitted_size(); |
877 return free() + _virtual_space.uncommitted_size(); |
874 } |
878 } |
1953 void CMSCollector::compute_new_size() { |
1957 void CMSCollector::compute_new_size() { |
1954 assert_locked_or_safepoint(Heap_lock); |
1958 assert_locked_or_safepoint(Heap_lock); |
1955 FreelistLocker z(this); |
1959 FreelistLocker z(this); |
1956 MetaspaceGC::compute_new_size(); |
1960 MetaspaceGC::compute_new_size(); |
1957 _cmsGen->compute_new_size_free_list(); |
1961 _cmsGen->compute_new_size_free_list(); |
|
1962 // recalculate CMS used space after CMS collection |
|
1963 _cmsGen->cmsSpace()->recalculate_used_stable(); |
1958 } |
1964 } |
1959 |
1965 |
1960 // A work method used by foreground collection to determine |
1966 // A work method used by foreground collection to determine |
1961 // what type of collection (compacting or not, continuing or fresh) |
1967 // what type of collection (compacting or not, continuing or fresh) |
1962 // it should do. |
1968 // it should do. |
2766 |
2772 |
2767 void ConcurrentMarkSweepGeneration::gc_prologue(bool full) { |
2773 void ConcurrentMarkSweepGeneration::gc_prologue(bool full) { |
2768 |
2774 |
2769 _capacity_at_prologue = capacity(); |
2775 _capacity_at_prologue = capacity(); |
2770 _used_at_prologue = used(); |
2776 _used_at_prologue = used(); |
|
2777 _cmsSpace->recalculate_used_stable(); |
2771 |
2778 |
2772 // Delegate to CMScollector which knows how to coordinate between |
2779 // Delegate to CMScollector which knows how to coordinate between |
2773 // this and any other CMS generations that it is responsible for |
2780 // this and any other CMS generations that it is responsible for |
2774 // collecting. |
2781 // collecting. |
2775 collector()->gc_prologue(full); |
2782 collector()->gc_prologue(full); |
2835 } |
2842 } |
2836 // reset _eden_chunk_array so sampling starts afresh |
2843 // reset _eden_chunk_array so sampling starts afresh |
2837 _eden_chunk_index = 0; |
2844 _eden_chunk_index = 0; |
2838 |
2845 |
2839 size_t cms_used = _cmsGen->cmsSpace()->used(); |
2846 size_t cms_used = _cmsGen->cmsSpace()->used(); |
|
2847 _cmsGen->cmsSpace()->recalculate_used_stable(); |
2840 |
2848 |
2841 // update performance counters - this uses a special version of |
2849 // update performance counters - this uses a special version of |
2842 // update_counters() that allows the utilization to be passed as a |
2850 // update_counters() that allows the utilization to be passed as a |
2843 // parameter, avoiding multiple calls to used(). |
2851 // parameter, avoiding multiple calls to used(). |
2844 // |
2852 // |
3670 // now enable ("weak") refs discovery |
3678 // now enable ("weak") refs discovery |
3671 rp->enable_discovery(true /*verify_disabled*/, false /*verify_no_refs*/); |
3679 rp->enable_discovery(true /*verify_disabled*/, false /*verify_no_refs*/); |
3672 _collectorState = Marking; |
3680 _collectorState = Marking; |
3673 } |
3681 } |
3674 SpecializationStats::print(); |
3682 SpecializationStats::print(); |
|
3683 _cmsGen->cmsSpace()->recalculate_used_stable(); |
3675 } |
3684 } |
3676 |
3685 |
3677 void CMSCollector::checkpointRootsInitialWork(bool asynch) { |
3686 void CMSCollector::checkpointRootsInitialWork(bool asynch) { |
3678 assert(SafepointSynchronize::is_at_safepoint(), "world should be stopped"); |
3687 assert(SafepointSynchronize::is_at_safepoint(), "world should be stopped"); |
3679 assert(_collectorState == InitialMarking, "just checking"); |
3688 assert(_collectorState == InitialMarking, "just checking"); |
5064 FreelistLocker x(this); |
5073 FreelistLocker x(this); |
5065 MutexLockerEx y(bitMapLock(), |
5074 MutexLockerEx y(bitMapLock(), |
5066 Mutex::_no_safepoint_check_flag); |
5075 Mutex::_no_safepoint_check_flag); |
5067 assert(!init_mark_was_synchronous, "but that's impossible!"); |
5076 assert(!init_mark_was_synchronous, "but that's impossible!"); |
5068 checkpointRootsFinalWork(asynch, clear_all_soft_refs, false); |
5077 checkpointRootsFinalWork(asynch, clear_all_soft_refs, false); |
|
5078 _cmsGen->cmsSpace()->recalculate_used_stable(); |
5069 } else { |
5079 } else { |
5070 // already have all the locks |
5080 // already have all the locks |
5071 checkpointRootsFinalWork(asynch, clear_all_soft_refs, |
5081 checkpointRootsFinalWork(asynch, clear_all_soft_refs, |
5072 init_mark_was_synchronous); |
5082 init_mark_was_synchronous); |
|
5083 _cmsGen->cmsSpace()->recalculate_used_stable(); |
5073 } |
5084 } |
5074 verify_work_stacks_empty(); |
5085 verify_work_stacks_empty(); |
5075 verify_overflow_empty(); |
5086 verify_overflow_empty(); |
5076 SpecializationStats::print(); |
5087 SpecializationStats::print(); |
5077 } |
5088 } |
6366 { |
6377 { |
6367 CMSTokenSyncWithLocks ts(true, _cmsGen->freelistLock()); |
6378 CMSTokenSyncWithLocks ts(true, _cmsGen->freelistLock()); |
6368 // Update heap occupancy information which is used as |
6379 // Update heap occupancy information which is used as |
6369 // input to soft ref clearing policy at the next gc. |
6380 // input to soft ref clearing policy at the next gc. |
6370 Universe::update_heap_info_at_gc(); |
6381 Universe::update_heap_info_at_gc(); |
|
6382 |
|
6383 // recalculate CMS used space after CMS collection |
|
6384 _cmsGen->cmsSpace()->recalculate_used_stable(); |
|
6385 |
6371 _collectorState = Resizing; |
6386 _collectorState = Resizing; |
6372 } |
6387 } |
6373 } else { |
6388 } else { |
6374 // already have needed locks |
6389 // already have needed locks |
6375 sweepWork(_cmsGen, asynch); |
6390 sweepWork(_cmsGen, asynch); |
6465 // that are of interest at this point. |
6480 // that are of interest at this point. |
6466 if (!full && (current_level + 1) == level()) { |
6481 if (!full && (current_level + 1) == level()) { |
6467 // Gather statistics on the young generation collection. |
6482 // Gather statistics on the young generation collection. |
6468 collector()->stats().record_gc0_end(used()); |
6483 collector()->stats().record_gc0_end(used()); |
6469 } |
6484 } |
|
6485 _cmsSpace->recalculate_used_stable(); |
6470 } |
6486 } |
6471 |
6487 |
6472 CMSAdaptiveSizePolicy* ConcurrentMarkSweepGeneration::size_policy() { |
6488 CMSAdaptiveSizePolicy* ConcurrentMarkSweepGeneration::size_policy() { |
6473 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
6489 GenCollectedHeap* gch = GenCollectedHeap::heap(); |
6474 assert(gch->kind() == CollectedHeap::GenCollectedHeap, |
6490 assert(gch->kind() == CollectedHeap::GenCollectedHeap, |