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.

Slides:



Advertisements
Similar presentations
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
Advertisements

U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Potential Languages of the Future Chapel,
UNIT-III By Mr. M. V. Nikum (B.E.I.T). Programming Language Lexical and Syntactic features of a programming Language are specified by its grammar Language:-
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Mitigating the Compiler Optimization Phase- Ordering Problem using Machine Learning.
Lecture 01 - Introduction Eran Yahav 1. 2 Who? Eran Yahav Taub 734 Tel: Monday 13:30-14:30
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
From Cooper & Torczon1 Implications Must recognize legal (and illegal) programs Must generate correct code Must manage storage of all variables (and code)
Compiler Construction
Compiler Construction1 A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University First Semester 2009/2010.
Wrapping Up Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
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.
Introduction & Overview CS4533 from Cooper & Torczon.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Topic #10: Optimization EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
COP4020 Programming Languages
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2011 Course Overview John Cavazos University.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
CSC 338: Compiler design and implementation
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
Java Virtual Machine Case Study on the Design of JikesRVM.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Register Allocation John Cavazos University.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
May 31, May 31, 2016May 31, 2016May 31, 2016 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University Azusa Pacific University,
Research Topics CSC Parallel Computing & Compilers CSC 3990.
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2011 Dependence Analysis and Loop Transformations.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Static Single Assignment John Cavazos.
CS 671 Compilers Prof. Kim Hazelwood Spring 2008.
Compiler design Lecture 1: Compiler Overview Sulaimany University 2 Oct
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Compilers: Overview/1 1 Compiler Structures Objective – –what are the main features (structures) in a compiler? , Semester 1,
Introduction CPSC 388 Ellen Walker Hiram College.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Dynamic Compilation I John Cavazos University.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Chapter# 6 Code generation.  The final phase in our compiler model is the code generator.  It takes as input the intermediate representation(IR) produced.
Chapter 1: Introduction 1 Compiler Designs and Constructions Chapter 1: Introduction Objectives: Course Objectives Introduction Dr. Mohsen Chitsaz.
Compiler Optimizations ECE 454 Computer Systems Programming Topics: The Role of the Compiler Common Compiler (Automatic) Code Optimizations Cristiana Amza.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Intelligent Compilation John Cavazos Computer & Information Sciences Department.
What is a compiler? –A program that reads a program written in one language (source language) and translates it into an equivalent program in another language.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
CS412/413 Introduction to Compilers and Translators April 2, 1999 Lecture 24: Introduction to Optimization.
1 Compiler Construction Vana Doufexi office CS dept.
Objective of the course Understanding the fundamentals of the compilation technique Assist you in writing you own compiler (or any part of compiler)
©SoftMoore ConsultingSlide 1 Code Optimization. ©SoftMoore ConsultingSlide 2 Code Optimization Code generation techniques and transformations that result.
CHAPTER 1 INTRODUCTION TO COMPILER SUNG-DONG KIM, DEPT. OF COMPUTER ENGINEERING, HANSUNG UNIVERSITY.
Advanced Computer Systems
Compiler Design (40-414) Main Text Book:
Chapter 1 Introduction.
Introduction to Advanced Topics Chapter 1 Text Book: Advanced compiler Design implementation By Steven S Muchnick (Elsevier)
SOFTWARE DESIGN AND ARCHITECTURE
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
Optimization Code Optimization ©SoftMoore Consulting.
Compiler Lecture 1 CS510.
Compiler Construction
Wrapping Up Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit.
8 Code Generation Topics A simple code generator algorithm
Chapter 10: Compilers and Language Translation
Compiler Construction
Compiler Structures 1. Overview Objective
Optimizing Compilers CISC 673 Spring 2009 Course Overview
Presentation transcript:

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 Cavazos University of Delaware

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 2 Compiler Overview Lexical analyzer Syntax analyzer Semantic analyzer Code optimizer Code generator Source program Target program Error handlerSymbol-table

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 3 Compiler Frontend Lexical Analyzer Parser Semantic Analyzer Source Program Token Stream Syntax Tree Intermediate Rep Gen IR Series of passes Source program – Written in a HLL Lexical analysis – Convert keywords into “tokens” Parser – Forms a syntax “tree” (statements, expressions, etc.) Semantic analysis – Type checking, etc. We will not cover the front end in this class! (See CISC 672)

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 4 Compiler Middleend and Backend Code Optimizer Code Generator IR Target program This is where the “interesting” stuff happens … enough to fill an entire grad-level course Code optimization – “improves” the intermediate code  Consists of machine independent & dependent opts Code generation – register allocation, instruction scheduling

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 5 Traditional Optimizations Analyze the program  Where is this value used?  Is this value recomputed? Reduce the total number of operations  Common subexpression elimination  Strength reduction Maintain values in registers  Elimination of redundant loads

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 6 Developing an Optimization FormulateImplementEvaluate Refine Formulate the problem based on:  Intuition  Extract properties from a program Implement the algorithm Evaluate results based on test programs Use results to refine the algorithm

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 7 Building an Optimizing Compiler Strict requirements Must be correct for all possible inputs Must provide robust solution  Small changes in input should not produce wild changes in output Good optimizing compilers are crafted Careful selection of transformations Careful use of algorithms and data structures

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 8 Building an Optimizing Compiler Compilers are engineered objects Try to minimize running time of compiled code Try to minimize compile time Try to limit use of compile-time space Try to keep engineering efforts reasonable With all these constraints, results are … unexpected!

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 9 Quick Look at Real Compilers Consider inline substitution Replace procedure call with body of called procedure  Rename to handle naming issues  Widely used (and important!) for optimizing OOPs

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 10 Characteristics of Function Inlining Safety: almost always safe Profitability: avoid overhead of a procedure call Opportunity: inline leaf procedures How well do compilers handle inlined code?

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 11 5 Real Good Compilers Source Program Compiler InlinerCompiler Execute & time Experimental Setup Execute & time

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 12 The Study Cooper/Hall/Torczon (Software-Practice & Experience 91) Eight programs, five compilers, five processors Eliminated over 99% of dynamic calls in 5 of programs Measured speed of original versus transformed code Expected uniform speed up, at least from call overhead What really happened?

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 13 Change in Execution Time

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 14 Happens with Good Compilers! Input code violated assumptions made by compiler writers  Longer procedures  More names  Different code shapes Exacerbated problems that are hard to detect!  Imprecise analysis  Algorithms that scale poorly  Tradeoffs between global and local speed  Limitations in the implementations The compiler writers were surprised (most of them)

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 15 JikesRVM Translation From Bytecode to HIR Optimization of HIR HIR Jikes Front End Translation From HIR to LIR Optimization of LIR Translation From LIR To MIR Optimization of MIR Final Assembly Jikes Back End LIR MIR Optimized HIR Optimized LIR Optimized MIR Binary Code

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 16 Levels of IR HIR (High Level IR) LIR (Low Level IR) MIR (Machine Specific IR)

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 17 HIR Operators similar to Java bytecode Example: ARRAYLENGTH, NEW, GETFIELD, BOUNDS_CHECK, NULL_CHECK Symbolic registers instead of an implicit stack Contains separate operators to implement explicit checks for run-time exceptions (eg., array-bounds checks)

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 18 LIR Details of JikesRVM runtime and object layout Example: GET_TIB (vtable), INT_LOAD (for getfield) Expands complicated HIR structures such as TABLE_SWITCH

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 19 MIR Similar to assembly code Details of target architecture are introduced Register Allocation is performed on MIR

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 20 A Tour of the JikesRVM codebase

U NIVERSITY OF D ELAWARE Computer & Information Sciences Department 21 Next Time Read the following Wikipedia pages (section) Graph Theory (Basics) Basic Blocks Control Flow Graphs