Skip to content
Permalink
Browse files

8241844: Shenandoah: rename ShenandoahHeapRegion::region_number

Reviewed-by: rkennke
  • Loading branch information
shipilev committed Mar 30, 2020
1 parent 87396af commit 6df237012070edb2138e4f48048a01bbdce2b67a
@@ -257,7 +257,7 @@ void ShenandoahAsserts::assert_in_correct_region(void* interior_loc, oop obj, co

size_t alloc_size = obj->size();
if (alloc_size > ShenandoahHeapRegion::humongous_threshold_words()) {
size_t idx = r->region_number();
size_t idx = r->index();
size_t num_regions = ShenandoahHeapRegion::required_regions(alloc_size * HeapWordSize);
for (size_t i = idx; i < idx + num_regions; i++) {
ShenandoahHeapRegion* chain_reg = heap->get_region(i);
@@ -83,7 +83,7 @@ void ShenandoahCollectionSet::add_region(ShenandoahHeapRegion* r) {
assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
assert(Thread::current()->is_VM_thread(), "Must be VMThread");
assert(!is_in(r), "Already in collection set");
_cset_map[r->region_number()] = 1;
_cset_map[r->index()] = 1;
_region_count ++;
_garbage += r->garbage();
_live_data += r->get_live_data_bytes();
@@ -103,7 +103,7 @@ void ShenandoahCollectionSet::remove_region(ShenandoahHeapRegion* r) {
assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
assert(Thread::current()->is_VM_thread(), "Must be VMThread");
assert(is_in(r), "Not in collection set");
_cset_map[r->region_number()] = 0;
_cset_map[r->index()] = 0;
_region_count --;
}

@@ -80,7 +80,7 @@ class ShenandoahCollectionSet : public CHeapObj<mtGC> {
}

inline bool is_in(ShenandoahHeapRegion* r) const;
inline bool is_in(size_t region_number) const;
inline bool is_in(size_t region_idx) const;
inline bool is_in(oop obj) const;
inline bool is_in_loc(void* loc) const;

@@ -30,13 +30,13 @@
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
#include "gc/shenandoah/shenandoahHeapRegion.hpp"

bool ShenandoahCollectionSet::is_in(size_t region_number) const {
assert(region_number < _heap->num_regions(), "Sanity");
return _cset_map[region_number] == 1;
bool ShenandoahCollectionSet::is_in(size_t region_idx) const {
assert(region_idx < _heap->num_regions(), "Sanity");
return _cset_map[region_idx] == 1;
}

bool ShenandoahCollectionSet::is_in(ShenandoahHeapRegion* r) const {
return is_in(r->region_number());
return is_in(r->index());
}

bool ShenandoahCollectionSet::is_in(oop p) const {
@@ -148,7 +148,7 @@ HeapWord* ShenandoahFreeSet::allocate_single(ShenandoahAllocRequest& req, bool&
}

HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, ShenandoahAllocRequest& req, bool& in_new_region) {
assert (!has_no_alloc_capacity(r), "Performance: should avoid full regions on this path: " SIZE_FORMAT, r->region_number());
assert (!has_no_alloc_capacity(r), "Performance: should avoid full regions on this path: " SIZE_FORMAT, r->index());

if (_heap->is_concurrent_root_in_progress() &&
r->is_trash()) {
@@ -217,7 +217,7 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
}
}

size_t num = r->region_number();
size_t num = r->index();
_collector_free_bitmap.clear_bit(num);
_mutator_free_bitmap.clear_bit(num);
// Touched the bounds? Need to update:
@@ -307,7 +307,7 @@ HeapWord* ShenandoahFreeSet::allocate_contiguous(ShenandoahAllocRequest& req) {
ShenandoahHeapRegion* r = _heap->get_region(i);
try_recycle_trashed(r);

assert(i == beg || _heap->get_region(i-1)->region_number() + 1 == r->region_number(), "Should be contiguous");
assert(i == beg || _heap->get_region(i - 1)->index() + 1 == r->index(), "Should be contiguous");
assert(r->is_empty(), "Should be empty");

if (i == beg) {
@@ -327,7 +327,7 @@ HeapWord* ShenandoahFreeSet::allocate_contiguous(ShenandoahAllocRequest& req) {
r->set_top(r->bottom() + used_words);
r->reset_alloc_metadata_to_shared();

_mutator_free_bitmap.clear_bit(r->region_number());
_mutator_free_bitmap.clear_bit(r->index());
}

// While individual regions report their true use, all humongous regions are
@@ -388,7 +388,7 @@ void ShenandoahFreeSet::recycle_trash() {
}

void ShenandoahFreeSet::flip_to_gc(ShenandoahHeapRegion* r) {
size_t idx = r->region_number();
size_t idx = r->index();

assert(_mutator_free_bitmap.at(idx), "Should be in mutator view");
assert(can_allocate_from(r), "Should not be allocated");
@@ -132,8 +132,8 @@ class ShenandoahPretouchBitmapTask : public AbstractGangTask {
virtual void work(uint worker_id) {
ShenandoahHeapRegion* r = _regions.next();
while (r != NULL) {
size_t start = r->region_number() * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor();
size_t end = (r->region_number() + 1) * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor();
size_t start = r->index() * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor();
size_t end = (r->index() + 1) * ShenandoahHeapRegion::region_size_bytes() / MarkBitMap::heap_map_factor();
assert (end <= _bitmap_size, "end is sane: " SIZE_FORMAT " < " SIZE_FORMAT, end, _bitmap_size);

os::pretouch_memory(_bitmap_base + start, _bitmap_base + end, _page_size);
@@ -952,7 +952,7 @@ class ShenandoahEvacuationTask : public AbstractGangTask {
ShenandoahConcurrentEvacuateRegionObjectClosure cl(_sh);
ShenandoahHeapRegion* r;
while ((r =_cs->claim_next()) != NULL) {
assert(r->has_live(), "Region " SIZE_FORMAT " should have been reclaimed early", r->region_number());
assert(r->has_live(), "Region " SIZE_FORMAT " should have been reclaimed early", r->index());
_sh->marked_object_iterate(r, &cl);

if (ShenandoahPacing) {
@@ -996,7 +996,7 @@ void ShenandoahHeap::trash_humongous_region_at(ShenandoahHeapRegion* start) {
oop humongous_obj = oop(start->bottom());
size_t size = humongous_obj->size();
size_t required_regions = ShenandoahHeapRegion::required_regions(size * HeapWordSize);
size_t index = start->region_number() + required_regions - 1;
size_t index = start->index() + required_regions - 1;

assert(!start->has_live(), "liveness must be zero");

@@ -1360,9 +1360,9 @@ class ShenandoahClearLivenessClosure : public ShenandoahHeapRegionClosure {
r->clear_live_data();
_ctx->capture_top_at_mark_start(r);
} else {
assert(!r->has_live(), "Region " SIZE_FORMAT " should have no live data", r->region_number());
assert(!r->has_live(), "Region " SIZE_FORMAT " should have no live data", r->index());
assert(_ctx->top_at_mark_start(r) == r->top(),
"Region " SIZE_FORMAT " should already have correct TAMS", r->region_number());
"Region " SIZE_FORMAT " should already have correct TAMS", r->index());
}
}

@@ -1438,9 +1438,9 @@ class ShenandoahCompleteLivenessClosure : public ShenandoahHeapRegionClosure {
r->increase_live_data_alloc_words(pointer_delta(top, tams));
}
} else {
assert(!r->has_live(), "Region " SIZE_FORMAT " should have no live data", r->region_number());
assert(!r->has_live(), "Region " SIZE_FORMAT " should have no live data", r->index());
assert(_ctx->top_at_mark_start(r) == r->top(),
"Region " SIZE_FORMAT " should have correct TAMS", r->region_number());
"Region " SIZE_FORMAT " should have correct TAMS", r->index());
}
}

@@ -2512,13 +2512,13 @@ void ShenandoahHeap::print_extended_on(outputStream *st) const {
}

bool ShenandoahHeap::is_bitmap_slice_committed(ShenandoahHeapRegion* r, bool skip_self) {
size_t slice = r->region_number() / _bitmap_regions_per_slice;
size_t slice = r->index() / _bitmap_regions_per_slice;

size_t regions_from = _bitmap_regions_per_slice * slice;
size_t regions_to = MIN2(num_regions(), _bitmap_regions_per_slice * (slice + 1));
for (size_t g = regions_from; g < regions_to; g++) {
assert (g / _bitmap_regions_per_slice == slice, "same slice");
if (skip_self && g == r->region_number()) continue;
if (skip_self && g == r->index()) continue;
if (get_region(g)->is_committed()) {
return true;
}
@@ -2541,7 +2541,7 @@ bool ShenandoahHeap::commit_bitmap_slice(ShenandoahHeapRegion* r) {
}

// Commit the bitmap slice:
size_t slice = r->region_number() / _bitmap_regions_per_slice;
size_t slice = r->index() / _bitmap_regions_per_slice;
size_t off = _bitmap_bytes_per_slice * slice;
size_t len = _bitmap_bytes_per_slice;
if (!os::commit_memory((char*)_bitmap_region.start() + off, len, false)) {
@@ -2565,7 +2565,7 @@ bool ShenandoahHeap::uncommit_bitmap_slice(ShenandoahHeapRegion *r) {
}

// Uncommit the bitmap slice:
size_t slice = r->region_number() / _bitmap_regions_per_slice;
size_t slice = r->index() / _bitmap_regions_per_slice;
size_t off = _bitmap_bytes_per_slice * slice;
size_t len = _bitmap_bytes_per_slice;
if (!os::uncommit_memory((char*)_bitmap_region.start() + off, len)) {
@@ -56,7 +56,7 @@ size_t ShenandoahHeapRegion::MaxTLABSizeWords = 0;
ShenandoahHeapRegion::PaddedAllocSeqNum ShenandoahHeapRegion::_alloc_seq_num;

ShenandoahHeapRegion::ShenandoahHeapRegion(HeapWord* start, size_t index, bool committed) :
_region_number(index),
_index(index),
_bottom(start),
_end(start + RegionSizeWords),
_new_top(NULL),
@@ -370,7 +370,7 @@ size_t ShenandoahHeapRegion::garbage() const {

void ShenandoahHeapRegion::print_on(outputStream* st) const {
st->print("|");
st->print(SIZE_FORMAT_W(5), this->_region_number);
st->print(SIZE_FORMAT_W(5), this->_index);

switch (_state) {
case _empty_uncommitted:
@@ -454,12 +454,12 @@ 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();
size_t i = index();
ShenandoahHeapRegion* r = const_cast<ShenandoahHeapRegion*>(this);
while (!r->is_humongous_start()) {
assert(reg_num > 0, "Sanity");
reg_num --;
r = heap->get_region(reg_num);
assert(i > 0, "Sanity");
i--;
r = heap->get_region(i);
assert(r->is_humongous(), "Must be a part of the humongous region");
}
assert(r->is_humongous_start(), "Must be");
@@ -691,7 +691,7 @@ void ShenandoahHeapRegion::do_uncommit() {
void ShenandoahHeapRegion::set_state(RegionState to) {
EventShenandoahHeapRegionStateChange evt;
if (evt.should_commit()){
evt.set_index((unsigned)region_number());
evt.set_index((unsigned) index());
evt.set_start((uintptr_t)bottom());
evt.set_used(used());
evt.set_from(_state);
@@ -706,7 +706,7 @@ void ShenandoahHeapRegion::record_pin() {
}

void ShenandoahHeapRegion::record_unpin() {
assert(pin_count() > 0, "Region " SIZE_FORMAT " should have non-zero pins", region_number());
assert(pin_count() > 0, "Region " SIZE_FORMAT " should have non-zero pins", index());
Atomic::sub(&_critical_pins, (size_t)1);
}

@@ -238,7 +238,7 @@ class ShenandoahHeapRegion : public CHeapObj<mtGC> {
static PaddedAllocSeqNum _alloc_seq_num;

// Never updated fields
size_t const _region_number;
size_t const _index;
HeapWord* const _bottom;
HeapWord* const _end;

@@ -353,8 +353,8 @@ class ShenandoahHeapRegion : public CHeapObj<mtGC> {
return _alloc_seq_num.value - 1;
}

inline size_t region_number() const {
return _region_number;
inline size_t index() const {
return _index;
}

// Allocation (return NULL if full)
@@ -59,7 +59,7 @@ ShenandoahHeapRegionSet::~ShenandoahHeapRegionSet() {

void ShenandoahHeapRegionSet::add_region(ShenandoahHeapRegion* r) {
assert(!is_in(r), "Already in collection set");
_set_map[r->region_number()] = 1;
_set_map[r->index()] = 1;
_region_count++;
}

@@ -76,7 +76,7 @@ void ShenandoahHeapRegionSet::remove_region(ShenandoahHeapRegion* r) {
assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
assert(Thread::current()->is_VM_thread(), "Must be VMThread");
assert(is_in(r), "Not in region set");
_set_map[r->region_number()] = 0;
_set_map[r->index()] = 0;
_region_count --;
}

@@ -84,7 +84,7 @@ class ShenandoahHeapRegionSet : public CHeapObj<mtGC> {
bool is_empty() const { return _region_count == 0; }

inline bool is_in(ShenandoahHeapRegion* r) const;
inline bool is_in(size_t region_number) const;
inline bool is_in(size_t region_idx) const;
inline bool is_in(oop p) const;

void print_on(outputStream* out) const;
@@ -31,13 +31,13 @@
#include "gc/shenandoah/shenandoahHeap.inline.hpp"
#include "gc/shenandoah/shenandoahHeapRegion.hpp"

bool ShenandoahHeapRegionSet::is_in(size_t region_number) const {
assert(region_number < _heap->num_regions(), "Sanity");
return _set_map[region_number] == 1;
bool ShenandoahHeapRegionSet::is_in(size_t region_idx) const {
assert(region_idx < _heap->num_regions(), "Sanity");
return _set_map[region_idx] == 1;
}

bool ShenandoahHeapRegionSet::is_in(ShenandoahHeapRegion* r) const {
return is_in(r->region_number());
return is_in(r->index());
}

bool ShenandoahHeapRegionSet::is_in(oop p) const {
@@ -57,7 +57,7 @@ class ShenandoahDumpHeapRegionInfoClosure : public ShenandoahHeapRegionClosure {
public:
virtual void heap_region_do(ShenandoahHeapRegion* r) {
EventShenandoahHeapRegionInformation evt;
evt.set_index((unsigned)r->region_number());
evt.set_index((unsigned) r->index());
evt.set_state((u8)r->state());
evt.set_start((uintptr_t)r->bottom());
evt.set_used(r->used());

0 comments on commit 6df2370

Please sign in to comment.