反汇编Java JIT编译的原生字节码 [英] Disassemble Java JIT compiled native bytecode

查看:285
本文介绍了反汇编Java JIT编译的原生字节码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法对Java即时编译器生成的本地代码进行汇编转储?

Is there any way to do an assembly dump of the native code generated by the Java just-in-time compiler?

还有一个相关问题:如何使用JIT编译器而不运行JVM将我的代码编译为本地机器码?

And a related question: Is there any way to use the JIT compiler without running the JVM to compile my code into native machine code?

推荐答案

https://wiki.openjdk.java.net/display/HotSpot/PrintAssembly =nofollow>有一种方法打印生成的本地代码(需要OpenJDK 7)。

Yes, there is a way to print the generated native code (requires OpenJDK 7).

否,无法使用JDK的JIT将Java字节码编译为本机代码,并将其保存为本机可执行文件。

No, there is no way to compile your Java bytecode to native code using the JDK's JIT and save it as a native executable.

即使这是可能的,它可能没有你想象的有用。 JVM做了一些非常复杂的优化,如果需要它甚至可以在运行时优化代码。换句话说,它不像JIT将你的代码编译为本地机器语言那样简单,然后在程序运行时本地机器语言将保持不变。此外,这不会让你创建一个独立于JVM和运行时库的本地可执行文件。

Even if this were possible, it would probably not as useful as you think. The JVM does some very sophisticated optimizations, and it can even de-optimize code on the fly if necessary. In other words, it's not as simple as the JIT compiles your code to native machine language, and then that native machine language will remain unchanged while the program is running. Also, this would not let you make a native executable that is independent of the JVM and runtime library.

这篇关于反汇编Java JIT编译的原生字节码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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