RFR: 8371956: Convert OopStorage to use Atomic<T> [v2]
Kim Barrett
kbarrett at openjdk.org
Wed Nov 19 00:18:59 UTC 2025
On Mon, 17 Nov 2025 10:40:24 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
> [...] I also noticed that we use `volatile` with `_owner_address`, is that because of the SafeFetch usage?
I forgot to respond to this question.
As the comment says, the member clearing in ~Block resets values used
elsewhere for mapping from an entry to its containing block, and validating
that lookup. So this clearing will cause the lookup to fail if the block has
been destructed and not reallocated by the same storage object, or reallocated
by the same storage object but the specific entry hasn't been reallocated. So
perhaps being somewhat paranoid, but that lookup and block management are a
little bit tricky.
The reason for the cast to volatile isn't about SafeFetch usage specifically
though. Rather, as the comment says, it's to prevent the compiler from
(potentially) eliminating the dead store, since we're in the destructor and
that member is about to be (trivially) destructed itself.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28338#issuecomment-3549995629
More information about the hotspot-gc-dev
mailing list