diff -r 1de1b145f6bc -r b735136e0d82 src/share/vm/gc_implementation/shared/markSweep.cpp --- a/src/share/vm/gc_implementation/shared/markSweep.cpp Wed Dec 26 15:05:30 2012 -0800 +++ b/src/share/vm/gc_implementation/shared/markSweep.cpp Wed Jan 02 11:32:41 2013 -0800 @@ -42,26 +42,6 @@ PreservedMark* MarkSweep::_preserved_marks = NULL; ReferenceProcessor* MarkSweep::_ref_processor = NULL; -#ifdef VALIDATE_MARK_SWEEP -GrowableArray* MarkSweep::_root_refs_stack = NULL; -GrowableArray * MarkSweep::_live_oops = NULL; -GrowableArray * MarkSweep::_live_oops_moved_to = NULL; -GrowableArray* MarkSweep::_live_oops_size = NULL; -size_t MarkSweep::_live_oops_index = 0; -size_t MarkSweep::_live_oops_index_at_perm = 0; -GrowableArray* MarkSweep::_other_refs_stack = NULL; -GrowableArray* MarkSweep::_adjusted_pointers = NULL; -bool MarkSweep::_pointer_tracking = false; -bool MarkSweep::_root_tracking = true; - -GrowableArray* MarkSweep::_cur_gc_live_oops = NULL; -GrowableArray* MarkSweep::_cur_gc_live_oops_moved_to = NULL; -GrowableArray * MarkSweep::_cur_gc_live_oops_size = NULL; -GrowableArray* MarkSweep::_last_gc_live_oops = NULL; -GrowableArray* MarkSweep::_last_gc_live_oops_moved_to = NULL; -GrowableArray * MarkSweep::_last_gc_live_oops_size = NULL; -#endif - MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; CodeBlobToOopClosure MarkSweep::follow_code_root_closure(&MarkSweep::follow_root_closure, /*do_marking=*/ true); @@ -185,142 +165,6 @@ } } -#ifdef VALIDATE_MARK_SWEEP - -void MarkSweep::track_adjusted_pointer(void* p, bool isroot) { - if (!ValidateMarkSweep) - return; - - if (!isroot) { - if (_pointer_tracking) { - guarantee(_adjusted_pointers->contains(p), "should have seen this pointer"); - _adjusted_pointers->remove(p); - } - } else { - ptrdiff_t index = _root_refs_stack->find(p); - if (index != -1) { - int l = _root_refs_stack->length(); - if (l > 0 && l - 1 != index) { - void* last = _root_refs_stack->pop(); - assert(last != p, "should be different"); - _root_refs_stack->at_put(index, last); - } else { - _root_refs_stack->remove(p); - } - } - } -} - -void MarkSweep::check_adjust_pointer(void* p) { - _adjusted_pointers->push(p); -} - -class AdjusterTracker: public OopClosure { - public: - AdjusterTracker() {} - void do_oop(oop* o) { MarkSweep::check_adjust_pointer(o); } - void do_oop(narrowOop* o) { MarkSweep::check_adjust_pointer(o); } -}; - -void MarkSweep::track_interior_pointers(oop obj) { - if (ValidateMarkSweep) { - _adjusted_pointers->clear(); - _pointer_tracking = true; - - AdjusterTracker checker; - obj->oop_iterate_no_header(&checker); - } -} - -void MarkSweep::check_interior_pointers() { - if (ValidateMarkSweep) { - _pointer_tracking = false; - guarantee(_adjusted_pointers->length() == 0, "should have processed the same pointers"); - } -} - -void MarkSweep::reset_live_oop_tracking() { - if (ValidateMarkSweep) { - guarantee((size_t)_live_oops->length() == _live_oops_index, "should be at end of live oops"); - _live_oops_index = 0; - } -} - -void MarkSweep::register_live_oop(oop p, size_t size) { - if (ValidateMarkSweep) { - _live_oops->push(p); - _live_oops_size->push(size); - _live_oops_index++; - } -} - -void MarkSweep::validate_live_oop(oop p, size_t size) { - if (ValidateMarkSweep) { - oop obj = _live_oops->at((int)_live_oops_index); - guarantee(obj == p, "should be the same object"); - guarantee(_live_oops_size->at((int)_live_oops_index) == size, "should be the same size"); - _live_oops_index++; - } -} - -void MarkSweep::live_oop_moved_to(HeapWord* q, size_t size, - HeapWord* compaction_top) { - assert(oop(q)->forwardee() == NULL || oop(q)->forwardee() == oop(compaction_top), - "should be moved to forwarded location"); - if (ValidateMarkSweep) { - MarkSweep::validate_live_oop(oop(q), size); - _live_oops_moved_to->push(oop(compaction_top)); - } - if (RecordMarkSweepCompaction) { - _cur_gc_live_oops->push(q); - _cur_gc_live_oops_moved_to->push(compaction_top); - _cur_gc_live_oops_size->push(size); - } -} - -void MarkSweep::compaction_complete() { - if (RecordMarkSweepCompaction) { - GrowableArray* _tmp_live_oops = _cur_gc_live_oops; - GrowableArray* _tmp_live_oops_moved_to = _cur_gc_live_oops_moved_to; - GrowableArray * _tmp_live_oops_size = _cur_gc_live_oops_size; - - _cur_gc_live_oops = _last_gc_live_oops; - _cur_gc_live_oops_moved_to = _last_gc_live_oops_moved_to; - _cur_gc_live_oops_size = _last_gc_live_oops_size; - _last_gc_live_oops = _tmp_live_oops; - _last_gc_live_oops_moved_to = _tmp_live_oops_moved_to; - _last_gc_live_oops_size = _tmp_live_oops_size; - } -} - -void MarkSweep::print_new_location_of_heap_address(HeapWord* q) { - if (!RecordMarkSweepCompaction) { - tty->print_cr("Requires RecordMarkSweepCompaction to be enabled"); - return; - } - - if (_last_gc_live_oops == NULL) { - tty->print_cr("No compaction information gathered yet"); - return; - } - - for (int i = 0; i < _last_gc_live_oops->length(); i++) { - HeapWord* old_oop = _last_gc_live_oops->at(i); - size_t sz = _last_gc_live_oops_size->at(i); - if (old_oop <= q && q < (old_oop + sz)) { - HeapWord* new_oop = _last_gc_live_oops_moved_to->at(i); - size_t offset = (q - old_oop); - tty->print_cr("Address " PTR_FORMAT, q); - tty->print_cr(" Was in oop " PTR_FORMAT ", size " SIZE_FORMAT ", at offset " SIZE_FORMAT, old_oop, sz, offset); - tty->print_cr(" Now in oop " PTR_FORMAT ", actual address " PTR_FORMAT, new_oop, new_oop + offset); - return; - } - } - - tty->print_cr("Address " PTR_FORMAT " not found in live oop information from last GC", q); -} -#endif //VALIDATE_MARK_SWEEP - MarkSweep::IsAliveClosure MarkSweep::is_alive; void MarkSweep::IsAliveClosure::do_object(oop p) { ShouldNotReachHere(); }