JVM print assembly code
需要反汇编插件,不然看到的就是二进制代码了。hsdis HotSpot Disassembly Plugin Downloads
这篇文章值得参考一下CompileCommand JVM option | It’s All Relative
如果我想看trino package下面生成的汇编代码,可以在 `jvm.config` 里面配置
- 允许对jvm进行diagnose
- 对所有的package都不打印汇编代码,否则每个类/方法都会打印生成的汇编代码
- 然后针对 `io/trino/sql` 这个package下面所有的类/方法打印汇编代码
-XX:+UnlockDiagnosticVMOptions -XX:-PrintAssembly -XX:CompileCommand=option,io.trino.sql.*::*,PrintAssembly,+
最后输出的结果是在 `log/var/log/launcher.log` 里面
============================= C2-compiled nmethod ============================== ----------------------------------- Assembly ----------------------------------- Compiled method (c2) 29768 25579 4 io.trino.sql.gen.ExpressionProfiler::start (12 bytes) total in heap [0x00007fc978886590,0x00007fc978886880] = 752 relocation [0x00007fc9788866e0,0x00007fc978886700] = 32 main code [0x00007fc978886700,0x00007fc9788867d0] = 208 stub code [0x00007fc9788867d0,0x00007fc9788867e8] = 24 oops [0x00007fc9788867e8,0x00007fc9788867f0] = 8 metadata [0x00007fc9788867f0,0x00007fc978886808] = 24 scopes data [0x00007fc978886808,0x00007fc978886828] = 32 scopes pcs [0x00007fc978886828,0x00007fc978886868] = 64 dependencies [0x00007fc978886868,0x00007fc978886870] = 8 nul chk table [0x00007fc978886870,0x00007fc978886880] = 16
如果加上下面两个选项, 可以在 `log/assembly.log` 里面得到比较详细的编译信息,这个日志可以喂给JITWatch来看。
-XX:+LogCompilation -XX:LogFile=assembly.log