< prev index next >

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

Print this page

 34 #include "oops/markWord.hpp"
 35 #include "oops/oop.hpp"
 36 #include "runtime/timer.hpp"
 37 #include "utilities/growableArray.hpp"
 38 #include "utilities/stack.hpp"
 39 
 40 class DataLayout;
 41 class SerialOldTracer;
 42 class STWGCTimer;
 43 
 44 // MarkSweep takes care of global mark-compact garbage collection for a
 45 // SerialHeap 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:
 62     virtual void do_oop(oop* p);
 63     virtual void do_oop(narrowOop* p);
 64   };
 65 
 66   class FollowStackClosure: public VoidClosure {
 67    public:
 68     virtual void do_void();
 69   };
 70 
 71   // Used for java/lang/ref handling
 72   class IsAliveClosure: public BoolObjectClosure {
 73    public:
 74     virtual bool do_object_b(oop p);
 75   };
 76 
 77   class KeepAliveClosure: public OopClosure {
 78    protected:
 79     template <class T> void do_oop_work(T* p);
 80    public:
 81     virtual void do_oop(oop* p);
 82     virtual void do_oop(narrowOop* p);
 83   };
 84 
 85   //
 86   // Friend decls
 87   //
 88   friend class AdjustPointerClosure;
 89   friend class KeepAliveClosure;
 90 
 91   //
 92   // Vars
 93   //
 94  protected:
 95   // Total invocations of a MarkSweep collection
 96   static uint _total_invocations;
 97 
 98   // Traversal stacks used during phase1
 99   static Stack<oop, mtGC>                      _marking_stack;
100   static Stack<ObjArrayTask, mtGC>             _objarray_stack;
101 
102   // Space for storing/restoring mark word
103   static PreservedMarksSet               _preserved_overflow_stack_set;
104   static size_t                          _preserved_count;
105   static size_t                          _preserved_count_max;
106   static PreservedMark*                  _preserved_marks;
107 
108   static AlwaysTrueClosure               _always_true_closure;
109   static ReferenceProcessor*             _ref_processor;
110 
111   static STWGCTimer*                     _gc_timer;
112   static SerialOldTracer*                _gc_tracer;
113 
114   static StringDedup::Requests* _string_dedup_requests;
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   static AdjustPointerClosure adjust_pointer_closure;
129   static CLDToOopClosure      adjust_cld_closure;
130 
131   // Accessors
132   static uint total_invocations() { return _total_invocations; }
133 
134   // Reference Processing
135   static ReferenceProcessor* ref_processor() { return _ref_processor; }
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 size_t adjust_pointers(oop obj);
146 
147   static void follow_stack();   // Empty marking stack.
148 
149   template <class T> static inline void adjust_pointer(T* p);

150 
151   // Check mark and maybe push on marking stack
152   template <class T> static void mark_and_push(T* p);
153 
154  private:



155   // Call backs for marking
156   static void mark_object(oop obj);
157   // Mark pointer and follow contents.  Empty marking stack afterwards.
158   template <class T> static inline void follow_root(T* p);
159 
160   static inline void push_objarray(oop obj, size_t index);
161 
162   static void follow_object(oop obj);
163 
164   static void follow_array(objArrayOop array);
165 
166   static void follow_array_chunk(objArrayOop array, int index);
167 };
168 
169 class MarkAndPushClosure: public ClaimMetadataVisitingOopIterateClosure {
170 public:
171   MarkAndPushClosure(int claim) : ClaimMetadataVisitingOopIterateClosure(claim) {}
172 
173   template <typename T> void do_oop_work(T* p);
174   virtual void do_oop(      oop* p);
175   virtual void do_oop(narrowOop* p);
176 
177   void set_ref_discoverer(ReferenceDiscoverer* rd) {
178     set_ref_discoverer_internal(rd);
179   }
180 };
181 

