Execution Engine in JVM
- This is the central component of JVM. Execution engine is responsible to execute java class file.
- Execution engine mainly contains 2 component.
- Interpreter
- JIT Compiler
1. Interpreter:-
- It is the responsible to read byte code and interpret ( Convert ) into machine code ( Native Code ) and execute that machine code line by line.
- The problem with this interpreter is it interprets every time even some method invoked multiple times which reduce performance of the system.
- To overcome this problem sun people introduce JIT compiler in 1.1 version.
1. JIT Compiler (Just In Time Compiler):-
- The main purpose of JIT compiler is to improve performance.
- Internally JIT Compiler maintains a separates count for every method.
- Whenever JVM comes across any method call first that method will be interpreted normally by the interpreter and JIT compiler increments corresponding count variable.
- This process will be continued for every method .
- Once if any method count reaches threshold value then JIT Compiler identify that method is a repeatedly used methods. ( hot spot )
- Immediately JIT compiler compile that methods and generates corresponding machine ( native ) code.
- Next time JVM come across that method call then JVM use native code directly and execute it instead of interpreting once again. So that performance of the system will be improve.
- The Threshold count varied from JVM to JVM.
- Some advance JIT Compilers will re-compile generated native code if count reached threshold value second time. So that more optimized machine code will be generated.
- Internally Profiler, which is the part of JIT Compiler is responsible to identify hot spot.
Note:
- JVM interprets total program at least once.
- JIT Compilation is applicable only for repeatedly required method not for every method.
Java Native Interface
- JNI access mediator for java method calls and corresponding native libraries. i.e. JNI is responsible to provide information about native libraries to the JVM.
- Native Method library provide or holds native libraries information.
Related Post
JVM Architecture : Virtual Machine in Java
JVM Architecture : Java Virtual Machine
JVM memory type | Memory types in Java
Very helpful for me
ReplyDeleteGreat content.
ReplyDeletethanks
Delete