java_2
java_2
Session-3
Operand Stack – Each frame contains a last-in-first-out (LIFO) stack known as its operand stack.
This acts as a runtime workspace to perform any intermediate operations. The maximum depth
of this stack is determined at compile-time.
Frame Data – All symbols corresponding to the method are stored here. This also stores the
catch block information in case of exceptions.
Execution Engine
Once the bytecode has been loaded into the main memory, and details are available in the
runtime data area, the next step is to run the program. The Execution Engine handles this
by executing the code present in each class.
However, before executing the program, the bytecode needs to be converted into
machine language instructions. The JVM can use an interpreter or a JIT compiler for the
execution engine.
Interpreter
The interpreter reads and
executes the bytecode
instructions line by line.
Due to the line by line JIT Compiler
execution, the interpreter is The JIT Compiler overcomes the disadvantage of the
comparatively slower. interpreter. The Execution Engine first uses the interpreter to
execute the byte code, but when it finds some repeated code,
Another disadvantage of it uses the JIT compiler.
the interpreter is that when
a method is called multiple The JIT compiler then compiles the entire bytecode and
times, every time a new changes it to native machine code. This native machine code is
interpretation is required.. used directly for repeated method calls, which improves the
performance of the system.
Garbage Collector
The Garbage Collector (GC)
collects and removes
unreferenced objects from
the heap area. It is the
process of reclaiming the Java Native Interface (JNI)
runtime unused memory JNI acts as a bridge for permitting the supporting packages for
automatically by destroying other programming languages such as C, C++, and so on. This is
them. especially helpful in cases where you need to write code that is
not entirely supported by Java, like some platform specific
Garbage collection makes features that can only be written in C.
Java memory efficient
because it removes the Native Method Libraries
unreferenced objects from Native Method Libraries are libraries that are written in other
heap memory and makes programming languages, such as C, C++, and assembly. These
free space for new objects. libraries are usually present in the form of .dll or .so files. These
native libraries can be loaded through JNI.
- Santosh Katti, Department of Computer Applications, PESU