SlideShare a Scribd company logo
JVM++: The Graal VM
Martin Toshev,
BGOUG, 04.06.2016
Special thanks to Thomas Wuerthinger and
Oracle Labs for inspiring this presentation …
Who am I
Software consultant (CoffeeCupConsulting)
BG JUG board member (http://jug.bg)
OpenJDK and Oracle RDBMS enthusiast
Who am I
Author of Learning RabbitMQ
Agenda
• Overview of the Graal VM
• Building and managing Graal
• Performance benchmarks
• Future directions
Overview of the Graal VM
Overview of the Graal VM
Some background …
static compilation vs dynamic compilation
static compiler
source code (e.g. JVM bytecode)
dynamic compiler
runtime
machine code
runtime
source code (e.g. JVM bytecode)
machine code
Overview of the Graal VM
• The javac tool performs static compilation of Java
sources to bytecode
• The JVM may perform dynamic compilation of
bytecode to machine code for optimization using a
JIT (Just-in-Time) compiler
Overview of the Graal VM
• Graal is a new JIT (Just-in-Time) compiler for the
JVM
• Brings the performance of Java to scripting
languages (via the Truffle API)
• written in Java
Overview of the Graal VM
• In essence the Graal JIT compiler generates
machine code from an optimized AST rather than
bytecode
• However the Graal VM has both AST and bytecode
interpreters
Overview of the Graal VM
• The Graal VM supports the following types of
compilers (apart from the Graal JIT compiler):
--vm server-nograal // server compiler
--vm server // server compiler using Graal
--vm graal // Graal compiler using Graal
--vm client-nograal // client compiler
--vm client // client compiler running Graal
Overview of the Graal VM
• The Truffle API:
– is a Java API
– provides AST (Abstract Syntax Tree) representation of
source code
– provides a mechanism to convert the generated AST
into a Graal IR (intermediate representation)
Overview of the Graal VM
• The Truffle API is declarative (uses Java
annotations)
• The AST graph generated by Truffle is a mixture of
control flow and data flow graph
• Essential feature of the Truffle API is the ability to
specify node specializations used in node rewriting
Overview of the Graal VM
• The Truffle API is used in conjunction with custom
annotation processor that generates code based
on the Truffle annotations used in the interpreter
classes
Truffle
Interpreter
javac
Annotation
processor
Compiled
Interpreter
Generated
Interpreter
source code
Overview of the Graal VM
• General architecture:
HotSpot VM (C++)
Graal (Java)
Truffle (Java) Java Other JVM language
JavaScript Ruby R
Other interpreted
language
Graal <–> Hotspot adapter (C++, Java)
Maxine VM (Java)
Graal <–> Maxine
adapter (Java)
Overview of the Graal VM
• Let’s see, for example, how a JavaScript interpreter
works in Graal …
Overview of the Graal VM
HotSpot VM (C++)
Graal (Java)
Truffle (Java) Java Other JVM language
JavaScript Ruby R
Other interpreted
language
Graal <–> Hotspot adapter (C++, Java)
Run JavaScript file: app.js
Overview of the Graal VM
HotSpot VM (C++)
Graal (Java)
Truffle (Java) Java Other JVM language
JavaScript Ruby R
Other interpreted
language
Graal <–> Hotspot adapter (C++, Java)
JavaScript Interpreter parses app.js and converts it to Truffle AST
Overview of the Graal VM
HotSpot VM (C++)
Graal (Java)
Truffle (Java) Java Other JVM language
JavaScript Ruby R
Other interpreted
language
Graal <–> Hotspot adapter (C++, Java)
The app.js Truffle AST is converted to Graal IR (AST)
Overview of the Graal VM
HotSpot VM (C++)
Graal (Java)
Truffle (Java) Java Other JVM language
JavaScript Ruby R
Other interpreted
language
Graal <–> Hotspot adapter (C++, Java)
The Graal VM has bytecode and AST interpreters along with a JIT compiler
(optimizations and AST lowering is performed to generate machine code
and perform partial evaluation)
Overview of the Graal VM
HotSpot VM (C++)
Graal (Java)
Truffle (Java) Java Other JVM language
JavaScript Ruby R
Other interpreted
language
Graal <–> Hotspot adapter (C++, Java)
When parts of app.js are compiled to machine code by the Graal compiler
the compiled code is transferred to Hotspot for execution by means of
Hotspot APIs and with the help of a Graal – Hotspot adapter interface
Overview of the Graal VM
HotSpot VM (C++)
Graal (Java)
Truffle (Java) Java Other JVM language
JavaScript Ruby R
Other interpreted
language
Graal <–> Hotspot adapter (C++, Java)
Compiled code can also be deoptimized and control is transferred back to
the interpreter (e.g. when an exception occurs, an assumption fails or a
guard is reached)
Overview of the Graal VM
• Optimizations done on the Graal IR include:
– method inlining
– partial escape analysis
– inline caching
– constant folding
– arithmetic optimizations and others …
Overview of the Graal VM
• Currently supported languages include:
– JavaScript (Graal.JS)
– R (FastR)
– Ruby (RubyTruffle)
– Experimental interpreters for C, Python, Smalltalk, LLVM
IR and others …
(some are not open-sourced as of the time of this presentation)
Overview of the Graal VM
• The SimpleLanguage project provides a showcase
on how to use the Truffle APIs
Source file Parser Truffle AST Graal VM
Building the Graal VM
Building the Graal VM
• The Graal VM interoperates with JEP 243: Java-
Level JVM Compiler Interface
• In that regard two modes of operation are
supported – via the Graal VM or via the JVMCI
(JVM Compiler Interface)
Building the Graal VM
• Early access builds of Graal available for download
• You can build Graal on any supported platform
(Windows, Linux, MacOS, Solaris) from source
code
Building the Graal VM
git clone https://github.com/graalvm/mx.git
export PATH=$PWD/mx:$PATH
git clone https://github.com/graalvm/graal-core.git
cd graal-core
mx --vm graal build
mx vm
Building the Graal VM
• The MX tool is a Python (2.7) tool that manages the
Graal projects and allows to:
- update sources and run JUnit tests and benchmarks;
- builds (sub)projects (Java and C++ sources can be built
separately);
- runs VM tools (such as IGV or c1visualizer) that can aid
development of Graal or language interpreters;
- can be used to generate IDE project files for Graal development
(support for Eclipse and NetBeans)
The Graal VM
demo
Performance benchmarks
Performance benchmarks
• According to various JVM benchmarks such as SPECjvm2008
and Scala Dacapo the Graal compiler positions between the
client and server JVM compilers
(source: One VM to Rule Them All, Thomas Wuertinger)
• In general Truffle interpreters provide much better
performance for some dynamic languages
Performance benchmarks
• Graal.JS – shows improvement of 1.5x in some cases
with a peak of 2.6x compared to V8 (running Google Octane’s
benchmark)
• RubyTruffle – shows improvements between 1.5x and 4.5x in some
cases with a peak of 14x compared to JRuby
• FastR - shows improvements between 2x and 39x in some cases
with a peak of 94x compared to GnuR
(source: One VM to Rule Them All, Thomas Wuertinger)
Future directions
Future directions
• Graal provides an extensible framework for
researching and experimenting with other
compiler optimizations
• In that regard new types of compiler optimization
may be introduced in the VM that address runtime
behavior in certain scenarios
Future directions
• Graal provides an extensible framework for
creating language interpreters further simplified by
the Truffle API
• In that regard more languages can be introduced
that run in the Graal VM
• Currently existing languages that compile to
bytecode may support Truffle in the future
Future directions
• Graal provides an extensible framework for
different types of operating systems and CPU
architectures
• In that regard CPU architectures and operating
systems might be supported by Graal
Thank you !
Q&A
References
Graal Project
http://openjdk.java.net/projects/graal/
Graal - A New Just In Time Compiler for the JVM
http://www.oracle.com/technetwork/oracle-labs/program-
languages/overview/index.html
Graal VM: GitHub repositories
https://github.com/graalvm
References
Graal - A Bytecode Agnostic Compiler for the JVM, Thomas Wuerthinger, JVM
Language Summit
http://medianetwork.oracle.com/video/player/1113230360001
Graal and Truffle: One VM to Rule Them All
http://www.slideshare.net/ThomasWuerthinger/graal-truffle-
ethdec2013?qid=848a4965-9768-40d5-b167-
ccd8eb7d1659&v=&b=&from_search=2
References
Graal and Truffle: Modularity and Separation of Concerns as Cornerstones for
Building a Multipurpose Runtime
http://www.slideshare.net/ThomasWuerthinger/2014-0424-graal-
modularity?qid=0e86ed21-0b8f-4087-9212-
68f76546d674&v=&b=&from_search=4
Dynamic Compilation - Thomas Wuerthinger
https://www.youtube.com/watch?v=RLsG2kE1EMI
https://www.youtube.com/watch?v=U_QpToYLsO0
JVMLS 2012: Graal
http://medianetwork.oracle.com/video/player/1785432492001
References
Graal Tutorial at CGO 2015 by Christian Wimmer
http://lafo.ssw.uni-linz.ac.at/papers/2015_CGO_Graal.pdf
Writing a language in Truffle: Part 1 - Using Truffle and Graal
https://cesquivias.github.io/blog/2014/10/13/writing-a-language-in-truffle-
part-1-a-simple-slow-interpreter/
Writing a language in Truffle: Part 2 - Using Truffle and Graal
http://cesquivias.github.io/blog/2014/12/02/writing-a-language-in-truffle-
part-2-using-truffle-and-graal/
References
Graal publications, JKU, Linz
http://ssw.jku.at/Research/Projects/JVM/Graal.html
Truffle publications, JKU, Linz
http://ssw.jku.at/Research/Projects/JVM/Truffle.html
References
R as a citizen in a Polyglot world: The promise of the Truffle framework
http://user2015.math.aau.dk/presentations/112.pdf
Truffle/C Interpreter
http://www.manuelrigger.at/downloads/trufflec_thesis.pdf
Graal.JS - high-performance JavaScript on the JVM talk by Christian Wirth
https://www.youtube.com/watch?v=OUo3BFMwQFo

More Related Content

PPTX
Discover Quarkus and GraalVM
PDF
GraalVm and Quarkus
PDF
GraalVM Native and Spring Boot 3.0
PDF
Graal and Truffle: One VM to Rule Them All
PPTX
Introduction to GraalVM
PDF
Spring Native and Spring AOT
PPTX
Discover Quarkus and GraalVM
GraalVm and Quarkus
GraalVM Native and Spring Boot 3.0
Graal and Truffle: One VM to Rule Them All
Introduction to GraalVM
Spring Native and Spring AOT

What's hot (20)

PDF
Spring Boot
PDF
Gradle Introduction
PDF
SpringOne Tour: Spring Boot 3 and Beyond
PPTX
How and Why GraalVM is quickly becoming relevant for developers (ACEs@home - ...
PDF
GraalVM: Run Programs Faster Everywhere
PDF
Gradle - the Enterprise Automation Tool
PDF
Quarkus - a next-generation Kubernetes Native Java framework
PDF
GraalVM Native Images by Oleg Selajev @shelajev
PDF
PPTX
Spring boot Introduction
PPTX
Spring Boot
PDF
GraphQL Fundamentals
PPTX
Stability Patterns for Microservices
ODP
Java 9 Features
PPTX
Maven ppt
PDF
Spring Boot
PDF
Reactive Microservices with Quarkus
PPTX
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
PDF
Secrets of Performance Tuning Java on Kubernetes
PDF
Introduction to Java 11
Spring Boot
Gradle Introduction
SpringOne Tour: Spring Boot 3 and Beyond
How and Why GraalVM is quickly becoming relevant for developers (ACEs@home - ...
GraalVM: Run Programs Faster Everywhere
Gradle - the Enterprise Automation Tool
Quarkus - a next-generation Kubernetes Native Java framework
GraalVM Native Images by Oleg Selajev @shelajev
Spring boot Introduction
Spring Boot
GraphQL Fundamentals
Stability Patterns for Microservices
Java 9 Features
Maven ppt
Spring Boot
Reactive Microservices with Quarkus
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
Secrets of Performance Tuning Java on Kubernetes
Introduction to Java 11
Ad

Viewers also liked (20)

PDF
Graal and Truffle: Modularity and Separation of Concerns as Cornerstones for ...
PDF
Graal Tutorial at CGO 2015 by Christian Wimmer
PDF
Graal VM: Multi-Language Execution Platform
PPTX
Scalable SAAS Meetup - Oct 6th
PPTX
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
PPTX
Security Аrchitecture of Тhe Java Platform
PPTX
Writing Stored Procedures with Oracle Database 12c
PDF
2016 JavaOne Deconstructing REST Security
PPTX
Writing Stored Procedures in Oracle RDBMS
PPTX
Writing Java Stored Procedures in Oracle 12c
PPTX
Modular Java
PPTX
RxJS vs RxJava: Intro
PPTX
Spring RabbitMQ
PDF
KDB database (EPAM tech talks, Sofia, April, 2015)
PPTX
Gábor Horváth - Code Generation in Serializers and Comparators of Apache Flink
PPTX
Security Architecture of the Java platform
PDF
Eclipse plug in development
PPTX
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
PPTX
The HaLVM: A Simple Platform for Simple Platforms
PPTX
Service Discovery and Registration in a Microservices Architecture
Graal and Truffle: Modularity and Separation of Concerns as Cornerstones for ...
Graal Tutorial at CGO 2015 by Christian Wimmer
Graal VM: Multi-Language Execution Platform
Scalable SAAS Meetup - Oct 6th
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Security Аrchitecture of Тhe Java Platform
Writing Stored Procedures with Oracle Database 12c
2016 JavaOne Deconstructing REST Security
Writing Stored Procedures in Oracle RDBMS
Writing Java Stored Procedures in Oracle 12c
Modular Java
RxJS vs RxJava: Intro
Spring RabbitMQ
KDB database (EPAM tech talks, Sofia, April, 2015)
Gábor Horváth - Code Generation in Serializers and Comparators of Apache Flink
Security Architecture of the Java platform
Eclipse plug in development
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
The HaLVM: A Simple Platform for Simple Platforms
Service Discovery and Registration in a Microservices Architecture
Ad

Similar to JVM++: The Graal VM (20)

PDF
Javantura v4 - JVM++ The GraalVM - Martin Toshev
PPTX
HOW TO CREATE AWESOME POLYGLOT APPLICATIONS USING GRAALVM
PDF
PDF
GraalVM - OpenSlava 2019-10-18
PDF
Run * on the JVM - Simonyi Conference Budapest April 15
PDF
GraalVM - JBCNConf 2019-05-28
PDF
GraalVM - MadridJUG 2019-10-22
PDF
Polyglot Applications with GraalVM
PDF
Jaroslav Tulach: GraalVM - z vývoje nejrychlejšího virtuálního stroje na světě
PDF
Graalvm with Groovy and Kotlin - Madrid GUG 2019
PPTX
GraalVM how to speedup & lover footprint of your app by doing nothing*
PDF
Graalvm with Groovy and Kotlin - Greach 2019
PDF
General Capabilities of GraalVM by Oleg Selajev @shelajev
PDF
PWL: One VM to Rule Them All
PDF
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
PDF
Polygot Java EE on the GraalVM
PPTX
How and why GraalVM is quickly becoming relevant for you (DOAG 2020)
PDF
The need for speed. What is GraalVM? – 4Developers Wrocław 2019
PDF
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
PDF
TechEvent Graal(VM) Performance Interoperability
Javantura v4 - JVM++ The GraalVM - Martin Toshev
HOW TO CREATE AWESOME POLYGLOT APPLICATIONS USING GRAALVM
GraalVM - OpenSlava 2019-10-18
Run * on the JVM - Simonyi Conference Budapest April 15
GraalVM - JBCNConf 2019-05-28
GraalVM - MadridJUG 2019-10-22
Polyglot Applications with GraalVM
Jaroslav Tulach: GraalVM - z vývoje nejrychlejšího virtuálního stroje na světě
Graalvm with Groovy and Kotlin - Madrid GUG 2019
GraalVM how to speedup & lover footprint of your app by doing nothing*
Graalvm with Groovy and Kotlin - Greach 2019
General Capabilities of GraalVM by Oleg Selajev @shelajev
PWL: One VM to Rule Them All
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
Polygot Java EE on the GraalVM
How and why GraalVM is quickly becoming relevant for you (DOAG 2020)
The need for speed. What is GraalVM? – 4Developers Wrocław 2019
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
TechEvent Graal(VM) Performance Interoperability

More from Martin Toshev (15)

PPTX
Building highly scalable data pipelines with Apache Spark
PPTX
Big data processing with Apache Spark and Oracle Database
PPT
Jdk 10 sneak peek
PPT
Semantic Technology In Oracle Database 12c
PPTX
Practical security In a modular world
PPT
Java 9 Security Enhancements in Practice
PPTX
Java 9 sneak peek
PPTX
Spring RabbitMQ
PPTX
Oracle Database 12c Attack Vectors
PDF
Concurrency Utilities in Java 8
PPTX
The RabbitMQ Message Broker
PPTX
java2days 2014: Attacking JavaEE Application Servers
PPTX
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
PPTX
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
PPTX
New Features in JDK 8
Building highly scalable data pipelines with Apache Spark
Big data processing with Apache Spark and Oracle Database
Jdk 10 sneak peek
Semantic Technology In Oracle Database 12c
Practical security In a modular world
Java 9 Security Enhancements in Practice
Java 9 sneak peek
Spring RabbitMQ
Oracle Database 12c Attack Vectors
Concurrency Utilities in Java 8
The RabbitMQ Message Broker
java2days 2014: Attacking JavaEE Application Servers
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
New Features in JDK 8

Recently uploaded (20)

PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
System and Network Administraation Chapter 3
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Nekopoi APK 2025 free lastest update
PDF
System and Network Administration Chapter 2
PPTX
L1 - Introduction to python Backend.pptx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Upgrade and Innovation Strategies for SAP ERP Customers
System and Network Administraation Chapter 3
Wondershare Filmora 15 Crack With Activation Key [2025
Odoo POS Development Services by CandidRoot Solutions
How Creative Agencies Leverage Project Management Software.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Nekopoi APK 2025 free lastest update
System and Network Administration Chapter 2
L1 - Introduction to python Backend.pptx
2025 Textile ERP Trends: SAP, Odoo & Oracle
ISO 45001 Occupational Health and Safety Management System
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Operating system designcfffgfgggggggvggggggggg
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Lecture 3: Operating Systems Introduction to Computer Hardware Systems

JVM++: The Graal VM

  • 1. JVM++: The Graal VM Martin Toshev, BGOUG, 04.06.2016
  • 2. Special thanks to Thomas Wuerthinger and Oracle Labs for inspiring this presentation …
  • 3. Who am I Software consultant (CoffeeCupConsulting) BG JUG board member (http://jug.bg) OpenJDK and Oracle RDBMS enthusiast
  • 4. Who am I Author of Learning RabbitMQ
  • 5. Agenda • Overview of the Graal VM • Building and managing Graal • Performance benchmarks • Future directions
  • 6. Overview of the Graal VM
  • 7. Overview of the Graal VM Some background … static compilation vs dynamic compilation static compiler source code (e.g. JVM bytecode) dynamic compiler runtime machine code runtime source code (e.g. JVM bytecode) machine code
  • 8. Overview of the Graal VM • The javac tool performs static compilation of Java sources to bytecode • The JVM may perform dynamic compilation of bytecode to machine code for optimization using a JIT (Just-in-Time) compiler
  • 9. Overview of the Graal VM • Graal is a new JIT (Just-in-Time) compiler for the JVM • Brings the performance of Java to scripting languages (via the Truffle API) • written in Java
  • 10. Overview of the Graal VM • In essence the Graal JIT compiler generates machine code from an optimized AST rather than bytecode • However the Graal VM has both AST and bytecode interpreters
  • 11. Overview of the Graal VM • The Graal VM supports the following types of compilers (apart from the Graal JIT compiler): --vm server-nograal // server compiler --vm server // server compiler using Graal --vm graal // Graal compiler using Graal --vm client-nograal // client compiler --vm client // client compiler running Graal
  • 12. Overview of the Graal VM • The Truffle API: – is a Java API – provides AST (Abstract Syntax Tree) representation of source code – provides a mechanism to convert the generated AST into a Graal IR (intermediate representation)
  • 13. Overview of the Graal VM • The Truffle API is declarative (uses Java annotations) • The AST graph generated by Truffle is a mixture of control flow and data flow graph • Essential feature of the Truffle API is the ability to specify node specializations used in node rewriting
  • 14. Overview of the Graal VM • The Truffle API is used in conjunction with custom annotation processor that generates code based on the Truffle annotations used in the interpreter classes Truffle Interpreter javac Annotation processor Compiled Interpreter Generated Interpreter source code
  • 15. Overview of the Graal VM • General architecture: HotSpot VM (C++) Graal (Java) Truffle (Java) Java Other JVM language JavaScript Ruby R Other interpreted language Graal <–> Hotspot adapter (C++, Java) Maxine VM (Java) Graal <–> Maxine adapter (Java)
  • 16. Overview of the Graal VM • Let’s see, for example, how a JavaScript interpreter works in Graal …
  • 17. Overview of the Graal VM HotSpot VM (C++) Graal (Java) Truffle (Java) Java Other JVM language JavaScript Ruby R Other interpreted language Graal <–> Hotspot adapter (C++, Java) Run JavaScript file: app.js
  • 18. Overview of the Graal VM HotSpot VM (C++) Graal (Java) Truffle (Java) Java Other JVM language JavaScript Ruby R Other interpreted language Graal <–> Hotspot adapter (C++, Java) JavaScript Interpreter parses app.js and converts it to Truffle AST
  • 19. Overview of the Graal VM HotSpot VM (C++) Graal (Java) Truffle (Java) Java Other JVM language JavaScript Ruby R Other interpreted language Graal <–> Hotspot adapter (C++, Java) The app.js Truffle AST is converted to Graal IR (AST)
  • 20. Overview of the Graal VM HotSpot VM (C++) Graal (Java) Truffle (Java) Java Other JVM language JavaScript Ruby R Other interpreted language Graal <–> Hotspot adapter (C++, Java) The Graal VM has bytecode and AST interpreters along with a JIT compiler (optimizations and AST lowering is performed to generate machine code and perform partial evaluation)
  • 21. Overview of the Graal VM HotSpot VM (C++) Graal (Java) Truffle (Java) Java Other JVM language JavaScript Ruby R Other interpreted language Graal <–> Hotspot adapter (C++, Java) When parts of app.js are compiled to machine code by the Graal compiler the compiled code is transferred to Hotspot for execution by means of Hotspot APIs and with the help of a Graal – Hotspot adapter interface
  • 22. Overview of the Graal VM HotSpot VM (C++) Graal (Java) Truffle (Java) Java Other JVM language JavaScript Ruby R Other interpreted language Graal <–> Hotspot adapter (C++, Java) Compiled code can also be deoptimized and control is transferred back to the interpreter (e.g. when an exception occurs, an assumption fails or a guard is reached)
  • 23. Overview of the Graal VM • Optimizations done on the Graal IR include: – method inlining – partial escape analysis – inline caching – constant folding – arithmetic optimizations and others …
  • 24. Overview of the Graal VM • Currently supported languages include: – JavaScript (Graal.JS) – R (FastR) – Ruby (RubyTruffle) – Experimental interpreters for C, Python, Smalltalk, LLVM IR and others … (some are not open-sourced as of the time of this presentation)
  • 25. Overview of the Graal VM • The SimpleLanguage project provides a showcase on how to use the Truffle APIs Source file Parser Truffle AST Graal VM
  • 27. Building the Graal VM • The Graal VM interoperates with JEP 243: Java- Level JVM Compiler Interface • In that regard two modes of operation are supported – via the Graal VM or via the JVMCI (JVM Compiler Interface)
  • 28. Building the Graal VM • Early access builds of Graal available for download • You can build Graal on any supported platform (Windows, Linux, MacOS, Solaris) from source code
  • 29. Building the Graal VM git clone https://github.com/graalvm/mx.git export PATH=$PWD/mx:$PATH git clone https://github.com/graalvm/graal-core.git cd graal-core mx --vm graal build mx vm
  • 30. Building the Graal VM • The MX tool is a Python (2.7) tool that manages the Graal projects and allows to: - update sources and run JUnit tests and benchmarks; - builds (sub)projects (Java and C++ sources can be built separately); - runs VM tools (such as IGV or c1visualizer) that can aid development of Graal or language interpreters; - can be used to generate IDE project files for Graal development (support for Eclipse and NetBeans)
  • 33. Performance benchmarks • According to various JVM benchmarks such as SPECjvm2008 and Scala Dacapo the Graal compiler positions between the client and server JVM compilers (source: One VM to Rule Them All, Thomas Wuertinger) • In general Truffle interpreters provide much better performance for some dynamic languages
  • 34. Performance benchmarks • Graal.JS – shows improvement of 1.5x in some cases with a peak of 2.6x compared to V8 (running Google Octane’s benchmark) • RubyTruffle – shows improvements between 1.5x and 4.5x in some cases with a peak of 14x compared to JRuby • FastR - shows improvements between 2x and 39x in some cases with a peak of 94x compared to GnuR (source: One VM to Rule Them All, Thomas Wuertinger)
  • 36. Future directions • Graal provides an extensible framework for researching and experimenting with other compiler optimizations • In that regard new types of compiler optimization may be introduced in the VM that address runtime behavior in certain scenarios
  • 37. Future directions • Graal provides an extensible framework for creating language interpreters further simplified by the Truffle API • In that regard more languages can be introduced that run in the Graal VM • Currently existing languages that compile to bytecode may support Truffle in the future
  • 38. Future directions • Graal provides an extensible framework for different types of operating systems and CPU architectures • In that regard CPU architectures and operating systems might be supported by Graal
  • 40. References Graal Project http://openjdk.java.net/projects/graal/ Graal - A New Just In Time Compiler for the JVM http://www.oracle.com/technetwork/oracle-labs/program- languages/overview/index.html Graal VM: GitHub repositories https://github.com/graalvm
  • 41. References Graal - A Bytecode Agnostic Compiler for the JVM, Thomas Wuerthinger, JVM Language Summit http://medianetwork.oracle.com/video/player/1113230360001 Graal and Truffle: One VM to Rule Them All http://www.slideshare.net/ThomasWuerthinger/graal-truffle- ethdec2013?qid=848a4965-9768-40d5-b167- ccd8eb7d1659&v=&b=&from_search=2
  • 42. References Graal and Truffle: Modularity and Separation of Concerns as Cornerstones for Building a Multipurpose Runtime http://www.slideshare.net/ThomasWuerthinger/2014-0424-graal- modularity?qid=0e86ed21-0b8f-4087-9212- 68f76546d674&v=&b=&from_search=4 Dynamic Compilation - Thomas Wuerthinger https://www.youtube.com/watch?v=RLsG2kE1EMI https://www.youtube.com/watch?v=U_QpToYLsO0 JVMLS 2012: Graal http://medianetwork.oracle.com/video/player/1785432492001
  • 43. References Graal Tutorial at CGO 2015 by Christian Wimmer http://lafo.ssw.uni-linz.ac.at/papers/2015_CGO_Graal.pdf Writing a language in Truffle: Part 1 - Using Truffle and Graal https://cesquivias.github.io/blog/2014/10/13/writing-a-language-in-truffle- part-1-a-simple-slow-interpreter/ Writing a language in Truffle: Part 2 - Using Truffle and Graal http://cesquivias.github.io/blog/2014/12/02/writing-a-language-in-truffle- part-2-using-truffle-and-graal/
  • 44. References Graal publications, JKU, Linz http://ssw.jku.at/Research/Projects/JVM/Graal.html Truffle publications, JKU, Linz http://ssw.jku.at/Research/Projects/JVM/Truffle.html
  • 45. References R as a citizen in a Polyglot world: The promise of the Truffle framework http://user2015.math.aau.dk/presentations/112.pdf Truffle/C Interpreter http://www.manuelrigger.at/downloads/trufflec_thesis.pdf Graal.JS - high-performance JavaScript on the JVM talk by Christian Wirth https://www.youtube.com/watch?v=OUo3BFMwQFo

Editor's Notes

  • #9: The JVM may also perform deoptimization.
  • #12: This essentially means the Graal VM can run in client/server mode but also use the Graal JIT compiler in certain scenarios
  • #14: Truffle can be used for static analysis as well
  • #15: Truffle can be used for static analysis as well
  • #16: Without Graal you will be need to write a bytecode compiler.
  • #21: There are high level optimization on the AST and low level optimization (after the AST is lowered).
  • #24: In inline caching the callee is cached at the call site instead of a dynamic callee method lookup. -
  • #25: Some of the languages are not open-sourced as of the time of this presentation (such as GraalJS). Interpreter executables are provided in the official distribution under <GraalVM>/bin/ (e.g. <GraalVM>/bin/js for GraalJS)
  • #28: Up to JDK 9 Graal had to use a modified version of Hotspot. With JDK9 the JVMCI enables the deployment of Graal on top of an existing JVM without further modifications (using JVMCI).