src/share/vm/gc_implementation/shared/markSweep.inline.hpp

Tue, 22 Sep 2009 14:06:10 -0700

author
xdono
date
Tue, 22 Sep 2009 14:06:10 -0700
changeset 1383
89e0543e1737
parent 809
a4b729f5b611
child 1746
2a1472c30599
permissions
-rw-r--r--

6884624: Update copyright year
Summary: Update copyright for files that have been modified in 2009 through Septermber
Reviewed-by: tbell, ohair

duke@435 1 /*
xdono@631 2 * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 inline void MarkSweep::mark_object(oop obj) {
duke@435 26 // some marks may contain information we need to preserve so we store them away
duke@435 27 // and overwrite the mark. We'll restore it at the end of markSweep.
duke@435 28 markOop mark = obj->mark();
duke@435 29 obj->set_mark(markOopDesc::prototype()->set_marked());
duke@435 30
duke@435 31 if (mark->must_be_preserved(obj)) {
duke@435 32 preserve_mark(obj, mark);
duke@435 33 }
duke@435 34 }
coleenp@548 35
coleenp@548 36 template <class T> inline void MarkSweep::follow_root(T* p) {
coleenp@548 37 assert(!Universe::heap()->is_in_reserved(p),
coleenp@548 38 "roots shouldn't be things within the heap");
coleenp@548 39 #ifdef VALIDATE_MARK_SWEEP
coleenp@548 40 if (ValidateMarkSweep) {
coleenp@548 41 guarantee(!_root_refs_stack->contains(p), "should only be in here once");
coleenp@548 42 _root_refs_stack->push(p);
coleenp@548 43 }
coleenp@548 44 #endif
coleenp@548 45 T heap_oop = oopDesc::load_heap_oop(p);
coleenp@548 46 if (!oopDesc::is_null(heap_oop)) {
coleenp@548 47 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
coleenp@548 48 if (!obj->mark()->is_marked()) {
coleenp@548 49 mark_object(obj);
coleenp@548 50 obj->follow_contents();
coleenp@548 51 }
coleenp@548 52 }
coleenp@548 53 follow_stack();
coleenp@548 54 }
coleenp@548 55
coleenp@548 56 template <class T> inline void MarkSweep::mark_and_follow(T* p) {
coleenp@548 57 // assert(Universe::heap()->is_in_reserved(p), "should be in object space");
coleenp@548 58 T heap_oop = oopDesc::load_heap_oop(p);
coleenp@548 59 if (!oopDesc::is_null(heap_oop)) {
coleenp@548 60 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
coleenp@548 61 if (!obj->mark()->is_marked()) {
coleenp@548 62 mark_object(obj);
coleenp@548 63 obj->follow_contents();
coleenp@548 64 }
coleenp@548 65 }
coleenp@548 66 }
coleenp@548 67
coleenp@548 68 template <class T> inline void MarkSweep::mark_and_push(T* p) {
coleenp@548 69 // assert(Universe::heap()->is_in_reserved(p), "should be in object space");
coleenp@548 70 T heap_oop = oopDesc::load_heap_oop(p);
coleenp@548 71 if (!oopDesc::is_null(heap_oop)) {
coleenp@548 72 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
coleenp@548 73 if (!obj->mark()->is_marked()) {
coleenp@548 74 mark_object(obj);
coleenp@548 75 _marking_stack->push(obj);
coleenp@548 76 }
coleenp@548 77 }
coleenp@548 78 }
coleenp@548 79
coleenp@548 80 template <class T> inline void MarkSweep::adjust_pointer(T* p, bool isroot) {
coleenp@548 81 T heap_oop = oopDesc::load_heap_oop(p);
coleenp@548 82 if (!oopDesc::is_null(heap_oop)) {
coleenp@548 83 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
coleenp@548 84 oop new_obj = oop(obj->mark()->decode_pointer());
coleenp@548 85 assert(new_obj != NULL || // is forwarding ptr?
coleenp@548 86 obj->mark() == markOopDesc::prototype() || // not gc marked?
coleenp@548 87 (UseBiasedLocking && obj->mark()->has_bias_pattern()) ||
coleenp@548 88 // not gc marked?
coleenp@548 89 obj->is_shared(), // never forwarded?
coleenp@548 90 "should be forwarded");
coleenp@548 91 if (new_obj != NULL) {
coleenp@548 92 assert(Universe::heap()->is_in_reserved(new_obj),
coleenp@548 93 "should be in object space");
coleenp@548 94 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
coleenp@548 95 }
coleenp@548 96 }
coleenp@548 97 VALIDATE_MARK_SWEEP_ONLY(track_adjusted_pointer(p, isroot));
coleenp@548 98 }
coleenp@548 99
coleenp@548 100 template <class T> inline void MarkSweep::KeepAliveClosure::do_oop_work(T* p) {
coleenp@548 101 #ifdef VALIDATE_MARK_SWEEP
coleenp@548 102 if (ValidateMarkSweep) {
coleenp@548 103 if (!Universe::heap()->is_in_reserved(p)) {
coleenp@548 104 _root_refs_stack->push(p);
coleenp@548 105 } else {
coleenp@548 106 _other_refs_stack->push(p);
coleenp@548 107 }
coleenp@548 108 }
coleenp@548 109 #endif
coleenp@548 110 mark_and_push(p);
coleenp@548 111 }

mercurial