Questions about CompareAndSwap

Aleksey Shipilev aleksey.shipilev at
Fri Nov 20 21:35:19 UTC 2015

Hi Roman,

On 11/20/2015 06:31 PM, Roman Kennke wrote:
> 2. Would it be possible to also get the actual old-value out of
> CompareAndSwapP, in addition to the flags? My idea is that
> CompareAndSwapP would be a MultiNode producing two outputs. Would that
> be possible? Would there be any disadvantages (i.e. loss of performance
> due to messed up optimizations, or such?)

Actually, VarHandles add new compareAndExchange methods, that are
intrinsified with the new C1/C2 code. Those methods return old value on
success, and expected value on failure (actually, they leave accumulator
untouched on failure) -- pretty much what you expect from x86-style lock

We already did prototypal x86_*.ad changes for them. See:

We are planning to sweep the implementation, and hit the review soon.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the hotspot-compiler-dev mailing list