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