Services Provided By The Java HotSpot Virtual Machine And the JRE


The Java HotSpot Virtual Machine

The Java HotSpot virtual machine (JVM) is a program that runs Java programs. The JVM is targeted to work on specific hardware platforms and host operating systems such as Intel processors running the Microsoft Windows operating system or the PowerPC processor running Mac OS X as is shown in figure 4-14.

image from book
Figure 4-14: Java HotSpot Virtual Machine Targets Specific Hardware Platforms

As figure 4-14 illustrates, the concept of the virtual machine facilitates the write-once, run-anywhere nature of Java code. Programmers write Java programs that can run on any computing platform that implements a Java virtual machine.

Obtaining The Java HotSpot Virtual Machine

When you download the Java Software Developers Kit (SDK) it comes with a Java Runtime Environment (JRE) that includes two versions of the JVM: a client version and a server version.

Client & Server Virtual Machines

When you run Java programs with the Java command-line tool you are executing them with the client version of the JVM, which is the default virtual machine. If you specify -server as an argument to the Java command-line tool you will execute your programs using the server version of the JVM.

The difference between the two version of the JVM lies in how each version optimizes the Java bytecode execution. The client version optimizes execution primarily to support fast program startups and graphical user interfaces (GUIs). The server optimizes execution to support often-repeated code snippets.

Classic VM vs. JIT vs. HotSpot

The first several releases of the Java runtime environment shipped with what is now referred to as the classic virtual machine. The classic virtual machine ran Java bytecode in an interpreted mode, meaning each bytecode instruction was executed by the virtual machine. The virtual machine was responsible for translating each bytecode instruction into a series of virtual machine instructions that then performed the operation indicated by the bytecode instruction.

Later releases of the Java runtime environment added the services of a just-in-time (JIT) compiler to the virtual machine architecture. The purpose of the JIT is to compile bytecode instructions into processor native code that can be executed directly on the target hardware platform. The JIT provided improvements in execution speed but extracted an upfront penalty due to the compilation process since all bytecodes are compiled prior to execution.

The HotSpot virtual machine provides performance improvements over both the classic VM and the JIT. The HotSpot virtual machine utililizes the services of a bytecode profiler. As bytecode is executed by the virtual machine, an analysis is performed to determine the locations of critical bytecode sequences, or hotspots, and to then compile those bytecode hotspots into native code. Programs startup faster and, as execution progresses, also benefit from native processor execution speeds.

Java HotSpot Virtual Machine Architecture

Figure 4-15 shows a high-level Java HotSpot virtual machine architectural diagram. Bytecode loaded into and executed by the HotSpot VM is initially interpreted. As execution progresses information about the code’s execution behavior is obtained by the profiler. Frequently executed bytecode sequences are compiled into host-computer native code. Bytecode evaluation continues throughout the execution lifetime of the program.

image from book
Figure 4-15: Java HotSpot Virtual Machine Architecture

There are two versions of the adaptive compiler: one tuned specifically to compile client programs and one tuned to compile server programs. Use of the client compiler results in smaller program memory footprints and quicker program startup times. Use of the server compiler results in more stringent code optimizations to extract every ounce of performance.




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net