Skip to content

Commit 8757040

Browse files
author
Thomas Schatzl
committed
Playing around with heap region printing
1 parent 2662f25 commit 8757040

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,16 +2057,6 @@ bool G1CollectedHeap::supports_concurrent_gc_breakpoints() const {
20572057
return true;
20582058
}
20592059

2060-
class PrintRegionClosure: public HeapRegionClosure {
2061-
outputStream* _st;
2062-
public:
2063-
PrintRegionClosure(outputStream* st) : _st(st) {}
2064-
bool do_heap_region(HeapRegion* r) {
2065-
r->print_on(_st);
2066-
return false;
2067-
}
2068-
};
2069-
20702060
bool G1CollectedHeap::is_obj_dead_cond(const oop obj,
20712061
const HeapRegion* hr,
20722062
const VerifyOption vo) const {
@@ -2088,11 +2078,11 @@ bool G1CollectedHeap::is_obj_dead_cond(const oop obj,
20882078
return false; // keep some compilers happy
20892079
}
20902080

2091-
void G1CollectedHeap::print_heap_regions() const {
2081+
void G1CollectedHeap::print_heap_regions(bool print_pin_counts) const {
20922082
LogTarget(Trace, gc, heap, region) lt;
20932083
if (lt.is_enabled()) {
20942084
LogStream ls(lt);
2095-
print_regions_on(&ls);
2085+
print_regions_on(&ls, print_pin_counts);
20962086
}
20972087
}
20982088

@@ -2126,13 +2116,25 @@ void G1CollectedHeap::print_on(outputStream* st) const {
21262116
MetaspaceUtils::print_on(st);
21272117
}
21282118

2129-
void G1CollectedHeap::print_regions_on(outputStream* st) const {
2119+
2120+
class PrintRegionClosure: public HeapRegionClosure {
2121+
outputStream* _st;
2122+
const bool _print_pin_counts;
2123+
public:
2124+
PrintRegionClosure(outputStream* st, bool print_pin_counts) : _st(st), _print_pin_counts(print_pin_counts) {}
2125+
bool do_heap_region(HeapRegion* r) {
2126+
r->print_on(_st, _print_pin_counts);
2127+
return false;
2128+
}
2129+
};
2130+
2131+
void G1CollectedHeap::print_regions_on(outputStream* st, bool print_pin_counts) const {
21302132
st->print_cr("Heap Regions: E=young(eden), S=young(survivor), O=old, "
21312133
"HS=humongous(starts), HC=humongous(continues), "
21322134
"CS=collection set, F=free, "
21332135
"TAMS=top-at-mark-start, "
21342136
"PB=parsable bottom");
2135-
PrintRegionClosure blk(st);
2137+
PrintRegionClosure blk(st, print_pin_counts);
21362138
heap_region_iterate(&blk);
21372139
}
21382140

@@ -2141,7 +2143,7 @@ void G1CollectedHeap::print_extended_on(outputStream* st) const {
21412143

21422144
// Print the per-region information.
21432145
st->cr();
2144-
print_regions_on(st);
2146+
print_regions_on(st, true /* print_pin_counts */);
21452147
}
21462148

21472149
void G1CollectedHeap::print_on_error(outputStream* st) const {
@@ -2422,7 +2424,8 @@ G1HeapPrinterMark::G1HeapPrinterMark(G1CollectedHeap* g1h) : _g1h(g1h), _heap_tr
24222424
_g1h->total_collections(),
24232425
true /* show_thread_times */);
24242426
_g1h->print_heap_before_gc();
2425-
_g1h->print_heap_regions();
2427+
// We did not merge in the cached pin counts yet, making the output confusing.
2428+
_g1h->print_heap_regions(false /* print_pin_counts */);
24262429
}
24272430

24282431
G1HeapPrinterMark::~G1HeapPrinterMark() {
@@ -2434,7 +2437,7 @@ G1HeapPrinterMark::~G1HeapPrinterMark() {
24342437
false /* show_thread_times */);
24352438

24362439
_heap_transition.print();
2437-
_g1h->print_heap_regions();
2440+
_g1h->print_heap_regions(true /* print_pin_counts */);
24382441
_g1h->print_heap_after_gc();
24392442
// Print NUMA statistics.
24402443
_g1h->numa()->print_statistics();

src/hotspot/share/gc/g1/g1CollectedHeap.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,8 +1306,8 @@ class G1CollectedHeap : public CollectedHeap {
13061306

13071307
// Printing
13081308
private:
1309-
void print_heap_regions() const;
1310-
void print_regions_on(outputStream* st) const;
1309+
void print_heap_regions(bool print_pin_counts) const;
1310+
void print_regions_on(outputStream* st, bool print_pin_counts) const;
13111311

13121312
public:
13131313
void print_on(outputStream* st) const override;

src/hotspot/share/gc/g1/heapRegion.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,7 @@ bool HeapRegion::verify_code_roots(VerifyOption vo) const {
399399
return cb_cl.failures();
400400
}
401401

402-
void HeapRegion::print() const { print_on(tty); }
403-
404-
void HeapRegion::print_on(outputStream* st) const {
402+
void HeapRegion::print_on(outputStream* st, bool print_pin_counts) const {
405403
st->print("|%4u", this->_hrm_index);
406404
st->print("|" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT,
407405
p2i(bottom()), p2i(top()), p2i(end()));
@@ -425,7 +423,7 @@ void HeapRegion::print_on(outputStream* st) const {
425423
st->print("|-");
426424
}
427425
}
428-
st->print("|%3zu", Atomic::load(&_pinned_object_count));
426+
st->print("|%s%3zu", print_pin_counts ? "" : "~", Atomic::load(&_pinned_object_count));
429427
st->print("|%3zu", Atomic::load(&_total_pinned_atomicops));
430428
st->print_cr("");
431429
}

src/hotspot/share/gc/g1/heapRegion.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,7 @@ class HeapRegion : public CHeapObj<mtGC> {
575575
bool verify_code_roots(VerifyOption vo) const;
576576
bool verify_liveness_and_remset(VerifyOption vo) const;
577577

578-
void print() const;
579-
void print_on(outputStream* st) const;
578+
void print_on(outputStream* st, bool print_pin_counts) const;
580579

581580
bool verify(VerifyOption vo) const;
582581
};

0 commit comments

Comments
 (0)