Tue, 19 Aug 2014 02:05:49 -0700
8044406: JVM crash with JDK8 (build 1.8.0-b132) with G1 GC
Summary: Fill the last card that has been allocated into with a dummy object
Reviewed-by: tschatzl, mgerdin
ysr@777 | 1 | /* |
tschatzl@6269 | 2 | * Copyright (c) 2001, 2014, 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; |
johnc@3175 | 37 | class ReferenceProcessor; |
ysr@777 | 38 | |
ysr@777 | 39 | // A class that scans oops in a given heap region (much as OopsInGenClosure |
ysr@777 | 40 | // scans oops in a generation.) |
tschatzl@6231 | 41 | class OopsInHeapRegionClosure: public ExtendedOopClosure { |
ysr@777 | 42 | protected: |
ysr@777 | 43 | HeapRegion* _from; |
ysr@777 | 44 | public: |
tonyp@2962 | 45 | void set_region(HeapRegion* from) { _from = from; } |
ysr@777 | 46 | }; |
ysr@777 | 47 | |
ysr@777 | 48 | class G1ParClosureSuper : public OopsInHeapRegionClosure { |
ysr@777 | 49 | protected: |
ysr@777 | 50 | G1CollectedHeap* _g1; |
ysr@777 | 51 | G1ParScanThreadState* _par_scan_state; |
johnc@3463 | 52 | uint _worker_id; |
ysr@777 | 53 | public: |
ysr@777 | 54 | G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); |
ysr@777 | 55 | bool apply_to_weak_ref_discovered_field() { return true; } |
ysr@777 | 56 | }; |
ysr@777 | 57 | |
iveresov@1696 | 58 | class G1ParPushHeapRSClosure : public G1ParClosureSuper { |
iveresov@1696 | 59 | public: |
johnc@3175 | 60 | G1ParPushHeapRSClosure(G1CollectedHeap* g1, |
johnc@3179 | 61 | G1ParScanThreadState* par_scan_state): |
johnc@3179 | 62 | G1ParClosureSuper(g1, par_scan_state) { } |
johnc@3175 | 63 | |
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: |
johnc@3175 | 71 | G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) : |
johnc@3175 | 72 | G1ParClosureSuper(g1, par_scan_state) |
johnc@3175 | 73 | { |
johnc@3175 | 74 | assert(_ref_processor == NULL, "sanity"); |
johnc@3175 | 75 | _ref_processor = rp; |
johnc@3175 | 76 | } |
johnc@3175 | 77 | |
ysr@1280 | 78 | template <class T> void do_oop_nv(T* p); |
ysr@777 | 79 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
ysr@777 | 80 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
ysr@777 | 81 | }; |
ysr@777 | 82 | |
coleenp@4037 | 83 | // Add back base class for metadata |
coleenp@4037 | 84 | class G1ParCopyHelper : public G1ParClosureSuper { |
tschatzl@6329 | 85 | protected: |
coleenp@4037 | 86 | Klass* _scanned_klass; |
tschatzl@6329 | 87 | ConcurrentMark* _cm; |
coleenp@4037 | 88 | |
tschatzl@6329 | 89 | // Mark the object if it's not already marked. This is used to mark |
tschatzl@6329 | 90 | // objects pointed to by roots that are guaranteed not to move |
tschatzl@6329 | 91 | // during the GC (i.e., non-CSet objects). It is MT-safe. |
tschatzl@6329 | 92 | void mark_object(oop obj); |
tschatzl@6329 | 93 | |
tschatzl@6329 | 94 | // Mark the object if it's not already marked. This is used to mark |
tschatzl@6329 | 95 | // objects pointed to by roots that have been forwarded during a |
tschatzl@6329 | 96 | // GC. It is MT-safe. |
tschatzl@6329 | 97 | void mark_forwarded_object(oop from_obj, oop to_obj); |
coleenp@4037 | 98 | public: |
tschatzl@6329 | 99 | G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); |
coleenp@4037 | 100 | |
coleenp@4037 | 101 | void set_scanned_klass(Klass* k) { _scanned_klass = k; } |
coleenp@4037 | 102 | template <class T> void do_klass_barrier(T* p, oop new_obj); |
coleenp@4037 | 103 | }; |
coleenp@4037 | 104 | |
tschatzl@6231 | 105 | template <G1Barrier barrier, bool do_mark_object> |
coleenp@4037 | 106 | class G1ParCopyClosure : public G1ParCopyHelper { |
tschatzl@6331 | 107 | private: |
brutisso@3690 | 108 | template <class T> void do_oop_work(T* p); |
ysr@777 | 109 | |
ysr@777 | 110 | public: |
johnc@3175 | 111 | G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, |
johnc@3175 | 112 | ReferenceProcessor* rp) : |
coleenp@4037 | 113 | G1ParCopyHelper(g1, par_scan_state) { |
johnc@3175 | 114 | assert(_ref_processor == NULL, "sanity"); |
johnc@3175 | 115 | } |
johnc@3175 | 116 | |
tschatzl@6329 | 117 | template <class T> void do_oop_nv(T* p) { do_oop_work(p); } |
ysr@777 | 118 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
ysr@777 | 119 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
ysr@777 | 120 | }; |
ysr@777 | 121 | |
tschatzl@6231 | 122 | typedef G1ParCopyClosure<G1BarrierNone, false> G1ParScanExtRootClosure; |
tschatzl@6231 | 123 | typedef G1ParCopyClosure<G1BarrierKlass, false> G1ParScanMetadataClosure; |
coleenp@4037 | 124 | |
johnc@3175 | 125 | |
tschatzl@6231 | 126 | typedef G1ParCopyClosure<G1BarrierNone, true> G1ParScanAndMarkExtRootClosure; |
tschatzl@6231 | 127 | typedef G1ParCopyClosure<G1BarrierKlass, true> G1ParScanAndMarkMetadataClosure; |
johnc@3175 | 128 | |
johnc@3175 | 129 | // We use a separate closure to handle references during evacuation |
johnc@3175 | 130 | // failure processing. |
johnc@3175 | 131 | |
tschatzl@6231 | 132 | typedef G1ParCopyClosure<G1BarrierEvac, false> G1ParScanHeapEvacFailureClosure; |
ysr@777 | 133 | |
coleenp@4037 | 134 | class FilterIntoCSClosure: public ExtendedOopClosure { |
ysr@777 | 135 | G1CollectedHeap* _g1; |
ysr@777 | 136 | OopClosure* _oc; |
ysr@777 | 137 | DirtyCardToOopClosure* _dcto_cl; |
ysr@777 | 138 | public: |
ysr@777 | 139 | FilterIntoCSClosure( DirtyCardToOopClosure* dcto_cl, |
johnc@3175 | 140 | G1CollectedHeap* g1, |
johnc@3179 | 141 | OopClosure* oc) : |
johnc@3179 | 142 | _dcto_cl(dcto_cl), _g1(g1), _oc(oc) { } |
johnc@3175 | 143 | |
ysr@1280 | 144 | template <class T> void do_oop_nv(T* p); |
ysr@1280 | 145 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
ysr@1280 | 146 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
ysr@777 | 147 | bool apply_to_weak_ref_discovered_field() { return true; } |
ysr@777 | 148 | }; |
ysr@777 | 149 | |
coleenp@4037 | 150 | class FilterOutOfRegionClosure: public ExtendedOopClosure { |
ysr@777 | 151 | HeapWord* _r_bottom; |
ysr@777 | 152 | HeapWord* _r_end; |
ysr@777 | 153 | OopClosure* _oc; |
ysr@777 | 154 | public: |
ysr@777 | 155 | FilterOutOfRegionClosure(HeapRegion* r, OopClosure* oc); |
ysr@1280 | 156 | template <class T> void do_oop_nv(T* p); |
ysr@1280 | 157 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
ysr@1280 | 158 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
ysr@777 | 159 | bool apply_to_weak_ref_discovered_field() { return true; } |
ysr@777 | 160 | }; |
stefank@2314 | 161 | |
tonyp@2968 | 162 | // Closure for iterating over object fields during concurrent marking |
coleenp@4037 | 163 | class G1CMOopClosure : public ExtendedOopClosure { |
tonyp@3464 | 164 | private: |
tonyp@2968 | 165 | G1CollectedHeap* _g1h; |
tonyp@2968 | 166 | ConcurrentMark* _cm; |
tonyp@2968 | 167 | CMTask* _task; |
tonyp@2968 | 168 | public: |
tonyp@2968 | 169 | G1CMOopClosure(G1CollectedHeap* g1h, ConcurrentMark* cm, CMTask* task); |
tonyp@2968 | 170 | template <class T> void do_oop_nv(T* p); |
tonyp@2968 | 171 | virtual void do_oop( oop* p) { do_oop_nv(p); } |
tonyp@2968 | 172 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
tonyp@2968 | 173 | }; |
tonyp@2968 | 174 | |
tonyp@3464 | 175 | // Closure to scan the root regions during concurrent marking |
coleenp@4037 | 176 | class G1RootRegionScanClosure : public ExtendedOopClosure { |
tonyp@3464 | 177 | private: |
tonyp@3464 | 178 | G1CollectedHeap* _g1h; |
tonyp@3464 | 179 | ConcurrentMark* _cm; |
tonyp@3464 | 180 | uint _worker_id; |
tonyp@3464 | 181 | public: |
tonyp@3464 | 182 | G1RootRegionScanClosure(G1CollectedHeap* g1h, ConcurrentMark* cm, |
tonyp@3464 | 183 | uint worker_id) : |
tonyp@3464 | 184 | _g1h(g1h), _cm(cm), _worker_id(worker_id) { } |
tonyp@3464 | 185 | template <class T> void do_oop_nv(T* p); |
tonyp@3464 | 186 | virtual void do_oop( oop* p) { do_oop_nv(p); } |
tonyp@3464 | 187 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
tonyp@3464 | 188 | }; |
tonyp@3464 | 189 | |
johnc@3466 | 190 | // Closure that applies the given two closures in sequence. |
johnc@3466 | 191 | // Used by the RSet refinement code (when updating RSets |
johnc@3466 | 192 | // during an evacuation pause) to record cards containing |
johnc@3466 | 193 | // pointers into the collection set. |
johnc@3466 | 194 | |
coleenp@4037 | 195 | class G1Mux2Closure : public ExtendedOopClosure { |
johnc@3466 | 196 | OopClosure* _c1; |
johnc@3466 | 197 | OopClosure* _c2; |
johnc@3466 | 198 | public: |
johnc@3466 | 199 | G1Mux2Closure(OopClosure *c1, OopClosure *c2); |
johnc@3466 | 200 | template <class T> void do_oop_nv(T* p); |
johnc@3466 | 201 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
johnc@3466 | 202 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
johnc@3466 | 203 | }; |
johnc@3466 | 204 | |
johnc@3466 | 205 | // A closure that returns true if it is actually applied |
johnc@3466 | 206 | // to a reference |
johnc@3466 | 207 | |
coleenp@4037 | 208 | class G1TriggerClosure : public ExtendedOopClosure { |
johnc@3466 | 209 | bool _triggered; |
johnc@3466 | 210 | public: |
johnc@3466 | 211 | G1TriggerClosure(); |
johnc@3466 | 212 | bool triggered() const { return _triggered; } |
johnc@3466 | 213 | template <class T> void do_oop_nv(T* p); |
johnc@3466 | 214 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
johnc@3466 | 215 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
johnc@3466 | 216 | }; |
johnc@3466 | 217 | |
johnc@3466 | 218 | // A closure which uses a triggering closure to determine |
johnc@3466 | 219 | // whether to apply an oop closure. |
johnc@3466 | 220 | |
coleenp@4037 | 221 | class G1InvokeIfNotTriggeredClosure: public ExtendedOopClosure { |
johnc@3466 | 222 | G1TriggerClosure* _trigger_cl; |
johnc@3466 | 223 | OopClosure* _oop_cl; |
johnc@3466 | 224 | public: |
johnc@3466 | 225 | G1InvokeIfNotTriggeredClosure(G1TriggerClosure* t, OopClosure* oc); |
johnc@3466 | 226 | template <class T> void do_oop_nv(T* p); |
johnc@3466 | 227 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
johnc@3466 | 228 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
johnc@3466 | 229 | }; |
johnc@3466 | 230 | |
coleenp@4037 | 231 | class G1UpdateRSOrPushRefOopClosure: public ExtendedOopClosure { |
johnc@3466 | 232 | G1CollectedHeap* _g1; |
johnc@3466 | 233 | G1RemSet* _g1_rem_set; |
johnc@3466 | 234 | HeapRegion* _from; |
johnc@3466 | 235 | OopsInHeapRegionClosure* _push_ref_cl; |
johnc@3466 | 236 | bool _record_refs_into_cset; |
vkempik@6552 | 237 | uint _worker_i; |
johnc@3466 | 238 | |
johnc@3466 | 239 | public: |
johnc@3466 | 240 | G1UpdateRSOrPushRefOopClosure(G1CollectedHeap* g1h, |
johnc@3466 | 241 | G1RemSet* rs, |
johnc@3466 | 242 | OopsInHeapRegionClosure* push_ref_cl, |
johnc@3466 | 243 | bool record_refs_into_cset, |
vkempik@6552 | 244 | uint worker_i = 0); |
johnc@3466 | 245 | |
johnc@3466 | 246 | void set_from(HeapRegion* from) { |
johnc@3466 | 247 | assert(from != NULL, "from region must be non-NULL"); |
johnc@3466 | 248 | _from = from; |
johnc@3466 | 249 | } |
johnc@3466 | 250 | |
johnc@3466 | 251 | bool self_forwarded(oop obj) { |
johnc@3466 | 252 | bool result = (obj->is_forwarded() && (obj->forwardee()== obj)); |
johnc@3466 | 253 | return result; |
johnc@3466 | 254 | } |
johnc@3466 | 255 | |
johnc@3466 | 256 | bool apply_to_weak_ref_discovered_field() { return true; } |
johnc@3466 | 257 | |
johnc@3466 | 258 | template <class T> void do_oop_nv(T* p); |
johnc@3466 | 259 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
johnc@3466 | 260 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
johnc@3466 | 261 | }; |
johnc@3466 | 262 | |
stefank@2314 | 263 | #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_HPP |