19 August 2013

JVM internals: VM types

Like the Java programming language JVM operated two kinds of types: primitive and reference types.

All type checking performed by compiler, and does not have to be done by JVM.

VM primitive data types:
  • numeric
    • byte - 8-bit signed / [-128;127];
    • short - 16-bit signed [-32768; 32767];
    • char - 16-bit unsigned [0; 65535];
    • int - 32-bit signed [-2147483648; 2147483647];
    • float - 32-bit precision (IEEE 754 standard);
    • long - 64-bit signed [-;];
    • double - 64-bit precision (IEEE 754 standard).
  • boolean - JVM provides limited support to boolean data type. There are no VM instructions solely dedicated to operation on boolean type. Expressions to operate boolean type are compiled to use int data type (int value 1 - true, int value 0 - false). JVM directly supports boolean arrays as byte arrays (so it using 8 bytes per boolean value and bytecode instructions that are also suitable for byte arrays):
    • newarray - creates boolean array;
    • baload - access to boolean array;
    • bastore - modify boolean array.
  • returnAddress - returns pointer to the opcodes of JVM instructions. The data type used by JVM instructions: jsr, jsr_w, ret. Anlilke other JVM datatypes, returnAddress doesn't correspond to any Java programming language type and cannot be modified by running program.
VM reference types:
  • class types;
  • interface types;
  • array types.
A VM reference may be null reference - reference to no object and default value of any reference. Null reference initialy in runtime has no type, but may be cast to any reference type. 

No comments:

Post a Comment