Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Become Polyglot by learning Java!
@JaroslavTulach Oracle Labs
CopyrightCopyright ©© 20152006 OracleOracle and/orand/or itsits affiliates.affiliates. AllAll rightsrights reserved.reserved. Jaroslav Tulach
1 NetBeans Founder
2 NetBeans Initial Architect
3 Practical API Design book
4 Oracle Labs: Graal/Truffle
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement
The preceding and following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Program Agenda
1 The Polyglot World
2 Graal VM
3 Truffle Languages
4 References & Discussion
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Aren’t you Already a Polyglot?
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | 6 OracleLabs Vision
● Vision without speculation would be today's reality
● Radical innovation
● New approach to existing technologies
● Research + Engineering
● Hardware & Software
● Engineered to work together
● Java/bytecode/IR/assembly/processors/memory
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Systems come with Various Interfaces
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | 8 You can execute any language on the JVM / CLR - as long as it looks like Java / C#.
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. 9 Can we Connect the Polyglots… Easily!?
? ? Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | 10 Demo Sieve of Eratosthenes with many Polyglot Flavors
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | GraalVM: One VM to Rule them all!
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | 12 Graal Virtual Machine • Modern alternative to HotSpot C2
l Maintainable code base
l Toolable, approachable
l Ready for today's code
l JEP 243: Java Compiler Interface • Partial evaluation • Aggressive speculations • Smooth de-optimizations
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Truffle: Write your own language!
Current situation How it should be
Prototype a new language Prototype a new language in Java Parser and language work to build Parser and language work to build syntax tree (AST), AST Interpreter syntax tree (AST) Execute using AST interpreter Write a “real” VM In C/C++, still using AST interpreter, Integrate with VM-building framework spend a lot of time implementing Integrate with Modular VM runtime system, GC, … Add small language-specific parts People start using it People start using it And it is already fast People complain about performance Define a bytecode format and write bytecode interpreter Performance is still bad Write a JIT compiler Improve the garbage collector
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Demo Debugger, profiler, coverage & other tooling for free
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Do you care about code or data?
Static typing Java, C# Faster execution Visual Basic Targeting larger projects that care about code Python, Ruby
JavaScript
R
More flexible
Easier to use
Targeting exploratory programming, rapid prototyping, scripting Are C, C++, Java domain specific languages?
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | One VM for all languages means interoperability and being able to choose the best language for the task! r e t t e b
s i
r e w o L 3
The goal:
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. 17 GraalVM: Technology Stack
FastR C, C++, Ruby + FastR Graal.js Fortran Truffle via Sulong
Truffle framework for AST interpreters
Graal compiler
JVM Compiler Interface (JDK9 JEP 243)
HotSpot
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | 18 Demo Polyglot node.js with Java, Ruby, R, JShell and NetBeans
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | The Biggest Problem of Dynamic Languages
a + b
int String Object
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. 20 How Does it Work?
Node Rewriting Compilation using U for Profiling Feedback G Partial Evaluation G
U U Node Transitions I G I G
Uninitialized Integer I I U U U I I I
S D AST Interpreter AST Interpreter Compiled Code Uninitialized Nodes String Double Rewritten Nodes G Generic
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. 21 In case of Invalid Assumptions...
Deoptimization Node Rewriting to Update Recompilation using to AST Interpreter G Profiling Feedback G Partial Evaluation G G
I G I G D G D G
I I I D
I I I D
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. 22 Become Polyglot! • Try it now!
– Download JVM: http://www.oracle.com/technetwork/oracle-labs/program-languages/ – Open source: https://github.com/graalvm • Mix it all! – JRuby, Python, JavaScript, R, C, node.js • Learn (to use) Java – The whole polyglot world will be yours!
• We are hiring! Praha, Curych, Linec
Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |