[9] RFR (XS): C2: Broken cmpxchgb encoding on x86

Paul Sandoz paul.sandoz at oracle.com
Wed Aug 17 19:54:32 UTC 2016


Aleksey and I learned that Java has OS-specific calling conventions so as to ensure less shuffling of arguments for any JNI calls:

  http://hg.openjdk.java.net/jdk9/dev/hotspot/file/2bf98fb4ca55/src/cpu/x86/vm/assembler_x86.hpp#l92 <http://hg.openjdk.java.net/jdk9/dev/hotspot/file/2bf98fb4ca55/src/cpu/x86/vm/assembler_x86.hpp#l92>

Paul.

> On 17 Aug 2016, at 11:22, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:
> 
> Hi Vladimir,
> 
> Thanks for chasing this down. This REX encoding is quite confusing.
> 
> So it appears on the windows platform we sometimes get unlucky in whatever the value of the bl register is and the register chosen to represent the boolean mask value:
> 
> jdk/internal/misc/Unsafe.getAndBitwiseAndBoolean(Ljava/lang/Object;JZ)Z  [0x000000000cd1c5c0, 0x000000000cd1c678]  184 bytes
> Argument 0 is unknown.RIP: 0xcd1c5c0 Code size: 0x000000b8
> [Entry Point]
> [Constants]
>  # {method} {0x000000002dcd6578} 'getAndBitwiseAndBoolean' '(Ljava/lang/Object;JZ)Z' in 'jdk/internal/misc/Unsafe'
>  # this:     rdx:rdx   = 'jdk/internal/misc/Unsafe'
>  # parm0:    r8:r8     = 'java/lang/Object'
>  # parm1:    r9:r9     = long
>  # parm2:    rdi       = boolean
> 
> On my mac i observe the following which works out:
> 
> jdk/internal/misc/Unsafe.getAndBitwiseAndBoolean(Ljava/lang/Object;JZ)Z  [0x0000000112555620, 0x00000001125556f8]  216 bytes
> [Entry Point]
> [Constants]
>  # {method} {0x000000011ea3efc8} 'getAndBitwiseAndBoolean' '(Ljava/lang/Object;JZ)Z' in 'jdk/internal/misc/Unsafe'
>  # this:     rsi:rsi   = 'jdk/internal/misc/Unsafe'
>  # parm0:    rdx:rdx   = 'java/lang/Object'
>  # parm1:    rcx:rcx   = long
>  # parm2:    r8        = boolean
> 
> Paul.
> 
> 
>> On 17 Aug 2016, at 09:56, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> wrote:
>> 
>> http://cr.openjdk.java.net/~vlivanov/8164103/webrev.00/
>> https://bugs.openjdk.java.net/browse/JDK-8164103
>> 
>> Newly introduced compareAndSwapB/compareAndExchangeB rules on x64 incorrectly encodes cmpxchgb instruction when new value is in DIL (RDI) register.
>> 
>> What was missing is REX prefix. The fix is to use REX_breg_mem which takes care of that case [1].
>> 
>> The bug was found by new VarHandle tests on bitwise atomics [2]. So, I decided not to duplicate the failing test in hotspot repository. 8161444 will be integrated after the fix is in.
>> 
>> Testing: failing test, VarHandle tests (existing and new), RBT (hs-tier0-comp, in progress).
>> 
>> Thanks!
>> 
>> Best regards,
>> Vladimir Ivanov
>> 
>> [1] http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/file/031f53ef620a/src/cpu/x86/vm/x86_64.ad#l2375
>> 
>> [2] https://jbs.oracle.com/browse/JDK-8161444
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20160817/a91bfa93/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20160817/a91bfa93/signature.asc>


More information about the hotspot-compiler-dev mailing list