1 /*
   2  * Copyright (c) 2015, 2020, Red Hat, Inc. 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_GC_SHENANDOAH_SHENANDOAHHEAP_INLINE_HPP
  26 #define SHARE_GC_SHENANDOAH_SHENANDOAHHEAP_INLINE_HPP
  27 
  28 #include "classfile/javaClasses.inline.hpp"
  29 #include "gc/shared/markBitMap.inline.hpp"
  30 #include "gc/shared/threadLocalAllocBuffer.inline.hpp"
  31 #include "gc/shared/suspendibleThreadSet.hpp"
  32 #include "gc/shenandoah/shenandoahAsserts.hpp"
  33 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
  34 #include "gc/shenandoah/shenandoahCollectionSet.inline.hpp"
  35 #include "gc/shenandoah/shenandoahForwarding.inline.hpp"
  36 #include "gc/shenandoah/shenandoahWorkGroup.hpp"
  37 #include "gc/shenandoah/shenandoahHeap.hpp"
  38 #include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp"
  39 #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
  40 #include "gc/shenandoah/shenandoahControlThread.hpp"
  41 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
  42 #include "gc/shenandoah/shenandoahThreadLocalData.hpp"
  43 #include "oops/compressedOops.inline.hpp"
  44 #include "oops/oop.inline.hpp"
  45 #include "runtime/atomic.hpp"
  46 #include "runtime/prefetch.inline.hpp"
  47 #include "runtime/thread.hpp"
  48 #include "utilities/copy.hpp"
  49 #include "utilities/globalDefinitions.hpp"
  50 
  51 inline ShenandoahHeap* ShenandoahHeap::heap() {
  52   return named_heap<ShenandoahHeap>(CollectedHeap::Shenandoah);
  53 }
  54 
  55 inline ShenandoahHeapRegion* ShenandoahRegionIterator::next() {
  56   size_t new_index = Atomic::add(&_index, (size_t) 1);
  57   // get_region() provides the bounds-check and returns NULL on OOB.
  58   return _heap->get_region(new_index - 1);
  59 }
  60 
  61 inline bool ShenandoahHeap::has_forwarded_objects() const {
  62   return _gc_state.is_set(HAS_FORWARDED);
  63 }
  64 
  65 inline WorkGang* ShenandoahHeap::workers() const {
  66   return _workers;
  67 }
  68 
  69 inline WorkGang* ShenandoahHeap::safepoint_workers() {
  70   return _safepoint_workers;
  71 }
  72 
  73 inline size_t ShenandoahHeap::heap_region_index_containing(const void* addr) const {
  74   uintptr_t region_start = ((uintptr_t) addr);
  75   uintptr_t index = (region_start - (uintptr_t) base()) >> ShenandoahHeapRegion::region_size_bytes_shift();
  76   assert(index < num_regions(), "Region index is in bounds: " PTR_FORMAT, p2i(addr));
  77   return index;
  78 }
  79 
  80 inline ShenandoahHeapRegion* const ShenandoahHeap::heap_region_containing(const void* addr) const {
  81   size_t index = heap_region_index_containing(addr);
  82   ShenandoahHeapRegion* const result = get_region(index);
  83   assert(addr >= result->bottom() && addr < result->end(), "Heap region contains the address: " PTR_FORMAT, p2i(addr));
  84   return result;
  85 }
  86 
  87 inline void ShenandoahHeap::enter_evacuation(Thread* t) {
  88   _oom_evac_handler.enter_evacuation(t);
  89 }
  90 
  91 inline void ShenandoahHeap::leave_evacuation(Thread* t) {
  92   _oom_evac_handler.leave_evacuation(t);
  93 }
  94 
  95 template <class T>
  96 inline oop ShenandoahHeap::update_with_forwarded_not_null(T* p, oop obj) {
  97   if (in_collection_set(obj)) {
  98     shenandoah_assert_forwarded_except(p, obj, is_full_gc_in_progress() || cancelled_gc() || is_degenerated_gc_in_progress());
  99     obj = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
 100     RawAccess<IS_NOT_NULL>::oop_store(p, obj);
 101   }
 102 #ifdef ASSERT
 103   else {
 104     shenandoah_assert_not_forwarded(p, obj);
 105   }
 106 #endif
 107   return obj;
 108 }
 109 
 110 template <class T>
 111 inline oop ShenandoahHeap::maybe_update_with_forwarded(T* p) {
 112   T o = RawAccess<>::oop_load(p);
 113   if (!CompressedOops::is_null(o)) {
 114     oop obj = CompressedOops::decode_not_null(o);
 115     return maybe_update_with_forwarded_not_null(p, obj);
 116   } else {
 117     return NULL;
 118   }
 119 }
 120 
 121 template <class T>
 122 inline oop ShenandoahHeap::evac_update_with_forwarded(T* p) {
 123   T o = RawAccess<>::oop_load(p);
 124   if (!CompressedOops::is_null(o)) {
 125     oop heap_oop = CompressedOops::decode_not_null(o);
 126     if (in_collection_set(heap_oop)) {
 127       oop forwarded_oop = ShenandoahBarrierSet::resolve_forwarded_not_null(heap_oop);
 128       if (forwarded_oop == heap_oop) {
 129         forwarded_oop = evacuate_object(heap_oop, Thread::current());
 130       }
 131       oop prev = cas_oop(forwarded_oop, p, heap_oop);
 132       if (prev == heap_oop) {
 133         return forwarded_oop;
 134       } else {
 135         return NULL;
 136       }
 137     }
 138     return heap_oop;
 139   } else {
 140     return NULL;
 141   }
 142 }
 143 
 144 inline oop ShenandoahHeap::cas_oop(oop n, oop* addr, oop c) {
 145   assert(is_aligned(addr, HeapWordSize), "Address should be aligned: " PTR_FORMAT, p2i(addr));
 146   return (oop) Atomic::cmpxchg(addr, c, n);
 147 }
 148 
 149 inline oop ShenandoahHeap::cas_oop(oop n, narrowOop* addr, narrowOop c) {
 150   assert(is_aligned(addr, sizeof(narrowOop)), "Address should be aligned: " PTR_FORMAT, p2i(addr));
 151   narrowOop val = CompressedOops::encode(n);
 152   return CompressedOops::decode((narrowOop) Atomic::cmpxchg(addr, c, val));
 153 }
 154 
 155 inline oop ShenandoahHeap::cas_oop(oop n, narrowOop* addr, oop c) {
 156   assert(is_aligned(addr, sizeof(narrowOop)), "Address should be aligned: " PTR_FORMAT, p2i(addr));
 157   narrowOop cmp = CompressedOops::encode(c);
 158   narrowOop val = CompressedOops::encode(n);
 159   return CompressedOops::decode((narrowOop) Atomic::cmpxchg(addr, cmp, val));
 160 }
 161 
 162 template <class T>
 163 inline oop ShenandoahHeap::maybe_update_with_forwarded_not_null(T* p, oop heap_oop) {
 164   shenandoah_assert_not_in_cset_loc_except(p, !is_in(p) || is_full_gc_in_progress() || is_degenerated_gc_in_progress());
 165   shenandoah_assert_correct(p, heap_oop);
 166 
 167   if (in_collection_set(heap_oop)) {
 168     oop forwarded_oop = ShenandoahBarrierSet::resolve_forwarded_not_null(heap_oop);
 169     if (forwarded_oop == heap_oop) {
 170       // E.g. during evacuation.
 171       return forwarded_oop;
 172     }
 173 
 174     shenandoah_assert_forwarded_except(p, heap_oop, is_full_gc_in_progress() || is_degenerated_gc_in_progress());
 175     shenandoah_assert_not_forwarded(p, forwarded_oop);
 176     shenandoah_assert_not_in_cset_except(p, forwarded_oop, cancelled_gc());
 177 
 178     // If this fails, another thread wrote to p before us, it will be logged in SATB and the
 179     // reference be updated later.
 180     oop witness = cas_oop(forwarded_oop, p, heap_oop);
 181 
 182     if (witness != heap_oop) {
 183       // CAS failed, someone had beat us to it. Normally, we would return the failure witness,
 184       // because that would be the proper write of to-space object, enforced by strong barriers.
 185       // However, there is a corner case with arraycopy. It can happen that a Java thread
 186       // beats us with an arraycopy, which first copies the array, which potentially contains
 187       // from-space refs, and only afterwards updates all from-space refs to to-space refs,
 188       // which leaves a short window where the new array elements can be from-space.
 189       // In this case, we can just resolve the result again. As we resolve, we need to consider
 190       // the contended write might have been NULL.
 191       oop result = ShenandoahBarrierSet::resolve_forwarded(witness);
 192       shenandoah_assert_not_forwarded_except(p, result, (result == NULL));
 193       shenandoah_assert_not_in_cset_except(p, result, (result == NULL) || cancelled_gc());
 194       return result;
 195     } else {
 196       // Success! We have updated with known to-space copy. We have already asserted it is sane.
 197       return forwarded_oop;
 198     }
 199   } else {
 200     shenandoah_assert_not_forwarded(p, heap_oop);
 201     return heap_oop;
 202   }
 203 }
 204 
 205 inline bool ShenandoahHeap::cancelled_gc() const {
 206   return _cancelled_gc.get() == CANCELLED;
 207 }
 208 
 209 inline bool ShenandoahHeap::check_cancelled_gc_and_yield(bool sts_active) {
 210   if (! (sts_active && ShenandoahSuspendibleWorkers)) {
 211     return cancelled_gc();
 212   }
 213 
 214   jbyte prev = _cancelled_gc.cmpxchg(NOT_CANCELLED, CANCELLABLE);
 215   if (prev == CANCELLABLE || prev == NOT_CANCELLED) {
 216     if (SuspendibleThreadSet::should_yield()) {
 217       SuspendibleThreadSet::yield();
 218     }
 219 
 220     // Back to CANCELLABLE. The thread that poked NOT_CANCELLED first gets
 221     // to restore to CANCELLABLE.
 222     if (prev == CANCELLABLE) {
 223       _cancelled_gc.set(CANCELLABLE);
 224     }
 225     return false;
 226   } else {
 227     return true;
 228   }
 229 }
 230 
 231 inline void ShenandoahHeap::clear_cancelled_gc() {
 232   _cancelled_gc.set(CANCELLABLE);
 233   _oom_evac_handler.clear();
 234 }
 235 
 236 inline HeapWord* ShenandoahHeap::allocate_from_gclab(Thread* thread, size_t size) {
 237   assert(UseTLAB, "TLABs should be enabled");
 238 
 239   PLAB* gclab = ShenandoahThreadLocalData::gclab(thread);
 240   if (gclab == NULL) {
 241     assert(!thread->is_Java_thread() && !thread->is_Worker_thread(),
 242            "Performance: thread should have GCLAB: %s", thread->name());
 243     // No GCLABs in this thread, fallback to shared allocation
 244     return NULL;
 245   }
 246   HeapWord* obj = gclab->allocate(size);
 247   if (obj != NULL) {
 248     return obj;
 249   }
 250   // Otherwise...
 251   return allocate_from_gclab_slow(thread, size);
 252 }
 253 
 254 inline oop ShenandoahHeap::evacuate_object(oop p, Thread* thread) {
 255   if (ShenandoahThreadLocalData::is_oom_during_evac(Thread::current())) {
 256     // This thread went through the OOM during evac protocol and it is safe to return
 257     // the forward pointer. It must not attempt to evacuate any more.
 258     return ShenandoahBarrierSet::resolve_forwarded(p);
 259   }
 260 
 261   assert(ShenandoahThreadLocalData::is_evac_allowed(thread), "must be enclosed in oom-evac scope");
 262 
 263   size_t size = p->size();
 264 
 265   assert(!heap_region_containing(p)->is_humongous(), "never evacuate humongous objects");
 266 
 267   bool alloc_from_gclab = true;
 268   HeapWord* copy = NULL;
 269 
 270 #ifdef ASSERT
 271   if (ShenandoahOOMDuringEvacALot &&
 272       (os::random() & 1) == 0) { // Simulate OOM every ~2nd slow-path call
 273         copy = NULL;
 274   } else {
 275 #endif
 276     if (UseTLAB) {
 277       copy = allocate_from_gclab(thread, size);
 278     }
 279     if (copy == NULL) {
 280       ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc(size);
 281       copy = allocate_memory(req);
 282       alloc_from_gclab = false;
 283     }
 284 #ifdef ASSERT
 285   }
 286 #endif
 287 
 288   if (copy == NULL) {
 289     control_thread()->handle_alloc_failure_evac(size);
 290 
 291     _oom_evac_handler.handle_out_of_memory_during_evacuation();
 292 
 293     return ShenandoahBarrierSet::resolve_forwarded(p);
 294   }
 295 
 296   // Copy the object:
 297   Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(p), copy, size);
 298 
 299   // Try to install the new forwarding pointer.
 300   oop copy_val = oop(copy);
 301   oop result = ShenandoahForwarding::try_update_forwardee(p, copy_val);
 302   if (result == copy_val) {
 303     // Successfully evacuated. Our copy is now the public one!
 304     shenandoah_assert_correct(NULL, copy_val);
 305     return copy_val;
 306   }  else {
 307     // Failed to evacuate. We need to deal with the object that is left behind. Since this
 308     // new allocation is certainly after TAMS, it will be considered live in the next cycle.
 309     // But if it happens to contain references to evacuated regions, those references would
 310     // not get updated for this stale copy during this cycle, and we will crash while scanning
 311     // it the next cycle.
 312     //
 313     // For GCLAB allocations, it is enough to rollback the allocation ptr. Either the next
 314     // object will overwrite this stale copy, or the filler object on LAB retirement will
 315     // do this. For non-GCLAB allocations, we have no way to retract the allocation, and
 316     // have to explicitly overwrite the copy with the filler object. With that overwrite,
 317     // we have to keep the fwdptr initialized and pointing to our (stale) copy.
 318     if (alloc_from_gclab) {
 319       ShenandoahThreadLocalData::gclab(thread)->undo_allocation(copy, size);
 320     } else {
 321       fill_with_object(copy, size);
 322       shenandoah_assert_correct(NULL, copy_val);
 323     }
 324     shenandoah_assert_correct(NULL, result);
 325     return result;
 326   }
 327 }
 328 
 329 inline bool ShenandoahHeap::requires_marking(const void* entry) const {
 330   oop obj = oop(entry);
 331   return !_marking_context->is_marked(obj);
 332 }
 333 
 334 inline bool ShenandoahHeap::in_collection_set(oop p) const {
 335   assert(collection_set() != NULL, "Sanity");
 336   return collection_set()->is_in(p);
 337 }
 338 
 339 inline bool ShenandoahHeap::in_collection_set_loc(void* p) const {
 340   assert(collection_set() != NULL, "Sanity");
 341   return collection_set()->is_in_loc(p);
 342 }
 343 
 344 inline bool ShenandoahHeap::is_stable() const {
 345   return _gc_state.is_clear();
 346 }
 347 
 348 inline bool ShenandoahHeap::is_idle() const {
 349   return _gc_state.is_unset(MARKING | EVACUATION | UPDATEREFS);
 350 }
 351 
 352 inline bool ShenandoahHeap::is_concurrent_mark_in_progress() const {
 353   return _gc_state.is_set(MARKING);
 354 }
 355 
 356 inline bool ShenandoahHeap::is_evacuation_in_progress() const {
 357   return _gc_state.is_set(EVACUATION);
 358 }
 359 
 360 inline bool ShenandoahHeap::is_gc_in_progress_mask(uint mask) const {
 361   return _gc_state.is_set(mask);
 362 }
 363 
 364 inline bool ShenandoahHeap::is_degenerated_gc_in_progress() const {
 365   return _degenerated_gc_in_progress.is_set();
 366 }
 367 
 368 inline bool ShenandoahHeap::is_full_gc_in_progress() const {
 369   return _full_gc_in_progress.is_set();
 370 }
 371 
 372 inline bool ShenandoahHeap::is_full_gc_move_in_progress() const {
 373   return _full_gc_move_in_progress.is_set();
 374 }
 375 
 376 inline bool ShenandoahHeap::is_update_refs_in_progress() const {
 377   return _gc_state.is_set(UPDATEREFS);
 378 }
 379 
 380 inline bool ShenandoahHeap::is_stw_gc_in_progress() const {
 381   return is_full_gc_in_progress() || is_degenerated_gc_in_progress();
 382 }
 383 
 384 inline bool ShenandoahHeap::is_concurrent_strong_root_in_progress() const {
 385   return _concurrent_strong_root_in_progress.is_set();
 386 }
 387 
 388 inline bool ShenandoahHeap::is_concurrent_weak_root_in_progress() const {
 389   return _concurrent_weak_root_in_progress.is_set();
 390 }
 391 
 392 template<class T>
 393 inline void ShenandoahHeap::marked_object_iterate(ShenandoahHeapRegion* region, T* cl) {
 394   marked_object_iterate(region, cl, region->top());
 395 }
 396 
 397 template<class T>
 398 inline void ShenandoahHeap::marked_object_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* limit) {
 399   assert(! region->is_humongous_continuation(), "no humongous continuation regions here");
 400 
 401   ShenandoahMarkingContext* const ctx = complete_marking_context();
 402   assert(ctx->is_complete(), "sanity");
 403 
 404   MarkBitMap* mark_bit_map = ctx->mark_bit_map();
 405   HeapWord* tams = ctx->top_at_mark_start(region);
 406 
 407   size_t skip_bitmap_delta = 1;
 408   HeapWord* start = region->bottom();
 409   HeapWord* end = MIN2(tams, region->end());
 410 
 411   // Step 1. Scan below the TAMS based on bitmap data.
 412   HeapWord* limit_bitmap = MIN2(limit, tams);
 413 
 414   // Try to scan the initial candidate. If the candidate is above the TAMS, it would
 415   // fail the subsequent "< limit_bitmap" checks, and fall through to Step 2.
 416   HeapWord* cb = mark_bit_map->get_next_marked_addr(start, end);
 417 
 418   intx dist = ShenandoahMarkScanPrefetch;
 419   if (dist > 0) {
 420     // Batched scan that prefetches the oop data, anticipating the access to
 421     // either header, oop field, or forwarding pointer. Not that we cannot
 422     // touch anything in oop, while it still being prefetched to get enough
 423     // time for prefetch to work. This is why we try to scan the bitmap linearly,
 424     // disregarding the object size. However, since we know forwarding pointer
 425     // preceeds the object, we can skip over it. Once we cannot trust the bitmap,
 426     // there is no point for prefetching the oop contents, as oop->size() will
 427     // touch it prematurely.
 428 
 429     // No variable-length arrays in standard C++, have enough slots to fit
 430     // the prefetch distance.
 431     static const int SLOT_COUNT = 256;
 432     guarantee(dist <= SLOT_COUNT, "adjust slot count");
 433     HeapWord* slots[SLOT_COUNT];
 434 
 435     int avail;
 436     do {
 437       avail = 0;
 438       for (int c = 0; (c < dist) && (cb < limit_bitmap); c++) {
 439         Prefetch::read(cb, oopDesc::mark_offset_in_bytes());
 440         slots[avail++] = cb;
 441         cb += skip_bitmap_delta;
 442         if (cb < limit_bitmap) {
 443           cb = mark_bit_map->get_next_marked_addr(cb, limit_bitmap);
 444         }
 445       }
 446 
 447       for (int c = 0; c < avail; c++) {
 448         assert (slots[c] < tams,  "only objects below TAMS here: "  PTR_FORMAT " (" PTR_FORMAT ")", p2i(slots[c]), p2i(tams));
 449         assert (slots[c] < limit, "only objects below limit here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(slots[c]), p2i(limit));
 450         oop obj = oop(slots[c]);
 451         assert(oopDesc::is_oop(obj), "sanity");
 452         assert(ctx->is_marked(obj), "object expected to be marked");
 453         cl->do_object(obj);
 454       }
 455     } while (avail > 0);
 456   } else {
 457     while (cb < limit_bitmap) {
 458       assert (cb < tams,  "only objects below TAMS here: "  PTR_FORMAT " (" PTR_FORMAT ")", p2i(cb), p2i(tams));
 459       assert (cb < limit, "only objects below limit here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cb), p2i(limit));
 460       oop obj = oop(cb);
 461       assert(oopDesc::is_oop(obj), "sanity");
 462       assert(ctx->is_marked(obj), "object expected to be marked");
 463       cl->do_object(obj);
 464       cb += skip_bitmap_delta;
 465       if (cb < limit_bitmap) {
 466         cb = mark_bit_map->get_next_marked_addr(cb, limit_bitmap);
 467       }
 468     }
 469   }
 470 
 471   // Step 2. Accurate size-based traversal, happens past the TAMS.
 472   // This restarts the scan at TAMS, which makes sure we traverse all objects,
 473   // regardless of what happened at Step 1.
 474   HeapWord* cs = tams;
 475   while (cs < limit) {
 476     assert (cs >= tams, "only objects past TAMS here: "   PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(tams));
 477     assert (cs < limit, "only objects below limit here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(limit));
 478     oop obj = oop(cs);
 479     assert(oopDesc::is_oop(obj), "sanity");
 480     assert(ctx->is_marked(obj), "object expected to be marked");
 481     int size = obj->size();
 482     cl->do_object(obj);
 483     cs += size;
 484   }
 485 }
 486 
 487 template <class T>
 488 class ShenandoahObjectToOopClosure : public ObjectClosure {
 489   T* _cl;
 490 public:
 491   ShenandoahObjectToOopClosure(T* cl) : _cl(cl) {}
 492 
 493   void do_object(oop obj) {
 494     obj->oop_iterate(_cl);
 495   }
 496 };
 497 
 498 template <class T>
 499 class ShenandoahObjectToOopBoundedClosure : public ObjectClosure {
 500   T* _cl;
 501   MemRegion _bounds;
 502 public:
 503   ShenandoahObjectToOopBoundedClosure(T* cl, HeapWord* bottom, HeapWord* top) :
 504     _cl(cl), _bounds(bottom, top) {}
 505 
 506   void do_object(oop obj) {
 507     obj->oop_iterate(_cl, _bounds);
 508   }
 509 };
 510 
 511 template<class T>
 512 inline void ShenandoahHeap::marked_object_oop_iterate(ShenandoahHeapRegion* region, T* cl, HeapWord* top) {
 513   if (region->is_humongous()) {
 514     HeapWord* bottom = region->bottom();
 515     if (top > bottom) {
 516       region = region->humongous_start_region();
 517       ShenandoahObjectToOopBoundedClosure<T> objs(cl, bottom, top);
 518       marked_object_iterate(region, &objs);
 519     }
 520   } else {
 521     ShenandoahObjectToOopClosure<T> objs(cl);
 522     marked_object_iterate(region, &objs, top);
 523   }
 524 }
 525 
 526 inline ShenandoahHeapRegion* const ShenandoahHeap::get_region(size_t region_idx) const {
 527   if (region_idx < _num_regions) {
 528     return _regions[region_idx];
 529   } else {
 530     return NULL;
 531   }
 532 }
 533 
 534 inline void ShenandoahHeap::mark_complete_marking_context() {
 535   _marking_context->mark_complete();
 536 }
 537 
 538 inline void ShenandoahHeap::mark_incomplete_marking_context() {
 539   _marking_context->mark_incomplete();
 540 }
 541 
 542 inline ShenandoahMarkingContext* ShenandoahHeap::complete_marking_context() const {
 543   assert (_marking_context->is_complete()," sanity");
 544   return _marking_context;
 545 }
 546 
 547 inline ShenandoahMarkingContext* ShenandoahHeap::marking_context() const {
 548   return _marking_context;
 549 }
 550 
 551 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHHEAP_INLINE_HPP