0N/A/*
2099N/A * Copyright (c) 2005, 2011, Oracle and/or its affiliates. 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 *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP
1879N/A#define SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP
1879N/A
1879N/A#ifndef SERIALGC
1879N/A#include "gc_implementation/parNew/parNewGeneration.hpp"
1879N/A#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
1879N/A#include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
1879N/A#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
1879N/A#include "gc_implementation/parallelScavenge/psScavenge.hpp"
1879N/A#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
1879N/A#endif
1879N/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::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
1899N/A while (!oldMark->is_marked()) {
0N/A curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark);
1899N/A assert(is_forwarded(), "object should have been forwarded");
0N/A if (curMark == oldMark) {
0N/A return NULL;
0N/A }
1899N/A // If the CAS was unsuccessful then curMark->is_marked()
1899N/A // should return true as another thread has CAS'd in another
1899N/A // forwarding pointer.
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
1879N/A#endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP