mirror of
https://github.com/darlinghq/darling-openjdk.git
synced 2025-01-31 05:24:38 +00:00
8241520: Shenandoah: simplify region sequence numbers handling
Reviewed-by: rkennke
This commit is contained in:
parent
6c2d3f690b
commit
c3042accea
@ -178,6 +178,9 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
|
||||
// Allocation successful, bump stats:
|
||||
if (req.is_mutator_alloc()) {
|
||||
increase_used(size * HeapWordSize);
|
||||
if (_heap->is_traversal_mode()) {
|
||||
r->update_seqnum_last_alloc_mutator();
|
||||
}
|
||||
}
|
||||
|
||||
// Record actual allocation size
|
||||
|
@ -989,7 +989,7 @@ void ShenandoahHeap::print_heap_regions_on(outputStream* st) const {
|
||||
st->print_cr("EU=empty-uncommitted, EC=empty-committed, R=regular, H=humongous start, HC=humongous continuation, CS=collection set, T=trash, P=pinned");
|
||||
st->print_cr("BTE=bottom/top/end, U=used, T=TLAB allocs, G=GCLAB allocs, S=shared allocs, L=live data");
|
||||
st->print_cr("R=root, CP=critical pins, TAMS=top-at-mark-start, UWM=update watermark");
|
||||
st->print_cr("SN=alloc sequence numbers (first mutator, last mutator, first gc, last gc)");
|
||||
st->print_cr("SN=alloc sequence number");
|
||||
|
||||
for (size_t i = 0; i < num_regions(); i++) {
|
||||
get_region(i)->print_on(st);
|
||||
|
@ -65,10 +65,7 @@ ShenandoahHeapRegion::ShenandoahHeapRegion(ShenandoahHeap* heap, HeapWord* start
|
||||
_tlab_allocs(0),
|
||||
_gclab_allocs(0),
|
||||
_shared_allocs(0),
|
||||
_seqnum_first_alloc_mutator(0),
|
||||
_seqnum_first_alloc_gc(0),
|
||||
_seqnum_last_alloc_mutator(0),
|
||||
_seqnum_last_alloc_gc(0),
|
||||
_live_data(0),
|
||||
_critical_pins(0),
|
||||
_update_watermark(start) {
|
||||
@ -314,10 +311,7 @@ void ShenandoahHeapRegion::reset_alloc_metadata() {
|
||||
_tlab_allocs = 0;
|
||||
_gclab_allocs = 0;
|
||||
_shared_allocs = 0;
|
||||
_seqnum_first_alloc_mutator = 0;
|
||||
_seqnum_last_alloc_mutator = 0;
|
||||
_seqnum_first_alloc_gc = 0;
|
||||
_seqnum_last_alloc_gc = 0;
|
||||
}
|
||||
|
||||
void ShenandoahHeapRegion::reset_alloc_metadata_to_shared() {
|
||||
@ -325,16 +319,20 @@ void ShenandoahHeapRegion::reset_alloc_metadata_to_shared() {
|
||||
_tlab_allocs = 0;
|
||||
_gclab_allocs = 0;
|
||||
_shared_allocs = used() >> LogHeapWordSize;
|
||||
uint64_t next = _alloc_seq_num.value++;
|
||||
_seqnum_first_alloc_mutator = next;
|
||||
_seqnum_last_alloc_mutator = next;
|
||||
_seqnum_first_alloc_gc = 0;
|
||||
_seqnum_last_alloc_gc = 0;
|
||||
if (_heap->is_traversal_mode()) {
|
||||
update_seqnum_last_alloc_mutator();
|
||||
}
|
||||
} else {
|
||||
reset_alloc_metadata();
|
||||
}
|
||||
}
|
||||
|
||||
void ShenandoahHeapRegion::update_seqnum_last_alloc_mutator() {
|
||||
assert(_heap->is_traversal_mode(), "Sanity");
|
||||
_heap->assert_heaplock_or_safepoint();
|
||||
_seqnum_last_alloc_mutator = _alloc_seq_num.value++;
|
||||
}
|
||||
|
||||
size_t ShenandoahHeapRegion::get_shared_allocs() const {
|
||||
return _shared_allocs * HeapWordSize;
|
||||
}
|
||||
@ -422,9 +420,7 @@ void ShenandoahHeapRegion::print_on(outputStream* st) const {
|
||||
st->print("|S " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_shared_allocs()), proper_unit_for_byte_size(get_shared_allocs()));
|
||||
st->print("|L " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_live_data_bytes()), proper_unit_for_byte_size(get_live_data_bytes()));
|
||||
st->print("|CP " SIZE_FORMAT_W(3), pin_count());
|
||||
st->print("|SN " UINT64_FORMAT_X_W(12) ", " UINT64_FORMAT_X_W(8) ", " UINT64_FORMAT_X_W(8) ", " UINT64_FORMAT_X_W(8),
|
||||
seqnum_first_alloc_mutator(), seqnum_last_alloc_mutator(),
|
||||
seqnum_first_alloc_gc(), seqnum_last_alloc_gc());
|
||||
st->print("|SN " UINT64_FORMAT_X_W(12), _seqnum_last_alloc_mutator);
|
||||
st->cr();
|
||||
}
|
||||
|
||||
|
@ -252,10 +252,7 @@ private:
|
||||
size_t _gclab_allocs;
|
||||
size_t _shared_allocs;
|
||||
|
||||
uint64_t _seqnum_first_alloc_mutator;
|
||||
uint64_t _seqnum_first_alloc_gc;
|
||||
uint64_t _seqnum_last_alloc_mutator;
|
||||
uint64_t _seqnum_last_alloc_gc;
|
||||
|
||||
volatile size_t _live_data;
|
||||
volatile size_t _critical_pins;
|
||||
@ -403,31 +400,12 @@ public:
|
||||
size_t get_tlab_allocs() const;
|
||||
size_t get_gclab_allocs() const;
|
||||
|
||||
uint64_t seqnum_first_alloc() const {
|
||||
if (_seqnum_first_alloc_mutator == 0) return _seqnum_first_alloc_gc;
|
||||
if (_seqnum_first_alloc_gc == 0) return _seqnum_first_alloc_mutator;
|
||||
return MIN2(_seqnum_first_alloc_mutator, _seqnum_first_alloc_gc);
|
||||
}
|
||||
|
||||
uint64_t seqnum_last_alloc() const {
|
||||
return MAX2(_seqnum_last_alloc_mutator, _seqnum_last_alloc_gc);
|
||||
}
|
||||
|
||||
uint64_t seqnum_first_alloc_mutator() const {
|
||||
return _seqnum_first_alloc_mutator;
|
||||
}
|
||||
|
||||
uint64_t seqnum_last_alloc_mutator() const {
|
||||
assert(_heap->is_traversal_mode(), "Sanity");
|
||||
return _seqnum_last_alloc_mutator;
|
||||
}
|
||||
|
||||
uint64_t seqnum_first_alloc_gc() const {
|
||||
return _seqnum_first_alloc_gc;
|
||||
}
|
||||
|
||||
uint64_t seqnum_last_alloc_gc() const {
|
||||
return _seqnum_last_alloc_gc;
|
||||
}
|
||||
void update_seqnum_last_alloc_mutator();
|
||||
|
||||
HeapWord* get_update_watermark() const {
|
||||
// Updates to the update-watermark only happen at safepoints or, when pushing
|
||||
|
@ -52,29 +52,6 @@ HeapWord* ShenandoahHeapRegion::allocate(size_t size, ShenandoahAllocRequest::Ty
|
||||
}
|
||||
|
||||
inline void ShenandoahHeapRegion::adjust_alloc_metadata(ShenandoahAllocRequest::Type type, size_t size) {
|
||||
bool is_first_alloc = (top() == bottom());
|
||||
|
||||
switch (type) {
|
||||
case ShenandoahAllocRequest::_alloc_shared:
|
||||
case ShenandoahAllocRequest::_alloc_tlab:
|
||||
_seqnum_last_alloc_mutator = _alloc_seq_num.value++;
|
||||
if (is_first_alloc) {
|
||||
assert (_seqnum_first_alloc_mutator == 0, "Region " SIZE_FORMAT " metadata is correct", _region_number);
|
||||
_seqnum_first_alloc_mutator = _seqnum_last_alloc_mutator;
|
||||
}
|
||||
break;
|
||||
case ShenandoahAllocRequest::_alloc_shared_gc:
|
||||
case ShenandoahAllocRequest::_alloc_gclab:
|
||||
_seqnum_last_alloc_gc = _alloc_seq_num.value++;
|
||||
if (is_first_alloc) {
|
||||
assert (_seqnum_first_alloc_gc == 0, "Region " SIZE_FORMAT " metadata is correct", _region_number);
|
||||
_seqnum_first_alloc_gc = _seqnum_last_alloc_gc;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case ShenandoahAllocRequest::_alloc_shared:
|
||||
case ShenandoahAllocRequest::_alloc_shared_gc:
|
||||
|
@ -395,27 +395,6 @@ public:
|
||||
|
||||
verify(r, r->is_cset() == _heap->collection_set()->is_in(r),
|
||||
"Transitional: region flags and collection set agree");
|
||||
|
||||
verify(r, r->is_empty() || r->seqnum_first_alloc() != 0,
|
||||
"Non-empty regions should have first seqnum set");
|
||||
|
||||
verify(r, r->is_empty() || (r->seqnum_first_alloc_mutator() != 0 || r->seqnum_first_alloc_gc() != 0),
|
||||
"Non-empty regions should have first seqnum set to either GC or mutator");
|
||||
|
||||
verify(r, r->is_empty() || r->seqnum_last_alloc() != 0,
|
||||
"Non-empty regions should have last seqnum set");
|
||||
|
||||
verify(r, r->is_empty() || (r->seqnum_last_alloc_mutator() != 0 || r->seqnum_last_alloc_gc() != 0),
|
||||
"Non-empty regions should have last seqnum set to either GC or mutator");
|
||||
|
||||
verify(r, r->seqnum_first_alloc() <= r->seqnum_last_alloc(),
|
||||
"First seqnum should not be greater than last timestamp");
|
||||
|
||||
verify(r, r->seqnum_first_alloc_mutator() <= r->seqnum_last_alloc_mutator(),
|
||||
"First mutator seqnum should not be greater than last seqnum");
|
||||
|
||||
verify(r, r->seqnum_first_alloc_gc() <= r->seqnum_last_alloc_gc(),
|
||||
"First GC seqnum should not be greater than last seqnum");
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user