src/share/vm/oops/oop.pcgc.inline.hpp

Wed, 25 Jan 2012 17:40:51 -0500

author
jiangli
date
Wed, 25 Jan 2012 17:40:51 -0500
changeset 3526
a79cb7c55012
parent 2534
e5383553fd4e
child 4037
da91efe96a93
permissions
-rw-r--r--

7132690: InstanceKlass:_reference_type should be u1 type
Summary: Change InstanceKlass::_reference_type to u1 type.
Reviewed-by: dholmes, coleenp, acorn
Contributed-by: Jiangli Zhou <jiangli.zhou@oracle.com>

duke@435 1 /*
stefank@2534 2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP
stefank@2314 26 #define SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP
stefank@2314 27
stefank@2314 28 #ifndef SERIALGC
stefank@2314 29 #include "gc_implementation/parNew/parNewGeneration.hpp"
stefank@2314 30 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
stefank@2314 31 #include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
stefank@2314 32 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
stefank@2314 33 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
stefank@2314 34 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
stefank@2314 35 #endif
stefank@2314 36
duke@435 37 inline void oopDesc::update_contents(ParCompactionManager* cm) {
duke@435 38 // The klass field must be updated before anything else
duke@435 39 // can be done.
duke@435 40 DEBUG_ONLY(klassOopDesc* original_klass = klass());
duke@435 41
duke@435 42 // Can the option to update and/or copy be moved up in the
duke@435 43 // call chain to avoid calling into here?
duke@435 44
duke@435 45 if (PSParallelCompact::should_update_klass(klass())) {
duke@435 46 update_header();
duke@435 47 assert(klass()->is_klass(), "Not updated correctly");
duke@435 48 } else {
duke@435 49 assert(klass()->is_klass(), "Not updated");
duke@435 50 }
duke@435 51
duke@435 52 Klass* new_klass = blueprint();
duke@435 53 if (!new_klass->oop_is_typeArray()) {
duke@435 54 // It might contain oops beyond the header, so take the virtual call.
duke@435 55 new_klass->oop_update_pointers(cm, this);
duke@435 56 }
duke@435 57 // Else skip it. The typeArrayKlass in the header never needs scavenging.
duke@435 58 }
duke@435 59
duke@435 60 inline void oopDesc::follow_contents(ParCompactionManager* cm) {
duke@435 61 assert (PSParallelCompact::mark_bitmap()->is_marked(this),
duke@435 62 "should be marked");
duke@435 63 blueprint()->oop_follow_contents(cm, this);
duke@435 64 }
duke@435 65
duke@435 66 // Used by parallel old GC.
duke@435 67
duke@435 68 inline void oopDesc::follow_header(ParCompactionManager* cm) {
coleenp@548 69 if (UseCompressedOops) {
coleenp@548 70 PSParallelCompact::mark_and_push(cm, compressed_klass_addr());
coleenp@548 71 } else {
coleenp@548 72 PSParallelCompact::mark_and_push(cm, klass_addr());
coleenp@548 73 }
duke@435 74 }
duke@435 75
duke@435 76 inline oop oopDesc::forward_to_atomic(oop p) {
duke@435 77 assert(ParNewGeneration::is_legal_forward_ptr(p),
duke@435 78 "illegal forwarding pointer value.");
duke@435 79 markOop oldMark = mark();
duke@435 80 markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
duke@435 81 markOop curMark;
duke@435 82
duke@435 83 assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable");
duke@435 84 assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
duke@435 85
johnc@2334 86 while (!oldMark->is_marked()) {
duke@435 87 curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark);
johnc@2334 88 assert(is_forwarded(), "object should have been forwarded");
duke@435 89 if (curMark == oldMark) {
duke@435 90 return NULL;
duke@435 91 }
johnc@2334 92 // If the CAS was unsuccessful then curMark->is_marked()
johnc@2334 93 // should return true as another thread has CAS'd in another
johnc@2334 94 // forwarding pointer.
duke@435 95 oldMark = curMark;
duke@435 96 }
duke@435 97 return forwardee();
duke@435 98 }
duke@435 99
duke@435 100 inline void oopDesc::update_header() {
coleenp@548 101 if (UseCompressedOops) {
coleenp@548 102 PSParallelCompact::adjust_pointer(compressed_klass_addr());
coleenp@548 103 } else {
coleenp@548 104 PSParallelCompact::adjust_pointer(klass_addr());
coleenp@548 105 }
duke@435 106 }
duke@435 107
stefank@2314 108 #endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP

mercurial