What does a just-in-time (JIT) compiler do?

后端 未结 18 1716
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 12:42

What does a JIT compiler specifically do as opposed to a non-JIT compiler? Can someone give a succinct and easy to understand description?

18条回答
  •  囚心锁ツ
    2020-11-22 12:57

    As other have mentioned

    JIT stands for Just-in-Time which means that code gets compiled when it is needed, not before runtime.

    Just to add a point to above discussion JVM maintains a count as of how many time a function is executed. If this count exceeds a predefined limit JIT compiles the code into machine language which can directly be executed by the processor (unlike the normal case in which javac compile the code into bytecode and then java - the interpreter interprets this bytecode line by line converts it into machine code and executes).

    Also next time this function is calculated same compiled code is executed again unlike normal interpretation in which the code is interpreted again line by line. This makes execution faster.

提交回复
热议问题