Accelerating Ruby with LLVM

Size: px
Start display at page:

Download "Accelerating Ruby with LLVM"

Transcription

1 Accelerating Ruby with LLVM Evan Phoenix Oct 2, 2009

2 RUBY

3 RUBY Strongly, dynamically typed

4 RUBY Unified Model

5 RUBY Everything is an object

6 RUBY 3.class # => Fixnum

7 RUBY Every code context is equal

8 RUBY Every context is a method

9 RUBY Garbage Collected

10 RUBY A lot of syntax

11 RUBY Strongly, dynamically typed Unified model Everything is an object 3.class Every code context is equal Every context is a method Garbage collected A lot of syntax

12 Rubinius

13 Rubinius Started in 2006

14 Rubinius Build a ruby environment for fun

15 Rubinius Unlike most scripting languages, write as much in ruby as possible

16 Rubinius Core functionality of perl/python/ruby in C, NOT in their respective language.

17 Rubinius C => ruby => C => ruby

18 Rubinius Language boundaries suck

19 Rubinius Started in 2006 Built for fun Turtles all the way down

20 Evolution

21 Evolution 100% ruby prototype running on 1.8

22 Evolution Hand translated VM to C

23 Evolution Rewrote VM in C++

24 Evolution Switch away from stackless

25 Evolution Experimented with handwritten assembler for x86

26 Evolution Switch to LLVM for JIT

27 Evolution 100% ruby prototype Hand translated VM to C Rewrote VM in C++ Switch away from stackless Experiment with assembler Switch to LLVM for JIT

28 Features

29 Features Bytecode VM

30 Features Simple interface to native code

31 Features Accurate, generational garbage collector

32 Features Integrated FFI API

33 Features Bytecode VM Interface to native code Generational GC Integrated FFI

34 Benchmarks

35 def foo() ary = [] 100.times { i ary << i } end 300,000 times

36 Seconds rbx rbx jit rbx jit +blocks

37 def foo() hsh = {} 100.times { i hsh[i] = 0 } end 100,000 times

38 Seconds rbx rbx jit rbx jit +blocks

39 def foo() hsh = { 47 => true } 100.times { i hsh[i] } end 100,000 times

40 Seconds rbx rbx jit rbx jit +blocks

41 Early LLVM Usage

42 Early LLVM Usage Compiled all methods up front

43 Early LLVM Usage Simple opcode-to-function translation with inlining

44 Early LLVM Usage Startup went from 0.3s to 80s

45 Early LLVM Usage Compiled all methods upfront Simple opcode-to-function translation Startup from 0.3s to 80s

46 True JIT

47 True JIT JIT Goals

48 True JIT JIT Goals Choose methods that benefit the most

49 True JIT JIT Goals Compiling has minimum impact on performance

50 True JIT JIT Goals Ability to make intelligent frontend decisions

51 Choosing Methods

52 Choosing Methods Simple call counters

53 Choosing Methods When counter trips, the fun starts

54 Choosing Methods Room for improvement

55 Choosing Methods Room for improvement Increment counters in loops

56 Choosing Methods Room for improvement Weigh different invocations differently

57 Choosing Methods Simple counters Trip the counters, do it Room for improvement Increment in loops Weigh invocations

58 Which Method?

59 Which Method? Leaf methods trip quickly

60 Which Methods? Leaf methods trip quickly Consider the whole callstack

61 Which Methods? Leaf methods trip quickly Pick a parent expecting inlining

62 Which Method? Leaf methods trip Consider the callstack Find a parent

63 Minimal Impact

64 Minimal Impact After the counters trip

65 Minimal Impact Queue the method

66 Minimal Impact Background thread drains queue

67 Minimal Impact Frontend, passes, codegen in background

68 Minimal Impact Install JIT d function

69 Minimal Impact Install JIT d function Requires GC interaction

70 Minimal Impact Trip the counters Queue the method Compile in background Install function pointer

71 Good Decisions

72 Good Decisions Naive translation yields fixed improvement

73 Good Decisions Performance shifts to method dispatch

74 Good Decisions Improve optimization horizon

75 Good Decisions Inline using type feedback

76 Good Decisions Naive translation sucks Inline using type feedback Performance in dispatch Improve optimizations

77 Type Feedback

78 Type Feedback Frontend translates to IR

79 Type Feedback Read InlineCache information

80 Type Feedback InlineCaches contain profiling info

81 Type Feedback Use profiling to drive inlining!

82 Type Feedback Frontend generates IR Reads InlineCaches InlineCaches have profiling Use profiling to drive inlining!

83 Inlining

84 Inlining Profiling info shows a dominant class

85 2 1% 1 class 98%

86 Inlining Lookup method in compiler

87 Inlining For native functions, emit direct call

88 Inlining For FFI, inline conversions and call

89 Inlining Find dominant class Lookup method Emit direct calls if possible

90 Inlining Ruby

91 Inlining Ruby Policy decides on inlining

92 Inlining Ruby Drive sub-frontend at call site

93 Inlining Ruby All inlining occurs in the frontend

94 Inlining Ruby Generated IR preserves runtime data

