Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Dan Heidinga, J9 VM Interpreter Lead
Daniel_Heidinga@ca.ibm.com
@DanHeidinga
18 September 2016
J9: Under the Hood of the
N...
Important disclaimers
 THE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY.
 WHIL...
Who am I?
 I've been involved with virtual machine development at IBM
since 2007 and am now the J9 Virtual Machine Team L...
High performance
High reliability
Serviceability
J9: IBM’s Java Virtual Machine
4
OS
JVM
Middle ware
User application
J9: IBM’s Java Virtual Machine scales
5
J9 Architecture
6
SE 7
Operating system
Native
applications
OS-specific calls
Virtual machine
SE 6
Garbage collector
Inter...
PERFORMANCE !
Java6
SR16 FP4
Java 6.1
SR8 FP4
Java 7
SR9
Java 7.1
SR3
Java 8
SR1
Apache Spark 1.4 Daytrader3 Linux Intel
Envy/Developer: J9’s Smalltalk Roots
Virtual machines on oscilloscopes?
“Lots” of ROM, very little RAM
https://upload.wikimedia.org/wikipedia/commons/7/7
e/Tek...
Data dominates. If you've chosen the right data
structures and organized things well, the algorithms
will almost always be...
You want me to interpret that?
11
You want me to interpret that?
Constant offsets
Fast access
Easy to find constant_pool start
12
Relative offsets
Variable ...
Conversion to ROM
13
Classfile Static
Verification
ROMClassROM Class
Builder
Essential Classfile data
Position independent (SRP)
Less variable than a Classfile
Still variable, but structured
From ROM to RAM
15
RAM Creation
Load superclases
Load superinterfaces
Calculate vtable
ROMClass J9RAMClass
 Live pointers, not SRPs
 Pointer to the ROMClass
 Live data
 Describes the shape of
this class in this VM.
 Requires...
Classloading: tying it all together
17
ROMClass J9RAMClass
J9ClassLoader
java.lang.Class java.lang.ClassLoader
Heap
Native
Bytecode loaded? Check
18
ROMClass
J9RAMClass
stack=2, locals=1, args_size=1
0: getstatic #2
3: ldc #3
5: invokevirtual #4...
Threading
19
J9VMThreadJ9VMThreadJ9JavaVM
omrthread_t omrthread_t omrthread_t
Heap
Native
java.lang.Thread java.lang.Threa...
SP
A0
PC
Method
Per-Thread Interpreter State
20
J9VMThread
omrthread_t
java.lang.Thread
J9Method
ROMMethod
Bytecodes
SP
A0
PC
Method
Per-Thread Interpreter State
21
J9VMThread
omrthread_t
java.lang.Thread
J9Method
ROMMethod
Bytecodes
SP
A0
PC
Method
Per-Thread Interpreter State
22
J9VMThread
omrthread_t
java.lang.Thread
Pending
Frame
Temps
Args
Java stac...
Interpreter
 Written in C++
 Switch statement / computed goto
 Executes:
– bytecodes
– INLs
– builds stack frames
 Tra...
Primordial Call-in frame
24
JIT
Interpreter
Callin frame
Helpers
….
SharedClasses: ROM pays off
JVM 1 JVM 2 JVM 3
SharedClasses: ROM pays off
JVM 1 JVM 2 JVM 3
SharedClasses: ROM pays off
JVM 1 JVM 2 JVM 3
Shared Classes
Cache
SharedClasses: “dynamic” AOT
Shared Classes
Cache
AOTROM Classes
Diagnostic tools
 Diagnostic information (-Xdump)
– Java dump (javacore)
– Heap dump
– System dump (core)
– JIT dump
 Tr...
