< prev index next >

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

Print this page

 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/stringdedup/stringDedup.hpp"
 31 #include "gc/shared/taskqueue.hpp"
 32 #include "memory/iterator.hpp"
 33 #include "oops/markWord.hpp"
 34 #include "oops/oop.hpp"
 35 #include "runtime/timer.hpp"
 36 #include "utilities/growableArray.hpp"
 37 #include "utilities/stack.hpp"
 38 
 39 class ReferenceProcessor;
 40 class DataLayout;
 41 class SerialOldTracer;

 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:

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


191  public:

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   PreservedMark(oop obj, markWord mark) : _obj(obj), _mark(mark) {}
205   void adjust_pointer();
206   void restore();
207 };
208 
209 #endif // SHARE_GC_SERIAL_MARKSWEEP_HPP

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

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   static StringDedup::Requests* _string_dedup_requests;
117 
118   // Non public closures
119   static KeepAliveClosure keep_alive;
120 
121  public:
122   static void initialize();
123 
124   // Public closures
125   static IsAliveClosure       is_alive;
126   static FollowRootClosure    follow_root_closure;
127   static MarkAndPushClosure   mark_and_push_closure;
128   static FollowStackClosure   follow_stack_closure;
129   static CLDToOopClosure      follow_cld_closure;


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