oop.pcgc.inline.hpp revision 113
0N/A/*
0N/A * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A *
0N/A */
0N/A
0N/Ainline void oopDesc::update_contents(ParCompactionManager* cm) {
0N/A // The klass field must be updated before anything else
0N/A // can be done.
0N/A DEBUG_ONLY(klassOopDesc* original_klass = klass());
0N/A
0N/A // Can the option to update and/or copy be moved up in the
0N/A // call chain to avoid calling into here?
0N/A
0N/A if (PSParallelCompact::should_update_klass(klass())) {
0N/A update_header();
0N/A assert(klass()->is_klass(), "Not updated correctly");
0N/A } else {
0N/A assert(klass()->is_klass(), "Not updated");
0N/A }
0N/A
0N/A Klass* new_klass = blueprint();
0N/A if (!new_klass->oop_is_typeArray()) {
0N/A // It might contain oops beyond the header, so take the virtual call.
0N/A new_klass->oop_update_pointers(cm, this);
0N/A }
0N/A // Else skip it. The typeArrayKlass in the header never needs scavenging.
0N/A}
0N/A
0N/Ainline void oopDesc::update_contents(ParCompactionManager* cm,
0N/A HeapWord* begin_limit,
0N/A HeapWord* end_limit) {
0N/A // The klass field must be updated before anything else
0N/A // can be done.
0N/A debug_only(klassOopDesc* original_klass = klass());
0N/A
0N/A update_contents(cm, klass(), begin_limit, end_limit);
0N/A}
0N/A
0N/Ainline void oopDesc::update_contents(ParCompactionManager* cm,
0N/A klassOop old_klass,
0N/A HeapWord* begin_limit,
0N/A HeapWord* end_limit) {
0N/A
0N/A klassOop updated_klass =
0N/A PSParallelCompact::summary_data().calc_new_klass(old_klass);
0N/A
0N/A // Needs to be boundary aware for the 64 bit case
0N/A // update_header();
0N/A // The klass has moved. Is the location of the klass
0N/A // within the limits?
113N/A if ((((HeapWord*)&_metadata._klass) >= begin_limit) &&
113N/A (((HeapWord*)&_metadata._klass) < end_limit)) {
0N/A set_klass(updated_klass);
0N/A }
0N/A
0N/A Klass* klass = updated_klass->klass_part();
0N/A if (!klass->oop_is_typeArray()) {
0N/A // It might contain oops beyond the header, so take the virtual call.
0N/A klass->oop_update_pointers(cm, this, begin_limit, end_limit);
0N/A }
0N/A // Else skip it. The typeArrayKlass in the header never needs scavenging.
0N/A}
0N/A
0N/Ainline void oopDesc::follow_contents(ParCompactionManager* cm) {
0N/A assert (PSParallelCompact::mark_bitmap()->is_marked(this),
0N/A "should be marked");
0N/A blueprint()->oop_follow_contents(cm, this);
0N/A}
0N/A
0N/A// Used by parallel old GC.
0N/A
0N/Ainline void oopDesc::follow_header(ParCompactionManager* cm) {
113N/A if (UseCompressedOops) {
113N/A PSParallelCompact::mark_and_push(cm, compressed_klass_addr());
113N/A } else {
113N/A PSParallelCompact::mark_and_push(cm, klass_addr());
113N/A }
0N/A}
0N/A
0N/Ainline oop oopDesc::forward_to_atomic(oop p) {
0N/A assert(ParNewGeneration::is_legal_forward_ptr(p),
0N/A "illegal forwarding pointer value.");
0N/A markOop oldMark = mark();
0N/A markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
0N/A markOop curMark;
0N/A
0N/A assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable");
0N/A assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
0N/A
0N/A while (!is_forwarded()) {
0N/A curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark);
0N/A if (curMark == oldMark) {
0N/A assert(is_forwarded(), "the CAS should have succeeded.");
0N/A return NULL;
0N/A }
0N/A oldMark = curMark;
0N/A }
0N/A return forwardee();
0N/A}
0N/A
0N/Ainline void oopDesc::update_header() {
113N/A if (UseCompressedOops) {
113N/A PSParallelCompact::adjust_pointer(compressed_klass_addr());
113N/A } else {
113N/A PSParallelCompact::adjust_pointer(klass_addr());
113N/A }
0N/A}
0N/A
0N/Ainline void oopDesc::update_header(HeapWord* beg_addr, HeapWord* end_addr) {
113N/A if (UseCompressedOops) {
113N/A PSParallelCompact::adjust_pointer(compressed_klass_addr(),
113N/A beg_addr, end_addr);
113N/A } else {
113N/A PSParallelCompact::adjust_pointer(klass_addr(), beg_addr, end_addr);
113N/A }
0N/A}