Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp @ 20804:7848fc12602b
Merge with jdk8u40-b25
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Tue, 07 Apr 2015 14:58:49 +0200 |
parents | 89152779163c 4c1b88a53c74 |
children |
comparison
equal
deleted
inserted
replaced
20184:84105dcdb05b | 20804:7848fc12602b |
---|---|
24 | 24 |
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSOOPCLOSURES_HPP | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSOOPCLOSURES_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSOOPCLOSURES_HPP | 26 #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSOOPCLOSURES_HPP |
27 | 27 |
28 #include "memory/genOopClosures.hpp" | 28 #include "memory/genOopClosures.hpp" |
29 #include "memory/iterator.hpp" | |
29 | 30 |
30 ///////////////////////////////////////////////////////////////// | 31 ///////////////////////////////////////////////////////////////// |
31 // Closures used by ConcurrentMarkSweepGeneration's collector | 32 // Closures used by ConcurrentMarkSweepGeneration's collector |
32 ///////////////////////////////////////////////////////////////// | 33 ///////////////////////////////////////////////////////////////// |
33 class ConcurrentMarkSweepGeneration; | 34 class ConcurrentMarkSweepGeneration; |
46 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); \ | 47 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); \ |
47 do_oop(obj); \ | 48 do_oop(obj); \ |
48 } \ | 49 } \ |
49 } | 50 } |
50 | 51 |
51 // Applies the given oop closure to all oops in all klasses visited. | 52 // TODO: This duplication of the MetadataAwareOopClosure class is only needed |
52 class CMKlassClosure : public KlassClosure { | 53 // because some CMS OopClosures derive from OopsInGenClosure. It would be |
53 friend class CMSOopClosure; | 54 // good to get rid of them completely. |
54 friend class CMSOopsInGenClosure; | 55 class MetadataAwareOopsInGenClosure: public OopsInGenClosure { |
55 | 56 KlassToOopClosure _klass_closure; |
56 OopClosure* _oop_closure; | 57 public: |
57 | 58 MetadataAwareOopsInGenClosure() { |
58 // Used when _oop_closure couldn't be set in an initialization list. | |
59 void initialize(OopClosure* oop_closure) { | |
60 assert(_oop_closure == NULL, "Should only be called once"); | |
61 _oop_closure = oop_closure; | |
62 } | |
63 public: | |
64 CMKlassClosure(OopClosure* oop_closure = NULL) : _oop_closure(oop_closure) { } | |
65 | |
66 void do_klass(Klass* k); | |
67 }; | |
68 | |
69 // The base class for all CMS marking closures. | |
70 // It's used to proxy through the metadata to the oops defined in them. | |
71 class CMSOopClosure: public ExtendedOopClosure { | |
72 CMKlassClosure _klass_closure; | |
73 public: | |
74 CMSOopClosure() : ExtendedOopClosure() { | |
75 _klass_closure.initialize(this); | |
76 } | |
77 CMSOopClosure(ReferenceProcessor* rp) : ExtendedOopClosure(rp) { | |
78 _klass_closure.initialize(this); | 59 _klass_closure.initialize(this); |
79 } | 60 } |
80 | 61 |
81 virtual bool do_metadata() { return do_metadata_nv(); } | 62 virtual bool do_metadata() { return do_metadata_nv(); } |
82 inline bool do_metadata_nv() { return true; } | 63 inline bool do_metadata_nv() { return true; } |
85 void do_klass_nv(Klass* k); | 66 void do_klass_nv(Klass* k); |
86 | 67 |
87 virtual void do_class_loader_data(ClassLoaderData* cld); | 68 virtual void do_class_loader_data(ClassLoaderData* cld); |
88 }; | 69 }; |
89 | 70 |
90 // TODO: This duplication of the CMSOopClosure class is only needed because | 71 class MarkRefsIntoClosure: public MetadataAwareOopsInGenClosure { |
91 // some CMS OopClosures derive from OopsInGenClosure. It would be good | |
92 // to get rid of them completely. | |
93 class CMSOopsInGenClosure: public OopsInGenClosure { | |
94 CMKlassClosure _klass_closure; | |
95 public: | |
96 CMSOopsInGenClosure() { | |
97 _klass_closure.initialize(this); | |
98 } | |
99 | |
100 virtual bool do_metadata() { return do_metadata_nv(); } | |
101 inline bool do_metadata_nv() { return true; } | |
102 | |
103 virtual void do_klass(Klass* k); | |
104 void do_klass_nv(Klass* k); | |
105 | |
106 virtual void do_class_loader_data(ClassLoaderData* cld); | |
107 }; | |
108 | |
109 class MarkRefsIntoClosure: public CMSOopsInGenClosure { | |
110 private: | 72 private: |
111 const MemRegion _span; | 73 const MemRegion _span; |
112 CMSBitMap* _bitMap; | 74 CMSBitMap* _bitMap; |
113 protected: | 75 protected: |
114 DO_OOP_WORK_DEFN | 76 DO_OOP_WORK_DEFN |
120 Prefetch::style prefetch_style() { | 82 Prefetch::style prefetch_style() { |
121 return Prefetch::do_read; | 83 return Prefetch::do_read; |
122 } | 84 } |
123 }; | 85 }; |
124 | 86 |
125 class Par_MarkRefsIntoClosure: public CMSOopsInGenClosure { | 87 class Par_MarkRefsIntoClosure: public MetadataAwareOopsInGenClosure { |
126 private: | 88 private: |
127 const MemRegion _span; | 89 const MemRegion _span; |
128 CMSBitMap* _bitMap; | 90 CMSBitMap* _bitMap; |
129 protected: | 91 protected: |
130 DO_OOP_WORK_DEFN | 92 DO_OOP_WORK_DEFN |
138 } | 100 } |
139 }; | 101 }; |
140 | 102 |
141 // A variant of the above used in certain kinds of CMS | 103 // A variant of the above used in certain kinds of CMS |
142 // marking verification. | 104 // marking verification. |
143 class MarkRefsIntoVerifyClosure: public CMSOopsInGenClosure { | 105 class MarkRefsIntoVerifyClosure: public MetadataAwareOopsInGenClosure { |
144 private: | 106 private: |
145 const MemRegion _span; | 107 const MemRegion _span; |
146 CMSBitMap* _verification_bm; | 108 CMSBitMap* _verification_bm; |
147 CMSBitMap* _cms_bm; | 109 CMSBitMap* _cms_bm; |
148 protected: | 110 protected: |
157 return Prefetch::do_read; | 119 return Prefetch::do_read; |
158 } | 120 } |
159 }; | 121 }; |
160 | 122 |
161 // The non-parallel version (the parallel version appears further below). | 123 // The non-parallel version (the parallel version appears further below). |
162 class PushAndMarkClosure: public CMSOopClosure { | 124 class PushAndMarkClosure: public MetadataAwareOopClosure { |
163 private: | 125 private: |
164 CMSCollector* _collector; | 126 CMSCollector* _collector; |
165 MemRegion _span; | 127 MemRegion _span; |
166 CMSBitMap* _bit_map; | 128 CMSBitMap* _bit_map; |
167 CMSBitMap* _mod_union_table; | 129 CMSBitMap* _mod_union_table; |
191 // reference processor are currently all shared. Access to | 153 // reference processor are currently all shared. Access to |
192 // these shared mutable structures must use appropriate | 154 // these shared mutable structures must use appropriate |
193 // synchronization (for instance, via CAS). The marking stack | 155 // synchronization (for instance, via CAS). The marking stack |
194 // used in the non-parallel case above is here replaced with | 156 // used in the non-parallel case above is here replaced with |
195 // an OopTaskQueue structure to allow efficient work stealing. | 157 // an OopTaskQueue structure to allow efficient work stealing. |
196 class Par_PushAndMarkClosure: public CMSOopClosure { | 158 class Par_PushAndMarkClosure: public MetadataAwareOopClosure { |
197 private: | 159 private: |
198 CMSCollector* _collector; | 160 CMSCollector* _collector; |
199 MemRegion _span; | 161 MemRegion _span; |
200 CMSBitMap* _bit_map; | 162 CMSBitMap* _bit_map; |
201 OopTaskQueue* _work_queue; | 163 OopTaskQueue* _work_queue; |
216 return Prefetch::do_read; | 178 return Prefetch::do_read; |
217 } | 179 } |
218 }; | 180 }; |
219 | 181 |
220 // The non-parallel version (the parallel version appears further below). | 182 // The non-parallel version (the parallel version appears further below). |
221 class MarkRefsIntoAndScanClosure: public CMSOopsInGenClosure { | 183 class MarkRefsIntoAndScanClosure: public MetadataAwareOopsInGenClosure { |
222 private: | 184 private: |
223 MemRegion _span; | 185 MemRegion _span; |
224 CMSBitMap* _bit_map; | 186 CMSBitMap* _bit_map; |
225 CMSMarkStack* _mark_stack; | 187 CMSMarkStack* _mark_stack; |
226 PushAndMarkClosure _pushAndMarkClosure; | 188 PushAndMarkClosure _pushAndMarkClosure; |
260 | 222 |
261 // Tn this, the parallel avatar of MarkRefsIntoAndScanClosure, the revisit | 223 // Tn this, the parallel avatar of MarkRefsIntoAndScanClosure, the revisit |
262 // stack and the bitMap are shared, so access needs to be suitably | 224 // stack and the bitMap are shared, so access needs to be suitably |
263 // sycnhronized. An OopTaskQueue structure, supporting efficient | 225 // sycnhronized. An OopTaskQueue structure, supporting efficient |
264 // workstealing, replaces a CMSMarkStack for storing grey objects. | 226 // workstealing, replaces a CMSMarkStack for storing grey objects. |
265 class Par_MarkRefsIntoAndScanClosure: public CMSOopsInGenClosure { | 227 class Par_MarkRefsIntoAndScanClosure: public MetadataAwareOopsInGenClosure { |
266 private: | 228 private: |
267 MemRegion _span; | 229 MemRegion _span; |
268 CMSBitMap* _bit_map; | 230 CMSBitMap* _bit_map; |
269 OopTaskQueue* _work_queue; | 231 OopTaskQueue* _work_queue; |
270 const uint _low_water_mark; | 232 const uint _low_water_mark; |
289 }; | 251 }; |
290 | 252 |
291 // This closure is used during the concurrent marking phase | 253 // This closure is used during the concurrent marking phase |
292 // following the first checkpoint. Its use is buried in | 254 // following the first checkpoint. Its use is buried in |
293 // the closure MarkFromRootsClosure. | 255 // the closure MarkFromRootsClosure. |
294 class PushOrMarkClosure: public CMSOopClosure { | 256 class PushOrMarkClosure: public MetadataAwareOopClosure { |
295 private: | 257 private: |
296 CMSCollector* _collector; | 258 CMSCollector* _collector; |
297 MemRegion _span; | 259 MemRegion _span; |
298 CMSBitMap* _bitMap; | 260 CMSBitMap* _bitMap; |
299 CMSMarkStack* _markStack; | 261 CMSMarkStack* _markStack; |
322 | 284 |
323 // A parallel (MT) version of the above. | 285 // A parallel (MT) version of the above. |
324 // This closure is used during the concurrent marking phase | 286 // This closure is used during the concurrent marking phase |
325 // following the first checkpoint. Its use is buried in | 287 // following the first checkpoint. Its use is buried in |
326 // the closure Par_MarkFromRootsClosure. | 288 // the closure Par_MarkFromRootsClosure. |
327 class Par_PushOrMarkClosure: public CMSOopClosure { | 289 class Par_PushOrMarkClosure: public MetadataAwareOopClosure { |
328 private: | 290 private: |
329 CMSCollector* _collector; | 291 CMSCollector* _collector; |
330 MemRegion _whole_span; | 292 MemRegion _whole_span; |
331 MemRegion _span; // local chunk | 293 MemRegion _span; // local chunk |
332 CMSBitMap* _bit_map; | 294 CMSBitMap* _bit_map; |
362 // given objects (transitively) as being reachable/live. | 324 // given objects (transitively) as being reachable/live. |
363 // This is currently used during the (weak) reference object | 325 // This is currently used during the (weak) reference object |
364 // processing phase of the CMS final checkpoint step, as | 326 // processing phase of the CMS final checkpoint step, as |
365 // well as during the concurrent precleaning of the discovered | 327 // well as during the concurrent precleaning of the discovered |
366 // reference lists. | 328 // reference lists. |
367 class CMSKeepAliveClosure: public CMSOopClosure { | 329 class CMSKeepAliveClosure: public MetadataAwareOopClosure { |
368 private: | 330 private: |
369 CMSCollector* _collector; | 331 CMSCollector* _collector; |
370 const MemRegion _span; | 332 const MemRegion _span; |
371 CMSMarkStack* _mark_stack; | 333 CMSMarkStack* _mark_stack; |
372 CMSBitMap* _bit_map; | 334 CMSBitMap* _bit_map; |
382 virtual void do_oop(narrowOop* p); | 344 virtual void do_oop(narrowOop* p); |
383 inline void do_oop_nv(oop* p) { CMSKeepAliveClosure::do_oop_work(p); } | 345 inline void do_oop_nv(oop* p) { CMSKeepAliveClosure::do_oop_work(p); } |
384 inline void do_oop_nv(narrowOop* p) { CMSKeepAliveClosure::do_oop_work(p); } | 346 inline void do_oop_nv(narrowOop* p) { CMSKeepAliveClosure::do_oop_work(p); } |
385 }; | 347 }; |
386 | 348 |
387 class CMSInnerParMarkAndPushClosure: public CMSOopClosure { | 349 class CMSInnerParMarkAndPushClosure: public MetadataAwareOopClosure { |
388 private: | 350 private: |
389 CMSCollector* _collector; | 351 CMSCollector* _collector; |
390 MemRegion _span; | 352 MemRegion _span; |
391 OopTaskQueue* _work_queue; | 353 OopTaskQueue* _work_queue; |
392 CMSBitMap* _bit_map; | 354 CMSBitMap* _bit_map; |
403 }; | 365 }; |
404 | 366 |
405 // A parallel (MT) version of the above, used when | 367 // A parallel (MT) version of the above, used when |
406 // reference processing is parallel; the only difference | 368 // reference processing is parallel; the only difference |
407 // is in the do_oop method. | 369 // is in the do_oop method. |
408 class CMSParKeepAliveClosure: public CMSOopClosure { | 370 class CMSParKeepAliveClosure: public MetadataAwareOopClosure { |
409 private: | 371 private: |
410 MemRegion _span; | 372 MemRegion _span; |
411 OopTaskQueue* _work_queue; | 373 OopTaskQueue* _work_queue; |
412 CMSBitMap* _bit_map; | 374 CMSBitMap* _bit_map; |
413 CMSInnerParMarkAndPushClosure | 375 CMSInnerParMarkAndPushClosure |