An updated version of my "OpenJ9: Under the hood of the next open source JVM" that covers where it was open sourced (github.com/eclipse/openj9), how to build it, and then deep dives into the ROM/RAM divide before touching on interpreter, JIT and AOT.
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
JavaOne 2017: Eclipse OpenJ9: Under the hood of the JVM
1. Dan Heidinga,
OpenJ9 Project Lead
IBM Runtimes J9 Interpreter Lead
Daniel_Heidinga@ca.ibm.com
@DanHeidinga
Oct 3, 2017
OpenJ9: Under the Hood of the
Next Open Source JVM
2. 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
3. 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.
§ Now one of the Project Leads for the Eclipse OpenJ9 JVM.
3
4. Dan Heidinga,
OpenJ9 Project Lead
IBM Runtimes J9 Interpreter Lead
Daniel_Heidinga@ca.ibm.com
@DanHeidinga
Oct 3, 2017
Eclipse
OpenJ9: Under the Hood of the
Next Open Source JVM
14. 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
27. 27
…
class load: jdk/internal/org/objectweb/asm/FieldVisitor from: jrt:/java.base
class load: jdk/internal/org/objectweb/asm/FieldWriter from: jrt:/java.base
class load: java/lang/ClassLoader$$Lambda$3/00000000702E91F0
class load: HelloService from: file:/openj9/uber.jar
class load: jdk/internal/reflect/UnsafeFieldAccessorFactory from: jrt:/java.base
class load: jdk/internal/reflect/FieldAccessor from: jrt:/java.base
class load: jdk/internal/reflect/FieldAccessorImpl from: jrt:/java.base
class load: jdk/internal/reflect/UnsafeFieldAccessorImpl from: jrt:/java.base
class load: jdk/internal/reflect/UnsafeObjectFieldAccessorImpl from: jrt:/java.base
class load: java/lang/Class$ReflectCache from: jrt:/java.base
class load: java/lang/annotation/Annotation from: jrt:/java.base
class load: jdk/internal/reflect/CallerSensitive from: jrt:/java.base
….
28. “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 (known for Plan 9, UTF-8, Go)
28
32. J9ROMClass: a better classfile
§ Keep all the symbolic info from a classfile
§ Remove variability (where possible)
§ Position independent: map anywhere in the address space
§ ROM: Read only once written
– Learn from the Smalltalk past
32
ROMClass
33. Conversion to ROM
33
Classfile Static
Verification
ROMClassROM Class
Builder
https://github.com/eclipse/openj9/tree/master/runtime/bcverify
https://github.com/eclipse/openj9/tree/master/runtime/bcutil
37. 37
public static void main(java.lang.String[])
0 JBgetstatic 2 System.out LPrintStream;
3 JBldc 3 (java.lang.String) "Hello”
5 JBinvokevirtual 4 PrintStream.println(LString;)V
8 JBreturn
Java’s late bound… Isn’t it slow to resolve
the fields / methods every time?
38. From ROM to RAM
38
RAM class creation
Load superclases
Load superinterfaces
Calculate vtable
ROMClass J9RAMClass
https://github.com/eclipse/openj9/blob/master/runtime/vm/createramclass.cpp
44. Classloading: tying it all together
44
ROMClass J9RAMClass
J9ClassLoader
java.lang.Class java.lang.ClassLoader
Heap
Native
45. 45
public static void main(java.lang.String[])
0 JBgetstatic 2 System.out LPrintStream;
3 JBldc 3 (java.lang.String) "Hello”
5 JBinvokevirtual 4 PrintStream.println(LString;)V
8 JBreturn
That’s all good but what about actually
running my code???
50. Interpreter
§ Written in C++
§ Switch statement / computed goto
§ Executes:
– bytecodes
– INLs
– builds stack frames
§ Transition to the JIT
50
https://github.com/eclipse/openj9/blob/master/runtime/vm/BytecodeInterpreter.hpp
51. JIT Compilation
ARM
Optimizer
Analyses and Optimizations
cold warm hot FSDscorching AOT
IL Generation
x86
POWER
Z
Code Generators
Runtime
Environment/
Configuration
•Options
•Object Model
•Memory
•Threading
•Tracing
codeMetadataRuntimeRT Helpers
very hot profiling
Profile
Manager
Hardware
counters
Sampling
Thread
Interpreter
Profile Info
JIT
Profile Info
Profiler
52. Adaptive JIT Compilation
52
§ Methods start out running bytecode form directly
§ After many invocations (or via sampling) code get compiled at
‘cold’ or ‘warm’ level
§ Low overhead sampling thread is used to identify hot methods
§ Methods may get recompiled at ‘hot’ or ‘scorching’ levels (for more
optimizations)
§ Transition to ‘scorching’ goes through a temporary profiling step
cold
hot
scorching
profiling
interpreter
warm
56. Wrap-up: Want to get involved?
§ Download OpenJDK with OpenJ9 and try it out!
– https://adoptopenjdk.net/releases.html?variant=openjdk9-openj9
– Run on your favourite Java application and let us know how it went!
§ Interact with our community via Github issues
– https://github.com/eclipse/openj9
– Ask questions, report problems, report Amazing Results
– Download the code, build it yourself, play around!
– Submit pull requests, see them tested on multiple platforms in the open
§ Whatever you think will make Eclipse OpenJ9 better, we’d love to hear it
56
57. Learn more at Java One!
§ Have even more questions? Dan Heidinga, Mark Stoodley, John Duimovich
Ask the OpenJ9 Architects [CON2672]
Wednesday, Oct 04, 8:30 a.m. - 9:15 a.m. | Moscone West - Room 2011
§ Learn about microservices for open testing with Shelley Lambert
Cloud-Based Test Microservices [CON2789]
Thursday, Oct 05, 11:45 a.m. - 12:30 p.m. | Marriott Marquis (Yerba Buena Level) - Salon 12
§ Debugging runtimes with Dan Heidinga for Bjørn Vårdal
Secrets of Building a Debuggable Runime [CON4081]
Thursday, Oct 05, 12:45 p.m. - 1:30 p.m. | Marriott Marquis (Yerba Buena Level) - Salon 15
§ Visit the Eclipse Foundation booth (6140)
Dan Heidinga & Mark Stoodley today from 4:00 - 5:45
Mark Stoodley on Wednesday from 2:30 - 4:30
57
59. 59
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.