Just-In-Time Compilers & Runtime Optimizers

Size: px
Start display at page:

Download "Just-In-Time Compilers & Runtime Optimizers"

Transcription

1 COMP 412 FALL 2017 Just-In-Time Compilers & Runtime Optimizers Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make copies of these materials for their personal use. Faculty from other educational institutions may use these materials for nonprofit educational purposes, provided this copyright notice is preserved. Not in EaC2e; might be in EaC3e

2 Runtime Compilation Many modern languages have features that make it difficult to produce high-quality code at compile time Late binding Dynamic loading Polymorphism One approach to improving performance in these languages is to compile, or to optimize, at runtime Just-in-time compilers Runtime optimizers Distinction with very little difference We will talk about one of each The idea is simple: optimize at runtime when more facts are known. COMP 412, Fall

3 This Lecture We will look at two examples: Dynamo & the Hotspot Server Compiler Very different use cases Dynamo sits between a normal executable & the hardware Dynamo finds hot traces & uses local optimization to improve them Hotspot sits inside the JVM & compiles hot methods to native code Hotspot spends more compile time to achieve more improvement Good examples of JIT compilation Different granularities & levels of aggression Different runtime environments enable different techniques Online: the grandfather of Hotspot may well be Deutsch & Schiffman s system for Smalltalk-80 Hotspot authors studied that paper in COMP 512 Vasanth Bala got his PhD before COMP 512 existed COMP 412, Fall

4 Runtime Optimizers: Dynamo Dynamo and DynamoRIO are classic examples of a runtime optimizer Attach to a running executable Capture hot traces, optimize them, & link them into running code Code Static & Global Runtime Stack Free Space Heap Dynamo ran on an HP 8000 Worked with, essentially, any executable Programmer adds a call to start the system Processor Normal Execution DynamoRIO re-implemented Dynamo for the x86 under Windows & Linux COMP 412, Fall

5 Runtime Optimizers: Dynamo Dynamo and DynamoRIO are classic examples of a runtime optimizer Attach to a running executable Capture hot traces, optimize them, & link them into running code Code Static & Global Runtime Stack Free Space Heap Dynamo Processor Execution with Dynamo Dynamo sits between the code & the hardware Interprets the code & builds up traces Collects profile data When trace count > 50, it compiles & optimizes trace Future executions run the compiled version of trace Bala, Duesterwald, Banerjia, Dynamo: A transparent dynamic optimization system, COMP Proceedings 412, Fall of 2017 PLDI 2000, ACM,

6 How does it work? no Interpret until taken branch Lookup branch target in cache miss start of trace? hit Jump to cached fragment yes Counter for br. target ++ no Counter > hot threshold Fragment Cache yes Interpret + code gen until taken branch Emit, link, & recycle counter Create & opt ze new fragment end of trace? no COMP 412, Fall

7 How does it work? no Interpret until taken branch Lookup branch target in cache hit Jump to cached fragment miss Fragment Cache Interpret the cold code until the code start of trace? takes a branch Target yesis in fragment cache? no Yes Þ jump to the fragment Counter for br. Counter > target No ++ Þ decide whether hot threshold or not to start a new fragment yes Interpret + code Cold code is interpreted gen until taken(slow) Hot code is optimized & branch run (fast) Emit, link, & recycle counter Create no Hot & must opt zemake up for end cold, of trace? if system is new to fragment be profitable COMP 412, Fall

8 How does it work? Start of trace Þ Target of backward branch (loop header) Þ Fragment cache exit branch no Interpret until taken branch Lookup branch target in cache miss start of trace? hit Jump to cached fragment yes Counter for br. target ++ no Counter > hot threshold If start of trace condition holds, bump Fragment trace s counter Cache If the counter > some threshold value (50) Move into code generation & optimization phase to convert code into an optimized fragment in the fragment cache Emit, link, & Create & opt ze Otherwise, go back to interpreting recycle counter new fragment Counter forces trace to be hot before spending effort to improve it COMP 412, Fall yes Interpret + code gen until taken branch end of trace? no

9 How does it work? End of trace Þ Taken backward branch (bottom of loop) Þ Fragment cache entry label To build an optimized fragment: no Interpret each operation & generate low-level IR code Interpret until Lookup branch Encounter a branch? start of trace? taken branch target in cache miss If end-of-trace condition holds create & optimize the hitnew fragment yes no emit the fragment, link it to other fragments, & free the counter Otherwise, keep Jump interpreting to cached Counter for br. Counter > fragment target ++ hot threshold Fragment Cache yes Interpret + code gen until taken branch Emit, link, & recycle counter Create & opt ze new fragment end of trace? no COMP 412, Fall

10 How does it work? no Interpret until taken branch Lookup branch target in cache miss start of trace? hit Jump to cached fragment yes Counter for br. target ++ no Counter > hot threshold Fragment Cache yes Interpret + code gen until taken branch Emit, link, & recycle counter Moving Create & code opt ze fragment into the cache end of trace? End new of fragment branch jumps to stub that jumps to the interpreter no COMP 412, Fall

