From 918cf114548d0098cf6a8a50032b78ee04d453db Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Wed, 21 Aug 2024 12:01:57 +0000 Subject: [PATCH] 8338490: Serial: Move Generation::print_on to subclasses Reviewed-by: gli --- src/hotspot/share/gc/serial/defNewGeneration.cpp | 15 +++++++++------ src/hotspot/share/gc/serial/defNewGeneration.hpp | 3 +-- src/hotspot/share/gc/serial/generation.cpp | 12 ------------ src/hotspot/share/gc/serial/generation.hpp | 7 ------- src/hotspot/share/gc/serial/serialHeap.cpp | 16 ++++++++-------- .../share/gc/serial/tenuredGeneration.cpp | 10 +++++++++- .../share/gc/serial/tenuredGeneration.hpp | 3 +-- 7 files changed, 28 insertions(+), 38 deletions(-) diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp index 047171a5eb3..f3b3c8952b9 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.cpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp @@ -846,7 +846,15 @@ void DefNewGeneration::verify() { } void DefNewGeneration::print_on(outputStream* st) const { - Generation::print_on(st); + st->print(" %-10s", name()); + + st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", + capacity()/K, used()/K); + st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ")", + p2i(_virtual_space.low_boundary()), + p2i(_virtual_space.high()), + p2i(_virtual_space.high_boundary())); + st->print(" eden"); eden()->print_on(st); st->print(" from"); @@ -855,11 +863,6 @@ void DefNewGeneration::print_on(outputStream* st) const { to()->print_on(st); } - -const char* DefNewGeneration::name() const { - return "def new generation"; -} - HeapWord* DefNewGeneration::allocate(size_t word_size) { // This is the slow-path allocation for the DefNewGeneration. // Most allocations are fast-path in compiled code. diff --git a/src/hotspot/share/gc/serial/defNewGeneration.hpp b/src/hotspot/share/gc/serial/defNewGeneration.hpp index c5b7c095ac4..e86ea6b9747 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.hpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.hpp @@ -234,8 +234,7 @@ class DefNewGeneration: public Generation { void update_counters(); // Printing - virtual const char* name() const; - virtual const char* short_name() const { return "DefNew"; } + const char* name() const { return "DefNew"; } void print_on(outputStream* st) const; diff --git a/src/hotspot/share/gc/serial/generation.cpp b/src/hotspot/share/gc/serial/generation.cpp index 5d3b7fe2fe3..b15b071d710 100644 --- a/src/hotspot/share/gc/serial/generation.cpp +++ b/src/hotspot/share/gc/serial/generation.cpp @@ -58,15 +58,3 @@ Generation::Generation(ReservedSpace rs, size_t initial_size) : size_t Generation::max_capacity() const { return reserved().byte_size(); } - -void Generation::print() const { print_on(tty); } - -void Generation::print_on(outputStream* st) const { - st->print(" %-20s", name()); - st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", - capacity()/K, used()/K); - st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ")", - p2i(_virtual_space.low_boundary()), - p2i(_virtual_space.high()), - p2i(_virtual_space.high_boundary())); -} diff --git a/src/hotspot/share/gc/serial/generation.hpp b/src/hotspot/share/gc/serial/generation.hpp index c6a9f94a870..e13b42956e1 100644 --- a/src/hotspot/share/gc/serial/generation.hpp +++ b/src/hotspot/share/gc/serial/generation.hpp @@ -103,13 +103,6 @@ class Generation: public CHeapObj { return _reserved.contains(p); } - // Printing - virtual const char* name() const = 0; - virtual const char* short_name() const = 0; - - virtual void print() const; - virtual void print_on(outputStream* st) const; - virtual void verify() = 0; public: diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp index 3c481775541..9dcfb5b6092 100644 --- a/src/hotspot/share/gc/serial/serialHeap.cpp +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -882,12 +882,12 @@ void SerialHeap::verify(VerifyOption option /* ignored */) { } void SerialHeap::print_on(outputStream* st) const { - if (_young_gen != nullptr) { - _young_gen->print_on(st); - } - if (_old_gen != nullptr) { - _old_gen->print_on(st); - } + assert(_young_gen != nullptr, "precondition"); + assert(_old_gen != nullptr, "precondition"); + + _young_gen->print_on(st); + _old_gen->print_on(st); + MetaspaceUtils::print_on(st); } @@ -908,7 +908,7 @@ void SerialHeap::print_heap_change(const PreGenGCValues& pre_gc_values) const { log_info(gc, heap)(HEAP_CHANGE_FORMAT" " HEAP_CHANGE_FORMAT" " HEAP_CHANGE_FORMAT, - HEAP_CHANGE_FORMAT_ARGS(def_new_gen->short_name(), + HEAP_CHANGE_FORMAT_ARGS(def_new_gen->name(), pre_gc_values.young_gen_used(), pre_gc_values.young_gen_capacity(), def_new_gen->used(), @@ -924,7 +924,7 @@ void SerialHeap::print_heap_change(const PreGenGCValues& pre_gc_values) const { def_new_gen->from()->used(), def_new_gen->from()->capacity())); log_info(gc, heap)(HEAP_CHANGE_FORMAT, - HEAP_CHANGE_FORMAT_ARGS(old_gen()->short_name(), + HEAP_CHANGE_FORMAT_ARGS(old_gen()->name(), pre_gc_values.old_gen_used(), pre_gc_values.old_gen_capacity(), old_gen()->used(), diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.cpp b/src/hotspot/share/gc/serial/tenuredGeneration.cpp index febc4713d03..99031c379d8 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.cpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.cpp @@ -440,7 +440,15 @@ void TenuredGeneration::verify() { } void TenuredGeneration::print_on(outputStream* st) const { - Generation::print_on(st); + st->print(" %-10s", name()); + + st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", + capacity()/K, used()/K); + st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ")", + p2i(_virtual_space.low_boundary()), + p2i(_virtual_space.high()), + p2i(_virtual_space.high_boundary())); + st->print(" the"); _the_space->print_on(st); } diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.hpp b/src/hotspot/share/gc/serial/tenuredGeneration.hpp index fc0578d4e4f..88bfe6ecf46 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.hpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.hpp @@ -121,8 +121,7 @@ public: CardTableRS* remset); // Printing - const char* name() const { return "tenured generation"; } - const char* short_name() const { return "Tenured"; } + const char* name() const { return "Tenured"; } // Iteration void object_iterate(ObjectClosure* blk);