JAVA VIRTUAL MACHINE
1. DATA TYPES
2. DATA STORAGE
3. JAVA INSTRUCTION SET
4. EXCEPTIONS AND ERRORS
5. BINARY CLASSES
6. THE JAVA NATIVE INTERFACE
1.DATA TYPES
PRIMITIVE DATA TYPES:
 Size is platform independent
 char
 short
 double
 float
OBJECTS AND ARRAYS:
 Array object is a special and intrinsic type of object
 Elements of an array must be same primitive type or references of same type
Multi dimensional arrays
2. DATA STORAGE
There are three types of storage namely,
 Global Storage (Main memory)
 Local Storage (Methods)
 Operand Storage (Instructions)
THE STACK
The Local storage(Fixed size), Operand Storage and Method arguments are allocated on
the stack
GLOBAL MEMORY
 The main Memory architecture of Java contains,
• Method area (stores Code)
• Global storage area (stores Arrays & Objects)
 Global Memory is managed as a Heap
 Size of the Heap is platform dependent
CONSTANT POOL
 ISA of Java allows to store some constant values as immediate operands
 Constant operands may have varying size
 JVM supports a special memory area called the Constant Pool for storing immediate
operands
MEMORY HIERARCHY
It contains,
 STACK
 Constant pool
 Heap
3. JAVA INSTRUCTION SET
INSTRUCTION FORMATS
Java ISA have 5 major types as given,
Constant Pool
Stack
DATA MOVEMENT INSTRUCTIONS
There are four sets of Data movement instructions,
Set1- push constant values onto the stack (includes all loads and stores)
Set2- pops values at the top
Set3- moves values b/w local storage and operand stack
Set4- moves values b/w global storage and stack
TYPE CONVERSION
 JVM allows to convert one type of data to other type in the stack.
 It requires a Pop and Push operation
FUNCTIONAL INSTRUCTIONS
There are three types namely,
 Arithmetic
 Logical
 Shifts Requires internal conversion to binary form
In all the instructions, operands are taken from the stack and results are pushed
back to the stack
CONTROL FLOW STATEMENT (branches and jumps)
There are two sets of statements,
Set1 – compares a element in stack with zero
Set2- compares two or more elements in a stack
There will be a PC relative branching to an offset, found by concatenating the data bytes
Methods are called via invoking instructions like,
 Invokevirtual index1 index2
 Invoke interface
 Invokestatic
 ireturn
OPERAND STACK TRACKING
Regardless to the path taken by program, at any given point of time, the operand stack
must have,
 Same number of operands
 Same types of operands
 In the same order
To maintain this operand stack has to be monitored through static program analysis
4.EXCEPTION HANDLING AND ERRORS
Majorly there are two types of Exceptions,
 Default (Automatically handled)
 User defined (Needed to be handled manually)
ERRORS (Inherent)
Stackoverflowerror
Internal error
EXCEPTIONS (related to program behaviour)
NullpointerException
ArrayindexoutofboundException
IncompatibleclasschangException
EXCEPTION TABLE
FROM TO TARGET TYPE
8 12 90 Arithmetic Exception
5.BINARY CLASSES
 Any HLL Program will contain,
 Code
 Metadata
Binary classes= Code+ Metadata
Class file contains Binary classes
Advantages
All Binary classes do not have to be loaded
when the program starts
Classes can be loaded on demand
Reduces bandwidth for loading classes
6. JAVA NATIVE INTERFACE
 It helps Java code to interoperate with native compiled code
THANK YOU

Java Virtual Machine

  • 1.
    JAVA VIRTUAL MACHINE 1.DATA TYPES 2. DATA STORAGE 3. JAVA INSTRUCTION SET 4. EXCEPTIONS AND ERRORS 5. BINARY CLASSES 6. THE JAVA NATIVE INTERFACE
  • 2.
    1.DATA TYPES PRIMITIVE DATATYPES:  Size is platform independent  char  short  double  float OBJECTS AND ARRAYS:  Array object is a special and intrinsic type of object  Elements of an array must be same primitive type or references of same type Multi dimensional arrays
  • 3.
    2. DATA STORAGE Thereare three types of storage namely,  Global Storage (Main memory)  Local Storage (Methods)  Operand Storage (Instructions) THE STACK The Local storage(Fixed size), Operand Storage and Method arguments are allocated on the stack
  • 4.
    GLOBAL MEMORY  Themain Memory architecture of Java contains, • Method area (stores Code) • Global storage area (stores Arrays & Objects)  Global Memory is managed as a Heap  Size of the Heap is platform dependent CONSTANT POOL  ISA of Java allows to store some constant values as immediate operands  Constant operands may have varying size  JVM supports a special memory area called the Constant Pool for storing immediate operands
  • 5.
    MEMORY HIERARCHY It contains, STACK  Constant pool  Heap
  • 6.
    3. JAVA INSTRUCTIONSET INSTRUCTION FORMATS Java ISA have 5 major types as given, Constant Pool Stack
  • 7.
    DATA MOVEMENT INSTRUCTIONS Thereare four sets of Data movement instructions, Set1- push constant values onto the stack (includes all loads and stores) Set2- pops values at the top Set3- moves values b/w local storage and operand stack Set4- moves values b/w global storage and stack
  • 8.
    TYPE CONVERSION  JVMallows to convert one type of data to other type in the stack.  It requires a Pop and Push operation FUNCTIONAL INSTRUCTIONS There are three types namely,  Arithmetic  Logical  Shifts Requires internal conversion to binary form In all the instructions, operands are taken from the stack and results are pushed back to the stack
  • 9.
    CONTROL FLOW STATEMENT(branches and jumps) There are two sets of statements, Set1 – compares a element in stack with zero Set2- compares two or more elements in a stack There will be a PC relative branching to an offset, found by concatenating the data bytes Methods are called via invoking instructions like,  Invokevirtual index1 index2  Invoke interface  Invokestatic  ireturn
  • 10.
    OPERAND STACK TRACKING Regardlessto the path taken by program, at any given point of time, the operand stack must have,  Same number of operands  Same types of operands  In the same order To maintain this operand stack has to be monitored through static program analysis
  • 11.
    4.EXCEPTION HANDLING ANDERRORS Majorly there are two types of Exceptions,  Default (Automatically handled)  User defined (Needed to be handled manually) ERRORS (Inherent) Stackoverflowerror Internal error EXCEPTIONS (related to program behaviour) NullpointerException ArrayindexoutofboundException IncompatibleclasschangException EXCEPTION TABLE FROM TO TARGET TYPE 8 12 90 Arithmetic Exception
  • 12.
    5.BINARY CLASSES  AnyHLL Program will contain,  Code  Metadata Binary classes= Code+ Metadata Class file contains Binary classes Advantages All Binary classes do not have to be loaded when the program starts Classes can be loaded on demand Reduces bandwidth for loading classes
  • 13.
    6. JAVA NATIVEINTERFACE  It helps Java code to interoperate with native compiled code
  • 14.