Sat, 07 Nov 2020 10:30:02 +0800
Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f
aoqi@0 | 1 | /* |
kevinw@8368 | 2 | * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@1 | 25 | /* |
aoqi@1 | 26 | * This file has been modified by Loongson Technology in 2015. These |
aoqi@1 | 27 | * modifications are Copyright (c) 2015 Loongson Technology, and are made |
aoqi@1 | 28 | * available on the same license terms set forth above. |
aoqi@1 | 29 | */ |
aoqi@1 | 30 | |
aoqi@0 | 31 | #ifndef SHARE_VM_OOPS_OOP_INLINE_HPP |
aoqi@0 | 32 | #define SHARE_VM_OOPS_OOP_INLINE_HPP |
aoqi@0 | 33 | |
aoqi@0 | 34 | #include "gc_implementation/shared/ageTable.hpp" |
aoqi@0 | 35 | #include "gc_implementation/shared/markSweep.inline.hpp" |
aoqi@0 | 36 | #include "gc_interface/collectedHeap.inline.hpp" |
aoqi@0 | 37 | #include "memory/barrierSet.inline.hpp" |
aoqi@0 | 38 | #include "memory/cardTableModRefBS.hpp" |
aoqi@0 | 39 | #include "memory/genCollectedHeap.hpp" |
aoqi@0 | 40 | #include "memory/generation.hpp" |
aoqi@0 | 41 | #include "memory/specialized_oop_closures.hpp" |
aoqi@0 | 42 | #include "oops/arrayKlass.hpp" |
aoqi@0 | 43 | #include "oops/arrayOop.hpp" |
aoqi@0 | 44 | #include "oops/klass.inline.hpp" |
aoqi@0 | 45 | #include "oops/markOop.inline.hpp" |
aoqi@0 | 46 | #include "oops/oop.hpp" |
goetz@6911 | 47 | #include "runtime/atomic.inline.hpp" |
goetz@6911 | 48 | #include "runtime/orderAccess.inline.hpp" |
aoqi@0 | 49 | #include "runtime/os.hpp" |
aoqi@0 | 50 | #include "utilities/macros.hpp" |
aoqi@0 | 51 | #ifdef TARGET_ARCH_x86 |
aoqi@0 | 52 | # include "bytes_x86.hpp" |
aoqi@0 | 53 | #endif |
aoqi@0 | 54 | #ifdef TARGET_ARCH_sparc |
aoqi@0 | 55 | # include "bytes_sparc.hpp" |
aoqi@0 | 56 | #endif |
aoqi@0 | 57 | #ifdef TARGET_ARCH_zero |
aoqi@0 | 58 | # include "bytes_zero.hpp" |
aoqi@0 | 59 | #endif |
aoqi@0 | 60 | #ifdef TARGET_ARCH_arm |
aoqi@0 | 61 | # include "bytes_arm.hpp" |
aoqi@0 | 62 | #endif |
aoqi@0 | 63 | #ifdef TARGET_ARCH_ppc |
aoqi@0 | 64 | # include "bytes_ppc.hpp" |
aoqi@0 | 65 | #endif |
aoqi@1 | 66 | #ifdef TARGET_ARCH_mips |
aoqi@1 | 67 | # include "bytes_mips.hpp" |
aoqi@1 | 68 | #endif |
aoqi@0 | 69 | |
aoqi@0 | 70 | // Implementation of all inlined member functions defined in oop.hpp |
aoqi@0 | 71 | // We need a separate file to avoid circular references |
aoqi@0 | 72 | |
aoqi@0 | 73 | inline void oopDesc::release_set_mark(markOop m) { |
aoqi@0 | 74 | OrderAccess::release_store_ptr(&_mark, m); |
aoqi@0 | 75 | } |
aoqi@0 | 76 | |
aoqi@0 | 77 | inline markOop oopDesc::cas_set_mark(markOop new_mark, markOop old_mark) { |
aoqi@0 | 78 | return (markOop) Atomic::cmpxchg_ptr(new_mark, &_mark, old_mark); |
aoqi@0 | 79 | } |
aoqi@0 | 80 | |
aoqi@0 | 81 | inline Klass* oopDesc::klass() const { |
aoqi@0 | 82 | if (UseCompressedClassPointers) { |
aoqi@0 | 83 | return Klass::decode_klass_not_null(_metadata._compressed_klass); |
aoqi@0 | 84 | } else { |
aoqi@0 | 85 | return _metadata._klass; |
aoqi@0 | 86 | } |
aoqi@0 | 87 | } |
aoqi@0 | 88 | |
aoqi@0 | 89 | inline Klass* oopDesc::klass_or_null() const volatile { |
aoqi@0 | 90 | // can be NULL in CMS |
aoqi@0 | 91 | if (UseCompressedClassPointers) { |
aoqi@0 | 92 | return Klass::decode_klass(_metadata._compressed_klass); |
aoqi@0 | 93 | } else { |
aoqi@0 | 94 | return _metadata._klass; |
aoqi@0 | 95 | } |
aoqi@0 | 96 | } |
aoqi@0 | 97 | |
aoqi@0 | 98 | inline int oopDesc::klass_gap_offset_in_bytes() { |
aoqi@0 | 99 | assert(UseCompressedClassPointers, "only applicable to compressed klass pointers"); |
aoqi@0 | 100 | return oopDesc::klass_offset_in_bytes() + sizeof(narrowKlass); |
aoqi@0 | 101 | } |
aoqi@0 | 102 | |
aoqi@0 | 103 | inline Klass** oopDesc::klass_addr() { |
aoqi@0 | 104 | // Only used internally and with CMS and will not work with |
aoqi@0 | 105 | // UseCompressedOops |
aoqi@0 | 106 | assert(!UseCompressedClassPointers, "only supported with uncompressed klass pointers"); |
aoqi@0 | 107 | return (Klass**) &_metadata._klass; |
aoqi@0 | 108 | } |
aoqi@0 | 109 | |
aoqi@0 | 110 | inline narrowKlass* oopDesc::compressed_klass_addr() { |
aoqi@0 | 111 | assert(UseCompressedClassPointers, "only called by compressed klass pointers"); |
aoqi@0 | 112 | return &_metadata._compressed_klass; |
aoqi@0 | 113 | } |
aoqi@0 | 114 | |
aoqi@0 | 115 | inline void oopDesc::set_klass(Klass* k) { |
aoqi@0 | 116 | // since klasses are promoted no store check is needed |
aoqi@0 | 117 | assert(Universe::is_bootstrapping() || k != NULL, "must be a real Klass*"); |
aoqi@0 | 118 | assert(Universe::is_bootstrapping() || k->is_klass(), "not a Klass*"); |
aoqi@0 | 119 | if (UseCompressedClassPointers) { |
aoqi@0 | 120 | *compressed_klass_addr() = Klass::encode_klass_not_null(k); |
aoqi@0 | 121 | } else { |
aoqi@0 | 122 | *klass_addr() = k; |
aoqi@0 | 123 | } |
aoqi@0 | 124 | } |
aoqi@0 | 125 | |
aoqi@0 | 126 | inline int oopDesc::klass_gap() const { |
aoqi@0 | 127 | return *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes()); |
aoqi@0 | 128 | } |
aoqi@0 | 129 | |
aoqi@0 | 130 | inline void oopDesc::set_klass_gap(int v) { |
aoqi@0 | 131 | if (UseCompressedClassPointers) { |
aoqi@0 | 132 | *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes()) = v; |
aoqi@0 | 133 | } |
aoqi@0 | 134 | } |
aoqi@0 | 135 | |
aoqi@0 | 136 | inline void oopDesc::set_klass_to_list_ptr(oop k) { |
aoqi@0 | 137 | // This is only to be used during GC, for from-space objects, so no |
aoqi@0 | 138 | // barrier is needed. |
aoqi@0 | 139 | if (UseCompressedClassPointers) { |
aoqi@0 | 140 | _metadata._compressed_klass = (narrowKlass)encode_heap_oop(k); // may be null (parnew overflow handling) |
aoqi@0 | 141 | } else { |
aoqi@0 | 142 | _metadata._klass = (Klass*)(address)k; |
aoqi@0 | 143 | } |
aoqi@0 | 144 | } |
aoqi@0 | 145 | |
aoqi@0 | 146 | inline oop oopDesc::list_ptr_from_klass() { |
aoqi@0 | 147 | // This is only to be used during GC, for from-space objects. |
aoqi@0 | 148 | if (UseCompressedClassPointers) { |
aoqi@0 | 149 | return decode_heap_oop((narrowOop)_metadata._compressed_klass); |
aoqi@0 | 150 | } else { |
aoqi@0 | 151 | // Special case for GC |
aoqi@0 | 152 | return (oop)(address)_metadata._klass; |
aoqi@0 | 153 | } |
aoqi@0 | 154 | } |
aoqi@0 | 155 | |
aoqi@0 | 156 | inline void oopDesc::init_mark() { set_mark(markOopDesc::prototype_for_object(this)); } |
aoqi@0 | 157 | |
aoqi@0 | 158 | inline bool oopDesc::is_a(Klass* k) const { return klass()->is_subtype_of(k); } |
aoqi@0 | 159 | |
stefank@6976 | 160 | inline bool oopDesc::is_instance() const { return klass()->oop_is_instance(); } |
stefank@6976 | 161 | inline bool oopDesc::is_instanceClassLoader() const { return klass()->oop_is_instanceClassLoader(); } |
stefank@6976 | 162 | inline bool oopDesc::is_instanceMirror() const { return klass()->oop_is_instanceMirror(); } |
stefank@6976 | 163 | inline bool oopDesc::is_instanceRef() const { return klass()->oop_is_instanceRef(); } |
stefank@6976 | 164 | inline bool oopDesc::is_array() const { return klass()->oop_is_array(); } |
stefank@6976 | 165 | inline bool oopDesc::is_objArray() const { return klass()->oop_is_objArray(); } |
stefank@6976 | 166 | inline bool oopDesc::is_typeArray() const { return klass()->oop_is_typeArray(); } |
aoqi@0 | 167 | |
aoqi@0 | 168 | inline void* oopDesc::field_base(int offset) const { return (void*)&((char*)this)[offset]; } |
aoqi@0 | 169 | |
aoqi@0 | 170 | template <class T> inline T* oopDesc::obj_field_addr(int offset) const { return (T*)field_base(offset); } |
aoqi@0 | 171 | inline Metadata** oopDesc::metadata_field_addr(int offset) const { return (Metadata**)field_base(offset); } |
aoqi@0 | 172 | inline jbyte* oopDesc::byte_field_addr(int offset) const { return (jbyte*) field_base(offset); } |
aoqi@0 | 173 | inline jchar* oopDesc::char_field_addr(int offset) const { return (jchar*) field_base(offset); } |
aoqi@0 | 174 | inline jboolean* oopDesc::bool_field_addr(int offset) const { return (jboolean*)field_base(offset); } |
aoqi@0 | 175 | inline jint* oopDesc::int_field_addr(int offset) const { return (jint*) field_base(offset); } |
aoqi@0 | 176 | inline jshort* oopDesc::short_field_addr(int offset) const { return (jshort*) field_base(offset); } |
aoqi@0 | 177 | inline jlong* oopDesc::long_field_addr(int offset) const { return (jlong*) field_base(offset); } |
aoqi@0 | 178 | inline jfloat* oopDesc::float_field_addr(int offset) const { return (jfloat*) field_base(offset); } |
aoqi@0 | 179 | inline jdouble* oopDesc::double_field_addr(int offset) const { return (jdouble*) field_base(offset); } |
aoqi@0 | 180 | inline address* oopDesc::address_field_addr(int offset) const { return (address*) field_base(offset); } |
aoqi@0 | 181 | |
aoqi@0 | 182 | |
aoqi@0 | 183 | // Functions for getting and setting oops within instance objects. |
aoqi@0 | 184 | // If the oops are compressed, the type passed to these overloaded functions |
aoqi@0 | 185 | // is narrowOop. All functions are overloaded so they can be called by |
aoqi@0 | 186 | // template functions without conditionals (the compiler instantiates via |
aoqi@0 | 187 | // the right type and inlines the appopriate code). |
aoqi@0 | 188 | |
aoqi@0 | 189 | inline bool oopDesc::is_null(oop obj) { return obj == NULL; } |
aoqi@0 | 190 | inline bool oopDesc::is_null(narrowOop obj) { return obj == 0; } |
aoqi@0 | 191 | |
aoqi@0 | 192 | // Algorithm for encoding and decoding oops from 64 bit pointers to 32 bit |
aoqi@0 | 193 | // offset from the heap base. Saving the check for null can save instructions |
aoqi@0 | 194 | // in inner GC loops so these are separated. |
aoqi@0 | 195 | |
aoqi@0 | 196 | inline bool check_obj_alignment(oop obj) { |
aoqi@0 | 197 | return cast_from_oop<intptr_t>(obj) % MinObjAlignmentInBytes == 0; |
aoqi@0 | 198 | } |
aoqi@0 | 199 | |
aoqi@0 | 200 | inline narrowOop oopDesc::encode_heap_oop_not_null(oop v) { |
aoqi@0 | 201 | assert(!is_null(v), "oop value can never be zero"); |
aoqi@0 | 202 | assert(check_obj_alignment(v), "Address not aligned"); |
aoqi@0 | 203 | assert(Universe::heap()->is_in_reserved(v), "Address not in heap"); |
aoqi@0 | 204 | address base = Universe::narrow_oop_base(); |
aoqi@0 | 205 | int shift = Universe::narrow_oop_shift(); |
aoqi@0 | 206 | uint64_t pd = (uint64_t)(pointer_delta((void*)v, (void*)base, 1)); |
aoqi@0 | 207 | assert(OopEncodingHeapMax > pd, "change encoding max if new encoding"); |
aoqi@0 | 208 | uint64_t result = pd >> shift; |
aoqi@0 | 209 | assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow"); |
aoqi@0 | 210 | assert(decode_heap_oop(result) == v, "reversibility"); |
aoqi@0 | 211 | return (narrowOop)result; |
aoqi@0 | 212 | } |
aoqi@0 | 213 | |
aoqi@0 | 214 | inline narrowOop oopDesc::encode_heap_oop(oop v) { |
aoqi@0 | 215 | return (is_null(v)) ? (narrowOop)0 : encode_heap_oop_not_null(v); |
aoqi@0 | 216 | } |
aoqi@0 | 217 | |
aoqi@0 | 218 | inline oop oopDesc::decode_heap_oop_not_null(narrowOop v) { |
aoqi@0 | 219 | assert(!is_null(v), "narrow oop value can never be zero"); |
aoqi@0 | 220 | address base = Universe::narrow_oop_base(); |
aoqi@0 | 221 | int shift = Universe::narrow_oop_shift(); |
aoqi@0 | 222 | oop result = (oop)(void*)((uintptr_t)base + ((uintptr_t)v << shift)); |
aoqi@0 | 223 | assert(check_obj_alignment(result), err_msg("address not aligned: " INTPTR_FORMAT, p2i((void*) result))); |
aoqi@0 | 224 | return result; |
aoqi@0 | 225 | } |
aoqi@0 | 226 | |
aoqi@0 | 227 | inline oop oopDesc::decode_heap_oop(narrowOop v) { |
aoqi@0 | 228 | return is_null(v) ? (oop)NULL : decode_heap_oop_not_null(v); |
aoqi@0 | 229 | } |
aoqi@0 | 230 | |
aoqi@0 | 231 | inline oop oopDesc::decode_heap_oop_not_null(oop v) { return v; } |
aoqi@0 | 232 | inline oop oopDesc::decode_heap_oop(oop v) { return v; } |
aoqi@0 | 233 | |
aoqi@0 | 234 | // Load an oop out of the Java heap as is without decoding. |
aoqi@0 | 235 | // Called by GC to check for null before decoding. |
aoqi@0 | 236 | inline oop oopDesc::load_heap_oop(oop* p) { return *p; } |
aoqi@0 | 237 | inline narrowOop oopDesc::load_heap_oop(narrowOop* p) { return *p; } |
aoqi@0 | 238 | |
aoqi@0 | 239 | // Load and decode an oop out of the Java heap into a wide oop. |
aoqi@0 | 240 | inline oop oopDesc::load_decode_heap_oop_not_null(oop* p) { return *p; } |
aoqi@0 | 241 | inline oop oopDesc::load_decode_heap_oop_not_null(narrowOop* p) { |
aoqi@0 | 242 | return decode_heap_oop_not_null(*p); |
aoqi@0 | 243 | } |
aoqi@0 | 244 | |
aoqi@0 | 245 | // Load and decode an oop out of the heap accepting null |
aoqi@0 | 246 | inline oop oopDesc::load_decode_heap_oop(oop* p) { return *p; } |
aoqi@0 | 247 | inline oop oopDesc::load_decode_heap_oop(narrowOop* p) { |
aoqi@0 | 248 | return decode_heap_oop(*p); |
aoqi@0 | 249 | } |
aoqi@0 | 250 | |
aoqi@0 | 251 | // Store already encoded heap oop into the heap. |
aoqi@0 | 252 | inline void oopDesc::store_heap_oop(oop* p, oop v) { *p = v; } |
aoqi@0 | 253 | inline void oopDesc::store_heap_oop(narrowOop* p, narrowOop v) { *p = v; } |
aoqi@0 | 254 | |
aoqi@0 | 255 | // Encode and store a heap oop. |
aoqi@0 | 256 | inline void oopDesc::encode_store_heap_oop_not_null(narrowOop* p, oop v) { |
aoqi@0 | 257 | *p = encode_heap_oop_not_null(v); |
aoqi@0 | 258 | } |
aoqi@0 | 259 | inline void oopDesc::encode_store_heap_oop_not_null(oop* p, oop v) { *p = v; } |
aoqi@0 | 260 | |
aoqi@0 | 261 | // Encode and store a heap oop allowing for null. |
aoqi@0 | 262 | inline void oopDesc::encode_store_heap_oop(narrowOop* p, oop v) { |
aoqi@0 | 263 | *p = encode_heap_oop(v); |
aoqi@0 | 264 | } |
aoqi@0 | 265 | inline void oopDesc::encode_store_heap_oop(oop* p, oop v) { *p = v; } |
aoqi@0 | 266 | |
aoqi@0 | 267 | // Store heap oop as is for volatile fields. |
aoqi@0 | 268 | inline void oopDesc::release_store_heap_oop(volatile oop* p, oop v) { |
aoqi@0 | 269 | OrderAccess::release_store_ptr(p, v); |
aoqi@0 | 270 | } |
aoqi@0 | 271 | inline void oopDesc::release_store_heap_oop(volatile narrowOop* p, |
aoqi@0 | 272 | narrowOop v) { |
aoqi@0 | 273 | OrderAccess::release_store(p, v); |
aoqi@0 | 274 | } |
aoqi@0 | 275 | |
aoqi@0 | 276 | inline void oopDesc::release_encode_store_heap_oop_not_null( |
aoqi@0 | 277 | volatile narrowOop* p, oop v) { |
aoqi@0 | 278 | // heap oop is not pointer sized. |
aoqi@0 | 279 | OrderAccess::release_store(p, encode_heap_oop_not_null(v)); |
aoqi@0 | 280 | } |
aoqi@0 | 281 | |
aoqi@0 | 282 | inline void oopDesc::release_encode_store_heap_oop_not_null( |
aoqi@0 | 283 | volatile oop* p, oop v) { |
aoqi@0 | 284 | OrderAccess::release_store_ptr(p, v); |
aoqi@0 | 285 | } |
aoqi@0 | 286 | |
aoqi@0 | 287 | inline void oopDesc::release_encode_store_heap_oop(volatile oop* p, |
aoqi@0 | 288 | oop v) { |
aoqi@0 | 289 | OrderAccess::release_store_ptr(p, v); |
aoqi@0 | 290 | } |
aoqi@0 | 291 | inline void oopDesc::release_encode_store_heap_oop( |
aoqi@0 | 292 | volatile narrowOop* p, oop v) { |
aoqi@0 | 293 | OrderAccess::release_store(p, encode_heap_oop(v)); |
aoqi@0 | 294 | } |
aoqi@0 | 295 | |
aoqi@0 | 296 | |
aoqi@0 | 297 | // These functions are only used to exchange oop fields in instances, |
aoqi@0 | 298 | // not headers. |
aoqi@0 | 299 | inline oop oopDesc::atomic_exchange_oop(oop exchange_value, volatile HeapWord *dest) { |
aoqi@0 | 300 | if (UseCompressedOops) { |
aoqi@0 | 301 | // encode exchange value from oop to T |
aoqi@0 | 302 | narrowOop val = encode_heap_oop(exchange_value); |
aoqi@0 | 303 | narrowOop old = (narrowOop)Atomic::xchg(val, (narrowOop*)dest); |
aoqi@0 | 304 | // decode old from T to oop |
aoqi@0 | 305 | return decode_heap_oop(old); |
aoqi@0 | 306 | } else { |
aoqi@0 | 307 | return (oop)Atomic::xchg_ptr(exchange_value, (oop*)dest); |
aoqi@0 | 308 | } |
aoqi@0 | 309 | } |
aoqi@0 | 310 | |
aoqi@0 | 311 | // In order to put or get a field out of an instance, must first check |
aoqi@0 | 312 | // if the field has been compressed and uncompress it. |
aoqi@0 | 313 | inline oop oopDesc::obj_field(int offset) const { |
aoqi@0 | 314 | return UseCompressedOops ? |
aoqi@0 | 315 | load_decode_heap_oop(obj_field_addr<narrowOop>(offset)) : |
aoqi@0 | 316 | load_decode_heap_oop(obj_field_addr<oop>(offset)); |
aoqi@0 | 317 | } |
aoqi@0 | 318 | inline volatile oop oopDesc::obj_field_volatile(int offset) const { |
aoqi@0 | 319 | volatile oop value = obj_field(offset); |
aoqi@0 | 320 | OrderAccess::acquire(); |
aoqi@0 | 321 | return value; |
aoqi@0 | 322 | } |
aoqi@0 | 323 | inline void oopDesc::obj_field_put(int offset, oop value) { |
aoqi@0 | 324 | UseCompressedOops ? oop_store(obj_field_addr<narrowOop>(offset), value) : |
aoqi@0 | 325 | oop_store(obj_field_addr<oop>(offset), value); |
aoqi@0 | 326 | } |
aoqi@0 | 327 | |
aoqi@0 | 328 | inline Metadata* oopDesc::metadata_field(int offset) const { |
aoqi@0 | 329 | return *metadata_field_addr(offset); |
aoqi@0 | 330 | } |
aoqi@0 | 331 | |
aoqi@0 | 332 | inline void oopDesc::metadata_field_put(int offset, Metadata* value) { |
aoqi@0 | 333 | *metadata_field_addr(offset) = value; |
aoqi@0 | 334 | } |
aoqi@0 | 335 | |
aoqi@0 | 336 | inline void oopDesc::obj_field_put_raw(int offset, oop value) { |
aoqi@0 | 337 | UseCompressedOops ? |
aoqi@0 | 338 | encode_store_heap_oop(obj_field_addr<narrowOop>(offset), value) : |
aoqi@0 | 339 | encode_store_heap_oop(obj_field_addr<oop>(offset), value); |
aoqi@0 | 340 | } |
aoqi@0 | 341 | inline void oopDesc::obj_field_put_volatile(int offset, oop value) { |
aoqi@0 | 342 | OrderAccess::release(); |
aoqi@0 | 343 | obj_field_put(offset, value); |
aoqi@0 | 344 | OrderAccess::fence(); |
aoqi@0 | 345 | } |
aoqi@0 | 346 | |
aoqi@0 | 347 | inline jbyte oopDesc::byte_field(int offset) const { return (jbyte) *byte_field_addr(offset); } |
aoqi@0 | 348 | inline void oopDesc::byte_field_put(int offset, jbyte contents) { *byte_field_addr(offset) = (jint) contents; } |
aoqi@0 | 349 | |
aoqi@0 | 350 | inline jboolean oopDesc::bool_field(int offset) const { return (jboolean) *bool_field_addr(offset); } |
kevinw@8368 | 351 | inline void oopDesc::bool_field_put(int offset, jboolean contents) { *bool_field_addr(offset) = (( (jint) contents) & 1); } |
aoqi@0 | 352 | |
aoqi@0 | 353 | inline jchar oopDesc::char_field(int offset) const { return (jchar) *char_field_addr(offset); } |
aoqi@0 | 354 | inline void oopDesc::char_field_put(int offset, jchar contents) { *char_field_addr(offset) = (jint) contents; } |
aoqi@0 | 355 | |
aoqi@0 | 356 | inline jint oopDesc::int_field(int offset) const { return *int_field_addr(offset); } |
aoqi@0 | 357 | inline void oopDesc::int_field_put(int offset, jint contents) { *int_field_addr(offset) = contents; } |
aoqi@0 | 358 | |
aoqi@0 | 359 | inline jshort oopDesc::short_field(int offset) const { return (jshort) *short_field_addr(offset); } |
aoqi@0 | 360 | inline void oopDesc::short_field_put(int offset, jshort contents) { *short_field_addr(offset) = (jint) contents;} |
aoqi@0 | 361 | |
aoqi@0 | 362 | inline jlong oopDesc::long_field(int offset) const { return *long_field_addr(offset); } |
aoqi@0 | 363 | inline void oopDesc::long_field_put(int offset, jlong contents) { *long_field_addr(offset) = contents; } |
aoqi@0 | 364 | |
aoqi@0 | 365 | inline jfloat oopDesc::float_field(int offset) const { return *float_field_addr(offset); } |
aoqi@0 | 366 | inline void oopDesc::float_field_put(int offset, jfloat contents) { *float_field_addr(offset) = contents; } |
aoqi@0 | 367 | |
aoqi@0 | 368 | inline jdouble oopDesc::double_field(int offset) const { return *double_field_addr(offset); } |
aoqi@0 | 369 | inline void oopDesc::double_field_put(int offset, jdouble contents) { *double_field_addr(offset) = contents; } |
aoqi@0 | 370 | |
aoqi@0 | 371 | inline address oopDesc::address_field(int offset) const { return *address_field_addr(offset); } |
aoqi@0 | 372 | inline void oopDesc::address_field_put(int offset, address contents) { *address_field_addr(offset) = contents; } |
aoqi@0 | 373 | |
aoqi@0 | 374 | inline oop oopDesc::obj_field_acquire(int offset) const { |
aoqi@0 | 375 | return UseCompressedOops ? |
aoqi@0 | 376 | decode_heap_oop((narrowOop) |
aoqi@0 | 377 | OrderAccess::load_acquire(obj_field_addr<narrowOop>(offset))) |
aoqi@0 | 378 | : decode_heap_oop((oop) |
aoqi@0 | 379 | OrderAccess::load_ptr_acquire(obj_field_addr<oop>(offset))); |
aoqi@0 | 380 | } |
aoqi@0 | 381 | inline void oopDesc::release_obj_field_put(int offset, oop value) { |
aoqi@0 | 382 | UseCompressedOops ? |
aoqi@0 | 383 | oop_store((volatile narrowOop*)obj_field_addr<narrowOop>(offset), value) : |
aoqi@0 | 384 | oop_store((volatile oop*) obj_field_addr<oop>(offset), value); |
aoqi@0 | 385 | } |
aoqi@0 | 386 | |
aoqi@0 | 387 | inline jbyte oopDesc::byte_field_acquire(int offset) const { return OrderAccess::load_acquire(byte_field_addr(offset)); } |
aoqi@0 | 388 | inline void oopDesc::release_byte_field_put(int offset, jbyte contents) { OrderAccess::release_store(byte_field_addr(offset), contents); } |
aoqi@0 | 389 | |
aoqi@0 | 390 | inline jboolean oopDesc::bool_field_acquire(int offset) const { return OrderAccess::load_acquire(bool_field_addr(offset)); } |
kevinw@8368 | 391 | inline void oopDesc::release_bool_field_put(int offset, jboolean contents) { OrderAccess::release_store(bool_field_addr(offset), (contents & 1)); } |
aoqi@0 | 392 | |
aoqi@0 | 393 | inline jchar oopDesc::char_field_acquire(int offset) const { return OrderAccess::load_acquire(char_field_addr(offset)); } |
aoqi@0 | 394 | inline void oopDesc::release_char_field_put(int offset, jchar contents) { OrderAccess::release_store(char_field_addr(offset), contents); } |
aoqi@0 | 395 | |
aoqi@0 | 396 | inline jint oopDesc::int_field_acquire(int offset) const { return OrderAccess::load_acquire(int_field_addr(offset)); } |
aoqi@0 | 397 | inline void oopDesc::release_int_field_put(int offset, jint contents) { OrderAccess::release_store(int_field_addr(offset), contents); } |
aoqi@0 | 398 | |
aoqi@0 | 399 | inline jshort oopDesc::short_field_acquire(int offset) const { return (jshort)OrderAccess::load_acquire(short_field_addr(offset)); } |
aoqi@0 | 400 | inline void oopDesc::release_short_field_put(int offset, jshort contents) { OrderAccess::release_store(short_field_addr(offset), contents); } |
aoqi@0 | 401 | |
aoqi@0 | 402 | inline jlong oopDesc::long_field_acquire(int offset) const { return OrderAccess::load_acquire(long_field_addr(offset)); } |
aoqi@0 | 403 | inline void oopDesc::release_long_field_put(int offset, jlong contents) { OrderAccess::release_store(long_field_addr(offset), contents); } |
aoqi@0 | 404 | |
aoqi@0 | 405 | inline jfloat oopDesc::float_field_acquire(int offset) const { return OrderAccess::load_acquire(float_field_addr(offset)); } |
aoqi@0 | 406 | inline void oopDesc::release_float_field_put(int offset, jfloat contents) { OrderAccess::release_store(float_field_addr(offset), contents); } |
aoqi@0 | 407 | |
aoqi@0 | 408 | inline jdouble oopDesc::double_field_acquire(int offset) const { return OrderAccess::load_acquire(double_field_addr(offset)); } |
aoqi@0 | 409 | inline void oopDesc::release_double_field_put(int offset, jdouble contents) { OrderAccess::release_store(double_field_addr(offset), contents); } |
aoqi@0 | 410 | |
aoqi@0 | 411 | inline address oopDesc::address_field_acquire(int offset) const { return (address) OrderAccess::load_ptr_acquire(address_field_addr(offset)); } |
aoqi@0 | 412 | inline void oopDesc::release_address_field_put(int offset, address contents) { OrderAccess::release_store_ptr(address_field_addr(offset), contents); } |
aoqi@0 | 413 | |
aoqi@0 | 414 | inline int oopDesc::size_given_klass(Klass* klass) { |
aoqi@0 | 415 | int lh = klass->layout_helper(); |
aoqi@0 | 416 | int s; |
aoqi@0 | 417 | |
aoqi@0 | 418 | // lh is now a value computed at class initialization that may hint |
aoqi@0 | 419 | // at the size. For instances, this is positive and equal to the |
aoqi@0 | 420 | // size. For arrays, this is negative and provides log2 of the |
aoqi@0 | 421 | // array element size. For other oops, it is zero and thus requires |
aoqi@0 | 422 | // a virtual call. |
aoqi@0 | 423 | // |
aoqi@0 | 424 | // We go to all this trouble because the size computation is at the |
aoqi@0 | 425 | // heart of phase 2 of mark-compaction, and called for every object, |
aoqi@0 | 426 | // alive or dead. So the speed here is equal in importance to the |
aoqi@0 | 427 | // speed of allocation. |
aoqi@0 | 428 | |
aoqi@0 | 429 | if (lh > Klass::_lh_neutral_value) { |
aoqi@0 | 430 | if (!Klass::layout_helper_needs_slow_path(lh)) { |
aoqi@0 | 431 | s = lh >> LogHeapWordSize; // deliver size scaled by wordSize |
aoqi@0 | 432 | } else { |
aoqi@0 | 433 | s = klass->oop_size(this); |
aoqi@0 | 434 | } |
aoqi@0 | 435 | } else if (lh <= Klass::_lh_neutral_value) { |
aoqi@0 | 436 | // The most common case is instances; fall through if so. |
aoqi@0 | 437 | if (lh < Klass::_lh_neutral_value) { |
aoqi@0 | 438 | // Second most common case is arrays. We have to fetch the |
aoqi@0 | 439 | // length of the array, shift (multiply) it appropriately, |
aoqi@0 | 440 | // up to wordSize, add the header, and align to object size. |
aoqi@0 | 441 | size_t size_in_bytes; |
aoqi@0 | 442 | #ifdef _M_IA64 |
aoqi@0 | 443 | // The Windows Itanium Aug 2002 SDK hoists this load above |
aoqi@0 | 444 | // the check for s < 0. An oop at the end of the heap will |
aoqi@0 | 445 | // cause an access violation if this load is performed on a non |
aoqi@0 | 446 | // array oop. Making the reference volatile prohibits this. |
aoqi@0 | 447 | // (%%% please explain by what magic the length is actually fetched!) |
aoqi@0 | 448 | volatile int *array_length; |
aoqi@0 | 449 | array_length = (volatile int *)( (intptr_t)this + |
aoqi@0 | 450 | arrayOopDesc::length_offset_in_bytes() ); |
aoqi@0 | 451 | assert(array_length > 0, "Integer arithmetic problem somewhere"); |
aoqi@0 | 452 | // Put into size_t to avoid overflow. |
aoqi@0 | 453 | size_in_bytes = (size_t) array_length; |
aoqi@0 | 454 | size_in_bytes = size_in_bytes << Klass::layout_helper_log2_element_size(lh); |
aoqi@0 | 455 | #else |
aoqi@0 | 456 | size_t array_length = (size_t) ((arrayOop)this)->length(); |
aoqi@0 | 457 | size_in_bytes = array_length << Klass::layout_helper_log2_element_size(lh); |
aoqi@0 | 458 | #endif |
aoqi@0 | 459 | size_in_bytes += Klass::layout_helper_header_size(lh); |
aoqi@0 | 460 | |
aoqi@0 | 461 | // This code could be simplified, but by keeping array_header_in_bytes |
aoqi@0 | 462 | // in units of bytes and doing it this way we can round up just once, |
aoqi@0 | 463 | // skipping the intermediate round to HeapWordSize. Cast the result |
aoqi@0 | 464 | // of round_to to size_t to guarantee unsigned division == right shift. |
aoqi@0 | 465 | s = (int)((size_t)round_to(size_in_bytes, MinObjAlignmentInBytes) / |
aoqi@0 | 466 | HeapWordSize); |
aoqi@0 | 467 | |
aoqi@0 | 468 | // UseParNewGC, UseParallelGC and UseG1GC can change the length field |
aoqi@0 | 469 | // of an "old copy" of an object array in the young gen so it indicates |
aoqi@0 | 470 | // the grey portion of an already copied array. This will cause the first |
aoqi@0 | 471 | // disjunct below to fail if the two comparands are computed across such |
aoqi@0 | 472 | // a concurrent change. |
aoqi@0 | 473 | // UseParNewGC also runs with promotion labs (which look like int |
aoqi@0 | 474 | // filler arrays) which are subject to changing their declared size |
aoqi@0 | 475 | // when finally retiring a PLAB; this also can cause the first disjunct |
aoqi@0 | 476 | // to fail for another worker thread that is concurrently walking the block |
aoqi@0 | 477 | // offset table. Both these invariant failures are benign for their |
aoqi@0 | 478 | // current uses; we relax the assertion checking to cover these two cases below: |
aoqi@0 | 479 | // is_objArray() && is_forwarded() // covers first scenario above |
aoqi@0 | 480 | // || is_typeArray() // covers second scenario above |
aoqi@0 | 481 | // If and when UseParallelGC uses the same obj array oop stealing/chunking |
aoqi@0 | 482 | // technique, we will need to suitably modify the assertion. |
aoqi@0 | 483 | assert((s == klass->oop_size(this)) || |
aoqi@0 | 484 | (Universe::heap()->is_gc_active() && |
aoqi@0 | 485 | ((is_typeArray() && UseParNewGC) || |
aoqi@0 | 486 | (is_objArray() && is_forwarded() && (UseParNewGC || UseParallelGC || UseG1GC)))), |
aoqi@0 | 487 | "wrong array object size"); |
aoqi@0 | 488 | } else { |
aoqi@0 | 489 | // Must be zero, so bite the bullet and take the virtual call. |
aoqi@0 | 490 | s = klass->oop_size(this); |
aoqi@0 | 491 | } |
aoqi@0 | 492 | } |
aoqi@0 | 493 | |
aoqi@0 | 494 | assert(s % MinObjAlignment == 0, "alignment check"); |
aoqi@0 | 495 | assert(s > 0, "Bad size calculated"); |
aoqi@0 | 496 | return s; |
aoqi@0 | 497 | } |
aoqi@0 | 498 | |
aoqi@0 | 499 | |
aoqi@0 | 500 | inline int oopDesc::size() { |
aoqi@0 | 501 | return size_given_klass(klass()); |
aoqi@0 | 502 | } |
aoqi@0 | 503 | |
aoqi@0 | 504 | inline void update_barrier_set(void* p, oop v, bool release = false) { |
aoqi@0 | 505 | assert(oopDesc::bs() != NULL, "Uninitialized bs in oop!"); |
aoqi@0 | 506 | oopDesc::bs()->write_ref_field(p, v, release); |
aoqi@0 | 507 | } |
aoqi@0 | 508 | |
aoqi@0 | 509 | template <class T> inline void update_barrier_set_pre(T* p, oop v) { |
aoqi@0 | 510 | oopDesc::bs()->write_ref_field_pre(p, v); |
aoqi@0 | 511 | } |
aoqi@0 | 512 | |
aoqi@0 | 513 | template <class T> inline void oop_store(T* p, oop v) { |
aoqi@0 | 514 | if (always_do_update_barrier) { |
aoqi@0 | 515 | oop_store((volatile T*)p, v); |
aoqi@0 | 516 | } else { |
aoqi@0 | 517 | update_barrier_set_pre(p, v); |
aoqi@0 | 518 | oopDesc::encode_store_heap_oop(p, v); |
aoqi@0 | 519 | // always_do_update_barrier == false => |
aoqi@0 | 520 | // Either we are at a safepoint (in GC) or CMS is not used. In both |
aoqi@0 | 521 | // cases it's unnecessary to mark the card as dirty with release sematics. |
aoqi@0 | 522 | update_barrier_set((void*)p, v, false /* release */); // cast away type |
aoqi@0 | 523 | } |
aoqi@0 | 524 | } |
aoqi@0 | 525 | |
aoqi@0 | 526 | template <class T> inline void oop_store(volatile T* p, oop v) { |
aoqi@0 | 527 | update_barrier_set_pre((T*)p, v); // cast away volatile |
aoqi@0 | 528 | // Used by release_obj_field_put, so use release_store_ptr. |
aoqi@0 | 529 | oopDesc::release_encode_store_heap_oop(p, v); |
aoqi@0 | 530 | // When using CMS we must mark the card corresponding to p as dirty |
aoqi@0 | 531 | // with release sematics to prevent that CMS sees the dirty card but |
aoqi@0 | 532 | // not the new value v at p due to reordering of the two |
aoqi@0 | 533 | // stores. Note that CMS has a concurrent precleaning phase, where |
aoqi@0 | 534 | // it reads the card table while the Java threads are running. |
aoqi@0 | 535 | update_barrier_set((void*)p, v, true /* release */); // cast away type |
aoqi@0 | 536 | } |
aoqi@0 | 537 | |
aoqi@0 | 538 | // Should replace *addr = oop assignments where addr type depends on UseCompressedOops |
aoqi@0 | 539 | // (without having to remember the function name this calls). |
aoqi@0 | 540 | inline void oop_store_raw(HeapWord* addr, oop value) { |
aoqi@0 | 541 | if (UseCompressedOops) { |
aoqi@0 | 542 | oopDesc::encode_store_heap_oop((narrowOop*)addr, value); |
aoqi@0 | 543 | } else { |
aoqi@0 | 544 | oopDesc::encode_store_heap_oop((oop*)addr, value); |
aoqi@0 | 545 | } |
aoqi@0 | 546 | } |
aoqi@0 | 547 | |
aoqi@0 | 548 | inline oop oopDesc::atomic_compare_exchange_oop(oop exchange_value, |
aoqi@0 | 549 | volatile HeapWord *dest, |
aoqi@0 | 550 | oop compare_value, |
aoqi@0 | 551 | bool prebarrier) { |
aoqi@0 | 552 | if (UseCompressedOops) { |
aoqi@0 | 553 | if (prebarrier) { |
aoqi@0 | 554 | update_barrier_set_pre((narrowOop*)dest, exchange_value); |
aoqi@0 | 555 | } |
aoqi@0 | 556 | // encode exchange and compare value from oop to T |
aoqi@0 | 557 | narrowOop val = encode_heap_oop(exchange_value); |
aoqi@0 | 558 | narrowOop cmp = encode_heap_oop(compare_value); |
aoqi@0 | 559 | |
aoqi@0 | 560 | narrowOop old = (narrowOop) Atomic::cmpxchg(val, (narrowOop*)dest, cmp); |
aoqi@0 | 561 | // decode old from T to oop |
aoqi@0 | 562 | return decode_heap_oop(old); |
aoqi@0 | 563 | } else { |
aoqi@0 | 564 | if (prebarrier) { |
aoqi@0 | 565 | update_barrier_set_pre((oop*)dest, exchange_value); |
aoqi@0 | 566 | } |
aoqi@0 | 567 | return (oop)Atomic::cmpxchg_ptr(exchange_value, (oop*)dest, compare_value); |
aoqi@0 | 568 | } |
aoqi@0 | 569 | } |
aoqi@0 | 570 | |
aoqi@0 | 571 | // Used only for markSweep, scavenging |
aoqi@0 | 572 | inline bool oopDesc::is_gc_marked() const { |
aoqi@0 | 573 | return mark()->is_marked(); |
aoqi@0 | 574 | } |
aoqi@0 | 575 | |
aoqi@0 | 576 | inline bool oopDesc::is_locked() const { |
aoqi@0 | 577 | return mark()->is_locked(); |
aoqi@0 | 578 | } |
aoqi@0 | 579 | |
aoqi@0 | 580 | inline bool oopDesc::is_unlocked() const { |
aoqi@0 | 581 | return mark()->is_unlocked(); |
aoqi@0 | 582 | } |
aoqi@0 | 583 | |
aoqi@0 | 584 | inline bool oopDesc::has_bias_pattern() const { |
aoqi@0 | 585 | return mark()->has_bias_pattern(); |
aoqi@0 | 586 | } |
aoqi@0 | 587 | |
aoqi@0 | 588 | |
aoqi@0 | 589 | // used only for asserts |
aoqi@0 | 590 | inline bool oopDesc::is_oop(bool ignore_mark_word) const { |
aoqi@0 | 591 | oop obj = (oop) this; |
aoqi@0 | 592 | if (!check_obj_alignment(obj)) return false; |
aoqi@0 | 593 | if (!Universe::heap()->is_in_reserved(obj)) return false; |
aoqi@0 | 594 | // obj is aligned and accessible in heap |
aoqi@0 | 595 | if (Universe::heap()->is_in_reserved(obj->klass_or_null())) return false; |
aoqi@0 | 596 | |
aoqi@0 | 597 | // Header verification: the mark is typically non-NULL. If we're |
aoqi@0 | 598 | // at a safepoint, it must not be null. |
aoqi@0 | 599 | // Outside of a safepoint, the header could be changing (for example, |
aoqi@0 | 600 | // another thread could be inflating a lock on this object). |
aoqi@0 | 601 | if (ignore_mark_word) { |
aoqi@0 | 602 | return true; |
aoqi@0 | 603 | } |
aoqi@0 | 604 | if (mark() != NULL) { |
aoqi@0 | 605 | return true; |
aoqi@0 | 606 | } |
aoqi@0 | 607 | return !SafepointSynchronize::is_at_safepoint(); |
aoqi@0 | 608 | } |
aoqi@0 | 609 | |
aoqi@0 | 610 | |
aoqi@0 | 611 | // used only for asserts |
aoqi@0 | 612 | inline bool oopDesc::is_oop_or_null(bool ignore_mark_word) const { |
aoqi@0 | 613 | return this == NULL ? true : is_oop(ignore_mark_word); |
aoqi@0 | 614 | } |
aoqi@0 | 615 | |
aoqi@0 | 616 | #ifndef PRODUCT |
aoqi@0 | 617 | // used only for asserts |
aoqi@0 | 618 | inline bool oopDesc::is_unlocked_oop() const { |
aoqi@0 | 619 | if (!Universe::heap()->is_in_reserved(this)) return false; |
aoqi@0 | 620 | return mark()->is_unlocked(); |
aoqi@0 | 621 | } |
aoqi@0 | 622 | #endif // PRODUCT |
aoqi@0 | 623 | |
aoqi@0 | 624 | inline void oopDesc::follow_contents(void) { |
aoqi@0 | 625 | assert (is_gc_marked(), "should be marked"); |
aoqi@0 | 626 | klass()->oop_follow_contents(this); |
aoqi@0 | 627 | } |
aoqi@0 | 628 | |
aoqi@0 | 629 | // Used by scavengers |
aoqi@0 | 630 | |
aoqi@0 | 631 | inline bool oopDesc::is_forwarded() const { |
aoqi@0 | 632 | // The extra heap check is needed since the obj might be locked, in which case the |
aoqi@0 | 633 | // mark would point to a stack location and have the sentinel bit cleared |
aoqi@0 | 634 | return mark()->is_marked(); |
aoqi@0 | 635 | } |
aoqi@0 | 636 | |
aoqi@0 | 637 | // Used by scavengers |
aoqi@0 | 638 | inline void oopDesc::forward_to(oop p) { |
aoqi@0 | 639 | assert(check_obj_alignment(p), |
aoqi@0 | 640 | "forwarding to something not aligned"); |
aoqi@0 | 641 | assert(Universe::heap()->is_in_reserved(p), |
aoqi@0 | 642 | "forwarding to something not in heap"); |
aoqi@0 | 643 | markOop m = markOopDesc::encode_pointer_as_mark(p); |
aoqi@0 | 644 | assert(m->decode_pointer() == p, "encoding must be reversable"); |
aoqi@0 | 645 | set_mark(m); |
aoqi@0 | 646 | } |
aoqi@0 | 647 | |
aoqi@0 | 648 | // Used by parallel scavengers |
aoqi@0 | 649 | inline bool oopDesc::cas_forward_to(oop p, markOop compare) { |
aoqi@0 | 650 | assert(check_obj_alignment(p), |
aoqi@0 | 651 | "forwarding to something not aligned"); |
aoqi@0 | 652 | assert(Universe::heap()->is_in_reserved(p), |
aoqi@0 | 653 | "forwarding to something not in heap"); |
aoqi@0 | 654 | markOop m = markOopDesc::encode_pointer_as_mark(p); |
aoqi@0 | 655 | assert(m->decode_pointer() == p, "encoding must be reversable"); |
aoqi@0 | 656 | return cas_set_mark(m, compare) == compare; |
aoqi@0 | 657 | } |
aoqi@0 | 658 | |
aoqi@0 | 659 | // Note that the forwardee is not the same thing as the displaced_mark. |
aoqi@0 | 660 | // The forwardee is used when copying during scavenge and mark-sweep. |
aoqi@0 | 661 | // It does need to clear the low two locking- and GC-related bits. |
aoqi@0 | 662 | inline oop oopDesc::forwardee() const { |
aoqi@0 | 663 | return (oop) mark()->decode_pointer(); |
aoqi@0 | 664 | } |
aoqi@0 | 665 | |
aoqi@0 | 666 | inline bool oopDesc::has_displaced_mark() const { |
aoqi@0 | 667 | return mark()->has_displaced_mark_helper(); |
aoqi@0 | 668 | } |
aoqi@0 | 669 | |
aoqi@0 | 670 | inline markOop oopDesc::displaced_mark() const { |
aoqi@0 | 671 | return mark()->displaced_mark_helper(); |
aoqi@0 | 672 | } |
aoqi@0 | 673 | |
aoqi@0 | 674 | inline void oopDesc::set_displaced_mark(markOop m) { |
aoqi@0 | 675 | mark()->set_displaced_mark_helper(m); |
aoqi@0 | 676 | } |
aoqi@0 | 677 | |
aoqi@0 | 678 | // The following method needs to be MT safe. |
aoqi@0 | 679 | inline uint oopDesc::age() const { |
aoqi@0 | 680 | assert(!is_forwarded(), "Attempt to read age from forwarded mark"); |
aoqi@0 | 681 | if (has_displaced_mark()) { |
aoqi@0 | 682 | return displaced_mark()->age(); |
aoqi@0 | 683 | } else { |
aoqi@0 | 684 | return mark()->age(); |
aoqi@0 | 685 | } |
aoqi@0 | 686 | } |
aoqi@0 | 687 | |
aoqi@0 | 688 | inline void oopDesc::incr_age() { |
aoqi@0 | 689 | assert(!is_forwarded(), "Attempt to increment age of forwarded mark"); |
aoqi@0 | 690 | if (has_displaced_mark()) { |
aoqi@0 | 691 | set_displaced_mark(displaced_mark()->incr_age()); |
aoqi@0 | 692 | } else { |
aoqi@0 | 693 | set_mark(mark()->incr_age()); |
aoqi@0 | 694 | } |
aoqi@0 | 695 | } |
aoqi@0 | 696 | |
aoqi@0 | 697 | |
aoqi@0 | 698 | inline intptr_t oopDesc::identity_hash() { |
aoqi@0 | 699 | // Fast case; if the object is unlocked and the hash value is set, no locking is needed |
aoqi@0 | 700 | // Note: The mark must be read into local variable to avoid concurrent updates. |
aoqi@0 | 701 | markOop mrk = mark(); |
aoqi@0 | 702 | if (mrk->is_unlocked() && !mrk->has_no_hash()) { |
aoqi@0 | 703 | return mrk->hash(); |
aoqi@0 | 704 | } else if (mrk->is_marked()) { |
aoqi@0 | 705 | return mrk->hash(); |
aoqi@0 | 706 | } else { |
aoqi@0 | 707 | return slow_identity_hash(); |
aoqi@0 | 708 | } |
aoqi@0 | 709 | } |
aoqi@0 | 710 | |
aoqi@0 | 711 | inline int oopDesc::adjust_pointers() { |
aoqi@0 | 712 | debug_only(int check_size = size()); |
aoqi@0 | 713 | int s = klass()->oop_adjust_pointers(this); |
aoqi@0 | 714 | assert(s == check_size, "should be the same"); |
aoqi@0 | 715 | return s; |
aoqi@0 | 716 | } |
aoqi@0 | 717 | |
aoqi@0 | 718 | #define OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ |
aoqi@0 | 719 | \ |
aoqi@0 | 720 | inline int oopDesc::oop_iterate(OopClosureType* blk) { \ |
aoqi@0 | 721 | SpecializationStats::record_call(); \ |
aoqi@0 | 722 | return klass()->oop_oop_iterate##nv_suffix(this, blk); \ |
aoqi@0 | 723 | } \ |
aoqi@0 | 724 | \ |
aoqi@0 | 725 | inline int oopDesc::oop_iterate(OopClosureType* blk, MemRegion mr) { \ |
aoqi@0 | 726 | SpecializationStats::record_call(); \ |
aoqi@0 | 727 | return klass()->oop_oop_iterate##nv_suffix##_m(this, blk, mr); \ |
aoqi@0 | 728 | } |
aoqi@0 | 729 | |
aoqi@0 | 730 | |
aoqi@0 | 731 | inline int oopDesc::oop_iterate_no_header(OopClosure* blk) { |
aoqi@0 | 732 | // The NoHeaderExtendedOopClosure wraps the OopClosure and proxies all |
aoqi@0 | 733 | // the do_oop calls, but turns off all other features in ExtendedOopClosure. |
aoqi@0 | 734 | NoHeaderExtendedOopClosure cl(blk); |
aoqi@0 | 735 | return oop_iterate(&cl); |
aoqi@0 | 736 | } |
aoqi@0 | 737 | |
aoqi@0 | 738 | inline int oopDesc::oop_iterate_no_header(OopClosure* blk, MemRegion mr) { |
aoqi@0 | 739 | NoHeaderExtendedOopClosure cl(blk); |
aoqi@0 | 740 | return oop_iterate(&cl, mr); |
aoqi@0 | 741 | } |
aoqi@0 | 742 | |
aoqi@0 | 743 | ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_DEFN) |
aoqi@0 | 744 | ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_DEFN) |
aoqi@0 | 745 | |
aoqi@0 | 746 | #if INCLUDE_ALL_GCS |
aoqi@0 | 747 | #define OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \ |
aoqi@0 | 748 | \ |
aoqi@0 | 749 | inline int oopDesc::oop_iterate_backwards(OopClosureType* blk) { \ |
aoqi@0 | 750 | SpecializationStats::record_call(); \ |
aoqi@0 | 751 | return klass()->oop_oop_iterate_backwards##nv_suffix(this, blk); \ |
aoqi@0 | 752 | } |
aoqi@0 | 753 | |
aoqi@0 | 754 | ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_BACKWARDS_DEFN) |
aoqi@0 | 755 | ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_BACKWARDS_DEFN) |
aoqi@0 | 756 | #endif // INCLUDE_ALL_GCS |
aoqi@0 | 757 | |
aoqi@0 | 758 | #endif // SHARE_VM_OOPS_OOP_INLINE_HPP |