Jikes RVM and Java Operating Systems The UK

  • Slides: 36
Download presentation
Jikes RVM and Java Operating Systems The UK Memory Management Network Workshop, November 9

Jikes RVM and Java Operating Systems The UK Memory Management Network Workshop, November 9 th 2006 Dr. Ian Rogers, Research Fellow, The University of Manchester ian. rogers@manchester. ac. uk

Presentation Outline A bit about the Jikes RVM A view of a Jikes RVM

Presentation Outline A bit about the Jikes RVM A view of a Jikes RVM Operating System Some early results Other work: Parallelization Adaptive parallelization optimization Potpourri

The Jikes RVM Overview of the adaptive compilation system:

The Jikes RVM Overview of the adaptive compilation system:

The baseline compiler Used to compile code the first time it’s invoked Very simple

The baseline compiler Used to compile code the first time it’s invoked Very simple code generation: Load t 0, [locals + 0] iload_0 Store [stack+0], t 0 Load t 0, [locals + 4] iload_1 Store [stack+4], t 0 iadd Load t 0, [stack+0] istore_0 Load t 1, [stack+4] Add t 0, t 1 Store [stack+0], t 0 Load t 0, [stack+0] Store [locals + 0], t 0

The baseline compiler Pros: Easy to port – just write emit code for each

The baseline compiler Pros: Easy to port – just write emit code for each bytecode Minimal work needed to port runtime and garbage collector Fast compilation speed Cons: Low performance

The boot image Hijack the view of memory (mapping of objects to addresses) Compile

The boot image Hijack the view of memory (mapping of objects to addresses) Compile list of primordial classes Write view of memory to disk (the boot image) The boot image runner loads the disk image and branches into the code block for VM. boot

The boot image Problems: Difference of views between: Jikes RVM Classpath Bootstrap JVM Fix

The boot image Problems: Difference of views between: Jikes RVM Classpath Bootstrap JVM Fix by writing null to some fields (new oracle feature appearing in post 2. 4. 6 Jikes RVM) Jikes RVM runtime needs to keep pace with Classpath

The runtime M-of-N threading Thread yields are GC points Native code can deadlock the

The runtime M-of-N threading Thread yields are GC points Native code can deadlock the VM JNI written in Java with knowledge of C layout Classpath interface written in Java

The Jikes RVM Overview of the adaptive compilation system: Methods recompiled based on their

The Jikes RVM Overview of the adaptive compilation system: Methods recompiled based on their predicted future execution time and the time taken to compile Some optimisation levels are skipped

The optimizing compiler Structured from compiler phases based on HIR, LIR and MIR phases

The optimizing compiler Structured from compiler phases based on HIR, LIR and MIR phases from Muchnick IR object holds instructions in linked lists in a control flow graph Instructions are an object with: One operator Variable number of use operands Variable number of def operands Support for def/use operands Some operands and operators are virtual

The optimizing compiler HIR: Infinite registers Operators correspond to bytecodes SSA phase performed LIR:

The optimizing compiler HIR: Infinite registers Operators correspond to bytecodes SSA phase performed LIR: Load/store operators Java specific operators expanded GC barrier operators SSA phase performed MIR: Fixed number of registers Machine operators

The optimizing compiler Factored control graph: Don’t terminate blocks on Potentially Exceptioning Instructions (PEIs)

The optimizing compiler Factored control graph: Don’t terminate blocks on Potentially Exceptioning Instructions (PEIs) Bound check Null check Checks define guards which are used by: Putfield, getfield, array load/store, invokevirtual Eliminating guards requires propagation of use

The optimizing compiler Java – can we capture and benefit from strong type information?

The optimizing compiler Java – can we capture and benefit from strong type information? Extended Array SSA: Single assignment Array – Fortran style - a float and an int array can’t alias Extended – different fields and different objects can’t alias Phi operator – for registers, heaps and exceptions Pi operator – define points where knowledge of a variable is exposed. E. g. A = new int[100], later uses of A can know the array length is 100 (ABCD)

The optimizing compiler HIR: Simplification, tail recursion elimination, estimate execution frequencies, loop unrolling, branch

