Mercurial > hg > graal-jvmci-8
comparison src/share/vm/memory/iterator.hpp @ 935:05f89f00a864
6798898: CMS: bugs related to class unloading
Summary: Override should_remember_klasses() and remember_klass() as needed.
Reviewed-by: ysr, jcoomes
author | jmasa |
---|---|
date | Mon, 24 Aug 2009 10:36:31 -0700 |
parents | 1ee8caae33af |
children | 8b46c4d82093 |
comparison
equal
deleted
inserted
replaced
912:308762b2bf14 | 935:05f89f00a864 |
---|---|
52 virtual void do_oop(narrowOop* o) = 0; | 52 virtual void do_oop(narrowOop* o) = 0; |
53 virtual void do_oop_v(narrowOop* o) { do_oop(o); } | 53 virtual void do_oop_v(narrowOop* o) { do_oop(o); } |
54 | 54 |
55 // In support of post-processing of weak links of KlassKlass objects; | 55 // In support of post-processing of weak links of KlassKlass objects; |
56 // see KlassKlass::oop_oop_iterate(). | 56 // see KlassKlass::oop_oop_iterate(). |
57 virtual const bool should_remember_klasses() const { return false; } | 57 |
58 virtual const bool should_remember_klasses() const { | |
59 assert(!must_remember_klasses(), "Should have overriden this method."); | |
60 return false; | |
61 } | |
62 | |
58 virtual void remember_klass(Klass* k) { /* do nothing */ } | 63 virtual void remember_klass(Klass* k) { /* do nothing */ } |
59 | 64 |
60 // If "true", invoke on nmethods (when scanning compiled frames). | 65 // If "true", invoke on nmethods (when scanning compiled frames). |
61 virtual const bool do_nmethods() const { return false; } | 66 virtual const bool do_nmethods() const { return false; } |
62 | 67 |
72 | 77 |
73 // True iff this closure may be safely applied more than once to an oop | 78 // True iff this closure may be safely applied more than once to an oop |
74 // location without an intervening "major reset" (like the end of a GC). | 79 // location without an intervening "major reset" (like the end of a GC). |
75 virtual bool idempotent() { return false; } | 80 virtual bool idempotent() { return false; } |
76 virtual bool apply_to_weak_ref_discovered_field() { return false; } | 81 virtual bool apply_to_weak_ref_discovered_field() { return false; } |
82 | |
83 #ifdef ASSERT | |
84 static bool _must_remember_klasses; | |
85 static bool must_remember_klasses(); | |
86 static void set_must_remember_klasses(bool v); | |
87 #endif | |
77 }; | 88 }; |
78 | 89 |
79 // ObjectClosure is used for iterating through an object space | 90 // ObjectClosure is used for iterating through an object space |
80 | 91 |
81 class ObjectClosure : public Closure { | 92 class ObjectClosure : public Closure { |
217 // the passed in value and fail is they don't match. This allows | 228 // the passed in value and fail is they don't match. This allows |
218 // for verification that sections of the serialized data are of the | 229 // for verification that sections of the serialized data are of the |
219 // correct length. | 230 // correct length. |
220 virtual void do_tag(int tag) = 0; | 231 virtual void do_tag(int tag) = 0; |
221 }; | 232 }; |
233 | |
234 #ifdef ASSERT | |
235 // This class is used to flag phases of a collection that | |
236 // can unload classes and which should override the | |
237 // should_remember_klasses() and remember_klass() of OopClosure. | |
238 // The _must_remember_klasses is set in the contructor and restored | |
239 // in the destructor. _must_remember_klasses is checked in assertions | |
240 // in the OopClosure implementations of should_remember_klasses() and | |
241 // remember_klass() and the expectation is that the OopClosure | |
242 // implementation should not be in use if _must_remember_klasses is set. | |
243 // Instances of RememberKlassesChecker can be place in | |
244 // marking phases of collections which can do class unloading. | |
245 // RememberKlassesChecker can be passed "false" to turn off checking. | |
246 // It is used by CMS when CMS yields to a different collector. | |
247 class RememberKlassesChecker: StackObj { | |
248 bool _state; | |
249 bool _skip; | |
250 public: | |
251 RememberKlassesChecker(bool checking_on) : _state(false), _skip(false) { | |
252 _skip = !(ClassUnloading && !UseConcMarkSweepGC || | |
253 CMSClassUnloadingEnabled && UseConcMarkSweepGC); | |
254 if (_skip) { | |
255 return; | |
256 } | |
257 _state = OopClosure::must_remember_klasses(); | |
258 OopClosure::set_must_remember_klasses(checking_on); | |
259 } | |
260 ~RememberKlassesChecker() { | |
261 if (_skip) { | |
262 return; | |
263 } | |
264 OopClosure::set_must_remember_klasses(_state); | |
265 } | |
266 }; | |
267 #endif // ASSERT |