--- old/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp 2009-08-01 04:11:23.671122296 +0100 +++ new/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp 2009-08-01 04:11:23.593605331 +0100 @@ -2,7 +2,7 @@ #pragma ident "@(#)markSweep.cpp 1.196 07/05/05 17:05:35 JVM" #endif /* - * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,16 +39,16 @@ ReferenceProcessor* MarkSweep::_ref_processor = NULL; #ifdef VALIDATE_MARK_SWEEP -GrowableArray* MarkSweep::_root_refs_stack = NULL; +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::_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; @@ -62,7 +62,6 @@ _revisit_klass_stack->push(k); } - void MarkSweep::follow_weak_klass_links() { // All klasses on the revisit stack are marked at this point. // Update and follow all subklass, sibling and implementor links. @@ -72,44 +71,15 @@ follow_stack(); } +MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; -void MarkSweep::mark_and_follow(oop* p) { - assert(Universe::heap()->is_in_reserved(p), - "we should only be traversing objects here"); - oop m = *p; - if (m != NULL && !m->mark()->is_marked()) { - mark_object(m); - m->follow_contents(); // Follow contents of the marked object - } -} - -void MarkSweep::_mark_and_push(oop* p) { - // Push marked object, contents will be followed later - oop m = *p; - mark_object(m); - _marking_stack->push(m); -} +void MarkSweep::FollowRootClosure::do_oop(oop* p) { follow_root(p); } +void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); } MarkSweep::MarkAndPushClosure MarkSweep::mark_and_push_closure; -void MarkSweep::follow_root(oop* p) { - assert(!Universe::heap()->is_in_reserved(p), - "roots shouldn't be things within the heap"); -#ifdef VALIDATE_MARK_SWEEP - if (ValidateMarkSweep) { - guarantee(!_root_refs_stack->contains(p), "should only be in here once"); - _root_refs_stack->push(p); - } -#endif - oop m = *p; - if (m != NULL && !m->mark()->is_marked()) { - mark_object(m); - m->follow_contents(); // Follow contents of the marked object - } - follow_stack(); -} - -MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; +void MarkSweep::MarkAndPushClosure::do_oop(oop* p) { mark_and_push(p); } +void MarkSweep::MarkAndPushClosure::do_oop(narrowOop* p) { mark_and_push(p); } void MarkSweep::follow_stack() { while (!_marking_stack->is_empty()) { @@ -121,6 +91,7 @@ MarkSweep::FollowStackClosure MarkSweep::follow_stack_closure; +void MarkSweep::FollowStackClosure::do_void() { follow_stack(); } // We preserve the mark which should be replaced at the end and the location that it // will go. Note that the object that this markOop belongs to isn't currently at that @@ -145,6 +116,9 @@ MarkSweep::AdjustPointerClosure MarkSweep::adjust_root_pointer_closure(true); MarkSweep::AdjustPointerClosure MarkSweep::adjust_pointer_closure(false); +void MarkSweep::AdjustPointerClosure::do_oop(oop* p) { adjust_pointer(p, _is_root); } +void MarkSweep::AdjustPointerClosure::do_oop(narrowOop* p) { adjust_pointer(p, _is_root); } + void MarkSweep::adjust_marks() { assert(_preserved_oop_stack == NULL || _preserved_oop_stack->length() == _preserved_mark_stack->length(), @@ -190,7 +164,7 @@ #ifdef VALIDATE_MARK_SWEEP -void MarkSweep::track_adjusted_pointer(oop* p, oop newobj, bool isroot) { +void MarkSweep::track_adjusted_pointer(void* p, bool isroot) { if (!ValidateMarkSweep) return; @@ -204,9 +178,9 @@ if (index != -1) { int l = _root_refs_stack->length(); if (l > 0 && l - 1 != index) { - oop* last = _root_refs_stack->pop(); - assert(last != p, "should be different"); - _root_refs_stack->at_put(index, last); + 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); } @@ -214,19 +188,17 @@ } } - -void MarkSweep::check_adjust_pointer(oop* 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); } + 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(); @@ -237,7 +209,6 @@ } } - void MarkSweep::check_interior_pointers() { if (ValidateMarkSweep) { _pointer_tracking = false; @@ -245,7 +216,6 @@ } } - void MarkSweep::reset_live_oop_tracking(bool at_perm) { if (ValidateMarkSweep) { guarantee((size_t)_live_oops->length() == _live_oops_index, "should be at end of live oops"); @@ -253,7 +223,6 @@ } } - void MarkSweep::register_live_oop(oop p, size_t size) { if (ValidateMarkSweep) { _live_oops->push(p); @@ -286,7 +255,6 @@ } } - void MarkSweep::compaction_complete() { if (RecordMarkSweepCompaction) { GrowableArray* _tmp_live_oops = _cur_gc_live_oops; @@ -302,7 +270,6 @@ } } - void MarkSweep::print_new_location_of_heap_address(HeapWord* q) { if (!RecordMarkSweepCompaction) { tty->print_cr("Requires RecordMarkSweepCompaction to be enabled"); @@ -321,7 +288,7 @@ 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 %d, at offset %d", old_oop, sz, offset); + 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; } @@ -331,23 +298,16 @@ } #endif //VALIDATE_MARK_SWEEP -MarkSweep::IsAliveClosure MarkSweep::is_alive; +MarkSweep::IsAliveClosure MarkSweep::is_alive; -void MarkSweep::KeepAliveClosure::do_oop(oop* p) { -#ifdef VALIDATE_MARK_SWEEP - if (ValidateMarkSweep) { - if (!Universe::heap()->is_in_reserved(p)) { - _root_refs_stack->push(p); - } else { - _other_refs_stack->push(p); - } - } -#endif - mark_and_push(p); -} +void MarkSweep::IsAliveClosure::do_object(oop p) { ShouldNotReachHere(); } +bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); } MarkSweep::KeepAliveClosure MarkSweep::keep_alive; +void MarkSweep::KeepAliveClosure::do_oop(oop* p) { MarkSweep::KeepAliveClosure::do_oop_work(p); } +void MarkSweep::KeepAliveClosure::do_oop(narrowOop* p) { MarkSweep::KeepAliveClosure::do_oop_work(p); } + void marksweep_init() { /* empty */ } #ifndef PRODUCT