如何在优化后看到HotSpot生成的代码? [英] How can I see the code that HotSpot generates after optimizing?

查看:191
本文介绍了如何在优化后看到HotSpot生成的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更好地了解HotSpot在运行时可能为我的Java代码生成的优化。

I'd like to have a better understanding of what optimizations HotSpot might generate for my Java code at run time.

有没有办法看到HotSpot在运行一段时间后使用的优化代码?

Is there a way to see the optimized code that HotSpot is using after it's been running for a while?

推荐答案

您需要使用选项 -XX:+ PrintAssembly -XX:UnlockDiagnosticVMOptions启动JVM ,但PrintAssembly要求JVM拥有hsdis二进制文件(HotSpot反汇编程序)。由于许可证不兼容,hsdis二进制文件不随JVM一起分发,因此您需要编译hsdis你自己或从非官方网站上找到预建的hsdis二进制文件

You will need to start the JVM with the options -XX:+PrintAssembly and -XX:UnlockDiagnosticVMOptions, but PrintAssembly requires the JVM to have the hsdis binary (HotSpot disassembler). The hsdis binary is not distributed with the JVM due to license incompatibility, so you will need to compile hsdis yourself or find a prebuilt hsdis binary from an unofficial web site.

为了理解输出,像 JITWatch 很有用。按照其说明将调试信息写入日志文件,该日志文件可在JITWatch中进行分析。

To make sense of the output, a tool like JITWatch is useful. Follow its instructions to write the debug information to a log file which can be analyzed in JITWatch.

这篇关于如何在优化后看到HotSpot生成的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