diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp index 421997e06d2..0c80b800ac5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp @@ -291,6 +291,7 @@ void ShenandoahControlThread::service_concurrent_normal_cycle(GCCause::Cause cau log_info(gc)("Cancelled"); return; } + heap->increment_total_collections(false); ShenandoahGCSession session(cause, heap->global_generation()); @@ -337,6 +338,8 @@ void ShenandoahControlThread::service_stw_full_cycle(GCCause::Cause cause) { ShenandoahHeap* const heap = ShenandoahHeap::heap(); ShenandoahGCSession session(cause, heap->global_generation()); + heap->increment_total_collections(true); + ShenandoahFullGC gc; gc.collect(cause); } @@ -346,6 +349,8 @@ void ShenandoahControlThread::service_stw_degenerated_cycle(GCCause::Cause cause ShenandoahHeap* const heap = ShenandoahHeap::heap(); ShenandoahGCSession session(cause, heap->global_generation()); + heap->increment_total_collections(false); + ShenandoahDegenGC gc(point, heap->global_generation()); gc.collect(cause); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp index c941379d576..a99fa3ae62c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp @@ -482,7 +482,9 @@ const char* ShenandoahDegenGC::degen_event_message(ShenandoahDegenPoint point) c void ShenandoahDegenGC::upgrade_to_full() { log_info(gc)("Degenerated GC upgrading to Full GC"); - ShenandoahHeap::heap()->shenandoah_policy()->record_degenerated_upgrade_to_full(); + ShenandoahHeap* heap = ShenandoahHeap::heap(); + heap->increment_total_collections(true); + heap->shenandoah_policy()->record_degenerated_upgrade_to_full(); ShenandoahFullGC full_gc; full_gc.op_full(GCCause::_shenandoah_upgrade_to_full_gc); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp index 42671c33525..f5de41cb9ca 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp @@ -379,6 +379,8 @@ void ShenandoahGenerationalControlThread::service_concurrent_old_cycle(const She TraceCollectorStats tcs(_heap->monitoring_support()->concurrent_collection_counters()); + _heap->increment_total_collections(false); + switch (original_state) { case ShenandoahOldGeneration::FILLING: { ShenandoahGCSession session(request.cause, old_generation); @@ -528,6 +530,7 @@ void ShenandoahGenerationalControlThread::service_concurrent_cycle(ShenandoahGen assert(!generation->is_old(), "Old GC takes a different control path"); ShenandoahConcurrentGC gc(generation, do_old_gc_bootstrap); + _heap->increment_total_collections(false); if (gc.collect(cause)) { // Cycle is complete _heap->notify_gc_progress(); @@ -595,6 +598,7 @@ bool ShenandoahGenerationalControlThread::check_cancellation_or_degen(Shenandoah } void ShenandoahGenerationalControlThread::service_stw_full_cycle(GCCause::Cause cause) { + _heap->increment_total_collections(true); ShenandoahGCSession session(cause, _heap->global_generation()); maybe_set_aging_cycle(); ShenandoahFullGC gc; @@ -604,6 +608,7 @@ void ShenandoahGenerationalControlThread::service_stw_full_cycle(GCCause::Cause void ShenandoahGenerationalControlThread::service_stw_degenerated_cycle(const ShenandoahGCRequest& request) { assert(_degen_point != ShenandoahGC::_degenerated_unset, "Degenerated point should be set"); + _heap->increment_total_collections(false); ShenandoahGCSession session(request.cause, request.generation); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 72ee7a67e2a..71d4824562b 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -580,20 +580,35 @@ ShenandoahHeap::ShenandoahHeap(ShenandoahCollectorPolicy* policy) : #endif void ShenandoahHeap::print_heap_on(outputStream* st) const { - st->print_cr("Shenandoah Heap"); - st->print_cr(" %zu%s max, %zu%s soft max, %zu%s committed, %zu%s used", - byte_size_in_proper_unit(max_capacity()), proper_unit_for_byte_size(max_capacity()), - byte_size_in_proper_unit(soft_max_capacity()), proper_unit_for_byte_size(soft_max_capacity()), - byte_size_in_proper_unit(committed()), proper_unit_for_byte_size(committed()), - byte_size_in_proper_unit(used()), proper_unit_for_byte_size(used())); - st->print_cr(" %zu x %zu %s regions", - num_regions(), - byte_size_in_proper_unit(ShenandoahHeapRegion::region_size_bytes()), - proper_unit_for_byte_size(ShenandoahHeapRegion::region_size_bytes())); + const bool is_generational = mode()->is_generational(); + const char* front_spacing = ""; + if (is_generational) { + st->print_cr("Generational Shenandoah Heap"); + st->print_cr(" Young:"); + st->print_cr(" " PROPERFMT " max, " PROPERFMT " used", PROPERFMTARGS(young_generation()->max_capacity()), PROPERFMTARGS(young_generation()->used())); + st->print_cr(" Old:"); + st->print_cr(" " PROPERFMT " max, " PROPERFMT " used", PROPERFMTARGS(old_generation()->max_capacity()), PROPERFMTARGS(old_generation()->used())); + st->print_cr(" Entire heap:"); + st->print_cr(" " PROPERFMT " soft max, " PROPERFMT " committed", + PROPERFMTARGS(soft_max_capacity()), PROPERFMTARGS(committed())); + front_spacing = " "; + } else { + st->print_cr("Shenandoah Heap"); + st->print_cr(" " PROPERFMT " max, " PROPERFMT " soft max, " PROPERFMT " committed, " PROPERFMT " used", + PROPERFMTARGS(max_capacity()), + PROPERFMTARGS(soft_max_capacity()), + PROPERFMTARGS(committed()), + PROPERFMTARGS(used()) + ); + } + st->print_cr("%s %zu x " PROPERFMT " regions", + front_spacing, + num_regions(), + PROPERFMTARGS(ShenandoahHeapRegion::region_size_bytes())); st->print("Status: "); if (has_forwarded_objects()) st->print("has forwarded objects, "); - if (!mode()->is_generational()) { + if (!is_generational) { if (is_concurrent_mark_in_progress()) st->print("marking,"); } else { if (is_concurrent_old_mark_in_progress()) st->print("old marking, ");