eclipse omr: a modern, open-source toolkit for building language runtimes

43
#DevoxxUS #EclipseOMR @EclipseOMR Eclipse OMR: A Modern, Open-Source Toolkit For Building Language Runtimes Daryl Maier IBM Runtimes [email protected]

Upload: devevents

Post on 11-Apr-2017

14 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#DevoxxUS #EclipseOMR @EclipseOMR

Eclipse OMR: A Modern, Open-Source Toolkit For

Building Language RuntimesDaryl Maier

IBM Runtimes

[email protected]

Page 2: Eclipse OMR: a modern, open-source toolkit for building language 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

Page 3: Eclipse OMR: a modern, open-source toolkit for building 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

Page 4: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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!

Page 5: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 6: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#DevoxxUS #EclipseOMR @EclipseOMR 6

And before anyone asks…What does OMR stand for?

Page 7: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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?

Page 8: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#DevoxxUS #EclipseOMR @EclipseOMR 8

And before anyone asks…

Does it have anything to do with the Eclipse IDE?

Page 9: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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?

Page 10: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#DevoxxUS #EclipseOMR @EclipseOMR 10

What’s in a Language Runtime?

Page 11: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 12: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 13: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 14: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 15: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 16: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 17: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 18: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 19: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#DevoxxUS #EclipseOMR @EclipseOMR 19

Form Eclipse OMR around core components

OMRPlatform Abstraction Layer

OMRGarbageCollector

OMRDiagnostic and

Monitoring Services

OMRJust in Time

(JIT) Compiler

Page 20: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 21: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#DevoxxUS #EclipseOMR @EclipseOMR 21

Page 22: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 23: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 24: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 25: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 26: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 27: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 28: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 29: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 30: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 31: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 32: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 33: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 34: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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!

Page 35: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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!

Page 36: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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)

Page 37: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 38: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 39: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 40: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 41: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#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

Page 42: Eclipse OMR: a modern, open-source toolkit for building language runtimes

© 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

Page 43: Eclipse OMR: a modern, open-source toolkit for building language runtimes

#DevoxxUS #EclipseOMR @EclipseOMR 43

Questions?