8241743: Shenandoah: refactor and inline ShenandoahHeap::heap()
Reviewed-by: rkennke
This commit is contained in:
parent
7056b96854
commit
0861f3f796
@ -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"
|
||||
|
@ -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",
|
||||
|
@ -82,6 +82,8 @@
|
||||
#include "services/mallocTracker.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
ShenandoahHeap* ShenandoahHeap::_heap = NULL;
|
||||
|
||||
#ifdef ASSERT
|
||||
template <class T>
|
||||
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;
|
||||
|
@ -132,9 +132,11 @@ public:
|
||||
|
||||
// ---------- 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; }
|
||||
|
@ -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);
|
||||
|
@ -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"
|
||||
|
@ -982,7 +982,7 @@ private:
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user