Skip to content

Commit

Permalink
8271579: G1: Move copy before CAS in do_copy_to_survivor_space
Browse files Browse the repository at this point in the history
8272070: G1: Simplify age calculation after JDK-8271579

Co-authored-by: shoubing ma <mashoubing1@huawei.com>
Reviewed-by: tschatzl, ayang
  • Loading branch information
Hamlin Li and mashoubing committed Aug 20, 2021
1 parent 92bde67 commit d874e96
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/hotspot/share/gc/g1/g1ParScanThreadState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,11 @@ oop G1ParScanThreadState::do_copy_to_survivor_space(G1HeapRegionAttr const regio

// We're going to allocate linearly, so might as well prefetch ahead.
Prefetch::write(obj_ptr, PrefetchCopyIntervalInBytes);
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(old), obj_ptr, word_sz);

const oop obj = cast_to_oop(obj_ptr);
const oop forward_ptr = old->forward_to_atomic(obj, old_mark, memory_order_relaxed);
if (forward_ptr == NULL) {
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(old), obj_ptr, word_sz);

{
const uint young_index = from_region->young_index_in_cset();
Expand All @@ -480,19 +480,9 @@ oop G1ParScanThreadState::do_copy_to_survivor_space(G1HeapRegionAttr const regio
if (dest_attr.is_young()) {
if (age < markWord::max_age) {
age++;
}
if (old_mark.has_displaced_mark_helper()) {
// In this case, we have to install the old mark word containing the
// displacement tag, and update the age in the displaced mark word.
markWord new_mark = old_mark.displaced_mark_helper().set_age(age);
old_mark.set_displaced_mark_helper(new_mark);
obj->set_mark(old_mark);
} else {
obj->set_mark(old_mark.set_age(age));
obj->incr_age();
}
_age_table.add(age, word_sz);
} else {
obj->set_mark(old_mark);
}

// Most objects are not arrays, so do one array check rather than
Expand Down

1 comment on commit d874e96

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.