Eran Yahav Technion Recent Developments in the Real World 1.

Slides:



Advertisements
Similar presentations
Case Study: A Recursive Descent Interpreter Implementation in C++ (Source Code Courtesy of Dr. Adam Drozdek) Payap University ICS220 - Data Structures.
Advertisements

CPSC 388 – Compiler Design and Construction
Chapter 1: Computer Systems
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Trace-based Just-in-Time Type Specialization for Dynamic Languages Andreas Gal, Brendan Eich, Mike Shaver, David Anderson, David Mandelin, Mohammad R.
Lecture 01 - Introduction Eran Yahav 1. 2 Who? Eran Yahav Taub 734 Tel: Monday 13:30-14:30
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
Lecture 17 – Dataflow Analysis (and more!) Eran Yahav 1 Reference: Dragon 9, 12.
The Java Programming Language
Outline Java program structure Basic program elements
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
Building An Interpreter After having done all of the analysis, it’s possible to run the program directly rather than compile it … and it may be worth it.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
CPSC 388 – Compiler Design and Construction Lecture: MWF 11:00am-12:20pm, Room 106 Colton.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
COP4020 Programming Languages
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
Create your own language DESIGN -> PARSE -> INTERPRET.
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Lecture 10 : Introduction to Java Virtual Machine
Java Programming Introduction & Concepts. Introduction to Java Developed at Sun Microsystems by James Gosling in 1991 Object Oriented Free Compiled and.
Flex 2.0 Flex for ColdFusion developers Part 1. What is Flex Flex allows developers to create Flash content for Rich Internet Applications in a more programmer.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
1 Introduction to JVM Based on material produced by Bill Venners.
Lecture :2 1.  DEFENTION : Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Virtual Machines, Interpretation Techniques, and Just-In-Time Compilers Kostis Sagonas
CPS 506 Comparative Programming Languages Syntax Specification.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Programming Languages
Runtime System CS 153: Compilers. Runtime System Runtime system: all the stuff that the language implicitly assumes and that is not described in the program.
1 The JAVA Language Object Oriented Technology Mithani Binjan M.
Lecture 13 – Dataflow Analysis (and more!) Eran Yahav 1 Reference: Dragon 9, 12.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
Unit-IV - Flash Player - Flex framework - MXML introduction - Action script introduction - Working with Action script - Flex data binding - Common UI components.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
Language Implementation Overview John Keyser Spring 2016.
The Ins and Outs of Gradual Type Inference Avik Chaudhuri Basil Hosmer Adobe Systems Aseem Rastogi Stony Brook University.
COP4020 Programming Languages Introduction Prof. Robert van Engelen (modified by Prof. Em. Chris Lacher)
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
Dr. Hussien Sharaf Dr Emad Nabil. Dr. Hussien M. Sharaf 2 position := initial + rate * Lexical analyzer 2. Syntax analyzer id 1 := id 2 + id 3 *
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
Dart Omar Ansari, Kenneth Jones, Isaac Wilder. 1. Overview l Object Oriented Language l Developed By Google l Primarily used for building websites, servers,
ActionScript Programming Help
JAVA MULTIPLE CHOICE QUESTION.
Introduction to Web Assembly
Types for Programs and Proofs
PROGRAMMING LANGUAGES
CS 536 / Fall 2017 Introduction to programming languages and compilers
JavaScript an introduction.
Chapter 10 Programming Fundamentals with JavaScript
Conditional Statements
CSE401 Introduction to Compiler Construction
COP4020 Programming Languages
Introducing Java.
Programming language translators
IS 135 Business Programming
Presentation transcript:

Eran Yahav Technion Recent Developments in the Real World 1

Meanwhile, In the real world new hardware – Multi-core, GPU, Accelerators new compilers for new languages new compilers for old languages – e.g., Java->JavaScript new uses of compiler technology new performance criteria 2

Google Web Toolkit 3 Javascript code js Java code txt Semantic Representation Backend (synthesis) Compiler Frontend (analysis)

