J9: Under the hood of the next open source JVM

42
Dan Heidinga, J9 VM Interpreter Lead [email protected] @DanHeidinga 18 September 2016 J9: Under the Hood of the Next Open Source JVM

Transcript of J9: Under the hood of the next open source JVM

Page 1: J9: Under the hood of the next open source JVM

Dan Heidinga, J9 VM Interpreter Lead

[email protected]

@DanHeidinga

18 September 2016

J9: Under the Hood of the Next Open Source JVM

Page 2: J9: Under the hood of the next open source JVM

Important disclaimers

THE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY.

WHILST EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION

CONTAINED IN THIS PRESENTATION, IT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,

EXPRESS OR IMPLIED.

ALL PERFORMANCE DATA INCLUDED IN THIS PRESENTATION HAVE BEEN GATHERED IN A CONTROLLED

ENVIRONMENT. YOUR OWN TEST RESULTS MAY VARY BASED ON HARDWARE, SOFTWARE OR

INFRASTRUCTURE DIFFERENCES.

ALL DATA INCLUDED IN THIS PRESENTATION ARE MEANT TO BE USED ONLY AS A GUIDE.

IN ADDITION, THE INFORMATION CONTAINED IN THIS PRESENTATION IS BASED ON IBM’S CURRENT

PRODUCT PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BY IBM, WITHOUT NOTICE.

IBM AND ITS AFFILIATED COMPANIES SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT

OF THE USE OF, OR OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION.

NOTHING CONTAINED IN THIS PRESENTATION IS INTENDED TO, OR SHALL HAVE THE EFFECT OF:

– CREATING ANY WARRANT OR REPRESENTATION FROM IBM, ITS AFFILIATED COMPANIES OR ITS

OR THEIR SUPPLIERS AND/OR LICENSORS

2

Page 3: J9: Under the hood of the next open source JVM

Who am I?

I've been involved with virtual machine development at IBM

since 2007 and am now the J9 Virtual Machine Team Lead.

J9 is IBM's independent implementation of the JVM.

I've represented IBM on both the JSR 292 ('invokedynamic')

and JSR 335 ('lambda') expert groups and lead J9's

implementation of both JSRs.

I’ve also maintain the bytecode verifier and deal with various

other parts of the runtime.

3

Page 4: J9: Under the hood of the next open source JVM

High performance

High reliability

Serviceability

J9: IBM’s Java Virtual Machine

4

OS

JVM

Middle ware

User application

Page 5: J9: Under the hood of the next open source JVM

J9: IBM’s Java Virtual Machine scales

5

Page 6: J9: Under the hood of the next open source JVM

J9 Architecture

6

SE 7

Operating system

Nativeapplications

OS-specific calls

Virtual machine

SE 6

Garbage collector

Interpreter

Exception handler

Class loader

Pluggable components that dynamically load into the virtual machine

Thread model

JVM Profiler

Debugger

Port Library (file IO, sockets, memory allocation)

Uses 1 of many Java platform configurations

JCL natives

JNI

Calls toClibraries

CDC

MIDP

Java calls

JNI, INL, Fastcall

TR JIT

CLDC

VM Interface

Zip, fdlibm

Java VM Classes

Page 7: J9: Under the hood of the next open source JVM

PERFORMANCE !

Java6SR16 FP4

Java 6.1SR8 FP4

Java 7SR9

Java 7.1SR3

Java 8SR1

Apache Spark 1.4 Daytrader3 Linux Intel

Page 8: J9: Under the hood of the next open source JVM

Envy/Developer: J9’s Smalltalk Roots

Page 9: J9: Under the hood of the next open source JVM

Virtual machines on oscilloscopes?

“Lots” of ROM, very little RAMhttps://upload.wikimedia.org/wikipedia/commons/7/7e/Tektronix_TDS210_Oscilloscope.jpg

Page 10: J9: Under the hood of the next open source JVM

Data dominates. If you've chosen the right data

structures and organized things well, the algorithms

will almost always be self-evident. Data structures,

not algorithms, are central to programming.– Rob Pike

10

Page 11: J9: Under the hood of the next open source JVM

