Wed, 02 Nov 2011 08:04:23 +0100
7106751: G1: gc/gctests/nativeGC03 crashes VM with SIGSEGV
Summary: _cset_rs_update_cl[] was indexed with values beyond what it is set up to handle.
Reviewed-by: ysr, jmasa, johnc
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; |
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.) |
ysr@777 | 41 | class OopsInHeapRegionClosure: public OopsInGenClosure { |
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 | G1RemSet* _g1_rem; |
ysr@777 | 52 | ConcurrentMark* _cm; |
ysr@777 | 53 | G1ParScanThreadState* _par_scan_state; |
johnc@3086 | 54 | bool _during_initial_mark; |
johnc@3086 | 55 | bool _mark_in_progress; |
ysr@777 | 56 | public: |
ysr@777 | 57 | G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); |
ysr@777 | 58 | bool apply_to_weak_ref_discovered_field() { return true; } |
ysr@777 | 59 | }; |
ysr@777 | 60 | |
iveresov@1696 | 61 | class G1ParPushHeapRSClosure : public G1ParClosureSuper { |
iveresov@1696 | 62 | public: |
johnc@3175 | 63 | G1ParPushHeapRSClosure(G1CollectedHeap* g1, |
johnc@3179 | 64 | G1ParScanThreadState* par_scan_state): |
johnc@3179 | 65 | G1ParClosureSuper(g1, par_scan_state) { } |
johnc@3175 | 66 | |
iveresov@1696 | 67 | template <class T> void do_oop_nv(T* p); |
iveresov@1696 | 68 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
iveresov@1696 | 69 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
iveresov@1696 | 70 | }; |
iveresov@1696 | 71 | |
ysr@777 | 72 | class G1ParScanClosure : public G1ParClosureSuper { |
ysr@777 | 73 | public: |
johnc@3175 | 74 | G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) : |
johnc@3175 | 75 | G1ParClosureSuper(g1, par_scan_state) |
johnc@3175 | 76 | { |
johnc@3175 | 77 | assert(_ref_processor == NULL, "sanity"); |
johnc@3175 | 78 | _ref_processor = rp; |
johnc@3175 | 79 | } |
johnc@3175 | 80 | |
ysr@1280 | 81 | template <class T> void do_oop_nv(T* p); |
ysr@777 | 82 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
ysr@777 | 83 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
ysr@777 | 84 | }; |
ysr@777 | 85 | |
ysr@1280 | 86 | #define G1_PARTIAL_ARRAY_MASK 0x2 |
ysr@777 | 87 | |
ysr@1280 | 88 | template <class T> inline bool has_partial_array_mask(T* ref) { |
ysr@1280 | 89 | return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; |
tonyp@961 | 90 | } |
tonyp@961 | 91 | |
ysr@1280 | 92 | template <class T> inline T* set_partial_array_mask(T obj) { |
ysr@1280 | 93 | assert(((uintptr_t)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); |
ysr@1280 | 94 | return (T*) ((uintptr_t)obj | G1_PARTIAL_ARRAY_MASK); |
tonyp@961 | 95 | } |
tonyp@961 | 96 | |
ysr@1280 | 97 | template <class T> inline oop clear_partial_array_mask(T* ref) { |
ysr@1280 | 98 | return oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); |
tonyp@961 | 99 | } |
tonyp@961 | 100 | |
ysr@777 | 101 | class G1ParScanPartialArrayClosure : public G1ParClosureSuper { |
ysr@777 | 102 | G1ParScanClosure _scanner; |
johnc@3175 | 103 | |
ysr@777 | 104 | public: |
johnc@3175 | 105 | G1ParScanPartialArrayClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) : |
johnc@3175 | 106 | G1ParClosureSuper(g1, par_scan_state), _scanner(g1, par_scan_state, rp) |
johnc@3175 | 107 | { |
johnc@3175 | 108 | assert(_ref_processor == NULL, "sanity"); |
johnc@3175 | 109 | } |
johnc@3175 | 110 | |
johnc@3175 | 111 | G1ParScanClosure* scanner() { |
johnc@3175 | 112 | return &_scanner; |
johnc@3175 | 113 | } |
johnc@3175 | 114 | |
ysr@1280 | 115 | template <class T> void do_oop_nv(T* p); |
ysr@777 | 116 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
ysr@777 | 117 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
ysr@777 | 118 | }; |
ysr@777 | 119 | |
ysr@777 | 120 | |
ysr@777 | 121 | class G1ParCopyHelper : public G1ParClosureSuper { |
ysr@777 | 122 | G1ParScanClosure *_scanner; |
ysr@777 | 123 | protected: |
johnc@3086 | 124 | template <class T> void mark_object(T* p); |
johnc@3169 | 125 | oop copy_to_survivor_space(oop obj, bool should_mark_root, |
johnc@3169 | 126 | bool should_mark_copy); |
ysr@777 | 127 | public: |
ysr@777 | 128 | G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, |
ysr@777 | 129 | G1ParScanClosure *scanner) : |
ysr@777 | 130 | G1ParClosureSuper(g1, par_scan_state), _scanner(scanner) { } |
ysr@777 | 131 | }; |
ysr@777 | 132 | |
tonyp@961 | 133 | template<bool do_gen_barrier, G1Barrier barrier, |
johnc@3086 | 134 | bool do_mark_object> |
ysr@777 | 135 | class G1ParCopyClosure : public G1ParCopyHelper { |
ysr@777 | 136 | G1ParScanClosure _scanner; |
johnc@3175 | 137 | |
ysr@1280 | 138 | template <class T> void do_oop_work(T* p); |
johnc@3175 | 139 | |
ysr@777 | 140 | public: |
johnc@3175 | 141 | G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, |
johnc@3175 | 142 | ReferenceProcessor* rp) : |
johnc@3175 | 143 | _scanner(g1, par_scan_state, rp), |
johnc@3175 | 144 | G1ParCopyHelper(g1, par_scan_state, &_scanner) |
johnc@3175 | 145 | { |
johnc@3175 | 146 | assert(_ref_processor == NULL, "sanity"); |
johnc@3175 | 147 | } |
johnc@3175 | 148 | |
johnc@3175 | 149 | G1ParScanClosure* scanner() { return &_scanner; } |
johnc@3175 | 150 | |
ysr@1280 | 151 | template <class T> void do_oop_nv(T* p) { |
ysr@777 | 152 | do_oop_work(p); |
ysr@777 | 153 | } |
ysr@777 | 154 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
ysr@777 | 155 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
ysr@777 | 156 | }; |
ysr@777 | 157 | |
iveresov@1696 | 158 | typedef G1ParCopyClosure<false, G1BarrierNone, false> G1ParScanExtRootClosure; |
iveresov@1696 | 159 | typedef G1ParCopyClosure<true, G1BarrierNone, false> G1ParScanPermClosure; |
johnc@3175 | 160 | |
iveresov@1696 | 161 | typedef G1ParCopyClosure<false, G1BarrierNone, true> G1ParScanAndMarkExtRootClosure; |
iveresov@1696 | 162 | typedef G1ParCopyClosure<true, G1BarrierNone, true> G1ParScanAndMarkPermClosure; |
iveresov@1696 | 163 | |
johnc@3175 | 164 | // The following closure types are no longer used but are retained |
johnc@3175 | 165 | // for historical reasons: |
johnc@3175 | 166 | // typedef G1ParCopyClosure<false, G1BarrierRS, false> G1ParScanHeapRSClosure; |
johnc@3175 | 167 | // typedef G1ParCopyClosure<false, G1BarrierRS, true> G1ParScanAndMarkHeapRSClosure; |
johnc@3175 | 168 | |
johnc@3175 | 169 | // The following closure type is defined in g1_specialized_oop_closures.hpp: |
johnc@3175 | 170 | // |
johnc@3175 | 171 | // typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacClosure; |
johnc@3175 | 172 | |
johnc@3175 | 173 | // We use a separate closure to handle references during evacuation |
johnc@3175 | 174 | // failure processing. |
johnc@3175 | 175 | // We could have used another instance of G1ParScanHeapEvacClosure |
johnc@3175 | 176 | // (since that closure no longer assumes that the references it |
johnc@3175 | 177 | // handles point into the collection set). |
johnc@3175 | 178 | |
iveresov@1696 | 179 | typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacFailureClosure; |
ysr@777 | 180 | |
ysr@777 | 181 | class FilterIntoCSClosure: public OopClosure { |
ysr@777 | 182 | G1CollectedHeap* _g1; |
ysr@777 | 183 | OopClosure* _oc; |
ysr@777 | 184 | DirtyCardToOopClosure* _dcto_cl; |
ysr@777 | 185 | public: |
ysr@777 | 186 | FilterIntoCSClosure( DirtyCardToOopClosure* dcto_cl, |
johnc@3175 | 187 | G1CollectedHeap* g1, |
johnc@3179 | 188 | OopClosure* oc) : |
johnc@3179 | 189 | _dcto_cl(dcto_cl), _g1(g1), _oc(oc) { } |
johnc@3175 | 190 | |
ysr@1280 | 191 | template <class T> void do_oop_nv(T* p); |
ysr@1280 | 192 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
ysr@1280 | 193 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
ysr@777 | 194 | bool apply_to_weak_ref_discovered_field() { return true; } |
ysr@777 | 195 | bool do_header() { return false; } |
ysr@777 | 196 | }; |
ysr@777 | 197 | |
ysr@777 | 198 | class FilterOutOfRegionClosure: public OopClosure { |
ysr@777 | 199 | HeapWord* _r_bottom; |
ysr@777 | 200 | HeapWord* _r_end; |
ysr@777 | 201 | OopClosure* _oc; |
ysr@777 | 202 | int _out_of_region; |
ysr@777 | 203 | public: |
ysr@777 | 204 | FilterOutOfRegionClosure(HeapRegion* r, OopClosure* oc); |
ysr@1280 | 205 | template <class T> void do_oop_nv(T* p); |
ysr@1280 | 206 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
ysr@1280 | 207 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
ysr@777 | 208 | bool apply_to_weak_ref_discovered_field() { return true; } |
ysr@777 | 209 | bool do_header() { return false; } |
ysr@777 | 210 | int out_of_region() { return _out_of_region; } |
ysr@777 | 211 | }; |
stefank@2314 | 212 | |
tonyp@2968 | 213 | // Closure for iterating over object fields during concurrent marking |
tonyp@2968 | 214 | class G1CMOopClosure : public OopClosure { |
tonyp@2968 | 215 | G1CollectedHeap* _g1h; |
tonyp@2968 | 216 | ConcurrentMark* _cm; |
tonyp@2968 | 217 | CMTask* _task; |
tonyp@2968 | 218 | public: |
tonyp@2968 | 219 | G1CMOopClosure(G1CollectedHeap* g1h, ConcurrentMark* cm, CMTask* task); |
tonyp@2968 | 220 | template <class T> void do_oop_nv(T* p); |
tonyp@2968 | 221 | virtual void do_oop( oop* p) { do_oop_nv(p); } |
tonyp@2968 | 222 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
tonyp@2968 | 223 | }; |
tonyp@2968 | 224 | |
stefank@2314 | 225 | #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_HPP |