11 Fragment Construction B A D E F C call H G J I Profile mechanism identifies A as start of a hot path After threshold trips through A, the next path is compiled Speculative construction method adds C, D, G, I, J, & E, then backward branch to A Run-time compiler builds a fragment for ACDGIJE, with exits for B, H, & F Builds the branch for E A return COMP Speculative 412, Fall 2017 construction because it assumes that 51 st time will take the hot path. 10

12 Effects of Fragment Construction From the interpreter Back to the interpreter A C D G I J E F* B* H* Hot path is linearized Eliminates branches Creates superblock Applies local optimization Cold-path branches remain Targets are stubs Start interpreter at the target op Path can include call & return Jumps not branches Interprocedural effects Indirect branches Speculate on target Fall back on hash table of branch targets COMP 412, Fall

13 Sources of Improvement Many small things contribute to make Dynamo profitable Linearization eliminates branches Improves TLB & I-cache behavior 2 passes of local optimization Redundancy elimination, copy propagation, constant folding, simple strength reduction, loop unrolling, loop invariant code motion, redundant load removal One forward pass, one backward pass Linear code with premature exits Dynamo appears to split traces at an intermediate entry point Fragment linking should make execution fast while splitting stops code motion across intermediate entry point Keep in mind that local in a trace captures interprocedural effects Engineering detail makes a difference Fragment cache management sparked lots of work in the noughts. COMP 412, Fall

14 Redundant Computations Some on-trace redundancies are easily detected Trace defines some register, say r 3 Definition may be partially dead Live on exit but not in the trace Þ move it to the exit stub Live in trace but not at early exit Þ move it below the exit Implies that we have LIVE information for the code Collect LIVE sets during backward pass Move partially dead definitions during forward pass Store summary LIVE set for fragments Allows interfragment optimization Can we know this? Only if exit is to a fragment rather than to the interpreter. Otherwise, must assume that definition is LIVE on each exit COMP 412, Fall

15 Fragment Linking Block B meets start of trace condition (exit from fragment) A From the interpreter A B C C D D E F call H G I Speculative Trace Construction G I J E J F* return What happens if another path becomes hot? (Say ABDGIJE) Back to the interpreter COMP 412, Fall B* H* *

16 Fragment Linking When counter in B reaches hot: Builds a fragment From the interpreter A C D G I J E Back to the interpreter COMP 412, Fall F* B* H*

17 Fragment Linking When counter in B reaches hot: Builds a fragment From the interpreter A C D G I J E B D G I J E Back to the interpreter COMP 412, Fall F* B* H* F* A* H*

18 Fragment Linking When counter reaches hot: Builds a fragment Links exit A B to new fragment Links exit E A to old fragment From the interpreter A C D G I J E B D G I J E F* F* Back to the interpreter COMP 412, Fall H* H*

19 Fragment Linking When counter reaches hot: Builds a fragment Links exit A B to new fragment Links exit E A to old fragment From the interpreter What if B* held redundant op? Have LIVE on entry to B Can test LIVE sets for both exit from A & entry to B May show op is dead Back to the interpreter COMP 412, Fall A C D G I J E F* H* B D G I J E F* H*

20 Results They measured performance on codes from Spec95 Now, recall that Dynamo operated in competition with the bare hardware the lowest overhead situation that we can imagine. What about a Java JIT, where the JVM has much higher overhead? Graphic from ARS Technica report on Dynamo COMP 412, Fall

21 JITs: The Java Hotspot TM Server Compiler Java s execution model is defined by the Java Virtual Machine (JVM) Code is compiled into bytecode for the JVM At runtime, the JVM interprets the bytecode Advantages for portability & security, disadvantage for execution speed Class Loader Thread 1 Thread 2 Thread n Bytecodes PC Register JVM Stack PC Register JVM Stack PC Register JVM Stack Native Stack Native Stack Native Stack Method Area Heap Execution Engine Native Method Interface Native Method Libraries COMP 412, Fall

22 JITs: The Java Hotspot TM Server Compiler Java s execution model is defined by the Java Virtual Machine (JVM) Classic example of a Java JIT is the Hotspot Server Compiler A JIT adds another execution mode: native methods for user code Class Loader Thread 1 Thread 2 Thread n Native Code Bytecodes PC Register JVM Stack PC Register JVM Stack PC Register JVM Stack Code Cache Method Area Native Stack Native Stack Native Stack Heap JIT Execution Engine Native Method Interface Native Method Libraries COMP 412, Fall

