Graal VM: Multi-Language Execution Platform
-
Upload
thomas-wuerthinger -
Category
Software
-
view
842 -
download
0
description
Transcript of Graal VM: Multi-Language Execution Platform
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
One VM To Rule Them All Thomas Wuerthinger
@thomaswue Oracle Labs
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 2
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 3
3
Goal:
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 4
You can execute any language on the JVM / CLR
-‐ as long as it looks like Java / C#.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 5
Parser and language work to build syntax tree (AST), AST Interpreter
Write a “real” VM In C/C++, sXll using AST interpreter, spend a lot of Xme implemenXng runXme system, GC, …
Define a bytecode format and write bytecode interpreter
People complain about performance
Write a JIT compiler Improve the garbage collector
Performance is sXll bad
Prototype a new language
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 6
Parser and language work to build syntax tree (AST), AST Interpreter
Write a “real” VM In C/C++, sXll using AST interpreter, spend a lot of Xme implemenXng runXme system, GC, …
People start using it
Define a bytecode format and write bytecode interpreter
People complain about performance
Write a JIT compiler Improve the garbage collector
Performance is sXll bad
Prototype a new language
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 7
Speculate and OpXmize…
U
U U
U
U I
I I
G
G I
I I
G
G
Node Rewriting for Profiling Feedback
AST InterpreterRewritten Nodes
AST InterpreterUninitialized Nodes
Compilation usingPartial Evaluation
Compiled Code
Node Transitions
S
UI
D
G
Uninitialized Integer
Generic
DoubleString
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 8
DeopXmize and ReopXmize…
I
I I
G
G I
I I
G
G
Deoptimizationto AST Interpreter
D
I D
G
G D
I D
G
G
Node Rewriting to Update Profiling Feedback
Recompilation usingPartial Evaluation
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Graal VM • A new JIT compiler for Java wriben in Java. • Designed for mulX-‐language performance. • Downloadable from the Oracle Technology Network (OTN) with Java and JavaScript support.
C
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 10
Graal
Truffle
R Ruby
Java Scala
Smalltalk C J Python JavaScript Parallel Graph AnalyXcs
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 11
Guest Language Implementation
Host Services
Guest Language Application
OS
Application Developer
Language Developer
VM Expert
Guest Language
Managed Host Language
Managed Host Languageor Unmanaged Language
Unmanaged Language(typically C or C++)
Written by: Written in:
OS Expert
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Languages – Special Aspects
• Everything is a map…
• Everything is a map and every operaXon a funcXon call…
• Everything is a map and every operaXon a funcXon call and everything is a vector…
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 13
Performance – Java and Scala
0
0.5
1
1.5
2
2.5
Java Scala
graal
server
DaCapo benchmarks -‐ Normalized versus client compiler
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 14
0
1
2
3
4
5
6
7
Graal/JS
V8
Performance – JavaScript
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 15
FFI? C
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 16
Cross-‐Language Inlining
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 17
1x! 1x!
8x! 11x!
32x!
0!5!
10!15!20!25!30!35!
MRI! JRuby! Graal/Ruby! MRI + C! Graal/Ruby + Graal/C!
spee
dup
rela
tive
to M
RI!
Image Processing Composite Speedup!
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
High-‐Performance Language Interoperability
0
200
400
600
800
1000
1200
Ruby data JS data C data
Ruby program
JS program
C program
C
• Scores for mixing Ruby/JS/C execuXng the scimark benchmarks.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 19
• Graal VM Binaries for Java and JavaScript hbp://www.oracle.com/technetwork/oracle-‐labs/program-‐languages
• Graal and Truffle API hbp://openjdk.java.net/projects/graal/
• FastR hbps://bitbucket.org/allr/fastr
• TruffleRuby hbps://github.com/jruby/jruby/wiki/Truffle
• ZipPy hbps://bitbucket.org/ssllab/zippy
• Other projects for Smalltalk, Clojure, Lua, …
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. 20
Safe Harbor Statement The preceding is intended to provide some insight into a line of research in Oracle Labs. It is intended for informaXon purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or funcXonality, and should not be relied upon in making purchasing decisions. The development, release, and Xming of any features or funcXonality described in connecXon with any Oracle product or service remains at the sole discreXon of Oracle. Any views expressed in this presentaXon are my own and do not necessarily reflect the views of Oracle.
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Q/A @thomaswue
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.