JAVA Processors and JIT JAVA Processors and JIT SchedulingScheduling
Overview & LiteratureOverview & Literature
Formulation of the problemFormulation of the problem JAVA introductionJAVA introduction Description of CaffeineDescription of Caffeine
Literature: “Java Bytecode to Native Literature: “Java Bytecode to Native Code Translation: The Caffeine Prototype Code Translation: The Caffeine Prototype and Preliminary Results” written by and Preliminary Results” written by Hsieh, Gyllenhaal and Hwu, 1996Hsieh, Gyllenhaal and Hwu, 1996
Formulation of the Formulation of the problemproblem
JAVA is a very well language which JAVA is a very well language which runs on different platforms, but runs on different platforms, but executing an application is much executing an application is much slower than that it is written in C.slower than that it is written in C.
The goal is to achieve a faster The goal is to achieve a faster translation from JAVA-bytecode to translation from JAVA-bytecode to native code.native code.
Intro: JAVAIntro: JAVA
import java.awg.Frame;
class GraphWindowextends Frame {
.
.
.
CA FE BA BE 0003 00 2D
.
.
.
.
.
JAVACompiler
JAVA Sourcecode JAVA Bytecodes
Intro: JAVAIntro: JAVA
In a classfile
Medium (e.g. internet)
* Classloader* Bytecode verificator* JIT Compiler
Pentium / PowerPC Alpha / …native code
CA FE BA BE 0003 00 2D
.
.
.
.
.
JAVA Bytecodes
OS-dependent
Machine-dependent
* Classloader* Bytecode verificator* Interpreter (JVM)
Pentium / PowerPC Alpha / …native code
OS-dependent
Machine-dependent
JAVA: CaffeineJAVA: Caffeine
Bytecode
OptimizedMachine-Specific
IR
Optimized Native Code
OptimizedMachine-Indep.
IR
Machine-Indep.IR (Lcode)
JAVAIR
IR = Instruction Representation
Medium
Optimizing native code translators
Caffeine: OverviewCaffeine: Overview
Stack to Virtual Register MappingStack to Virtual Register Mapping Stack AnalysisStack Analysis Run-time Memory OrganisationRun-time Memory Organisation
Stack to Virtual Register Stack to Virtual Register Mapping (1)Mapping (1)
Stack Computation ModelStack Computation Model– operand stackoperand stack– local variable arraylocal variable array– eliminating some loads and storeseliminating some loads and stores
Register MappingRegister Mapping– assign stack locations to unique virtual assign stack locations to unique virtual
register numbersregister numbers– allocate virtual registers to physical regs.allocate virtual registers to physical regs.
Improvement: 2.8 times faster than JITImprovement: 2.8 times faster than JIT
Stack to Virtual Register Stack to Virtual Register Mapping (2)Mapping (2)
Example
StackOperations
Translatedcode withoutregistermapping
Translatedcode withregistermapping
After copyprop. & deadcode removal
Push APush BAdd
Push APush BR2 <- pop (B)R1 <- pop (A)R3 <- R1 + R2Push R3
R1 <- AR2 <- BR1 <- R1 add R2
R1 <- A add B
Stack AnalysisStack Analysis
If #pushes == #pops in a path of If #pushes == #pops in a path of blocks ---> register mapping blocks ---> register mapping possiblepossible
Else: use the standard stack-model Else: use the standard stack-model (thus no optimization possible)(thus no optimization possible)
Take live range (LR) of stack Take live range (LR) of stack locations into accountlocations into account
Improvement: 55%Improvement: 55%
Run-time Memory Run-time Memory OrganisationOrganisation
JAVA has two types of objects:JAVA has two types of objects:– classclass objects objects– arrayarray objects objects
Interpreter: there is an 8-byte Interpreter: there is an 8-byte handler between object and datahandler between object and data
Caffeine: no handlerCaffeine: no handler Improvement: 7%Improvement: 7%
Conclusion / ComparisonConclusion / Comparison
0
10
20
30
40
50
60
70
Overall Benchmark
SUN (interpreter)
Symantec (J IT)
Caffeine (Register Mapping)
Caffeine (Stack Analysis)
Caffeine (Memory Organisation)
Percentage of C Performance
Caffeine does improve the performance of JAVA-programs, and it is able to reach the goal
to make translating JAVAbytecode to native code faster.