23 Hotspot How does all of this fit together? The execution engine identifies a hot method Typically uses a pre-set threshold (Hotspot default is 10,000) The execution engine invokes the JIT to compile for the hot method JIT compiles bytecode into native code that works within JVM structures JIT & execution engine arrange to link new code into the running program Class loader triggers selective de-optimization Runtime compilation places a premium on JIT efficiency What does the JIT do? Translation to its internal IR Fast optimization emphasis on fast, which often means local Translation to native code & linking to other native code Much of the speedup comes from eliminating cost of interpretation COMP 412, Fall

24 Java JVM versus JIT Interpreted code in the JVM The JVM interprets eachbytecode Fetch, decode, & execute in software 1 Multiple hardware operations per bytecode Almost certainly sequential Each bytecode is interpreted every time it is encountered Slope difference between a python lab 1 and a Java lab 1 is, in large part, the JIT Code produced by JIT in JVM Execution mixes interpreted & compiled code JIT-compiled code runs as native operations Fetch, decode, & execute in hardware Three phases run in parallel Fewer operations per bytecode JIT-compiled code uses JVM runtime structures Little or no translation Efficient switching from JVM to JIT and back Method is translated once 1 COMP See page 412, 6FF Fall in 2017 The ILOC Virtual Machine lecture 5 on the course web site s Lectures page 23

25 Java JVM versus JIT In this region, you see the switch over from JVM-interpreted code to native code Seconds ,000 8,000 12,000 16,000 Good lab 1 in python, which is interpreted 1.0 Good lab 1 in Java ,000 32,000 48,000 64,000 80,000 96, , ,000 COMP 412, Fall 2017 Lines of ILOC in Input File 24

26 Hotspot Hotspot looks very different from Dynamo Compiles single methods or inlined chains of methods Identifies performance critical methods and works backward from them to identify how many levels of method (in call graph) it should compile Counter at method entry and on backward branches (DOM) When sum of these counters exceeds threshold, compile method and, perhaps, the chain that calls it Parse Java bytecodes into a low-level, graphical IR First pass identifies basic blocks Second pass generates the graph Hotspot performs local optimization during this translation Parser identifies loop headers and creates a list of headers The IR is a variant of Ferrante, Ottenstein, & Warren s data-flow graphs. See Click & Paleczny, COMP A Simple 412, Graph-Based Fall 2017 Intermediate Representation, or Click s thesis for details. 25

27 Hotspot Hotspot looks very different from Dynamo Optimizer uses classical optimization techniques, adapted to JIT Full-fledged class hierarchy analysis (CHA) to infer types Inlining based on results of CHA Fast path / slow path optimization (allocation, instanceof, ) Optimistic constant propagation (Wegman Zadeck) Iterative global value numbering (iterate around loops) BURS-based instruction scheduling (locally optimal) Global instruction scheduling (Click s algorithm) Sparse Chaitin-Briggs, graph-coloring register allocator Final pass of peephole optimization Global value numbering Starts from list of loop headers that s where the opportunity lies GVN includes a bunch of transformations, including cloning & loop peeling, constant propagation, dead code elimination, & value numbering COMP Paleczny, 412, Vick, Fall and 2017 Click, The Java Hotspot Server Compiler, Proceedings of JVM 01, April

28 Hotspot Results 100% (selected, figure from JVM 01 paper) SPECjvm98 (test mode) on IA32[tm] 90% 80% performance 70% 60% 50% 40% 30% 20% Mtrt Jess Compress Db Mpegau dio Jack Javac No Inlining Simple Inline No CHA FCS 2.0 These results are for total execution time including Hotspot execution. COMP 412, Fall

29 Dynamo versus Hotspot Dynamo Input is running machine code Granularity is a runtime trace Performs 2 linear local passes Benefit comes from optimization and from linearization of trace Threshold is low (50) Overhead is low Dynamo is profitable, running on bare hardware (suprising) Hotspot Input is running Java bytecode Granularity is 1 method Parses bytecode, builds an IR, performs classical optimizations, uses a BURS selector, applies a graph-coloring allocator Threshold is high (sum > 10,000) Overhead is higher than Dynamo Hotspot is profitable, running inside the JVM Both systems worked quite well & inspired further work Their success inspired systems that are in widespread use, from DynamoRIO through JITs for Javascript (V8), PHP, and many others COMP 412, Fall

Register Allocation. Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP 412 at Rice.

Register Allocation. Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP 412 at Rice. Register Allocation Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP at Rice. Copyright 00, Keith D. Cooper & Linda Torczon, all rights reserved.

More information

Local Optimization: Value Numbering The Desert Island Optimization. Comp 412 COMP 412 FALL Chapter 8 in EaC2e. target code

Local Optimization: Value Numbering The Desert Island Optimization. Comp 412 COMP 412 FALL Chapter 8 in EaC2e. target code COMP 412 FALL 2017 Local Optimization: Value Numbering The Desert Island Optimization Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon,

More information

The Software Stack: From Assembly Language to Machine Code

