使用PrintAssembly打印java运行过程中的汇编
2013-08-08 11:29
411 查看
PrintAssembly是HotSpot JVM的一个诊断标志,允许我们获取JIT编译器/或者在解释过程中生成的汇编指令,通常可以通过分析执行的汇编指令可以帮助我们查找一些问题,也可以帮助我们分析和理解JVM 是如何解释和编译的。
下载:https://kenai.com/projects/base-hsdis/downloads
找到对应的指令集,操作系统所对应的so文件下载,好像不支持windows
安装目录:你的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
使用这些参数需要首先打开参数
-XX:+UnlockDiagnosticVMOptions
常见的用法
PrintAssembly 打印JIT编译后的汇编
PrintInterpreter 打印解释的汇编
你可以通过设置过滤,输出自己想要的方法的汇编
如何安装
这些并不是JVM直接提供的,在JVM里需要使用插件的方式,Kenai项目则提供了这个插件下载:https://kenai.com/projects/base-hsdis/downloads
找到对应的指令集,操作系统所对应的so文件下载,好像不支持windows
安装目录:你的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
PrintAssembly 打印JIT编译后的汇编
PrintInterpreter 打印解释的汇编
如何过滤输出
-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
你可以通过设置过滤,输出自己想要的方法的汇编
相关文章推荐
- Java千百问_02基本使用(015)_java如何通过汇编方式运行
- Android Studio使用过程中Java类突然报红,但项目可运行解决方案
- AndroidStudio使用过程中java类突然报红,但是程序可运行
- Android Studio使用过程中Java类突然报红,但项目可运行解决方案
- 查看Eclipse 运行java程序时使用的命令
- 【Java】使用Junit测试线程过程中出现的小问题
- 让Java程序作为linux的Daemon后台运行 和 使用Java Service Wrapper将java程序作为linux服务并且开机自动启动
- java使用ITEXT打印PDF
- java -虚拟机(JVM)的运行过程
- 使用Maven运行Java main的3种方式
- Java中使用Runtime和Process类运行外部程序
- Android使用XLog打印与收集程序运行详细日志
- JAVA之旅(十二)——Thread,run和start的特点,线程运行状态,获取线程对象和名称,多线程实例演示,使用Runnable接口
- 整理关于java开发工具使用过程中一些小技巧来提高开发效率
- Java程序运行内容加载过程
- Java程序编译和运行的过程
- java原生数据队列的简单使用,可变数据集合,遍历过程中动态添加数据并能在后续遍历过程中获取
- Java高效运行必备:如何选择使用String、StringBuffer与StringBuilder
- 使用Maven运行Java main的3种方式
- Linux预处理、编译、汇编、链接和运行的过程(包括一些基本的命令)