Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Virtual Machine Case Study on the Design of JikesRVM.

Similar presentations


Presentation on theme: "Java Virtual Machine Case Study on the Design of JikesRVM."— Presentation transcript:

1 Java Virtual Machine Case Study on the Design of JikesRVM

2 JVM JVM runs Java application in bytecode –Other sources can also be compiled to bytecode –JVM is a process virtual machine Hardware support exists –Execution by Interpreter JIT (just-in-time) compilation: HotSpot, JikesRVM

3 JikesRVM Originally Jalapeno A research compiler by IBM written mostly in Java –Why Java? Software engineering Bridging gap between runtime servers and user code Most used research JVM in academics

4 Design Goals Exploitation of high-performance processors SMP scalability Thread limits Continuous availability Rapid response Library usage Graceful degradation

5 Object Model and Memory Layout Field and array access should be fast Virtual method dispatch should be fast Null pointer checks should be performed by the hardware Other Java operations should not be prohibitively slow

6 Array and Scalar Object Layout

7 Object Header TIB (type information block) –Reference to the object’s class –An array of objects Class Compiled methods –Array of instructions Status –Locking field –Hashing field –Memory management

8 JTOC (JikesRVM Table of Contents)

9 Method Invocation Stack

10 Runtime Subsystem Exceptions Dynamic class loading Input/Output Reflection

11 Exceptions –Null pointer exception by hardware –Out of bound –Divided by zero –Method invocation stack overflow –Software-generated exceptions Handling –Caught by a C interrupt handler and pass to deliverException method –deliverException collects stack trace, transfer control to “try” block if exists

12 Dynamic Class Loading Java can load classes during execution In JikesRVM, when a class not loaded is referred –Generate code to load, resolve and instantiate the class before execution Subtleties for address resolution

13 Input and Output Use OS’ services through system routine calls

14 Reflection Reflection: runtime access to fields and runtime invocation of methods –For fields, JVM keep tracks type information –For method invocation, need to match the signature public int incrementField(String name, Object obj) throws... { Field field = obj.getClass().getDeclaredField(name); int value = field.getInt(obj) + 1; field.setInt(obj, value); return value; }

15 Threads and Synchronization JikesRVM implemenst virtual processor as pthreads –Java threads are multiplexed on virtual processors –One virtual processor for each physical processor Locks –Processor lock ( a java object with a field denting owner) –Thin lock: use lock field on an object header –Thick lock: object level lock with a queue of threads waiting for thelock

16 Memory Management Java is an automatic memory managed language Memory management is most critical for Java –We will spend several weeks on this topic In JikesRVM (obsolete) –A family of memory managers

17 Choices Copying or non-copying collectors Incremental/concurrent or stop-the-world Generational collectors –Most objects die young –Minor collection, major collection –Remember set

18 Compiler JikesRVM provides three compilers –Baseline compiler More of an interpreter Easy to develop and verify –Quick (fast) compiler Balance compile-time and execution time –Optimizing compiler Deliver high-quality code with likely long compilation time

19 Quick Compiler Compile each method as it executes for the first time Apply a few highly effective optimizations –Minimal transformation –Decorate the byte code and optimized with Copy propagation Register allocation

20 Optimizing Compiler For frequently executed method –Need a profiler –Dynamic versus adaptive

21 Optimizing Compiler Structure

22 Optimizations HIR (n-tuple, register-based IR) –Local optimizations: CSE, elimination of redundant load –Flow-insensitive optimizations: dead code elimination –In-lining

23 Optimizations LIR (adopt object layout and calling convention) –Larger than HIR –Local CSE MIR (machine specific) –Instruction selection using BURS –Live variable analysis –Register allocation (linear scan)

24 Compilation Speeds

25 Performance on SPEC JVM98

26 Extra Magic Boot image

27 Byteocde Example int align2grain(int i, int grain) { return ((i + grain-1) & ~(grain-1)); } Method int align2grain(int,int) 0 iload_1 1 iload_2 2 iadd 3 iconst_1 4 isub 5 iload_2 6 iconst_1 7 isub 8 iconst_m1 9 ixor 10 iand 11 ireturn


Download ppt "Java Virtual Machine Case Study on the Design of JikesRVM."

Similar presentations


Ads by Google