The Software Stack: From Assembly Language to Machine Code COMP 506 Rice University Spring 2018 The Software Stack: From Assembly Language to Machine Code source code IR Front End Optimizer Back End IR target code Somewhere Out Here Copyright 2018, Keith D. Cooper

More information

Code Merge. Flow Analysis. bookkeeping

Code Merge. Flow Analysis. bookkeeping Historic Compilers Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make copies of these materials

More information

Instruction Scheduling Beyond Basic Blocks Extended Basic Blocks, Superblock Cloning, & Traces, with a quick introduction to Dominators.

Instruction Scheduling Beyond Basic Blocks Extended Basic Blocks, Superblock Cloning, & Traces, with a quick introduction to Dominators. Instruction Scheduling Beyond Basic Blocks Extended Basic Blocks, Superblock Cloning, & Traces, with a quick introduction to Dominators Comp 412 COMP 412 FALL 2016 source code IR Front End Optimizer Back

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

The Processor Memory Hierarchy

The Processor Memory Hierarchy Corrected COMP 506 Rice University Spring 2018 The Processor Memory Hierarchy source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved.

More information

The View from 35,000 Feet

The View from 35,000 Feet The View from 35,000 Feet This lecture is taken directly from the Engineering a Compiler web site with only minor adaptations for EECS 6083 at University of Cincinnati Copyright 2003, Keith D. Cooper,

More information

Runtime Support for Algol-Like Languages Comp 412

Runtime Support for Algol-Like Languages Comp 412 COMP 412 FALL 2018 Runtime Support for Algol-Like Languages Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students

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

Instruction Selection: Preliminaries. Comp 412

Instruction Selection: Preliminaries. Comp 412 COMP 412 FALL 2017 Instruction Selection: Preliminaries Comp 412 source code Front End Optimizer Back End target code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled

More information

Combining Optimizations: Sparse Conditional Constant Propagation

Combining Optimizations: Sparse Conditional Constant Propagation Comp 512 Spring 2011 Combining Optimizations: Sparse Conditional Constant Propagation Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University

More information

Procedure and Function Calls, Part II. Comp 412 COMP 412 FALL Chapter 6 in EaC2e. target code. source code Front End Optimizer Back End

Procedure and Function Calls, Part II. Comp 412 COMP 412 FALL Chapter 6 in EaC2e. target code. source code Front End Optimizer Back End COMP 412 FALL 2017 Procedure and Function Calls, Part II Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students

More information

Mixed Mode Execution with Context Threading

Mixed Mode Execution with Context Threading Mixed Mode Execution with Context Threading Mathew Zaleski, Marc Berndl, Angela Demke Brown University of Toronto {matz,berndl,demke}@cs.toronto.edu (CASCON 2005, Oct 19/2005.) Overview Introduction Background:

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

Sustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java)

Sustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java) COMP 412 FALL 2017 Sustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java) Copyright 2017, Keith D. Cooper & Zoran Budimlić, all rights reserved. Students enrolled in Comp 412 at Rice

More information

Runtime Support for OOLs Object Records, Code Vectors, Inheritance Comp 412

Runtime Support for OOLs Object Records, Code Vectors, Inheritance Comp 412 COMP 412 FALL 2017 Runtime Support for OOLs Object Records, Code Vectors, Inheritance Comp 412 source IR Front End Optimizer Back End IR target Copyright 2017, Keith D. Cooper & Linda Torczon, all rights

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

Code Shape Comp 412 COMP 412 FALL Chapters 4, 5, 6 & 7 in EaC2e. source code. IR IR target. code. Front End Optimizer Back End

Code Shape Comp 412 COMP 412 FALL Chapters 4, 5, 6 & 7 in EaC2e. source code. IR IR target. code. Front End Optimizer Back End COMP 412 FALL 2017 Code Shape Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at

More information

Optimizer. Defining and preserving the meaning of the program

Optimizer. Defining and preserving the meaning of the program Where are we? Well understood Engineering Source Code Front End IR Optimizer IR Back End Machine code Errors The latter half of a compiler contains more open problems, more challenges, and more gray areas

More information

Implementing Control Flow Constructs Comp 412

Implementing Control Flow Constructs Comp 412 COMP 412 FALL 2018 Implementing Control Flow Constructs Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students

More information

Just-In-Time Compilation

Just-In-Time Compilation Just-In-Time Compilation Thiemo Bucciarelli Institute for Software Engineering and Programming Languages 18. Januar 2016 T. Bucciarelli 18. Januar 2016 1/25 Agenda Definitions Just-In-Time Compilation

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

Naming in OOLs and Storage Layout Comp 412

Naming in OOLs and Storage Layout Comp 412 COMP 412 FALL 2018 Naming in OOLs and Storage Layout Comp 412 source IR IR target Front End Optimizer Back End Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in

More information

Overview of a Compiler

Overview of a Compiler High-level View of a Compiler Overview of a Compiler Compiler Copyright 2010, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University of Southern California have

More information

Arrays and Functions

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

More information

