RFR: 8343394: Make MemorySessionImpl.state a stable field [v4]

Quan Anh Mai qamai at openjdk.org
Mon Nov 4 13:20:31 UTC 2024


On Mon, 4 Nov 2024 11:32:12 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> I'm dubious about this. Typically these modes work in a symmetric way - if you `setOpaque` you need to `getOpaque`. From [this](https://gee.cs.oswego.edu/dl/html/j9mm.html):
>> 
>>> Opaque mode, obtained using VarHandle getOpaque and setOpaque, adds constraints over Plain mode that provide minimal awareness of a variable that is subject to interthread access, **when all accesses use Opaque (or stronger) mode**
>
>> I'm dubious about this. 
> 
> NVM, I see it now -`sharedSessionAlreadyAcquired` uses a `getVolatile` (which has stronger semantics), so we're in the clear.

`checkValidStateRaw` synchronizes with `justClose` using handshakes so an opaque or higher load is only needed in `sharedSessionAlreadyClosed`. A `getOpaque` would probably be adequate. But I believe there is no formal restriction preventing the load from being hoisted out of the loop, so I decided to go for the strongest ordering in this exception-throwing case.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21810#discussion_r1827717654


More information about the core-libs-dev mailing list