src/share/vm/memory/iterator.hpp

changeset 6992
2c6ef90f030a
parent 6982
4c1b88a53c74
child 7535
7ae4e26cb1e0
child 9661
379a59bf685d
equal deleted inserted replaced
6991:882004b9e7e1 6992:2c6ef90f030a
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
143 void initialize(OopClosure* oop_closure) { 143 void initialize(OopClosure* oop_closure) {
144 assert(_oop_closure == NULL, "Should only be called once"); 144 assert(_oop_closure == NULL, "Should only be called once");
145 _oop_closure = oop_closure; 145 _oop_closure = oop_closure;
146 } 146 }
147 147
148 public: 148 public:
149 KlassToOopClosure(OopClosure* oop_closure = NULL) : _oop_closure(oop_closure) {} 149 KlassToOopClosure(OopClosure* oop_closure = NULL) : _oop_closure(oop_closure) {}
150
150 virtual void do_klass(Klass* k); 151 virtual void do_klass(Klass* k);
151 }; 152 };
152 153
153 class CLDToOopClosure : public CLDClosure { 154 class CLDToOopClosure : public CLDClosure {
154 OopClosure* _oop_closure; 155 OopClosure* _oop_closure;
155 KlassToOopClosure _klass_closure; 156 KlassToOopClosure _klass_closure;
156 bool _must_claim_cld; 157 bool _must_claim_cld;
157 158
158 public: 159 public:
159 CLDToOopClosure(OopClosure* oop_closure, bool must_claim_cld = true) : 160 CLDToOopClosure(OopClosure* oop_closure, bool must_claim_cld = true) :
160 _oop_closure(oop_closure), 161 _oop_closure(oop_closure),
161 _klass_closure(oop_closure), 162 _klass_closure(oop_closure),
162 _must_claim_cld(must_claim_cld) {} 163 _must_claim_cld(must_claim_cld) {}
163 164
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) {}
164 void do_cld(ClassLoaderData* cld); 182 void do_cld(ClassLoaderData* cld);
165 }; 183 };
166 184
167 // The base class for all concurrent marking closures, 185 // The base class for all concurrent marking closures,
168 // that participates in class unloading. 186 // that participates in class unloading.
263 public: 281 public:
264 // Called for each code blob. 282 // Called for each code blob.
265 virtual void do_code_blob(CodeBlob* cb) = 0; 283 virtual void do_code_blob(CodeBlob* cb) = 0;
266 }; 284 };
267 285
268 286 // Applies an oop closure to all ref fields in code blobs
269 class MarkingCodeBlobClosure : public CodeBlobClosure { 287 // iterated over in an object iteration.
270 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) {}
271 // 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.
272 virtual void do_newly_marked_nmethod(nmethod* nm) = 0;
273 304
274 virtual void do_code_blob(CodeBlob* cb); 305 virtual void do_code_blob(CodeBlob* cb);
275 // = { if (!nmethod(cb)->test_set_oops_do_mark()) do_newly_marked_nmethod(cb); }
276 306
277 class MarkScope : public StackObj { 307 class MarkScope : public StackObj {
278 protected: 308 protected:
279 bool _active; 309 bool _active;
280 public: 310 public:
282 // = { if (active) nmethod::oops_do_marking_prologue(); } 312 // = { if (active) nmethod::oops_do_marking_prologue(); }
283 ~MarkScope(); 313 ~MarkScope();
284 // = { if (active) nmethod::oops_do_marking_epilogue(); } 314 // = { if (active) nmethod::oops_do_marking_epilogue(); }
285 }; 315 };
286 }; 316 };
287
288
289 // Applies an oop closure to all ref fields in code blobs
290 // iterated over in an object iteration.
291 class CodeBlobToOopClosure: public MarkingCodeBlobClosure {
292 OopClosure* _cl;
293 bool _do_marking;
294 public:
295 virtual void do_newly_marked_nmethod(nmethod* cb);
296 // = { cb->oops_do(_cl); }
297 virtual void do_code_blob(CodeBlob* cb);
298 // = { if (_do_marking) super::do_code_blob(cb); else cb->oops_do(_cl); }
299 CodeBlobToOopClosure(OopClosure* cl, bool do_marking)
300 : _cl(cl), _do_marking(do_marking) {}
301 };
302
303
304 317
305 // MonitorClosure is used for iterating over monitors in the monitors cache 318 // MonitorClosure is used for iterating over monitors in the monitors cache
306 319
307 class ObjectMonitor; 320 class ObjectMonitor;
308 321

mercurial