< prev index next >

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

Print this page

 43 
 44 Stack<oop, mtGC>              MarkSweep::_marking_stack;
 45 Stack<ObjArrayTask, mtGC>     MarkSweep::_objarray_stack;
 46 
 47 PreservedMarksSet       MarkSweep::_preserved_overflow_stack_set(false /* in_c_heap */);
 48 size_t                  MarkSweep::_preserved_count = 0;
 49 size_t                  MarkSweep::_preserved_count_max = 0;
 50 PreservedMark*          MarkSweep::_preserved_marks = nullptr;
 51 STWGCTimer*             MarkSweep::_gc_timer        = nullptr;
 52 SerialOldTracer*        MarkSweep::_gc_tracer       = nullptr;
 53 
 54 AlwaysTrueClosure   MarkSweep::_always_true_closure;
 55 ReferenceProcessor* MarkSweep::_ref_processor;
 56 
 57 StringDedup::Requests*  MarkSweep::_string_dedup_requests = nullptr;
 58 
 59 MarkSweep::FollowRootClosure  MarkSweep::follow_root_closure;
 60 
 61 MarkAndPushClosure MarkSweep::mark_and_push_closure(ClassLoaderData::_claim_stw_fullgc_mark);
 62 CLDToOopClosure    MarkSweep::follow_cld_closure(&mark_and_push_closure, ClassLoaderData::_claim_stw_fullgc_mark);
 63 CLDToOopClosure    MarkSweep::adjust_cld_closure(&adjust_pointer_closure, ClassLoaderData::_claim_stw_fullgc_adjust);
 64 
 65 template <class T> void MarkSweep::KeepAliveClosure::do_oop_work(T* p) {
 66   mark_and_push(p);
 67 }
 68 
 69 void MarkSweep::push_objarray(oop obj, size_t index) {
 70   ObjArrayTask task(obj, index);
 71   assert(task.is_valid(), "bad ObjArrayTask");
 72   _objarray_stack.push(task);
 73 }
 74 
 75 void MarkSweep::follow_array(objArrayOop array) {
 76   mark_and_push_closure.do_klass(array->klass());
 77   // Don't push empty arrays to avoid unnecessary work.
 78   if (array->length() > 0) {
 79     MarkSweep::push_objarray(array, 0);
 80   }
 81 }
 82 
 83 void MarkSweep::follow_object(oop obj) {

147 // currently at that address but it will be after phase4
148 void MarkSweep::preserve_mark(oop obj, markWord mark) {
149   // We try to store preserved marks in the to space of the new generation since
150   // this is storage which should be available.  Most of the time this should be
151   // sufficient space for the marks we need to preserve but if it isn't we fall
152   // back to using Stacks to keep track of the overflow.
153   if (_preserved_count < _preserved_count_max) {
154     _preserved_marks[_preserved_count++] = PreservedMark(obj, mark);
155   } else {
156     _preserved_overflow_stack_set.get()->push_always(obj, mark);
157   }
158 }
159 
160 void MarkSweep::mark_object(oop obj) {
161   if (StringDedup::is_enabled() &&
162       java_lang_String::is_instance(obj) &&
163       SerialStringDedup::is_candidate_from_mark(obj)) {
164     _string_dedup_requests->add(obj);
165   }
166 




167   // some marks may contain information we need to preserve so we store them away
168   // and overwrite the mark.  We'll restore it at the end of markSweep.
169   markWord mark = obj->mark();
170   obj->set_mark(markWord::prototype().set_marked());
171 
172   ContinuationGCSupport::transform_stack_chunk(obj);
173 
174   if (obj->mark_must_be_preserved(mark)) {
175     preserve_mark(obj, mark);
176   }
177 }
178 
179 template <class T> void MarkSweep::mark_and_push(T* p) {
180   T heap_oop = RawAccess<>::oop_load(p);
181   if (!CompressedOops::is_null(heap_oop)) {
182     oop obj = CompressedOops::decode_not_null(heap_oop);
183     if (!obj->mark().is_marked()) {
184       mark_object(obj);
185       _marking_stack.push(obj);
186     }
187   }
188 }
189 
190 template <typename T>
191 void MarkAndPushClosure::do_oop_work(T* p)            { MarkSweep::mark_and_push(p); }
192 void MarkAndPushClosure::do_oop(      oop* p)         { do_oop_work(p); }
193 void MarkAndPushClosure::do_oop(narrowOop* p)         { do_oop_work(p); }
194 
195 AdjustPointerClosure MarkSweep::adjust_pointer_closure;
196 
197 void MarkSweep::adjust_marks() {
198   // adjust the oops we saved earlier
199   for (size_t i = 0; i < _preserved_count; i++) {
200     PreservedMarks::adjust_preserved_mark(_preserved_marks + i);
201   }
202 
203   // deal with the overflow stack
204   _preserved_overflow_stack_set.get()->adjust_during_full_gc();
205 }
206 








207 void MarkSweep::restore_marks() {
208   log_trace(gc)("Restoring " SIZE_FORMAT " marks", _preserved_count + _preserved_overflow_stack_set.get()->size());
209 
210   // restore the marks we saved earlier
211   for (size_t i = 0; i < _preserved_count; i++) {
212     _preserved_marks[i].set_mark();
213   }
214 
215   // deal with the overflow
216   _preserved_overflow_stack_set.restore(nullptr);
217 }
218 
219 MarkSweep::IsAliveClosure   MarkSweep::is_alive;
220 
221 bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); }
222 
223 MarkSweep::KeepAliveClosure MarkSweep::keep_alive;
224 
225 void MarkSweep::KeepAliveClosure::do_oop(oop* p)       { MarkSweep::KeepAliveClosure::do_oop_work(p); }
226 void MarkSweep::KeepAliveClosure::do_oop(narrowOop* p) { MarkSweep::KeepAliveClosure::do_oop_work(p); }

 43 
 44 Stack<oop, mtGC>              MarkSweep::_marking_stack;
 45 Stack<ObjArrayTask, mtGC>     MarkSweep::_objarray_stack;
 46 
 47 PreservedMarksSet       MarkSweep::_preserved_overflow_stack_set(false /* in_c_heap */);
 48 size_t                  MarkSweep::_preserved_count = 0;
 49 size_t                  MarkSweep::_preserved_count_max = 0;
 50 PreservedMark*          MarkSweep::_preserved_marks = nullptr;
 51 STWGCTimer*             MarkSweep::_gc_timer        = nullptr;
 52 SerialOldTracer*        MarkSweep::_gc_tracer       = nullptr;
 53 
 54 AlwaysTrueClosure   MarkSweep::_always_true_closure;
 55 ReferenceProcessor* MarkSweep::_ref_processor;
 56 
 57 StringDedup::Requests*  MarkSweep::_string_dedup_requests = nullptr;
 58 
 59 MarkSweep::FollowRootClosure  MarkSweep::follow_root_closure;
 60 
 61 MarkAndPushClosure MarkSweep::mark_and_push_closure(ClassLoaderData::_claim_stw_fullgc_mark);
 62 CLDToOopClosure    MarkSweep::follow_cld_closure(&mark_and_push_closure, ClassLoaderData::_claim_stw_fullgc_mark);

 63 
 64 template <class T> void MarkSweep::KeepAliveClosure::do_oop_work(T* p) {
 65   mark_and_push(p);
 66 }
 67 
 68 void MarkSweep::push_objarray(oop obj, size_t index) {
 69   ObjArrayTask task(obj, index);
 70   assert(task.is_valid(), "bad ObjArrayTask");
 71   _objarray_stack.push(task);
 72 }
 73 
 74 void MarkSweep::follow_array(objArrayOop array) {
 75   mark_and_push_closure.do_klass(array->klass());
 76   // Don't push empty arrays to avoid unnecessary work.
 77   if (array->length() > 0) {
 78     MarkSweep::push_objarray(array, 0);
 79   }
 80 }
 81 
 82 void MarkSweep::follow_object(oop obj) {

146 // currently at that address but it will be after phase4
147 void MarkSweep::preserve_mark(oop obj, markWord mark) {
148   // We try to store preserved marks in the to space of the new generation since
149   // this is storage which should be available.  Most of the time this should be
150   // sufficient space for the marks we need to preserve but if it isn't we fall
151   // back to using Stacks to keep track of the overflow.
152   if (_preserved_count < _preserved_count_max) {
153     _preserved_marks[_preserved_count++] = PreservedMark(obj, mark);
154   } else {
155     _preserved_overflow_stack_set.get()->push_always(obj, mark);
156   }
157 }
158 
159 void MarkSweep::mark_object(oop obj) {
160   if (StringDedup::is_enabled() &&
161       java_lang_String::is_instance(obj) &&
162       SerialStringDedup::is_candidate_from_mark(obj)) {
163     _string_dedup_requests->add(obj);
164   }
165 
166   // Do the transform while we still have the header intact,
167   // which might include important class information.
168   ContinuationGCSupport::transform_stack_chunk(obj);
169 
170   // some marks may contain information we need to preserve so we store them away
171   // and overwrite the mark.  We'll restore it at the end of markSweep.
172   markWord mark = obj->mark();
173   obj->set_mark(obj->prototype_mark().set_marked());


174 
175   if (obj->mark_must_be_preserved(mark)) {
176     preserve_mark(obj, mark);
177   }
178 }
179 
180 template <class T> void MarkSweep::mark_and_push(T* p) {
181   T heap_oop = RawAccess<>::oop_load(p);
182   if (!CompressedOops::is_null(heap_oop)) {
183     oop obj = CompressedOops::decode_not_null(heap_oop);
184     if (!obj->mark().is_marked()) {
185       mark_object(obj);
186       _marking_stack.push(obj);
187     }
188   }
189 }
190 
191 template <typename T>
192 void MarkAndPushClosure::do_oop_work(T* p)            { MarkSweep::mark_and_push(p); }
193 void MarkAndPushClosure::do_oop(      oop* p)         { do_oop_work(p); }
194 void MarkAndPushClosure::do_oop(narrowOop* p)         { do_oop_work(p); }
195 
196 template <bool ALT_FWD>
197 void MarkSweep::adjust_marks_impl() {

198   // adjust the oops we saved earlier
199   for (size_t i = 0; i < _preserved_count; i++) {
200     PreservedMarks::adjust_preserved_mark<ALT_FWD>(_preserved_marks + i);
201   }
202 
203   // deal with the overflow stack
204   _preserved_overflow_stack_set.get()->adjust_during_full_gc();
205 }
206 
207 void MarkSweep::adjust_marks() {
208   if (UseAltGCForwarding) {
209     adjust_marks_impl<true>();
210   } else {
211     adjust_marks_impl<false>();
212   }
213 }
214 
215 void MarkSweep::restore_marks() {
216   log_trace(gc)("Restoring " SIZE_FORMAT " marks", _preserved_count + _preserved_overflow_stack_set.get()->size());
217 
218   // restore the marks we saved earlier
219   for (size_t i = 0; i < _preserved_count; i++) {
220     _preserved_marks[i].set_mark();
221   }
222 
223   // deal with the overflow
224   _preserved_overflow_stack_set.restore(nullptr);
225 }
226 
227 MarkSweep::IsAliveClosure   MarkSweep::is_alive;
228 
229 bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); }
230 
231 MarkSweep::KeepAliveClosure MarkSweep::keep_alive;
232 
233 void MarkSweep::KeepAliveClosure::do_oop(oop* p)       { MarkSweep::KeepAliveClosure::do_oop_work(p); }
234 void MarkSweep::KeepAliveClosure::do_oop(narrowOop* p) { MarkSweep::KeepAliveClosure::do_oop_work(p); }
< prev index next >