diff --git a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp index 5f61f6cccf0..2b363bf1a58 100644 --- a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp +++ b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp @@ -27,7 +27,7 @@ #include "gc/shared/satbMarkQueue.hpp" #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" -#include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahRuntime.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp b/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp index e9fb8d97cb0..b63e8da7a1b 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp @@ -169,7 +169,7 @@ void ShenandoahAsserts::print_failure(SafeLevel level, oop obj, void* interior_l } void ShenandoahAsserts::assert_in_heap(void* interior_loc, oop obj, const char *file, int line) { - ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); + ShenandoahHeap* heap = ShenandoahHeap::heap(); if (!heap->is_in(obj)) { print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_heap failed", @@ -179,7 +179,7 @@ void ShenandoahAsserts::assert_in_heap(void* interior_loc, oop obj, const char * } void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char* file, int line) { - ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); + ShenandoahHeap* heap = ShenandoahHeap::heap(); // Step 1. Check that obj is correct. // After this step, it is safe to call heap_region_containing(). @@ -247,7 +247,7 @@ void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char* void ShenandoahAsserts::assert_in_correct_region(void* interior_loc, oop obj, const char* file, int line) { assert_correct(interior_loc, obj, file, line); - ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); + ShenandoahHeap* heap = ShenandoahHeap::heap(); ShenandoahHeapRegion* r = heap->heap_region_containing(obj); if (!r->is_active()) { print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_in_correct_region failed", @@ -300,7 +300,7 @@ void ShenandoahAsserts::assert_not_forwarded(void* interior_loc, oop obj, const void ShenandoahAsserts::assert_marked(void *interior_loc, oop obj, const char *file, int line) { assert_correct(interior_loc, obj, file, line); - ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); + ShenandoahHeap* heap = ShenandoahHeap::heap(); if (!heap->marking_context()->is_marked(obj)) { print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked failed", "Object should be marked", @@ -311,7 +311,7 @@ void ShenandoahAsserts::assert_marked(void *interior_loc, oop obj, const char *f void ShenandoahAsserts::assert_in_cset(void* interior_loc, oop obj, const char* file, int line) { assert_correct(interior_loc, obj, file, line); - ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); + ShenandoahHeap* heap = ShenandoahHeap::heap(); if (!heap->in_collection_set(obj)) { print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_in_cset failed", "Object should be in collection set", @@ -322,7 +322,7 @@ void ShenandoahAsserts::assert_in_cset(void* interior_loc, oop obj, const char* void ShenandoahAsserts::assert_not_in_cset(void* interior_loc, oop obj, const char* file, int line) { assert_correct(interior_loc, obj, file, line); - ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); + ShenandoahHeap* heap = ShenandoahHeap::heap(); if (heap->in_collection_set(obj)) { print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_not_in_cset failed", "Object should not be in collection set", @@ -331,7 +331,7 @@ void ShenandoahAsserts::assert_not_in_cset(void* interior_loc, oop obj, const ch } void ShenandoahAsserts::assert_not_in_cset_loc(void* interior_loc, const char* file, int line) { - ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); + ShenandoahHeap* heap = ShenandoahHeap::heap(); if (heap->in_collection_set_loc(interior_loc)) { print_failure(_safe_unknown, NULL, interior_loc, NULL, "Shenandoah assert_not_in_cset_loc failed", "Interior location should not be in collection set", diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 9e27fa56560..8c7fb2db9f1 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -82,6 +82,8 @@ #include "services/mallocTracker.hpp" #include "utilities/powerOfTwo.hpp" +ShenandoahHeap* ShenandoahHeap::_heap = NULL; + #ifdef ASSERT template void ShenandoahAssertToSpaceClosure::do_oop_work(T* p) { @@ -461,6 +463,8 @@ ShenandoahHeap::ShenandoahHeap(ShenandoahCollectorPolicy* policy) : _liveness_cache(NULL), _collection_set(NULL) { + _heap = this; + log_info(gc, init)("GC threads: " UINT32_FORMAT " parallel, " UINT32_FORMAT " concurrent", ParallelGCThreads, ConcGCThreads); log_info(gc, init)("Reference processing: %s", ParallelRefProcEnabled ? "parallel" : "serial"); @@ -777,18 +781,6 @@ HeapWord* ShenandoahHeap::allocate_new_gclab(size_t min_size, return res; } -ShenandoahHeap* ShenandoahHeap::heap() { - CollectedHeap* heap = Universe::heap(); - assert(heap != NULL, "Unitialized access to ShenandoahHeap::heap()"); - assert(heap->kind() == CollectedHeap::Shenandoah, "not a shenandoah heap"); - return (ShenandoahHeap*) heap; -} - -ShenandoahHeap* ShenandoahHeap::heap_no_check() { - CollectedHeap* heap = Universe::heap(); - return (ShenandoahHeap*) heap; -} - HeapWord* ShenandoahHeap::allocate_memory(ShenandoahAllocRequest& req) { intptr_t pacer_epoch = 0; bool in_new_region = false; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp index 8cd853e0a5a..5072d99c938 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp @@ -132,9 +132,11 @@ class ShenandoahHeap : public CollectedHeap { // ---------- Initialization, termination, identification, printing routines // +private: + static ShenandoahHeap* _heap; + public: static ShenandoahHeap* heap(); - static ShenandoahHeap* heap_no_check(); const char* name() const { return "Shenandoah"; } ShenandoahHeap::Name kind() const { return CollectedHeap::Shenandoah; } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp index 03a67fb9195..a857d006f80 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp @@ -48,6 +48,10 @@ #include "utilities/copy.hpp" #include "utilities/globalDefinitions.hpp" +inline ShenandoahHeap* ShenandoahHeap::heap() { + assert(_heap != NULL, "Heap is not initialized yet"); + return _heap; +} inline ShenandoahHeapRegion* ShenandoahRegionIterator::next() { size_t new_index = Atomic::add(&_index, (size_t) 1); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp index 14f673ebde8..8d290817132 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp @@ -27,7 +27,7 @@ #include "gc/shared/generationCounters.hpp" #include "gc/shared/hSpaceCounters.hpp" #include "gc/shenandoah/shenandoahMonitoringSupport.hpp" -#include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegionCounters.hpp" #include "memory/metaspaceCounters.hpp" #include "services/memoryService.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp index b52e83505b4..188bf4852a8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp @@ -982,7 +982,7 @@ class ShenandoahVerifyInToSpaceClosure : public OopClosure { T o = RawAccess<>::oop_load(p); if (!CompressedOops::is_null(o)) { oop obj = CompressedOops::decode_not_null(o); - ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); + ShenandoahHeap* heap = ShenandoahHeap::heap(); if (!heap->marking_context()->is_marked(obj)) { ShenandoahAsserts::print_failure(ShenandoahAsserts::_safe_all, obj, p, NULL,