CS 598 Scripting Languages Design and Implementation 14. Self Compilers.

Slides:



Advertisements
Similar presentations
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Advertisements

Synopsys University Courseware Copyright © 2012 Synopsys, Inc. All rights reserved. Compiler Optimization and Code Generation Lecture - 3 Developed By:
Architecture-dependent optimizations Functional units, delay slots and dependency analysis.
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
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.
Chapter 10 Code Optimization. A main goal is to achieve a better performance Front End Code Gen Intermediate Code source Code target Code user Machine-
Lecture 10: Part 1: OO Issues CS 540 George Mason University.
Zhiguo Ge, Weng-Fai Wong, and Hock-Beng Lim Proceedings of the Design, Automation, and Test in Europe Conference, 2007 (DATE’07) April /4/17.
The Assembly Language Level
Dynamic Compilation in an OOL: The Deutsch-Schiffman Smalltalk-80 Implementation “Efficient Implementation of the Smalltalk-80 System” L. Peter Deutsch.
Overview Motivations Basic static and dynamic optimization methods ADAPT Dynamo.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
PART 4: (2/2) Central Processing Unit (CPU) Basics CHAPTER 13: REDUCED INSTRUCTION SET COMPUTERS (RISC) 1.
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
Trace-based Just-in-Time Type Specialization for Dynamic Languages Andreas Gal, Brendan Eich, Mike Shaver, David Anderson, David Mandelin, Mohammad R.
6/9/2015© Hal Perkins & UW CSEU-1 CSE P 501 – Compilers SSA Hal Perkins Winter 2008.
Aarhus University, 2005Esmertec AG1 Implementing Object-Oriented Virtual Machines Lars Bak & Kasper Lund Esmertec AG
Chapter XI Reduced Instruction Set Computing (RISC) CS 147 Li-Chuan Fang.
CS 536 Spring Intermediate Code. Local Optimizations. Lecture 22.
4/23/09Prof. Hilfinger CS 164 Lecture 261 IL for Arrays & Local Optimizations Lecture 26 (Adapted from notes by R. Bodik and G. Necula)
High-Level Programming Languages
Previous finals up on the web page use them as practice problems look at them early.
Scripting Languages For Virtual Worlds. Outline Necessary Features Classes, Prototypes, and Mixins Static vs. Dynamic Typing Concurrency Versioning Distribution.
Intermediate Code. Local Optimizations
Prof. Fateman CS164 Lecture 211 Local Optimizations Lecture 21.
Data Flow Analysis Compiler Design Nov. 8, 2005.
3-1 3 Compilers and interpreters  Compilers and other translators  Interpreters  Tombstone diagrams  Real vs virtual machines  Interpretive compilers.
Reduced Instruction Set Computers (RISC) Computer Organization and Architecture.
Computer Science 210 Computer Organization The Instruction Execution Cycle.
CS 355 – Programming Languages
Topic #10: Optimization EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
1 Software Development Topic 2 Software Development Languages and Environments.
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
Adapted from Prof. Necula UCB CS 1641 Overview of COOL ICOM 4029 Lecture 2 ICOM 4029 Fall 2008.
7. Just In Time Compilation Prof. O. Nierstrasz Jan Kurs.
CSC 310 – Imperative Programming Languages, Spring, 2009 Virtual Machines and Threaded Intermediate Code (instead of PR Chapter 5 on Target Machine Architecture)
Introduction to Java August 14, 2008 Mrs. C. Furman.
Intraprocedural Optimizations Jonathan Bachrach MIT AI Lab.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
CE Operating Systems Lecture 14 Memory management.
1 Code optimization “Code optimization refers to the techniques used by the compiler to improve the execution efficiency of the generated object code”
Cache Coherence Protocols 1 Cache Coherence Protocols in Shared Memory Multiprocessors Mehmet Şenvar.
Reducing Interprocess Communication Overhead in Concurrent Programs Erik Stenman Kostis Sagonas.
ECEG-3202 Computer Architecture and Organization Chapter 7 Reduced Instruction Set Computers.
Reduced Instruction Set Computers. Major Advances in Computers(1) The family concept —IBM System/ —DEC PDP-8 —Separates architecture from implementation.
12/9/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
Compiler Optimizations ECE 454 Computer Systems Programming Topics: The Role of the Compiler Common Compiler (Automatic) Code Optimizations Cristiana Amza.
CS 598 Scripting Languages Design and Implementation 13. The Deutsch-Schiffman Smalltalk- 80 Implementation.
OODL Runtime Optimizations Jonathan Bachrach MIT AI Lab Feb 2001.
Computer Organization Instructions Language of The Computer (MIPS) 2.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
CS412/413 Introduction to Compilers and Translators April 2, 1999 Lecture 24: Introduction to Optimization.
Michael J. Voss and Rudolf Eigenmann PPoPP, ‘01 (Presented by Kanad Sinha)
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Code Optimization.
5.2 Eleven Advanced Optimizations of Cache Performance
“Efficient Implementation of the Smalltalk-80 System”
Computer Science 210 Computer Organization
Design III Chapter 13 9/20/2018 Crowley OS Chap. 13.
Computer Science 210 Computer Organization
Dynamic Languages Hal Perkins Autumn 2009
Trace-based Just-in-Time Type Specialization for Dynamic Languages
Chapter 12 Pipelining and RISC
ICOM 4029 Fall 2003 Lecture 2 (Adapted from Prof. Necula UCB CS 164)
CSE P 501 – Compilers SSA Hal Perkins Autumn /31/2019
Procedure Linkages Standard procedure linkage Procedure has
CSc 453 Interpreters & Interpretation
Dynamic Binary Translators and Instrumenters
Presentation transcript:

