The high performance implementation of Java Virtual Machines (JVM) and Just
-In-Time (JIT) compilers is directed toward adaptive compilation optimizati
ons on the basis of online runtime profile information. This paper describe
s the design and implementation of a dynamic optimization framework in a pr
oduction-level Java JIT compiler. Our approach is to employ a mixed mode in
terpreter and a three level optimizing compiler, supporting quick, full, an
d special optimization, each of which has a different set of tradeoffs betw
een compilation overhead and execution speed. A lightweight sampling profil
er operates continuously during the entire program's execution. When necess
ary, detailed information on runtime behavior is collected by dynamically g
enerating instrumentation code which can be installed to and uninstalled fr
om the specified recompilation target code. Value profiling with this instr
umentation mechanism allows fully automatic code specialization to be perfo
rmed on the basis of specific parameter values or global data at the highes
t optimization level. The experimental results show that our approach offer
s high performance and a low code expansion ratio in both program startup a
nd steady state measurements in comparison to the compile-only approach, an
d that the code specialization can also contribute modest performance impro
vements.