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

Tue, 20 Sep 2011 15:39:17 -0700

author
johnc
date
Tue, 20 Sep 2011 15:39:17 -0700
changeset 3169
663cb89032b1
parent 3086
eeae91c9baba
child 3175
4dfb2df418f2
permissions
-rw-r--r--

7092412: G1: Some roots not marked during an initial mark that gets an evacuation failure
Summary: As a result of the changes for 7080389, an evacuation failure during an initial mark pause may result in some root objects not being marked. Pass whether the caller is a root scanning closure into the evacuation failure handling code so that the thread that successfully forwards an object to itself also marks the object.
Reviewed-by: ysr, brutisso, tonyp

ysr@777 1 /*
tonyp@2962 2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_HPP
stefank@2314 27
ysr@777 28 class HeapRegion;
ysr@777 29 class G1CollectedHeap;
ysr@777 30 class G1RemSet;
ysr@777 31 class ConcurrentMark;
ysr@777 32 class DirtyCardToOopClosure;
ysr@777 33 class CMBitMap;
ysr@777 34 class CMMarkStack;
ysr@777 35 class G1ParScanThreadState;
tonyp@2968 36 class CMTask;
ysr@777 37
ysr@777 38 // A class that scans oops in a given heap region (much as OopsInGenClosure
ysr@777 39 // scans oops in a generation.)
ysr@777 40 class OopsInHeapRegionClosure: public OopsInGenClosure {
ysr@777 41 protected:
ysr@777 42 HeapRegion* _from;
ysr@777 43 public:
tonyp@2962 44 void set_region(HeapRegion* from) { _from = from; }
ysr@777 45 };
ysr@777 46
ysr@777 47 class G1ParClosureSuper : public OopsInHeapRegionClosure {
ysr@777 48 protected:
ysr@777 49 G1CollectedHeap* _g1;
ysr@777 50 G1RemSet* _g1_rem;
ysr@777 51 ConcurrentMark* _cm;
ysr@777 52 G1ParScanThreadState* _par_scan_state;
johnc@3086 53 bool _during_initial_mark;
johnc@3086 54 bool _mark_in_progress;
ysr@777 55 public:
ysr@777 56 G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state);
ysr@777 57 bool apply_to_weak_ref_discovered_field() { return true; }
ysr@777 58 };
ysr@777 59
iveresov@1696 60 class G1ParPushHeapRSClosure : public G1ParClosureSuper {
iveresov@1696 61 public:
iveresov@1696 62 G1ParPushHeapRSClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
iveresov@1696 63 G1ParClosureSuper(g1, par_scan_state) { }
iveresov@1696 64 template <class T> void do_oop_nv(T* p);
iveresov@1696 65 virtual void do_oop(oop* p) { do_oop_nv(p); }
iveresov@1696 66 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
iveresov@1696 67 };
iveresov@1696 68
ysr@777 69 class G1ParScanClosure : public G1ParClosureSuper {
ysr@777 70 public:
ysr@777 71 G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
ysr@777 72 G1ParClosureSuper(g1, par_scan_state) { }
ysr@1280 73 template <class T> void do_oop_nv(T* p);
ysr@777 74 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@777 75 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 76 };
ysr@777 77
ysr@1280 78 #define G1_PARTIAL_ARRAY_MASK 0x2
ysr@777 79
ysr@1280 80 template <class T> inline bool has_partial_array_mask(T* ref) {
ysr@1280 81 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
tonyp@961 82 }
tonyp@961 83
ysr@1280 84 template <class T> inline T* set_partial_array_mask(T obj) {
ysr@1280 85 assert(((uintptr_t)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!");
ysr@1280 86 return (T*) ((uintptr_t)obj | G1_PARTIAL_ARRAY_MASK);
tonyp@961 87 }
tonyp@961 88
ysr@1280 89 template <class T> inline oop clear_partial_array_mask(T* ref) {
ysr@1280 90 return oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK);
tonyp@961 91 }
tonyp@961 92
ysr@777 93 class G1ParScanPartialArrayClosure : public G1ParClosureSuper {
ysr@777 94 G1ParScanClosure _scanner;
ysr@777 95 public:
ysr@777 96 G1ParScanPartialArrayClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
ysr@777 97 G1ParClosureSuper(g1, par_scan_state), _scanner(g1, par_scan_state) { }
ysr@1280 98 template <class T> void do_oop_nv(T* p);
ysr@777 99 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@777 100 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 101 };
ysr@777 102
ysr@777 103
ysr@777 104 class G1ParCopyHelper : public G1ParClosureSuper {
ysr@777 105 G1ParScanClosure *_scanner;
ysr@777 106 protected:
johnc@3086 107 template <class T> void mark_object(T* p);
johnc@3169 108 oop copy_to_survivor_space(oop obj, bool should_mark_root,
johnc@3169 109 bool should_mark_copy);
ysr@777 110 public:
ysr@777 111 G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state,
ysr@777 112 G1ParScanClosure *scanner) :
ysr@777 113 G1ParClosureSuper(g1, par_scan_state), _scanner(scanner) { }
ysr@777 114 };
ysr@777 115
tonyp@961 116 template<bool do_gen_barrier, G1Barrier barrier,
johnc@3086 117 bool do_mark_object>
ysr@777 118 class G1ParCopyClosure : public G1ParCopyHelper {
ysr@777 119 G1ParScanClosure _scanner;
ysr@1280 120 template <class T> void do_oop_work(T* p);
ysr@777 121 public:
ysr@777 122 G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
ysr@777 123 _scanner(g1, par_scan_state), G1ParCopyHelper(g1, par_scan_state, &_scanner) { }
ysr@1280 124 template <class T> void do_oop_nv(T* p) {
ysr@777 125 do_oop_work(p);
ysr@777 126 }
ysr@777 127 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@777 128 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 129 };
ysr@777 130
iveresov@1696 131 typedef G1ParCopyClosure<false, G1BarrierNone, false> G1ParScanExtRootClosure;
iveresov@1696 132 typedef G1ParCopyClosure<true, G1BarrierNone, false> G1ParScanPermClosure;
iveresov@1696 133 typedef G1ParCopyClosure<false, G1BarrierRS, false> G1ParScanHeapRSClosure;
iveresov@1696 134 typedef G1ParCopyClosure<false, G1BarrierNone, true> G1ParScanAndMarkExtRootClosure;
iveresov@1696 135 typedef G1ParCopyClosure<true, G1BarrierNone, true> G1ParScanAndMarkPermClosure;
iveresov@1696 136 typedef G1ParCopyClosure<false, G1BarrierRS, true> G1ParScanAndMarkHeapRSClosure;
iveresov@1696 137
tonyp@961 138 // This is the only case when we set skip_cset_test. Basically, this
tonyp@961 139 // closure is (should?) only be called directly while we're draining
tonyp@961 140 // the overflow and task queues. In that case we know that the
tonyp@961 141 // reference in question points into the collection set, otherwise we
ysr@1280 142 // would not have pushed it on the queue. The following is defined in
ysr@1280 143 // g1_specialized_oop_closures.hpp.
ysr@1280 144 // typedef G1ParCopyClosure<false, G1BarrierEvac, false, true> G1ParScanHeapEvacClosure;
tonyp@961 145 // We need a separate closure to handle references during evacuation
ysr@1280 146 // failure processing, as we cannot asume that the reference already
ysr@1280 147 // points into the collection set (like G1ParScanHeapEvacClosure does).
iveresov@1696 148 typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacFailureClosure;
ysr@777 149
ysr@777 150 class FilterIntoCSClosure: public OopClosure {
ysr@777 151 G1CollectedHeap* _g1;
ysr@777 152 OopClosure* _oc;
ysr@777 153 DirtyCardToOopClosure* _dcto_cl;
ysr@777 154 public:
ysr@777 155 FilterIntoCSClosure( DirtyCardToOopClosure* dcto_cl,
ysr@777 156 G1CollectedHeap* g1, OopClosure* oc) :
ysr@777 157 _dcto_cl(dcto_cl), _g1(g1), _oc(oc)
ysr@777 158 {}
ysr@1280 159 template <class T> void do_oop_nv(T* p);
ysr@1280 160 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@1280 161 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 162 bool apply_to_weak_ref_discovered_field() { return true; }
ysr@777 163 bool do_header() { return false; }
ysr@777 164 };
ysr@777 165
ysr@777 166 class FilterOutOfRegionClosure: public OopClosure {
ysr@777 167 HeapWord* _r_bottom;
ysr@777 168 HeapWord* _r_end;
ysr@777 169 OopClosure* _oc;
ysr@777 170 int _out_of_region;
ysr@777 171 public:
ysr@777 172 FilterOutOfRegionClosure(HeapRegion* r, OopClosure* oc);
ysr@1280 173 template <class T> void do_oop_nv(T* p);
ysr@1280 174 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@1280 175 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 176 bool apply_to_weak_ref_discovered_field() { return true; }
ysr@777 177 bool do_header() { return false; }
ysr@777 178 int out_of_region() { return _out_of_region; }
ysr@777 179 };
stefank@2314 180
tonyp@2968 181 // Closure for iterating over object fields during concurrent marking
tonyp@2968 182 class G1CMOopClosure : public OopClosure {
tonyp@2968 183 G1CollectedHeap* _g1h;
tonyp@2968 184 ConcurrentMark* _cm;
tonyp@2968 185 CMTask* _task;
tonyp@2968 186 public:
tonyp@2968 187 G1CMOopClosure(G1CollectedHeap* g1h, ConcurrentMark* cm, CMTask* task);
tonyp@2968 188 template <class T> void do_oop_nv(T* p);
tonyp@2968 189 virtual void do_oop( oop* p) { do_oop_nv(p); }
tonyp@2968 190 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
tonyp@2968 191 };
tonyp@2968 192
stefank@2314 193 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_HPP

mercurial