JOVE. An Optimizing Compiler for Java. Allen Wirfs-Brock Instantiations Inc.

JOVE. An Optimizing Compiler for Java. Allen Wirfs-Brock Instantiations Inc. An Optimizing Compiler for Java Allen Wirfs-Brock Instantiations Inc. Object-Orient Languages Provide a Breakthrough in Programmer Productivity Reusable software components Higher level abstractions Yield

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

Compiler construction 2009

Compiler construction 2009 Compiler construction 2009 Lecture 3 JVM and optimization. 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

More information

Introduction to Optimization Local Value Numbering

Introduction to Optimization Local Value Numbering COMP 506 Rice University Spring 2018 Introduction to Optimization Local Value Numbering source IR IR target code Front End Optimizer Back End code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights

More information

About the Authors... iii Introduction... xvii. Chapter 1: System Software... 1

About the Authors... iii Introduction... xvii. Chapter 1: System Software... 1 Table of Contents About the Authors... iii Introduction... xvii Chapter 1: System Software... 1 1.1 Concept of System Software... 2 Types of Software Programs... 2 Software Programs and the Computing Machine...

More information

Dynamic Compila-on in Smalltalk- 80

Dynamic Compila-on in Smalltalk- 80 COMP 512 Rice University Spring 2015 Dynamic Compila-on in Smalltalk- 80 The Deutsch- Schiffman Implementa4on L.P. Deutsch and A.M. Schiffman, Efficient ImplementaHon of the Smalltalk- 80 System, Conference

More information

Dynamo: A Transparent Dynamic Optimization System

Dynamo: A Transparent Dynamic Optimization System Dynamo: A Transparent Dynamic Optimization System Vasanth Bala vas@hpl.hp.com Evelyn Duesterwald duester@hpl.hp.com Hewlett-Packard Labs 1 Main Street, Cambridge, MA 02142 www.hpl.hp.com/cambridge/projects/dynamo

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

Handling Assignment Comp 412

Handling Assignment Comp 412 COMP 412 FALL 2018 Handling Assignment Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp

More information

Parsing II Top-down parsing. Comp 412

Parsing II Top-down parsing. Comp 412 COMP 412 FALL 2018 Parsing II Top-down parsing Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled

More information

Code Shape II Expressions & Assignment

Code Shape II Expressions & Assignment Code Shape II Expressions & Assignment Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make

More information

Lecture 9 Dynamic Compilation

Lecture 9 Dynamic Compilation Lecture 9 Dynamic Compilation I. Motivation & Background II. Overview III. Compilation Policy IV. Partial Method Compilation V. Partial Dead Code Elimination VI. Escape Analysis VII. Results Partial Method

More information

Building a Runnable Program and Code Improvement. Dario Marasco, Greg Klepic, Tess DiStefano

Building a Runnable Program and Code Improvement. Dario Marasco, Greg Klepic, Tess DiStefano Building a Runnable Program and Code Improvement Dario Marasco, Greg Klepic, Tess DiStefano Building a Runnable Program Review Front end code Source code analysis Syntax tree Back end code Target code

More information

Intelligent Compilation

Intelligent Compilation Intelligent Compilation John Cavazos Department of Computer and Information Sciences University of Delaware Autotuning and Compilers Proposition: Autotuning is a component of an Intelligent Compiler. Code

More information

YETI. GraduallY Extensible Trace Interpreter VEE Mathew Zaleski, Angela Demke Brown (University of Toronto) Kevin Stoodley (IBM Toronto)

YETI. GraduallY Extensible Trace Interpreter VEE Mathew Zaleski, Angela Demke Brown (University of Toronto) Kevin Stoodley (IBM Toronto) YETI GraduallY Extensible Trace Interpreter Mathew Zaleski, Angela Demke Brown (University of Toronto) Kevin Stoodley (IBM Toronto) VEE 2007 1 Goal Create a VM that is more easily extended with a just

More information

Optimization Techniques

Optimization Techniques Smalltalk Implementation: Optimization Techniques Prof. Harry Porter Portland State University 1 Optimization Ideas Just-In-Time (JIT) compiling When a method is first invoked, compile it into native code.

More information

Tour of common optimizations

Tour of common optimizations Tour of common optimizations Simple example foo(z) { x := 3 + 6; y := x 5 return z * y } Simple example foo(z) { x := 3 + 6; y := x 5; return z * y } x:=9; Applying Constant Folding Simple example foo(z)

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

The ILOC Virtual Machine (Lab 1 Background Material) Comp 412

The ILOC Virtual Machine (Lab 1 Background Material) Comp 412 COMP 12 FALL 20 The ILOC Virtual Machine (Lab 1 Background Material) Comp 12 source code IR Front End OpMmizer Back End IR target code Copyright 20, Keith D. Cooper & Linda Torczon, all rights reserved.

More information

Reducing the Overhead of Dynamic Compilation

