src/share/vm/gc_implementation/g1/g1OopClosures.hpp

Fri, 02 Oct 2009 16:12:07 -0400

author
tonyp
date
Fri, 02 Oct 2009 16:12:07 -0400
changeset 1454
035d2e036a9b
parent 1280
df6caf649ff7
child 1696
0414c1049f15
permissions
-rw-r--r--

6885041: G1: inconsistent thread dump
Summary: When G1 is enabled, thread dumps are inconsistent as the info for some of the G1 threads is not formatted properly.
Reviewed-by: ysr, johnc

ysr@777 1 /*
xdono@1014 2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
ysr@777 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@777 4 *
ysr@777 5 * This code is free software; you can redistribute it and/or modify it
ysr@777 6 * under the terms of the GNU General Public License version 2 only, as
ysr@777 7 * published by the Free Software Foundation.
ysr@777 8 *
ysr@777 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@777 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@777 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@777 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@777 13 * accompanied this code).
ysr@777 14 *
ysr@777 15 * You should have received a copy of the GNU General Public License version
ysr@777 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@777 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@777 18 *
ysr@777 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
ysr@777 20 * CA 95054 USA or visit www.sun.com if you need additional information or
ysr@777 21 * have any questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
ysr@777 25 class HeapRegion;
ysr@777 26 class G1CollectedHeap;
ysr@777 27 class G1RemSet;
ysr@777 28 class HRInto_G1RemSet;
ysr@777 29 class G1RemSet;
ysr@777 30 class ConcurrentMark;
ysr@777 31 class DirtyCardToOopClosure;
ysr@777 32 class CMBitMap;
ysr@777 33 class CMMarkStack;
ysr@777 34 class G1ParScanThreadState;
ysr@777 35
ysr@777 36 // A class that scans oops in a given heap region (much as OopsInGenClosure
ysr@777 37 // scans oops in a generation.)
ysr@777 38 class OopsInHeapRegionClosure: public OopsInGenClosure {
ysr@777 39 protected:
ysr@777 40 HeapRegion* _from;
ysr@777 41 public:
ysr@777 42 virtual void set_region(HeapRegion* from) { _from = from; }
ysr@777 43 };
ysr@777 44
ysr@777 45 class G1ParClosureSuper : public OopsInHeapRegionClosure {
ysr@777 46 protected:
ysr@777 47 G1CollectedHeap* _g1;
ysr@777 48 G1RemSet* _g1_rem;
ysr@777 49 ConcurrentMark* _cm;
ysr@777 50 G1ParScanThreadState* _par_scan_state;
ysr@777 51 public:
ysr@777 52 G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state);
ysr@777 53 bool apply_to_weak_ref_discovered_field() { return true; }
ysr@777 54 };
ysr@777 55
ysr@777 56 class G1ParScanClosure : public G1ParClosureSuper {
ysr@777 57 public:
ysr@777 58 G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
ysr@777 59 G1ParClosureSuper(g1, par_scan_state) { }
ysr@1280 60 template <class T> void do_oop_nv(T* p);
ysr@777 61 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@777 62 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 63 };
ysr@777 64
ysr@1280 65 #define G1_PARTIAL_ARRAY_MASK 0x2
ysr@777 66
ysr@1280 67 template <class T> inline bool has_partial_array_mask(T* ref) {
ysr@1280 68 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
tonyp@961 69 }
tonyp@961 70
ysr@1280 71 template <class T> inline T* set_partial_array_mask(T obj) {
ysr@1280 72 assert(((uintptr_t)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!");
ysr@1280 73 return (T*) ((uintptr_t)obj | G1_PARTIAL_ARRAY_MASK);
tonyp@961 74 }
tonyp@961 75
ysr@1280 76 template <class T> inline oop clear_partial_array_mask(T* ref) {
ysr@1280 77 return oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK);
tonyp@961 78 }
tonyp@961 79
ysr@777 80 class G1ParScanPartialArrayClosure : public G1ParClosureSuper {
ysr@777 81 G1ParScanClosure _scanner;
ysr@777 82 public:
ysr@777 83 G1ParScanPartialArrayClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
ysr@777 84 G1ParClosureSuper(g1, par_scan_state), _scanner(g1, par_scan_state) { }
ysr@1280 85 template <class T> void do_oop_nv(T* p);
ysr@777 86 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@777 87 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 88 };
ysr@777 89
ysr@777 90
ysr@777 91 class G1ParCopyHelper : public G1ParClosureSuper {
ysr@777 92 G1ParScanClosure *_scanner;
ysr@777 93 protected:
ysr@1280 94 template <class T> void mark_forwardee(T* p);
ysr@777 95 oop copy_to_survivor_space(oop obj);
ysr@777 96 public:
ysr@777 97 G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state,
ysr@777 98 G1ParScanClosure *scanner) :
ysr@777 99 G1ParClosureSuper(g1, par_scan_state), _scanner(scanner) { }
ysr@777 100 };
ysr@777 101
tonyp@961 102 template<bool do_gen_barrier, G1Barrier barrier,
tonyp@961 103 bool do_mark_forwardee, bool skip_cset_test>
ysr@777 104 class G1ParCopyClosure : public G1ParCopyHelper {
ysr@777 105 G1ParScanClosure _scanner;
ysr@1280 106 template <class T> void do_oop_work(T* p);
ysr@777 107 public:
ysr@777 108 G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
ysr@777 109 _scanner(g1, par_scan_state), G1ParCopyHelper(g1, par_scan_state, &_scanner) { }
ysr@1280 110 template <class T> void do_oop_nv(T* p) {
ysr@777 111 do_oop_work(p);
ysr@777 112 if (do_mark_forwardee)
ysr@777 113 mark_forwardee(p);
ysr@777 114 }
ysr@777 115 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@777 116 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 117 };
ysr@777 118
tonyp@961 119 typedef G1ParCopyClosure<false, G1BarrierNone, false, false> G1ParScanExtRootClosure;
tonyp@961 120 typedef G1ParCopyClosure<true, G1BarrierNone, false, false> G1ParScanPermClosure;
ysr@1280 121 typedef G1ParCopyClosure<false, G1BarrierRS, false, false> G1ParScanHeapRSClosure;
tonyp@961 122 typedef G1ParCopyClosure<false, G1BarrierNone, true, false> G1ParScanAndMarkExtRootClosure;
tonyp@961 123 typedef G1ParCopyClosure<true, G1BarrierNone, true, false> G1ParScanAndMarkPermClosure;
tonyp@961 124 typedef G1ParCopyClosure<false, G1BarrierRS, true, false> G1ParScanAndMarkHeapRSClosure;
tonyp@961 125 // This is the only case when we set skip_cset_test. Basically, this
tonyp@961 126 // closure is (should?) only be called directly while we're draining
tonyp@961 127 // the overflow and task queues. In that case we know that the
tonyp@961 128 // reference in question points into the collection set, otherwise we
ysr@1280 129 // would not have pushed it on the queue. The following is defined in
ysr@1280 130 // g1_specialized_oop_closures.hpp.
ysr@1280 131 // typedef G1ParCopyClosure<false, G1BarrierEvac, false, true> G1ParScanHeapEvacClosure;
tonyp@961 132 // We need a separate closure to handle references during evacuation
ysr@1280 133 // failure processing, as we cannot asume that the reference already
ysr@1280 134 // points into the collection set (like G1ParScanHeapEvacClosure does).
tonyp@961 135 typedef G1ParCopyClosure<false, G1BarrierEvac, false, false> G1ParScanHeapEvacFailureClosure;
ysr@777 136
ysr@777 137 class FilterIntoCSClosure: public OopClosure {
ysr@777 138 G1CollectedHeap* _g1;
ysr@777 139 OopClosure* _oc;
ysr@777 140 DirtyCardToOopClosure* _dcto_cl;
ysr@777 141 public:
ysr@777 142 FilterIntoCSClosure( DirtyCardToOopClosure* dcto_cl,
ysr@777 143 G1CollectedHeap* g1, OopClosure* oc) :
ysr@777 144 _dcto_cl(dcto_cl), _g1(g1), _oc(oc)
ysr@777 145 {}
ysr@1280 146 template <class T> void do_oop_nv(T* p);
ysr@1280 147 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@1280 148 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 149 bool apply_to_weak_ref_discovered_field() { return true; }
ysr@777 150 bool do_header() { return false; }
ysr@777 151 };
ysr@777 152
ysr@777 153 class FilterInHeapRegionAndIntoCSClosure : public OopsInHeapRegionClosure {
ysr@777 154 G1CollectedHeap* _g1;
ysr@777 155 OopsInHeapRegionClosure* _oc;
ysr@777 156 public:
ysr@777 157 FilterInHeapRegionAndIntoCSClosure(G1CollectedHeap* g1,
ysr@777 158 OopsInHeapRegionClosure* oc) :
ysr@777 159 _g1(g1), _oc(oc)
ysr@777 160 {}
ysr@1280 161 template <class T> void do_oop_nv(T* p);
ysr@1280 162 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@1280 163 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 164 bool apply_to_weak_ref_discovered_field() { return true; }
ysr@777 165 bool do_header() { return false; }
ysr@777 166 void set_region(HeapRegion* from) {
ysr@777 167 _oc->set_region(from);
ysr@777 168 }
ysr@777 169 };
ysr@777 170
ysr@777 171 class FilterAndMarkInHeapRegionAndIntoCSClosure : public OopsInHeapRegionClosure {
ysr@777 172 G1CollectedHeap* _g1;
ysr@777 173 ConcurrentMark* _cm;
ysr@777 174 OopsInHeapRegionClosure* _oc;
ysr@777 175 public:
ysr@777 176 FilterAndMarkInHeapRegionAndIntoCSClosure(G1CollectedHeap* g1,
ysr@777 177 OopsInHeapRegionClosure* oc,
ysr@777 178 ConcurrentMark* cm)
ysr@777 179 : _g1(g1), _oc(oc), _cm(cm) { }
ysr@777 180
ysr@1280 181 template <class T> void do_oop_nv(T* p);
ysr@1280 182 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@1280 183 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 184 bool apply_to_weak_ref_discovered_field() { return true; }
ysr@777 185 bool do_header() { return false; }
ysr@777 186 void set_region(HeapRegion* from) {
ysr@777 187 _oc->set_region(from);
ysr@777 188 }
ysr@777 189 };
ysr@777 190
ysr@777 191 class FilterOutOfRegionClosure: public OopClosure {
ysr@777 192 HeapWord* _r_bottom;
ysr@777 193 HeapWord* _r_end;
ysr@777 194 OopClosure* _oc;
ysr@777 195 int _out_of_region;
ysr@777 196 public:
ysr@777 197 FilterOutOfRegionClosure(HeapRegion* r, OopClosure* oc);
ysr@1280 198 template <class T> void do_oop_nv(T* p);
ysr@1280 199 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@1280 200 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 201 bool apply_to_weak_ref_discovered_field() { return true; }
ysr@777 202 bool do_header() { return false; }
ysr@777 203 int out_of_region() { return _out_of_region; }
ysr@777 204 };

mercurial