Trustworthy Compilers

Similar documents
Trustworthy Compilers

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

List of Figures. About the Authors. Acknowledgments

A simple syntax-directed

Roll No. :... Invigilator's Signature :. CS/B.Tech(CSE)/SEM-7/CS-701/ LANGUAGE PROCESSOR. Time Allotted : 3 Hours Full Marks : 70

Compiler Construction Using

EDAN65: Compilers, Lecture 06 A LR parsing. Görel Hedin Revised:

A programming language requires two major definitions A simple one pass compiler

Grammars and Parsing, second week

Structure of a compiler. More detailed overview of compiler front end. Today we ll take a quick look at typical parts of a compiler.

What do Compilers Produce?

Undergraduate Compilers in a Day

SYLLABUS UNIT - I UNIT - II UNIT - III UNIT - IV CHAPTER - 1 : INTRODUCTION CHAPTER - 4 : SYNTAX AX-DIRECTED TRANSLATION TION CHAPTER - 7 : STORA

Syntax Analysis. Chapter 4

COMPILER CONSTRUCTION LAB 2 THE SYMBOL TABLE. Tutorial 2 LABS. PHASES OF A COMPILER Source Program. Lab 2 Symbol table

1. Explain the input buffer scheme for scanning the source program. How the use of sentinels can improve its performance? Describe in detail.

LECTURE NOTES ON COMPILER DESIGN P a g e 2

SYSTEMS PROGRAMMING. Srimanta Pal. Associate Professor Indian Statistical Institute Kolkata OXFORD UNIVERSITY PRESS

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

CJT^jL rafting Cm ompiler

Group B Assignment 9. Code generation using DAG. Title of Assignment: Problem Definition: Code generation using DAG / labeled tree.

10/4/18. Lexical and Syntactic Analysis. Lexical and Syntax Analysis. Tokenizing Source. Scanner. Reasons to Separate Lexical and Syntactic Analysis

CS606- compiler instruction Solved MCQS From Midterm Papers

COMP 181. Prelude. Prelude. Summary of parsing. A Hierarchy of Grammar Classes. More power? Syntax-directed translation. Analysis

Chapter 4 - Semantic Analysis. June 2, 2015

10/5/17. Lexical and Syntactic Analysis. Lexical and Syntax Analysis. Tokenizing Source. Scanner. Reasons to Separate Lexical and Syntax Analysis

Compilers and Interpreters

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Subject Name: CS2352 Principles of Compiler Design Year/Sem : III/VI

What is a compiler? Xiaokang Qiu Purdue University. August 21, 2017 ECE 573

Yacc: A Syntactic Analysers Generator

Parser. Larissa von Witte. 11. Januar Institut für Softwaretechnik und Programmiersprachen. L. v. Witte 11. Januar /23

CPS 506 Comparative Programming Languages. Syntax Specification

Compiling Regular Expressions COMP360

2068 (I) Attempt all questions.

Chapter 4. Lexical and Syntax Analysis

Building Compilers with Phoenix

Introduction to Compiler Design

JavaCC Parser. The Compilation Task. Automated? JavaCC Parser

Review of CFGs and Parsing II Bottom-up Parsers. Lecture 5. Review slides 1

VALLIAMMAI ENGINEERING COLLEGE

CS 406/534 Compiler Construction Putting It All Together

What is a compiler? var a var b mov 3 a mov 4 r1 cmpi a r1 jge l_e mov 2 b jmp l_d l_e: mov 3 b l_d: ;done

Crafting a Compiler with C (II) Compiler V. S. Interpreter

1. The output of lexical analyser is a) A set of RE b) Syntax Tree c) Set of Tokens d) String Character

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

Compiler Design Overview. Compiler Design 1

COP 3402 Systems Software. Lecture 4: Compilers. Interpreters

Introduction to Syntax Analysis. Compiler Design Syntax Analysis s.l. dr. ing. Ciprian-Bogdan Chirila

Syntax. A. Bellaachia Page: 1

CST-402(T): Language Processors

Compiler Design Aug 1996

Alternatives for semantic processing

Formats of Translated Programs

Compiler Design (40-414)

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

Final Term Papers 2013

Recursive Descent Parsers

Lexical and Syntax Analysis

Name of chapter & details

Chapter 4. Abstract Syntax

Context-Free Grammar. Concepts Introduced in Chapter 2. Parse Trees. Example Grammar and Derivation

Using an LALR(1) Parser Generator

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation

Theoretical Part. Chapter one:- - What are the Phases of compiler? Answer:

QUESTIONS RELATED TO UNIT I, II And III

Object-oriented Compiler Construction

When do We Run a Compiler?

Quick Parser Development Using Modified Compilers and Generated Syntax Rules

