Understanding How Just in Time Compiler WorksThe source code that is written is compiled to an intermediate code called the bytecode (in Java) or the Common Intermediate Language (in .Net). Either the Java Virtual Machine or the Common Language Runtime (CLR) is used to compile the code to the intermediate form. When you execute the program, i.e. the intermediate code, the Just-In-Time (JIT) compiler comes into the picture. The job of the JIT compiler is to convert intermediate code in to the machine code or the native code for execution. With the JIT the code can be optimized to a particular operating system. This is one of the advantages of going for such code execution. The advantage of converting the source code to the intermediate code is that it can run on any operating system provided you have the JIT for that operating system. This gives the portability to your code. In .Net the CLR which also has the JIT is used to convert the CIL code into the native code to be processed by the machine. It is also possible to convert the source code to the native code directly by bypassing the tasks done by the JIT. This helps to reduce the load in the JIT. This is done in some cases.
|