From 0579e53a797aa56a4beea220108b13f03dc37619 Mon Sep 17 00:00:00 2001 From: tonyp Date: Tue, 8 Nov 2011 00:41:28 -0500 Subject: [PATCH] 7099849: G1: include heap region information in hs_err files Reviewed-by: johnc, brutisso, poonam --- .../gc_implementation/g1/g1CollectedHeap.cpp | 22 ++++++++--------- .../gc_implementation/g1/g1CollectedHeap.hpp | 8 +------ .../vm/gc_implementation/g1/heapRegion.cpp | 2 +- .../parallelScavenge/parallelScavengeHeap.cpp | 2 -- .../parallelScavenge/parallelScavengeHeap.hpp | 3 +-- src/share/vm/gc_interface/collectedHeap.hpp | 18 ++++++++++++-- src/share/vm/memory/genCollectedHeap.cpp | 1 - src/share/vm/memory/genCollectedHeap.hpp | 3 +-- src/share/vm/memory/universe.cpp | 24 +++++++++++++++---- src/share/vm/memory/universe.hpp | 8 +++++-- src/share/vm/utilities/vmError.cpp | 6 +++-- 11 files changed, 59 insertions(+), 38 deletions(-) diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 861c2154c..50eb83371 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -3006,7 +3006,10 @@ void G1CollectedHeap::verify(bool allow_dirty, if (failures) { gclog_or_tty->print_cr("Heap:"); - print_on(gclog_or_tty, true /* extended */); + // It helps to have the per-region information in the output to + // help us track down what went wrong. This is why we call + // print_extended_on() instead of print_on(). + print_extended_on(gclog_or_tty); gclog_or_tty->print_cr(""); #ifndef PRODUCT if (VerifyDuringGC && G1VerifyDuringGCPrintReachable) { @@ -3032,13 +3035,7 @@ public: } }; -void G1CollectedHeap::print() const { print_on(tty); } - void G1CollectedHeap::print_on(outputStream* st) const { - print_on(st, PrintHeapAtGCExtended); -} - -void G1CollectedHeap::print_on(outputStream* st, bool extended) const { st->print(" %-20s", "garbage-first heap"); st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", capacity()/K, used_unlocked()/K); @@ -3056,13 +3053,14 @@ void G1CollectedHeap::print_on(outputStream* st, bool extended) const { survivor_regions, survivor_regions * HeapRegion::GrainBytes / K); st->cr(); perm()->as_gen()->print_on(st); - if (extended) { - st->cr(); - print_on_extended(st); - } } -void G1CollectedHeap::print_on_extended(outputStream* st) const { +void G1CollectedHeap::print_extended_on(outputStream* st) const { + print_on(st); + + // Print the per-region information. + st->cr(); + st->print_cr("Heap Regions: (Y=young(eden), SU=young(survivor), HS=humongous(starts), HC=humongous(continues), CS=collection set, F=free, TS=gc time stamp, PTAMS=previous top-at-mark-start, NTAMS=next top-at-mark-start)"); PrintRegionClosure blk(st); heap_region_iterate(&blk); } diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index f3ec833f7..d0e0941b7 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -1449,14 +1449,8 @@ public: // Override; it uses the "prev" marking information virtual void verify(bool allow_dirty, bool silent); - // Default behavior by calling print(tty); - virtual void print() const; - // This calls print_on(st, PrintHeapAtGCExtended). virtual void print_on(outputStream* st) const; - // If extended is true, it will print out information for all - // regions in the heap by calling print_on_extended(st). - virtual void print_on(outputStream* st, bool extended) const; - virtual void print_on_extended(outputStream* st) const; + virtual void print_extended_on(outputStream* st) const; virtual void print_gc_threads_on(outputStream* st) const; virtual void gc_threads_do(ThreadClosure* tc) const; diff --git a/src/share/vm/gc_implementation/g1/heapRegion.cpp b/src/share/vm/gc_implementation/g1/heapRegion.cpp index c85611f84..98b7ebf0c 100644 --- a/src/share/vm/gc_implementation/g1/heapRegion.cpp +++ b/src/share/vm/gc_implementation/g1/heapRegion.cpp @@ -722,7 +722,7 @@ void HeapRegion::print_on(outputStream* st) const { st->print(" F"); else st->print(" "); - st->print(" %5d", _gc_time_stamp); + st->print(" TS %5d", _gc_time_stamp); st->print(" PTAMS "PTR_FORMAT" NTAMS "PTR_FORMAT, prev_top_at_mark_start(), next_top_at_mark_start()); G1OffsetTableContigSpace::print_on(st); diff --git a/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp b/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp index 42e65f1ad..04d2c721d 100644 --- a/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp +++ b/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp @@ -863,8 +863,6 @@ void ParallelScavengeHeap::prepare_for_verify() { ensure_parsability(false); // no need to retire TLABs for verification } -void ParallelScavengeHeap::print() const { print_on(tty); } - void ParallelScavengeHeap::print_on(outputStream* st) const { young_gen()->print_on(st); old_gen()->print_on(st); diff --git a/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp b/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp index 3d1065f48..f9ff99652 100644 --- a/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp +++ b/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp @@ -246,8 +246,7 @@ CollectorPolicy* collector_policy() const { return (CollectorPolicy*) _collector jlong millis_since_last_gc(); void prepare_for_verify(); - void print() const; - void print_on(outputStream* st) const; + virtual void print_on(outputStream* st) const; virtual void print_gc_threads_on(outputStream* st) const; virtual void gc_threads_do(ThreadClosure* tc) const; virtual void print_tracing_info() const; diff --git a/src/share/vm/gc_interface/collectedHeap.hpp b/src/share/vm/gc_interface/collectedHeap.hpp index ff7a112b1..726a30e30 100644 --- a/src/share/vm/gc_interface/collectedHeap.hpp +++ b/src/share/vm/gc_interface/collectedHeap.hpp @@ -590,13 +590,27 @@ class CollectedHeap : public CHeapObj { void pre_full_gc_dump(); void post_full_gc_dump(); - virtual void print() const = 0; + // Print heap information on the given outputStream. virtual void print_on(outputStream* st) const = 0; + // The default behavior is to call print_on() on tty. + virtual void print() const { + print_on(tty); + } + // Print more detailed heap information on the given + // outputStream. The default behaviour is to call print_on(). It is + // up to each subclass to override it and add any additional output + // it needs. + virtual void print_extended_on(outputStream* st) const { + print_on(st); + } // Print all GC threads (other than the VM thread) // used by this heap. virtual void print_gc_threads_on(outputStream* st) const = 0; - void print_gc_threads() { print_gc_threads_on(tty); } + // The default behavior is to call print_gc_threads_on() on tty. + void print_gc_threads() { + print_gc_threads_on(tty); + } // Iterator for all GC threads (other than VM thread) virtual void gc_threads_do(ThreadClosure* tc) const = 0; diff --git a/src/share/vm/memory/genCollectedHeap.cpp b/src/share/vm/memory/genCollectedHeap.cpp index d6a54e17e..babb0068b 100644 --- a/src/share/vm/memory/genCollectedHeap.cpp +++ b/src/share/vm/memory/genCollectedHeap.cpp @@ -1270,7 +1270,6 @@ void GenCollectedHeap::verify(bool allow_dirty, bool silent, VerifyOption option rem_set()->verify(); } -void GenCollectedHeap::print() const { print_on(tty); } void GenCollectedHeap::print_on(outputStream* st) const { for (int i = 0; i < _n_gens; i++) { _gens[i]->print_on(st); diff --git a/src/share/vm/memory/genCollectedHeap.hpp b/src/share/vm/memory/genCollectedHeap.hpp index 9c1537732..e7bea6476 100644 --- a/src/share/vm/memory/genCollectedHeap.hpp +++ b/src/share/vm/memory/genCollectedHeap.hpp @@ -360,8 +360,7 @@ public: void verify(bool allow_dirty, bool silent, VerifyOption option); // Override. - void print() const; - void print_on(outputStream* st) const; + virtual void print_on(outputStream* st) const; virtual void print_gc_threads_on(outputStream* st) const; virtual void gc_threads_do(ThreadClosure* tc) const; virtual void print_tracing_info() const; diff --git a/src/share/vm/memory/universe.cpp b/src/share/vm/memory/universe.cpp index 5dbf25889..22f5bb9e6 100644 --- a/src/share/vm/memory/universe.cpp +++ b/src/share/vm/memory/universe.cpp @@ -1281,11 +1281,17 @@ void Universe::flush_dependents_on_method(methodHandle m_h) { } } -void Universe::print() { print_on(gclog_or_tty); } +void Universe::print() { + print_on(gclog_or_tty); +} -void Universe::print_on(outputStream* st) { +void Universe::print_on(outputStream* st, bool extended) { st->print_cr("Heap"); - heap()->print_on(st); + if (!extended) { + heap()->print_on(st); + } else { + heap()->print_extended_on(st); + } } void Universe::print_heap_at_SIGBREAK() { @@ -1301,14 +1307,22 @@ void Universe::print_heap_before_gc(outputStream* st) { st->print_cr("{Heap before GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections()); - heap()->print_on(st); + if (!PrintHeapAtGCExtended) { + heap()->print_on(st); + } else { + heap()->print_extended_on(st); + } } void Universe::print_heap_after_gc(outputStream* st) { st->print_cr("Heap after GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections()); - heap()->print_on(st); + if (!PrintHeapAtGCExtended) { + heap()->print_on(st); + } else { + heap()->print_extended_on(st); + } st->print_cr("}"); } diff --git a/src/share/vm/memory/universe.hpp b/src/share/vm/memory/universe.hpp index 0f90ff5e6..24c793f25 100644 --- a/src/share/vm/memory/universe.hpp +++ b/src/share/vm/memory/universe.hpp @@ -414,9 +414,13 @@ class Universe: AllStatic { static bool verify_in_progress() { return _verify_in_progress; } static void verify(bool allow_dirty = true, bool silent = false, VerifyOption option = VerifyOption_Default ); - static int verify_count() { return _verify_count; } + static int verify_count() { return _verify_count; } + // The default behavior is to call print_on() on gclog_or_tty. static void print(); - static void print_on(outputStream* st); + // The extended parameter determines which method on the heap will + // be called: print_on() (extended == false) or print_extended_on() + // (extended == true). + static void print_on(outputStream* st, bool extended = false); static void print_heap_at_SIGBREAK(); static void print_heap_before_gc() { print_heap_before_gc(gclog_or_tty); } static void print_heap_after_gc() { print_heap_after_gc(gclog_or_tty); } diff --git a/src/share/vm/utilities/vmError.cpp b/src/share/vm/utilities/vmError.cpp index bb34fcd63..94ed68ea8 100644 --- a/src/share/vm/utilities/vmError.cpp +++ b/src/share/vm/utilities/vmError.cpp @@ -680,8 +680,10 @@ void VMError::report(outputStream* st) { STEP(190, "(printing heap information)" ) if (_verbose && Universe::is_fully_initialized()) { - // print heap information before vm abort - Universe::print_on(st); + // Print heap information before vm abort. As we'd like as much + // information as possible in the report we ask for the + // extended (i.e., more detailed) version. + Universe::print_on(st, true /* extended */); st->cr(); } -- GitLab