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