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

Tue, 21 Aug 2012 14:10:39 -0700

author
johnc
date
Tue, 21 Aug 2012 14:10:39 -0700
changeset 3998
7383557659bd
parent 3957
a2f7274eb6ef
child 4037
da91efe96a93
permissions
-rw-r--r--

7185699: G1: Prediction model discrepancies
Summary: Correct the result value of G1CollectedHeap::pending_card_num(). Change the code that calculates the GC efficiency of a non-young heap region to use historical data from mixed GCs and the actual number of live bytes when predicting how long it would take to collect the region. Changes were also reviewed by Thomas Schatzl.
Reviewed-by: azeemj, brutisso

ysr@777 1 /*
tonyp@3416 2 * Copyright (c) 2001, 2012, 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@3463 54 uint _worker_id;
johnc@3086 55 bool _during_initial_mark;
johnc@3086 56 bool _mark_in_progress;
ysr@777 57 public:
ysr@777 58 G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state);
ysr@777 59 bool apply_to_weak_ref_discovered_field() { return true; }
ysr@777 60 };
ysr@777 61
iveresov@1696 62 class G1ParPushHeapRSClosure : public G1ParClosureSuper {
iveresov@1696 63 public:
johnc@3175 64 G1ParPushHeapRSClosure(G1CollectedHeap* g1,
johnc@3179 65 G1ParScanThreadState* par_scan_state):
johnc@3179 66 G1ParClosureSuper(g1, par_scan_state) { }
johnc@3175 67
iveresov@1696 68 template <class T> void do_oop_nv(T* p);
iveresov@1696 69 virtual void do_oop(oop* p) { do_oop_nv(p); }
iveresov@1696 70 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
iveresov@1696 71 };
iveresov@1696 72
ysr@777 73 class G1ParScanClosure : public G1ParClosureSuper {
ysr@777 74 public:
johnc@3175 75 G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) :
johnc@3175 76 G1ParClosureSuper(g1, par_scan_state)
johnc@3175 77 {
johnc@3175 78 assert(_ref_processor == NULL, "sanity");
johnc@3175 79 _ref_processor = rp;
johnc@3175 80 }
johnc@3175 81
ysr@1280 82 template <class T> void do_oop_nv(T* p);
ysr@777 83 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@777 84 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 85 };
ysr@777 86
ysr@1280 87 #define G1_PARTIAL_ARRAY_MASK 0x2
ysr@777 88
ysr@1280 89 template <class T> inline bool has_partial_array_mask(T* ref) {
ysr@1280 90 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
tonyp@961 91 }
tonyp@961 92
ysr@1280 93 template <class T> inline T* set_partial_array_mask(T obj) {
ysr@1280 94 assert(((uintptr_t)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!");
ysr@1280 95 return (T*) ((uintptr_t)obj | G1_PARTIAL_ARRAY_MASK);
tonyp@961 96 }
tonyp@961 97
ysr@1280 98 template <class T> inline oop clear_partial_array_mask(T* ref) {
ysr@1280 99 return oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK);
tonyp@961 100 }
tonyp@961 101
ysr@777 102 class G1ParScanPartialArrayClosure : public G1ParClosureSuper {
ysr@777 103 G1ParScanClosure _scanner;
johnc@3175 104
ysr@777 105 public:
johnc@3175 106 G1ParScanPartialArrayClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) :
johnc@3175 107 G1ParClosureSuper(g1, par_scan_state), _scanner(g1, par_scan_state, rp)
johnc@3175 108 {
johnc@3175 109 assert(_ref_processor == NULL, "sanity");
johnc@3175 110 }
johnc@3175 111
johnc@3175 112 G1ParScanClosure* scanner() {
johnc@3175 113 return &_scanner;
johnc@3175 114 }
johnc@3175 115
ysr@1280 116 template <class T> void do_oop_nv(T* p);
ysr@777 117 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@777 118 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 119 };
ysr@777 120
brutisso@3690 121 template <bool do_gen_barrier, G1Barrier barrier, bool do_mark_object>
brutisso@3690 122 class G1ParCopyClosure : public G1ParClosureSuper {
brutisso@3690 123 G1ParScanClosure _scanner;
brutisso@3690 124 template <class T> void do_oop_work(T* p);
ysr@777 125
ysr@777 126 protected:
tonyp@3416 127 // Mark the object if it's not already marked. This is used to mark
tonyp@3416 128 // objects pointed to by roots that are guaranteed not to move
tonyp@3416 129 // during the GC (i.e., non-CSet objects). It is MT-safe.
tonyp@3416 130 void mark_object(oop obj);
tonyp@3416 131
tonyp@3416 132 // Mark the object if it's not already marked. This is used to mark
tonyp@3416 133 // objects pointed to by roots that have been forwarded during a
tonyp@3416 134 // GC. It is MT-safe.
tonyp@3416 135 void mark_forwarded_object(oop from_obj, oop to_obj);
tonyp@3416 136
tonyp@3416 137 oop copy_to_survivor_space(oop obj);
tonyp@3416 138
ysr@777 139 public:
johnc@3175 140 G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state,
johnc@3175 141 ReferenceProcessor* rp) :
tonyp@3416 142 _scanner(g1, par_scan_state, rp),
brutisso@3690 143 G1ParClosureSuper(g1, par_scan_state) {
johnc@3175 144 assert(_ref_processor == NULL, "sanity");
johnc@3175 145 }
johnc@3175 146
johnc@3175 147 G1ParScanClosure* scanner() { return &_scanner; }
johnc@3175 148
ysr@1280 149 template <class T> void do_oop_nv(T* p) {
ysr@777 150 do_oop_work(p);
ysr@777 151 }
ysr@777 152 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@777 153 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 154 };
ysr@777 155
iveresov@1696 156 typedef G1ParCopyClosure<false, G1BarrierNone, false> G1ParScanExtRootClosure;
iveresov@1696 157 typedef G1ParCopyClosure<true, G1BarrierNone, false> G1ParScanPermClosure;
johnc@3175 158
iveresov@1696 159 typedef G1ParCopyClosure<false, G1BarrierNone, true> G1ParScanAndMarkExtRootClosure;
iveresov@1696 160 typedef G1ParCopyClosure<true, G1BarrierNone, true> G1ParScanAndMarkPermClosure;
iveresov@1696 161
johnc@3175 162 // The following closure types are no longer used but are retained
johnc@3175 163 // for historical reasons:
johnc@3175 164 // typedef G1ParCopyClosure<false, G1BarrierRS, false> G1ParScanHeapRSClosure;
johnc@3175 165 // typedef G1ParCopyClosure<false, G1BarrierRS, true> G1ParScanAndMarkHeapRSClosure;
johnc@3175 166
johnc@3175 167 // The following closure type is defined in g1_specialized_oop_closures.hpp:
johnc@3175 168 //
johnc@3175 169 // typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacClosure;
johnc@3175 170
johnc@3175 171 // We use a separate closure to handle references during evacuation
johnc@3175 172 // failure processing.
johnc@3175 173 // We could have used another instance of G1ParScanHeapEvacClosure
johnc@3175 174 // (since that closure no longer assumes that the references it
johnc@3175 175 // handles point into the collection set).
johnc@3175 176
iveresov@1696 177 typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacFailureClosure;
ysr@777 178
ysr@777 179 class FilterIntoCSClosure: public OopClosure {
ysr@777 180 G1CollectedHeap* _g1;
ysr@777 181 OopClosure* _oc;
ysr@777 182 DirtyCardToOopClosure* _dcto_cl;
ysr@777 183 public:
ysr@777 184 FilterIntoCSClosure( DirtyCardToOopClosure* dcto_cl,
johnc@3175 185 G1CollectedHeap* g1,
johnc@3179 186 OopClosure* oc) :
johnc@3179 187 _dcto_cl(dcto_cl), _g1(g1), _oc(oc) { }
johnc@3175 188
ysr@1280 189 template <class T> void do_oop_nv(T* p);
ysr@1280 190 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@1280 191 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 192 bool apply_to_weak_ref_discovered_field() { return true; }
ysr@777 193 bool do_header() { return false; }
ysr@777 194 };
ysr@777 195
ysr@777 196 class FilterOutOfRegionClosure: public OopClosure {
ysr@777 197 HeapWord* _r_bottom;
ysr@777 198 HeapWord* _r_end;
ysr@777 199 OopClosure* _oc;
ysr@777 200 public:
ysr@777 201 FilterOutOfRegionClosure(HeapRegion* r, OopClosure* oc);
ysr@1280 202 template <class T> void do_oop_nv(T* p);
ysr@1280 203 virtual void do_oop(oop* p) { do_oop_nv(p); }
ysr@1280 204 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
ysr@777 205 bool apply_to_weak_ref_discovered_field() { return true; }
ysr@777 206 bool do_header() { return false; }
ysr@777 207 };
stefank@2314 208
tonyp@2968 209 // Closure for iterating over object fields during concurrent marking
tonyp@2968 210 class G1CMOopClosure : public OopClosure {
tonyp@3464 211 private:
tonyp@2968 212 G1CollectedHeap* _g1h;
tonyp@2968 213 ConcurrentMark* _cm;
tonyp@2968 214 CMTask* _task;
tonyp@2968 215 public:
tonyp@2968 216 G1CMOopClosure(G1CollectedHeap* g1h, ConcurrentMark* cm, CMTask* task);
tonyp@2968 217 template <class T> void do_oop_nv(T* p);
tonyp@2968 218 virtual void do_oop( oop* p) { do_oop_nv(p); }
tonyp@2968 219 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
tonyp@2968 220 };
tonyp@2968 221
tonyp@3464 222 // Closure to scan the root regions during concurrent marking
tonyp@3464 223 class G1RootRegionScanClosure : public OopClosure {
tonyp@3464 224 private:
tonyp@3464 225 G1CollectedHeap* _g1h;
tonyp@3464 226 ConcurrentMark* _cm;
tonyp@3464 227 uint _worker_id;
tonyp@3464 228 public:
tonyp@3464 229 G1RootRegionScanClosure(G1CollectedHeap* g1h, ConcurrentMark* cm,
tonyp@3464 230 uint worker_id) :
tonyp@3464 231 _g1h(g1h), _cm(cm), _worker_id(worker_id) { }
tonyp@3464 232 template <class T> void do_oop_nv(T* p);
tonyp@3464 233 virtual void do_oop( oop* p) { do_oop_nv(p); }
tonyp@3464 234 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
tonyp@3464 235 };
tonyp@3464 236
johnc@3466 237 // Closure that applies the given two closures in sequence.
johnc@3466 238 // Used by the RSet refinement code (when updating RSets
johnc@3466 239 // during an evacuation pause) to record cards containing
johnc@3466 240 // pointers into the collection set.
johnc@3466 241
johnc@3466 242 class G1Mux2Closure : public OopClosure {
johnc@3466 243 OopClosure* _c1;
johnc@3466 244 OopClosure* _c2;
johnc@3466 245 public:
johnc@3466 246 G1Mux2Closure(OopClosure *c1, OopClosure *c2);
johnc@3466 247 template <class T> void do_oop_nv(T* p);
johnc@3466 248 virtual void do_oop(oop* p) { do_oop_nv(p); }
johnc@3466 249 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
johnc@3466 250 };
johnc@3466 251
johnc@3466 252 // A closure that returns true if it is actually applied
johnc@3466 253 // to a reference
johnc@3466 254
johnc@3466 255 class G1TriggerClosure : public OopClosure {
johnc@3466 256 bool _triggered;
johnc@3466 257 public:
johnc@3466 258 G1TriggerClosure();
johnc@3466 259 bool triggered() const { return _triggered; }
johnc@3466 260 template <class T> void do_oop_nv(T* p);
johnc@3466 261 virtual void do_oop(oop* p) { do_oop_nv(p); }
johnc@3466 262 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
johnc@3466 263 };
johnc@3466 264
johnc@3466 265 // A closure which uses a triggering closure to determine
johnc@3466 266 // whether to apply an oop closure.
johnc@3466 267
johnc@3466 268 class G1InvokeIfNotTriggeredClosure: public OopClosure {
johnc@3466 269 G1TriggerClosure* _trigger_cl;
johnc@3466 270 OopClosure* _oop_cl;
johnc@3466 271 public:
johnc@3466 272 G1InvokeIfNotTriggeredClosure(G1TriggerClosure* t, OopClosure* oc);
johnc@3466 273 template <class T> void do_oop_nv(T* p);
johnc@3466 274 virtual void do_oop(oop* p) { do_oop_nv(p); }
johnc@3466 275 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
johnc@3466 276 };
johnc@3466 277
johnc@3466 278 class G1UpdateRSOrPushRefOopClosure: public OopClosure {
johnc@3466 279 G1CollectedHeap* _g1;
johnc@3466 280 G1RemSet* _g1_rem_set;
johnc@3466 281 HeapRegion* _from;
johnc@3466 282 OopsInHeapRegionClosure* _push_ref_cl;
johnc@3466 283 bool _record_refs_into_cset;
johnc@3466 284 int _worker_i;
johnc@3466 285
johnc@3466 286 public:
johnc@3466 287 G1UpdateRSOrPushRefOopClosure(G1CollectedHeap* g1h,
johnc@3466 288 G1RemSet* rs,
johnc@3466 289 OopsInHeapRegionClosure* push_ref_cl,
johnc@3466 290 bool record_refs_into_cset,
johnc@3466 291 int worker_i = 0);
johnc@3466 292
johnc@3466 293 void set_from(HeapRegion* from) {
johnc@3466 294 assert(from != NULL, "from region must be non-NULL");
johnc@3466 295 _from = from;
johnc@3466 296 }
johnc@3466 297
johnc@3466 298 bool self_forwarded(oop obj) {
johnc@3466 299 bool result = (obj->is_forwarded() && (obj->forwardee()== obj));
johnc@3466 300 return result;
johnc@3466 301 }
johnc@3466 302
johnc@3466 303 bool apply_to_weak_ref_discovered_field() { return true; }
johnc@3466 304
johnc@3466 305 template <class T> void do_oop_nv(T* p);
johnc@3466 306 virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
johnc@3466 307 virtual void do_oop(oop* p) { do_oop_nv(p); }
johnc@3466 308 };
johnc@3466 309
stefank@2314 310 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1OOPCLOSURES_HPP

mercurial