You want me to interpret that?

11

Page 12: J9: Under the hood of the next open source JVM

You want me to interpret that?

Constant offsets

Fast access

Easy to find constant_pool start

12

Relative offsets

Variable sized arrays

Variable sized entries

Slow access to specific index

Page 13: J9: Under the hood of the next open source JVM

Conversion to ROM

13

Classfile StaticVerification

ROMClassROM ClassBuilder

Page 14: J9: Under the hood of the next open source JVM

Essential Classfile data

Position independent (SRP)

Less variable than a Classfile

Still variable, but structured

Page 15: J9: Under the hood of the next open source JVM

From ROM to RAM

15

RAM CreationLoad superclases

Load superinterfacesCalculate vtable

ROMClass J9RAMClass

Page 16: J9: Under the hood of the next open source JVM

Live pointers, not SRPs

Pointer to the ROMClass

Live data

Describes the shape of

this class in this VM.

Requires its entire

hierarchy and interfaces

to be loaded.

Page 17: J9: Under the hood of the next open source JVM

Classloading: tying it all together

17ROMClass J9RAMClass

J9ClassLoader

java.lang.Class java.lang.ClassLoader

Heap

Native

Page 18: J9: Under the hood of the next open source JVM

Bytecode loaded? Check

18

ROMClass

J9RAMClass

stack=2, locals=1, args_size=10: getstatic #23: ldc #35: invokevirtual #48: return

Page 19: J9: Under the hood of the next open source JVM

Threading

19

J9VMThreadJ9VMThreadJ9JavaVM

omrthread_t omrthread_t omrthread_t

Heap

Native

java.lang.Thread java.lang.Thread java.lang.Thread

Page 20: J9: Under the hood of the next open source JVM

SP

A0

PC

Method

Per-Thread Interpreter State

20

J9VMThread

omrthread_t

java.lang.Thread

J9MethodROMMethod

Bytecodes

Page 21: J9: Under the hood of the next open source JVM

SP

A0

PC

Method

Per-Thread Interpreter State

21

J9VMThread

omrthread_t

java.lang.Thread

J9MethodROMMethod

Bytecodes

Page 22: J9: Under the hood of the next open source JVM

SP

A0

PC

Method

Per-Thread Interpreter State

22

J9VMThread

omrthread_t

java.lang.Thread

Pending

Frame

Temps

Args

Java stack

J9MethodROMMethod

Bytecodes

0

Page 23: J9: Under the hood of the next open source JVM

Interpreter

Written in C++

Switch statement / computed goto

Executes:

– bytecodes

– INLs

– builds stack frames

Transition to the JIT

23

Page 24: J9: Under the hood of the next open source JVM

Primordial Call-in frame

24

JIT

Interpreter

Callin frame

Helpers

….

Page 25: J9: Under the hood of the next open source JVM

SharedClasses: ROM pays off

JVM 1 JVM 2 JVM 3

Page 26: J9: Under the hood of the next open source JVM

SharedClasses: ROM pays off

JVM 1 JVM 2 JVM 3

Page 27: J9: Under the hood of the next open source JVM

SharedClasses: ROM pays off

JVM 1 JVM 2 JVM 3

Shared Classes Cache

Page 28: J9: Under the hood of the next open source JVM

SharedClasses: “dynamic” AOT

Shared Classes Cache

AOTROM Classes

Page 29: J9: Under the hood of the next open source JVM

Diagnostic tools

Diagnostic information (-Xdump)– Java dump (javacore)– Heap dump– System dump (core)– JIT dump

Tracepoints (-Xtrace)

bin/jdmpview –core <corefile>

29

Page 30: J9: Under the hood of the next open source JVM

J9: Meet IBM’s OpenJDK distroOracle JDK

JCL

Hotspot

Open JDK JCL

Hotspot

IBM JDK JCL

IBM J9

+ IBM JCL

Page 31: J9: Under the hood of the next open source JVM

J9: Meet IBM’s OpenJDK & OMR distro

OMR

Oracle JDK JCL

Hotspot

Open JDK JCL

Hotspot

IBM JDK JCL

IBM J9