CS 598 Scripting Languages Design and Implementation 14. Self Compilers

Self compilers We discuss three compilers described in the following documents: [ChUL89] Craig Chambers, David Ungar, Elgin Lee: An Efficient Implementation of SELF - a Dynamically-Typed Object-Oriented Language Based on Prototypes. OOPSLA 1989: [SELF-89] [ChUn90] Craig Chambers, David Ungar: Iterative Type Analysis and Extended Message Splitting: Optimizing Dynamically-Typed Object-Oriented Programs. PLDI 1990: [SELF-91] [Holz94] Urs Hölzle. Adaptive Optimization for SELF: Reconciling High Performance with Exploratory Programming. August [SELF-93]

First Self compiler

The compilation process All three compilers used Dynamic compilation: The compiler dynamically translates source methods on demand …”inspired by the Deutsch-Schiffman Smalltalk system”

The compiler Many potential inefficiencies shared with Smalltalk Cost of interpretation (fetch decode …) Dynamic dispatch This is particularly serious because of the many method invocations typical of OOLs Exacerbated in self where even variable accesses are implemented with messages Space inefficiencies of self due to absence of classes. It produces code that is 2 times faster than Smalltalk.

Maps From the implementation point of view, maps look much like classes, and achieve the same sorts of space savings for shared data. But maps are totally transparent at the SELF language level, simplifying the language and increasing expressive power by allowing objects to change their formats at will.

The parser Generates bytecode which contains 3 bits opcode and a 5-bit object array index (similar to the literal frame of Smalltalk) The 8 opcodes are to the right.

The parser (cont.)

Customized compilation A different compilation for each type of receiver of a method. For example, consider the method min: arg = ( < arg ifTrue: [self] False: [arg] ). If the expression i min: j is evaluated with i an integer, the compiler starts by building the flowgraph to the right. It then continues the compilation knowing that the receiver is an integer. The goal here is to optimize the < message. This is possible because inside the integer class, we know the type of self This technique is particularly useful in the case of instance variable accesses which are messages to self.

Message inlining If the type of the receiver is known at compile time, the compiler can perform the message lookup at compile-time and do one of the following: If the slot contains a method, the compiler will inline the body of the method at the call site, if the method is short enough and nonrecursive. If the slot contains a block value method, the compiler will inline the body of the block value method at the call site, if it is short enough. If after inlining there are no remaining uses of the block object, the compiler will eliminate the code to create the block at run-time. If the slot is a constant data slot, the compiler will replace the message send with the value of the slot (a constant known at compile-time). If the slot is an assignable data slot, the compiler will replace the message send with code to fetch the contents of the slot (e.g. a load instruction). If the slot is an assignment slot, the compiler will replace the message send with code to update the contents of the slot (e.g. a store instruction)

Message inlining (cont.) Consider the case of the < message < arg = ( _IntLTPrim: arg IfFail: [... ] ). Here, like in the case of all primitive implementations there is a failure block. Inlining will proceed as follows:

Primitive inlining Primitive invocations can be Inlined Executed at compile time for constant folding

Message splitting This strategy “a polymorphic message into several separate monomorphic messages. It avoids type tests by copying parts of the control flow graph” [Holz94]. Also useful for constant propagation.

Message Splitting

Type prediction Basically consist in introducing if statements testing type or value and the using message splitting for optimization.

Type prediction

Performance measurements Done on a Sun-4/260 (16.67 MHz Fujitsu processor). Compare to Smalltalk-80 system that incorporates the techniques described by Deutsch and Schiffman. Used the Stanford integer benchmarks, the Richards operating system simulation benchmarks, and these two codes:

SELF’ measures performance of rewritten benchmarks (those where the ration is within parenthesis were not rewritten)

SELF-91

Contributions Type inference Type information is used for message inlining Hence, type inference should help This includes an iterative procedure for loops. An initial assignment of types can lead to inlining. From the inlined version, new types are inferred. Repeat until convergence Extended splitting (see fig to the right)

Also on a Sun-4/260 (16.67 MHz Fujitsu processor) SELF-91/ C

Hölzle’s compiler (SELF-93)

Contributions Type Feedback, that allows any dynamically-dispatched call to be inlined. In our example implementation for SELF, type feedback reduces the call frequency by a factor of four and improves performance by 70% A recompilation system that dynamically reoptimizes the “hot spots” of an application. Polymorphic inline caching A debugging system that dynamically deoptimizes code to provide source-level debugging of globally optimized code.

Performance on Stanford Benchmarks Performance evaluation on “ a SPARC simulator based on the spa [76] and shade [34] tracing tools and the dinero cache simulator [66]. The simulator models the Cypress CY7C601 implementation of the SPARC architecture running at 40 MHz, i.e., the chip used in the SPARCstation-2 (SS-2) workstation.”

Performance on large benchmarks