Changed code generation in JDK 9
Vladimir Parfinenko
vparfinenko at excelsior-usa.com
Tue Mar 13 09:39:53 UTC 2018
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?
--
Vladimir Parfinenko
More information about the hotspot-compiler-dev
mailing list