4. Eclipse OMR: Building Blocks
for Polyglot
TURBO’18 @ Boston
Speaker: Xiaoli (Shelley) Liang
November 5, 2018
5. 5
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
7. 7
Can we reuse components across different languages?
Investment in one runtime has close to zero carry over to other runtimes
Becomes a bigger problem as more workloads move into the cloud
8. 8
Cloud platforms depend on better runtime support
Great runtime support is key to
successful cloud platforms
Different language runtime
technologies present in the cloud
Advancing cloud platforms can
become expensive, slow, and
depends on many different
communities
11. 11
J9 Java JIT Compiler
Layer
J9 Java Execution Environment
Refactor “Java”-ness into a language-specific layer
OMR
Platform Abstraction Layer
OMR
Garbage
Collector
OMR
Diagnostic and
Monitoring Services
Source Code Bytecode/AST
Compiler
Interpreter
Java
Source
J9 Java
Bytecode
Compiler
J9 Java
Bytecode
Interpreter
J9 Java Diagnostic
Layer
J9
Java
GC
Laye
r
OMR
Just in Time
(JIT)
Compiler
12. Core components make up Eclipse OMR
12
OMR
Platform Abstraction Layer
OMR
Garbage
Collector
OMR
Diagnostic and
Monitoring Services
OMR
Just in Time
(JIT)
Compiler
14. An open-sourced and reusable C++ library for building runtimes
A toolkit derived from the source code of IBM’s production J9 JVM
Implements language-agnostic parts of a managed runtime
Bootstraps development of new runtimes
Allows incremental enablement of advanced functionality
What is Eclipse OMR?
15. 15
Eclipse OMR mission
Build an open reusable language runtime foundation
– To accelerate cloud platform advancement and innovation
– In full cooperation with existing language communities
– With a diverse community of people interested in language runtimes
Professional developers
Researchers
Students
Hobbyists
16. 16
Eclipse 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 library providing a simplified API to the JIT compiler
omrtrace library for publishing trace events for monitoring/diagnostics
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
Over 1M LOC to date, more functionality and components are coming!
17. Projects using JitBuilder
1. Lua Vermelha (JIT for Lua 5.3 implementing “all but one” opcodes) ~3,000 lines of C++ code
• https://github.com/Leonardo2718/lua-vermelha
2. JIT for LPEG runtime used by Rosie Pattern Language (all opcodes used by Rosie) ~1,200 lines of C++ code
• https://github.com/mstoodle/rosie-lpeg
3. JIT for Swift (about 1/3 of SIL opcodes) ~2,000 lines of C++ code
• To be open sourced, some details here: http://www.ustream.tv/recorded/105013815
4. Smalltalk: SOM++ runtime ~2,500 lines of C++ code
• https://github.com/charliegracie/SOMpp/tree/jitbuilder_vmstate
5. Base9 JIT: Javascript-like tutorial language ~1,000 lines of C++ code
• https://github.com/b9org/b9
6. WebAssembly JIT: U of Calgary undergraduate project (144 of 177 opcodes!) ~2,000 lines of C++ code
• https://github.com/wasmjit-omr/wasmjit-omr
7. T4 JIT: experimental Javascript implementation ~2,700 lines of C++ code
• Written by John Duimovich, not yet open sourced
8. Kaleidoscope JIT: JitBuilder JIT implementation for LLVM tutorial language ~300 lines of C++ code
• Written by Mark Stoodley, some details here: http://www.ustream.tv/recorded/105013815
9. Java matrix multiply accelerator prototype with Vector math services 58 lines of Java code
• https://ibm.box.com/v/JavaJitBuilder-x86-64
17
23. 23
Potential Collaboration Project Ideas
JIT-as-a-Service
– Provides on-demand compilation services for runtimes employing JIT compilation
Exploit new hardware capabilities with Eclipse OMR and OpenJ9
– GPU/SIMD
– Runtime Instrumentation (RI)
– Hardware Transactional Memory (HTM)
Build new language runtime or interop with other language runtimes with Eclipse OMR
Create a runtimes course curriculum based on Eclipse OMR or OpenJ9
– Allows students to get hands-on exposure to low-level runtime components
25. http://www.eclipse.org/omr
https://github.com/eclipse/omr (beginner/help wanted issues)
Users and contributors very welcome!
https://github.com/eclipse/omr/blob/master/CONTRIBUTING.md
Eclipse OMR
Mark Stoodley
mstoodle@ca.ibm.co
m
Daryl Maier
maier@ca.ibm.com
Follow us @EclipseOMR
Join our Slack workspace eclipse-omr
Leonardo Banderali
leob@ibm.com
Robert Young
rwyoung@ca.ibm.co
m
Xiaoli Liang
xsliang@ca.ibm.co
m
26. Mark Stoodley
Daryl Maier
Vijay Sundaresan
Leonardo Banderali
Robert Young
Nazim Bhuiyan
Acknowledgements
26
The IBM Runtime Technologies team spent the last 20+ years on building a high performance, enterprise caliber, cross-platform Java virtual machine, namely the IBM J9 JVM. A few years ago, we started noticing other languages like Python, Javascript, Ruby, and php that developers cared about. We asked ourselves, can we reuse the same runtime components like a Just-In-Time (JIT) compiler and a garbage collector across different languages? What we found was no, we couldn’t. The components re similar but underlying implementations are quite different. So investment in one language runtime has close to zero carry over benefit to the other language runtimes. And it becomes a much bigger problem as more and more workloads move into the cloud.
For the last few years, more and more businesses are deploying their software solutions in the cloud with the expectations that cloud platforms will offer great reliability, scalability, security, and their applications will still have the same awesome performance as before. To meet these expectations, cloud platforms rely on great runtime support. At the same time application developers want to have the freedom to choose whatever languages that best suit their needs, and as a result, there are many different language runtime technologies present in the cloud. This means advancing cloud platforms depends on many different language communities, and can be expensive and slow.
We want to change this by building reusable runtime components based on the great technology we developed for the Java ecosystem (like the JIT and GC). How can we achieve this? Our answer was Eclipse OMR.
We started with the high performance and production ready IBM J9 Java runtime that is used in many IBM products. Here we have a java source program, it is first compiled into bytecodes, then it is either interpreted or optimized and compiled into efficient machine instructions to be executed on a target platform.
We identified the major components in the Java execution environment that can be common across different language runtimes. They are the JIT compiler, GC, diagnostic and monitoring tools, and platform abstraction layer.
From there, we then refactored the J9 code into two separate code bases. We have a thin language-specific layer that understands the Java semantics, they are the yellow boxes in the diagram. But more importantly, we also have a set of language-agnostic components that can be used by any language runtime (including Java) to leverage the JIT, GC, diagnostic and monitoring and platform abstraction capabilities. These are the red boxes in the diagram.
Removing the Java language specific (or yellow) boxes from the previous slide and we have the core runtime components that make up the Eclipse OMR project.
In case you are wondering what happened to the thin layer that understands the Java semantics, a.k.a. the yellow boxes from the earlier slide? That code was open sourced in 2017 as the Eclipse OpenJ9 project.
So what is Eclipse OMR? In a nutshell, OMR is an open-sourced and resuable C++ library for building runtimes….
Here is a non-exhaustive list of the Eclipse OMR components. I want to emphasize on the three components in red: gc is garbage collection framework for heap memory management, compiler is JIT compiler framework for improved runtime performance, and jitbuilder is a library that provides a simplified API interface to the JIT compiler component to make it easier to write a new JIT compiler. To date, the Eclipse OMR project has over 1 million lines of code, and more functionality and components are coming.
There have been a number of proof of concept projects based on Eclipse OMR using the JitBuilder API. We listed 9 of these projects here. On the right hand side, we can see the numbers of lines of code required to incorporate the OMR JIT compiler into these projects. It ranges from about 3000 lines of code to less than 100 lines of code. It is very impressive, requiring much fewer lines of code than writing a JIT compiler from scratch. I want to point out project #6 the WebAssembly JIT project, which is what we will be using later today for our first hands-on tutorial.
Here are some key facts about the Eclipse OMR project. The project repository is being hosted on github under the Eclipse foundation. It has a dual license: Eclipse Public License v2.0 and Apache 2.0 license. Both licenses are permissive licenses that do not require derivative work or modifications to be distributed using the same licenses. Everyone is welcome to participate and contributions to the Eclipse OMR project are greatly appreciated.
Here is a snapshot of Eclispe OMR I took this weekend, there were over 450 open issues, 60 open pull requests, and over 100 contributors in the community. As you can see from the picture on the bottom, there have been continuous commit acitivites since the project’s inception in 2016.
The IBM Runtime Technologies team has had a long history of collaborating with universities and research institutions. Currently, we are collaborating with UNB, Alberta,…
This year, we started expanding collaborations outside of North America. We are talking to IIT in India, a couple of universities in UK, Manchester and Edinburgh, we are also expanding our existing collaborations with UofT, and started initial discussions with Delaware.
If you are wondering what potential collaboration project ideas there may be, I listed a few interesting areas here. The new JIT-as-a-Service framework opens doors to a lot of interesting research opportunities that didn’t exist before. Mark Stoodley will give a talk on the JIT-as-a-Service project in more detail later today.
Here are many ways you can join the Eclipse OMR community. There are issues marked with beginner and help wanted labels – a great place to get familiar with the code base and start contributing to the project right away.