[concurrency-interest] VarHandle.setVolatile vs classical volatile write

Dávid Karnok akarnokd at gmail.com
Fri Aug 18 14:49:10 EDT 2017


in an older blog post (
about write barriers, it is mentioned the JIT uses a stack local address
and XADD to flush the write buffer when a volatile field is written on x86
and also mentions the option to use XCHG instead, targeting the actual
memory location.

My question is, does a compiled VarHandle.setVolatile do the same XADD
trick or is it using XCHG? Has there been a newer performance evaluation
with XCHG since the blog post? In other terms, is there a performance
penalty/benefit in changing VarHandle.setVolatile() into
VarHandle.getAndSet() when considering a modern x86 ?

My particular use case is for running code designed for concurrency in
non-concurrent fashion and perhaps saving the cost of a MOVE + XADD pair
when an XCHG has the very same effect.

Thank you for your time.
Best regards,
David Karnok
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20170818/ebe0e7ff/attachment.html>

More information about the Concurrency-interest mailing list