PrintAssembly是HotSpot JVM的一个诊断标志,允许我们获取JIT编译器/或者在解释过程中生成的汇编指令,通常可以通过分析执行的汇编指令可以帮助我们查找一些问题,也可以帮助我们分析和理解JVM 是如何解释和编译的。
安装目录:你的libjvm.so同目录
$JAVA_PATH/jre/lib/cpu指令集/server/
例如:
$JAVA_PATH/jre/lib/amd64/server/
文件名命名规则
1. 不同的指令集使用hsdis-指令集
hsdis-amd64, hsdis-sparc, hsdis-sparcv9
2. so文件改名为以lib为前缀的文件名, 这好像是JVM的bug(http://mail.openjdk.java.net/pipermail/hotspot-dev/2011-July/004284.html)
例如libhdis-amd64.so
+PrintAssembly print assembly code for bytecoded and native methods +PrintNMethods print nmethods as they are generated +PrintNativeNMethods print native method wrappers as they are generated +PrintSignatureHandlers print native method signature handlers +PrintAdapterHandlers print adapters (i2c, c2i) as they are generated +PrintStubCode print stubs: deopt, uncommon trap, exception, safepoint, runtime support +PrintInterpreter print interpreter code
使用这些参数需要首先打开参数
-XX:+UnlockDiagnosticVMOptions
常见的用法
-XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly
-XX:CompileCommand=print,*MyClass.myMethod prints assembly for just one method -XX:CompileCommand=option,*MyClass.myMethod,PrintOptoAssembly (debug build only) produces the old print command output -XX:CompileCommand=option,*MyClass.myMethod,PrintNMethods produces method dumps