What does a JIT compiler do?

后端 未结 9 1283
孤街浪徒
孤街浪徒 2020-12-13 00:28

I was just watching the Google IO videos and they talked about the JIT compiler that they included in the android. They showed a demo of performance improvements thanks to t

相关标签:
9条回答
  • 2020-12-13 01:16

    JIT is short for "just in time". A JIT compiler compiles code, which is often in an intermediate language like Java bytecode or Microsoft IL, into native, executable code, and it does this at the moment that the code is called. So until the code is called, it exists only in portable, non-machine specific bytecode or IL, and then when it is called, native code is generated (which is then re-used on subsequent calls).

    0 讨论(0)
  • 2020-12-13 01:19

    Doubt Sir if javac is a Java compiler its role is to convert source code to byte code means .Class and then .class (byte code) is interpreted by Java interpretor (Java) means by JVM and JIT is the part of JVM then what is its actual work

    0 讨论(0)
  • 2020-12-13 01:20

    Pretty nice explanation:

    "In practice, methods are not compiled the first time they are called. For each method, the JVM maintains a call count, which is incremented every time the method is called. The JVM interprets a method until its call count exceeds a JIT compilation threshold. Therefore, often-used methods are compiled soon after the JVM has started, and less-used methods are compiled much later, or not at all. The JIT compilation threshold helps the JVM start quickly and still have improved performance. The threshold has been carefully selected to obtain an optimal balance between startup times and long term performance.

    After a method is compiled, its call count is reset to zero and subsequent calls to the method continue to increment its count. When the call count of a method reaches a JIT recompilation threshold, the JIT compiler compiles it a second time, applying a larger selection of optimizations than on the previous compilation. This process is repeated until the maximum optimization level is reached. The busiest methods of a Java program are always optimized most aggressively, maximizing the performance benefits of using the JIT compiler. The JIT compiler can also measure operational data at run time, and use that data to improve the quality of further recompilations.

    The JIT compiler can be disabled, in which case the entire Java program will be interpreted. Disabling the JIT compiler is not recommended except to diagnose or work around JIT compilation problems."

    Source: https://www-01.ibm.com/support/knowledgecenter/SSYKE2_7.0.0/com.ibm.java.aix.71.doc/diag/understanding/jit_overview.html

    0 讨论(0)
提交回复
热议问题