EDAN65: Compilers, Lecture 04 Grammar transformations: Eliminating ambiguities, adapting to LL parsing. Görel Hedin Revised:

Automated Tools. The Compilation Task. Automated? Automated? Easier ways to create parsers. The final stages of compilation are language dependant

COMPILER CONSTRUCTION Seminar 02 TDDB44

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division

SYED AMMAL ENGINEERING COLLEGE (An ISO 9001:2008 Certified Institution) Dr. E.M. Abdullah Campus, Ramanathapuram

Compilers and Code Optimization EDOARDO FUSELLA

COMPILER DESIGN LECTURE NOTES

Grammars and Parsing. Paul Klint. Grammars and Parsing

Compiler Design. Computer Science & Information Technology (CS) Rank under AIR 100

CSC488S/CSC2107S - Compilers and Interpreters. CSC 488S/CSC 2107S Lecture Notes

Compiling Techniques

Syntax-Directed Translation. Lecture 14

Pioneering Compiler Design

SLIDE 2. At the beginning of the lecture, we answer question: On what platform the system will work when discussing this subject?

Appendix A The DL Language

Better Extensibility through Modular Syntax. Robert Grimm New York University

Compiler Construction

Examples of attributes: values of evaluated subtrees, type information, source file coordinates,


About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

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

Academic Formalities. CS Modern Compilers: Theory and Practise. Images of the day. What, When and Why of Compilers

Eclipse Support for Using Eli and Teaching Programming Languages

CS/SE 153 Concepts of Compiler Design

CSCI 1260: Compilers and Program Analysis Steven Reiss Fall Lecture 4: Syntax Analysis I

COP 3402 Systems Software Syntax Analysis (Parser)

CS Compiler Construction West Virginia fall semester 2014 August 18, 2014 syllabus 1.0

Performance Evaluation of Annotation Based Innovative Parser Generator

Evaluation Scheme L T P Total Credit Theory Mid Sem Exam

LECTURE 3. Compiler Phases

Building Compilers with Phoenix

Syntax-Directed Translation Part I

Transcription:

Trustworthy Compilers Vladimir O. Safonov St. Petersburg University )WILEY A John Wiley &> Sons, Inc., Pablication

Contents Preface Acknowledgments xüi xix 1. Introduction 1 1.1. The Concept of a Trustworthy Compiler / 2 1.2. Kinds of Compilers / 4 1.3. Evolution of Java Compilers / 5 1.4. Compilation for.net / 6 1.5. Phases of Compilation / 7 1.6. Overview of Compiler Development Principles and Technologies / 8 1.7. History of Compiler Development in the U.S.S.R. and in Russia / 13 Exercises to Chapter 1/15 2. Theoretical Foundations and Principles of Trustworthy Compilers 16 2.1. The Trustworthy Computing (TWC) Initiative / 16 2.2. TWC and Trustworthy Compilers / 17 2.3. Verified Compilers / 24 2.4. Spec#: Microsoft's Approach to Verifying Compilers / 26 2.5. Perspectives of Verified and Verifying Compilation / 28 Exercises to Chapter 2/29 vii

ViU CONTENTS 3. Lexical Analysis and Its Trustworthiness Principles 3.1. Token Classes / 31 3.2. The Output of the Lexical Analyzer / 33 3.3. Processing White Spaces, Comments, and New Lines / 34 3.4. Theoretical Models of Lexical Analysis / 35 3.5. Lexical Errors, Error Diagnostics, and Recovery / 38 3.6. Processing Identifiers and Keywords / 38 3.7. The Architecture of a Lexical Analyzer and the Principles of Its Implementation / 42 3.8. The Lexical Analyzer Generator Lex I 45 3.9. Lexical Analyzer Generation in ANTLR / 48 Exercises to Chapter 3/51 4. Parsing and Trustworthy Methods of Syntax Error Recovery 4.1. Basic Concepts and Principles of Parsing / 53 4.2. Recursive Descent and Simple Lookahead Mechanism / 55 4.3. Overview of Error Recovery in Parsing: Error Recovery for Recursive Descent / 62 4.4. LR(1) and LALR(l) Parsing / 67 4.5. Error Recovery in LR Parsing / 81 4.6. The Yacc Parser Generator / 82 4.7. The Bison Parser Generator: Generalized LR Parsing / 87 4.8. The Yacc++, JavaCC, SableCC, ANTLR, and CoCo/R Object-Oriented Parser Generators / 89 Exercises to Chapter 4/95 5. Semantic Analysis and Typing: Efficient and Trustworthy Techniques 5.1. Basic Concepts and Principles of Semantic Analysis / 97 5.2. Formal Model of Semantic Analysis: Attributed Grammars / 99 5.3. Definition Systems with Forward References and the Algorithm of Their One-Pass Analysis / 103 5.4. Commonly Used Semantic Attributes for Program Constructs / 107 5.5. Design Flaws of the Semantic Attribute Evaluation and Our Efficient Methods to Speed It Up / 111 5.6. Lookup Traditional and Novel Techniques / 114 5.7. Typing and Type-Checking: Basic Concepts / 118

