< prev index next >

src/hotspot/share/memory/iterator.hpp

Print this page

 37 class ClassLoaderData;
 38 class Symbol;
 39 class Metadata;
 40 class Thread;
 41 
 42 // The following classes are C++ `closures` for iterating over objects, roots and spaces
 43 
 44 class Closure : public StackObj { };
 45 
 46 // Thread iterator
 47 class ThreadClosure {
 48  public:
 49   virtual void do_thread(Thread* thread) = 0;
 50 };
 51 
 52 // OopClosure is used for iterating through references to Java objects.
 53 class OopClosure : public Closure {
 54  public:
 55   virtual void do_oop(oop* o) = 0;
 56   virtual void do_oop(narrowOop* o) = 0;


 57 };
 58 
 59 class DoNothingClosure : public OopClosure {
 60  public:
 61   virtual void do_oop(oop* p)       {}
 62   virtual void do_oop(narrowOop* p) {}
 63 };
 64 extern DoNothingClosure do_nothing_cl;
 65 
 66 // OopIterateClosure adds extra code to be run during oop iterations.
 67 // This is needed by the GC and is extracted to a separate type to not
 68 // pollute the OopClosure interface.
 69 class OopIterateClosure : public OopClosure {
 70  private:
 71   ReferenceDiscoverer* _ref_discoverer;
 72 
 73  protected:
 74   OopIterateClosure(ReferenceDiscoverer* rd) : _ref_discoverer(rd) { }
 75   OopIterateClosure() : _ref_discoverer(NULL) { }
 76   ~OopIterateClosure() { }

 97   //
 98   // 1) do_klass on the header klass pointer.
 99   // 2) do_klass on the klass pointer in the mirrors.
100   // 3) do_cld   on the class loader data in class loaders.
101 
102   virtual bool do_metadata() = 0;
103   virtual void do_klass(Klass* k) = 0;
104   virtual void do_cld(ClassLoaderData* cld) = 0;
105 };
106 
107 // An OopIterateClosure that can be used when there's no need to visit the Metadata.
108 class BasicOopIterateClosure : public OopIterateClosure {
109 public:
110   BasicOopIterateClosure(ReferenceDiscoverer* rd = NULL) : OopIterateClosure(rd) {}
111 
112   virtual bool do_metadata() { return false; }
113   virtual void do_klass(Klass* k) { ShouldNotReachHere(); }
114   virtual void do_cld(ClassLoaderData* cld) { ShouldNotReachHere(); }
115 };
116 





117 class KlassClosure : public Closure {
118  public:
119   virtual void do_klass(Klass* k) = 0;
120 };
121 
122 class CLDClosure : public Closure {
123  public:
124   virtual void do_cld(ClassLoaderData* cld) = 0;
125 };
126 
127 class MetadataClosure : public Closure {
128  public:
129   virtual void do_metadata(Metadata* md) = 0;
130 };
131 
132 
133 class CLDToOopClosure : public CLDClosure {
134   OopClosure*       _oop_closure;
135   int               _cld_claim;
136 

 37 class ClassLoaderData;
 38 class Symbol;
 39 class Metadata;
 40 class Thread;
 41 
 42 // The following classes are C++ `closures` for iterating over objects, roots and spaces
 43 
 44 class Closure : public StackObj { };
 45 
 46 // Thread iterator
 47 class ThreadClosure {
 48  public:
 49   virtual void do_thread(Thread* thread) = 0;
 50 };
 51 
 52 // OopClosure is used for iterating through references to Java objects.
 53 class OopClosure : public Closure {
 54  public:
 55   virtual void do_oop(oop* o) = 0;
 56   virtual void do_oop(narrowOop* o) = 0;
 57   virtual void do_oop_no_buffering(oop* o) { do_oop(o); }
 58   virtual void do_oop_no_buffering(narrowOop* o) { do_oop(o); }
 59 };
 60 
 61 class DoNothingClosure : public OopClosure {
 62  public:
 63   virtual void do_oop(oop* p)       {}
 64   virtual void do_oop(narrowOop* p) {}
 65 };
 66 extern DoNothingClosure do_nothing_cl;
 67 
 68 // OopIterateClosure adds extra code to be run during oop iterations.
 69 // This is needed by the GC and is extracted to a separate type to not
 70 // pollute the OopClosure interface.
 71 class OopIterateClosure : public OopClosure {
 72  private:
 73   ReferenceDiscoverer* _ref_discoverer;
 74 
 75  protected:
 76   OopIterateClosure(ReferenceDiscoverer* rd) : _ref_discoverer(rd) { }
 77   OopIterateClosure() : _ref_discoverer(NULL) { }
 78   ~OopIterateClosure() { }

 99   //
100   // 1) do_klass on the header klass pointer.
101   // 2) do_klass on the klass pointer in the mirrors.
102   // 3) do_cld   on the class loader data in class loaders.
103 
104   virtual bool do_metadata() = 0;
105   virtual void do_klass(Klass* k) = 0;
106   virtual void do_cld(ClassLoaderData* cld) = 0;
107 };
108 
109 // An OopIterateClosure that can be used when there's no need to visit the Metadata.
110 class BasicOopIterateClosure : public OopIterateClosure {
111 public:
112   BasicOopIterateClosure(ReferenceDiscoverer* rd = NULL) : OopIterateClosure(rd) {}
113 
114   virtual bool do_metadata() { return false; }
115   virtual void do_klass(Klass* k) { ShouldNotReachHere(); }
116   virtual void do_cld(ClassLoaderData* cld) { ShouldNotReachHere(); }
117 };
118 
119 class BufferedValueClosure : public Closure {
120 public:
121   virtual void do_buffered_value(oop* p) = 0;
122 };
123 
124 class KlassClosure : public Closure {
125  public:
126   virtual void do_klass(Klass* k) = 0;
127 };
128 
129 class CLDClosure : public Closure {
130  public:
131   virtual void do_cld(ClassLoaderData* cld) = 0;
132 };
133 
134 class MetadataClosure : public Closure {
135  public:
136   virtual void do_metadata(Metadata* md) = 0;
137 };
138 
139 
140 class CLDToOopClosure : public CLDClosure {
141   OopClosure*       _oop_closure;
142   int               _cld_claim;
143 
< prev index next >