8338490: Serial: Move Generation::print_on to subclasses

Reviewed-by: gli
This commit is contained in:
Albert Mingkun Yang 2024-08-21 12:01:57 +00:00
parent 80adea8e0a
commit 918cf11454
7 changed files with 28 additions and 38 deletions

View file

@ -846,7 +846,15 @@ void DefNewGeneration::verify() {
} }
void DefNewGeneration::print_on(outputStream* st) const { 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"); st->print(" eden");
eden()->print_on(st); eden()->print_on(st);
st->print(" from"); st->print(" from");
@ -855,11 +863,6 @@ void DefNewGeneration::print_on(outputStream* st) const {
to()->print_on(st); to()->print_on(st);
} }
const char* DefNewGeneration::name() const {
return "def new generation";
}
HeapWord* DefNewGeneration::allocate(size_t word_size) { HeapWord* DefNewGeneration::allocate(size_t word_size) {
// This is the slow-path allocation for the DefNewGeneration. // This is the slow-path allocation for the DefNewGeneration.
// Most allocations are fast-path in compiled code. // Most allocations are fast-path in compiled code.

View file

@ -234,8 +234,7 @@ class DefNewGeneration: public Generation {
void update_counters(); void update_counters();
// Printing // Printing
virtual const char* name() const; const char* name() const { return "DefNew"; }
virtual const char* short_name() const { return "DefNew"; }
void print_on(outputStream* st) const; void print_on(outputStream* st) const;

View file

@ -58,15 +58,3 @@ Generation::Generation(ReservedSpace rs, size_t initial_size) :
size_t Generation::max_capacity() const { size_t Generation::max_capacity() const {
return reserved().byte_size(); 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()));
}

View file

@ -103,13 +103,6 @@ class Generation: public CHeapObj<mtGC> {
return _reserved.contains(p); 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; virtual void verify() = 0;
public: public:

View file

@ -882,12 +882,12 @@ void SerialHeap::verify(VerifyOption option /* ignored */) {
} }
void SerialHeap::print_on(outputStream* st) const { void SerialHeap::print_on(outputStream* st) const {
if (_young_gen != nullptr) { assert(_young_gen != nullptr, "precondition");
_young_gen->print_on(st); assert(_old_gen != nullptr, "precondition");
}
if (_old_gen != nullptr) { _young_gen->print_on(st);
_old_gen->print_on(st); _old_gen->print_on(st);
}
MetaspaceUtils::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" " log_info(gc, heap)(HEAP_CHANGE_FORMAT" "
HEAP_CHANGE_FORMAT" " 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_used(),
pre_gc_values.young_gen_capacity(), pre_gc_values.young_gen_capacity(),
def_new_gen->used(), 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()->used(),
def_new_gen->from()->capacity())); def_new_gen->from()->capacity()));
log_info(gc, heap)(HEAP_CHANGE_FORMAT, 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_used(),
pre_gc_values.old_gen_capacity(), pre_gc_values.old_gen_capacity(),
old_gen()->used(), old_gen()->used(),

View file

@ -440,7 +440,15 @@ void TenuredGeneration::verify() {
} }
void TenuredGeneration::print_on(outputStream* st) const { 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"); st->print(" the");
_the_space->print_on(st); _the_space->print_on(st);
} }

View file

@ -121,8 +121,7 @@ public:
CardTableRS* remset); CardTableRS* remset);
// Printing // Printing
const char* name() const { return "tenured generation"; } const char* name() const { return "Tenured"; }
const char* short_name() const { return "Tenured"; }
// Iteration // Iteration
void object_iterate(ObjectClosure* blk); void object_iterate(ObjectClosure* blk);