comparison src/share/vm/memory/iterator.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 2c6ef90f030a
children
comparison
equal deleted inserted replaced
20184:84105dcdb05b 20804:7848fc12602b
82 // The virtual (without suffix) and the non-virtual (with _nv suffix) need 82 // The virtual (without suffix) and the non-virtual (with _nv suffix) need
83 // to be updated together, or else the devirtualization will break. 83 // to be updated together, or else the devirtualization will break.
84 // 84 //
85 // Providing default implementations of the _nv functions unfortunately 85 // Providing default implementations of the _nv functions unfortunately
86 // removes the compile-time safeness, but reduces the clutter for the 86 // removes the compile-time safeness, but reduces the clutter for the
87 // ExtendedOopClosures that don't need to walk the metadata. Currently, 87 // ExtendedOopClosures that don't need to walk the metadata.
88 // only CMS needs these. 88 // Currently, only CMS and G1 need these.
89 89
90 virtual bool do_metadata() { return do_metadata_nv(); } 90 virtual bool do_metadata() { return do_metadata_nv(); }
91 bool do_metadata_v() { return do_metadata(); } 91 bool do_metadata_v() { return do_metadata(); }
92 bool do_metadata_nv() { return false; } 92 bool do_metadata_nv() { return false; }
93 93
126 class KlassClosure : public Closure { 126 class KlassClosure : public Closure {
127 public: 127 public:
128 virtual void do_klass(Klass* k) = 0; 128 virtual void do_klass(Klass* k) = 0;
129 }; 129 };
130 130
131 class CLDClosure : public Closure {
132 public:
133 virtual void do_cld(ClassLoaderData* cld) = 0;
134 };
135
131 class KlassToOopClosure : public KlassClosure { 136 class KlassToOopClosure : public KlassClosure {
137 friend class MetadataAwareOopClosure;
138 friend class MetadataAwareOopsInGenClosure;
139
132 OopClosure* _oop_closure; 140 OopClosure* _oop_closure;
133 public: 141
134 KlassToOopClosure(OopClosure* oop_closure) : _oop_closure(oop_closure) {} 142 // Used when _oop_closure couldn't be set in an initialization list.
143 void initialize(OopClosure* oop_closure) {
144 assert(_oop_closure == NULL, "Should only be called once");
145 _oop_closure = oop_closure;
146 }
147
148 public:
149 KlassToOopClosure(OopClosure* oop_closure = NULL) : _oop_closure(oop_closure) {}
150
135 virtual void do_klass(Klass* k); 151 virtual void do_klass(Klass* k);
136 }; 152 };
137 153
138 class CLDToOopClosure { 154 class CLDToOopClosure : public CLDClosure {
139 OopClosure* _oop_closure; 155 OopClosure* _oop_closure;
140 KlassToOopClosure _klass_closure; 156 KlassToOopClosure _klass_closure;
141 bool _must_claim_cld; 157 bool _must_claim_cld;
142 158
143 public: 159 public:
144 CLDToOopClosure(OopClosure* oop_closure, bool must_claim_cld = true) : 160 CLDToOopClosure(OopClosure* oop_closure, bool must_claim_cld = true) :
145 _oop_closure(oop_closure), 161 _oop_closure(oop_closure),
146 _klass_closure(oop_closure), 162 _klass_closure(oop_closure),
147 _must_claim_cld(must_claim_cld) {} 163 _must_claim_cld(must_claim_cld) {}
148 164
149 void do_cld(ClassLoaderData* cld); 165 void do_cld(ClassLoaderData* cld);
166 };
167
168 class CLDToKlassAndOopClosure : public CLDClosure {
169 friend class SharedHeap;
170 friend class G1CollectedHeap;
171 protected:
172 OopClosure* _oop_closure;
173 KlassClosure* _klass_closure;
174 bool _must_claim_cld;
175 public:
176 CLDToKlassAndOopClosure(KlassClosure* klass_closure,
177 OopClosure* oop_closure,
178 bool must_claim_cld) :
179 _oop_closure(oop_closure),
180 _klass_closure(klass_closure),
181 _must_claim_cld(must_claim_cld) {}
182 void do_cld(ClassLoaderData* cld);
183 };
184
185 // The base class for all concurrent marking closures,
186 // that participates in class unloading.
187 // It's used to proxy through the metadata to the oops defined in them.
188 class MetadataAwareOopClosure: public ExtendedOopClosure {
189 KlassToOopClosure _klass_closure;
190
191 public:
192 MetadataAwareOopClosure() : ExtendedOopClosure() {
193 _klass_closure.initialize(this);
194 }
195 MetadataAwareOopClosure(ReferenceProcessor* rp) : ExtendedOopClosure(rp) {
196 _klass_closure.initialize(this);
197 }
198
199 virtual bool do_metadata() { return do_metadata_nv(); }
200 inline bool do_metadata_nv() { return true; }
201
202 virtual void do_klass(Klass* k);
203 void do_klass_nv(Klass* k);
204
205 virtual void do_class_loader_data(ClassLoaderData* cld);
150 }; 206 };
151 207
152 // ObjectClosure is used for iterating through an object space 208 // ObjectClosure is used for iterating through an object space
153 209
154 class ObjectClosure : public Closure { 210 class ObjectClosure : public Closure {
170 public: 226 public:
171 void do_object(oop obj); 227 void do_object(oop obj);
172 ObjectToOopClosure(ExtendedOopClosure* cl) : _cl(cl) {} 228 ObjectToOopClosure(ExtendedOopClosure* cl) : _cl(cl) {}
173 }; 229 };
174 230
175 // A version of ObjectClosure with "memory" (see _previous_address below)
176 class UpwardsObjectClosure: public BoolObjectClosure {
177 HeapWord* _previous_address;
178 public:
179 UpwardsObjectClosure() : _previous_address(NULL) { }
180 void set_previous(HeapWord* addr) { _previous_address = addr; }
181 HeapWord* previous() { return _previous_address; }
182 // A return value of "true" can be used by the caller to decide
183 // if this object's end should *NOT* be recorded in
184 // _previous_address above.
185 virtual bool do_object_bm(oop obj, MemRegion mr) = 0;
186 };
187
188 // A version of ObjectClosure that is expected to be robust 231 // A version of ObjectClosure that is expected to be robust
189 // in the face of possibly uninitialized objects. 232 // in the face of possibly uninitialized objects.
190 class ObjectClosureCareful : public ObjectClosure { 233 class ObjectClosureCareful : public ObjectClosure {
191 public: 234 public:
192 virtual size_t do_object_careful_m(oop p, MemRegion mr) = 0; 235 virtual size_t do_object_careful_m(oop p, MemRegion mr) = 0;
238 public: 281 public:
239 // Called for each code blob. 282 // Called for each code blob.
240 virtual void do_code_blob(CodeBlob* cb) = 0; 283 virtual void do_code_blob(CodeBlob* cb) = 0;
241 }; 284 };
242 285
243 286 // Applies an oop closure to all ref fields in code blobs
244 class MarkingCodeBlobClosure : public CodeBlobClosure { 287 // iterated over in an object iteration.
245 public: 288 class CodeBlobToOopClosure : public CodeBlobClosure {
289 OopClosure* _cl;
290 bool _fix_relocations;
291 protected:
292 void do_nmethod(nmethod* nm);
293 public:
294 CodeBlobToOopClosure(OopClosure* cl, bool fix_relocations) : _cl(cl), _fix_relocations(fix_relocations) {}
295 virtual void do_code_blob(CodeBlob* cb);
296
297 const static bool FixRelocations = true;
298 };
299
300 class MarkingCodeBlobClosure : public CodeBlobToOopClosure {
301 public:
302 MarkingCodeBlobClosure(OopClosure* cl, bool fix_relocations) : CodeBlobToOopClosure(cl, fix_relocations) {}
246 // Called for each code blob, but at most once per unique blob. 303 // Called for each code blob, but at most once per unique blob.
247 virtual void do_newly_marked_nmethod(nmethod* nm) = 0;
248 304
249 virtual void do_code_blob(CodeBlob* cb); 305 virtual void do_code_blob(CodeBlob* cb);
250 // = { if (!nmethod(cb)->test_set_oops_do_mark()) do_newly_marked_nmethod(cb); }
251 306
252 class MarkScope : public StackObj { 307 class MarkScope : public StackObj {
253 protected: 308 protected:
254 bool _active; 309 bool _active;
255 public: 310 public:
257 // = { if (active) nmethod::oops_do_marking_prologue(); } 312 // = { if (active) nmethod::oops_do_marking_prologue(); }
258 ~MarkScope(); 313 ~MarkScope();
259 // = { if (active) nmethod::oops_do_marking_epilogue(); } 314 // = { if (active) nmethod::oops_do_marking_epilogue(); }
260 }; 315 };
261 }; 316 };
262
263
264 // Applies an oop closure to all ref fields in code blobs
265 // iterated over in an object iteration.
266 class CodeBlobToOopClosure: public MarkingCodeBlobClosure {
267 OopClosure* _cl;
268 bool _do_marking;
269 public:
270 virtual void do_newly_marked_nmethod(nmethod* cb);
271 // = { cb->oops_do(_cl); }
272 virtual void do_code_blob(CodeBlob* cb);
273 // = { if (_do_marking) super::do_code_blob(cb); else cb->oops_do(_cl); }
274 CodeBlobToOopClosure(OopClosure* cl, bool do_marking)
275 : _cl(cl), _do_marking(do_marking) {}
276 };
277
278
279 317
280 // MonitorClosure is used for iterating over monitors in the monitors cache 318 // MonitorClosure is used for iterating over monitors in the monitors cache
281 319
282 class ObjectMonitor; 320 class ObjectMonitor;
283 321
343 static void store_symbol(Symbol** p, Symbol* sym) { 381 static void store_symbol(Symbol** p, Symbol* sym) {
344 *p = (Symbol*)(intptr_t(sym) | (intptr_t(*p) & 1)); 382 *p = (Symbol*)(intptr_t(sym) | (intptr_t(*p) & 1));
345 } 383 }
346 }; 384 };
347 385
386
387 // Helper defines for ExtendOopClosure
388
389 #define if_do_metadata_checked(closure, nv_suffix) \
390 /* Make sure the non-virtual and the virtual versions match. */ \
391 assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \
392 "Inconsistency in do_metadata"); \
393 if (closure->do_metadata##nv_suffix())
394
395 #define assert_should_ignore_metadata(closure, nv_suffix) \
396 assert(!closure->do_metadata##nv_suffix(), "Code to handle metadata is not implemented")
397
348 #endif // SHARE_VM_MEMORY_ITERATOR_HPP 398 #endif // SHARE_VM_MEMORY_ITERATOR_HPP