//java architect /
Part 1
Introduction to JIT Compilation
in Java HotSpot VM
COMMUNITY
Use the PrintCompilation switch to observe the effects of Java HotSpot VM compiling
methods during runs.
JAVA IN ACTION
BEN EVANS AND
PETER LAWREY
The last two functions are huge
topics in their own right, so in this
article we will focus purely on the
execution of code.
ABOUT US
Java HotSpot VM
works best when
it can accumulate
enough statistics
to make intelligent
decisions about
what to compile.
blog
BEN EVANS’ PHOTOGRAPH BY
JOHN BLYTHE
This article is the first article in a two-part series about Java
HotSpot VM and just-in-time (JIT)
compilation.
Java HotSpot VM is the VM
that Oracle acquired with the Sun
acquisition, and it is the VM that
forms the basis of both the Java
Virtual Machine (JVM) and the
open source OpenJDK.
Like all VMs, Java
HotSpot VM’s role is
to provide an operating environment for
bytecode. In practice,
there are three major
functions that need to
; ; Executing the
instructions and
computations that
are requested by
methods
; ; Locating, loading,
and verifying new types (that is,
class loading)
; ; Managing memory on behalf of
application code
JIT Compilation
Java HotSpot VM is a
mixed-mode VM, which means that it
starts off interpreting the bytecode, but it can (on a
method-by-method
basis) compile code
into native machine
instructions for faster
execution.
By passing the switch
-XX:+PrintCompilation,
you can see entries in
the log file that show
each method as it is
compiled.
This compilation takes place at
runtime—after the method has
already been run a number of
times. By waiting until the method
is actually being used, Java
HotSpot VM can make sophisticated decisions about how to
optimize the code as it compiles
the code.
48
ORACLE.COM/JAVAMAGAZINE /////////////////////////////////////////////// MAY/JUNE 2012