Java Byte Code, Interpreter and JIT

Generally, when a program is compiled to an intermediate level and then interpreted by a virtual machine, it runs slower than it would run if compiled to machine code.
However, with Java, the differential between the two is not important for general purpose. Because byte-codes are highly optimized, the use of byte-code enables the Java Virtual Machine to execute programs much faster than you might expect.
Java is also designed as an interpreted language, so java does not have anything to stop (on the fly) compilation of byte-code into machine code, to improve performance.
For this reason, the HotSpot technology was introduced after Java’s initial release.
HotSpot provides a Just In Time (JIT) compiler for bytecode. When a JIT compiler is part of the JVM, selected set of bytecode are compiled into executable code in real time, on a piece, by, piece, demand basis. 
It is important to understand that it is not practical to compile a whole Java program into machine code all at once, because Java performs several run-time checks that can be done only at run time. Instead, a JIT compiler compiles code as it is needed, during execution. Furthermore, not whole the bytecode of a programme are compiled, only those that will benefit from compilation. The remaining code is simply interpreted line by line. 
However, the JIT approach still yields a significant performance increment. Even when dynamic compilation is applied to bytecode, the portability and safety features are still apply, because the Java Virtual Machine is still in charge of the execution environment.



Comments

Post a Comment

Popular posts from this blog

Connect Huawei Modem Linux - USB Modeswitch

Department for Persons Registration of Sri Lanka