182 class AdjustPointerClosure: public BasicOopIterateClosure {
183  public:
184   template <typename T> void do_oop_work(T* p);
185   virtual void do_oop(oop* p);
186   virtual void do_oop(narrowOop* p);
187   virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
188 };
189 
190 #endif // SHARE_GC_SERIAL_MARKSWEEP_HPP

 34 #include "oops/markWord.hpp"
 35 #include "oops/oop.hpp"
 36 #include "runtime/timer.hpp"
 37 #include "utilities/growableArray.hpp"
 38 #include "utilities/stack.hpp"
 39 
 40 class DataLayout;
 41 class SerialOldTracer;
 42 class STWGCTimer;
 43 
 44 // MarkSweep takes care of global mark-compact garbage collection for a
 45 // SerialHeap 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 
 55 class MarkSweep : AllStatic {
 56   //
 57   // Inline closure decls
 58   //
 59   class FollowRootClosure: public BasicOopIterateClosure {
 60    public:
 61     virtual void do_oop(oop* p);
 62     virtual void do_oop(narrowOop* p);
 63   };
 64 
 65   class FollowStackClosure: public VoidClosure {
 66    public:
 67     virtual void do_void();
 68   };
 69 
 70   // Used for java/lang/ref handling
 71   class IsAliveClosure: public BoolObjectClosure {
 72    public:
 73     virtual bool do_object_b(oop p);
 74   };
 75 
 76   class KeepAliveClosure: public OopClosure {
 77    protected:
 78     template <class T> void do_oop_work(T* p);
 79    public:
 80     virtual void do_oop(oop* p);
 81     virtual void do_oop(narrowOop* p);
 82   };
 83 
 84   //
 85   // Friend decls
 86   //

 87   friend class KeepAliveClosure;
 88 
 89   //
 90   // Vars
 91   //
 92  protected:
 93   // Total invocations of a MarkSweep collection
 94   static uint _total_invocations;
 95 
 96   // Traversal stacks used during phase1
 97   static Stack<oop, mtGC>                      _marking_stack;
 98   static Stack<ObjArrayTask, mtGC>             _objarray_stack;
 99 
100   // Space for storing/restoring mark word
101   static PreservedMarksSet               _preserved_overflow_stack_set;
102   static size_t                          _preserved_count;
103   static size_t                          _preserved_count_max;
104   static PreservedMark*                  _preserved_marks;
105 
106   static AlwaysTrueClosure               _always_true_closure;
107   static ReferenceProcessor*             _ref_processor;
108 
109   static STWGCTimer*                     _gc_timer;
110   static SerialOldTracer*                _gc_tracer;
111 
112   static StringDedup::Requests* _string_dedup_requests;
113 
114   // Non public closures
115   static KeepAliveClosure keep_alive;
116 
117  public:
118   static void initialize();
119 
120   // Public closures
121   static IsAliveClosure       is_alive;
122   static FollowRootClosure    follow_root_closure;
123   static MarkAndPushClosure   mark_and_push_closure;
124   static FollowStackClosure   follow_stack_closure;
125   static CLDToOopClosure      follow_cld_closure;


126 
127   // Accessors
128   static uint total_invocations() { return _total_invocations; }
129 
130   // Reference Processing
131   static ReferenceProcessor* ref_processor() { return _ref_processor; }
132 
133   static STWGCTimer* gc_timer() { return _gc_timer; }
134   static SerialOldTracer* gc_tracer() { return _gc_tracer; }
135 
136   static void preserve_mark(oop p, markWord mark);
137                                 // Save the mark word so it can be restored later
138   static void adjust_marks();   // Adjust the pointers in the preserved marks table
139   static void restore_marks();  // Restore the marks that we saved in preserve_mark
140 
141   template <bool ALT_FWD>
142   static size_t adjust_pointers(oop obj);
143 
144   static void follow_stack();   // Empty marking stack.
145 
146   template <bool ALT_FWD, class T>
147   static void adjust_pointer(T* p);
148 
149   // Check mark and maybe push on marking stack
150   template <class T> static void mark_and_push(T* p);
151 
152  private:
153   template <bool ALT_FWD>
154   static void adjust_marks_impl();
155 
156   // Call backs for marking
157   static void mark_object(oop obj);
158   // Mark pointer and follow contents.  Empty marking stack afterwards.
159   template <class T> static inline void follow_root(T* p);
160 
161   static inline void push_objarray(oop obj, size_t index);
162 
163   static void follow_object(oop obj);
164 
165   static void follow_array(objArrayOop array);
166 
167   static void follow_array_chunk(objArrayOop array, int index);
168 };
169 
170 class MarkAndPushClosure: public ClaimMetadataVisitingOopIterateClosure {
171 public:
172   MarkAndPushClosure(int claim) : ClaimMetadataVisitingOopIterateClosure(claim) {}
173 
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   void set_ref_discoverer(ReferenceDiscoverer* rd) {
179     set_ref_discoverer_internal(rd);
180   }
181 };
182 
183 template <bool ALT_FWD>
184 class AdjustPointerClosure: public BasicOopIterateClosure {
185  public:
186   template <typename T> void do_oop_work(T* p);
187   virtual void do_oop(oop* p);
188   virtual void do_oop(narrowOop* p);
189   virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
190 };
191 
192 #endif // SHARE_GC_SERIAL_MARKSWEEP_HPP
< prev index next >