8252035: G1: Clean up G1CollectedHeap::*reserved* methods
Reviewed-by: sjohanss, iwalulya
This commit is contained in:
parent
75a69333f8
commit
f9e6f26ca4
@ -130,9 +130,7 @@ inline void G1ArchiveAllocator::enable_archive_object_check() {
|
||||
}
|
||||
|
||||
_archive_check_enabled = true;
|
||||
size_t length = G1CollectedHeap::heap()->max_reserved_capacity();
|
||||
_archive_region_map.initialize(G1CollectedHeap::heap()->base(),
|
||||
G1CollectedHeap::heap()->base() + length,
|
||||
_archive_region_map.initialize(G1CollectedHeap::heap()->reserved(),
|
||||
HeapRegion::GrainBytes);
|
||||
}
|
||||
|
||||
|
@ -192,10 +192,9 @@ protected:
|
||||
public:
|
||||
G1BiasedMappedArray() {}
|
||||
|
||||
// Allocate and initialize this array to cover the heap addresses in the range
|
||||
// of [bottom, end).
|
||||
void initialize(HeapWord* bottom, HeapWord* end, size_t mapping_granularity) {
|
||||
G1BiasedMappedArrayBase::initialize(bottom, end, sizeof(T), mapping_granularity);
|
||||
// Allocate and initialize this array to cover the heap addresses in the given MemRegion.
|
||||
void initialize(MemRegion region, size_t mapping_granularity) {
|
||||
G1BiasedMappedArrayBase::initialize(region.start(), region.end(), sizeof(T), mapping_granularity);
|
||||
this->clear();
|
||||
}
|
||||
};
|
||||
|
@ -63,7 +63,7 @@ G1CardCounts::G1CardCounts(G1CollectedHeap *g1h):
|
||||
}
|
||||
|
||||
void G1CardCounts::initialize(G1RegionToSpaceMapper* mapper) {
|
||||
assert(_g1h->max_reserved_capacity() > 0, "initialization order");
|
||||
assert(_g1h->reserved().byte_size() > 0, "initialization order");
|
||||
assert(_g1h->capacity() == 0, "initialization order");
|
||||
|
||||
if (G1ConcRSHotCardLimit > 0) {
|
||||
@ -73,7 +73,7 @@ void G1CardCounts::initialize(G1RegionToSpaceMapper* mapper) {
|
||||
guarantee(G1ConcRSHotCardLimit <= max_jubyte, "sanity");
|
||||
|
||||
_ct = _g1h->card_table();
|
||||
_ct_bot = _ct->byte_for_const(_g1h->reserved_region().start());
|
||||
_ct_bot = _ct->byte_for_const(_g1h->reserved().start());
|
||||
|
||||
_card_counts = (jubyte*) mapper->reserved().start();
|
||||
_reserved_max_card_num = mapper->reserved().byte_size();
|
||||
|
@ -1684,7 +1684,7 @@ jint G1CollectedHeap::initialize() {
|
||||
guarantee(heap_rs.base() >= (char*)G1CardTable::card_size, "Java heap must not start within the first card.");
|
||||
// Also create a G1 rem set.
|
||||
_rem_set = new G1RemSet(this, _card_table, _hot_card_cache);
|
||||
_rem_set->initialize(max_reserved_capacity(), max_regions());
|
||||
_rem_set->initialize(max_regions());
|
||||
|
||||
size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
|
||||
guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
|
||||
@ -1693,15 +1693,13 @@ jint G1CollectedHeap::initialize() {
|
||||
|
||||
FreeRegionList::set_unrealistically_long_length(max_expandable_regions() + 1);
|
||||
|
||||
_bot = new G1BlockOffsetTable(reserved_region(), bot_storage);
|
||||
_bot = new G1BlockOffsetTable(reserved(), bot_storage);
|
||||
|
||||
{
|
||||
HeapWord* start = _hrm->reserved().start();
|
||||
HeapWord* end = _hrm->reserved().end();
|
||||
size_t granularity = HeapRegion::GrainBytes;
|
||||
|
||||
_region_attr.initialize(start, end, granularity);
|
||||
_humongous_reclaim_candidates.initialize(start, end, granularity);
|
||||
_region_attr.initialize(reserved(), granularity);
|
||||
_humongous_reclaim_candidates.initialize(reserved(), granularity);
|
||||
}
|
||||
|
||||
_workers = new WorkGang("GC Thread", ParallelGCThreads,
|
||||
@ -2274,7 +2272,7 @@ bool G1CollectedHeap::is_in(const void* p) const {
|
||||
|
||||
#ifdef ASSERT
|
||||
bool G1CollectedHeap::is_in_exact(const void* p) const {
|
||||
bool contains = reserved_region().contains(p);
|
||||
bool contains = reserved().contains(p);
|
||||
bool available = _hrm->is_available(addr_to_region((HeapWord*)p));
|
||||
if (contains && available) {
|
||||
return true;
|
||||
@ -2396,10 +2394,6 @@ size_t G1CollectedHeap::max_capacity() const {
|
||||
return _hrm->max_expandable_length() * HeapRegion::GrainBytes;
|
||||
}
|
||||
|
||||
size_t G1CollectedHeap::max_reserved_capacity() const {
|
||||
return _hrm->max_length() * HeapRegion::GrainBytes;
|
||||
}
|
||||
|
||||
void G1CollectedHeap::deduplicate_string(oop str) {
|
||||
assert(java_lang_String::is_instance(str), "invariant");
|
||||
|
||||
|
@ -1141,16 +1141,12 @@ public:
|
||||
inline G1HeapRegionAttr region_attr(const void* obj) const;
|
||||
inline G1HeapRegionAttr region_attr(uint idx) const;
|
||||
|
||||
MemRegion reserved_region() const {
|
||||
return _reserved;
|
||||
}
|
||||
|
||||
HeapWord* base() const {
|
||||
return _reserved.start();
|
||||
MemRegion reserved() const {
|
||||
return _hrm->reserved();
|
||||
}
|
||||
|
||||
bool is_in_reserved(const void* addr) const {
|
||||
return _reserved.contains(addr);
|
||||
return reserved().contains(addr);
|
||||
}
|
||||
|
||||
G1HotCardCache* hot_card_cache() const { return _hot_card_cache; }
|
||||
@ -1282,9 +1278,6 @@ public:
|
||||
// Print the maximum heap capacity.
|
||||
virtual size_t max_capacity() const;
|
||||
|
||||
// Return the size of reserved memory. Returns different value than max_capacity() when AllocateOldGenAt is used.
|
||||
virtual size_t max_reserved_capacity() const;
|
||||
|
||||
Tickspan time_since_last_collection() const { return Ticks::now() - _collection_pause_end; }
|
||||
|
||||
// Convenience function to be used in situations where the heap type can be
|
||||
|
@ -76,8 +76,8 @@ inline HeapRegion* G1CollectedHeap::next_region_in_humongous(HeapRegion* hr) con
|
||||
inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
|
||||
assert(is_in_reserved(addr),
|
||||
"Cannot calculate region index for address " PTR_FORMAT " that is outside of the heap [" PTR_FORMAT ", " PTR_FORMAT ")",
|
||||
p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end()));
|
||||
return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
|
||||
p2i(addr), p2i(reserved().start()), p2i(reserved().end()));
|
||||
return (uint)(pointer_delta(addr, reserved().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
|
||||
}
|
||||
|
||||
inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
|
||||
@ -89,7 +89,7 @@ inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const {
|
||||
assert(addr != NULL, "invariant");
|
||||
assert(is_in_reserved((const void*) addr),
|
||||
"Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
|
||||
p2i((void*)addr), p2i(reserved_region().start()), p2i(reserved_region().end()));
|
||||
p2i((void*)addr), p2i(reserved().start()), p2i(reserved().end()));
|
||||
return _hrm->addr_to_region((HeapWord*)(void*) addr);
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ inline HeapRegion* G1CollectedHeap::heap_region_containing_or_null(const T addr)
|
||||
assert(addr != NULL, "invariant");
|
||||
assert(is_in_reserved((const void*) addr),
|
||||
"Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
|
||||
p2i((void*)addr), p2i(reserved_region().start()), p2i(reserved_region().end()));
|
||||
p2i((void*)addr), p2i(reserved().start()), p2i(reserved().end()));
|
||||
uint const region_idx = addr_to_region(addr);
|
||||
return region_at_or_null(region_idx);
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ G1ConcurrentMark::G1ConcurrentMark(G1CollectedHeap* g1h,
|
||||
_prev_mark_bitmap(&_mark_bitmap_1),
|
||||
_next_mark_bitmap(&_mark_bitmap_2),
|
||||
|
||||
_heap(_g1h->reserved_region()),
|
||||
_heap(_g1h->reserved()),
|
||||
|
||||
_root_regions(_g1h->max_regions()),
|
||||
|
||||
@ -410,8 +410,8 @@ G1ConcurrentMark::G1ConcurrentMark(G1CollectedHeap* g1h,
|
||||
{
|
||||
assert(CGC_lock != NULL, "CGC_lock must be initialized");
|
||||
|
||||
_mark_bitmap_1.initialize(g1h->reserved_region(), prev_bitmap_storage);
|
||||
_mark_bitmap_2.initialize(g1h->reserved_region(), next_bitmap_storage);
|
||||
_mark_bitmap_1.initialize(g1h->reserved(), prev_bitmap_storage);
|
||||
_mark_bitmap_2.initialize(g1h->reserved(), next_bitmap_storage);
|
||||
|
||||
// Create & start ConcurrentMark thread.
|
||||
_cm_thread = new G1ConcurrentMarkThread(this);
|
||||
@ -2893,7 +2893,7 @@ G1PrintRegionLivenessInfoClosure::G1PrintRegionLivenessInfoClosure(const char* p
|
||||
}
|
||||
|
||||
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||
MemRegion reserved = g1h->reserved_region();
|
||||
MemRegion reserved = g1h->reserved();
|
||||
double now = os::elapsedTime();
|
||||
|
||||
// Print the header of the output.
|
||||
|
@ -485,7 +485,7 @@ uint G1RemSet::num_par_rem_sets() {
|
||||
return G1DirtyCardQueueSet::num_par_ids() + G1ConcurrentRefine::max_num_threads() + MAX2(ConcGCThreads, ParallelGCThreads);
|
||||
}
|
||||
|
||||
void G1RemSet::initialize(size_t capacity, uint max_regions) {
|
||||
void G1RemSet::initialize(uint max_regions) {
|
||||
G1FromCardCache::initialize(num_par_rem_sets(), max_regions);
|
||||
_scan_state->initialize(max_regions);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
static uint num_par_rem_sets();
|
||||
|
||||
// Initialize data that depends on the heap size being known.
|
||||
void initialize(size_t capacity, uint max_regions);
|
||||
void initialize(uint max_regions);
|
||||
|
||||
G1RemSet(G1CollectedHeap* g1h,
|
||||
G1CardTable* ct,
|
||||
|
@ -102,8 +102,7 @@ void HeapRegionManager::initialize(G1RegionToSpaceMapper* heap_storage,
|
||||
|
||||
_card_counts_mapper = card_counts;
|
||||
|
||||
MemRegion reserved = heap_storage->reserved();
|
||||
_regions.initialize(reserved.start(), reserved.end(), HeapRegion::GrainBytes);
|
||||
_regions.initialize(heap_storage->reserved(), HeapRegion::GrainBytes);
|
||||
|
||||
_available_map.initialize(_regions.length());
|
||||
}
|
||||
|
@ -503,11 +503,12 @@ WB_ENTRY(jlong, WB_DramReservedStart(JNIEnv* env, jobject o))
|
||||
#if INCLUDE_G1GC
|
||||
if (UseG1GC) {
|
||||
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||
HeapWord* base = g1h->reserved().start();
|
||||
if (g1h->is_heterogeneous_heap()) {
|
||||
uint start_region = HeterogeneousHeapRegionManager::manager()->start_index_of_dram();
|
||||
return (jlong)(g1h->base() + start_region * HeapRegion::GrainBytes);
|
||||
return (jlong)(base + start_region * HeapRegion::GrainBytes);
|
||||
} else {
|
||||
return (jlong)g1h->base();
|
||||
return (jlong)base;
|
||||
}
|
||||
}
|
||||
#endif // INCLUDE_G1GC
|
||||
@ -529,11 +530,12 @@ WB_ENTRY(jlong, WB_DramReservedEnd(JNIEnv* env, jobject o))
|
||||
#if INCLUDE_G1GC
|
||||
if (UseG1GC) {
|
||||
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||
HeapWord* base = g1h->reserved().start();
|
||||
if (g1h->is_heterogeneous_heap()) {
|
||||
uint end_region = HeterogeneousHeapRegionManager::manager()->end_index_of_dram();
|
||||
return (jlong)(g1h->base() + (end_region + 1) * HeapRegion::GrainBytes - 1);
|
||||
return (jlong)(base + (end_region + 1) * HeapRegion::GrainBytes - 1);
|
||||
} else {
|
||||
return (jlong)g1h->base() + G1Arguments::heap_max_size_bytes();
|
||||
return (jlong)base + G1Arguments::heap_max_size_bytes();
|
||||
}
|
||||
}
|
||||
#endif // INCLUDE_G1GC
|
||||
@ -557,7 +559,7 @@ WB_ENTRY(jlong, WB_NvdimmReservedStart(JNIEnv* env, jobject o))
|
||||
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||
if (g1h->is_heterogeneous_heap()) {
|
||||
uint start_region = HeterogeneousHeapRegionManager::manager()->start_index_of_nvdimm();
|
||||
return (jlong)(g1h->base() + start_region * HeapRegion::GrainBytes);
|
||||
return (jlong)(g1h->reserved().start() + start_region * HeapRegion::GrainBytes);
|
||||
} else {
|
||||
THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_NvdimmReservedStart: Old gen is not allocated on NV-DIMM using AllocateOldGenAt flag");
|
||||
}
|
||||
@ -583,7 +585,7 @@ WB_ENTRY(jlong, WB_NvdimmReservedEnd(JNIEnv* env, jobject o))
|
||||
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||
if (g1h->is_heterogeneous_heap()) {
|
||||
uint end_region = HeterogeneousHeapRegionManager::manager()->start_index_of_nvdimm();
|
||||
return (jlong)(g1h->base() + (end_region + 1) * HeapRegion::GrainBytes - 1);
|
||||
return (jlong)(g1h->reserved().start() + (end_region + 1) * HeapRegion::GrainBytes - 1);
|
||||
} else {
|
||||
THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_NvdimmReservedEnd: Old gen is not allocated on NV-DIMM using AllocateOldGenAt flag");
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ TEST_VM(G1BiasedArray, simple) {
|
||||
(HeapWord*) LP64_ONLY(0xBAAA00000) NOT_LP64(0xBA000000);
|
||||
|
||||
TestMappedArray array;
|
||||
array.initialize(fake_heap, fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
|
||||
REGION_SIZE_IN_WORDS * HeapWordSize);
|
||||
MemRegion range(fake_heap, fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS);
|
||||
array.initialize(range, REGION_SIZE_IN_WORDS * HeapWordSize);
|
||||
const int DEFAULT_VALUE = array.default_value();
|
||||
|
||||
// Check address calculation (bounds)
|
||||
|
Loading…
x
Reference in New Issue
Block a user