GraalVM - Compiler and JVM Research at JKU

Werbung
GraalVM
Compiler and JVM Research at JKU
Josef Eisl
About Me
●
●
Finished Master's studies January 2014
–
Master's Thesis about CACAO VM
–
Supervised by Prof. Krall
Since March 2014
–
●
PhD Student & Research Assistant
@ Institute for System Software, JKU Linz
Working on the Graal Compiler
–
Backend Optimization, Register Allocation
14.04.2016
Josef Eisl
2
Agenda
JS
C/C++
Python
Truffle
Ruby
R
...
InterOp
Graal
JVMCI
HotSpot VM
14.04.2016
Josef Eisl
3
Who Are We?
Institute for System
Software
14.04.2016
Josef Eisl
4
Sun/Oracle Collaboration
●
Started 2001 by Prof. Hanspeter Mössenböck with
Sun Microsystems
–
●
●
Dynamic compiler optimizations and JVM-related research
Many artifacts now in the Java HotSpot VM and JDK
–
Escape Analysis (C1), Register Allocator (C1), …
–
JVM Compiler Interface in Java 9
Current research
$ java ...
–
Graal Compiler
–
Truffle Language Implementation Framework
14.04.2016
inside!
Josef Eisl
5
Oracle Labs Austria Collaboration
Oracle Labs Austria
PhD Students
●
Thomas Würthinger (lead)
●
Benoit Daloze
●
Danilo Ansaloni
●
Josef Eisl
●
Stefan Anzinger
●
Thomas Feichtinger
●
Daniele Bonetta
●
David Gnedt
●
David Leopoldseder
●
Manuel Rigger
●
Roland Schatz
●
Lukas Stadler
●
Christian Wirth
●
Josef Haider
●
Paul Wögerer
●
Stefan Rumzucker
●
Andreas Wöß
14.04.2016
Master Students
Josef Eisl
6
HotSpot VM
JS
C/C++
Python
Truffle
Ruby
R
...
InterOp
Graal
JVMCI
HotSpot VM
14.04.2016
Josef Eisl
7
Java Platform
Java Language
Java Language
java
Tools &
Tool APIs
javac
javadoc
jar
javap
jdeps Scripting
JMC
JFR
Java DB
Deployment
Security Monitoring JConsole VisualVM
JPDA
JVM TI
IDL
Internationalization
RMI
Web Services
Java Web Start
Deployment
Troubleshooting
Applet / Java Plug-in
JavaFX
User Interface
Toolkits
JDK
Integration
Libraries
JRE
Other Base
Libraries
Swing
Java 2D
AWT
Drag and Drop
Input Methods
Image I/O
IDL
JDBC
JNDI
RMI
Accessibility
Print Service
RMI-IIOP
Sound
Scripting
Beans
Security
Serialization
Extension Mechanism
JMX
XML JAXP
Networking
Override Mechanism
JNI
Date and Time
Input/Output
Internationalization
lang and util
lang and util
Base Libraries
Java Virtual Machine
Math
Collections
Ref Objects
Regular Expressions
Logging
Management
Instrumentation
Concurrency Utilities
Reflection
Versioning
Preferences API
JAR
Compact
Profiles
Java SE
API
Zip
Java HotSpot Client and Server VM
http://docs.oracle.com/javase/8/docs/index.html
14.04.2016
Josef Eisl
8
HotSpot VM
●
●
Virtual Machine for Java
–
Execute Java Bytecode (class files)
–
Runtime (Garbage Collection, ...)
Interpreter
Deoptimization
Execution modes
–
Immediate start up, slow execution
Client Compiler
●
–
Client Compiler
Optimized
Machine Code
Server Compiler
Aggressively
Optimized
Machine Code
Bytecode Interpreter
●
–
Bytecode
Fast start up, medium execution
Server Compiler
●
Slow start up, fast execution
14.04.2016
$ java -version
java version "1.8.0"
Java(TM) SE Runtime Environment
Java HotSpot(TM) 64-Bit Server VM
Josef Eisl
9
Graal
JS
C/C++
Python
Truffle
Ruby
R
...
InterOp
Graal
JVMCI
HotSpot VM
14.04.2016
Josef Eisl
10
Graal
●
Optimizing JIT compiler for
the HotSpot VM
–
Interpreter
OpenJDK Project
Deoptimization
https://github.com/graalvm/graal-core
●
Written in Java
Client Compiler
Optimized
Machine Code
Graal
Aggressively
Optimized
Machine Code
JVMCI
–
Meta-circular
–
Benefiting from Java’s annotation
and meta-programming, IDE
support
$
$
$
$
14.04.2016
Bytecode
git clone https://github.com/graalvm/graal-core.git
cd graal-core
mx build
mx vm -version
Josef Eisl
11
Performance – Java and Scala
2,5
Higher is better
2
1,5
server
graal
1
0,5
0
Java
Scala
DaCapo benchmarks - Normalized versus client compiler
14.04.2016
Josef Eisl
12
Truffle – Language Implementation Framework
JS
C/C++
Python
Truffle
Ruby
R
...
InterOp
Graal
JVMCI
HotSpot VM
14.04.2016
Josef Eisl
13
“Write Your Own Language”
How it is/used to be:
●
Prototype a new language
–
●
Write a “real” VM
–
●
●
How it should be/With Truffle:
●
In C/C++, still using AST interpreter, spend a lot
of time implementing runtime system, GC, ...
People start using it
People complain about performance
–
●
Parser and language work to build syntax tree
(AST), AST Interpreter
Define a bytecode format and write bytecode
interpreter
Write a JIT compiler
–
Improve the garbage collector
14.04.2016
–
Parser and language work to build
syntax tree (AST)
–
Execute using AST interpreter
●
People start using it
●
And it is already fast!
Performance is still bad
–
Prototype a new language in Java
Josef Eisl
14
AST Interpreter
... = a + b
class AddNode {
int execute(int a, int b) {
return a + b;
}
double execute(double a, double b) {
return a + b;
}
String execute(String a, String b) {
return a + b;
}
Object execute(Object a, Object b) {
return genericAdd(a, b);
}
}
14.04.2016
+
a
Josef Eisl
b
15
Speculate and Optimize ...
14.04.2016
Josef Eisl
16
Truffle Implementations
JavaScript – JKU, Oracle Labs
Closed Source
LLVM IR (C/C++/…) - JKU, Oracle Labs
JRuby - JKU, Oracle Labs
https://github.com/jruby/jruby/wiki/Truffle
https://github.com/graalvm/sulong
ZipPy - UCI Irvine
FastR - JKU, Oracle Labs
https://bitbucket.org/ssllab/zippy
https://github.com/graalvm/fastr
Smalltalk - JKU (Stefan Marr)
https://github.com/SOM-st/TruffleSOM
14.04.2016
Josef Eisl
17
Performance – JavaScript
7
6
Higher is better
5
4
3
V8
Graal/JS
2
1
0
14.04.2016
Josef Eisl
18
Performance – C
500
450
Higher is better
400
350
300
GCC O0
GCC best
TruffleC
250
200
150
100
50
0
Composite
NB
14.04.2016
FA
SN
FK
MB
Josef Eisl
FFT
SOR
MC
SM
LU
19
High-Performance Language Interoperability
JS
C/C++
Python
Truffle
Ruby
R
...
InterOp
Graal
JVMCI
HotSpot VM
14.04.2016
Josef Eisl
20
Motivation
main.c
#include<stdio.h>
struct complex {
double r;
double i;
}
complex.js
function add(a, b) {
var result = {r:0, i:0};
int main() {
struct complex *a = ...;
struct complex *b = ...;
}
return add(a,b);
add(a, b)
result.r = a.r
a->r
+ b->r
b.r;
result.i = a.i
a->i
+ b->i
b.i;
return result;
}
14.04.2016
Josef Eisl
21
var a = obj . val ue;
obj is a
C struct
Message Resolution
JS
Dynamic Compilation
JS
=
=
JS
=
JS
C
C
a
.
obj
a
value
JS
Msg
obj
value
Map J S access
to a message
J S-specif c
object access
C
Msg
Map message
to a C access
Language-independent
object access
14.04.2016
is
C?
a
Read
JS
->
obj
value
C-specif c
object access
Josef Eisl
JS
Machine Code
22
Performance – Ruby + C Interoperability
35
32
Higher is better
30
25
20
15
10
5
0
11
8
1
CRuby
Graal/Ruby
CRuby+C
Pure Ruby
Graal/Ruby+C
Ruby + C
Image Processing Composite Speedup. See also Chris Seaton's blog post: http://goo.gl/Q8GQiX
14.04.2016
Josef Eisl
23
GraalVM Demo
JS
C/C++
Python
Truffle
Ruby
R
...
InterOp
Graal
JVMCI
HotSpot VM
Christian Humer's GraalVM Demo at JavaOne 2015: https://youtu.be/lYGfD2H99Ls
14.04.2016
Josef Eisl
24
Get in Contact
●
●
●
Projects, Internships, PhD
Positions, ...
Me
–
Mail: [email protected]
–
Twitter: @zapstercc
GraalVM
–
Github: https://github.com/graalvm
http://goo.gl/cVhX3U
14.04.2016
Josef Eisl
25
Herunterladen