Trace-based Just-in-Time Type Specialization for Dynamic Languages Andreas Gal, Brendan Eich, Mike Shaver, David Anderson, David Mandelin, Mohammad R.

Slides:



Advertisements
Similar presentations
Intermediate Representations CS 671 February 12, 2008.
Advertisements

Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
P3 / 2004 Register Allocation. Kostis Sagonas 2 Spring 2004 Outline What is register allocation Webs Interference Graphs Graph coloring Spilling Live-Range.
7. Optimization Prof. O. Nierstrasz Lecture notes by Marcus Denker.
The Case for a SC-preserving Compiler Madan Musuvathi Microsoft Research Dan Marino Todd Millstein UCLA University of Michigan Abhay Singh Satish Narayanasamy.
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
1 Chapter 8: Code Generation. 2 Generating Instructions from Three-address Code Example: D = (A*B)+C =* A B T1 =+ T1 C T2 = T2 D.
8. Code Generation. Generate executable code for a target machine that is a faithful representation of the semantics of the source code Depends not only.
Control-Flow Graphs & Dataflow Analysis CS153: Compilers Greg Morrisett.
CSI 3120, Implementing subprograms, page 1 Implementing subprograms The environment in block-structured languages The structure of the activation stack.
Control Structures Any mechanism that departs from straight-line execution: –Selection: if-statements –Multiway-selection: case statements –Unbounded iteration:
1 Code Optimization Code produced by compilation algorithms can often be improved (ideally optimized) in terms of run-time speed and the amount of memory.
Overview Motivations Basic static and dynamic optimization methods ADAPT Dynamo.
1 S. Tallam, R. Gupta, and X. Zhang PACT 2005 Extended Whole Program Paths Sriraman Tallam Rajiv Gupta Xiangyu Zhang University of Arizona.
From AST to Code Generation Professor Yihjia Tsai Tamkang University.
Cpeg421-08S/final-review1 Course Review Tom St. John.
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
9. Optimization Marcus Denker. 2 © Marcus Denker Optimization Roadmap  Introduction  Optimizations in the Back-end  The Optimizer  SSA Optimizations.
Towards eliminating runtime array bound checks in the Java Virtual Machine Hongwei Songtao
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
Program Design and Development
4/25/08Prof. Hilfinger CS164 Lecture 371 Global Optimization Lecture 37 (From notes by R. Bodik & G. Necula)
Code Generation for Basic Blocks Introduction Mooly Sagiv html:// Chapter
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
Michael Ernst, page 1 Improving Test Suites via Operational Abstraction Michael Ernst MIT Lab for Computer Science Joint.
Machine-Independent Optimizations Ⅰ CS308 Compiler Theory1.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Eran Yahav Technion Recent Developments in the Real World 1.
Query Processing Presented by Aung S. Win.
Chapter 7: Runtime Environment –Run time memory organization. We need to use memory to store: –code –static data (global variables) –dynamic data objects.
Introduction For some compiler, the intermediate code is a pseudo code of a virtual machine. Interpreter of the virtual machine is invoked to execute the.
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
O VERVIEW OF THE IBM J AVA J UST - IN -T IME C OMPILER Presenters: Zhenhua Liu, Sanjeev Singh 1.
1 Introduction to JVM Based on material produced by Bill Venners.
1 Advance Computer Architecture CSE 8383 Ranya Alawadhi.
Compiler Chapter# 5 Intermediate code generation.
Buffered dynamic run-time profiling of arbitrary data for Virtual Machines which employ interpreter and Just-In-Time (JIT) compiler Compiler workshop ’08.
Tracing and a Javascript VM Increasing the Performance of Web 3.0 Mohammad Soryani Mazandaran University of Science and Technology
Predicated Static Single Assignment (PSSA) Presented by AbdulAziz Al-Shammari
Optimization in XSLT and XQuery Michael Kay. 2 Challenges XSLT/XQuery are high-level declarative languages: performance depends on good optimization Performance.
1 Code optimization “Code optimization refers to the techniques used by the compiler to improve the execution efficiency of the generated object code”
Online partial evaluation of bytecodes (3)
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
Dynamo: A Transparent Dynamic Optimization System Bala, Dueterwald, and Banerjia projects/Dynamo.
Virtual Machines, Interpretation Techniques, and Just-In-Time Compilers Kostis Sagonas
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Overview of Compilers and JikesRVM John.
CS536 Semantic Analysis Introduction with Emphasis on Name Analysis 1.
CS 598 Scripting Languages Design and Implementation 14. Self Compilers.
Compiler Optimizations ECE 454 Computer Systems Programming Topics: The Role of the Compiler Common Compiler (Automatic) Code Optimizations Cristiana Amza.
1 Compiler & its Phases Krishan Kumar Asstt. Prof. (CSE) BPRCE, Gohana.
CS412/413 Introduction to Compilers Radu Rugina Lecture 18: Control Flow Graphs 29 Feb 02.
1 Control Flow Graphs. 2 Optimizations Code transformations to improve program –Mainly: improve execution time –Also: reduce program size Can be done.
Dynamic Parallelization of JavaScript Applications Using an Ultra-lightweight Speculation Mechanism ECE 751, Fall 2015 Peng Liu 1.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
CS412/413 Introduction to Compilers and Translators April 2, 1999 Lecture 24: Introduction to Optimization.
Code Optimization Code produced by compilation algorithms can often be improved (ideally optimized) in terms of run-time speed and the amount of memory.
Code Optimization Overview and Examples
Introduction to Web Assembly
WHAT DO COMPILATION STRATEGIES HAVE TO DO WITH WEB CONTENT DELIVERY?
Eugene Gavrin – MSc student
Code Generation Part III
Code Optimization Overview and Examples Control Flow Graph
Code Generation Part III
Trace-based Just-in-Time Type Specialization for Dynamic Languages
UNIT V Run Time Environments.
A programming language
Optimization 薛智文 (textbook ch# 9) 薛智文 96 Spring.
C. M. Overstreet Old Dominion University Fall 2005
Dynamic Binary Translators and Instrumenters
Presentation transcript:

Trace-based Just-in-Time Type Specialization for Dynamic Languages Andreas Gal, Brendan Eich, Mike Shaver, David Anderson, David Mandelin, Mohammad R. Haghighat, Blake Kaplan, Graydon Hoare, Boris Zbarsky, Jason Orendorff, Jesse Ruderman, Edwin Smith, Rick Reitmaier, Michael Bebenita, Mason Chang, Michael Franz

2 Dynamic Languages  JavaScript, Python, and Ruby  They are expressive, accessible to non-experts, and make deployment as easy as distributing a source file  JavaScript is the de facto standard for client-side web programming and is used for the application logic of browser-based productivity applications  Dynamically-typed (most of them, not all) -The types of expressions may vary during runtime -Traditional static analysis is too expensive

Solution: Trace-based Jit Compiler  Jit Compiler: a hybrid approach that combines interpreter and static compiler  Trace-based compilation - trace: an acyclic path through CFG - schedule traces as if they were basic blocks - need compensation code for off-trace path  TraceMonkey: starts running JavaScript in a fast-starting bytecode interpreter, and detects hot bytecode sequences (trace) as the program runs, recording and compiling them into native code.  Two assumptions - programs spend most of their time in hot loops - code in hot loops are type-stable

Outline  Algorithm for dynamically forming trace trees to cover a program, representing nested loops as nested trace trees  How to speculatively generate efficient type- specialized code for traces from dynamic language programs  Implementation based on the SpiderMonkey JavaScript interpreter

5 Typed Trace  A typed trace is a trace annotated with a type for every variable (including temporaries) on the trace. (type-stable)  Guard instructions to guarantee assumptions, side exit the trace if guards fail  Optimizations achieved: - type specialization - representation specialization: objects, numbers - function inlining  Abort a trace - unpredictable exits - limited memory

Trace Tree  An extension of typed trace with branch traces  A tree always starts at a loop header  A tree closes the loop: - at loop header as it started (type-stable) - at a side exit (type-unstable) - at break or return statements (end trace and exit to the trace monitor)  Extend a tree with branch starting at side exits (only control-flow branches)  Blacklist: avoid checking failed traces again and again

Trace Tree Cont.  Unsolved problem if a loop meets the following conditions - The VM can form at least one root trace for the loop - There is at least one hot side exit for which the VM cannot complete a trace - The loop body is short Then the overhead exceeds the optimization

Nested Trace Tree Formation 1 for (var i = 2; i < 100; ++i) { 2 if (!primes[i]) 3 continue; 4 for (var k = i + i; k < 100; k += i) 5 primes[k] = true; 6 }

Trace Tree Optimization  Front-end filters - a soft-float filter converts floating-point LIR instructions to sequences of integer instructions - CSE (constant sub-expression elimination) - expression simplification: constant folding.. - source language semantic-specific expression simplification  Back-end filters - Dead data-stack store elimination - Dead call-stack store elimination - Dead code elimination

Implementation  Calling Compiled Traces  Trace Stitching  Trace Recording  Preemption  Calling External Functions

Evaluation

Evaluation cont. Outperform the fastest available JavaScript compiler (V8) and the fastest available JavaScript inline threaded interpreter (SFX) on 9 of 26 benchmarks

Related Work  Trace optimization for dynamic languages  General trace optimization  Type specialization for dynamic languages  Native code generation by interpreters