180
181 // VM operation to invoke a concurrent collection of a
182 // GenCollectedHeap heap.
183 void VM_GenCollectFullConcurrent::doit() {
184 assert(Thread::current()->is_VM_thread(), "Should be VM thread");
185 assert(GCLockerInvokesConcurrent || ExplicitGCInvokesConcurrent, "Unexpected");
186
187 GenCollectedHeap* gch = GenCollectedHeap::heap();
188 if (_gc_count_before == gch->total_collections()) {
189 // The "full" of do_full_collection call below "forces"
190 // a collection; the second arg, 0, below ensures that
191 // only the young gen is collected. XXX In the future,
192 // we'll probably need to have something in this interface
193 // to say do this only if we are sure we will not bail
194 // out to a full collection in this attempt, but that's
195 // for the future.
196 assert(SafepointSynchronize::is_at_safepoint(),
197 "We can only be executing this arm of if at a safepoint");
198 GCCauseSetter gccs(gch, _gc_cause);
199 gch->do_full_collection(gch->must_clear_all_soft_refs(),
200 0 /* collect only youngest gen */);
201 } // Else no need for a foreground young gc
202 assert((_gc_count_before < gch->total_collections()) ||
203 (GC_locker::is_active() /* gc may have been skipped */
204 && (_gc_count_before == gch->total_collections())),
205 "total_collections() should be monotonically increasing");
206
207 MutexLockerEx x(FullGCCount_lock, Mutex::_no_safepoint_check_flag);
208 assert(_full_gc_count_before <= gch->total_full_collections(), "Error");
209 if (gch->total_full_collections() == _full_gc_count_before) {
210 // Disable iCMS until the full collection is done, and
211 // remember that we did so.
212 CMSCollector::disable_icms();
213 _disabled_icms = true;
214 // In case CMS thread was in icms_wait(), wake it up.
215 CMSCollector::start_icms();
216 // Nudge the CMS thread to start a concurrent collection.
217 CMSCollector::request_full_gc(_full_gc_count_before, _gc_cause);
218 } else {
219 assert(_full_gc_count_before < gch->total_full_collections(), "Error");
220 FullGCCount_lock->notify_all(); // Inform the Java thread its work is done
|
180
181 // VM operation to invoke a concurrent collection of a
182 // GenCollectedHeap heap.
183 void VM_GenCollectFullConcurrent::doit() {
184 assert(Thread::current()->is_VM_thread(), "Should be VM thread");
185 assert(GCLockerInvokesConcurrent || ExplicitGCInvokesConcurrent, "Unexpected");
186
187 GenCollectedHeap* gch = GenCollectedHeap::heap();
188 if (_gc_count_before == gch->total_collections()) {
189 // The "full" of do_full_collection call below "forces"
190 // a collection; the second arg, 0, below ensures that
191 // only the young gen is collected. XXX In the future,
192 // we'll probably need to have something in this interface
193 // to say do this only if we are sure we will not bail
194 // out to a full collection in this attempt, but that's
195 // for the future.
196 assert(SafepointSynchronize::is_at_safepoint(),
197 "We can only be executing this arm of if at a safepoint");
198 GCCauseSetter gccs(gch, _gc_cause);
199 gch->do_full_collection(gch->must_clear_all_soft_refs(),
200 Generation::Young /* collect only youngest gen */);
201 } // Else no need for a foreground young gc
202 assert((_gc_count_before < gch->total_collections()) ||
203 (GC_locker::is_active() /* gc may have been skipped */
204 && (_gc_count_before == gch->total_collections())),
205 "total_collections() should be monotonically increasing");
206
207 MutexLockerEx x(FullGCCount_lock, Mutex::_no_safepoint_check_flag);
208 assert(_full_gc_count_before <= gch->total_full_collections(), "Error");
209 if (gch->total_full_collections() == _full_gc_count_before) {
210 // Disable iCMS until the full collection is done, and
211 // remember that we did so.
212 CMSCollector::disable_icms();
213 _disabled_icms = true;
214 // In case CMS thread was in icms_wait(), wake it up.
215 CMSCollector::start_icms();
216 // Nudge the CMS thread to start a concurrent collection.
217 CMSCollector::request_full_gc(_full_gc_count_before, _gc_cause);
218 } else {
219 assert(_full_gc_count_before < gch->total_full_collections(), "Error");
220 FullGCCount_lock->notify_all(); // Inform the Java thread its work is done
|