Mercurial > hg > graal-compiler
diff src/share/vm/gc_implementation/g1/concurrentMark.cpp @ 1388:7666957bc44d
6937142: G1: improvements to debugging output (S-M)
Summary: Various fixes to the G1 debugging output.
Reviewed-by: johnc, iveresov
author | tonyp |
---|---|
date | Tue, 30 Mar 2010 15:43:03 -0400 |
parents | 23b1b27ac76c |
children | fb1a39993f69 |
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp Tue Apr 13 13:52:10 2010 -0700 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp Tue Mar 30 15:43:03 2010 -0400 @@ -767,7 +767,8 @@ _has_aborted = false; if (G1PrintReachableAtInitialMark) { - print_reachable(true, "before"); + print_reachable("at-cycle-start", + true /* use_prev_marking */, true /* all */); } // Initialise marking structures. This has to be done in a STW phase. @@ -1979,19 +1980,21 @@ #ifndef PRODUCT -class ReachablePrinterOopClosure: public OopClosure { +class PrintReachableOopClosure: public OopClosure { private: G1CollectedHeap* _g1h; CMBitMapRO* _bitmap; outputStream* _out; bool _use_prev_marking; + bool _all; public: - ReachablePrinterOopClosure(CMBitMapRO* bitmap, - outputStream* out, - bool use_prev_marking) : + PrintReachableOopClosure(CMBitMapRO* bitmap, + outputStream* out, + bool use_prev_marking, + bool all) : _g1h(G1CollectedHeap::heap()), - _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } + _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking), _all(all) { } void do_oop(narrowOop* p) { do_oop_work(p); } void do_oop( oop* p) { do_oop_work(p); } @@ -2001,9 +2004,11 @@ const char* str = NULL; const char* str2 = ""; - if (!_g1h->is_in_g1_reserved(obj)) - str = "outside G1 reserved"; - else { + if (obj == NULL) { + str = ""; + } else if (!_g1h->is_in_g1_reserved(obj)) { + str = " O"; + } else { HeapRegion* hr = _g1h->heap_region_containing(obj); guarantee(hr != NULL, "invariant"); bool over_tams = false; @@ -2012,74 +2017,67 @@ } else { over_tams = hr->obj_allocated_since_next_marking(obj); } + bool marked = _bitmap->isMarked((HeapWord*) obj); if (over_tams) { - str = "over TAMS"; - if (_bitmap->isMarked((HeapWord*) obj)) { + str = " >"; + if (marked) { str2 = " AND MARKED"; } - } else if (_bitmap->isMarked((HeapWord*) obj)) { - str = "marked"; + } else if (marked) { + str = " M"; } else { - str = "#### NOT MARKED ####"; + str = " NOT"; } } - _out->print_cr(" "PTR_FORMAT" contains "PTR_FORMAT" %s%s", + _out->print_cr(" "PTR_FORMAT": "PTR_FORMAT"%s%s", p, (void*) obj, str, str2); } }; -class ReachablePrinterClosure: public BitMapClosure { +class PrintReachableObjectClosure : public ObjectClosure { private: CMBitMapRO* _bitmap; outputStream* _out; bool _use_prev_marking; + bool _all; + HeapRegion* _hr; public: - ReachablePrinterClosure(CMBitMapRO* bitmap, - outputStream* out, - bool use_prev_marking) : - _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } - - bool do_bit(size_t offset) { - HeapWord* addr = _bitmap->offsetToHeapWord(offset); - ReachablePrinterOopClosure oopCl(_bitmap, _out, _use_prev_marking); - - _out->print_cr(" obj "PTR_FORMAT", offset %10d (marked)", addr, offset); - oop(addr)->oop_iterate(&oopCl); - _out->print_cr(""); - - return true; + PrintReachableObjectClosure(CMBitMapRO* bitmap, + outputStream* out, + bool use_prev_marking, + bool all, + HeapRegion* hr) : + _bitmap(bitmap), _out(out), + _use_prev_marking(use_prev_marking), _all(all), _hr(hr) { } + + void do_object(oop o) { + bool over_tams; + if (_use_prev_marking) { + over_tams = _hr->obj_allocated_since_prev_marking(o); + } else { + over_tams = _hr->obj_allocated_since_next_marking(o); + } + bool marked = _bitmap->isMarked((HeapWord*) o); + bool print_it = _all || over_tams || marked; + + if (print_it) { + _out->print_cr(" "PTR_FORMAT"%s", + o, (over_tams) ? " >" : (marked) ? " M" : ""); + PrintReachableOopClosure oopCl(_bitmap, _out, _use_prev_marking, _all); + o->oop_iterate(&oopCl); + } } }; -class ObjInRegionReachablePrinterClosure : public ObjectClosure { +class PrintReachableRegionClosure : public HeapRegionClosure { private: CMBitMapRO* _bitmap; outputStream* _out; bool _use_prev_marking; - -public: - ObjInRegionReachablePrinterClosure(CMBitMapRO* bitmap, - outputStream* out, - bool use_prev_marking) : - _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } - - void do_object(oop o) { - ReachablePrinterOopClosure oopCl(_bitmap, _out, _use_prev_marking); - - _out->print_cr(" obj "PTR_FORMAT" (over TAMS)", (void*) o); - o->oop_iterate(&oopCl); - _out->print_cr(""); - } -}; - -class RegionReachablePrinterClosure : public HeapRegionClosure { -private: - CMBitMapRO* _bitmap; - outputStream* _out; - bool _use_prev_marking; + bool _all; public: bool doHeapRegion(HeapRegion* hr) { @@ -2094,22 +2092,35 @@ } _out->print_cr("** ["PTR_FORMAT", "PTR_FORMAT"] top: "PTR_FORMAT" " "TAMS: "PTR_FORMAT, b, e, t, p); - _out->print_cr(""); - - ObjInRegionReachablePrinterClosure ocl(_bitmap, _out, _use_prev_marking); - hr->object_iterate_mem_careful(MemRegion(p, t), &ocl); + _out->cr(); + + HeapWord* from = b; + HeapWord* to = t; + + if (to > from) { + _out->print_cr("Objects in ["PTR_FORMAT", "PTR_FORMAT"]", from, to); + _out->cr(); + PrintReachableObjectClosure ocl(_bitmap, _out, + _use_prev_marking, _all, hr); + hr->object_iterate_mem_careful(MemRegion(from, to), &ocl); + _out->cr(); + } return false; } - RegionReachablePrinterClosure(CMBitMapRO* bitmap, - outputStream* out, - bool use_prev_marking) : - _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } + PrintReachableRegionClosure(CMBitMapRO* bitmap, + outputStream* out, + bool use_prev_marking, + bool all) : + _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking), _all(all) { } }; -void ConcurrentMark::print_reachable(bool use_prev_marking, const char* str) { - gclog_or_tty->print_cr("== Doing reachable object dump... "); +void ConcurrentMark::print_reachable(const char* str, + bool use_prev_marking, + bool all) { + gclog_or_tty->cr(); + gclog_or_tty->print_cr("== Doing heap dump... "); if (G1PrintReachableBaseFile == NULL) { gclog_or_tty->print_cr(" #### error: no base file defined"); @@ -2144,19 +2155,14 @@ out->print_cr("-- USING %s", (use_prev_marking) ? "PTAMS" : "NTAMS"); out->cr(); - RegionReachablePrinterClosure rcl(bitmap, out, use_prev_marking); - out->print_cr("--- ITERATING OVER REGIONS WITH TAMS < TOP"); - out->cr(); - _g1h->heap_region_iterate(&rcl); + out->print_cr("--- ITERATING OVER REGIONS"); out->cr(); - - ReachablePrinterClosure cl(bitmap, out, use_prev_marking); - out->print_cr("--- ITERATING OVER MARKED OBJECTS ON THE BITMAP"); - out->cr(); - bitmap->iterate(&cl); + PrintReachableRegionClosure rcl(bitmap, out, use_prev_marking, all); + _g1h->heap_region_iterate(&rcl); out->cr(); gclog_or_tty->print_cr(" done"); + gclog_or_tty->flush(); } #endif // PRODUCT