Java jit编译器每次运行时都会编译它的代码吗? [英] Does Java jit compiler compiles its code every time it runs?

查看:157
本文介绍了Java jit编译器每次运行时都会编译它的代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是java的新手并且正在努力理解以下内容:
每次运行代码时jit是否编译? (我知道jit优化了经常运行的代码,但我问的不是热代码)

I am new to java and struggling to understand the following: Does jit compiles everytime we run the code? (I know jit optimizes that code which is run frequently but I am asking about other than a "hot code")

推荐答案

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.

这篇关于Java jit编译器每次运行时都会编译它的代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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