CONTENTS IX 5.8. Representing Types at Compile Time / 121 5.9. Efficient Method and Algorithm to Represent and Handle Types with Structural Identity / 123 5.10. Type Identity and Type Compatibility / 126 5.11. Type-Checking, Typing Error Diagnostics, and Recovery / 128 5.12. Code Trustworthiness Checks During Semantic Analysis / 131 5.13. Checks for Context Restrictions in Semantic Analysis / 139 5.14. Intermediate Code Generation Principles and Architectural Models / 141 5.15. Postfix (Reverse Polish) Notation / 142 5.16. PCC Trees / 146 5.17. Triples / 149 5.18. Summary of the Chapter / 150 Exercises to Chapter 5 / 151 6. Trustworthy Optimizations 152 6.1. Basic Concepts and Trustworthiness of Optimizations / 152 6.2. Optimizations as Mixed Computations / 154 6.3. Overview of the Most Common Kinds of Optimizations / 155 6.4. Control Flow and Data Flow Dependencies / 162 6.5. Static Single Assignment (SSA) / 163 6.6. Data Structures Constructed and Used by the Optimizer / 165 6.7. Optimization in Sun Studio Compilers / 165 6.8. Optimizations of the Java Bytecode / 167 6.9. Optimizations of the.net Common Intermediate Language (CIL) Code / 170 6.10. Optimizations during JIT Compilation / 170 Exercises to Chapter 6 / 173 7. Code Generation and Runtime Data Representation 174 7.1. Target Platforms for Code Generation / 174 7.2. Overview of Code Generation Tasks and Goals / 175 7.3. Specifics of Code Generation for.net / 179 7.4. Specifics of Code Generation for SPARC Architecture / 180 7.5. Representing Types and Addressing Variables / 181 7.6. Representing Procedures, Functions, and Methods / 186 7.7. Principles of SPARC Architecture / 190 7.8. Example of Code Generation for SPARC Architecture / 192 7.9. Generation of Debugging Information / 195

X CONTENTS 7.10. Code Generation for Declarations (Pefinitions), Expressions, and Statements / 197 Exercises to Chapter 7 / 199 8. Runtime, JIT, and AOT Compilation 200 8.1. The Tasks of the Runtime / 200 8.2. The Relationship of the Runtime and the Operating System (OS) / 202 8.3. JIT Compilation / 203 8.4. The Architecture of FJIT JIT Compiler for SSCLI/Rotor / 211 8.5. The Architecture of Optimizing JIT Compiler for SSCLI/Rotor / 212 8.6. AOT Compilation / 220 Exercises to Chapter 8 / 221 9. Graph Grammars and Graph Compilers 222 9.1. Basic Concepts of Graph Grammars and Graph Compilers / 223 9.2. Categorical Approach to Graph Transformations / 226 9.3. Reserved Graph Grammars (RGGs) / 230 9.4. Layered Graph Grammars / 232 9.5. Meta-Modeling Approach to Graph Grammars and Diameta Editor / 233 9.6. Hypergraph Approach to Graph Grammars in Diagen / 235 9.7. Graph Compiler Generation Tools / 237 Exercises to Chapter 9 / 238 10. Microsoft Phoenix, Phoenix-Targeted Tools, and Our Phoenix Projects 239 10.1. History of Phoenix and of Our Phoenix Projects / 240 10.2. Overview of Phoenix Architecture / 242 10.3. Phoenix-Based Tools, Passes, Phases, and Plug-Ins / 246 10.4. Phoenix Primitives: Strings and Names / 247 10.5. Phoenix Intermediate Representation (IR) / 248 10.6. Phoenix Symbol System / 253 10.7. Phoenix Type System / 257 10.8. Data Flow Analysis, Control Flow Analysis, Graphs, and Static Single Assignment (SSA) in Phoenix / 260 10.9. Overview of Other Phoenix Features / 264 10.10. Example of a Phoenix-Based Plug-In / 265

CONTENTS Xi 10.11. Phoenix-Fete A Compiler Front-End Development Toolkit and Environment Targeted to Phoenix / 267 10.11.1. Architectural Specifics of Phoenix-FETE / 268 10.11.2. The Input Grammar Meta-Language / 269 10.11.3. The Current Status of the Implementation / 271 Exercises to Chapter 10 / 274 Conclusions 277 References 279 Index 285