Sunday, June 9, 2019

JVM Architecture in Java

In this post you will learn what is JVM and architecture of JVM. It is an abstract machine which provides run time environment in which java byte code can be executed. JVM was designed as an interpreter for byte code. JVM is the heart of entire Java Program Execution process.



Let's understand the internal architecture of JVM:


It contains class loader , memory area , execution engine 


1)class loader :


class loader is a subsystem of JVM that is used to load class files. It loads the .class file into memory.Then it verifies whether all byte code instructions are proper or not. If it finds any suspicious,then execution is rejected immediately. If instructions are proper then it allocates necessary memory to execute the program.


2)class area:     


class area is also called method area. It is a memory block,which stores the class code,code of the variables and code of the methods in the java program.


3) Heap :  


It is the run time data area in which objects are allocated that means where objects are created. Whenever JVM loads a class,a method and a heap area are immediately created in it.


4) stack : 


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.


5) Program Counter :  


PC (program counter) register. It contains the address of the Java virtual machine instruction currently being executed. In other words, PC contains memory address of the instructions of the methods.


6)Native method stack: 


It contains all the native methods used in the application. Native methods are nothing but C/C++ functions. To execute native methods,generally native method libraries are required. These header files are located and connected to JVM by a program called Native method interface.




7) Execution Engine : 


Execution Engine Contains interpreter and JIT compiler


Interpreter:  It is used to converting the byte code instructions into machine code so that the processor will execute them. Most of the JVM implementations use both the interpreter and JIT compiler simultaneously to covert byte code .


Just-In-Time(JIT) compiler:It is used to improve the performance.JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.Here the term ?compiler? refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU.

No comments:

Post a Comment

High Paying Jobs after Learning Python

Everyone knows Python is one of the most demand Programming Language. It is a computer programming language to build web applications and sc...