[aarch64-port-dev ] RFR(XS): 8211320: Aarch64: unsafe.compareAndSetByte() and unsafe.compareAndSetShort() c2 intrinsics broken with negative expected value
aph at redhat.com
Mon Oct 1 11:03:20 UTC 2018
On 10/01/2018 11:50 AM, Andrew Dinn wrote:
> On 01/10/18 11:43, Andrew Haley wrote:
>> On 10/01/2018 11:09 AM, Roland Westrelin wrote:
>>> Intrinsics for unsafe.compareAndSetByte() and
>>> unsafe.compareAndSetShort() don't properly deal with sign extension:
>>> load exclusive doesn't sign extend loaded value but comparison is done
>>> with sign extended value.
>> Ooh, that's tricky. I wonder if we should do this inside cmpxchg().
>> Mind you, that would cause cmpxchg() to have a side effect on an input
> You seem to have answered that question (correctly?) in the negative :-)
IMO it's more complicated than that.
> If you moved the sign extend into the cmpxchg method the C2 code would
> still have to copy the input to a temporary register and pass the temp
> into cmpxchg. Since this is the only place where a cmpxchgb actually
> occurs that doesn't seem like a better solution.
The problem is that cmpxchg() is a trap for the unwary.
The alternative would be to have cmpxchg itself do the sign extension
on the output. I guess it all depends on what the LSE instructions do,
given that we don't want to have different results on a machine that
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the hotspot-compiler-dev