Friday, 8 July 2016

Java Virtual Machine (JVM) architecture

Java Virtual Machine (JVM) architecture
JVM's class loader sub system performs 3 tasks
1. It loads .class file into memory.
2. It verifies byte code instructions.
3. It allots memory required for the program.
Run time data area:
This is the memory resource used by JVM and it is divided into 5 parts
1. Method area: Method area stores class code and method code such as runtime constant pool, field and method data, the code for methods.

2. Heap: Objects are created on heap.

3. Java stacks: Java Stack stores frames. It holds local variables and partial results, and plays a part in method invocation and return. Each thread has a private JVM stack, created at the same time as thread. A new frame is created each time a method is invoked. A frame is destroyed when its method invocation completes.

4. Program counter registers: It contains the address of the Java virtual machine instruction currently being executed by microprocessor.

5. Native method stacks: The native method stacks are places where native methods (for example, C language programs) are executed.

Execution engine:
The byte code that is assigned to the runtime data areas in the JVM via class loader is executed by the execution engine. The execution engine reads the Java Byte code in the unit of instruction. It is like a CPU executing the machine command one by one.

Execution engine contains interpreter and JIT compiler, which covert byte code into machine code. JVM uses optimization technique to decide which part to be interpreted and which part to be used with JIT compiler. The HotSpot represents the block of code executed by JIT compiler.

Native method interface:
Native method interface is a program that connects native methods libraries (C header files) with JVM for executing native methods.

Native method library:
It holds the native libraries information.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...