Skip to content

Commit

Permalink
8309953: Strengthen and optimize oopDesc age methods
Browse files Browse the repository at this point in the history
Reviewed-by: mdoerr, rkennke, tschatzl, stefank
  • Loading branch information
shipilev committed Jun 15, 2023
1 parent 79ff72a commit 4a5475c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/hotspot/share/oops/oop.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,20 +296,22 @@ oop oopDesc::forwardee() const {

// The following method needs to be MT safe.
uint oopDesc::age() const {
assert(!mark().is_marked(), "Attempt to read age from forwarded mark");
if (has_displaced_mark()) {
return displaced_mark().age();
markWord m = mark();
assert(!m.is_marked(), "Attempt to read age from forwarded mark");
if (m.has_displaced_mark_helper()) {
return m.displaced_mark_helper().age();
} else {
return mark().age();
return m.age();
}
}

void oopDesc::incr_age() {
assert(!mark().is_marked(), "Attempt to increment age of forwarded mark");
if (has_displaced_mark()) {
set_displaced_mark(displaced_mark().incr_age());
markWord m = mark();
assert(!m.is_marked(), "Attempt to increment age of forwarded mark");
if (m.has_displaced_mark_helper()) {
m.set_displaced_mark_helper(m.displaced_mark_helper().incr_age());
} else {
set_mark(mark().incr_age());
set_mark(m.incr_age());
}
}

Expand Down

1 comment on commit 4a5475c

@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.