GWT Compiler Optimization public class ShapeExample implements EntryPoint { private static final double SIDE_LEN_SMALL = 2; private final Shape shape = new SmallSquare(); public static abstract class Shape { public abstract double getArea(); } public static abstract class Square extends Shape { public double getArea() { return getSideLength() * getSideLength(); } public abstract double getSideLength(); } public static class SmallSquare extends Square { public double getSideLength() { return SIDE_LEN_SMALL; } } public void onModuleLoad() { Shape shape = getShape(); Window.alert("Area is " + shape.getArea()); } private Shape getShape() { return shape; } 4 (source:

GWT Compiler Optimization public class ShapeExample implements EntryPoint { public void onModuleLoad() { Window.alert("Area is 4.0"); } 5 (source:

Adobe ActionScript First introduced in Flash Player 9, ActionScript 3 is an object-oriented programming (OOP) language based on ECMAScript—the same standard that is the basis for JavaScript—and provides incredible gains in runtime performance and developer productivity. ActionScript 2, the version of ActionScript used in Flash Player 8 and earlier, continues to be supported in Flash Player 9 and Flash Player ActionScript 3.0 introduces a new highly optimized ActionScript Virtual Machine, AVM2, which dramatically exceeds the performance possible with AVM1. As a result, ActionScript 3.0 code executes up to 10 times faster than legacy ActionScript code. (source:

Adobe ActionScript 7 AVM bytecode swf AS code txt Semantic Representation Backend (synthesis) Compiler Frontend (analysis)

Adobe ActionScript: Tamarin 8 The goal of the "Tamarin" project is to implement a high-performance, open source implementation of the ActionScript™ 3 language, which is based upon and extends ECMAScript 3rd edition (ES3). ActionScript provides many extensions to the ECMAScript language, including packages, namespaces, classes, and optional strict typing of variables. "Tamarin" implements both a high-performance just-in-time compiler and interpreter. The Tamarin virtual machine is used within the Adobe® Flash® Player and is also being adopted for use by projects outside Adobe. The Tamarin just-in- time compiler (the "NanoJIT") is a collaboratively developed component used by both Tamarin and Mozilla TraceMonkey. The ActionScript compiler is available as a component from the open source Flex SDK.Flex SDK

Mozilla SpiderMonkey SpiderMonkey is a fast interpreter runs an untyped bytecode and operates on values of type jsval— type-tagged double-sized values that represent the full range of JavaScript values.jsvaldouble-sized SpiderMonkey contains two JavaScript Just-In-Time (JIT) compilers, a garbage collector, code implementing the basic behavior of JavaScript values… SpiderMonkey's interpreter is mainly a single, tremendously long function that steps through the bytecode one instruction at a time, using a switch statement (or faster alternative, depending on the compiler) to jump to the appropriate chunk of code for the current instruction. 9 (source:

Mozilla SpiderMonkey: Compiler consumes JavaScript source code produces a script which contains bytecode, source annotations, and a pool of string, number, and identifier literals. The script also contains objects, including any functions defined in the source code, each of which has its own, nested script. The compiler consists of – a random-logic rather than table-driven lexical scanner – a recursive-descent parser that produces an AST – a tree-walking code generator The emitter does some constant folding and a few codegen optimizations 10 (source:

Mozilla SpiderMonkey SpiderMonkey contains a just-in-time trace compiler that converts bytecode to machine code for faster execution. The JIT works by detecting commonly executed loops, tracing the executed bytecodes in those loops as they run in the interpreter, and then compiling the trace to machine code. See the page about the Tracing JIT for more details.Tracing JIT The SpiderMonkey GC is a mark-and-sweep, non- conservative (exact) collector. 11 (source:

Mozilla TraceMonkey 12 (source:

Mozilla TraceMonkey Goal: generate type-specialized code Challenges – no type declarations – statically trying to determine types mostly hopeless Idea – run the program for a while and observe types – use observed types to generate type-specialized code – compile traces Sounds suspicious? 13

Mozilla TraceMonkey Problem 1: “observing types” + compiling possibly more expensive than running the code in the interpreter Solution: only compile code that executes many times – “hot code” = loops – initially everything runs in the interpreter – start tracing a loop once it becomes “hot” 14

Mozilla TraceMonkey Problem 2: past types do not guarantee future types… what happens if types change? Solution: insert type-checks into the compiled code – if type-check fails, need to recompile for new types – code with frequent type changes will suffer some slowdown 15

Mozilla TraceMonkey 16 function addTo(a, n) { for (var i = 0; i < n; ++i) a = a + i; return a; } var t0 = new Date(); var n = addTo(0, ); print(n); print(new Date() - t0); a = a + i; // a is an integer number (0 before, 1 after) ++i; // i is an integer number (1 before, 2 after) if (!(i < n)) // n is an integer number ( ) break; trace_1_start: ++i; // i is an integer number (0 before, 1 after) temp = a + i; // a is an integer number (1 before, 2 after) if (lastOperationOverflowed()) exit_trace(OVERFLOWED); a = temp; if (!(i < n)) // n is an integer number ( ) exit_trace(BRANCHED); goto trace_1_start;

Mozilla TraceMonkey 17 SystemRun Time (ms) SpiderMonkey (FF3)990 TraceMonkey (FF3.5)45 Java (using int)25 Java (using double)74 C (using int)5 C (using double)15

Static Analysis Tools Coverity SLAM ASTREE … 18

19

20

Lots and lots of research Program Analysis Program Synthesis … 21