J9: Meet IBM’s OpenJDK distro
Oracle JDK
JCL
Hotspot
Open JDK
JCL
Hotspot
IBM JDK JCL
IBM J9
+ IBM JCL
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...
Build an open reusable language runtime foundation for cloud
platforms
– To accelerate advancement and innovation
– In ful...
http://www.eclipse.org/omr
https://github.com/eclipse/omr
https://developer.ibm.com/open/omr/
Dual License:
Eclipse Public...
OMR components
port platform abstraction (porting) library
thread cross platform pthread-like threading library
vm APIs to...
OpenJ9: Meet an OpenJDK & OMR distro
OpenJ9
OMR OMR
Open JDK
JCL
OpenJ9
OMR
Oracle JDK
JCL
Hotspot
Open JDK
JCL
Hotspot
IB...
OpenJ9: Meet an OpenJDK & OMR distro
OpenJ9
OMR OMR
Open JDK
JCL
OpenJ9
OMR
Oracle JDK
JCL
Hotspot
Open JDK
JCL
Hotspot
IB...
37
“We believe open ecosystems
and partnerships are key to our
future innovation.”
-- Ginni Rometty
(http://www.ibm.com/an...
38
Collaboration
Competition
Polyglot
Platforms
Really? Why are you doing this?
When
39
Soon
When
40
Goal: release concurrently
with Java 9
41
Legal Notice
IBM and the IBM logo are trademarks or registered trademarks of IBM Corporation, in the United States, oth...
• IBM is open sourcing its J9 JVM technology
– Includes Testarossa Just in Time (JIT) compiler
• Eclipse OMR project is le...
Upcoming SlideShare
Loading in …5
×

J9: Under the hood of the next open source JVM

13,545 views

Published on

A description of how bytecodes are loaded into the J9VM and how bytecode execution occurs, plus IBM's plans to open source J9.
Session is the "new hire" talk given to all new J9 VM team members.

Published in: Technology

J9: Under the hood of the next open source JVM

  1. 1. Dan Heidinga, J9 VM Interpreter Lead Daniel_Heidinga@ca.ibm.com @DanHeidinga 18 September 2016 J9: Under the Hood of the Next Open Source JVM
  2. 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. 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. 3
  4. 4. High performance High reliability Serviceability J9: IBM’s Java Virtual Machine 4 OS JVM Middle ware User application
  5. 5. J9: IBM’s Java Virtual Machine scales 5
  6. 6. J9 Architecture 6 SE 7 Operating system Native applications 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 to C libraries CDC MIDP Java calls JNI, INL, Fastcall TR JIT CLDC VM Interface Zip, fdlibm Java VM Classes
  7. 7. PERFORMANCE ! Java6 SR16 FP4 Java 6.1 SR8 FP4 Java 7 SR9 Java 7.1 SR3 Java 8 SR1 Apache Spark 1.4 Daytrader3 Linux Intel
  8. 8. Envy/Developer: J9’s Smalltalk Roots
  9. 9. Virtual machines on oscilloscopes? “Lots” of ROM, very little RAM https://upload.wikimedia.org/wikipedia/commons/7/7 e/Tektronix_TDS210_Oscilloscope.jpg
  10. 10. 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
  11. 11. You want me to interpret that? 11
  12. 12. 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
  13. 13. Conversion to ROM 13 Classfile Static Verification ROMClassROM Class Builder
  14. 14. Essential Classfile data Position independent (SRP) Less variable than a Classfile Still variable, but structured
  15. 15. From ROM to RAM 15 RAM Creation Load superclases Load superinterfaces Calculate vtable ROMClass J9RAMClass
  16. 16.  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.
  17. 17. Classloading: tying it all together 17 ROMClass J9RAMClass J9ClassLoader java.lang.Class java.lang.ClassLoader Heap Native
  18. 18. Bytecode loaded? Check 18 ROMClass J9RAMClass stack=2, locals=1, args_size=1 0: getstatic #2 3: ldc #3 5: invokevirtual #4 8: return
  19. 19. Threading 19 J9VMThreadJ9VMThreadJ9JavaVM omrthread_t omrthread_t omrthread_t Heap Native java.lang.Thread java.lang.Thread java.lang.Thread
  20. 20. SP A0 PC Method Per-Thread Interpreter State 20 J9VMThread omrthread_t java.lang.Thread J9Method ROMMethod Bytecodes
  21. 21. SP A0 PC Method Per-Thread Interpreter State 21 J9VMThread omrthread_t java.lang.Thread J9Method ROMMethod Bytecodes
  22. 22. SP A0 PC Method Per-Thread Interpreter State 22 J9VMThread omrthread_t java.lang.Thread Pending Frame Temps Args Java stack J9Method ROMMethod Bytecodes 0
  23. 23. Interpreter  Written in C++  Switch statement / computed goto  Executes: – bytecodes – INLs – builds stack frames  Transition to the JIT 23
  24. 24. Primordial Call-in frame 24 JIT Interpreter Callin frame Helpers ….
  25. 25. SharedClasses: ROM pays off JVM 1 JVM 2 JVM 3
  26. 26. SharedClasses: ROM pays off JVM 1 JVM 2 JVM 3
  27. 27. SharedClasses: ROM pays off JVM 1 JVM 2 JVM 3 Shared Classes Cache
  28. 28. SharedClasses: “dynamic” AOT Shared Classes Cache AOTROM Classes
  29. 29. Diagnostic tools  Diagnostic information (-Xdump) – Java dump (javacore) – Heap dump – System dump (core) – JIT dump  Tracepoints (-Xtrace)  bin/jdmpview –core <corefile> 29
  30. 30. J9: Meet IBM’s OpenJDK distro Oracle JDK JCL Hotspot Open JDK JCL Hotspot IBM JDK JCL IBM J9 + IBM JCL
  31. 31. 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
  32. 32. 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
  33. 33. http://www.eclipse.org/omr https://github.com/eclipse/omr https://developer.ibm.com/open/omr/ Dual License: Eclipse Public License V1.0 Apache 2.0 Users and contributors very welcome https://github.com/eclipse/omr/blob/master/CONTRIBUTING.md Eclipse OMR Created March 2016
  34. 34. OMR components port 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!
  35. 35. 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
  36. 36. 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
  37. 37. 37 “We believe open ecosystems and partnerships are key to our future innovation.” -- Ginni Rometty (http://www.ibm.com/annualreport/2014/chairmans-letter.html)
  38. 38. 38 Collaboration Competition Polyglot Platforms Really? Why are you doing this?
  39. 39. When 39 Soon
  40. 40. When 40 Goal: release concurrently with Java 9
  41. 41. 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.
  42. 42. • 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

×