Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit

Permalink
8241844: Shenandoah: rename ShenandoahHeapRegion::region_number
Browse files Browse the repository at this point in the history
Reviewed-by: rkennke
  • Loading branch information
shipilev committed Mar 30, 2020
1 parent 87396af commit 6df2370
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 85 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahAsserts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 --;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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");
Expand Down
24 changes: 12 additions & 12 deletions src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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)) {
Expand All @@ -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)) {
Expand Down
16 changes: 8 additions & 8 deletions src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}

Expand All @@ -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 --;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahJfrSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading

0 comments on commit 6df2370

Please sign in to comment.