jdk9 VarHandle and Fence methods
Gil Tene
gil at azulsystems.com
Fri Aug 21 17:58:10 UTC 2015
> On Aug 21, 2015, at 9:39 AM, Doug Lea <dl at cs.oswego.edu> wrote:
>
> On 08/21/2015 10:50 AM, Gil Tene wrote:
> ...
>> - Is NotReallyVarHandle.setOpaque() more relaxed than a lazySet()? Or is it
>> similar?
>
> The unloved-but-necessary method setOpaque is setRelaxed with what
> amounts to a compiler directive saying that the write must actually
> occur even if other JMM rules would allow it to be optimized away.
> Usage should be rare. Think IO.
Ok, that makes more sense (as written above).
I think the comment needs to make this semantic meaning clear. The current one does not, leading to obvious questions.
The IO example is a good one. It is probably more tricky to word when it comes to non-IO realms, as "write [to memory] must actually occur" is hard to map to how various memory hierarchies are managed. Perhaps identifying it as a write to coherent memory being required would work. E.g. a write to globally coherent L1 data cache will probably qualify for what the operation is intended to do, but a write to a non-coherent structure (a CPU register, a non-coherent L1 cache, a local memory in a loosely coupled non-fully-coherent memory system) probably does not qualify unless a following coherency-assusring operation makes the data coherently visible (example coherency-creating operations can be: a write of the register to memory, a flush of dirty lines in a non-coherent cache, a cross-network data update in a loosely coupled message-based distributed system).
— Gil.
More information about the valhalla-dev
mailing list