#DevoxxUS #EclipseOMR @EclipseOMR
Eclipse OMR: A Modern, Open-Source Toolkit For
Building Language RuntimesDaryl Maier
IBM Runtimes
#DevoxxUS #EclipseOMR @EclipseOMR 2
About me• Senior software developer at IBM Canada
• Developing advanced compiler technology for HPC and dynamic languages for 20+ years
• Recently led a team to open-source IBM’s Testarossa compiler technology that underpins the J9 Java VM and many static languages
• Currently working on contributing even more compiler technology into Eclipse OMR and integrating into existing language runtimes
#DevoxxUS #EclipseOMR @EclipseOMR 3
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
#DevoxxUS #EclipseOMR @EclipseOMR 4
This session…• Introduction to Eclipse OMR• Eclipse OMR unboxing• Projects in the wild• Where are we going?• How you can get involved!
#DevoxxUS #EclipseOMR @EclipseOMR
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
Contributors are very welcome https://github.com/eclipse/omr/blob/master/CONTRIBUTING.md
Eclipse OMRCreated March 2016
#DevoxxUS #EclipseOMR @EclipseOMR 6
And before anyone asks…What does OMR stand for?
#DevoxxUS #EclipseOMR @EclipseOMR 7
And before anyone asks…
• Technically, nothing: it’s not an acronym• Historically, it stood for “Open Managed Runtime”, but the Eclipse
OMR project is not a managed runtime• The three letters persisted, however…
What does OMR stand for?
#DevoxxUS #EclipseOMR @EclipseOMR 8
And before anyone asks…
Does it have anything to do with the Eclipse IDE?
#DevoxxUS #EclipseOMR @EclipseOMR 9
And before anyone asks…
Nope--it is simply a project at the Eclipse Foundation and is not associated with the Eclipse IDE.
Does it have anything to do with the Eclipse IDE?
#DevoxxUS #EclipseOMR @EclipseOMR 10
What’s in a Language Runtime?
#DevoxxUS #EclipseOMR @EclipseOMR 11
Java Execution Environment
What’s in a Language Runtime for Java?
JavaPlatform Abstraction Layer
JavaGarbageCollector
JavaDiagnostic and
Monitoring Services
Source Code Bytecode/ASTCompiler
JavaJust-In-Time
Compiler
InterpreterJava
SourceJava
BytecodeCompiler
JavaBytecode
Interpreter
#DevoxxUS #EclipseOMR @EclipseOMR 12
Ruby Execution Environment
What’s in a Language Runtime for Ruby?
RubyPlatform Abstraction Layer
RubyGarbageCollector
RubyDiagnostic and
Monitoring Services
Source Code Bytecode/ASTCompiler
Just-In-TimeCompiler
InterpreterRuby
SourceRuby
BytecodeCompiler
RubyBytecode
Interpreter
#DevoxxUS #EclipseOMR @EclipseOMR 13
Javascript Execution Environment
What’s in a Language Runtime for Javascript ?
JavascriptPlatform Abstraction Layer
JavascriptGarbageCollector
JavascriptDiagnostic and
Monitoring Services
Source Code Bytecode/ASTCompiler
Just-In-TimeCompiler
InterpreterJavascript
SourceJavascriptBytecodeCompiler
JavascriptBytecode
Interpreter
JavascriptJust-In-Time
Compiler
#DevoxxUS #EclipseOMR @EclipseOMR 14
Similar components, but completely different implementations
Investment in one runtime has close to zero carry over to other runtimesMatters more as more workloads move into the cloud
#DevoxxUS #EclipseOMR @EclipseOMR 15
Cloud platforms really depend on runtimes
• Cloud platforms should be:• Resilient• Secure• Efficient• Elastic• Consistent
• Can only build on runtime support!• Different runtime technology means
advancing cloud platforms is expensive, slow, and depends on many different communities
#DevoxxUS #EclipseOMR @EclipseOMR 16
Eclipse OMR missionBuild an open reusable language runtime foundation for the cloud
• To accelerate cloud platform advancement and innovation
• In full cooperation with existing language communities
• Via a diverse community of people interested in language runtimes• Professional developers• Researchers• Students• Hobbyists
#DevoxxUS #EclipseOMR @EclipseOMR 17
Java Execution Environment
Start from the enterprise caliber IBM J9 Java runtime
J9 JavaPlatform Abstraction Layer
J9 JavaGarbageCollector
J9 JavaDiagnostic and
Monitoring Services
Source Code Bytecode/ASTCompiler
J9 JavaJust-In-Time Compiler
InterpreterJava
SourceJ9 Java
BytecodeCompiler
J9 JavaBytecode
Interpreter
#DevoxxUS #EclipseOMR @EclipseOMR 18
J9 Java
JIT Compiler Glue
J9 Java Execution Environment
Refactor “Java”-ness into a Glue layer that adds language specifics to each core component
OMRPlatform Abstraction Layer
OMR Garbage Collector
OMRDiagnostic and
Monitoring Services
Source Code Bytecode/ASTCompiler
InterpreterJava
SourceJ9 Java
BytecodeCompiler
J9 JavaBytecode
Interpreter
J9 Java Diagnostic and Monitoring Glue
J9 Java GC
Glue
OMRJust in Time
(JIT) Compiler
#DevoxxUS #EclipseOMR @EclipseOMR 19
Form Eclipse OMR around core components
OMRPlatform Abstraction Layer
OMRGarbageCollector
OMRDiagnostic and
Monitoring Services
OMRJust in Time
(JIT) Compiler
#DevoxxUS #EclipseOMR @EclipseOMR 20
Goals of Eclipse OMR1. OMR has no language semantics
2. OMR is not a language runtime
3. OMR components can be integrated into any language runtime, new or existing, without influencing language semantics
#DevoxxUS #EclipseOMR @EclipseOMR 21
#DevoxxUS #EclipseOMR @EclipseOMR 22
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 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 runtime might consume OMR components; and 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 to date, more runtime technology coming!
Eclipse OMR unboxing
#DevoxxUS #EclipseOMR @EclipseOMR 23
Garbage collection technology• Highly parallel, scalable garbage collector
• Exploits multiple cores• Balances work for multiple threads
• Rock solid automatic memory management for language runtimes• Used for over a decade in the IBM J9 enterprise caliber Java Virtual Machine
• Start by integrating Mark/Sweep GC• Typically <100 lines of code
• Then, add even more advanced capabilities as needed• Compaction• Generational• Concurrent
#DevoxxUS #EclipseOMR @EclipseOMR 24
What is Mark-Sweep GC?• Periodically, garbage collector stops all active application threads• Phase 1: Mark live objects by walking the live object graph
• Traversal begins from objects kept in a “root” set (e.g. global variables, local variables in every active frame on every thread stack, etc.)
• Each unmarked object is marked as live, then visit any objects it points at
• Phase 2: Sweep through memory to find memory not used by live objects• Unused memory regions added to free list(s)
• Once all memory has been swept, application threads restarted• Memory allocations can then take advantage of space added to free lists
#DevoxxUS #EclipseOMR @EclipseOMR 25
Hooking up the OMR Mark/Sweep Collector1. Call OMR_Initialize_VM() at startup2. Implement GC glue layer calls:
• getSizeInBytesWithHeader()• CollectorLanguageInterfaceImpl::markingScheme_scanRoots()• MM_CollectorLanguageInterfaceImpl::markingScheme_scanObject()
3. Use OMR_GC_Allocate() function to allocate objects4. Use OMR_GC_SystemCollect() function to trigger GC cycles5. Configure heap size at runtime
• e.g. OMR_GC_OPTIONS=“-Xmx2m”
6. Call OMR_Shutdown_VM() at shutdown
#DevoxxUS #EclipseOMR @EclipseOMR 26
Compiler technology• Heritage is a dynamic JIT for embedded Java
• Proven its flexibility by underpinning static compilers and binary retranslators• Clean room implementation
• Mix of C++, C, native assembler
• Design goals• Fast startup time• Miserly memory management• Flexible to meet different footprint configurations
#DevoxxUS #EclipseOMR @EclipseOMR 27
Compiler technology• Configurable high-level optimization framework
• Classic, loop, dataflow, control flow• High performance code generation with deep platform exploitation
• X86, Power, System Z, ARMv7
• Dynamic recompilation with profile-directed feedback• Speculative optimizations and supporting runtime framework
#DevoxxUS #EclipseOMR @EclipseOMR 28
ARM
Optimizer
Analyses and Optimizations
cold warm hot FSDscorching AOT
IL Generation
x86POWER
Z
Code Generators
RuntimeEnvironment/Configuration
•Options
•Object Model
•Memory
•Threading
•Tracing
codeMetadataRuntimeRT Helpers
very hot profiling
JITBuilder
Profile Manager
Hardwarecounters
SamplingThread
InterpreterProfile Info
JIT Profile Info
Profiler
#DevoxxUS #EclipseOMR @EclipseOMR 29
Hooking up a compiler via a native IL generator• Produce OMR IL directly from interpreted method “bytecodes”• Deepest exploitation with the Eclipse OMR compiler technology Maximize performance and functionality Permits greatest specialization for a host runtime Steeper learning curve, esp. OMR compiler intermediate language You assume ownership of complexity
#DevoxxUS #EclipseOMR @EclipseOMR 30
Hooking up a compiler via JITBuilder• Prototype interface to compiler technology• Designed to simplify work to bootstrap a JIT compiler to generate native instructions
for interpreted methods• https://developer.ibm.com/open/2016/07/19/jitbuilder-library-and-eclipse-omr-just
-in-time-compilers-made-easy• https://developer.ibm.com
/open/2017/03/08/build-more-complicated-methods-using-the-jitbuilder-library Simple API to describe method prototypes and behaviours, types, bytecode
interpretation, and compile and dispatch functionality Sacrifice some performance and specialization for rapid integration of compiler
technology Technology is a WIP, but continually improving
#DevoxxUS #EclipseOMR @EclipseOMR 31
In the wild: IBM SDKs for Java• IBM’s production Java Virtual Machine
• High performance, scalable, high reliability, serviceable• Independent implementation• Origin of much of Eclipse OMR technology
• IBM SDK for Java 8 delivered in 2014• Consumes, extends, and customizes Eclipse OMR for Java• Demonstrates versatility and adaptability of the technology• Important quality and performance proof points
#DevoxxUS #EclipseOMR @EclipseOMR 32
OpenJ9• IBM to open source the J9 Java Virtual Machine in 2017
• Preparations to open source proceeding in parallel with IBM SDK for Java 9 development
• Why open-source?• Facilitate collaboration and enable rapid innovation• Competition drives innovation• Cross-platform, cross-technology innovation
#DevoxxUS #EclipseOMR @EclipseOMR 33
OpenJ9 open source project• Most robust extension of Eclipse OMR technology
• Port Layer, Garbage collection, Compiler, Tooling, …
• Upstream repo for Java VM projects
• Open community governance
• Status: not public yet, likely around IBM Java 9 release• http://openj9.org
#DevoxxUS #EclipseOMR @EclipseOMR 34
Ruby• Integration of Eclipse OMR technology into CRuby VM
• GC + compiler technology -> CRuby 2.2• Compiler technology -> CRuby 2.4
• POCs show potential, can successfully run Rails• Goal is for Eclipse OMR to help achieve Ruby 3x3 target
• Requires better VM / JIT / GC communication of state-changing events• Profiling, type specialization, inlining optimizations required
• Repo: https://github.com/rubyomr-preview/ruby.git
Help Wanted!
#DevoxxUS #EclipseOMR @EclipseOMR 35
Lua• Experimental Eclipse OMR compiler integration as proof point for
technology and driving JitBuilder innovation• Status
• Produce compiler IL for all 47 Lua instructions• 50 LOC changes needed to integrate with PUC-Rio Lua 5.3• ~2000 LOC Lua compiler + Eclipse OMR• Performance: 2x performance over interpreted w/ Mandelbrot
• Repo: https://github.com/Leonardo2718/lua-vermelha• https://fosdem.org/2017/schedule/event/eclipse_omr
Help Wanted!
#DevoxxUS #EclipseOMR @EclipseOMR 36
SOM• Minimal Smalltalk implementation for teaching and experimentation
with virtual machines
• CSOM : proof point of simple integration of GC technology (approx 20% full benchmark speed up)
• SOM++ : proof point of simple integration with JitBuilder technology (1 week of work yielded benchmark speedups of 2x-15x)
#DevoxxUS #EclipseOMR @EclipseOMR 37
Base9 (B9)• Educational VM for demonstrating integration of Eclipse OMR
technology into a typical interpreted language VM• Small bytecode set (initially!)• Stack-based interpreter• Primitive types
• Integration with Eclipse OMR• JitBuilder : straightforward integration can yield 760x perf improvement over
interpreter on Fibonacci test (compilation, inlining)
• Repo: https://github.com/youngar/Base9
#DevoxxUS #EclipseOMR @EclipseOMR 38
What’s next?• IBM actively contributing to the technology
• Pulling commits hourly into development version of J9 Java 9
• Improve onboarding experience• Documentation, designs, sample code, how-to blogs• Create a Discourse instance for community project discussion
• Improve testability• Community building
• Grow the base of the Eclipse OMR project• Work with language runtime communities to foster broader adoption and drive improvements into
the technology
• Engage with research communities• Research projects in runtime/compiler technologies based on Eclipse OMR• Eclipse OMR as an undergrad/graduate teaching platform for runtime technologies
#DevoxxUS #EclipseOMR @EclipseOMR 39
Getting involved• GitHub repo contributions
• Require an account at Eclipse.org and you must sign the Eclipse ECA• https://projects.eclipse.org/user/sign/cla
• Contribution guidelines• https://github.com/eclipse/omr/blob/master/CONTRIBUTING.md
• Google Summer of Code• Eclipse Foundation is a mentoring organization• Project suggestions for prospective students: http://bit.ly/2mDGnwS
#DevoxxUS #EclipseOMR @EclipseOMR 40
More Eclipse OMR in actionJoin Bjørn Vårdal’s Tools-In-Action session:
Secrets of building a debuggable runtime: Learn how language implementors solve your runtime issues
Grand Ballroom 220AThursday, March 23 @ 3:30-4:00 pm
#DevoxxUS #EclipseOMR @EclipseOMR 41
http://www.eclipse.org/omrhttps://github.com/eclipse/omr
https://developer.ibm.com/open/omr/
Users and contributors very welcome! https://github.com/eclipse/omr/blob/master/CONTRIBUTING.md
Eclipse OMR
Mark StoodleyEclipse OMR Project [email protected]
Daryl MaierIBM OMR Compiler [email protected]
Charlie GracieEclipse OMR Project [email protected]
Follow us @EclipseOMR
© 2017 IBM Corporation
Mission Badge #6:SMS Text
Your mission should you choose to accept it….
Join us at the IBM Booth for hands-on labs, demos, games and talk to our developers.
Text Innovation to 41411to get one step closer to the booth giveaway and learn more about all the IBM sessions & speakers.
Enter the raffle by completing missions for a chance to win• a Drone• TJBot Kit • VR glasses
#DevoxxUS #EclipseOMR @EclipseOMR 43
Questions?