1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/oops/oop.pcgc.inline.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,83 @@ 1.4 +/* 1.5 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP 1.29 +#define SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP 1.30 + 1.31 +#include "utilities/macros.hpp" 1.32 +#if INCLUDE_ALL_GCS 1.33 +#include "gc_implementation/parNew/parNewGeneration.hpp" 1.34 +#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" 1.35 +#include "gc_implementation/parallelScavenge/psCompactionManager.hpp" 1.36 +#include "gc_implementation/parallelScavenge/psParallelCompact.hpp" 1.37 +#include "gc_implementation/parallelScavenge/psScavenge.hpp" 1.38 +#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" 1.39 +#endif // INCLUDE_ALL_GCS 1.40 + 1.41 +inline void oopDesc::update_contents(ParCompactionManager* cm) { 1.42 + // The klass field must be updated before anything else 1.43 + // can be done. 1.44 + DEBUG_ONLY(Klass* original_klass = klass()); 1.45 + 1.46 + Klass* new_klass = klass(); 1.47 + if (!new_klass->oop_is_typeArray()) { 1.48 + // It might contain oops beyond the header, so take the virtual call. 1.49 + new_klass->oop_update_pointers(cm, this); 1.50 + } 1.51 + // Else skip it. The TypeArrayKlass in the header never needs scavenging. 1.52 +} 1.53 + 1.54 +inline void oopDesc::follow_contents(ParCompactionManager* cm) { 1.55 + assert (PSParallelCompact::mark_bitmap()->is_marked(this), 1.56 + "should be marked"); 1.57 + klass()->oop_follow_contents(cm, this); 1.58 +} 1.59 + 1.60 +// Used by parallel old GC. 1.61 + 1.62 +inline oop oopDesc::forward_to_atomic(oop p) { 1.63 + assert(ParNewGeneration::is_legal_forward_ptr(p), 1.64 + "illegal forwarding pointer value."); 1.65 + markOop oldMark = mark(); 1.66 + markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p); 1.67 + markOop curMark; 1.68 + 1.69 + assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable"); 1.70 + assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this."); 1.71 + 1.72 + while (!oldMark->is_marked()) { 1.73 + curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark); 1.74 + assert(is_forwarded(), "object should have been forwarded"); 1.75 + if (curMark == oldMark) { 1.76 + return NULL; 1.77 + } 1.78 + // If the CAS was unsuccessful then curMark->is_marked() 1.79 + // should return true as another thread has CAS'd in another 1.80 + // forwarding pointer. 1.81 + oldMark = curMark; 1.82 + } 1.83 + return forwardee(); 1.84 +} 1.85 + 1.86 +#endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP