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

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

问题描述

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

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

还有一个相关的问题:有没有什么方法可以在不运行 JVM 的情况下使用 JIT 编译器将我的代码编译为本机代码?

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?

推荐答案

是的,有一种打印生成的本机代码的方法(需要 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天全站免登陆