Your SlideShare is downloading. ×
0
Run * on the JVM
Interpreters on the JVM with
Graal and Truffle
Balazs Varga / @vbalazs
Agenda
● Compiled, interpreted applications and VMs
● Interpreters under the hood
● Interpreter on the JVM
○ Existing solu...
Compiled, interpreted applications
Operating system
Libraries
Compiler
Operating system
Libraries
Executable
Machine Code
...
Virtual Machines (runtimes)
Operating system
Libraries
Java compiler
Operating system
Libraries
Executable
JVM bytecode
Ja...
Interpreters under the hood
1. Tokenize
2. Parse
3. AST
Ruby Tokens
Abstract Syntax Tree
nodes
C
Machine
Language
interpret
Abstract Syntax Tree
function sum(n) {
var sum = 0;
for (var i = 1; i < n; i++) {
sum += i;
}
return sum;
}
source: T. Wür...
Interpreter on the JVM
Ruby source code compiled to Java bytecode
Operating system
Libraries
JRuby interpreter
Java Runtim...
The future is here: Truffle and Graal
Goal: Native support for interpreters
Requirements:
● simplicity
● generality
● perf...
System structure
source: Christian Wimmer and Chris Seaton speak at the JVM Language Summit, July 31, 2013.
Ruby
Javascrip...
Truffle
● Java framework for writing AST interpreters
● node specialization with tree rewriting
● define compiler optimiza...
Graal
● 100% Java-based JIT framework
○ JIT: Just In Time (compiler)
● dynamic compiler
● directly control code generation...
Node rewrite - optimization
source: T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Si...
Node rewrite - de- and reoptimization
source: T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richa...
Bonus
“Write your own language!”
Before Truffle:
● write a parser and an AST interpreter
● create a runtime system (C/C++)...
Summary
● Truffle, Graal (~ Java 9)
○ “easy” to use AST interpreter framework
○ high performance (compiled to machine code...
Questions?
Upcoming SlideShare
Loading in...5
×

Run * on the JVM - Simonyi Conference Budapest April 15

549

Published on

Published in: Engineering, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
549
On Slideshare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Run * on the JVM - Simonyi Conference Budapest April 15"

  1. 1. Run * on the JVM Interpreters on the JVM with Graal and Truffle Balazs Varga / @vbalazs
  2. 2. Agenda ● Compiled, interpreted applications and VMs ● Interpreters under the hood ● Interpreter on the JVM ○ Existing solutions ○ Future ● Summary
  3. 3. Compiled, interpreted applications Operating system Libraries Compiler Operating system Libraries Executable Machine Code C source code Operating system Libraries InterpreterRuby source code (1.8) GC Libraries compiled C source code (executable machine code) Libraries GC: Garbage Collector
  4. 4. Virtual Machines (runtimes) Operating system Libraries Java compiler Operating system Libraries Executable JVM bytecode Java source code Libraries JVM bytecode Java Runtime Env. GC Libraries
  5. 5. Interpreters under the hood 1. Tokenize 2. Parse 3. AST Ruby Tokens Abstract Syntax Tree nodes C Machine Language interpret
  6. 6. Abstract Syntax Tree function sum(n) { var sum = 0; for (var i = 1; i < n; i++) { sum += i; } return sum; } source: T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, M. Wolczko: One VM to Rule Them All. In Proceedings of Onward!, ACM Press, 2013.
  7. 7. Interpreter on the JVM Ruby source code compiled to Java bytecode Operating system Libraries JRuby interpreter Java Runtime Env. GC Libraries Why? Existing solutions
  8. 8. The future is here: Truffle and Graal Goal: Native support for interpreters Requirements: ● simplicity ● generality ● performance
  9. 9. System structure source: Christian Wimmer and Chris Seaton speak at the JVM Language Summit, July 31, 2013. Ruby Javascript Python R ... Your language here TruffleGraal Language agnostic dynamic compiler Common API between language implementation and optimization system Substrate VM Graal VM
  10. 10. Truffle ● Java framework for writing AST interpreters ● node specialization with tree rewriting ● define compiler optimizations, directives ○ assumptions
  11. 11. Graal ● 100% Java-based JIT framework ○ JIT: Just In Time (compiler) ● dynamic compiler ● directly control code generation ● graph intermediate representation
  12. 12. Node rewrite - optimization source: T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, M. Wolczko: One VM to Rule Them All. In Proceedings of Onward!, ACM Press, 2013.
  13. 13. Node rewrite - de- and reoptimization source: T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, M. Wolczko: One VM to Rule Them All. In Proceedings of Onward!, ACM Press, 2013.
  14. 14. Bonus “Write your own language!” Before Truffle: ● write a parser and an AST interpreter ● create a runtime system (C/C++), GC ● performance problems: bytecode, JIT, improve GC ● ...??? Easy?
  15. 15. Summary ● Truffle, Graal (~ Java 9) ○ “easy” to use AST interpreter framework ○ high performance (compiled to machine code!) ● Bonus: “Write your own language!” ● Contribute! ○ meetup.com: budapest.rb, budapest.js, … ○ https://github.com/jruby/jruby ○ http://openjdk.java.net/
  16. 16. Questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×