23
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. One VM To Rule Them All Thomas Wuerthinger @thomaswue Oracle Labs

Graal VM: Multi-Language Execution Platform

Embed Size (px)

DESCRIPTION

Updates on the current status of Graal VM, a platform dedicated to run multiple programming languages at excellent performance. Experimental binaries are available from http://www.oracle.com/technetwork/oracle-labs/program-languages/overview/index.html.

Citation preview

Page 1: 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  

Page 2: Graal VM: Multi-Language Execution Platform

Copyright  ©  2014  Oracle  and/or  its  affiliates.  All  rights  reserved.       2  

Page 3: Graal VM: Multi-Language Execution Platform

Copyright  ©  2014  Oracle  and/or  its  affiliates.  All  rights  reserved.       3  

3  

Goal:  

Page 4: Graal VM: Multi-Language Execution Platform

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

Page 5: Graal VM: Multi-Language Execution Platform

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  

Page 6: Graal VM: Multi-Language Execution Platform

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  

Page 7: Graal VM: Multi-Language Execution Platform

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

Page 8: Graal VM: Multi-Language Execution Platform

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

Page 9: Graal VM: Multi-Language Execution Platform

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  

Page 10: Graal VM: Multi-Language Execution Platform

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  

Page 11: Graal VM: Multi-Language Execution Platform

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

Page 12: Graal VM: Multi-Language Execution Platform

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…  

Page 13: Graal VM: Multi-Language Execution Platform

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  

Page 14: Graal VM: Multi-Language Execution Platform

Copyright  ©  2014  Oracle  and/or  its  affiliates.  All  rights  reserved.       14  

0  

1  

2  

3  

4  

5  

6  

7  

Graal/JS  

V8  

Performance  –  JavaScript  

Page 15: Graal VM: Multi-Language Execution Platform

Copyright  ©  2014  Oracle  and/or  its  affiliates.  All  rights  reserved.       15  

FFI?   C  

Page 16: Graal VM: Multi-Language Execution Platform

Copyright  ©  2014  Oracle  and/or  its  affiliates.  All  rights  reserved.       16  

Cross-­‐Language  Inlining  

Page 17: Graal VM: Multi-Language Execution Platform

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!

Page 18: Graal VM: Multi-Language Execution Platform

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.  

Page 19: Graal VM: Multi-Language Execution Platform

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,  …  

Page 20: Graal VM: Multi-Language Execution Platform

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.  

Page 21: Graal VM: Multi-Language Execution Platform

Copyright  ©  2014  Oracle  and/or  its  affiliates.  All  rights  reserved.    

Q/A  @thomaswue  

Page 22: Graal VM: Multi-Language Execution Platform

Copyright  ©  2014  Oracle  and/or  its  affiliates.  All  rights  reserved.      

Page 23: Graal VM: Multi-Language Execution Platform