[aarch64-port-dev ] RFR(XS): 8211320: Aarch64: unsafe.compareAndSetByte() and unsafe.compareAndSetShort() c2 intrinsics broken with negative expected value

Andrew Haley aph at redhat.com
Mon Oct 1 13:18:37 UTC 2018

On 10/01/2018 12:03 PM, Andrew Haley wrote:
> 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
> supports LSE.

I'm looking at the LSE spec, and it compares the memory with the sub-
word (of whatever size) in the passed register. The equivalent for us
would be

    load_exclusive(result, addr, size, acquire);
    if (size == xword) {
      cmp(result, expected);
    } else if (size == word) {
      cmpw(result, expected);
    } else if (size == hword) {
      andr(rscratch1, expected, 0xffff);
      cmpw(result, rscratch1);
    } else if (size == byte) {
      andr(rscratch1, expected, 0xff);
      cmpw(result, rscratch1);
    } else {
    br(Assembler::NE, done);

It'd be better with a switch, but you get the idea.

Andrew Haley
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 mailing list