-XX:Inline ignored for system classes?
Peter Veentjer
alarmnummer at gmail.com
Sun Jan 22 12:52:12 UTC 2017
I'm doing some Assembly analysis to gain a deeper understanding in
devirtualization and I'm running into some unexpected behavior. What I'm
seeing is that even though inlining is disabled, the call to ArrayList.size
got inlined. Look for '0x000000010be7e539' and you will see the unexpected
behavior. Is this intentional behavior or am I missing something?
This is the class
public class Devirtualization_MonoMorphic {
public static void main(String[] args) {
ArrayList arrayList = new ArrayList();
int result = 0;
for (int k = 0; k < 100_000; k++) {
result += sizePlusOne(arrayList);
}
System.out.println("result:" + result);
}
public static int sizePlusOne(Collection c) {
return c.size() + 1;
}
}
The arguments
-XX:+UnlockDiagnosticVMOptions
-XX:PrintAssemblyOptions=intel
-XX:-TieredCompilation
-XX:-Inline
-XX:-BackgroundCompilation
-XX:CompileCommand=print,*Devirtualization_MonoMorphic.sizePlusOne
The assembly:
CompilerOracle: print *Devirtualization_MonoMorphic.sizePlusOne
Compiled method (c2) 247 9
com.devirtualization.Devirtualization_MonoMorphic::sizePlusOne (9 bytes)
total in heap [0x000000010be7e3d0,0x000000010be7e678] = 680
relocation [0x000000010be7e4f0,0x000000010be7e508] = 24
main code [0x000000010be7e520,0x000000010be7e580] = 96
stub code [0x000000010be7e580,0x000000010be7e598] = 24
oops [0x000000010be7e598,0x000000010be7e5a0] = 8
metadata [0x000000010be7e5a0,0x000000010be7e5b0] = 16
scopes data [0x000000010be7e5b0,0x000000010be7e5e0] = 48
scopes pcs [0x000000010be7e5e0,0x000000010be7e660] = 128
dependencies [0x000000010be7e660,0x000000010be7e668] = 8
nul chk table [0x000000010be7e668,0x000000010be7e678] = 16
Loaded disassembler from
/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/hsdis-amd64.dylib
Decoding compiled method 0x000000010be7e3d0:
Code:
[Disassembling for mach='i386:x86-64']
[Entry Point]
[Verified Entry Point]
[Constants]
# {method} {0x000000011417a560} 'sizePlusOne' '(Ljava/util/Collection;)I'
in 'com/devirtualization/Devirtualization_MonoMorphic'
# parm0: rsi:rsi = 'java/util/Collection'
# [sp+0x20] (sp of caller)
0x000000010be7e520: mov DWORD PTR [rsp-0x14000],eax
0x000000010be7e527: push rbp
0x000000010be7e528: sub rsp,0x10 ;*synchronization entry
; -
com.devirtualization.Devirtualization_MonoMorphic::sizePlusOne at -1 (line 21)
0x000000010be7e52c: mov r11d,DWORD PTR [rsi+0x8] ; implicit
exception: dispatches to 0x000000010be7e55d
0x000000010be7e530: cmp r11d,0xf8003231 ;
{metadata('java/util/ArrayList')}
0x000000010be7e537: jne 0x000000010be7e54a ;*invokeinterface size
; -
com.devirtualization.Devirtualization_MonoMorphic::sizePlusOne at 1 (line 21)
0x000000010be7e539: mov eax,DWORD PTR [rsi+0x10]
0x000000010be7e53c: inc eax ;*iadd
; -
com.devirtualization.Devirtualization_MonoMorphic::sizePlusOne at 7 (line 21)
0x000000010be7e53e: add rsp,0x10
0x000000010be7e542: pop rbp
0x000000010be7e543: test DWORD PTR [rip+0xffffffffff6fdab7],eax
# 0x000000010b57c000
; {poll_return}
0x000000010be7e549: ret
0x000000010be7e54a: mov rbp,rsi
0x000000010be7e54d: mov esi,0xffffffde
0x000000010be7e552: nop
0x000000010be7e553: call 0x000000010be47120 ; OopMap{rbp=Oop off=56}
;*invokeinterface size
; -
com.devirtualization.Devirtualization_MonoMorphic::sizePlusOne at 1 (line 21)
; {runtime_call}
0x000000010be7e558: call 0x000000010a9a2e44 ; {runtime_call}
0x000000010be7e55d: mov esi,0xfffffff6
0x000000010be7e562: nop
0x000000010be7e563: call 0x000000010be47120 ; OopMap{off=72}
;*invokeinterface size
; -
com.devirtualization.Devirtualization_MonoMorphic::sizePlusOne at 1 (line 21)
; {runtime_call}
0x000000010be7e568: call 0x000000010a9a2e44 ;*invokeinterface size
; -
com.devirtualization.Devirtualization_MonoMorphic::sizePlusOne at 1 (line 21)
; {runtime_call}
0x000000010be7e56d: hlt
0x000000010be7e56e: hlt
0x000000010be7e56f: hlt
0x000000010be7e570: hlt
0x000000010be7e571: hlt
0x000000010be7e572: hlt
0x000000010be7e573: hlt
0x000000010be7e574: hlt
0x000000010be7e575: hlt
0x000000010be7e576: hlt
0x000000010be7e577: hlt
0x000000010be7e578: hlt
0x000000010be7e579: hlt
0x000000010be7e57a: hlt
0x000000010be7e57b: hlt
0x000000010be7e57c: hlt
0x000000010be7e57d: hlt
0x000000010be7e57e: hlt
0x000000010be7e57f: hlt
[Exception Handler]
[Stub Code]
0x000000010be7e580: jmp 0x000000010be6bf60 ; {no_reloc}
[Deopt Handler Code]
0x000000010be7e585: call 0x000000010be7e58a
0x000000010be7e58a: sub QWORD PTR [rsp],0x5
0x000000010be7e58f: jmp 0x000000010be46d00 ; {runtime_call}
0x000000010be7e594: hlt
0x000000010be7e595: hlt
0x000000010be7e596: hlt
0x000000010be7e597: hlt
OopMapSet contains 2 OopMaps
#0
OopMap{rbp=Oop off=56}
#1
OopMap{off=72}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20170122/7f0c5d9c/attachment.html>
More information about the hotspot-compiler-dev
mailing list