The optimizing compiler HIR: Simplification, tail recursion elimination, estimate execution frequencies, loop unrolling, branch optimizations, (simple) escape analysis, local copy and constant propagation, local common subexpression elimination SSA in HIR: load/store elimination, redundant branch elimination, global constant propagation, loop versioning AOS framework

The optimizing compiler LIR: Simplification, estimate execution frequencies, basic block reordering, branch optimizations, (simple)

The optimizing compiler LIR: Simplification, estimate execution frequencies, basic block reordering, branch optimizations, (simple) escape analysis, local copy and constant propagation, local common sub-expression elimination SSA in LIR: global code placement, live range splitting AOS framework

The optimizing compiler MIR: instruction selection, register allocation, scheduling, simplification, branch optimizations Fix-ups for

The optimizing compiler MIR: instruction selection, register allocation, scheduling, simplification, branch optimizations Fix-ups for runtime

Speculative Optimisations Often in a JVM there’s potentially not a complete picture, in particular

Speculative Optimisations Often in a JVM there’s potentially not a complete picture, in particular for dynamic class loading On-stack replacement allows optimisation to proceed with a get out clause On-stack replacement is a virtual Jikes RVM instruction

Applications of on-stack replacement Safe invalidation for speculative optimisation Class hierarchy-based inlining Deferred compilation

Applications of on-stack replacement Safe invalidation for speculative optimisation Class hierarchy-based inlining Deferred compilation Don’t compile uncommon cases Improve dataflow optimization and improve compile time Debug optimised code via dynamic deoptimisaton At break-point, deoptimize activation to recover program state Runtime optimization of long-running activities Promote long-running loops to higher optimisation levels

Operating Systems Overview of our work

Operating Systems Overview of our work

Work done Addition of Java 1. 5 features to the Jikes RVM Support in

Work done Addition of Java 1. 5 features to the Jikes RVM Support in the Jikes RVM for isolation Made the Jikes RVM and JNode runtimes compatible

Early Performance Results

Early Performance Results

Early Performance Results

Early Performance Results

Pear. Colator

Pear. Colator

Pear. Colator

Pear. Colator

Pear. Colator Decoder: Disassembler Interpreter (Java threaded) Translator Generic components: Loaders System calls Memory

Pear. Colator Decoder: Disassembler Interpreter (Java threaded) Translator Generic components: Loaders System calls Memory

Other work • Loop parallelization: – Using extended array SSA form we have a

Other work • Loop parallelization: – Using extended array SSA form we have a lot of dependence information already – Loop parallelization requires analysis of loops and loop carried dependencies • Currently parallelize loops with scalars and arrays with affine indices • Fine grain threads not suited to current architectures

Loop Parallelization in Ja. VM (Jikes RVM for JAMAICA)

Loop Parallelization in Ja. VM (Jikes RVM for JAMAICA)

Fine grain threads slow things down on x 86

Fine grain threads slow things down on x 86

But with lightweight hardware threads…

But with lightweight hardware threads…

Adaptive parallelization optimisation Adapt code by: Recompilation Modifying parameters Amount of work created Switching

Adaptive parallelization optimisation Adapt code by: Recompilation Modifying parameters Amount of work created Switching policies Constant number of threads vs. recursive thread distribution

Speed up over parallelization by adaptation

Speed up over parallelization by adaptation

Speed up over parallelization by adaptation

Speed up over parallelization by adaptation

Speed up over parallelization by adaptation

Speed up over parallelization by adaptation

Speed up over parallelization by adaptation

Speed up over parallelization by adaptation

Potpourri Multithreaded compilation for the Jikes RVM Interpreter within the Jikes RVM (written in

Potpourri Multithreaded compilation for the Jikes RVM Interpreter within the Jikes RVM (written in Java) Debugger (JDWP), Eclipsification and other enhancements

Thanks! Any questions? Find out more at: http: //www. cs. manchester. ac. uk/apt/projects/jamaica http:

Thanks! Any questions? Find out more at: http: //www. cs. manchester. ac. uk/apt/projects/jamaica http: //jikesrvm. sourceforge. net/