Skip to content

Commit d874e96

Browse files
Hamlin Limashoubing
andcommitted
8271579: G1: Move copy before CAS in do_copy_to_survivor_space
8272070: G1: Simplify age calculation after JDK-8271579 Co-authored-by: shoubing ma <mashoubing1@huawei.com> Reviewed-by: tschatzl, ayang
1 parent 92bde67 commit d874e96

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/hotspot/share/gc/g1/g1ParScanThreadState.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,11 @@ oop G1ParScanThreadState::do_copy_to_survivor_space(G1HeapRegionAttr const regio
464464

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

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

473473
{
474474
const uint young_index = from_region->young_index_in_cset();
@@ -480,19 +480,9 @@ oop G1ParScanThreadState::do_copy_to_survivor_space(G1HeapRegionAttr const regio
480480
if (dest_attr.is_young()) {
481481
if (age < markWord::max_age) {
482482
age++;
483-
}
484-
if (old_mark.has_displaced_mark_helper()) {
485-
// In this case, we have to install the old mark word containing the
486-
// displacement tag, and update the age in the displaced mark word.
487-
markWord new_mark = old_mark.displaced_mark_helper().set_age(age);
488-
old_mark.set_displaced_mark_helper(new_mark);
489-
obj->set_mark(old_mark);
490-
} else {
491-
obj->set_mark(old_mark.set_age(age));
483+
obj->incr_age();
492484
}
493485
_age_table.add(age, word_sz);
494-
} else {
495-
obj->set_mark(old_mark);
496486
}
497487

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

0 commit comments

Comments
 (0)