有和没有JIT的JVM之间的区别 [英] Difference between a JVM with and without JIT

查看:113
本文介绍了有和没有JIT的JVM之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我指的是Oracle的以下文档:

I am referring to the below document by Oracle:

http://docs.oracle .com/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/underst_jit.html#wp1080014

在"1. JRockit JVM运行JIT编译"部分中提到,对于没有JIT的JVM,JIT JVM具有更多的启动时间和更少的执行时间.

It is mentioned in the "1. The JRockit JVM Runs JIT Compilation " section that the JIT JVM has more startup time and less execution time and vice-versa for JVMs without JIT.

我很困惑,因为据我所知,JIT根据程序的执行来编译代码,因此使编译速度更快.而且代码将得到优化,因此执行时间也将很快.

I am confused because as per my knowledge, JIT compiles the code as per the execution of program therefore making the compilation fast. And the code will be optimized so execution time will be fast as well.

在这一点上他们想表达什么?我不太了解.

What do they want to signify with this point? I am not understanding it properly.

推荐答案

基本上,他们说的是JIT编译需要时间.实际上,HotSpot会对代码进行两次编译-首先对代码进行优化,然后对常用部分进行优化.

Basically what they are saying that JIT compilation takes time. HotSpot actually compiles the code twice - unoptimized first, then with optimization for frequently used parts.

因此,在您的程序启动时,根据VM类型,它首先在解释模式下运行字节码,或者等待其编译并切换到编译版本,然后,如果该代码被频繁使用,则通过更多优化再次对其进行编译.所有这些都需要资源和时间,因此启动速度较慢,但​​是在程序预热后,它可以快速运行.

So when your program starts, depending on VM type, it first runs the bytecode in interpreted mode or waits for it to compile and switches to compiled version, then if the code is used frequently, compiling it again with more optimizations. It all takes resources and time, so startup is slower, but when the program is warmed up, it runs fast.

在解释模式下,如果没有JIT,VM会立即开始解释代码,因此启动速度更快,但性能却差得多.

In interpreted mode, without JIT, the VM just starts interpreting the code right away, so it starts faster, but with much worse performance.

这篇关于有和没有JIT的JVM之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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