< prev index next >

src/hotspot/share/gc/serial/markSweep.hpp

Print this page

 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_GC_SERIAL_MARKSWEEP_HPP
 26 #define SHARE_GC_SERIAL_MARKSWEEP_HPP
 27 
 28 #include "gc/shared/collectedHeap.hpp"
 29 #include "gc/shared/genOopClosures.hpp"
 30 #include "gc/shared/taskqueue.hpp"
 31 #include "memory/iterator.hpp"
 32 #include "oops/markWord.hpp"
 33 #include "oops/oop.hpp"
 34 #include "runtime/timer.hpp"
 35 #include "utilities/growableArray.hpp"
 36 #include "utilities/stack.hpp"
 37 
 38 class ReferenceProcessor;
 39 class DataLayout;
 40 class SerialOldTracer;

 41 class STWGCTimer;
 42 
 43 // MarkSweep takes care of global mark-compact garbage collection for a
 44 // GenCollectedHeap using a four-phase pointer forwarding algorithm.  All
 45 // generations are assumed to support marking; those that can also support
 46 // compaction.
 47 //
 48 // Class unloading will only occur when a full gc is invoked.
 49 
 50 // declared at end
 51 class PreservedMark;
 52 class MarkAndPushClosure;
 53 class AdjustPointerClosure;
 54 
 55 class MarkSweep : AllStatic {
 56   //
 57   // Inline closure decls
 58   //
 59   class FollowRootClosure: public BasicOopIterateClosure {
 60    public:

107   static PreservedMark*                  _preserved_marks;
108 
109   // Reference processing (used in ...follow_contents)
110   static ReferenceProcessor*             _ref_processor;
111 
112   static STWGCTimer*                     _gc_timer;
113   static SerialOldTracer*                _gc_tracer;
114 
115   // Non public closures
116   static KeepAliveClosure keep_alive;
117 
118  public:
119   static void initialize();
120 
121   // Public closures
122   static IsAliveClosure       is_alive;
123   static FollowRootClosure    follow_root_closure;
124   static MarkAndPushClosure   mark_and_push_closure;
125   static FollowStackClosure   follow_stack_closure;
126   static CLDToOopClosure      follow_cld_closure;
127   static AdjustPointerClosure adjust_pointer_closure;
128   static CLDToOopClosure      adjust_cld_closure;
129 
130   // Accessors
131   static uint total_invocations() { return _total_invocations; }
132 
133   // Reference Processing
134   static ReferenceProcessor* const ref_processor() { return _ref_processor; }
135   static void set_ref_processor(ReferenceProcessor* rp);
136 
137   static STWGCTimer* gc_timer() { return _gc_timer; }
138   static SerialOldTracer* gc_tracer() { return _gc_tracer; }
139 
140   static void preserve_mark(oop p, markWord mark);
141                                 // Save the mark word so it can be restored later
142   static void adjust_marks();   // Adjust the pointers in the preserved marks table
143   static void restore_marks();  // Restore the marks that we saved in preserve_mark
144 
145   static int adjust_pointers(oop obj);
146 
147   static void follow_stack();   // Empty marking stack.
148 
149   static void follow_klass(Klass* klass);
150 
151   static void follow_cld(ClassLoaderData* cld);
152 
153   template <class T> static inline void adjust_pointer(T* p);
154 
155   // Check mark and maybe push on marking stack
156   template <class T> static void mark_and_push(T* p);
157 
158  private:
159   // Call backs for marking
160   static void mark_object(oop obj);
161   // Mark pointer and follow contents.  Empty marking stack afterwards.
162   template <class T> static inline void follow_root(T* p);
163 
164   static inline void push_objarray(oop obj, size_t index);
165 
166   static void follow_object(oop obj);
167 
168   static void follow_array(objArrayOop array);
169 
170   static void follow_array_chunk(objArrayOop array, int index);
171 };
172 
173 class MarkAndPushClosure: public OopIterateClosure {
174 public:
175   template <typename T> void do_oop_work(T* p);
176   virtual void do_oop(oop* p);
177   virtual void do_oop(narrowOop* p);
178 
179   virtual bool do_metadata() { return true; }
180   virtual void do_klass(Klass* k);
181   virtual void do_cld(ClassLoaderData* cld);
182 
183   void set_ref_discoverer(ReferenceDiscoverer* rd) {
184     set_ref_discoverer_internal(rd);
185   }
186 };
187 
188 class AdjustPointerClosure: public BasicOopIterateClosure {


189  public:

190   template <typename T> void do_oop_work(T* p);
191   virtual void do_oop(oop* p);
192   virtual void do_oop(narrowOop* p);
193   virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
194 };
195 
196 class PreservedMark {
197 private:
198   oop _obj;
199   markWord _mark;
200 
201 public:
202   void init(oop obj, markWord mark) {
203     _obj = obj;
204     _mark = mark;
205   }
206 
207   void adjust_pointer();
208   void restore();
209 };
210 
211 #endif // SHARE_GC_SERIAL_MARKSWEEP_HPP

 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_GC_SERIAL_MARKSWEEP_HPP
 26 #define SHARE_GC_SERIAL_MARKSWEEP_HPP
 27 
 28 #include "gc/shared/collectedHeap.hpp"
 29 #include "gc/shared/genOopClosures.hpp"
 30 #include "gc/shared/taskqueue.hpp"
 31 #include "memory/iterator.hpp"
 32 #include "oops/markWord.hpp"
 33 #include "oops/oop.hpp"
 34 #include "runtime/timer.hpp"
 35 #include "utilities/growableArray.hpp"
 36 #include "utilities/stack.hpp"
 37 
 38 class ReferenceProcessor;
 39 class DataLayout;
 40 class SerialOldTracer;
 41 class SlidingForwarding;
 42 class STWGCTimer;
 43 
 44 // MarkSweep takes care of global mark-compact garbage collection for a
 45 // GenCollectedHeap using a four-phase pointer forwarding algorithm.  All
 46 // generations are assumed to support marking; those that can also support
 47 // compaction.
 48 //
 49 // Class unloading will only occur when a full gc is invoked.
 50 
 51 // declared at end
 52 class PreservedMark;
 53 class MarkAndPushClosure;
 54 class AdjustPointerClosure;
 55 
 56 class MarkSweep : AllStatic {
 57   //
 58   // Inline closure decls
 59   //
 60   class FollowRootClosure: public BasicOopIterateClosure {
 61    public:

108   static PreservedMark*                  _preserved_marks;
109 
110   // Reference processing (used in ...follow_contents)
111   static ReferenceProcessor*             _ref_processor;
112 
113   static STWGCTimer*                     _gc_timer;
114   static SerialOldTracer*                _gc_tracer;
115 
116   // Non public closures
117   static KeepAliveClosure keep_alive;
118 
119  public:
120   static void initialize();
121 
122   // Public closures
123   static IsAliveClosure       is_alive;
124   static FollowRootClosure    follow_root_closure;
125   static MarkAndPushClosure   mark_and_push_closure;
126   static FollowStackClosure   follow_stack_closure;
127   static CLDToOopClosure      follow_cld_closure;


128 
129   // Accessors
130   static uint total_invocations() { return _total_invocations; }
131 
132   // Reference Processing
133   static ReferenceProcessor* const ref_processor() { return _ref_processor; }
134   static void set_ref_processor(ReferenceProcessor* rp);
135 
136   static STWGCTimer* gc_timer() { return _gc_timer; }
137   static SerialOldTracer* gc_tracer() { return _gc_tracer; }
138 
139   static void preserve_mark(oop p, markWord mark);
140                                 // Save the mark word so it can be restored later
141   static void adjust_marks();   // Adjust the pointers in the preserved marks table
142   static void restore_marks();  // Restore the marks that we saved in preserve_mark
143 
144   static int adjust_pointers(const SlidingForwarding* const forwarding, oop obj);
145 
146   static void follow_stack();   // Empty marking stack.
147 
148   static void follow_klass(Klass* klass);
149 
150   static void follow_cld(ClassLoaderData* cld);
151 
152   template <class T> static inline void adjust_pointer(const SlidingForwarding* const forwarding, T* p);
153 
154   // Check mark and maybe push on marking stack
155   template <class T> static void mark_and_push(T* p);
156 
157  private:
158   // Call backs for marking
159   static void mark_object(oop obj);
160   // Mark pointer and follow contents.  Empty marking stack afterwards.
161   template <class T> static inline void follow_root(T* p);
162 
163   static inline void push_objarray(oop obj, size_t index);
164 
165   static void follow_object(oop obj);
166 
167   static void follow_array(objArrayOop array);
168 
169   static void follow_array_chunk(objArrayOop array, int index);
170 };
171 
172 class MarkAndPushClosure: public OopIterateClosure {
173 public:
174   template <typename T> void do_oop_work(T* p);
175   virtual void do_oop(oop* p);
176   virtual void do_oop(narrowOop* p);
177 
178   virtual bool do_metadata() { return true; }
179   virtual void do_klass(Klass* k);
180   virtual void do_cld(ClassLoaderData* cld);
181 
182   void set_ref_discoverer(ReferenceDiscoverer* rd) {
183     set_ref_discoverer_internal(rd);
184   }
185 };
186 
187 class AdjustPointerClosure: public BasicOopIterateClosure {
188 private:
189   const SlidingForwarding* const _forwarding;
190  public:
191   AdjustPointerClosure(const SlidingForwarding* forwarding) : _forwarding(forwarding) {}
192   template <typename T> void do_oop_work(T* p);
193   virtual void do_oop(oop* p);
194   virtual void do_oop(narrowOop* p);
195   virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
196 };
197 
198 class PreservedMark {
199 private:
200   oop _obj;
201   markWord _mark;
202 
203 public:
204   void init(oop obj, markWord mark) {
205     _obj = obj;
206     _mark = mark;
207   }
208 
209   void adjust_pointer(const SlidingForwarding* const forwarding);
210   void restore();
211 };
212 
213 #endif // SHARE_GC_SERIAL_MARKSWEEP_HPP
< prev index next >