OMR

+ IBM JCL + IBM OMR

Page 32: J9: Under the hood of the next open source JVM

Build an open reusable language runtime foundation for cloud platforms

– To accelerate advancement and innovation

– In full cooperation with existing language communities

– Engaging a diverse community of people interested in language runtimes

• Professional developers• Researchers• Students• Hobbyists

Eclipse OMR Mission

Page 33: J9: Under the hood of the next open source JVM

http://www.eclipse.org/omrhttps://github.com/eclipse/omr

https://developer.ibm.com/open/omr/

Dual License:Eclipse Public License V1.0

Apache 2.0

Users and contributors very welcomehttps://github.com/eclipse/omr/blob/master/CONTRIBUTING.md

Eclipse OMRCreated March 2016

Page 34: J9: Under the hood of the next open source JVM

OMR componentsport platform abstraction (porting) library

thread cross platform pthread-like threading library

vm APIs to manage per-interpreter and per-thread contexts

gc garbage collection framework for managed heaps

compiler extensible compiler framework

jitbuilder WIP project to simplify bring up for a new JIT compiler

omrtrace library for publishing trace events for monitoring/diagnostics

omrsigcompat signal handling compatibility library

example demonstration code to show how a language runtime might

consume OMR components, also used for testing

fvtest language independent test framework built on the example glue so that

components can be tested outside of a language runtime,

uses Google Test 1.7 framework

+ a few others

~800KLOC at this point, more components coming!

Page 35: J9: Under the hood of the next open source JVM

OpenJ9: Meet an OpenJDK & OMR distro

OpenJ9

OMR OMR

Open JDK JCL

OpenJ9

OMR

Oracle JDK JCL

Hotspot

Open JDK JCL

Hotspot

IBM JDK JCL

IBM J9

OMR

+ IBM isms

Page 36: J9: Under the hood of the next open source JVM

OpenJ9: Meet an OpenJDK & OMR distro

OpenJ9

OMR OMR

Open JDK JCL

OpenJ9

OMR

Oracle JDK JCL

Hotspot

Open JDK JCL

Hotspot

IBM JDK JCL

IBM J9

OMR

+ IBM isms

OMR & OpenJ9: note the arrow direction!

Open projects as the upstream repos

IBM JDK is a CONSUMER of OpenJ9

Page 37: J9: Under the hood of the next open source JVM

37

“We believe open ecosystems and partnerships are key to our

future innovation.”

-- Ginni Rometty(http://www.ibm.com/annualreport/2014/chairmans-letter.html)

Page 38: J9: Under the hood of the next open source JVM

38

Collaboration

Competition

Polyglot

Platforms

Really? Why are you doing this?

Page 39: J9: Under the hood of the next open source JVM

When

39

Soon

Page 40: J9: Under the hood of the next open source JVM

When

40

Goal: release concurrently with Java 9

Page 41: J9: Under the hood of the next open source JVM

41

Legal Notice

IBM and the IBM logo are trademarks or registered trademarks of IBM Corporation, in the United States, other

countries or both.

Java and all Java-based marks, among others, are trademarks or registered trademarks of Oracle in the United

States, other countries or both.

Other company, product and service names may be trademarks or service marks of others.

THE INFORMATION DISCUSSED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL

PURPOSES ONLY. WHILE EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND

ACCURACY OF THE INFORMATION, IT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,

EXPRESS OR IMPLIED, AND IBM SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT

OF THE USE OF, OR OTHERWISE RELATED TO, SUCH INFORMATION. ANY INFORMATION

CONCERNING IBM'S PRODUCT PLANS OR STRATEGY IS SUBJECT TO CHANGE BY IBM WITHOUT

NOTICE.

Page 42: J9: Under the hood of the next open source JVM

• IBM is open sourcing its J9 JVM technology

– Includes Testarossa Just in Time (JIT) compiler

• Eclipse OMR project is leading edge: github.com/eclipse/omr

– Project created March 7, 2016 : ~300KLOC

– Compiler contributed September 16, 2016 : ~500KLOC

• Open J9 project is also coming

– We’re working on it at same time as Java 9 development

Open source