# HG changeset patch # User tonyp # Date 1320730888 18000 # Node ID 53074c2c4600f885f4f0e5a3793fadd27cfe2300 # Parent 8aae2050e83e25ebd19d62bc955e9d155c6935da 7099849: G1: include heap region information in hs_err files Reviewed-by: johnc, brutisso, poonam diff -r 8aae2050e83e -r 53074c2c4600 src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Nov 07 22:11:12 2011 -0500 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Tue Nov 08 00:41:28 2011 -0500 @@ -3006,7 +3006,10 @@ 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 @@ } }; -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 @@ 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 -r 8aae2050e83e -r 53074c2c4600 src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Mon Nov 07 22:11:12 2011 -0500 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Tue Nov 08 00:41:28 2011 -0500 @@ -1449,14 +1449,8 @@ // 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 -r 8aae2050e83e -r 53074c2c4600 src/share/vm/gc_implementation/g1/heapRegion.cpp --- a/src/share/vm/gc_implementation/g1/heapRegion.cpp Mon Nov 07 22:11:12 2011 -0500 +++ b/src/share/vm/gc_implementation/g1/heapRegion.cpp Tue Nov 08 00:41:28 2011 -0500 @@ -722,7 +722,7 @@ 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 -r 8aae2050e83e -r 53074c2c4600 src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Mon Nov 07 22:11:12 2011 -0500 +++ b/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Tue Nov 08 00:41:28 2011 -0500 @@ -863,8 +863,6 @@ 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 -r 8aae2050e83e -r 53074c2c4600 src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp --- a/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Mon Nov 07 22:11:12 2011 -0500 +++ b/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Tue Nov 08 00:41:28 2011 -0500 @@ -246,8 +246,7 @@ 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 -r 8aae2050e83e -r 53074c2c4600 src/share/vm/gc_interface/collectedHeap.hpp --- a/src/share/vm/gc_interface/collectedHeap.hpp Mon Nov 07 22:11:12 2011 -0500 +++ b/src/share/vm/gc_interface/collectedHeap.hpp Tue Nov 08 00:41:28 2011 -0500 @@ -590,13 +590,27 @@ 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 -r 8aae2050e83e -r 53074c2c4600 src/share/vm/memory/genCollectedHeap.cpp --- a/src/share/vm/memory/genCollectedHeap.cpp Mon Nov 07 22:11:12 2011 -0500 +++ b/src/share/vm/memory/genCollectedHeap.cpp Tue Nov 08 00:41:28 2011 -0500 @@ -1270,7 +1270,6 @@ 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 -r 8aae2050e83e -r 53074c2c4600 src/share/vm/memory/genCollectedHeap.hpp --- a/src/share/vm/memory/genCollectedHeap.hpp Mon Nov 07 22:11:12 2011 -0500 +++ b/src/share/vm/memory/genCollectedHeap.hpp Tue Nov 08 00:41:28 2011 -0500 @@ -360,8 +360,7 @@ 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 -r 8aae2050e83e -r 53074c2c4600 src/share/vm/memory/universe.cpp --- a/src/share/vm/memory/universe.cpp Mon Nov 07 22:11:12 2011 -0500 +++ b/src/share/vm/memory/universe.cpp Tue Nov 08 00:41:28 2011 -0500 @@ -1281,11 +1281,17 @@ } } -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 @@ 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 -r 8aae2050e83e -r 53074c2c4600 src/share/vm/memory/universe.hpp --- a/src/share/vm/memory/universe.hpp Mon Nov 07 22:11:12 2011 -0500 +++ b/src/share/vm/memory/universe.hpp Tue Nov 08 00:41:28 2011 -0500 @@ -414,9 +414,13 @@ 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 -r 8aae2050e83e -r 53074c2c4600 src/share/vm/utilities/vmError.cpp --- a/src/share/vm/utilities/vmError.cpp Mon Nov 07 22:11:12 2011 -0500 +++ b/src/share/vm/utilities/vmError.cpp Tue Nov 08 00:41:28 2011 -0500 @@ -680,8 +680,10 @@ 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(); }