49 #include "runtime/java.hpp" |
49 #include "runtime/java.hpp" |
50 #include "runtime/vmThread.hpp" |
50 #include "runtime/vmThread.hpp" |
51 #include "services/memoryService.hpp" |
51 #include "services/memoryService.hpp" |
52 #include "utilities/vmError.hpp" |
52 #include "utilities/vmError.hpp" |
53 #include "utilities/workgroup.hpp" |
53 #include "utilities/workgroup.hpp" |
54 #ifndef SERIALGC |
54 #include "utilities/macros.hpp" |
|
55 #if INCLUDE_ALL_GCS |
55 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp" |
56 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp" |
56 #include "gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp" |
57 #include "gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp" |
57 #endif |
58 #endif // INCLUDE_ALL_GCS |
58 |
59 |
59 GenCollectedHeap* GenCollectedHeap::_gch; |
60 GenCollectedHeap* GenCollectedHeap::_gch; |
60 NOT_PRODUCT(size_t GenCollectedHeap::_skip_header_HeapWords = 0;) |
61 NOT_PRODUCT(size_t GenCollectedHeap::_skip_header_HeapWords = 0;) |
61 |
62 |
62 // The set of potentially parallel tasks in strong root scanning. |
63 // The set of potentially parallel tasks in strong root scanning. |
139 _gens[i] = _gen_specs[i]->init(this_rs, i, rem_set()); |
140 _gens[i] = _gen_specs[i]->init(this_rs, i, rem_set()); |
140 heap_rs = heap_rs.last_part(_gen_specs[i]->max_size()); |
141 heap_rs = heap_rs.last_part(_gen_specs[i]->max_size()); |
141 } |
142 } |
142 clear_incremental_collection_failed(); |
143 clear_incremental_collection_failed(); |
143 |
144 |
144 #ifndef SERIALGC |
145 #if INCLUDE_ALL_GCS |
145 // If we are running CMS, create the collector responsible |
146 // If we are running CMS, create the collector responsible |
146 // for collecting the CMS generations. |
147 // for collecting the CMS generations. |
147 if (collector_policy()->is_concurrent_mark_sweep_policy()) { |
148 if (collector_policy()->is_concurrent_mark_sweep_policy()) { |
148 bool success = create_cms_collector(); |
149 bool success = create_cms_collector(); |
149 if (!success) return JNI_ENOMEM; |
150 if (!success) return JNI_ENOMEM; |
150 } |
151 } |
151 #endif // SERIALGC |
152 #endif // INCLUDE_ALL_GCS |
152 |
153 |
153 return JNI_OK; |
154 return JNI_OK; |
154 } |
155 } |
155 |
156 |
156 |
157 |
684 |
685 |
685 // public collection interfaces |
686 // public collection interfaces |
686 |
687 |
687 void GenCollectedHeap::collect(GCCause::Cause cause) { |
688 void GenCollectedHeap::collect(GCCause::Cause cause) { |
688 if (should_do_concurrent_full_gc(cause)) { |
689 if (should_do_concurrent_full_gc(cause)) { |
689 #ifndef SERIALGC |
690 #if INCLUDE_ALL_GCS |
690 // mostly concurrent full collection |
691 // mostly concurrent full collection |
691 collect_mostly_concurrent(cause); |
692 collect_mostly_concurrent(cause); |
692 #else // SERIALGC |
693 #else // INCLUDE_ALL_GCS |
693 ShouldNotReachHere(); |
694 ShouldNotReachHere(); |
694 #endif // SERIALGC |
695 #endif // INCLUDE_ALL_GCS |
695 } else { |
696 } else { |
696 #ifdef ASSERT |
697 #ifdef ASSERT |
697 if (cause == GCCause::_scavenge_alot) { |
698 if (cause == GCCause::_scavenge_alot) { |
698 // minor collection only |
699 // minor collection only |
699 collect(cause, 0); |
700 collect(cause, 0); |
734 cause, max_level); |
735 cause, max_level); |
735 VMThread::execute(&op); |
736 VMThread::execute(&op); |
736 } |
737 } |
737 } |
738 } |
738 |
739 |
739 #ifndef SERIALGC |
740 #if INCLUDE_ALL_GCS |
740 bool GenCollectedHeap::create_cms_collector() { |
741 bool GenCollectedHeap::create_cms_collector() { |
741 |
742 |
742 assert(((_gens[1]->kind() == Generation::ConcurrentMarkSweep) || |
743 assert(((_gens[1]->kind() == Generation::ConcurrentMarkSweep) || |
743 (_gens[1]->kind() == Generation::ASConcurrentMarkSweep)), |
744 (_gens[1]->kind() == Generation::ASConcurrentMarkSweep)), |
744 "Unexpected generation kinds"); |
745 "Unexpected generation kinds"); |
770 MutexUnlocker mu(Heap_lock); |
771 MutexUnlocker mu(Heap_lock); |
771 VM_GenCollectFullConcurrent op(gc_count_before, full_gc_count_before, cause); |
772 VM_GenCollectFullConcurrent op(gc_count_before, full_gc_count_before, cause); |
772 VMThread::execute(&op); |
773 VMThread::execute(&op); |
773 } |
774 } |
774 } |
775 } |
775 #endif // SERIALGC |
776 #endif // INCLUDE_ALL_GCS |
776 |
777 |
777 void GenCollectedHeap::do_full_collection(bool clear_all_soft_refs) { |
778 void GenCollectedHeap::do_full_collection(bool clear_all_soft_refs) { |
778 do_full_collection(clear_all_soft_refs, _n_gens - 1); |
779 do_full_collection(clear_all_soft_refs, _n_gens - 1); |
779 } |
780 } |
780 |
781 |
1114 |
1115 |
1115 void GenCollectedHeap::gc_threads_do(ThreadClosure* tc) const { |
1116 void GenCollectedHeap::gc_threads_do(ThreadClosure* tc) const { |
1116 if (workers() != NULL) { |
1117 if (workers() != NULL) { |
1117 workers()->threads_do(tc); |
1118 workers()->threads_do(tc); |
1118 } |
1119 } |
1119 #ifndef SERIALGC |
1120 #if INCLUDE_ALL_GCS |
1120 if (UseConcMarkSweepGC) { |
1121 if (UseConcMarkSweepGC) { |
1121 ConcurrentMarkSweepThread::threads_do(tc); |
1122 ConcurrentMarkSweepThread::threads_do(tc); |
1122 } |
1123 } |
1123 #endif // SERIALGC |
1124 #endif // INCLUDE_ALL_GCS |
1124 } |
1125 } |
1125 |
1126 |
1126 void GenCollectedHeap::print_gc_threads_on(outputStream* st) const { |
1127 void GenCollectedHeap::print_gc_threads_on(outputStream* st) const { |
1127 #ifndef SERIALGC |
1128 #if INCLUDE_ALL_GCS |
1128 if (UseParNewGC) { |
1129 if (UseParNewGC) { |
1129 workers()->print_worker_threads_on(st); |
1130 workers()->print_worker_threads_on(st); |
1130 } |
1131 } |
1131 if (UseConcMarkSweepGC) { |
1132 if (UseConcMarkSweepGC) { |
1132 ConcurrentMarkSweepThread::print_all_on(st); |
1133 ConcurrentMarkSweepThread::print_all_on(st); |
1133 } |
1134 } |
1134 #endif // SERIALGC |
1135 #endif // INCLUDE_ALL_GCS |
1135 } |
1136 } |
1136 |
1137 |
1137 void GenCollectedHeap::print_tracing_info() const { |
1138 void GenCollectedHeap::print_tracing_info() const { |
1138 if (TraceGen0Time) { |
1139 if (TraceGen0Time) { |
1139 get_gen(0)->print_summary_info(); |
1140 get_gen(0)->print_summary_info(); |