Reducing the Overhead of Dynamic Compilation Reducing the Overhead of Dynamic Compilation Chandra Krintz y David Grove z Derek Lieber z Vivek Sarkar z Brad Calder y y Department of Computer Science and Engineering, University of California, San Diego

More information

Azul Systems, Inc.

Azul Systems, Inc. 1 Stack Based Allocation in the Azul JVM Dr. Cliff Click cliffc@azulsystems.com 2005 Azul Systems, Inc. Background The Azul JVM is based on Sun HotSpot a State-of-the-Art Java VM Java is a GC'd language

More information

Syntax Analysis, V Bottom-up Parsing & The Magic of Handles Comp 412

Syntax Analysis, V Bottom-up Parsing & The Magic of Handles Comp 412 Midterm Exam: Thursday October 18, 7PM Herzstein Amphitheater Syntax Analysis, V Bottom-up Parsing & The Magic of Handles Comp 412 COMP 412 FALL 2018 source code IR Front End Optimizer Back End IR target

More information

Syntax Analysis, III Comp 412

Syntax Analysis, III Comp 412 Updated algorithm for removal of indirect left recursion to match EaC3e (3/2018) COMP 412 FALL 2018 Midterm Exam: Thursday October 18, 7PM Herzstein Amphitheater Syntax Analysis, III Comp 412 source code

More information

Debunking Dynamic Optimization Myths

Debunking Dynamic Optimization Myths Debunking Dynamic Optimization Myths Michael Hind (Material borrowed from 3 hr PLDI 04 Tutorial by Stephen Fink, David Grove, and Michael Hind. See those slides for more details.) September 15, 2004 Future

More information

The So'ware Stack: From Assembly Language to Machine Code

The So'ware Stack: From Assembly Language to Machine Code Taken from COMP 506 Rice University Spring 2017 The So'ware Stack: From Assembly Language to Machine Code source code IR Front End OpJmizer Back End IR target code Somewhere Out Here Copyright 2017, Keith

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

Code Optimization. Code Optimization

Code Optimization. Code Optimization 161 Code Optimization Code Optimization 162 Two steps: 1. Analysis (to uncover optimization opportunities) 2. Optimizing transformation Optimization: must be semantically correct. shall improve program

More information

Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit

Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit Intermediate Representations Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make copies

More information

Syntax Analysis, III Comp 412

Syntax Analysis, III Comp 412 COMP 412 FALL 2017 Syntax Analysis, III Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp

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

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

Compact and Efficient Strings for Java

Compact and Efficient Strings for Java Compact and Efficient Strings for Java Christian Häubl, Christian Wimmer, Hanspeter Mössenböck Institute for System Software, Christian Doppler Laboratory for Automated Software Engineering, Johannes Kepler

More information

Intermediate Representations

Intermediate Representations Most of the material in this lecture comes from Chapter 5 of EaC2 Intermediate Representations Note by Baris Aktemur: Our slides are adapted from Cooper and Torczon s slides that they prepared for COMP

More information

For our next chapter, we will discuss the emulation process which is an integral part of virtual machines.

For our next chapter, we will discuss the emulation process which is an integral part of virtual machines. For our next chapter, we will discuss the emulation process which is an integral part of virtual machines. 1 2 For today s lecture, we ll start by defining what we mean by emulation. Specifically, in this

More information

Global Register Allocation via Graph Coloring

Global Register Allocation via Graph Coloring Global Register Allocation via Graph Coloring Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission

More information

Instruction Selection: Peephole Matching. Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.

Instruction Selection: Peephole Matching. Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Instruction Selection: Peephole Matching Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. The Problem Writing a compiler is a lot of work Would like to reuse components

More information

Swift: A Register-based JIT Compiler for Embedded JVMs

Swift: A Register-based JIT Compiler for Embedded JVMs Swift: A Register-based JIT Compiler for Embedded JVMs Yuan Zhang, Min Yang, Bo Zhou, Zhemin Yang, Weihua Zhang, Binyu Zang Fudan University Eighth Conference on Virtual Execution Environment (VEE 2012)

More information

Managed runtimes & garbage collection. CSE 6341 Some slides by Kathryn McKinley

Managed runtimes & garbage collection. CSE 6341 Some slides by Kathryn McKinley Managed runtimes & garbage collection CSE 6341 Some slides by Kathryn McKinley 1 Managed runtimes Advantages? Disadvantages? 2 Managed runtimes Advantages? Reliability Security Portability Performance?

More information

IBM Research - Tokyo 数理 計算科学特論 C プログラミング言語処理系の最先端実装技術. Trace Compilation IBM Corporation

IBM Research - Tokyo 数理 計算科学特論 C プログラミング言語処理系の最先端実装技術. Trace Compilation IBM Corporation 数理 計算科学特論 C プログラミング言語処理系の最先端実装技術 Trace Compilation Trace JIT vs. Method JIT https://twitter.com/yukihiro_matz/status/533775624486133762 2 Background: Trace-based Compilation Using a Trace, a hot path identified

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

