All languages compilers translate source code into machine code for a specific computer. Java compiler also does the same thing. Java compiler produces am intermediate code known as bytecode for a machine that does not exist. This machine is called the java virtual machine and it exist only inside the computer memory.
Process of compilation |
Java Virtual Machine(JVM) is the heart of entire java program execution process. It is responsible for taking the .class file and converting each byte code instruction into the machine language instructions that can be executed by the microprocessor.
Java Virtual Machine |
- First of all the .java program is converted into a .class file consisting of byte code instructions by the java compiler.
- In JVM, there is a module ( or program) called class loader sub system, which performs the following functions.
- First of all, it loads the .class file into memory.
- Then it verifies whether all byte code instructions are proper or not. If it finds any instruction suspicious, the execution is rejected immediately.
- If the byte instructions are proper, then it allocate necessary memory to execute the program.
Method Area:
Used to store class code, code of variables, and code of the java program.Heap Area:
This is the place where objects are created. Whenever JVM loads a class, a method and a heap are are immediately created in it.Java Stack:
Method code is stored on method area. But while running a method, it needs some more memory to store the data data and results. This memory is allotted on java stacks. So, Java stack are memory areas where java methods are executed. While executing methods, a separate frame will be created in the java stack, where the method is executed.
Program Counter Registers:
These are the registers, which contain memory address of the instructions of the methods,. If there are 4 methods, 4 PC registers while be used to track the instructions of the methods.Native method stacks:
Java methods are executed on java stack. Similarly native methods are executed on native method area.
The execution engine contains interpreter and JIT compiler, which are responsible for converting the byte code instructions into machine code so that the processor while execute them. Most of the JVM implementation use both the interpreter and JIT compiler simultaneously to convert the byte code. This technique is also called adaptive optimizer.
0 comments :
Post a Comment
Note: only a member of this blog may post a comment.