Skip to content
Permalink
Browse files

8241740: Shenandoah: remove ShenandoahHeapRegion::_heap

Reviewed-by: rkennke
  • Loading branch information
shipilev committed Mar 27, 2020
1 parent 0861f3f commit 92d854f5e1afc9c2f01ae7e1e3adf08024fad37d
@@ -290,7 +290,7 @@ jint ShenandoahHeap::initialize() {
for (size_t i = 0; i < _num_regions; i++) {
HeapWord* start = (HeapWord*)sh_rs.base() + ShenandoahHeapRegion::region_size_words() * i;
bool is_committed = i < num_committed_regions;
ShenandoahHeapRegion* r = new ShenandoahHeapRegion(this, start, i, is_committed);
ShenandoahHeapRegion* r = new ShenandoahHeapRegion(start, i, is_committed);

_marking_context->initialize_top_at_mark_start(r);
_regions[i] = r;
@@ -55,8 +55,7 @@ size_t ShenandoahHeapRegion::MaxTLABSizeWords = 0;

ShenandoahHeapRegion::PaddedAllocSeqNum ShenandoahHeapRegion::_alloc_seq_num;

ShenandoahHeapRegion::ShenandoahHeapRegion(ShenandoahHeap* heap, HeapWord* start, size_t index, bool committed) :
_heap(heap),
ShenandoahHeapRegion::ShenandoahHeapRegion(HeapWord* start, size_t index, bool committed) :
_region_number(index),
_bottom(start),
_end(start + RegionSizeWords),
@@ -109,7 +108,7 @@ void ShenandoahHeapRegion::make_regular_allocation() {

void ShenandoahHeapRegion::make_regular_bypass() {
shenandoah_assert_heaplocked();
assert (_heap->is_full_gc_in_progress() || _heap->is_degenerated_gc_in_progress(),
assert (ShenandoahHeap::heap()->is_full_gc_in_progress() || ShenandoahHeap::heap()->is_degenerated_gc_in_progress(),
"only for full or degen GC");

switch (_state) {
@@ -147,7 +146,7 @@ void ShenandoahHeapRegion::make_humongous_start() {

void ShenandoahHeapRegion::make_humongous_start_bypass() {
shenandoah_assert_heaplocked();
assert (_heap->is_full_gc_in_progress(), "only for full GC");
assert (ShenandoahHeap::heap()->is_full_gc_in_progress(), "only for full GC");

switch (_state) {
case _empty_committed:
@@ -176,7 +175,7 @@ void ShenandoahHeapRegion::make_humongous_cont() {

void ShenandoahHeapRegion::make_humongous_cont_bypass() {
shenandoah_assert_heaplocked();
assert (_heap->is_full_gc_in_progress(), "only for full GC");
assert (ShenandoahHeap::heap()->is_full_gc_in_progress(), "only for full GC");

switch (_state) {
case _empty_committed:
@@ -268,7 +267,7 @@ void ShenandoahHeapRegion::make_trash_immediate() {

// On this path, we know there are no marked objects in the region,
// tell marking context about it to bypass bitmap resets.
_heap->complete_marking_context()->reset_top_bitmap(this);
ShenandoahHeap::heap()->complete_marking_context()->reset_top_bitmap(this);
}

void ShenandoahHeapRegion::make_empty() {
@@ -297,7 +296,7 @@ void ShenandoahHeapRegion::make_uncommitted() {

void ShenandoahHeapRegion::make_committed_bypass() {
shenandoah_assert_heaplocked();
assert (_heap->is_full_gc_in_progress(), "only for full GC");
assert (ShenandoahHeap::heap()->is_full_gc_in_progress(), "only for full GC");

switch (_state) {
case _empty_uncommitted:
@@ -325,7 +324,7 @@ void ShenandoahHeapRegion::reset_alloc_metadata_to_shared() {
_tlab_allocs = 0;
_gclab_allocs = 0;
_shared_allocs = used() >> LogHeapWordSize;
if (_heap->is_traversal_mode()) {
if (ShenandoahHeap::heap()->is_traversal_mode()) {
update_seqnum_last_alloc_mutator();
}
} else {
@@ -334,7 +333,7 @@ void ShenandoahHeapRegion::reset_alloc_metadata_to_shared() {
}

void ShenandoahHeapRegion::update_seqnum_last_alloc_mutator() {
assert(_heap->is_traversal_mode(), "Sanity");
assert(ShenandoahHeap::heap()->is_traversal_mode(), "Sanity");
shenandoah_assert_heaplocked_or_safepoint();
_seqnum_last_alloc_mutator = _alloc_seq_num.value++;
}
@@ -417,7 +416,7 @@ void ShenandoahHeapRegion::print_on(outputStream* st) const {
st->print("|BTE " INTPTR_FORMAT_W(12) ", " INTPTR_FORMAT_W(12) ", " INTPTR_FORMAT_W(12),
p2i(bottom()), p2i(top()), p2i(end()));
st->print("|TAMS " INTPTR_FORMAT_W(12),
p2i(_heap->marking_context()->top_at_mark_start(const_cast<ShenandoahHeapRegion*>(this))));
p2i(ShenandoahHeap::heap()->marking_context()->top_at_mark_start(const_cast<ShenandoahHeapRegion*>(this))));
st->print("|UWM " INTPTR_FORMAT_W(12),
p2i(_update_watermark));
st->print("|U " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(used()), proper_unit_for_byte_size(used()));
@@ -460,13 +459,14 @@ void ShenandoahHeapRegion::oop_iterate_humongous(OopIterateClosure* blk) {
}

ShenandoahHeapRegion* ShenandoahHeapRegion::humongous_start_region() const {
ShenandoahHeap* heap = ShenandoahHeap::heap();
assert(is_humongous(), "Must be a part of the humongous region");
size_t reg_num = region_number();
ShenandoahHeapRegion* r = const_cast<ShenandoahHeapRegion*>(this);
while (!r->is_humongous_start()) {
assert(reg_num > 0, "Sanity");
reg_num --;
r = _heap->get_region(reg_num);
r = heap->get_region(reg_num);
assert(r->is_humongous(), "Must be a part of the humongous region");
}
assert(r->is_humongous_start(), "Must be");
@@ -479,7 +479,7 @@ void ShenandoahHeapRegion::recycle() {

reset_alloc_metadata();

_heap->marking_context()->reset_top_at_mark_start(this);
ShenandoahHeap::heap()->marking_context()->reset_top_at_mark_start(this);
set_update_watermark(bottom());

make_empty();
@@ -674,23 +674,25 @@ void ShenandoahHeapRegion::setup_sizes(size_t max_heap_size) {
}

void ShenandoahHeapRegion::do_commit() {
if (!_heap->is_heap_region_special() && !os::commit_memory((char *) bottom(), RegionSizeBytes, false)) {
ShenandoahHeap* heap = ShenandoahHeap::heap();
if (!heap->is_heap_region_special() && !os::commit_memory((char *) bottom(), RegionSizeBytes, false)) {
report_java_out_of_memory("Unable to commit region");
}
if (!_heap->commit_bitmap_slice(this)) {
if (!heap->commit_bitmap_slice(this)) {
report_java_out_of_memory("Unable to commit bitmaps for region");
}
_heap->increase_committed(ShenandoahHeapRegion::region_size_bytes());
heap->increase_committed(ShenandoahHeapRegion::region_size_bytes());
}

void ShenandoahHeapRegion::do_uncommit() {
if (!_heap->is_heap_region_special() && !os::uncommit_memory((char *) bottom(), RegionSizeBytes)) {
ShenandoahHeap* heap = ShenandoahHeap::heap();
if (!heap->is_heap_region_special() && !os::uncommit_memory((char *) bottom(), RegionSizeBytes)) {
report_java_out_of_memory("Unable to uncommit region");
}
if (!_heap->uncommit_bitmap_slice(this)) {
if (!heap->uncommit_bitmap_slice(this)) {
report_java_out_of_memory("Unable to uncommit bitmaps for region");
}
_heap->decrease_committed(ShenandoahHeapRegion::region_size_bytes());
heap->decrease_committed(ShenandoahHeapRegion::region_size_bytes());
}

void ShenandoahHeapRegion::set_state(RegionState to) {
@@ -238,7 +238,6 @@ class ShenandoahHeapRegion : public CHeapObj<mtGC> {
static PaddedAllocSeqNum _alloc_seq_num;

// Never updated fields
ShenandoahHeap* const _heap;
size_t const _region_number;
HeapWord* const _bottom;
HeapWord* const _end;
@@ -268,7 +267,7 @@ class ShenandoahHeapRegion : public CHeapObj<mtGC> {
shenandoah_padding(0);

public:
ShenandoahHeapRegion(ShenandoahHeap* heap, HeapWord* start, size_t index, bool committed);
ShenandoahHeapRegion(HeapWord* start, size_t index, bool committed);

static const size_t MIN_NUM_REGIONS = 10;

@@ -408,11 +407,7 @@ class ShenandoahHeapRegion : public CHeapObj<mtGC> {
size_t get_tlab_allocs() const;
size_t get_gclab_allocs() const;

uint64_t seqnum_last_alloc_mutator() const {
assert(_heap->is_traversal_mode(), "Sanity");
return _seqnum_last_alloc_mutator;
}

inline uint64_t seqnum_last_alloc_mutator() const;
void update_seqnum_last_alloc_mutator();

HeapWord* get_update_watermark() const {
@@ -75,7 +75,7 @@ inline void ShenandoahHeapRegion::increase_live_data_alloc_words(size_t s) {
inline void ShenandoahHeapRegion::increase_live_data_gc_words(size_t s) {
internal_increase_live_data(s);
if (ShenandoahPacing) {
_heap->pacer()->report_mark(s);
ShenandoahHeap::heap()->pacer()->report_mark(s);
}
}

@@ -89,4 +89,9 @@ inline void ShenandoahHeapRegion::internal_increase_live_data(size_t s) {
#endif
}

inline uint64_t ShenandoahHeapRegion::seqnum_last_alloc_mutator() const {
assert(ShenandoahHeap::heap()->is_traversal_mode(), "Sanity");
return _seqnum_last_alloc_mutator;
}

#endif // SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGION_INLINE_HPP

0 comments on commit 92d854f

Please sign in to comment.