Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/shared/markSweep.cpp @ 7448:b735136e0d82
8004132: SerialGC: ValidateMarkSweep broken when running GCOld
Summary: Remove bit-rotten ValidateMarkSweep functionality and flag.
Reviewed-by: johnc, jmasa
Contributed-by: tamao <tao.mao@oracle.com>
author | johnc |
---|---|
date | Wed, 02 Jan 2013 11:32:41 -0800 |
parents | d8ce2825b193 |
children | a08c80e9e1e5 |
comparison
equal
deleted
inserted
replaced
7447:1de1b145f6bc | 7448:b735136e0d82 |
---|---|
39 Stack<markOop, mtGC> MarkSweep::_preserved_mark_stack; | 39 Stack<markOop, mtGC> MarkSweep::_preserved_mark_stack; |
40 size_t MarkSweep::_preserved_count = 0; | 40 size_t MarkSweep::_preserved_count = 0; |
41 size_t MarkSweep::_preserved_count_max = 0; | 41 size_t MarkSweep::_preserved_count_max = 0; |
42 PreservedMark* MarkSweep::_preserved_marks = NULL; | 42 PreservedMark* MarkSweep::_preserved_marks = NULL; |
43 ReferenceProcessor* MarkSweep::_ref_processor = NULL; | 43 ReferenceProcessor* MarkSweep::_ref_processor = NULL; |
44 | |
45 #ifdef VALIDATE_MARK_SWEEP | |
46 GrowableArray<void*>* MarkSweep::_root_refs_stack = NULL; | |
47 GrowableArray<oop> * MarkSweep::_live_oops = NULL; | |
48 GrowableArray<oop> * MarkSweep::_live_oops_moved_to = NULL; | |
49 GrowableArray<size_t>* MarkSweep::_live_oops_size = NULL; | |
50 size_t MarkSweep::_live_oops_index = 0; | |
51 size_t MarkSweep::_live_oops_index_at_perm = 0; | |
52 GrowableArray<void*>* MarkSweep::_other_refs_stack = NULL; | |
53 GrowableArray<void*>* MarkSweep::_adjusted_pointers = NULL; | |
54 bool MarkSweep::_pointer_tracking = false; | |
55 bool MarkSweep::_root_tracking = true; | |
56 | |
57 GrowableArray<HeapWord*>* MarkSweep::_cur_gc_live_oops = NULL; | |
58 GrowableArray<HeapWord*>* MarkSweep::_cur_gc_live_oops_moved_to = NULL; | |
59 GrowableArray<size_t> * MarkSweep::_cur_gc_live_oops_size = NULL; | |
60 GrowableArray<HeapWord*>* MarkSweep::_last_gc_live_oops = NULL; | |
61 GrowableArray<HeapWord*>* MarkSweep::_last_gc_live_oops_moved_to = NULL; | |
62 GrowableArray<size_t> * MarkSweep::_last_gc_live_oops_size = NULL; | |
63 #endif | |
64 | 44 |
65 MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; | 45 MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; |
66 CodeBlobToOopClosure MarkSweep::follow_code_root_closure(&MarkSweep::follow_root_closure, /*do_marking=*/ true); | 46 CodeBlobToOopClosure MarkSweep::follow_code_root_closure(&MarkSweep::follow_root_closure, /*do_marking=*/ true); |
67 | 47 |
68 void MarkSweep::FollowRootClosure::do_oop(oop* p) { follow_root(p); } | 48 void MarkSweep::FollowRootClosure::do_oop(oop* p) { follow_root(p); } |
183 markOop mark = _preserved_mark_stack.pop(); | 163 markOop mark = _preserved_mark_stack.pop(); |
184 obj->set_mark(mark); | 164 obj->set_mark(mark); |
185 } | 165 } |
186 } | 166 } |
187 | 167 |
188 #ifdef VALIDATE_MARK_SWEEP | |
189 | |
190 void MarkSweep::track_adjusted_pointer(void* p, bool isroot) { | |
191 if (!ValidateMarkSweep) | |
192 return; | |
193 | |
194 if (!isroot) { | |
195 if (_pointer_tracking) { | |
196 guarantee(_adjusted_pointers->contains(p), "should have seen this pointer"); | |
197 _adjusted_pointers->remove(p); | |
198 } | |
199 } else { | |
200 ptrdiff_t index = _root_refs_stack->find(p); | |
201 if (index != -1) { | |
202 int l = _root_refs_stack->length(); | |
203 if (l > 0 && l - 1 != index) { | |
204 void* last = _root_refs_stack->pop(); | |
205 assert(last != p, "should be different"); | |
206 _root_refs_stack->at_put(index, last); | |
207 } else { | |
208 _root_refs_stack->remove(p); | |
209 } | |
210 } | |
211 } | |
212 } | |
213 | |
214 void MarkSweep::check_adjust_pointer(void* p) { | |
215 _adjusted_pointers->push(p); | |
216 } | |
217 | |
218 class AdjusterTracker: public OopClosure { | |
219 public: | |
220 AdjusterTracker() {} | |
221 void do_oop(oop* o) { MarkSweep::check_adjust_pointer(o); } | |
222 void do_oop(narrowOop* o) { MarkSweep::check_adjust_pointer(o); } | |
223 }; | |
224 | |
225 void MarkSweep::track_interior_pointers(oop obj) { | |
226 if (ValidateMarkSweep) { | |
227 _adjusted_pointers->clear(); | |
228 _pointer_tracking = true; | |
229 | |
230 AdjusterTracker checker; | |
231 obj->oop_iterate_no_header(&checker); | |
232 } | |
233 } | |
234 | |
235 void MarkSweep::check_interior_pointers() { | |
236 if (ValidateMarkSweep) { | |
237 _pointer_tracking = false; | |
238 guarantee(_adjusted_pointers->length() == 0, "should have processed the same pointers"); | |
239 } | |
240 } | |
241 | |
242 void MarkSweep::reset_live_oop_tracking() { | |
243 if (ValidateMarkSweep) { | |
244 guarantee((size_t)_live_oops->length() == _live_oops_index, "should be at end of live oops"); | |
245 _live_oops_index = 0; | |
246 } | |
247 } | |
248 | |
249 void MarkSweep::register_live_oop(oop p, size_t size) { | |
250 if (ValidateMarkSweep) { | |
251 _live_oops->push(p); | |
252 _live_oops_size->push(size); | |
253 _live_oops_index++; | |
254 } | |
255 } | |
256 | |
257 void MarkSweep::validate_live_oop(oop p, size_t size) { | |
258 if (ValidateMarkSweep) { | |
259 oop obj = _live_oops->at((int)_live_oops_index); | |
260 guarantee(obj == p, "should be the same object"); | |
261 guarantee(_live_oops_size->at((int)_live_oops_index) == size, "should be the same size"); | |
262 _live_oops_index++; | |
263 } | |
264 } | |
265 | |
266 void MarkSweep::live_oop_moved_to(HeapWord* q, size_t size, | |
267 HeapWord* compaction_top) { | |
268 assert(oop(q)->forwardee() == NULL || oop(q)->forwardee() == oop(compaction_top), | |
269 "should be moved to forwarded location"); | |
270 if (ValidateMarkSweep) { | |
271 MarkSweep::validate_live_oop(oop(q), size); | |
272 _live_oops_moved_to->push(oop(compaction_top)); | |
273 } | |
274 if (RecordMarkSweepCompaction) { | |
275 _cur_gc_live_oops->push(q); | |
276 _cur_gc_live_oops_moved_to->push(compaction_top); | |
277 _cur_gc_live_oops_size->push(size); | |
278 } | |
279 } | |
280 | |
281 void MarkSweep::compaction_complete() { | |
282 if (RecordMarkSweepCompaction) { | |
283 GrowableArray<HeapWord*>* _tmp_live_oops = _cur_gc_live_oops; | |
284 GrowableArray<HeapWord*>* _tmp_live_oops_moved_to = _cur_gc_live_oops_moved_to; | |
285 GrowableArray<size_t> * _tmp_live_oops_size = _cur_gc_live_oops_size; | |
286 | |
287 _cur_gc_live_oops = _last_gc_live_oops; | |
288 _cur_gc_live_oops_moved_to = _last_gc_live_oops_moved_to; | |
289 _cur_gc_live_oops_size = _last_gc_live_oops_size; | |
290 _last_gc_live_oops = _tmp_live_oops; | |
291 _last_gc_live_oops_moved_to = _tmp_live_oops_moved_to; | |
292 _last_gc_live_oops_size = _tmp_live_oops_size; | |
293 } | |
294 } | |
295 | |
296 void MarkSweep::print_new_location_of_heap_address(HeapWord* q) { | |
297 if (!RecordMarkSweepCompaction) { | |
298 tty->print_cr("Requires RecordMarkSweepCompaction to be enabled"); | |
299 return; | |
300 } | |
301 | |
302 if (_last_gc_live_oops == NULL) { | |
303 tty->print_cr("No compaction information gathered yet"); | |
304 return; | |
305 } | |
306 | |
307 for (int i = 0; i < _last_gc_live_oops->length(); i++) { | |
308 HeapWord* old_oop = _last_gc_live_oops->at(i); | |
309 size_t sz = _last_gc_live_oops_size->at(i); | |
310 if (old_oop <= q && q < (old_oop + sz)) { | |
311 HeapWord* new_oop = _last_gc_live_oops_moved_to->at(i); | |
312 size_t offset = (q - old_oop); | |
313 tty->print_cr("Address " PTR_FORMAT, q); | |
314 tty->print_cr(" Was in oop " PTR_FORMAT ", size " SIZE_FORMAT ", at offset " SIZE_FORMAT, old_oop, sz, offset); | |
315 tty->print_cr(" Now in oop " PTR_FORMAT ", actual address " PTR_FORMAT, new_oop, new_oop + offset); | |
316 return; | |
317 } | |
318 } | |
319 | |
320 tty->print_cr("Address " PTR_FORMAT " not found in live oop information from last GC", q); | |
321 } | |
322 #endif //VALIDATE_MARK_SWEEP | |
323 | |
324 MarkSweep::IsAliveClosure MarkSweep::is_alive; | 168 MarkSweep::IsAliveClosure MarkSweep::is_alive; |
325 | 169 |
326 void MarkSweep::IsAliveClosure::do_object(oop p) { ShouldNotReachHere(); } | 170 void MarkSweep::IsAliveClosure::do_object(oop p) { ShouldNotReachHere(); } |
327 bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); } | 171 bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); } |
328 | 172 |