comparison src/share/vm/memory/iterator.hpp @ 993:54b3b351d6f9

Merge
author jrose
date Wed, 23 Sep 2009 23:56:15 -0700
parents 148e5441d916 8b46c4d82093
children 753cf9794df9
comparison
equal deleted inserted replaced
992:6a8ccac44f41 993:54b3b351d6f9
24 24
25 // The following classes are C++ `closures` for iterating over objects, roots and spaces 25 // The following classes are C++ `closures` for iterating over objects, roots and spaces
26 26
27 class CodeBlob; 27 class CodeBlob;
28 class ReferenceProcessor; 28 class ReferenceProcessor;
29 class DataLayout;
29 30
30 // Closure provides abortability. 31 // Closure provides abortability.
31 32
32 class Closure : public StackObj { 33 class Closure : public StackObj {
33 protected: 34 protected:
53 virtual void do_oop(narrowOop* o) = 0; 54 virtual void do_oop(narrowOop* o) = 0;
54 virtual void do_oop_v(narrowOop* o) { do_oop(o); } 55 virtual void do_oop_v(narrowOop* o) { do_oop(o); }
55 56
56 // In support of post-processing of weak links of KlassKlass objects; 57 // In support of post-processing of weak links of KlassKlass objects;
57 // see KlassKlass::oop_oop_iterate(). 58 // see KlassKlass::oop_oop_iterate().
58 virtual const bool should_remember_klasses() const { return false; } 59
60 virtual const bool should_remember_klasses() const {
61 assert(!must_remember_klasses(), "Should have overriden this method.");
62 return false;
63 }
64
59 virtual void remember_klass(Klass* k) { /* do nothing */ } 65 virtual void remember_klass(Klass* k) { /* do nothing */ }
66
67 // In support of post-processing of weak references in
68 // ProfileData (MethodDataOop) objects; see, for example,
69 // VirtualCallData::oop_iterate().
70 virtual const bool should_remember_mdo() const { return false; }
71 virtual void remember_mdo(DataLayout* v) { /* do nothing */ }
72
73 // If "true", invoke on nmethods (when scanning compiled frames).
74 virtual const bool do_nmethods() const { return false; }
60 75
61 // The methods below control how object iterations invoking this closure 76 // The methods below control how object iterations invoking this closure
62 // should be performed: 77 // should be performed:
63 78
64 // If "true", invoke on header klass field. 79 // If "true", invoke on header klass field.
70 85
71 // True iff this closure may be safely applied more than once to an oop 86 // True iff this closure may be safely applied more than once to an oop
72 // location without an intervening "major reset" (like the end of a GC). 87 // location without an intervening "major reset" (like the end of a GC).
73 virtual bool idempotent() { return false; } 88 virtual bool idempotent() { return false; }
74 virtual bool apply_to_weak_ref_discovered_field() { return false; } 89 virtual bool apply_to_weak_ref_discovered_field() { return false; }
90
91 #ifdef ASSERT
92 static bool _must_remember_klasses;
93 static bool must_remember_klasses();
94 static void set_must_remember_klasses(bool v);
95 #endif
75 }; 96 };
76 97
77 // ObjectClosure is used for iterating through an object space 98 // ObjectClosure is used for iterating through an object space
78 99
79 class ObjectClosure : public Closure { 100 class ObjectClosure : public Closure {
260 // the passed in value and fail is they don't match. This allows 281 // the passed in value and fail is they don't match. This allows
261 // for verification that sections of the serialized data are of the 282 // for verification that sections of the serialized data are of the
262 // correct length. 283 // correct length.
263 virtual void do_tag(int tag) = 0; 284 virtual void do_tag(int tag) = 0;
264 }; 285 };
286
287 #ifdef ASSERT
288 // This class is used to flag phases of a collection that
289 // can unload classes and which should override the
290 // should_remember_klasses() and remember_klass() of OopClosure.
291 // The _must_remember_klasses is set in the contructor and restored
292 // in the destructor. _must_remember_klasses is checked in assertions
293 // in the OopClosure implementations of should_remember_klasses() and
294 // remember_klass() and the expectation is that the OopClosure
295 // implementation should not be in use if _must_remember_klasses is set.
296 // Instances of RememberKlassesChecker can be place in
297 // marking phases of collections which can do class unloading.
298 // RememberKlassesChecker can be passed "false" to turn off checking.
299 // It is used by CMS when CMS yields to a different collector.
300 class RememberKlassesChecker: StackObj {
301 bool _state;
302 bool _skip;
303 public:
304 RememberKlassesChecker(bool checking_on) : _state(false), _skip(false) {
305 _skip = !(ClassUnloading && !UseConcMarkSweepGC ||
306 CMSClassUnloadingEnabled && UseConcMarkSweepGC);
307 if (_skip) {
308 return;
309 }
310 _state = OopClosure::must_remember_klasses();
311 OopClosure::set_must_remember_klasses(checking_on);
312 }
313 ~RememberKlassesChecker() {
314 if (_skip) {
315 return;
316 }
317 OopClosure::set_must_remember_klasses(_state);
318 }
319 };
320 #endif // ASSERT