Changed code generation in JDK 9
Vladimir Parfinenko
vparfinenko at excelsior-usa.com
Tue Mar 13 11:16:50 UTC 2018
>> I would speculate it is related to boolean value normalization:
>> https://bugs.openjdk.java.net/browse/JDK-8161720
Yes, it looks very related. Thank you!
>> It is puzzling how would that leak to normal loads though.
You could always just write and execute handmade bytecode:
bipush 2
invokestatic Inverter.invert(Z)Z
--
Vladimir Parfinenko
P.S. Sorry for previous empty message.
-----Original Message-----
From: Vladimir Parfinenko
Sent: Tuesday, March 13, 2018 6:13 PM
To: 'Aleksey Shipilev'; hotspot-compiler-dev at openjdk.java.net
Subject: RE: Changed code generation in JDK 9
-----Original Message-----
From: Aleksey Shipilev [mailto:shade at redhat.com]
Sent: Tuesday, March 13, 2018 4:47 PM
To: Vladimir Parfinenko; hotspot-compiler-dev at openjdk.java.net
Subject: Re: Changed code generation in JDK 9
On 03/13/2018 10:39 AM, Vladimir Parfinenko wrote:
> Hi all,
>
> I am trying to investigate how C2 generates code for method:
>
> public static boolean invert(boolean x) {
> return !x;
> }
>
> I have found out that in JDK 8 it generates just "xor arg, 1" which does
> not properly handle random integers as booleans:
>
> 0x0000000004af4a8c: mov %edx,%eax
> 0x0000000004af4a8e: xor $0x1,%eax ;*ireturn
> ; - Inverter::invert at 9
> (line 3)
>
> In JDK 9 it performs truncation of argument to range {0, 1} and then
> "xor arg, 1".
>
> 0x000001d92cc9f0ac: test %edx,%edx
> 0x000001d92cc9f0ae: setne %al
> 0x000001d92cc9f0b1: movzbl %al,%eax
> 0x000001d92cc9f0b4: xor $0x1,%eax ;*ireturn {reexecute=0
> rethrow=0 return_oop=0}
> ; - Inverter::invert at 9
> (line 3)
>
> Full logs are available here:
> https://gist.github.com/cypok/24b2f30060958e10321f44784a4187c0
>
> So now I am trying to find the commit responsible for this change or
> motivational bug.
> Could anyone help me?
I would speculate it is related to boolean value normalization:
https://bugs.openjdk.java.net/browse/JDK-8161720
It is puzzling how would that leak to normal loads though.
-Aleksey
More information about the hotspot-compiler-dev
mailing list