Wed, 25 Mar 2009 13:10:54 -0700
6543938: G1: remove the concept of popularity
Reviewed-by: iveresov, tonyp
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 | |
ysr@777 | 46 | class G1ScanAndBalanceClosure : public OopClosure { |
ysr@777 | 47 | G1CollectedHeap* _g1; |
ysr@777 | 48 | static int _nq; |
ysr@777 | 49 | public: |
ysr@777 | 50 | G1ScanAndBalanceClosure(G1CollectedHeap* g1) : _g1(g1) { } |
ysr@777 | 51 | inline void do_oop_nv(oop* p); |
ysr@777 | 52 | inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 53 | virtual void do_oop(oop* p); |
ysr@777 | 54 | virtual void do_oop(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 55 | }; |
ysr@777 | 56 | |
ysr@777 | 57 | class G1ParClosureSuper : public OopsInHeapRegionClosure { |
ysr@777 | 58 | protected: |
ysr@777 | 59 | G1CollectedHeap* _g1; |
ysr@777 | 60 | G1RemSet* _g1_rem; |
ysr@777 | 61 | ConcurrentMark* _cm; |
ysr@777 | 62 | G1ParScanThreadState* _par_scan_state; |
ysr@777 | 63 | public: |
ysr@777 | 64 | G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); |
ysr@777 | 65 | bool apply_to_weak_ref_discovered_field() { return true; } |
ysr@777 | 66 | }; |
ysr@777 | 67 | |
ysr@777 | 68 | class G1ParScanClosure : public G1ParClosureSuper { |
ysr@777 | 69 | public: |
ysr@777 | 70 | G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : |
ysr@777 | 71 | G1ParClosureSuper(g1, par_scan_state) { } |
ysr@777 | 72 | void do_oop_nv(oop* p); // should be made inline |
ysr@777 | 73 | inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); } |
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@777 | 78 | #define G1_PARTIAL_ARRAY_MASK 1 |
ysr@777 | 79 | |
tonyp@961 | 80 | inline bool has_partial_array_mask(oop* ref) { |
tonyp@961 | 81 | return (intptr_t) ref & G1_PARTIAL_ARRAY_MASK; |
tonyp@961 | 82 | } |
tonyp@961 | 83 | |
tonyp@961 | 84 | inline oop* set_partial_array_mask(oop obj) { |
tonyp@961 | 85 | return (oop*) ((intptr_t) obj | G1_PARTIAL_ARRAY_MASK); |
tonyp@961 | 86 | } |
tonyp@961 | 87 | |
tonyp@961 | 88 | inline oop clear_partial_array_mask(oop* ref) { |
tonyp@961 | 89 | return oop((intptr_t) ref & ~G1_PARTIAL_ARRAY_MASK); |
tonyp@961 | 90 | } |
tonyp@961 | 91 | |
ysr@777 | 92 | class G1ParScanPartialArrayClosure : public G1ParClosureSuper { |
ysr@777 | 93 | G1ParScanClosure _scanner; |
ysr@777 | 94 | template <class T> void process_array_chunk(oop obj, int start, int end); |
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@777 | 98 | void do_oop_nv(oop* p); |
ysr@777 | 99 | void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 100 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
ysr@777 | 101 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
ysr@777 | 102 | }; |
ysr@777 | 103 | |
ysr@777 | 104 | |
ysr@777 | 105 | class G1ParCopyHelper : public G1ParClosureSuper { |
ysr@777 | 106 | G1ParScanClosure *_scanner; |
ysr@777 | 107 | protected: |
ysr@777 | 108 | void mark_forwardee(oop* p); |
ysr@777 | 109 | oop copy_to_survivor_space(oop obj); |
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, |
tonyp@961 | 117 | bool do_mark_forwardee, bool skip_cset_test> |
ysr@777 | 118 | class G1ParCopyClosure : public G1ParCopyHelper { |
ysr@777 | 119 | G1ParScanClosure _scanner; |
ysr@777 | 120 | void do_oop_work(oop* p); |
ysr@777 | 121 | void do_oop_work(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 122 | public: |
ysr@777 | 123 | G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : |
ysr@777 | 124 | _scanner(g1, par_scan_state), G1ParCopyHelper(g1, par_scan_state, &_scanner) { } |
ysr@777 | 125 | inline void do_oop_nv(oop* p) { |
ysr@777 | 126 | do_oop_work(p); |
ysr@777 | 127 | if (do_mark_forwardee) |
ysr@777 | 128 | mark_forwardee(p); |
ysr@777 | 129 | } |
ysr@777 | 130 | inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 131 | virtual void do_oop(oop* p) { do_oop_nv(p); } |
ysr@777 | 132 | virtual void do_oop(narrowOop* p) { do_oop_nv(p); } |
ysr@777 | 133 | }; |
ysr@777 | 134 | |
tonyp@961 | 135 | typedef G1ParCopyClosure<false, G1BarrierNone, false, false> G1ParScanExtRootClosure; |
tonyp@961 | 136 | typedef G1ParCopyClosure<true, G1BarrierNone, false, false> G1ParScanPermClosure; |
tonyp@961 | 137 | typedef G1ParCopyClosure<false, G1BarrierNone, true, false> G1ParScanAndMarkExtRootClosure; |
tonyp@961 | 138 | typedef G1ParCopyClosure<true, G1BarrierNone, true, false> G1ParScanAndMarkPermClosure; |
tonyp@961 | 139 | typedef G1ParCopyClosure<false, G1BarrierRS, false, false> G1ParScanHeapRSClosure; |
tonyp@961 | 140 | typedef G1ParCopyClosure<false, G1BarrierRS, true, false> G1ParScanAndMarkHeapRSClosure; |
tonyp@961 | 141 | // This is the only case when we set skip_cset_test. Basically, this |
tonyp@961 | 142 | // closure is (should?) only be called directly while we're draining |
tonyp@961 | 143 | // the overflow and task queues. In that case we know that the |
tonyp@961 | 144 | // reference in question points into the collection set, otherwise we |
tonyp@961 | 145 | // would not have pushed it on the queue. |
tonyp@961 | 146 | typedef G1ParCopyClosure<false, G1BarrierEvac, false, true> G1ParScanHeapEvacClosure; |
tonyp@961 | 147 | // We need a separate closure to handle references during evacuation |
tonyp@961 | 148 | // failure processing, as it cannot asume that the reference already |
tonyp@961 | 149 | // points to the collection set (like G1ParScanHeapEvacClosure does). |
tonyp@961 | 150 | typedef G1ParCopyClosure<false, G1BarrierEvac, false, false> G1ParScanHeapEvacFailureClosure; |
ysr@777 | 151 | |
ysr@777 | 152 | class FilterIntoCSClosure: public OopClosure { |
ysr@777 | 153 | G1CollectedHeap* _g1; |
ysr@777 | 154 | OopClosure* _oc; |
ysr@777 | 155 | DirtyCardToOopClosure* _dcto_cl; |
ysr@777 | 156 | public: |
ysr@777 | 157 | FilterIntoCSClosure( DirtyCardToOopClosure* dcto_cl, |
ysr@777 | 158 | G1CollectedHeap* g1, OopClosure* oc) : |
ysr@777 | 159 | _dcto_cl(dcto_cl), _g1(g1), _oc(oc) |
ysr@777 | 160 | {} |
ysr@777 | 161 | inline void do_oop_nv(oop* p); |
ysr@777 | 162 | inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 163 | virtual void do_oop(oop* p); |
ysr@777 | 164 | virtual void do_oop(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 165 | bool apply_to_weak_ref_discovered_field() { return true; } |
ysr@777 | 166 | bool do_header() { return false; } |
ysr@777 | 167 | }; |
ysr@777 | 168 | |
ysr@777 | 169 | class FilterInHeapRegionAndIntoCSClosure : public OopsInHeapRegionClosure { |
ysr@777 | 170 | G1CollectedHeap* _g1; |
ysr@777 | 171 | OopsInHeapRegionClosure* _oc; |
ysr@777 | 172 | public: |
ysr@777 | 173 | FilterInHeapRegionAndIntoCSClosure(G1CollectedHeap* g1, |
ysr@777 | 174 | OopsInHeapRegionClosure* oc) : |
ysr@777 | 175 | _g1(g1), _oc(oc) |
ysr@777 | 176 | {} |
ysr@777 | 177 | inline void do_oop_nv(oop* p); |
ysr@777 | 178 | inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 179 | virtual void do_oop(oop* p); |
ysr@777 | 180 | virtual void do_oop(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 181 | bool apply_to_weak_ref_discovered_field() { return true; } |
ysr@777 | 182 | bool do_header() { return false; } |
ysr@777 | 183 | void set_region(HeapRegion* from) { |
ysr@777 | 184 | _oc->set_region(from); |
ysr@777 | 185 | } |
ysr@777 | 186 | }; |
ysr@777 | 187 | |
ysr@777 | 188 | class FilterAndMarkInHeapRegionAndIntoCSClosure : public OopsInHeapRegionClosure { |
ysr@777 | 189 | G1CollectedHeap* _g1; |
ysr@777 | 190 | ConcurrentMark* _cm; |
ysr@777 | 191 | OopsInHeapRegionClosure* _oc; |
ysr@777 | 192 | public: |
ysr@777 | 193 | FilterAndMarkInHeapRegionAndIntoCSClosure(G1CollectedHeap* g1, |
ysr@777 | 194 | OopsInHeapRegionClosure* oc, |
ysr@777 | 195 | ConcurrentMark* cm) |
ysr@777 | 196 | : _g1(g1), _oc(oc), _cm(cm) { } |
ysr@777 | 197 | |
ysr@777 | 198 | inline void do_oop_nv(oop* p); |
ysr@777 | 199 | inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 200 | virtual void do_oop(oop* p); |
ysr@777 | 201 | virtual void do_oop(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 202 | bool apply_to_weak_ref_discovered_field() { return true; } |
ysr@777 | 203 | bool do_header() { return false; } |
ysr@777 | 204 | void set_region(HeapRegion* from) { |
ysr@777 | 205 | _oc->set_region(from); |
ysr@777 | 206 | } |
ysr@777 | 207 | }; |
ysr@777 | 208 | |
ysr@777 | 209 | class FilterOutOfRegionClosure: public OopClosure { |
ysr@777 | 210 | HeapWord* _r_bottom; |
ysr@777 | 211 | HeapWord* _r_end; |
ysr@777 | 212 | OopClosure* _oc; |
ysr@777 | 213 | int _out_of_region; |
ysr@777 | 214 | public: |
ysr@777 | 215 | FilterOutOfRegionClosure(HeapRegion* r, OopClosure* oc); |
ysr@777 | 216 | inline void do_oop_nv(oop* p); |
ysr@777 | 217 | inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 218 | virtual void do_oop(oop* p); |
ysr@777 | 219 | virtual void do_oop(narrowOop* p) { guarantee(false, "NYI"); } |
ysr@777 | 220 | bool apply_to_weak_ref_discovered_field() { return true; } |
ysr@777 | 221 | bool do_header() { return false; } |
ysr@777 | 222 | int out_of_region() { return _out_of_region; } |
ysr@777 | 223 | }; |