Syntax Analysis, VII One more LR(1) example, plus some more stuff. Comp 412 COMP 412 FALL Chapter 3 in EaC2e. target code.

Syntax Analysis, VII One more LR(1) example, plus some more stuff. Comp 412 COMP 412 FALL Chapter 3 in EaC2e. target code. COMP 412 FALL 2017 Syntax Analysis, VII One more LR(1) example, plus some more stuff Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon,

More information

Managed runtimes & garbage collection

Managed runtimes & garbage collection Managed runtimes Advantages? Managed runtimes & garbage collection CSE 631 Some slides by Kathryn McKinley Disadvantages? 1 2 Managed runtimes Portability (& performance) Advantages? Reliability Security

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

YETI: a gradually Extensible Trace Interpreter

YETI: a gradually Extensible Trace Interpreter Thesis Proposal: YETI: a gradually Extensible Trace Interpreter Mathew Zaleski (for advisory committee meeting Jan 17/2007) 1 2 Contents 1 Introduction 7 1.1 Challenges of Efficient Interpretation.......................

More information

Loop Invariant Code Mo0on

Loop Invariant Code Mo0on COMP 512 Rice University Spring 2015 Loop Invariant Code Mo0on A Simple Classical Approach Copyright 2015, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University

More information

Method-Level Phase Behavior in Java Workloads

Method-Level Phase Behavior in Java Workloads Method-Level Phase Behavior in Java Workloads Andy Georges, Dries Buytaert, Lieven Eeckhout and Koen De Bosschere Ghent University Presented by Bruno Dufour dufour@cs.rutgers.edu Rutgers University DCS

More information

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker Computers in Engineering COMP 208 Computer Structure Michael A. Hawker Computer Structure We will briefly look at the structure of a modern computer That will help us understand some of the concepts that

More information

Dynamic Selection of Application-Specific Garbage Collectors

Dynamic Selection of Application-Specific Garbage Collectors Dynamic Selection of Application-Specific Garbage Collectors Sunil V. Soman Chandra Krintz University of California, Santa Barbara David F. Bacon IBM T.J. Watson Research Center Background VMs/managed

More information

Compilers and Interpreters

Compilers and Interpreters Overview Roadmap Language Translators: Interpreters & Compilers Context of a compiler Phases of a compiler Compiler Construction tools Terminology How related to other CS Goals of a good compiler 1 Compilers

More information

Computing Inside The Parser Syntax-Directed Translation. Comp 412 COMP 412 FALL Chapter 4 in EaC2e. source code. IR IR target.

Computing Inside The Parser Syntax-Directed Translation. Comp 412 COMP 412 FALL Chapter 4 in EaC2e. source code. IR IR target. COMP 412 FALL 2017 Computing Inside The Parser Syntax-Directed Translation Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights

More information

FIST: A Framework for Instrumentation in Software Dynamic Translators

FIST: A Framework for Instrumentation in Software Dynamic Translators FIST: A Framework for Instrumentation in Software Dynamic Translators Naveen Kumar, Jonathan Misurda, Bruce R. Childers, and Mary Lou Soffa Department of Computer Science University of Pittsburgh Pittsburgh,

More information

EDAN65: Compilers, Lecture 13 Run;me systems for object- oriented languages. Görel Hedin Revised:

EDAN65: Compilers, Lecture 13 Run;me systems for object- oriented languages. Görel Hedin Revised: EDAN65: Compilers, Lecture 13 Run;me systems for object- oriented languages Görel Hedin Revised: 2014-10- 13 This lecture Regular expressions Context- free grammar ATribute grammar Lexical analyzer (scanner)

More information

CS 406/534 Compiler Construction Instruction Selection and Global Register Allocation

CS 406/534 Compiler Construction Instruction Selection and Global Register Allocation CS 406/534 Compiler Construction Instruction Selection and Global Register Allocation Prof. Li Xu Dept. of Computer Science UMass Lowell Fall 2004 Part of the course lecture notes are based on Prof. Keith

More information

COMP 181 Compilers. Administrative. Last time. Prelude. Compilation strategy. Translation strategy. Lecture 2 Overview

COMP 181 Compilers. Administrative. Last time. Prelude. Compilation strategy. Translation strategy. Lecture 2 Overview COMP 181 Compilers Lecture 2 Overview September 7, 2006 Administrative Book? Hopefully: Compilers by Aho, Lam, Sethi, Ullman Mailing list Handouts? Programming assignments For next time, write a hello,

More information

Reducing the Overhead of Dynamic Compilation

Reducing the Overhead of Dynamic Compilation Reducing the Overhead of Dynamic Compilation Chandra Krintz David Grove Derek Lieber Vivek Sarkar Brad Calder Department of Computer Science and Engineering, University of California, San Diego IBM T.

