Jikes RVM and Java Operating Systems

36
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 [email protected]

description

The UK Memory Management Network Workshop, November 9 th 2006 Dr. Ian Rogers, Research Fellow, The University of Manchester [email protected]. Jikes RVM and Java Operating Systems. Presentation Outline. A bit about the Jikes RVM A view of a Jikes RVM Operating System - PowerPoint PPT Presentation

Transcript of Jikes RVM and Java Operating Systems

Page 1: Jikes RVM and Java Operating Systems

Jikes RVM and Java Operating Systems

The UK Memory Management Network Workshop, November 9th 2006

Dr. Ian Rogers,Research Fellow,

The University of [email protected]

Page 2: Jikes RVM and Java Operating Systems

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

Page 3: Jikes RVM and Java Operating Systems

The Jikes RVM Overview of the adaptive compilation system:

Page 4: Jikes RVM and Java Operating Systems

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

Very simple code generation:

iload_0

iload_1

iadd

istore_0

Load t0, [locals + 0]

Store [stack+0], t0

Load t0, [locals + 4]

Store [stack+4], t0

Load t0, [stack+0]

Load t1, [stack+4]

Add t0, t0, t1

Store [stack+0], t0

Load t0, [stack+0]

Store [locals + 0], t0

Page 5: Jikes RVM and Java Operating Systems

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

Page 6: Jikes RVM and Java Operating Systems

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

Page 7: Jikes RVM and Java Operating Systems

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

Page 8: Jikes RVM and Java Operating Systems

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

Page 9: Jikes RVM and Java Operating Systems

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

Page 10: Jikes RVM and Java Operating Systems

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

Page 11: Jikes RVM and Java Operating Systems

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

Page 12: Jikes RVM and Java Operating Systems

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

Page 13: Jikes RVM and Java Operating Systems

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)

Page 14: Jikes RVM and Java Operating Systems

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 sub-expression elimination

SSA in HIR: load/store elimination, redundant branch elimination, global constant propagation, loop versioning

AOS framework

Page 15: Jikes RVM and Java Operating Systems

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

Page 16: Jikes RVM and Java Operating Systems

The optimizing compiler MIR: instruction selection, register allocation,

scheduling, simplification, branch optimizations

Fix-ups for runtime

Page 17: Jikes RVM and Java Operating Systems

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

Page 18: Jikes RVM and Java Operating Systems

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

Page 19: Jikes RVM and Java Operating Systems

Operating Systems

Overview of our work

Page 20: Jikes RVM and Java Operating Systems

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

Page 21: Jikes RVM and Java Operating Systems

Early Performance Results

Page 22: Jikes RVM and Java Operating Systems

Early Performance Results

Page 23: Jikes RVM and Java Operating Systems

PearColator

Page 24: Jikes RVM and Java Operating Systems

PearColator

Page 25: Jikes RVM and Java Operating Systems

PearColator

Decoder:

Disassembler

Interpreter (Java threaded)

Translator

Generic components:

Loaders

System calls

Memory

Page 26: Jikes RVM and Java Operating Systems

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

Page 27: Jikes RVM and Java Operating Systems

Loop Parallelization in JaVM(Jikes RVM for JAMAICA)

Page 28: Jikes RVM and Java Operating Systems

Fine grain threads slow things down on x86

Page 29: Jikes RVM and Java Operating Systems

But with lightweight hardware threads…

Page 30: Jikes RVM and Java Operating Systems

Adaptive parallelization optimisation Adapt code by:

Recompilation

Modifying parameters Amount of work created

Switching policies Constant number of threads vs. recursive thread

distribution

Page 31: Jikes RVM and Java Operating Systems

Speed up over parallelization by adaptation

Page 32: Jikes RVM and Java Operating Systems

Speed up over parallelization by adaptation

Page 33: Jikes RVM and Java Operating Systems

Speed up over parallelization by adaptation

Page 34: Jikes RVM and Java Operating Systems

Speed up over parallelization by adaptation

Page 35: Jikes RVM and Java Operating Systems

Potpourri Multithreaded compilation for the Jikes RVM

Interpreter within the Jikes RVM (written in Java)

Debugger (JDWP), Eclipsification and other enhancements

Page 36: Jikes RVM and Java Operating Systems

Thanks!

Any questions?

Find out more at: http://www.cs.manchester.ac.uk/apt/projects/jamaica

http://jikesrvm.sourceforge.net/