Why is mark read as MO_RELAXED in read_stable_mark()?
patricio.chilano.mateo at oracle.com
patricio.chilano.mateo at oracle.com
Mon Jul 12 17:19:06 UTC 2021
Hi Roman,
On 7/12/21 11:04 AM, Roman Kennke wrote:
> Hi Hotspot runtime devs,
>
> I am messing a little bit with read_stable_mark() in synchronizer.cpp
> in Lilliput project (because I want to load the Klass* from the header).
>
> I notice that, in read_stable_mark(), we are loading the header with
> MO_RELAXED memory ordering, even though the INFLATING header is stored
> either via CAS or (re-)stored with MO_RELEASE. Wouldn't it be more
> consequential to load the header with MO_ACQUIRE instead?
For the monitor case I think we already have an address dependency in
the reader so there is no need for the acquire. So we first read the
monitor address and then use that address to access the _header
field(FastHashCode() case) or _owner field(current_thread_holds_lock()
and get_lock_owner() cases). The writer in turn orders the stores to
_owner/_header and the publishing of the monitor address by using a
release store in inflate() (I think this is the one you are referring to).
Patricio
> Thanks,
> Roman
>
More information about the hotspot-runtime-dev
mailing list