Mercurial > hg > graal-compiler
comparison 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 |
comparison
equal
deleted
inserted
replaced
1387:0bfd3fb24150 | 1388:7666957bc44d |
---|---|
765 G1CollectorPolicy* g1p = g1h->g1_policy(); | 765 G1CollectorPolicy* g1p = g1h->g1_policy(); |
766 | 766 |
767 _has_aborted = false; | 767 _has_aborted = false; |
768 | 768 |
769 if (G1PrintReachableAtInitialMark) { | 769 if (G1PrintReachableAtInitialMark) { |
770 print_reachable(true, "before"); | 770 print_reachable("at-cycle-start", |
771 true /* use_prev_marking */, true /* all */); | |
771 } | 772 } |
772 | 773 |
773 // Initialise marking structures. This has to be done in a STW phase. | 774 // Initialise marking structures. This has to be done in a STW phase. |
774 reset(); | 775 reset(); |
775 } | 776 } |
1977 #endif | 1978 #endif |
1978 } | 1979 } |
1979 | 1980 |
1980 #ifndef PRODUCT | 1981 #ifndef PRODUCT |
1981 | 1982 |
1982 class ReachablePrinterOopClosure: public OopClosure { | 1983 class PrintReachableOopClosure: public OopClosure { |
1983 private: | 1984 private: |
1984 G1CollectedHeap* _g1h; | 1985 G1CollectedHeap* _g1h; |
1985 CMBitMapRO* _bitmap; | 1986 CMBitMapRO* _bitmap; |
1986 outputStream* _out; | 1987 outputStream* _out; |
1987 bool _use_prev_marking; | 1988 bool _use_prev_marking; |
1989 bool _all; | |
1988 | 1990 |
1989 public: | 1991 public: |
1990 ReachablePrinterOopClosure(CMBitMapRO* bitmap, | 1992 PrintReachableOopClosure(CMBitMapRO* bitmap, |
1991 outputStream* out, | 1993 outputStream* out, |
1992 bool use_prev_marking) : | 1994 bool use_prev_marking, |
1995 bool all) : | |
1993 _g1h(G1CollectedHeap::heap()), | 1996 _g1h(G1CollectedHeap::heap()), |
1994 _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } | 1997 _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking), _all(all) { } |
1995 | 1998 |
1996 void do_oop(narrowOop* p) { do_oop_work(p); } | 1999 void do_oop(narrowOop* p) { do_oop_work(p); } |
1997 void do_oop( oop* p) { do_oop_work(p); } | 2000 void do_oop( oop* p) { do_oop_work(p); } |
1998 | 2001 |
1999 template <class T> void do_oop_work(T* p) { | 2002 template <class T> void do_oop_work(T* p) { |
2000 oop obj = oopDesc::load_decode_heap_oop(p); | 2003 oop obj = oopDesc::load_decode_heap_oop(p); |
2001 const char* str = NULL; | 2004 const char* str = NULL; |
2002 const char* str2 = ""; | 2005 const char* str2 = ""; |
2003 | 2006 |
2004 if (!_g1h->is_in_g1_reserved(obj)) | 2007 if (obj == NULL) { |
2005 str = "outside G1 reserved"; | 2008 str = ""; |
2006 else { | 2009 } else if (!_g1h->is_in_g1_reserved(obj)) { |
2010 str = " O"; | |
2011 } else { | |
2007 HeapRegion* hr = _g1h->heap_region_containing(obj); | 2012 HeapRegion* hr = _g1h->heap_region_containing(obj); |
2008 guarantee(hr != NULL, "invariant"); | 2013 guarantee(hr != NULL, "invariant"); |
2009 bool over_tams = false; | 2014 bool over_tams = false; |
2010 if (_use_prev_marking) { | 2015 if (_use_prev_marking) { |
2011 over_tams = hr->obj_allocated_since_prev_marking(obj); | 2016 over_tams = hr->obj_allocated_since_prev_marking(obj); |
2012 } else { | 2017 } else { |
2013 over_tams = hr->obj_allocated_since_next_marking(obj); | 2018 over_tams = hr->obj_allocated_since_next_marking(obj); |
2014 } | 2019 } |
2020 bool marked = _bitmap->isMarked((HeapWord*) obj); | |
2015 | 2021 |
2016 if (over_tams) { | 2022 if (over_tams) { |
2017 str = "over TAMS"; | 2023 str = " >"; |
2018 if (_bitmap->isMarked((HeapWord*) obj)) { | 2024 if (marked) { |
2019 str2 = " AND MARKED"; | 2025 str2 = " AND MARKED"; |
2020 } | 2026 } |
2021 } else if (_bitmap->isMarked((HeapWord*) obj)) { | 2027 } else if (marked) { |
2022 str = "marked"; | 2028 str = " M"; |
2023 } else { | 2029 } else { |
2024 str = "#### NOT MARKED ####"; | 2030 str = " NOT"; |
2025 } | 2031 } |
2026 } | 2032 } |
2027 | 2033 |
2028 _out->print_cr(" "PTR_FORMAT" contains "PTR_FORMAT" %s%s", | 2034 _out->print_cr(" "PTR_FORMAT": "PTR_FORMAT"%s%s", |
2029 p, (void*) obj, str, str2); | 2035 p, (void*) obj, str, str2); |
2030 } | 2036 } |
2031 }; | 2037 }; |
2032 | 2038 |
2033 class ReachablePrinterClosure: public BitMapClosure { | 2039 class PrintReachableObjectClosure : public ObjectClosure { |
2034 private: | 2040 private: |
2035 CMBitMapRO* _bitmap; | 2041 CMBitMapRO* _bitmap; |
2036 outputStream* _out; | 2042 outputStream* _out; |
2037 bool _use_prev_marking; | 2043 bool _use_prev_marking; |
2044 bool _all; | |
2045 HeapRegion* _hr; | |
2038 | 2046 |
2039 public: | 2047 public: |
2040 ReachablePrinterClosure(CMBitMapRO* bitmap, | 2048 PrintReachableObjectClosure(CMBitMapRO* bitmap, |
2041 outputStream* out, | 2049 outputStream* out, |
2042 bool use_prev_marking) : | 2050 bool use_prev_marking, |
2043 _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } | 2051 bool all, |
2044 | 2052 HeapRegion* hr) : |
2045 bool do_bit(size_t offset) { | 2053 _bitmap(bitmap), _out(out), |
2046 HeapWord* addr = _bitmap->offsetToHeapWord(offset); | 2054 _use_prev_marking(use_prev_marking), _all(all), _hr(hr) { } |
2047 ReachablePrinterOopClosure oopCl(_bitmap, _out, _use_prev_marking); | 2055 |
2048 | 2056 void do_object(oop o) { |
2049 _out->print_cr(" obj "PTR_FORMAT", offset %10d (marked)", addr, offset); | 2057 bool over_tams; |
2050 oop(addr)->oop_iterate(&oopCl); | 2058 if (_use_prev_marking) { |
2051 _out->print_cr(""); | 2059 over_tams = _hr->obj_allocated_since_prev_marking(o); |
2052 | 2060 } else { |
2053 return true; | 2061 over_tams = _hr->obj_allocated_since_next_marking(o); |
2062 } | |
2063 bool marked = _bitmap->isMarked((HeapWord*) o); | |
2064 bool print_it = _all || over_tams || marked; | |
2065 | |
2066 if (print_it) { | |
2067 _out->print_cr(" "PTR_FORMAT"%s", | |
2068 o, (over_tams) ? " >" : (marked) ? " M" : ""); | |
2069 PrintReachableOopClosure oopCl(_bitmap, _out, _use_prev_marking, _all); | |
2070 o->oop_iterate(&oopCl); | |
2071 } | |
2054 } | 2072 } |
2055 }; | 2073 }; |
2056 | 2074 |
2057 class ObjInRegionReachablePrinterClosure : public ObjectClosure { | 2075 class PrintReachableRegionClosure : public HeapRegionClosure { |
2058 private: | 2076 private: |
2059 CMBitMapRO* _bitmap; | 2077 CMBitMapRO* _bitmap; |
2060 outputStream* _out; | 2078 outputStream* _out; |
2061 bool _use_prev_marking; | 2079 bool _use_prev_marking; |
2062 | 2080 bool _all; |
2063 public: | |
2064 ObjInRegionReachablePrinterClosure(CMBitMapRO* bitmap, | |
2065 outputStream* out, | |
2066 bool use_prev_marking) : | |
2067 _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } | |
2068 | |
2069 void do_object(oop o) { | |
2070 ReachablePrinterOopClosure oopCl(_bitmap, _out, _use_prev_marking); | |
2071 | |
2072 _out->print_cr(" obj "PTR_FORMAT" (over TAMS)", (void*) o); | |
2073 o->oop_iterate(&oopCl); | |
2074 _out->print_cr(""); | |
2075 } | |
2076 }; | |
2077 | |
2078 class RegionReachablePrinterClosure : public HeapRegionClosure { | |
2079 private: | |
2080 CMBitMapRO* _bitmap; | |
2081 outputStream* _out; | |
2082 bool _use_prev_marking; | |
2083 | 2081 |
2084 public: | 2082 public: |
2085 bool doHeapRegion(HeapRegion* hr) { | 2083 bool doHeapRegion(HeapRegion* hr) { |
2086 HeapWord* b = hr->bottom(); | 2084 HeapWord* b = hr->bottom(); |
2087 HeapWord* e = hr->end(); | 2085 HeapWord* e = hr->end(); |
2092 } else { | 2090 } else { |
2093 p = hr->next_top_at_mark_start(); | 2091 p = hr->next_top_at_mark_start(); |
2094 } | 2092 } |
2095 _out->print_cr("** ["PTR_FORMAT", "PTR_FORMAT"] top: "PTR_FORMAT" " | 2093 _out->print_cr("** ["PTR_FORMAT", "PTR_FORMAT"] top: "PTR_FORMAT" " |
2096 "TAMS: "PTR_FORMAT, b, e, t, p); | 2094 "TAMS: "PTR_FORMAT, b, e, t, p); |
2097 _out->print_cr(""); | 2095 _out->cr(); |
2098 | 2096 |
2099 ObjInRegionReachablePrinterClosure ocl(_bitmap, _out, _use_prev_marking); | 2097 HeapWord* from = b; |
2100 hr->object_iterate_mem_careful(MemRegion(p, t), &ocl); | 2098 HeapWord* to = t; |
2099 | |
2100 if (to > from) { | |
2101 _out->print_cr("Objects in ["PTR_FORMAT", "PTR_FORMAT"]", from, to); | |
2102 _out->cr(); | |
2103 PrintReachableObjectClosure ocl(_bitmap, _out, | |
2104 _use_prev_marking, _all, hr); | |
2105 hr->object_iterate_mem_careful(MemRegion(from, to), &ocl); | |
2106 _out->cr(); | |
2107 } | |
2101 | 2108 |
2102 return false; | 2109 return false; |
2103 } | 2110 } |
2104 | 2111 |
2105 RegionReachablePrinterClosure(CMBitMapRO* bitmap, | 2112 PrintReachableRegionClosure(CMBitMapRO* bitmap, |
2106 outputStream* out, | 2113 outputStream* out, |
2107 bool use_prev_marking) : | 2114 bool use_prev_marking, |
2108 _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking) { } | 2115 bool all) : |
2116 _bitmap(bitmap), _out(out), _use_prev_marking(use_prev_marking), _all(all) { } | |
2109 }; | 2117 }; |
2110 | 2118 |
2111 void ConcurrentMark::print_reachable(bool use_prev_marking, const char* str) { | 2119 void ConcurrentMark::print_reachable(const char* str, |
2112 gclog_or_tty->print_cr("== Doing reachable object dump... "); | 2120 bool use_prev_marking, |
2121 bool all) { | |
2122 gclog_or_tty->cr(); | |
2123 gclog_or_tty->print_cr("== Doing heap dump... "); | |
2113 | 2124 |
2114 if (G1PrintReachableBaseFile == NULL) { | 2125 if (G1PrintReachableBaseFile == NULL) { |
2115 gclog_or_tty->print_cr(" #### error: no base file defined"); | 2126 gclog_or_tty->print_cr(" #### error: no base file defined"); |
2116 return; | 2127 return; |
2117 } | 2128 } |
2142 } | 2153 } |
2143 | 2154 |
2144 out->print_cr("-- USING %s", (use_prev_marking) ? "PTAMS" : "NTAMS"); | 2155 out->print_cr("-- USING %s", (use_prev_marking) ? "PTAMS" : "NTAMS"); |
2145 out->cr(); | 2156 out->cr(); |
2146 | 2157 |
2147 RegionReachablePrinterClosure rcl(bitmap, out, use_prev_marking); | 2158 out->print_cr("--- ITERATING OVER REGIONS"); |
2148 out->print_cr("--- ITERATING OVER REGIONS WITH TAMS < TOP"); | |
2149 out->cr(); | 2159 out->cr(); |
2160 PrintReachableRegionClosure rcl(bitmap, out, use_prev_marking, all); | |
2150 _g1h->heap_region_iterate(&rcl); | 2161 _g1h->heap_region_iterate(&rcl); |
2151 out->cr(); | 2162 out->cr(); |
2152 | 2163 |
2153 ReachablePrinterClosure cl(bitmap, out, use_prev_marking); | |
2154 out->print_cr("--- ITERATING OVER MARKED OBJECTS ON THE BITMAP"); | |
2155 out->cr(); | |
2156 bitmap->iterate(&cl); | |
2157 out->cr(); | |
2158 | |
2159 gclog_or_tty->print_cr(" done"); | 2164 gclog_or_tty->print_cr(" done"); |
2165 gclog_or_tty->flush(); | |
2160 } | 2166 } |
2161 | 2167 |
2162 #endif // PRODUCT | 2168 #endif // PRODUCT |
2163 | 2169 |
2164 // This note is for drainAllSATBBuffers and the code in between. | 2170 // This note is for drainAllSATBBuffers and the code in between. |