+ All Categories
Home > Documents > Java Virtual Machine Case Study on the Design of JikesRVM.

Java Virtual Machine Case Study on the Design of JikesRVM.

Date post: 13-Jan-2016
Category:
Upload: justina-gibson
View: 222 times
Download: 0 times
Share this document with a friend
27
Java Virtual Machine Case Study on the Design of JikesRVM
Transcript
Page 1: Java Virtual Machine Case Study on the Design of JikesRVM.

Java Virtual Machine

Case Study on the Design of JikesRVM

Page 2: Java Virtual Machine Case Study on the Design of JikesRVM.

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

Page 3: Java Virtual Machine Case Study on the Design of JikesRVM.

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

Page 4: Java Virtual Machine Case Study on the Design of JikesRVM.

Design Goals

• Exploitation of high-performance processors

• SMP scalability• Thread limits• Continuous availability• Rapid response• Library usage• Graceful degradation

Page 5: Java Virtual Machine Case Study on the Design of JikesRVM.

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

Page 6: Java Virtual Machine Case Study on the Design of JikesRVM.

Array and Scalar Object Layout

Page 7: Java Virtual Machine Case Study on the Design of JikesRVM.

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

Page 8: Java Virtual Machine Case Study on the Design of JikesRVM.

JTOC (JikesRVM Table of Contents)

Page 9: Java Virtual Machine Case Study on the Design of JikesRVM.

Method Invocation Stack

Page 10: Java Virtual Machine Case Study on the Design of JikesRVM.

Runtime Subsystem

• Exceptions

• Dynamic class loading

• Input/Output

• Reflection

Page 11: Java Virtual Machine Case Study on the Design of JikesRVM.

Exceptions

• 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

Page 12: Java Virtual Machine Case Study on the Design of JikesRVM.

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

Page 13: Java Virtual Machine Case Study on the Design of JikesRVM.

Input and Output

• Use OS’ services through system routine calls

Page 14: Java Virtual Machine Case Study on the Design of JikesRVM.

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; }

Page 15: Java Virtual Machine Case Study on the Design of JikesRVM.

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

Page 16: Java Virtual Machine Case Study on the Design of JikesRVM.

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

Page 17: Java Virtual Machine Case Study on the Design of JikesRVM.

Choices

• Copying or non-copying collectors

• Incremental/concurrent or stop-the-world

• Generational collectors– Most objects die young– Minor collection, major collection– Remember set

Page 18: Java Virtual Machine Case Study on the Design of JikesRVM.

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

Page 19: Java Virtual Machine Case Study on the Design of JikesRVM.

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

Page 20: Java Virtual Machine Case Study on the Design of JikesRVM.

Optimizing Compiler

• For frequently executed method– Need a profiler – Dynamic versus adaptive

Page 21: Java Virtual Machine Case Study on the Design of JikesRVM.

Optimizing Compiler Structure

Page 22: Java Virtual Machine Case Study on the Design of JikesRVM.

Optimizations

• HIR (n-tuple, register-based IR)– Local optimizations: CSE, elimination of

redundant load– Flow-insensitive optimizations: dead code

elimination– In-lining

Page 23: Java Virtual Machine Case Study on the Design of JikesRVM.

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)

Page 24: Java Virtual Machine Case Study on the Design of JikesRVM.

Compilation Speeds

Page 25: Java Virtual Machine Case Study on the Design of JikesRVM.

Performance on SPEC JVM98

Page 26: Java Virtual Machine Case Study on the Design of JikesRVM.

Extra

• Magic

• Boot image

Page 27: Java Virtual Machine Case Study on the Design of JikesRVM.

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


Recommended