95 Inlining Ruby Generated IR preserves runtime data GC roots, backtraces, etc

96 Inlining Ruby No AST between bytecode and IR

97 Inlining Ruby No AST between bytecode and IR Fast, but limits the ability to generate better IR

98 Inlining Ruby Policy decides Drive sub-frontend Preserve runtime data Generates fast, ugly IR

99 LLVM

100 LLVM IR uses operand stack

101 LLVM IR uses operand stack Highlevel data flow not in SSA

102 LLVM IR uses operand stack Passes eliminate redundencies

103 LLVM IR uses operand stack Makes GC stack marking easy

104 LLVM IR uses operand stack nocapture improves propagation

105 LLVM Exceptions via sentinal value

106 LLVM Exceptions via sentinal value Nested handlers use branches for control

107 LLVM Exceptions via sentinal value Inlining exposes redundant checks

108 LLVM Inline guards

109 LLVM Inline guards Simple type guards

110 if(obj->class->class_id == <integer constant>) {

111 LLVM Inline guards Custom AA pass for guard elimination

112 LLVM Inline guards Teach pointstoconstantmemory about...

113 if(obj->class->class_id == <integer constant>) {

114 if(obj->class->class_id == <integer constant>) {

115 LLVM Maximizing constant propagation

116 LLVM Maximizing constant propagation Type failures shouldn t contribute values

117 if(obj->class->class_id == 0x33) { val = 0x7; } else { val = send_msg(state, obj,...); }

118 if(obj->class->class_id == 0x33) { val = 0x7; } else { return uncommon(state); }

119 LLVM Maximizing constant propagation Makes JIT similar to tracing

120 LLVM Use overflow intrinsics

121 LLVM Use overflow intrinsics Custom pass to fold constants arguments

122 LLVM AA knowledge for tagged pointers

123 LLVM AA knowledge of tagged pointers 0x5 is 2 as a tagged pointer

124 LLVM Not in SSA form Simplistic exceptions Inlining guards Maximize constants Use overflow Tagged pointer AA

125 Issues

126 Issues How to link with LLVM?

127 Issues How to link with LLVM? An important SCM issue

128 Issues Ugly, confusing IR from frontend

129 Issues instcombine confuses basicaa

130 Issues Operand stack confuses AA

131 Issues Inability to communicate semantics

132 Object* new_object(state)

133 Returned pointer aliases nothing Only modifies state If return value is unused, remove the call Semi-pure?

134 Issues Ugly IR Linking with LLVM AA confusion Highlevel semantics

135 Thanks!

Expressing high level optimizations within LLVM. Artur Pilipenko

Expressing high level optimizations within LLVM. Artur Pilipenko Expressing high level optimizations within LLVM Artur Pilipenko artur.pilipenko@azul.com This presentation describes advanced development work at Azul Systems and is for informational purposes only. Any

More information

code://rubinius/technical

code://rubinius/technical code://rubinius/technical /GC, /cpu, /organization, /compiler weeee!! Rubinius New, custom VM for running ruby code Small VM written in not ruby Kernel and everything else in ruby http://rubini.us git://rubini.us/code

More information

Towards Lean 4: Sebastian Ullrich 1, Leonardo de Moura 2.

Towards Lean 4: Sebastian Ullrich 1, Leonardo de Moura 2. Towards Lean 4: Sebastian Ullrich 1, Leonardo de Moura 2 1 Karlsruhe Institute of Technology, Germany 2 Microsoft Research, USA 1 2018/12/12 Ullrich, de Moura - Towards Lean 4: KIT The Research An University

More information

Announcements. My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM.

Announcements. My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM. IR Generation Announcements My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM. This is a hard deadline and no late submissions will be

More information

LLVM for a Managed Language What we've learned

LLVM for a Managed Language What we've learned LLVM for a Managed Language What we've learned Sanjoy Das, Philip Reames {sanjoy,preames}@azulsystems.com LLVM Developers Meeting Oct 30, 2015 This presentation describes advanced development work at Azul

More information

Pegarus & Poison. Rubinius VM as a Multilanguage Platform

Pegarus & Poison. Rubinius VM as a Multilanguage Platform Pegarus & Poison Rubinius VM as a Multilanguage Platform Thursday, July 29, 2010 Brian Ford brixen on {twitter IRC gmail} Thursday, July 29, 2010 discussion rant tutorial Q&A interaction Thursday, July

More information

BEAMJIT, a Maze of Twisty Little Traces

BEAMJIT, a Maze of Twisty Little Traces BEAMJIT, a Maze of Twisty Little Traces A walk-through of the prototype just-in-time (JIT) compiler for Erlang. Frej Drejhammar 130613 Who am I? Senior researcher at the Swedish Institute

More information

Where We Are. Lexical Analysis. Syntax Analysis. IR Generation. IR Optimization. Code Generation. Machine Code. Optimization.

Where We Are. Lexical Analysis. Syntax Analysis. IR Generation. IR Optimization. Code Generation. Machine Code. Optimization. Where We Are Source Code Lexical Analysis Syntax Analysis Semantic Analysis IR Generation IR Optimization Code Generation Optimization Machine Code Where We Are Source Code Lexical Analysis Syntax Analysis

More information

BEAMJIT: An LLVM based just-in-time compiler for Erlang. Frej Drejhammar

BEAMJIT: An LLVM based just-in-time compiler for Erlang. Frej Drejhammar BEAMJIT: An LLVM based just-in-time compiler for Erlang Frej Drejhammar 140407 Who am I? Senior researcher at the Swedish Institute of Computer Science (SICS) working on programming languages,

More information

Agenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1

Agenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1 Agenda CSE P 501 Compilers Java Implementation JVMs, JITs &c Hal Perkins Summer 2004 Java virtual machine architecture.class files Class loading Execution engines Interpreters & JITs various strategies

More information

SSA Based Mobile Code: Construction and Empirical Evaluation

SSA Based Mobile Code: Construction and Empirical Evaluation SSA Based Mobile Code: Construction and Empirical Evaluation Wolfram Amme Friedrich Schiller University Jena, Germany Michael Franz Universit of California, Irvine, USA Jeffery von Ronne Universtity of

More information

SABLEJIT: A Retargetable Just-In-Time Compiler for a Portable Virtual Machine p. 1

SABLEJIT: A Retargetable Just-In-Time Compiler for a Portable Virtual Machine p. 1 SABLEJIT: A Retargetable Just-In-Time Compiler for a Portable Virtual Machine David Bélanger dbelan2@cs.mcgill.ca Sable Research Group McGill University Montreal, QC January 28, 2004 SABLEJIT: A Retargetable

More information

High-Level Language VMs

High-Level Language VMs High-Level Language VMs Outline Motivation What is the need for HLL VMs? How are these different from System or Process VMs? Approach to HLL VMs Evolutionary history Pascal P-code Object oriented HLL VMs

More information

A Trace-based Java JIT Compiler Retrofitted from a Method-based Compiler

A Trace-based Java JIT Compiler Retrofitted from a Method-based Compiler A Trace-based Java JIT Compiler Retrofitted from a Method-based Compiler Hiroshi Inoue, Hiroshige Hayashizaki, Peng Wu and Toshio Nakatani IBM Research Tokyo IBM Research T.J. Watson Research Center April

More information

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1 CSE P 501 Compilers Java Implementation JVMs, JITs &c Hal Perkins Winter 2008 3/11/2008 2002-08 Hal Perkins & UW CSE V-1 Agenda Java virtual machine architecture.class files Class loading Execution engines

More information

Complex, concurrent software. Precision (no false positives) Find real bugs in real executions

Complex, concurrent software. Precision (no false positives) Find real bugs in real executions Harry Xu May 2012 Complex, concurrent software Precision (no false positives) Find real bugs in real executions Need to modify JVM (e.g., object layout, GC, or ISA-level code) Need to demonstrate realism

More information

LLVM Summer School, Paris 2017

LLVM Summer School, Paris 2017 LLVM Summer School, Paris 2017 David Chisnall June 12 & 13 Setting up You may either use the VMs provided on the lab machines or your own computer for the exercises. If you are using your own machine,

More information

Traditional Smalltalk Playing Well With Others Performance Etoile. Pragmatic Smalltalk. David Chisnall. August 25, 2011

Traditional Smalltalk Playing Well With Others Performance Etoile. Pragmatic Smalltalk. David Chisnall. August 25, 2011 Étoilé Pragmatic Smalltalk David Chisnall August 25, 2011 Smalltalk is Awesome! Pure object-oriented system Clean, simple syntax Automatic persistence and many other great features ...but no one cares

More information

Truffle A language implementation framework

Truffle A language implementation framework Truffle A language implementation framework Boris Spasojević Senior Researcher VM Research Group, Oracle Labs Slides based on previous talks given by Christian Wimmer, Christian Humer and Matthias Grimmer.

More information

What is a compiler? Xiaokang Qiu Purdue University. August 21, 2017 ECE 573

What is a compiler? Xiaokang Qiu Purdue University. August 21, 2017 ECE 573 What is a compiler? Xiaokang Qiu Purdue University ECE 573 August 21, 2017 What is a compiler? What is a compiler? Traditionally: Program that analyzes and translates from a high level language (e.g.,

More information

Contents in Detail. Who This Book Is For... xx Using Ruby to Test Itself... xx Which Implementation of Ruby?... xxi Overview...

Contents in Detail. Who This Book Is For... xx Using Ruby to Test Itself... xx Which Implementation of Ruby?... xxi Overview... Contents in Detail Foreword by Aaron Patterson xv Acknowledgments xvii Introduction Who This Book Is For................................................ xx Using Ruby to Test Itself.... xx Which Implementation

More information

CS153: Compilers Lecture 15: Local Optimization

CS153: Compilers Lecture 15: Local Optimization CS153: Compilers Lecture 15: Local Optimization Stephen Chong https://www.seas.harvard.edu/courses/cs153 Announcements Project 4 out Due Thursday Oct 25 (2 days) Project 5 out Due Tuesday Nov 13 (21 days)

More information

Lecture 3 Overview of the LLVM Compiler

Lecture 3 Overview of the LLVM Compiler LLVM Compiler System Lecture 3 Overview of the LLVM Compiler The LLVM Compiler Infrastructure - Provides reusable components for building compilers - Reduce the time/cost to build a new compiler - Build

More information

Intermediate Representations

Intermediate Representations COMP 506 Rice University Spring 2018 Intermediate Representations source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students

More information

Faster Programs with Guile 3

Faster Programs with Guile 3 Faster Programs with Guile 3 FOSDEM 2019, Brussels Andy Wingo wingo@igalia.com wingolog.org @andywingo this What? talk Your programs are faster with Guile 3! How? The path to Guile 3 Where? The road onward

More information

Parsing Scheme (+ (* 2 3) 1) * 1

Parsing Scheme (+ (* 2 3) 1) * 1 Parsing Scheme + (+ (* 2 3) 1) * 1 2 3 Compiling Scheme frame + frame halt * 1 3 2 3 2 refer 1 apply * refer apply + Compiling Scheme make-return START make-test make-close make-assign make- pair? yes

More information

Today. Instance Method Dispatch. Instance Method Dispatch. Instance Method Dispatch 11/29/11. today. last time

Today. Instance Method Dispatch. Instance Method Dispatch. Instance Method Dispatch 11/29/11. today. last time CS2110 Fall 2011 Lecture 25 Java program last time Java compiler Java bytecode (.class files) Compile for platform with JIT Interpret with JVM Under the Hood: The Java Virtual Machine, Part II 1 run native

More information

Building a Compiler with. JoeQ. Outline of this lecture. Building a compiler: what pieces we need? AKA, how to solve Homework 2

Building a Compiler with. JoeQ. Outline of this lecture. Building a compiler: what pieces we need? AKA, how to solve Homework 2 Building a Compiler with JoeQ AKA, how to solve Homework 2 Outline of this lecture Building a compiler: what pieces we need? An effective IR for Java joeq Homework hints How to Build a Compiler 1. Choose

More information

FTL WebKit s LLVM based JIT

FTL WebKit s LLVM based JIT FTL WebKit s LLVM based JIT Andrew Trick, Apple Juergen Ributzka, Apple LLVM Developers Meeting 2014 San Jose, CA WebKit JS Execution Tiers OSR Entry LLInt Baseline JIT DFG FTL Interpret bytecode Profiling

More information

MoarVM. A metamodel-focused runtime for NQP and Rakudo. Jonathan Worthington

MoarVM. A metamodel-focused runtime for NQP and Rakudo. Jonathan Worthington MoarVM A metamodel-focused runtime for NQP and Rakudo Jonathan Worthington What does a VM typically do? Execute instructions (possibly by interpreting, possibly by JIT compilation, often a combination)

More information

a translator to convert your AST representation to a TAC intermediate representation; and

a translator to convert your AST representation to a TAC intermediate representation; and CS 301 Spring 2016 Project Phase 3 March 28 April 14 IC Compiler Back End Plan By the end of this phase of the project, you will be able to run IC programs generated by your compiler! You will implement:

More information

HSA Foundation! Advanced Topics on Heterogeneous System Architectures. Politecnico di Milano! Seminar Room (Bld 20)! 15 December, 2017!

HSA Foundation! Advanced Topics on Heterogeneous System Architectures. Politecnico di Milano! Seminar Room (Bld 20)! 15 December, 2017! Advanced Topics on Heterogeneous System Architectures HSA Foundation! Politecnico di Milano! Seminar Room (Bld 20)! 15 December, 2017! Antonio R. Miele! Marco D. Santambrogio! Politecnico di Milano! 2

More information

ECE 5775 (Fall 17) High-Level Digital Design Automation. Static Single Assignment

ECE 5775 (Fall 17) High-Level Digital Design Automation. Static Single Assignment ECE 5775 (Fall 17) High-Level Digital Design Automation Static Single Assignment Announcements HW 1 released (due Friday) Student-led discussions on Tuesday 9/26 Sign up on Piazza: 3 students / group Meet

More information

CSc 453 Interpreters & Interpretation

CSc 453 Interpreters & Interpretation CSc 453 Interpreters & Interpretation Saumya Debray The University of Arizona Tucson Interpreters An interpreter is a program that executes another program. An interpreter implements a virtual machine,

More information

WELCOME TO PERL = Tuesday, June 4, 13

WELCOME TO PERL = Tuesday, June 4, 13 WELCOME TO PERL11 5 + 6 = 11 http://perl11.org/ Stavanger 2012 Moose + p5-mop Workshop Text Preikestolen Will Braswell Ingy döt net Austin 2012 PERL 11 5 + 6 = 11 perl11.org Will Braswell, Ingy döt net,

More information

Combined Object-Lambda Architectures

Combined Object-Lambda Architectures www.jquigley.com jquigley#jquigley.com Chicago Lisp April 2008 Research Goals System Goals Conventional Systems Unconventional Systems Research Goals Question: How to make with Pepsi and Coke? The Goal:

More information

Trace-based JIT Compilation

Trace-based JIT Compilation Trace-based JIT Compilation Hiroshi Inoue, IBM Research - Tokyo 1 Trace JIT vs. Method JIT https://twitter.com/yukihiro_matz/status/533775624486133762 2 Background: Trace-based Compilation Using a Trace,

More information

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

Python Implementation Strategies. Jeremy Hylton Python / Google

Python Implementation Strategies. Jeremy Hylton Python / Google Python Implementation Strategies Jeremy Hylton Python / Google Python language basics High-level language Untyped but safe First-class functions, classes, objects, &c. Garbage collected Simple module system

More information

Field Analysis. Last time Exploit encapsulation to improve memory system performance

Field Analysis. Last time Exploit encapsulation to improve memory system performance Field Analysis Last time Exploit encapsulation to improve memory system performance This time Exploit encapsulation to simplify analysis Two uses of field analysis Escape analysis Object inlining April

More information

HOT-Compilation: Garbage Collection

HOT-Compilation: Garbage Collection HOT-Compilation: Garbage Collection TA: Akiva Leffert aleffert@andrew.cmu.edu Out: Saturday, December 9th In: Tuesday, December 9th (Before midnight) Introduction It s time to take a step back and congratulate

More information

CSE 401 Final Exam. March 14, 2017 Happy π Day! (3/14) This exam is closed book, closed notes, closed electronics, closed neighbors, open mind,...

CSE 401 Final Exam. March 14, 2017 Happy π Day! (3/14) This exam is closed book, closed notes, closed electronics, closed neighbors, open mind,... CSE 401 Final Exam March 14, 2017 Happy π Day! (3/14) Name This exam is closed book, closed notes, closed electronics, closed neighbors, open mind,.... Please wait to turn the page until everyone has their

More information

Java: framework overview and in-the-small features

Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4020 July 5, 2007 14.00-15.30 This exam (8 pages) consists of 60 True/False

More information

Flow-sensitive rewritings and Inliner improvements for the Graal JIT compiler

Flow-sensitive rewritings and Inliner improvements for the Graal JIT compiler 1 / 25 Flow-sensitive rewritings and for the Graal JIT compiler Miguel Garcia http://lampwww.epfl.ch/~magarcia/ 2014-07-07 2 / 25 Outline Flow-sensitive rewritings during HighTier Example Rewritings in

More information

PyPy - How to not write Virtual Machines for Dynamic Languages

PyPy - How to not write Virtual Machines for Dynamic Languages PyPy - How to not write Virtual Machines for Dynamic Languages Institut für Informatik Heinrich-Heine-Universität Düsseldorf ESUG 2007 Scope This talk is about: implementing dynamic languages (with a focus

More information

Playing with bird guts. Jonathan Worthington YAPC::EU::2007

Playing with bird guts. Jonathan Worthington YAPC::EU::2007 Jonathan Worthington YAPC::EU::2007 I'm not going to do a dissection. The Plan For Today Take a simple Parrot program, written in PIR Look, from start to finish, at what happens when we feed it to the

More information

Sista: Improving Cog s JIT performance. Clément Béra

Sista: Improving Cog s JIT performance. Clément Béra Sista: Improving Cog s JIT performance Clément Béra Main people involved in Sista Eliot Miranda Over 30 years experience in Smalltalk VM Clément Béra 2 years engineer in the Pharo team Phd student starting

More information

Compiler Construction: LLVMlite

Compiler Construction: LLVMlite Compiler Construction: LLVMlite Direct compilation Expressions X86lite Input Output Compile directly from expression language to x86 Syntax-directed compilation scheme Special cases can improve generated

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter

More information

<Insert Picture Here> Symmetric multilanguage VM architecture: Running Java and JavaScript in Shared Environment on a Mobile Phone

<Insert Picture Here> Symmetric multilanguage VM architecture: Running Java and JavaScript in Shared Environment on a Mobile Phone Symmetric multilanguage VM architecture: Running Java and JavaScript in Shared Environment on a Mobile Phone Oleg Pliss Pavel Petroshenko Agenda Introduction to Monty JVM Motivation

More information

Semantic Analysis. Lecture 9. February 7, 2018

Semantic Analysis. Lecture 9. February 7, 2018 Semantic Analysis Lecture 9 February 7, 2018 Midterm 1 Compiler Stages 12 / 14 COOL Programming 10 / 12 Regular Languages 26 / 30 Context-free Languages 17 / 21 Parsing 20 / 23 Extra Credit 4 / 6 Average

More information

Intermediate Code & Local Optimizations

Intermediate Code & Local Optimizations Lecture Outline Intermediate Code & Local Optimizations Intermediate code Local optimizations Compiler Design I (2011) 2 Code Generation Summary We have so far discussed Runtime organization Simple stack

More information

CS 406/534 Compiler Construction Putting It All Together

CS 406/534 Compiler Construction Putting It All Together CS 406/534 Compiler Construction Putting It All Together Prof. Li Xu Dept. of Computer Science UMass Lowell Fall 2004 Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy

More information

Dynamic Dispatch and Duck Typing. L25: Modern Compiler Design

Dynamic Dispatch and Duck Typing. L25: Modern Compiler Design Dynamic Dispatch and Duck Typing L25: Modern Compiler Design Late Binding Static dispatch (e.g. C function calls) are jumps to specific addresses Object-oriented languages decouple method name from method

More information

Compiler Construction Lent Term 2013 Lectures 9 & 10 (of 16)

Compiler Construction Lent Term 2013 Lectures 9 & 10 (of 16) Compiler Construction ent Term 2013 ectures 9 & 10 (of 16) Assorted topics Tuples/records A peek at universal polymorphism exceptions linking and loading bootstrapping Timothy G. Griffin tgg22@cam.ac.uk

More information

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher COP4020 ming Languages Compilers and Interpreters Robert van Engelen & Chris Lacher Overview Common compiler and interpreter configurations Virtual machines Integrated development environments Compiler

More information

Self-Optimizing AST Interpreters

Self-Optimizing AST Interpreters Self-Optimizing AST Interpreters Thomas Würthinger Andreas Wöß Lukas Stadler Gilles Duboscq Doug Simon Christian Wimmer Oracle Labs Institute for System Software, Johannes Kepler University Linz, Austria

More information

Lisp to Ruby to Rubinius

Lisp to Ruby to Rubinius Lisp to Ruby to Rubinius ネットワーク応用通信研究所楽天技術研究所 Ruby アソシエーション @yukihiro_matz Yukihiro "Matz" Matsumoto Lisp 1/59 Lisp one of the oldest O-Parts out of place artifact 2/59 O-Parts of the language oldest but

More information

An Implementation of Python for Racket. Pedro Palma Ramos António Menezes Leitão

An Implementation of Python for Racket. Pedro Palma Ramos António Menezes Leitão An Implementation of Python for Racket Pedro Palma Ramos António Menezes Leitão Contents Motivation Goals Related Work Solution Performance Benchmarks Future Work 2 Racket + DrRacket 3 Racket + DrRacket

More information

Intermediate Representations

Intermediate Representations Intermediate Representations Intermediate Representations (EaC Chaper 5) Source Code Front End IR Middle End IR Back End Target Code Front end - produces an intermediate representation (IR) Middle end

More information

Dynamic Languages Strike Back. Steve Yegge Stanford EE Dept Computer Systems Colloquium May 7, 2008

Dynamic Languages Strike Back. Steve Yegge Stanford EE Dept Computer Systems Colloquium May 7, 2008 Dynamic Languages Strike Back Steve Yegge Stanford EE Dept Computer Systems Colloquium May 7, 2008 What is this talk about? Popular opinion of dynamic languages: Unfixably slow Not possible to create IDE-quality

More information

6.828: OS/Language Co-design. Adam Belay

6.828: OS/Language Co-design. Adam Belay 6.828: OS/Language Co-design Adam Belay Singularity An experimental research OS at Microsoft in the early 2000s Many people and papers, high profile project Influenced by experiences at

More information

MRI Internals. Koichi Sasada.

MRI Internals. Koichi Sasada. MRI Internals Koichi Sasada ko1@heroku.com MRI Internals towards Ruby 3 Koichi Sasada ko1@heroku.com Today s talk Koichi is working on improving Ruby internals Introduce my ideas toward Ruby 3 Koichi Sasada

More information

Tutorial: Building a backend in 24 hours. Anton Korobeynikov

Tutorial: Building a backend in 24 hours. Anton Korobeynikov Tutorial: Building a backend in 24 hours Anton Korobeynikov anton@korobeynikov.info Outline 1. From IR to assembler: codegen pipeline 2. MC 3. Parts of a backend 4. Example step-by-step The Pipeline LLVM

More information

The role of semantic analysis in a compiler

The role of semantic analysis in a compiler Semantic Analysis Outline The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2016 Lecture 3a Andrew Tolmach Portland State University 1994-2016 Formal Semantics Goal: rigorous and unambiguous definition in terms of a wellunderstood formalism (e.g.

More information

Compiling Techniques

Compiling Techniques Lecture 10: Introduction to 10 November 2015 Coursework: Block and Procedure Table of contents Introduction 1 Introduction Overview Java Virtual Machine Frames and Function Call 2 JVM Types and Mnemonics

More information

Java Internals. Frank Yellin Tim Lindholm JavaSoft

Java Internals. Frank Yellin Tim Lindholm JavaSoft Java Internals Frank Yellin Tim Lindholm JavaSoft About This Talk The JavaSoft implementation of the Java Virtual Machine (JDK 1.0.2) Some companies have tweaked our implementation Alternative implementations

More information

Skip the FFI! Embedding Clang for C Interoperability. Jordan Rose Compiler Engineer, Apple. John McCall Compiler Engineer, Apple

Skip the FFI! Embedding Clang for C Interoperability. Jordan Rose Compiler Engineer, Apple. John McCall Compiler Engineer, Apple Skip the FFI! Embedding Clang for C Interoperability Jordan Rose Compiler Engineer, Apple John McCall Compiler Engineer, Apple Problem Problem Languages don t exist in a vacuum Problem Languages don t

More information

Running class Timing on Java HotSpot VM, 1

Running class Timing on Java HotSpot VM, 1 Compiler construction 2009 Lecture 3. A first look at optimization: Peephole optimization. A simple example A Java class public class A { public static int f (int x) { int r = 3; int s = r + 5; return

More information

Project. there are a couple of 3 person teams. a new drop with new type checking is coming. regroup or see me or forever hold your peace

Project. there are a couple of 3 person teams. a new drop with new type checking is coming. regroup or see me or forever hold your peace Project there are a couple of 3 person teams regroup or see me or forever hold your peace a new drop with new type checking is coming using it is optional 1 Compiler Architecture source code Now we jump

More information

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc. Chapter 1 GETTING STARTED SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: Java platform. Applets and applications. Java programming language: facilities and foundation. Memory management

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2017 Lecture 4a Andrew Tolmach Portland State University 1994-2017 Semantics and Erroneous Programs Important part of language specification is distinguishing valid from

More information

A Propagation Engine for GCC

A Propagation Engine for GCC A Propagation Engine for GCC Diego Novillo Red Hat Canada dnovillo@redhat.com May 1, 2005 Abstract Several analyses and transformations work by propagating known values and attributes throughout the program.

More information

G Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 4 Robert Grimm, New York University 1 Review Last week Control Structures Selection Loops 2 Outline Subprograms Calling Sequences Parameter Passing

More information

Adobe Flash Player ActionScript Virtual Machine (Tamarin)

Adobe Flash Player ActionScript Virtual Machine (Tamarin) Adobe Flash Player ActionScript Virtual Machine (Tamarin) Rick Reitmaier Sr. Scientist Adobe Systems December 6, 2006 1 Adobe Today Worldwide Offices Key Statistics Adobe FY 2005 Revenue $1.966B Corporate

More information

Code Generation. Lecture 19

Code Generation. Lecture 19 Code Generation Lecture 19 Lecture Outline Topic 1: Basic Code Generation The MIPS assembly language A simple source language Stack-machine implementation of the simple language Topic 2: Code Generation

More information

Administration CS 412/413. Why build a compiler? Compilers. Architectural independence. Source-to-source translator

Administration CS 412/413. Why build a compiler? Compilers. Architectural independence. Source-to-source translator CS 412/413 Introduction to Compilers and Translators Andrew Myers Cornell University Administration Design reports due Friday Current demo schedule on web page send mail with preferred times if you haven

More information

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

More information

A Status Update of BEAMJIT, the Just-in-Time Compiling Abstract Machine. Frej Drejhammar and Lars Rasmusson

A Status Update of BEAMJIT, the Just-in-Time Compiling Abstract Machine. Frej Drejhammar and Lars Rasmusson A Status Update of BEAMJIT, the Just-in-Time Compiling Abstract Machine Frej Drejhammar and Lars Rasmusson 140609 Who am I? Senior researcher at the Swedish Institute of Computer Science

More information

VA Smalltalk 9: Exploring the next-gen LLVM-based virtual machine

VA Smalltalk 9: Exploring the next-gen LLVM-based virtual machine 2017 FAST Conference La Plata, Argentina November, 2017 VA Smalltalk 9: Exploring the next-gen LLVM-based virtual machine Alexander Mitin Senior Software Engineer Instantiations, Inc. The New VM Runtime

More information

Reference Counting. Reference counting: a way to know whether a record has other users

Reference Counting. Reference counting: a way to know whether a record has other users Garbage Collection Today: various garbage collection strategies; basic ideas: Allocate until we run out of space; then try to free stuff Invariant: only the PL implementation (runtime system) knows about

More information

FP Implementation. Simon Marlow PLMW 15

FP Implementation. Simon Marlow PLMW 15 FP Implementation Simon Marlow PLMW 15 I x = x K x y = x S x y z = x z (y z) SKI in GNU make I = $1 S = (PAP_S2,$1) S2 = (PAP_S3,$1,$2) S3 = $(call ap,$(call ap,$3,$1),$(call ap,$2,$1)) K = (PAP_K2,$1)

More information

HSA foundation! Advanced Topics on Heterogeneous System Architectures. Politecnico di Milano! Seminar Room A. Alario! 23 November, 2015!

HSA foundation! Advanced Topics on Heterogeneous System Architectures. Politecnico di Milano! Seminar Room A. Alario! 23 November, 2015! Advanced Topics on Heterogeneous System Architectures HSA foundation! Politecnico di Milano! Seminar Room A. Alario! 23 November, 2015! Antonio R. Miele! Marco D. Santambrogio! Politecnico di Milano! 2

More information

CS 426 Fall Machine Problem 4. Machine Problem 4. CS 426 Compiler Construction Fall Semester 2017

CS 426 Fall Machine Problem 4. Machine Problem 4. CS 426 Compiler Construction Fall Semester 2017 CS 426 Fall 2017 1 Machine Problem 4 Machine Problem 4 CS 426 Compiler Construction Fall Semester 2017 Handed out: November 16, 2017. Due: December 7, 2017, 5:00 p.m. This assignment deals with implementing

More information

Run-time Program Management. Hwansoo Han

Run-time Program Management. Hwansoo Han Run-time Program Management Hwansoo Han Run-time System Run-time system refers to Set of libraries needed for correct operation of language implementation Some parts obtain all the information from subroutine

More information

The Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer.

The Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer. The Compiler So Far CSC 4181 Compiler Construction Scanner - Lexical analysis Detects inputs with illegal tokens e.g.: main 5 (); Parser - Syntactic analysis Detects inputs with ill-formed parse trees

More information

Generating Code for Assignment Statements back to work. Comp 412 COMP 412 FALL Chapters 4, 6 & 7 in EaC2e. source code. IR IR target.

Generating Code for Assignment Statements back to work. Comp 412 COMP 412 FALL Chapters 4, 6 & 7 in EaC2e. source code. IR IR target. COMP 412 FALL 2017 Generating Code for Assignment Statements back to work Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights

More information

Run-time Environments. Lecture 13. Prof. Alex Aiken Original Slides (Modified by Prof. Vijay Ganesh) Lecture 13

Run-time Environments. Lecture 13. Prof. Alex Aiken Original Slides (Modified by Prof. Vijay Ganesh) Lecture 13 Run-time Environments Lecture 13 by Prof. Vijay Ganesh) Lecture 13 1 What have we covered so far? We have covered the front-end phases Lexical analysis (Lexer, regular expressions,...) Parsing (CFG, Top-down,

More information

JAVA PERFORMANCE. PR SW2 S18 Dr. Prähofer DI Leopoldseder

JAVA PERFORMANCE. PR SW2 S18 Dr. Prähofer DI Leopoldseder JAVA PERFORMANCE PR SW2 S18 Dr. Prähofer DI Leopoldseder OUTLINE 1. What is performance? 1. Benchmarking 2. What is Java performance? 1. Interpreter vs JIT 3. Tools to measure performance 4. Memory Performance

More information

A Translation Framework for Automatic Translation of Annotated LLVM IR into OpenCL Kernel Function

A Translation Framework for Automatic Translation of Annotated LLVM IR into OpenCL Kernel Function A Translation Framework for Automatic Translation of Annotated LLVM IR into OpenCL Kernel Function Chen-Ting Chang, Yu-Sheng Chen, I-Wei Wu, and Jyh-Jiun Shann Dept. of Computer Science, National Chiao

More information

Programming Assignment IV Due Thursday, June 1, 2017 at 11:59pm

Programming Assignment IV Due Thursday, June 1, 2017 at 11:59pm Programming Assignment IV Due Thursday, June 1, 2017 at 11:59pm 1 Introduction In this assignment, you will implement a code generator for Cool. When successfully completed, you will have a fully functional

More information

CSE 501: Compiler Construction. Course outline. Goals for language implementation. Why study compilers? Models of compilation

CSE 501: Compiler Construction. Course outline. Goals for language implementation. Why study compilers? Models of compilation CSE 501: Compiler Construction Course outline Main focus: program analysis and transformation how to represent programs? how to analyze programs? what to analyze? how to transform programs? what transformations

More information

Runtime. The optimized program is ready to run What sorts of facilities are available at runtime

Runtime. The optimized program is ready to run What sorts of facilities are available at runtime Runtime The optimized program is ready to run What sorts of facilities are available at runtime Compiler Passes Analysis of input program (front-end) character stream Lexical Analysis token stream Syntactic

More information

Principles of Compiler Design

Principles of Compiler Design Principles of Compiler Design Intermediate Representation Compiler Lexical Analysis Syntax Analysis Semantic Analysis Source Program Token stream Abstract Syntax tree Unambiguous Program representation

More information

JamaicaVM Java for Embedded Realtime Systems

JamaicaVM Java for Embedded Realtime Systems JamaicaVM Java for Embedded Realtime Systems... bringing modern software development methods to safety critical applications Fridtjof Siebert, 25. Oktober 2001 1 Deeply embedded applications Examples:

More information

Eliminating Global Interpreter Locks in Ruby through Hardware Transactional Memory

Eliminating Global Interpreter Locks in Ruby through Hardware Transactional Memory Eliminating Global Interpreter Locks in Ruby through Hardware Transactional Memory Rei Odaira, Jose G. Castanos and Hisanobu Tomari IBM Research and University of Tokyo April 8, 2014 Rei Odaira, Jose G.

More information

DragonEgg - the Fortran compiler

DragonEgg - the Fortran compiler DragonEgg - the Fortran compiler Contents DragonEgg - the Fortran compiler o SYNOPSIS o DESCRIPTION o BUILD DRAGONEGG PLUGIN o USAGE OF DRAGONEGG PLUGIN TO COMPILE FORTRAN PROGRAM o LLVM Optimizations

More information

LLVM for the future of Supercomputing

LLVM for the future of Supercomputing LLVM for the future of Supercomputing Hal Finkel hfinkel@anl.gov 2017-03-27 2017 European LLVM Developers' Meeting What is Supercomputing? Computing for large, tightly-coupled problems. Lots of computational

More information