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

Fri, 10 Oct 2014 15:51:58 +0200

author
tschatzl
date
Fri, 10 Oct 2014 15:51:58 +0200
changeset 7257
e7d0505c8a30
parent 6992
2c6ef90f030a
child 7535
7ae4e26cb1e0
child 7651
c132be0fb74d
child 7971
b554c7fa9478
permissions
-rw-r--r--

8059758: Footprint regressions with JDK-8038423
Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything.
Reviewed-by: jwilhelm, brutisso

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

mercurial