Professional Documents
Culture Documents
MASSLAB
Contents
Java Virtual Machine
Runtime data areas Java instruction set pros & cons
Just-In-Time Compiler(JITC)
Architecture System Overview Multi-level recompilation Cost/Benefit model Profiling heuristics performance
Conclusion
JVM
execution engine
native method invocation
Host OS
JVM stack
each JVM thread has its own stacks invoke method -> new frame is allocated on stack store operand stack, local variables, state variables
Operand Stack
used to pass arguments receive return results interpreter is responsible for transferring return result to the caller operand stack
Heap
one heap per one JVM created on VM start-up all class instance and arrays are allocated in heap
Constant pool
analogous to symbol table a collection of all symbolic data need by a class each constant pool is private to its class
opcode
opcode
index1 data
index2
Type conversion
convert one type of item on the stack to another ex) i2f, i2d, i2l, f2i, f2l
Functional instr.
operands are always taken from the stack and results are placed on the stack ex) iadd, iand
Cons
Bytecode interpret at runtime Low performance
JITC vs AOTC
Just-In-Time Compiler (JITC)
Compile bytecode to machine code at runtime Compile time are included in execute time make the maximum use of program execution information require some CPU and Memory resources ex) Jikes RVM, DSVM
Jikes RVM
Controller
Orchestrates and conducts the other components of AOS system
build an compilation plan using profiling data to improve their performance
Recompilation Subsystem
Recompilation occur
in separate threads from the application
Multi-Level Recompilation
Level 0 optimizations performed on-the-fly during the translation from bytecodes to the HIR
Register renaming for local variable, dead-code elimination
flow-insensitive optimizations
copy and constant propagation, dead-assignment elimination
Scalar replacement of aggregates and short arrays Level 2 SSA-based flow sensitive optimization
SSA-PRE, SSA-CSE
Cost/Benefit model
Assumptions Sample data determines how long a method has executed Method will execute as much in the future as it has in the past Compilation cost and speedup are offline average
Cost/Benefit model
Definitions cur, current optimization level for method m T(j), expected future execution time at optimization level j C(j), compilation cost at optimization level j Choose j > cur that minimizes T(j) + C(j) If T(j) + C(j) < T(cur) recompile at optimization level j.
Estimated Cost/Benefit
Profiling heuristics
How to find candidates for optimization
counters call stack sampling
Counters
Insert method-specific counter on method entry and loop back edge. Optimize method that surpasses threshold. Very popular approach : Self, Hotspot, DSVM Issues
Overhead for incrementing counter can be significant simple, but hard to tune
Performances
Conclusion
Java Virtual Machine has good features, but its performance is low. We can overcome low performance of JVM with Just-In-Time Compiler.