且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java jit编译器每次运行时都会编译它的代码吗?

更新时间:2023-11-10 18:50:16

JIT不记得以前的运行中的任何内容。

The JIT doesn't remember anything from a previous run.

这意味着它可以在每次运行时编译代码。 JIT甚至可以在运行时重新编译代码,以便进一步优化代码或者在检测到代码的使用方式发生变化时对其进行不同的优化。

This means it may compile code every time you run it. The JIT can even re-compile code while it is running to either optimise it further or optimise it differently if it detect how the code is used have changed.

代码是不被认为是热的将不会被编译,因为这可能比使用解释器运行它更昂贵。

Code which is not considered hot will not be compiled as this is likely to be more expensive than just running it with the interpreter.

当你有分层编译时(默认情况下在Java 8中打开)它会稍微编译适度的热门代码,当你运行它时会越来越多地重新编译它。它可以经历多个阶段。

When you have tiered compilation (on by default in Java 8) it will compile moderately hot code a little, recompile it more and more as you run it more. It can go through multiple stages.

如果你想查看正在编译的内容,请添加 -XX:+ PrintCompilation 在命令行上。

If you want to see what is being compiled add -XX:+PrintCompilation on the command line.