Skip to content

Commit 7b870e7

Browse files
committed
8242353: Shenandoah: micro-optimize region liveness handling
Reviewed-by: rkennke
1 parent 4c4271f commit 7b870e7

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.inline.hpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,15 @@ inline void ShenandoahConcurrentMark::count_liveness(jushort* live_data, oop obj
7575
if (!region->is_humongous_start()) {
7676
assert(!region->is_humongous(), "Cannot have continuations here");
7777
size_t max = (1 << (sizeof(jushort) * 8)) - 1;
78-
if (size >= max) {
79-
// too big, add to region data directly
80-
region->increase_live_data_gc_words(size);
78+
jushort cur = live_data[region_idx];
79+
size_t new_val = size + cur;
80+
if (new_val >= max) {
81+
// overflow, flush to region data
82+
region->increase_live_data_gc_words(new_val);
83+
live_data[region_idx] = 0;
8184
} else {
82-
jushort cur = live_data[region_idx];
83-
size_t new_val = cur + size;
84-
if (new_val >= max) {
85-
// overflow, flush to region data
86-
region->increase_live_data_gc_words(new_val);
87-
live_data[region_idx] = 0;
88-
} else {
89-
// still good, remember in locals
90-
live_data[region_idx] = (jushort) new_val;
91-
}
85+
// still good, remember in locals
86+
live_data[region_idx] = (jushort) new_val;
9287
}
9388
} else {
9489
shenandoah_assert_in_correct_region(NULL, obj);

src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3024,9 +3024,9 @@ void ShenandoahHeap::flush_liveness_cache(uint worker_id) {
30243024
assert(_liveness_cache != NULL, "sanity");
30253025
jushort* ld = _liveness_cache[worker_id];
30263026
for (uint i = 0; i < num_regions(); i++) {
3027-
ShenandoahHeapRegion* r = get_region(i);
30283027
jushort live = ld[i];
30293028
if (live > 0) {
3029+
ShenandoahHeapRegion* r = get_region(i);
30303030
r->increase_live_data_gc_words(live);
30313031
ld[i] = 0;
30323032
}

0 commit comments

Comments
 (0)