19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26
27 #include "gc/shared/collectorCounters.hpp"
28 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
29 #include "gc/shenandoah/shenandoahConcurrentMark.hpp"
30 #include "gc/shenandoah/shenandoahDegeneratedGC.hpp"
31 #include "gc/shenandoah/shenandoahFullGC.hpp"
32 #include "gc/shenandoah/shenandoahGeneration.hpp"
33 #include "gc/shenandoah/shenandoahGenerationalHeap.hpp"
34 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
35 #include "gc/shenandoah/shenandoahMetrics.hpp"
36 #include "gc/shenandoah/shenandoahMonitoringSupport.hpp"
37 #include "gc/shenandoah/shenandoahOldGeneration.hpp"
38 #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
39 #include "gc/shenandoah/shenandoahSTWMark.hpp"
40 #include "gc/shenandoah/shenandoahUtils.hpp"
41 #include "gc/shenandoah/shenandoahVerifier.hpp"
42 #include "gc/shenandoah/shenandoahVMOperations.hpp"
43 #include "gc/shenandoah/shenandoahWorkerPolicy.hpp"
44 #include "gc/shenandoah/shenandoahYoungGeneration.hpp"
45 #include "runtime/vmThread.hpp"
46 #include "utilities/events.hpp"
47
48 ShenandoahDegenGC::ShenandoahDegenGC(ShenandoahDegenPoint degen_point, ShenandoahGeneration* generation, bool do_old_gc_bootstrap) :
49 ShenandoahGC(generation),
50 _degen_point(degen_point),
51 _abbreviated(false),
52 _do_old_gc_bootstrap(do_old_gc_bootstrap) {
53 }
54
55 bool ShenandoahDegenGC::collect(GCCause::Cause cause) {
56 vmop_degenerated();
57 ShenandoahHeap* heap = ShenandoahHeap::heap();
58 if (heap->mode()->is_generational()) {
284 // and we need to do update-refs. Otherwise, it would be the shortcut cycle.
285 if (heap->has_forwarded_objects()) {
286 op_init_update_refs();
287 assert(!heap->cancelled_gc(), "STW reference update can not OOM");
288 } else {
289 _abbreviated = true;
290 }
291
292 // labs are retired, walk the old regions and update remembered set
293 if (ShenandoahHeap::heap()->mode()->is_generational()) {
294 ShenandoahGenerationalHeap::heap()->old_generation()->update_card_table();
295 }
296
297 case _degenerated_update_refs:
298 if (heap->has_forwarded_objects()) {
299 op_update_refs();
300 op_update_roots();
301 assert(!heap->cancelled_gc(), "STW reference update can not OOM");
302 }
303
304 // Disarm nmethods that armed in concurrent cycle.
305 // In above case, update roots should disarm them
306 ShenandoahCodeRoots::disarm_nmethods();
307
308 op_cleanup_complete();
309
310 if (heap->mode()->is_generational()) {
311 ShenandoahGenerationalHeap::heap()->complete_degenerated_cycle();
312 }
313
314 break;
315 default:
316 ShouldNotReachHere();
317 }
318
319 DEBUG_ONLY(heap->assert_no_self_forwards());
320
321 if (ShenandoahVerify) {
322 heap->verifier()->verify_after_degenerated(_generation);
323 }
324
325 if (VerifyAfterGC) {
326 Universe::verify();
327 }
328
329 // Decide if this cycle made good progress, and, if not, should it upgrade to a full GC.
330 const bool progress = metrics.is_good_progress();
331 ShenandoahCollectorPolicy* policy = heap->shenandoah_policy();
332 policy->record_degenerated(_generation->is_young(), _abbreviated, progress);
333 if (progress) {
334 heap->notify_gc_progress();
335 _generation->heuristics()->record_degenerated(heap->mode()->is_generational() && _generation->is_global());
336 heap->start_idle_span();
337 } else if (policy->should_upgrade_degenerated_gc()) {
338 // Upgrade to full GC, register full-GC impact on heuristics.
339 op_degenerated_futile();
340 } else {
|
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26
27 #include "gc/shared/collectorCounters.hpp"
28 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
29 #include "gc/shenandoah/shenandoahConcurrentMark.hpp"
30 #include "gc/shenandoah/shenandoahDegeneratedGC.hpp"
31 #include "gc/shenandoah/shenandoahFullGC.hpp"
32 #include "gc/shenandoah/shenandoahGeneration.hpp"
33 #include "gc/shenandoah/shenandoahGenerationalHeap.hpp"
34 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
35 #include "gc/shenandoah/shenandoahMetrics.hpp"
36 #include "gc/shenandoah/shenandoahMonitoringSupport.hpp"
37 #include "gc/shenandoah/shenandoahOldGeneration.hpp"
38 #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
39 #include "gc/shenandoah/shenandoahStackWatermark.hpp"
40 #include "gc/shenandoah/shenandoahSTWMark.hpp"
41 #include "gc/shenandoah/shenandoahUtils.hpp"
42 #include "gc/shenandoah/shenandoahVerifier.hpp"
43 #include "gc/shenandoah/shenandoahVMOperations.hpp"
44 #include "gc/shenandoah/shenandoahWorkerPolicy.hpp"
45 #include "gc/shenandoah/shenandoahYoungGeneration.hpp"
46 #include "runtime/vmThread.hpp"
47 #include "utilities/events.hpp"
48
49 ShenandoahDegenGC::ShenandoahDegenGC(ShenandoahDegenPoint degen_point, ShenandoahGeneration* generation, bool do_old_gc_bootstrap) :
50 ShenandoahGC(generation),
51 _degen_point(degen_point),
52 _abbreviated(false),
53 _do_old_gc_bootstrap(do_old_gc_bootstrap) {
54 }
55
56 bool ShenandoahDegenGC::collect(GCCause::Cause cause) {
57 vmop_degenerated();
58 ShenandoahHeap* heap = ShenandoahHeap::heap();
59 if (heap->mode()->is_generational()) {
285 // and we need to do update-refs. Otherwise, it would be the shortcut cycle.
286 if (heap->has_forwarded_objects()) {
287 op_init_update_refs();
288 assert(!heap->cancelled_gc(), "STW reference update can not OOM");
289 } else {
290 _abbreviated = true;
291 }
292
293 // labs are retired, walk the old regions and update remembered set
294 if (ShenandoahHeap::heap()->mode()->is_generational()) {
295 ShenandoahGenerationalHeap::heap()->old_generation()->update_card_table();
296 }
297
298 case _degenerated_update_refs:
299 if (heap->has_forwarded_objects()) {
300 op_update_refs();
301 op_update_roots();
302 assert(!heap->cancelled_gc(), "STW reference update can not OOM");
303 }
304
305 op_cleanup_complete();
306
307 if (heap->mode()->is_generational()) {
308 ShenandoahGenerationalHeap::heap()->complete_degenerated_cycle();
309 }
310
311 break;
312 default:
313 ShouldNotReachHere();
314 }
315
316 DEBUG_ONLY(heap->assert_no_self_forwards());
317
318 // Leaving degenerated GC, we need to flip barriers back to idle.
319 ShenandoahCodeRoots::arm_nmethods();
320 ShenandoahStackWatermark::change_epoch_id();
321
322 if (ShenandoahVerify) {
323 heap->verifier()->verify_after_degenerated(_generation);
324 }
325
326 if (VerifyAfterGC) {
327 Universe::verify();
328 }
329
330 // Decide if this cycle made good progress, and, if not, should it upgrade to a full GC.
331 const bool progress = metrics.is_good_progress();
332 ShenandoahCollectorPolicy* policy = heap->shenandoah_policy();
333 policy->record_degenerated(_generation->is_young(), _abbreviated, progress);
334 if (progress) {
335 heap->notify_gc_progress();
336 _generation->heuristics()->record_degenerated(heap->mode()->is_generational() && _generation->is_global());
337 heap->start_idle_span();
338 } else if (policy->should_upgrade_degenerated_gc()) {
339 // Upgrade to full GC, register full-GC impact on heuristics.
340 op_degenerated_futile();
341 } else {
|