1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_OOP_INLINE_HPP
  26 #define SHARE_VM_OOPS_OOP_INLINE_HPP
  27 
  28 #include "gc/shared/ageTable.hpp"
  29 #include "gc/shared/collectedHeap.inline.hpp"
  30 #include "gc/shared/genCollectedHeap.hpp"
  31 #include "gc/shared/generation.hpp"
  32 #include "oops/access.inline.hpp"
  33 #include "oops/arrayKlass.hpp"
  34 #include "oops/arrayOop.hpp"
  35 #include "oops/klass.inline.hpp"
  36 #include "oops/markOop.inline.hpp"
  37 #include "oops/oop.hpp"
  38 #include "runtime/atomic.hpp"
  39 #include "runtime/orderAccess.inline.hpp"
  40 #include "runtime/os.hpp"
  41 #include "utilities/align.hpp"
  42 #include "utilities/macros.hpp"
  43 
  44 // Implementation of all inlined member functions defined in oop.hpp
  45 // We need a separate file to avoid circular references
  46 
  47 void oopDesc::release_set_mark(markOop m) {
  48   OrderAccess::release_store(&_mark, m);
  49 }
  50 
  51 markOop oopDesc::cas_set_mark(markOop new_mark, markOop old_mark) {
  52   return Atomic::cmpxchg(new_mark, &_mark, old_mark);
  53 }
  54 
  55 void oopDesc::init_mark() {
  56   set_mark(markOopDesc::prototype_for_object(this));
  57 }
  58 
  59 Klass* oopDesc::klass() const {
  60   if (UseCompressedClassPointers) {
  61     return Klass::decode_klass_not_null(_metadata._compressed_klass);
  62   } else {
  63     return _metadata._klass;
  64   }
  65 }
  66 
  67 Klass* oopDesc::klass_or_null() const volatile {
  68   if (UseCompressedClassPointers) {
  69     return Klass::decode_klass(_metadata._compressed_klass);
  70   } else {
  71     return _metadata._klass;
  72   }
  73 }
  74 
  75 Klass* oopDesc::klass_or_null_acquire() const volatile {
  76   if (UseCompressedClassPointers) {
  77     // Workaround for non-const load_acquire parameter.
  78     const volatile narrowKlass* addr = &_metadata._compressed_klass;
  79     volatile narrowKlass* xaddr = const_cast<volatile narrowKlass*>(addr);
  80     return Klass::decode_klass(OrderAccess::load_acquire(xaddr));
  81   } else {
  82     return OrderAccess::load_acquire(&_metadata._klass);
  83   }
  84 }
  85 
  86 Klass** oopDesc::klass_addr() {
  87   // Only used internally and with CMS and will not work with
  88   // UseCompressedOops
  89   assert(!UseCompressedClassPointers, "only supported with uncompressed klass pointers");
  90   return (Klass**) &_metadata._klass;
  91 }
  92 
  93 narrowKlass* oopDesc::compressed_klass_addr() {
  94   assert(UseCompressedClassPointers, "only called by compressed klass pointers");
  95   return &_metadata._compressed_klass;
  96 }
  97 
  98 #if INCLUDE_VBC // fast oop only test (does not load klass)
  99 bool oopDesc::klass_is_value_based() {
 100         if (UseCompressedClassPointers) {
 101                 return Klass::decode_ptr_is_value_based(_metadata._compressed_klass);
 102         } else {
 103                 return Klass::ptr_is_value_based(_metadata._klass);
 104         }
 105 }
 106 #endif
 107 
 108 #define CHECK_SET_KLASS(k)                                                \
 109   do {                                                                    \
 110     assert(Universe::is_bootstrapping() || k != NULL, "NULL Klass");      \
 111     assert(Universe::is_bootstrapping() || k->is_klass(), "not a Klass"); \
 112   } while (0)
 113 
 114 void oopDesc::set_klass(Klass* k) {
 115   CHECK_SET_KLASS(k);
 116   if (UseCompressedClassPointers) {
 117     *compressed_klass_addr() = Klass::encode_klass_not_null(k);
 118   } else {
 119     *klass_addr() = k;
 120   }
 121 }
 122 
 123 void oopDesc::release_set_klass(Klass* k) {
 124   CHECK_SET_KLASS(k);
 125   if (UseCompressedClassPointers) {
 126     OrderAccess::release_store(compressed_klass_addr(),
 127                                Klass::encode_klass_not_null(k));
 128   } else {
 129     OrderAccess::release_store(klass_addr(), k);
 130   }
 131 }
 132 
 133 #undef CHECK_SET_KLASS
 134 
 135 int oopDesc::klass_gap() const {
 136   return *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes());
 137 }
 138 
 139 void oopDesc::set_klass_gap(int v) {
 140   if (UseCompressedClassPointers) {
 141     *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes()) = v;
 142   }
 143 }
 144 
 145 void oopDesc::set_klass_to_list_ptr(oop k) {
 146   // This is only to be used during GC, for from-space objects, so no
 147   // barrier is needed.
 148   if (UseCompressedClassPointers) {
 149     _metadata._compressed_klass = (narrowKlass)encode_heap_oop(k);  // may be null (parnew overflow handling)
 150   } else {
 151     _metadata._klass = (Klass*)(address)k;
 152   }
 153 }
 154 
 155 oop oopDesc::list_ptr_from_klass() {
 156   // This is only to be used during GC, for from-space objects.
 157   if (UseCompressedClassPointers) {
 158     return decode_heap_oop((narrowOop)_metadata._compressed_klass);
 159   } else {
 160     // Special case for GC
 161     return (oop)(address)_metadata._klass;
 162   }
 163 }
 164 
 165 bool oopDesc::is_a(Klass* k) const {
 166   return klass()->is_subtype_of(k);
 167 }
 168 
 169 int oopDesc::size()  {
 170   return size_given_klass(klass());
 171 }
 172 
 173 int oopDesc::size_given_klass(Klass* klass)  {
 174   int lh = klass->layout_helper();
 175   int s;
 176 
 177   // lh is now a value computed at class initialization that may hint
 178   // at the size.  For instances, this is positive and equal to the
 179   // size.  For arrays, this is negative and provides log2 of the
 180   // array element size.  For other oops, it is zero and thus requires
 181   // a virtual call.
 182   //
 183   // We go to all this trouble because the size computation is at the
 184   // heart of phase 2 of mark-compaction, and called for every object,
 185   // alive or dead.  So the speed here is equal in importance to the
 186   // speed of allocation.
 187 
 188   if (lh > Klass::_lh_neutral_value) {
 189     if (!Klass::layout_helper_needs_slow_path(lh)) {
 190       s = lh >> LogHeapWordSize;  // deliver size scaled by wordSize
 191     } else {
 192       s = klass->oop_size(this);
 193     }
 194   } else if (lh <= Klass::_lh_neutral_value) {
 195     // The most common case is instances; fall through if so.
 196     if (lh < Klass::_lh_neutral_value) {
 197       // Second most common case is arrays.  We have to fetch the
 198       // length of the array, shift (multiply) it appropriately,
 199       // up to wordSize, add the header, and align to object size.
 200       size_t size_in_bytes;
 201       size_t array_length = (size_t) ((arrayOop)this)->length();
 202       size_in_bytes = array_length << Klass::layout_helper_log2_element_size(lh);
 203       size_in_bytes += Klass::layout_helper_header_size(lh);
 204 
 205       // This code could be simplified, but by keeping array_header_in_bytes
 206       // in units of bytes and doing it this way we can round up just once,
 207       // skipping the intermediate round to HeapWordSize.
 208       s = (int)(align_up(size_in_bytes, MinObjAlignmentInBytes) / HeapWordSize);
 209 
 210       // ParNew (used by CMS), UseParallelGC and UseG1GC can change the length field
 211       // of an "old copy" of an object array in the young gen so it indicates
 212       // the grey portion of an already copied array. This will cause the first
 213       // disjunct below to fail if the two comparands are computed across such
 214       // a concurrent change.
 215       // ParNew also runs with promotion labs (which look like int
 216       // filler arrays) which are subject to changing their declared size
 217       // when finally retiring a PLAB; this also can cause the first disjunct
 218       // to fail for another worker thread that is concurrently walking the block
 219       // offset table. Both these invariant failures are benign for their
 220       // current uses; we relax the assertion checking to cover these two cases below:
 221       //     is_objArray() && is_forwarded()   // covers first scenario above
 222       //  || is_typeArray()                    // covers second scenario above
 223       // If and when UseParallelGC uses the same obj array oop stealing/chunking
 224       // technique, we will need to suitably modify the assertion.
 225       assert((s == klass->oop_size(this)) ||
 226              (Universe::heap()->is_gc_active() &&
 227               ((is_typeArray() && UseConcMarkSweepGC) ||
 228                (is_objArray()  && is_forwarded() && (UseConcMarkSweepGC || UseParallelGC || UseG1GC)))),
 229              "wrong array object size");
 230     } else {
 231       // Must be zero, so bite the bullet and take the virtual call.
 232       s = klass->oop_size(this);
 233     }
 234   }
 235 
 236   assert(s > 0, "Oop size must be greater than zero, not %d", s);
 237   assert(is_object_aligned(s), "Oop size is not properly aligned: %d", s);
 238   return s;
 239 }
 240 
 241 bool oopDesc::is_instance()  const { return klass()->is_instance_klass();  }
 242 bool oopDesc::is_array()     const { return klass()->is_array_klass();     }
 243 bool oopDesc::is_objArray()  const { return klass()->is_objArray_klass();  }
 244 bool oopDesc::is_typeArray() const { return klass()->is_typeArray_klass(); }
 245 
 246 void*      oopDesc::field_base(int offset)          const { return (void*)&((char*)this)[offset]; }
 247 
 248 jbyte*     oopDesc::byte_field_addr(int offset)     const { return (jbyte*)    field_base(offset); }
 249 jchar*     oopDesc::char_field_addr(int offset)     const { return (jchar*)    field_base(offset); }
 250 jboolean*  oopDesc::bool_field_addr(int offset)     const { return (jboolean*) field_base(offset); }
 251 jint*      oopDesc::int_field_addr(int offset)      const { return (jint*)     field_base(offset); }
 252 jshort*    oopDesc::short_field_addr(int offset)    const { return (jshort*)   field_base(offset); }
 253 jlong*     oopDesc::long_field_addr(int offset)     const { return (jlong*)    field_base(offset); }
 254 jfloat*    oopDesc::float_field_addr(int offset)    const { return (jfloat*)   field_base(offset); }
 255 jdouble*   oopDesc::double_field_addr(int offset)   const { return (jdouble*)  field_base(offset); }
 256 Metadata** oopDesc::metadata_field_addr(int offset) const { return (Metadata**)field_base(offset); }
 257 
 258 template <class T> T* oopDesc::obj_field_addr(int offset) const { return (T*)  field_base(offset); }
 259 address*   oopDesc::address_field_addr(int offset)  const { return (address*)  field_base(offset); }
 260 
 261 
 262 // Functions for getting and setting oops within instance objects.
 263 // If the oops are compressed, the type passed to these overloaded functions
 264 // is narrowOop.  All functions are overloaded so they can be called by
 265 // template functions without conditionals (the compiler instantiates via
 266 // the right type and inlines the appopriate code).
 267 
 268 // Algorithm for encoding and decoding oops from 64 bit pointers to 32 bit
 269 // offset from the heap base.  Saving the check for null can save instructions
 270 // in inner GC loops so these are separated.
 271 
 272 inline bool check_obj_alignment(oop obj) {
 273   return (cast_from_oop<intptr_t>(obj) & MinObjAlignmentInBytesMask) == 0;
 274 }
 275 
 276 oop oopDesc::decode_heap_oop_not_null(narrowOop v) {
 277   assert(!is_null(v), "narrow oop value can never be zero");
 278   address base = Universe::narrow_oop_base();
 279   int    shift = Universe::narrow_oop_shift();
 280   oop result = (oop)(void*)((uintptr_t)base + ((uintptr_t)v << shift));
 281   assert(check_obj_alignment(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
 282   return result;
 283 }
 284 
 285 oop oopDesc::decode_heap_oop(narrowOop v) {
 286   return is_null(v) ? (oop)NULL : decode_heap_oop_not_null(v);
 287 }
 288 
 289 narrowOop oopDesc::encode_heap_oop_not_null(oop v) {
 290   assert(!is_null(v), "oop value can never be zero");
 291   assert(check_obj_alignment(v), "Address not aligned");
 292   assert(Universe::heap()->is_in_reserved(v), "Address not in heap");
 293   address base = Universe::narrow_oop_base();
 294   int    shift = Universe::narrow_oop_shift();
 295   uint64_t  pd = (uint64_t)(pointer_delta((void*)v, (void*)base, 1));
 296   assert(OopEncodingHeapMax > pd, "change encoding max if new encoding");
 297   uint64_t result = pd >> shift;
 298   assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow");
 299   assert(decode_heap_oop(result) == v, "reversibility");
 300   return (narrowOop)result;
 301 }
 302 
 303 narrowOop oopDesc::encode_heap_oop(oop v) {
 304   return (is_null(v)) ? (narrowOop)0 : encode_heap_oop_not_null(v);
 305 }
 306 
 307 narrowOop oopDesc::load_heap_oop(narrowOop* p) { return *p; }
 308 oop       oopDesc::load_heap_oop(oop* p)       { return *p; }
 309 
 310 void oopDesc::store_heap_oop(narrowOop* p, narrowOop v) { *p = v; }
 311 void oopDesc::store_heap_oop(oop* p, oop v)             { *p = v; }
 312 
 313 // Load and decode an oop out of the Java heap into a wide oop.
 314 oop oopDesc::load_decode_heap_oop_not_null(narrowOop* p) {
 315   return decode_heap_oop_not_null(load_heap_oop(p));
 316 }
 317 
 318 // Load and decode an oop out of the heap accepting null
 319 oop oopDesc::load_decode_heap_oop(narrowOop* p) {
 320   return decode_heap_oop(load_heap_oop(p));
 321 }
 322 
 323 oop oopDesc::load_decode_heap_oop_not_null(oop* p) { return *p; }
 324 oop oopDesc::load_decode_heap_oop(oop* p)          { return *p; }
 325 
 326 void oopDesc::encode_store_heap_oop_not_null(oop* p, oop v) { *p = v; }
 327 void oopDesc::encode_store_heap_oop(oop* p, oop v)          { *p = v; }
 328 
 329 // Encode and store a heap oop.
 330 void oopDesc::encode_store_heap_oop_not_null(narrowOop* p, oop v) {
 331   *p = encode_heap_oop_not_null(v);
 332 }
 333 
 334 // Encode and store a heap oop allowing for null.
 335 void oopDesc::encode_store_heap_oop(narrowOop* p, oop v) {
 336   *p = encode_heap_oop(v);
 337 }
 338 
 339 inline oop  oopDesc::obj_field(int offset) const                    { return HeapAccess<>::oop_load_at(as_oop(), offset);  }
 340 inline void oopDesc::obj_field_put(int offset, oop value)           { HeapAccess<>::oop_store_at(as_oop(), offset, value); }
 341 
 342 inline jbyte oopDesc::byte_field(int offset) const                  { return HeapAccess<>::load_at(as_oop(), offset);  }
 343 inline void  oopDesc::byte_field_put(int offset, jbyte value)       { HeapAccess<>::store_at(as_oop(), offset, value); }
 344 
 345 inline jchar oopDesc::char_field(int offset) const                  { return HeapAccess<>::load_at(as_oop(), offset);  }
 346 inline void  oopDesc::char_field_put(int offset, jchar value)       { HeapAccess<>::store_at(as_oop(), offset, value); }
 347 
 348 inline jboolean oopDesc::bool_field(int offset) const               { return HeapAccess<>::load_at(as_oop(), offset);                }
 349 inline void     oopDesc::bool_field_put(int offset, jboolean value) { HeapAccess<>::store_at(as_oop(), offset, jboolean(value & 1)); }
 350 
 351 inline jshort oopDesc::short_field(int offset) const                { return HeapAccess<>::load_at(as_oop(), offset);  }
 352 inline void   oopDesc::short_field_put(int offset, jshort value)    { HeapAccess<>::store_at(as_oop(), offset, value); }
 353 
 354 inline jint oopDesc::int_field(int offset) const                    { return HeapAccess<>::load_at(as_oop(), offset);  }
 355 inline void oopDesc::int_field_put(int offset, jint value)          { HeapAccess<>::store_at(as_oop(), offset, value); }
 356 
 357 inline jlong oopDesc::long_field(int offset) const                  { return HeapAccess<>::load_at(as_oop(), offset);  }
 358 inline void  oopDesc::long_field_put(int offset, jlong value)       { HeapAccess<>::store_at(as_oop(), offset, value); }
 359 
 360 inline jfloat oopDesc::float_field(int offset) const                { return HeapAccess<>::load_at(as_oop(), offset);  }
 361 inline void   oopDesc::float_field_put(int offset, jfloat value)    { HeapAccess<>::store_at(as_oop(), offset, value); }
 362 
 363 inline jdouble oopDesc::double_field(int offset) const              { return HeapAccess<>::load_at(as_oop(), offset);  }
 364 inline void    oopDesc::double_field_put(int offset, jdouble value) { HeapAccess<>::store_at(as_oop(), offset, value); }
 365 
 366 bool oopDesc::is_locked() const {
 367   return mark()->is_locked();
 368 }
 369 
 370 bool oopDesc::is_unlocked() const {
 371   return mark()->is_unlocked();
 372 }
 373 
 374 bool oopDesc::has_bias_pattern() const {
 375   return mark()->has_bias_pattern();
 376 }
 377 
 378 // Used only for markSweep, scavenging
 379 bool oopDesc::is_gc_marked() const {
 380   return mark()->is_marked();
 381 }
 382 
 383 bool oopDesc::is_scavengable() const {
 384   return Universe::heap()->is_scavengable(oop(const_cast<oopDesc*>(this)));
 385 }
 386 
 387 // Used by scavengers
 388 bool oopDesc::is_forwarded() const {
 389   // The extra heap check is needed since the obj might be locked, in which case the
 390   // mark would point to a stack location and have the sentinel bit cleared
 391   return mark()->is_marked();
 392 }
 393 
 394 // Used by scavengers
 395 void oopDesc::forward_to(oop p) {
 396   assert(check_obj_alignment(p),
 397          "forwarding to something not aligned");
 398   assert(Universe::heap()->is_in_reserved(p),
 399          "forwarding to something not in heap");
 400   assert(!is_archive_object(oop(this)) &&
 401          !is_archive_object(p),
 402          "forwarding archive object");
 403   markOop m = markOopDesc::encode_pointer_as_mark(p);
 404   assert(m->decode_pointer() == p, "encoding must be reversable");
 405   set_mark(m);
 406 }
 407 
 408 // Used by parallel scavengers
 409 bool oopDesc::cas_forward_to(oop p, markOop compare) {
 410   assert(check_obj_alignment(p),
 411          "forwarding to something not aligned");
 412   assert(Universe::heap()->is_in_reserved(p),
 413          "forwarding to something not in heap");
 414   markOop m = markOopDesc::encode_pointer_as_mark(p);
 415   assert(m->decode_pointer() == p, "encoding must be reversable");
 416   return cas_set_mark(m, compare) == compare;
 417 }
 418 
 419 #if INCLUDE_ALL_GCS
 420 oop oopDesc::forward_to_atomic(oop p) {
 421   markOop oldMark = mark();
 422   markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
 423   markOop curMark;
 424 
 425   assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable");
 426   assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
 427 
 428   while (!oldMark->is_marked()) {
 429     curMark = Atomic::cmpxchg(forwardPtrMark, &_mark, oldMark);
 430     assert(is_forwarded(), "object should have been forwarded");
 431     if (curMark == oldMark) {
 432       return NULL;
 433     }
 434     // If the CAS was unsuccessful then curMark->is_marked()
 435     // should return true as another thread has CAS'd in another
 436     // forwarding pointer.
 437     oldMark = curMark;
 438   }
 439   return forwardee();
 440 }
 441 #endif
 442 
 443 // Note that the forwardee is not the same thing as the displaced_mark.
 444 // The forwardee is used when copying during scavenge and mark-sweep.
 445 // It does need to clear the low two locking- and GC-related bits.
 446 oop oopDesc::forwardee() const {
 447   return (oop) mark()->decode_pointer();
 448 }
 449 
 450 // The following method needs to be MT safe.
 451 uint oopDesc::age() const {
 452   assert(!is_forwarded(), "Attempt to read age from forwarded mark");
 453   if (has_displaced_mark()) {
 454     return displaced_mark()->age();
 455   } else {
 456     return mark()->age();
 457   }
 458 }
 459 
 460 void oopDesc::incr_age() {
 461   assert(!is_forwarded(), "Attempt to increment age of forwarded mark");
 462   if (has_displaced_mark()) {
 463     set_displaced_mark(displaced_mark()->incr_age());
 464   } else {
 465     set_mark(mark()->incr_age());
 466   }
 467 }
 468 
 469 #if INCLUDE_ALL_GCS
 470 void oopDesc::pc_follow_contents(ParCompactionManager* cm) {
 471   klass()->oop_pc_follow_contents(this, cm);
 472 }
 473 
 474 void oopDesc::pc_update_contents(ParCompactionManager* cm) {
 475   Klass* k = klass();
 476   if (!k->is_typeArray_klass()) {
 477     // It might contain oops beyond the header, so take the virtual call.
 478     k->oop_pc_update_pointers(this, cm);
 479   }
 480   // Else skip it.  The TypeArrayKlass in the header never needs scavenging.
 481 }
 482 
 483 void oopDesc::ps_push_contents(PSPromotionManager* pm) {
 484   Klass* k = klass();
 485   if (!k->is_typeArray_klass()) {
 486     // It might contain oops beyond the header, so take the virtual call.
 487     k->oop_ps_push_contents(this, pm);
 488   }
 489   // Else skip it.  The TypeArrayKlass in the header never needs scavenging.
 490 }
 491 #endif // INCLUDE_ALL_GCS
 492 
 493 #define OOP_ITERATE_DEFN(OopClosureType, nv_suffix)                 \
 494                                                                     \
 495 void oopDesc::oop_iterate(OopClosureType* blk) {                    \
 496   klass()->oop_oop_iterate##nv_suffix(this, blk);                   \
 497 }                                                                   \
 498                                                                     \
 499 void oopDesc::oop_iterate(OopClosureType* blk, MemRegion mr) {      \
 500   klass()->oop_oop_iterate_bounded##nv_suffix(this, blk, mr);       \
 501 }
 502 
 503 #define OOP_ITERATE_SIZE_DEFN(OopClosureType, nv_suffix)            \
 504                                                                     \
 505 int oopDesc::oop_iterate_size(OopClosureType* blk) {                \
 506   Klass* k = klass();                                               \
 507   int size = size_given_klass(k);                                   \
 508   k->oop_oop_iterate##nv_suffix(this, blk);                         \
 509   return size;                                                      \
 510 }                                                                   \
 511                                                                     \
 512 int oopDesc::oop_iterate_size(OopClosureType* blk, MemRegion mr) {  \
 513   Klass* k = klass();                                               \
 514   int size = size_given_klass(k);                                   \
 515   k->oop_oop_iterate_bounded##nv_suffix(this, blk, mr);             \
 516   return size;                                                      \
 517 }
 518 
 519 int oopDesc::oop_iterate_no_header(OopClosure* blk) {
 520   // The NoHeaderExtendedOopClosure wraps the OopClosure and proxies all
 521   // the do_oop calls, but turns off all other features in ExtendedOopClosure.
 522   NoHeaderExtendedOopClosure cl(blk);
 523   return oop_iterate_size(&cl);
 524 }
 525 
 526 int oopDesc::oop_iterate_no_header(OopClosure* blk, MemRegion mr) {
 527   NoHeaderExtendedOopClosure cl(blk);
 528   return oop_iterate_size(&cl, mr);
 529 }
 530 
 531 #if INCLUDE_ALL_GCS
 532 #define OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)       \
 533                                                                     \
 534 inline void oopDesc::oop_iterate_backwards(OopClosureType* blk) {   \
 535   klass()->oop_oop_iterate_backwards##nv_suffix(this, blk);         \
 536 }
 537 #else
 538 #define OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)
 539 #endif // INCLUDE_ALL_GCS
 540 
 541 #define ALL_OOPDESC_OOP_ITERATE(OopClosureType, nv_suffix)  \
 542   OOP_ITERATE_DEFN(OopClosureType, nv_suffix)               \
 543   OOP_ITERATE_SIZE_DEFN(OopClosureType, nv_suffix)          \
 544   OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix)
 545 
 546 ALL_OOP_OOP_ITERATE_CLOSURES_1(ALL_OOPDESC_OOP_ITERATE)
 547 ALL_OOP_OOP_ITERATE_CLOSURES_2(ALL_OOPDESC_OOP_ITERATE)
 548 
 549 intptr_t oopDesc::identity_hash() {
 550   // Fast case; if the object is unlocked and the hash value is set, no locking is needed
 551   // Note: The mark must be read into local variable to avoid concurrent updates.
 552   markOop mrk = mark();
 553   if (mrk->is_unlocked() && !mrk->has_no_hash()) {
 554     return mrk->hash();
 555   } else if (mrk->is_marked()) {
 556     return mrk->hash();
 557   } else {
 558     return slow_identity_hash();
 559   }
 560 }
 561 
 562 bool oopDesc::has_displaced_mark() const {
 563   return mark()->has_displaced_mark_helper();
 564 }
 565 
 566 markOop oopDesc::displaced_mark() const {
 567   return mark()->displaced_mark_helper();
 568 }
 569 
 570 void oopDesc::set_displaced_mark(markOop m) {
 571   mark()->set_displaced_mark_helper(m);
 572 }
 573 
 574 #endif // SHARE_VM_OOPS_OOP_INLINE_HPP