桌面上的 JVM 是否使用 JIT 编译?

2022-01-16 00:00:00 jvm jit java

我总是遇到声称 Java 被解释的文章.我知道 Oracle 的 HotSpot JRE 提供即时编译,但是对于大多数桌面用户来说是这样吗?例如,如果我通过以下方式下载 Java:http://www.java.com/en/download,这会包括 JIT 编译器吗?

I always come across articles which claim that Java is interpreted. I know that Oracle's HotSpot JRE provides just-in-time compilation, however is this the case for a majority of desktop users? For example, if I download Java via: http://www.java.com/en/download, will this include a JIT Compiler?

推荐答案

是的,绝对的.声称 Java 是解释型的文章通常由不了解 Java 工作原理或不了解解释型含义的人撰写.

Yes, absolutely. Articles claiming Java is interpreted are typically written by people who either don't understand how Java works or don't understand what interpreted means.

话虽如此,HotSpot 会有时会解释代码 - 这是一件好事.肯定有任何应用程序的一部分(通常在启动时)只执行一次.如果您可以比 JIT 编译它更快地解释它,为什么还要为开销而烦恼呢?另一方面,我对Java 被解释"文章的体验是,这不是他们的意思:)

Having said that, HotSpot will interpret code sometimes - and that's a good thing. There are definitely portions of any application (around startup, usually) which are only executed once. If you can interpret that faster than you can JIT compile it, why bother with the overhead? On the other hand, my experience of "Java is interpreted" articles is that this isn't what they mean :)

T. J. Crowder 的观点是:是的,从 java.com 下载的 JVM 将是 HotSpot.然而,HotSpot 有两种不同的 JIT——服务器和桌面.一句话总结差异,桌面 JIT 旨在快速启动应用程序,而服务器 JIT 更侧重于高性能随着时间的推移:服务器应用程序通常运行很长时间,因此花费大量时间优化它们从长远来看是有回报的.

To take T. J. Crowder's point in: yes, the JVM downloaded from java.com will be HotSpot. There are two different JITs for HotSpot, however - server and desktop. To sum up the differences in a single sentence, the desktop JIT is designed to start apps quickly, whereas the server JIT is more focused on high performance over time: server apps typically run for a very long time, so time spent optimising them really heavily pays off in the long run.

相关文章