More information

The Potentials and Challenges of Trace Compilation:

The Potentials and Challenges of Trace Compilation: Peng Wu IBM Research January 26, 2011 The Potentials and Challenges of Trace Compilation: Lessons learned from building a trace-jit on top of J9 JVM (Joint work with Hiroshige Hayashizaki and Hiroshi Inoue,

More information

Intermediate Code Generation (ICG)

Intermediate Code Generation (ICG) Intermediate Code Generation (ICG) Transform AST to lower-level intermediate representation Basic Goals: Separation of Concerns Generate efficient code sequences for individual operations Keep it fast

More information

CS415 Compilers. Procedure Abstractions. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS415 Compilers. Procedure Abstractions. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University CS415 Compilers Procedure Abstractions These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Where are we? Well understood Engineering Source Code

More information

CS553 Lecture Dynamic Optimizations 2

CS553 Lecture Dynamic Optimizations 2 Dynamic Optimizations Last time Predication and speculation Today Dynamic compilation CS553 Lecture Dynamic Optimizations 2 Motivation Limitations of static analysis Programs can have values and invariants

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

CS415 Compilers. Intermediate Represeation & Code Generation

CS415 Compilers. Intermediate Represeation & Code Generation CS415 Compilers Intermediate Represeation & Code Generation These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Review - Types of Intermediate Representations

More information

Combining Analyses, Combining Optimizations - Summary

Combining Analyses, Combining Optimizations - Summary Combining Analyses, Combining Optimizations - Summary 1. INTRODUCTION Cliff Click s thesis Combining Analysis, Combining Optimizations [Click and Cooper 1995] uses a structurally different intermediate

More information

Trace Compilation. Christian Wimmer September 2009

Trace Compilation. Christian Wimmer  September 2009 Trace Compilation Christian Wimmer cwimmer@uci.edu www.christianwimmer.at September 2009 Department of Computer Science University of California, Irvine Background Institute for System Software Johannes

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

Improving Mobile Program Performance Through the Use of a Hybrid Intermediate Representation

Improving Mobile Program Performance Through the Use of a Hybrid Intermediate Representation Improving Mobile Program Performance Through the Use of a Hybrid Intermediate Representation Chandra Krintz Computer Science Department University of California, Santa Barbara Abstract We present a novel

More information

Overview of a Compiler

Overview of a Compiler Overview of a Compiler Copyright 2017, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University of Southern California have explicit permission to make copies of

More information

Computing Inside The Parser Syntax-Directed Translation, II. Comp 412 COMP 412 FALL Chapter 4 in EaC2e. source code. IR IR target.

Computing Inside The Parser Syntax-Directed Translation, II. Comp 412 COMP 412 FALL Chapter 4 in EaC2e. source code. IR IR target. COMP 412 FALL 20167 Computing Inside The Parser Syntax-Directed Translation, II Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2017, Keith D. Cooper & Linda Torczon, all

More information

Overview of a Compiler

Overview of a Compiler Overview of a Compiler Copyright 2015, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University of Southern California have explicit permission to make copies of

More information

USC 227 Office hours: 3-4 Monday and Wednesday CS553 Lecture 1 Introduction 4

USC 227 Office hours: 3-4 Monday and Wednesday  CS553 Lecture 1 Introduction 4 CS553 Compiler Construction Instructor: URL: Michelle Strout mstrout@cs.colostate.edu USC 227 Office hours: 3-4 Monday and Wednesday http://www.cs.colostate.edu/~cs553 CS553 Lecture 1 Introduction 3 Plan

More information

A Sparse Algorithm for Predicated Global Value Numbering

A Sparse Algorithm for Predicated Global Value Numbering Sparse Predicated Global Value Numbering A Sparse Algorithm for Predicated Global Value Numbering Karthik Gargi Hewlett-Packard India Software Operation PLDI 02 Monday 17 June 2002 1. Introduction 2. Brute

More information

Optimized Interval Splitting in a Linear Scan Register Allocator

Optimized Interval Splitting in a Linear Scan Register Allocator Optimized Interval Splitting in a Linear Scan Register Allocator ABSTRACT Christian Wimmer Institute for System Software Johannes Kepler University Linz Linz, Austria wimmer@ssw.jku.at We present an optimized

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

Advanced Programming & C++ Language

Advanced Programming & C++ Language Advanced Programming & C++ Language ~6~ Introduction to Memory Management Ariel University 2018 Dr. Miri (Kopel) Ben-Nissan Stack & Heap 2 The memory a program uses is typically divided into four different

More information

The VMKit project: Java (and.net) on top of LLVM

The VMKit project: Java (and.net) on top of LLVM The VMKit project: Java (and.net) on top of LLVM Nicolas Geoffray Université Pierre et Marie Curie, France nicolas.geoffray@lip6.fr What is VMKit? Glue between existing VM components LLVM, GNU Classpath,

More information