Skip to content

Commit

Permalink
8338490: Serial: Move Generation::print_on to subclasses
Browse files Browse the repository at this point in the history
Reviewed-by: gli
  • Loading branch information
albertnetymk committed Aug 21, 2024
1 parent 80adea8 commit 918cf11
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 38 deletions.
15 changes: 9 additions & 6 deletions src/hotspot/share/gc/serial/defNewGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/gc/serial/defNewGeneration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 0 additions & 12 deletions src/hotspot/share/gc/serial/generation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
7 changes: 0 additions & 7 deletions src/hotspot/share/gc/serial/generation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@ class Generation: public CHeapObj<mtGC> {
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:
Expand Down
16 changes: 8 additions & 8 deletions src/hotspot/share/gc/serial/serialHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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(),
Expand All @@ -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(),
Expand Down
10 changes: 9 additions & 1 deletion src/hotspot/share/gc/serial/tenuredGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 1 addition & 2 deletions src/hotspot/share/gc/serial/tenuredGeneration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ class TenuredGeneration: public Generation {
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);
Expand Down

0 comments on commit 918cf11

Please sign in to comment.