Declarative Intraprocedural Flow Analysis of Java Source Code
|
|
- Roderick Hall
- 6 years ago
- Views:
Transcription
1 Declarative Intraprocedural Flow Analysis of Java Source Code Emma Nilsson-Nyman Torbjörn Ekman Görel Hedin Eva Magnusson Dept of Computer Science Lund University Programming Tools Group University of Oxford
2 Goals Source code analysis is useful Refactorings Errors Optimizations Simplify its implementation Intraprocedural control flow and data flow Normally: Three address code This paper: Declarative AST computations
3 Tool: Compiler Compiler CFG DF Application LOC Java 1.4 Compiler built using JastAdd Attribute grammars - declarative AST computations Synthesized and inherited attributes Modern extensions Reference attributes Super-imposed graphs Collection attributes Circular attributes Non-terminal attributes
4 Tool: Compiler Compiler CFG DF Application LOC Java 1.4 Compiler built using JastAdd Attribute grammars - declarative AST computations Synthesized and inherited attributes Modern extensions Reference attributes Super-imposed graphs Collection attributes Circular attributes Non-terminal attributes
5 Tool: Compiler Compiler CFG DF Application LOC Java 1.4 Compiler built using JastAdd Attribute grammars - declarative AST computations Synthesized and inherited attributes Modern extensions Reference attributes Super-imposed graphs Collection attributes Circular attributes Non-terminal attributes
6 Intraprocedural Control Flow Compiler CFG DF Application Traditional control flow graphs (CFG) Three address code Basic blocks Successors, predecessors Entry and exit blocks Entry Exit
7 Intraprocedural Control Flow CFG Our control flow graphs Basic blocks -> Statements AST: Entry MethodDecl Block WhileStmt Stmt
8 Intraprocedural Control Flow CFG AST: Our control flow graphs Basic blocks -> Statements MethodDecl Entry and exit nodes Entry Block Exit WhileStmt Stmt
9 Intraprocedural Control Flow CFG AST: Our control flow graphs Basic blocks -> Statements MethodDecl Entry and exit nodes Reference attributes Entry Block Exit Successors WhileStmt Stmt
10 Intraprocedural Control Flow CFG AST: Our control flow graphs Basic blocks -> Statements MethodDecl Entry and exit nodes Reference attributes Entry Block Exit Successors Predecessors WhileStmt Stmt
11 Intraprocedural Control Flow CFG AST: Defining successors: syn Set Stmt.succ(); eq Stmt.succ() = following(); eq WhileStmt.succ() = following().union(getstmt());... Entry MethodDecl Block WhileStmt Exit Stmt
12 Intraprocedural Control Flow CFG AST: Defining predecessors: coll Set Stmt.pred() [empty()] with add; Stmt contributes this to Stmt.pred() for each succ(); Entry MethodDecl Block WhileStmt Exit Stmt
13 Intraprocedural Control Flow Compiler CFG DF Application LOC 300 LOC Approx 240 LOC for Java exceptions Control Flow API: Stmt Stmt entry() Stmt exit() Set succ() Set pred()
14 Intraprocedural Data Flow Compiler CFG DF Application Data Flow (DF) Live variables a = 0; b = 0; a = b + 5; b = a + b;...
15 Intraprocedural Data Flow DF Live variables a = 0; b = 0; a = b + 5; b = a + b;... Definition: in(s) = use(s) (out(s) \ def(s)) out(s) = in(x) x succ(s)
16 Intraprocedural Data Flow DF Live variables a = 0; b = 0; a = b + 5; b = a + b;... Definition: in(s) = use(s) (out(s) \ def(s)) out(s) = in(x) x succ(s)
17 Intraprocedural Data Flow DF Live variables a = 0; b = 0; a = b + 5; b = a + b;... Definition: in(s) = use(s) (out(s) \ def(s)) out(s) = in(x) x succ(s)
18 Intraprocedural Data Flow DF Live variables a = 0; in=, out= b = 0; in=, out= {b} a = b + 5; in= {b}, out= {a,b} b = a + b; in= {a,b}, out= {...}... Definition: in(s) = use(s) (out(s) \ def(s)) out(s) = in(x) x succ(s)
19 Intraprocedural Data Flow DF Live variables a = 0; in=, out= def= {a}, use= b = 0; in=, out= {b} def= {b}, use= a = b + 5; in= {b}, out= {a,b} def= {a}, use= {b} b = a + b; in= {a,b}, out= {...} def= {b}, use= {a,b}... Definition: in(s) = use(s) (out(s) \ def(s)) out(s) = in(x) x succ(s)
20 Intraprocedural Data Flow DF Live variables a = 0; in=, out= def= {a}, use= b = 0; in=, out= {b} def= {b}, use= a = b + 5; in= {b}, out= {a,b} def= {a}, use= {b} b = a + b; in= {a,b}, out= {...} def= {b}, use= {a,b}... Definition: in(s) = use(s) (out(s) \ def(s)) out(s) = in(x) x succ(s)
21 Intraprocedural Data Flow DF in(s) = use(s) (out(s) \ def(s)) syn Set Stmt.in() circular [empty()]; eq Stmt.in() = use().union(out().compl(def())); out(s) = x succ(s) in(x) coll Set Stmt.out() circular [empty()] with add; Stmt contributes in() to Stmt.out() for each pred();
22 Intraprocedural Data Flow DF in(s) = use(s) (out(s) \ def(s)) syn Set Stmt.in() circular [empty()]; eq Stmt.in() = use().union(out().compl(def())); out(s) = x succ(s) in(x) coll Set Stmt.out() circular [empty()] with add; Stmt contributes in() to Stmt.out() for each pred();
23 Intraprocedural Data Flow Compiler CFG DF Application LOC 300 LOC 30 LOC Data Flow API: Stmt Set in() Set out() Set def() Set use()
24 Application: Dead Assignment Compiler CFG DF Application Dead assignment Dead! a = 0; b = 0; a = b + 5; b = a + b;...
25 Application: Dead Assignment DA Dead? a = 0; b = 0; a = b + 5; b = a + b;... true false false... not def(s) out(s) syn boolean Stmt.isDead(); eq Stmt.isDead() =!def().subset(out());
26 Application: Dead Assignment DA Dead? a = 0; true def= {a} out= b = 0; false def= {b} out= {b} a = b + 5; false def= {a} out= {a,b} b = a + b;... def= {b} out= {...}... not def(s) out(s) syn boolean Stmt.isDead(); eq Stmt.isDead() =!def().subset(out());
27 Application: Dead Assignment DA Dead? a = 0; true def= {a} out= b = 0; false def= {b} out= {b} a = b + 5; false def= {a} out= {a,b} b = a + b;... def= {b} out= {...}... not def(s) out(s) syn boolean Stmt.isDead(); eq Stmt.isDead() =!def().subset(out());
28 Application: Dead Assignment Compiler CFG DF Application LOC 300 LOC 30 LOC 10 LOC Dead Assignment API: Stmt boolean isdead()
29 Practical Experience Compilation Time (s) Imperative (s) kloc Declarative (s) Dead Assigns junit antlr bloat jigsaw
30 Practical Experience Compilation Time (s) Imperative (s) kloc Declarative (s) Dead Assigns junit antlr bloat jigsaw
31 Practical Experience Compilation Time (s) Imperative (s) kloc Declarative (s) Dead Assigns junit antlr bloat jigsaw
32 Practical Experience Seconds junit bloat antlr jigsaw Compilation Declarative Imperative kloc
33 Conclusions Concise - close to mathematical definitions Composable modules Source code instead of three address code Extensible Resonable execution times
34 Future Work Additional Analyses Interprocedural control flow and data flow Preliminary work: metrics (Chidamber & Kemerer), call graphs SSA graphs Additional Applications Bug detection Refactorings On going work...
35 The End Thanks for listening! Questions?
36 Exceptions Propagate down (inh) MethodDecl enclosingtrystmt() hasenclosingfinally() Propagate up (syn) Entry Block Exit containsreturn() TryStmt Block Finally TryStmt Block Finally ReturnStmt
37 Intraprocedural Data Flow DF def(s) coll Set Stmt.def() [empty()] with add; VarAccess contributes decl() when isdest() && decl().islocalvariable() to Stmt.def() for enclosingstmt(); use(s) coll Set Stmt.use() [empty()] with add; VarAccess contributes decl() when issource() && decl().islocalvariable() to Stmt.use() for enclosingstmt();
Compiler Structure. Data Flow Analysis. Control-Flow Graph. Available Expressions. Data Flow Facts
Compiler Structure Source Code Abstract Syntax Tree Control Flow Graph Object Code CMSC 631 Program Analysis and Understanding Fall 2003 Data Flow Analysis Source code parsed to produce AST AST transformed
More informationExtensible Compiler Architecture Examples from JModelica.org
Extensible Compiler Architecture Examples from JModelica.org Uses of the JastAdd systems Görel Hedin Computer Science, Lund University LCCC workshop, Lund, Sept 20, 2012 1 Background JastAdd: an open source
More informationLecture Compiler Middle-End
Lecture 16-18 18 Compiler Middle-End Jianwen Zhu Electrical and Computer Engineering University of Toronto Jianwen Zhu 2009 - P. 1 What We Have Done A lot! Compiler Frontend Defining language Generating
More informationTutorial: Generating Language Tools with JastAdd
Tutorial: Generating Language Tools with JastAdd Görel Hedin Lund University, Sweden gorel@cs.lth.se, Draft Oct 29, 2009 Abstract. JastAdd is an open-source system for generating compilers and other language-based
More informationExtendJ The Extensible Java Compiler. Jesper Öqvist, PhD Student Lund University
ExtendJ The Extensible Java Compiler Jesper Öqvist, PhD Student Lund University About Me PhD student since 2013 Google Intern (2015 & 2016) ExtendJ Maintainer (668 commits of 1158 total) Current main project:
More informationData Flow Analysis. Program Analysis
Program Analysis https://www.cse.iitb.ac.in/~karkare/cs618/ Data Flow Analysis Amey Karkare Dept of Computer Science and Engg IIT Kanpur Visiting IIT Bombay karkare@cse.iitk.ac.in karkare@cse.iitb.ac.in
More informationJastAdd an aspect-oriented compiler construction system
JastAdd an aspect-oriented compiler construction system Görel Hedin Eva Magnusson Department of Computer Science, Lund University, Sweden Abstract We describe JastAdd, a Java-based system for compiler
More informationAn Introductory Tutorial on JastAdd Attribute Grammars
An Introductory Tutorial on JastAdd Attribute Grammars Görel Hedin Lund University, Sweden gorel@cs.lth.se Preprint, May 1, 2010. To appear in Postproceedings of GTTSE 2009. The final publication will
More informationData Flow Analysis. Agenda CS738: Advanced Compiler Optimizations. 3-address Code Format. Assumptions
Agenda CS738: Advanced Compiler Optimizations Data Flow Analysis Amey Karkare karkare@cse.iitk.ac.in http://www.cse.iitk.ac.in/~karkare/cs738 Department of CSE, IIT Kanpur Static analysis and compile-time
More informationCompiler Construction
Compiler Construction Introduction and overview Görel Hedin Reviderad 2013-01-22 2013 Compiler Construction 2013 F01-1 Agenda Course registration, structure, etc. Course overview Compiler Construction
More informationIncremental Evaluation of Reference Attribute Grammars using Dynamic Dependency Tracking
Incremental Evaluation of Reference Attribute Grammars using Dynamic Dependency Tracking Söderberg, Emma; Hedin, Görel Unpublished: 2012-01-01 Link to publication Citation for published version (APA):
More informationMidterm 2. CMSC 430 Introduction to Compilers Fall Instructions Total 100. Name: November 21, 2016
Name: Midterm 2 CMSC 430 Introduction to Compilers Fall 2016 November 21, 2016 Instructions This exam contains 7 pages, including this one. Make sure you have all the pages. Write your name on the top
More informationDomain-Specific Languages for Program Analysis
Domain-Specific Languages for Program Analysis Mark Hills OOPSLE 2015: Open and Original Problems in Software Language Engineering March 6, 2014 Montreal, Canada http://www.rascal-mpl.org 1 Overview A
More informationEDAN65: Compilers, Lecture 08 Reference A<ribute Grammars AG mechanisms, SemanBc analysis. Görel Hedin Revised:
EDAN65: Compilers, Lecture 08 Reference A
More informationJava Code Cleanup using ExtendJ
Java Code Cleanup using ExtendJ Hannes Jönsson LTH stv10hjo@student.lu.se Felix Olsson LTH dat12fol@student.lu.se Abstract In order to reduce code size, ensure proper functionality of overridden methods
More informationCircular Reference Attributed Grammars - their Evaluation and Applications
Circular Reference Attributed Grammars - their Evaluation and Applications Eva Magnusson 1 Dept of Computer Science Lund University Lund, Sweden Görel Hedin 2 Dept of Computer Science Lund University Lund,
More informationCS 406/534 Compiler Construction Putting It All Together
CS 406/534 Compiler Construction Putting It All Together Prof. Li Xu Dept. of Computer Science UMass Lowell Fall 2004 Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy
More informationRewritable Reference Attributed Grammars
Rewritable Reference Attributed Grammars Torbjörn Ekman and Görel Hedin Department of Computer Science, Lund University, Sweden (torbjorn gorel)@cs.lth.se Abstract. This paper presents an object-oriented
More informationSound and Extensible Renaming for Java
Sound and Extensible Renaming for Java Max Schäfer, Torbjörn Ekman, Oege de Moor Daniel Gąsienica Software Engineering Seminar May 12, 2009 What Is Refactoring? To rewrite existing source code in order
More informationExtensible Compiler Construction
Extensible Compiler Construction Torbjörn Ekman Doctoral dissertation, 2006 Department of Computer Science Lund University ISBN 91-628-6839-X ISSN 1404-1219 Dissertation 25, 2006 LU-CS-DISS:2006-2 Department
More informationIntegrating Xtext and JavaRAG: Using an attribute grammar library in a language workbench
MASTER S THESIS LUND UNIVERSITY 2016 Integrating Xtext and JavaRAG: Using an attribute grammar library in a language workbench Emin Gigovic, Philip Malmros Department of Computer Science Faculty of Engineering
More informationProgramming Assignment 5 Interpreter and Static Analysis
Lund University Computer Science Niklas Fors, Görel Hedin, Christoff Bürger Compilers EDAN65 2016-09-24 Programming Assignment 5 Interpreter and Static Analysis The goal of this assignment is to implement
More informationCompiler Optimisation
Compiler Optimisation 4 Dataflow Analysis Hugh Leather IF 1.18a hleather@inf.ed.ac.uk Institute for Computing Systems Architecture School of Informatics University of Edinburgh 2018 Introduction This lecture:
More informationData Flow Analysis. CSCE Lecture 9-02/15/2018
Data Flow Analysis CSCE 747 - Lecture 9-02/15/2018 Data Flow Another view - program statements compute and transform data So, look at how that data is passed through the program. Reason about data dependence
More informationDrAST - An attribute debugger for JastAdd
MASTER S THESIS LUND UNIVERSITY 2016 DrAST - An attribute debugger for JastAdd Joel Lindholm, Johan Thorsberg Department of Computer Science Faculty of Engineering LTH ISSN 1650-2884 LU-CS-EX 2016-10 DrAST
More informationLecture 2. Introduction to Data Flow Analysis
Lecture 2 Introduction to Data Flow Analysis I II III Example: Reaching definition analysis Example: Liveness Analysis A General Framework (Theory in next lecture) Reading: Chapter 9.2 Advanced Compilers
More informationCompiler Optimization and Code Generation
Compiler Optimization and Code Generation Professor: Sc.D., Professor Vazgen Melikyan 1 Course Overview Introduction: Overview of Optimizations 1 lecture Intermediate-Code Generation 2 lectures Machine-Independent
More informationMore Dataflow Analysis
More Dataflow Analysis Steps to building analysis Step 1: Choose lattice Step 2: Choose direction of dataflow (forward or backward) Step 3: Create transfer function Step 4: Choose confluence operator (i.e.,
More informationLecture 4 Introduction to Data Flow Analysis
Lecture 4 Introduction to Data Flow Analysis I. Structure of data flow analysis II. Example 1: Reaching definition analysis III. Example 2: Liveness analysis IV. Generalization What is Data Flow Analysis?
More informationCS5363 Final Review. cs5363 1
CS5363 Final Review cs5363 1 Programming language implementation Programming languages Tools for describing data and algorithms Instructing machines what to do Communicate between computers and programmers
More informationA Short Summary of Javali
A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler
More informationStatic Analysis. Systems and Internet Infrastructure Security
Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA Static Analysis Trent
More informationGenerating Semantic Editors using Reference Attribute Grammars
Generating Semantic Editors using Reference Attribute Grammars Emma Söderberg Department of Computer Science, Lund University, Lund, Sweden emma.soderberg@cs.lth.se Abstract. In this short research plan
More informationObject-oriented metrics for Java programs
Object-oriented metrics for Java programs Project in Computer Science EDAN70 January 22, 2015 Olle Tervalampi-Olsson D11, Lund Institute of Technology, Sweden dat11ote@student.lu.se Marcus Lacerda D11,
More informationReview; questions Basic Analyses (2) Assign (see Schedule for links)
Class 2 Review; questions Basic Analyses (2) Assign (see Schedule for links) Representation and Analysis of Software (Sections -5) Additional reading: depth-first presentation, data-flow analysis, etc.
More informationIntroduction to Machine-Independent Optimizations - 6
Introduction to Machine-Independent Optimizations - 6 Machine-Independent Optimization Algorithms Department of Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course
More informationWhy Data Flow Models? Dependence and Data Flow Models. Learning objectives. Def-Use Pairs (1) Models from Chapter 5 emphasized control
Why Data Flow Models? Dependence and Data Flow Models Models from Chapter 5 emphasized control Control flow graph, call graph, finite state machines We also need to reason about dependence Where does this
More informationCompilers. Compiler Construction Tutorial The Front-end
Compilers Compiler Construction Tutorial The Front-end Salahaddin University College of Engineering Software Engineering Department 2011-2012 Amanj Sherwany http://www.amanj.me/wiki/doku.php?id=teaching:su:compilers
More informationTree-based abstract syntax
Tree-based abstract syntax Ralf Lämmel Software Language Engineering Team University of Koblenz-Landau http://www.softlang.org/ A conditional expression Concrete syntax Abstract syntax Text Tree Tree as
More informationRegister Allocation. CS 502 Lecture 14 11/25/08
Register Allocation CS 502 Lecture 14 11/25/08 Where we are... Reasonably low-level intermediate representation: sequence of simple instructions followed by a transfer of control. a representation of static
More informationDependence and Data Flow Models. (c) 2007 Mauro Pezzè & Michal Young Ch 6, slide 1
Dependence and Data Flow Models (c) 2007 Mauro Pezzè & Michal Young Ch 6, slide 1 Why Data Flow Models? Models from Chapter 5 emphasized control Control flow graph, call graph, finite state machines We
More informationCompiler Design Spring 2017
Compiler Design Spring 2017 8.6 Live variables Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation Live variables Foundations for several optimizations If a variable is not live,
More informationClass 6. Review; questions Assign (see Schedule for links) Slicing overview (cont d) Problem Set 3: due 9/8/09. Program Slicing
Class 6 Review; questions Assign (see Schedule for links) Slicing overview (cont d) Problem Set 3: due 9/8/09 1 Program Slicing 2 1 Program Slicing 1. Slicing overview 2. Types of slices, levels of slices
More informationStreamlining Control-Flow Graph Construction with DCFlow
Streamlining Control-Flow Graph Construction with DCFlow Mark Hills 7th International Conference on Software Language Engineering (SLE 2014) September 15-16, 2014 Västerås, Sweden http://www.rascal-mpl.org
More informationCompiler Passes. Optimization. The Role of the Optimizer. Optimizations. The Optimizer (or Middle End) Traditional Three-pass Compiler
Compiler Passes Analysis of input program (front-end) character stream Lexical Analysis Synthesis of output program (back-end) Intermediate Code Generation Optimization Before and after generating machine
More informationSound and Extensible Renaming for Java
Sound and Extensible Renaming for Java Max Schäfer Torbjörn Ekman Oege de Moor Programming Tools Group, University of Oxford, UK {max.schaefer, torbjorn.ekman, oege.de.moor@comlab.ox.ac.uk Abstract Descriptive
More informationAttribute Grammars. Wilhelm/Seidl/Hack: Compiler Design, Volume 2, Chapter 4. Reinhard Wilhelm Universität des Saarlandes
Wilhelm/Seidl/Hack: Compiler Design, Volume 2, Chapter 4 Reinhard Wilhelm Universität des Saarlandes wilhelm@cs.uni-saarland.de Attributes: containers for static semantic (non-context free syntactic) information,
More informationEDA180: Compiler Construc6on. More Top- Down Parsing Abstract Syntax Trees Görel Hedin Revised:
EDA180: Compiler Construc6on More Top- Down Parsing Abstract Syntax Trees Görel Hedin Revised: 2013-02- 05 Compiler phases and program representa6ons source code Lexical analysis (scanning) Intermediate
More informationDebugging Framework for Attribute Grammars
Debugging Framework for Attribute Grammars A THESIS SUBMITTED TO THE FACULTY OF THE GRADUATE SCHOOL OF THE UNIVERSITY OF MINNESOTA BY Praveen Kambam Sugavanam IN PARTIAL FULFILLMENT OF THE REQUIREMENTS
More informationTopic 9: Control Flow
Topic 9: Control Flow COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 The Front End The Back End (Intel-HP codename for Itanium ; uses compiler to identify parallelism)
More informationELEC 876: Software Reengineering
ELEC 876: Software Reengineering () Dr. Ying Zou Department of Electrical & Computer Engineering Queen s University Compiler and Interpreter Compiler Source Code Object Compile Execute Code Results data
More informationSyntactic Directed Translation
Syntactic Directed Translation Translation Schemes Copyright 2016, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University of Southern California have explicit permission
More informationCS153: Compilers Lecture 23: Static Single Assignment Form
CS153: Compilers Lecture 23: Static Single Assignment Form Stephen Chong https://www.seas.harvard.edu/courses/cs153 Pre-class Puzzle Suppose we want to compute an analysis over CFGs. We have two possible
More informationFlow Analysis. Data-flow analysis, Control-flow analysis, Abstract interpretation, AAM
Flow Analysis Data-flow analysis, Control-flow analysis, Abstract interpretation, AAM Helpful Reading: Sections 1.1-1.5, 2.1 Data-flow analysis (DFA) A framework for statically proving facts about program
More informationCompiler Construction 2009/2010 SSA Static Single Assignment Form
Compiler Construction 2009/2010 SSA Static Single Assignment Form Peter Thiemann March 15, 2010 Outline 1 Static Single-Assignment Form 2 Converting to SSA Form 3 Optimization Algorithms Using SSA 4 Dependencies
More informationDependence and Data Flow Models. (c) 2007 Mauro Pezzè & Michal Young Ch 6, slide 1
Dependence and Data Flow Models (c) 2007 Mauro Pezzè & Michal Young Ch 6, slide 1 Why Data Flow Models? Models from Chapter 5 emphasized control Control flow graph, call graph, finite state machines We
More informationData Flow Analysis. Suman Jana. Adopted From U Penn CIS 570: Modern Programming Language Implementa=on (Autumn 2006)
Data Flow Analysis Suman Jana Adopted From U Penn CIS 570: Modern Programming Language Implementa=on (Autumn 2006) Data flow analysis Derives informa=on about the dynamic behavior of a program by only
More informationPSD3A Principles of Compiler Design Unit : I-V. PSD3A- Principles of Compiler Design
PSD3A Principles of Compiler Design Unit : I-V 1 UNIT I - SYLLABUS Compiler Assembler Language Processing System Phases of Compiler Lexical Analyser Finite Automata NFA DFA Compiler Tools 2 Compiler -
More informationA main goal is to achieve a better performance. Code Optimization. Chapter 9
1 A main goal is to achieve a better performance Code Optimization Chapter 9 2 A main goal is to achieve a better performance source Code Front End Intermediate Code Code Gen target Code user Machineindependent
More informationProgram analysis parameterized by the semantics in Maude
Program analysis parameterized by the semantics in Maude A. Riesco (joint work with I. M. Asăvoae and M. Asăvoae) Universidad Complutense de Madrid, Madrid, Spain Workshop on Logic, Algebra and Category
More informationCS553 Lecture Generalizing Data-flow Analysis 3
Generalizing Data-flow Analysis Announcements Project 2 writeup is available Read Stephenson paper Last Time Control-flow analysis Today C-Breeze Introduction Other types of data-flow analysis Reaching
More informationConstant Propagation with Conditional Branches
Seminar zum Projektpraktikum Pathfinder Dozent: Dr.Torsten Grust Universität Konstanz Wintersemester 2002/03 Constant Propagation with Conditional Branches Constant Propagation/ Brendan Briody - 1 - Brendan
More informationCS153: Compilers Lecture 17: Control Flow Graph and Data Flow Analysis
CS153: Compilers Lecture 17: Control Flow Graph and Data Flow Analysis Stephen Chong https://www.seas.harvard.edu/courses/cs153 Announcements Project 5 out Due Tuesday Nov 13 (14 days) Project 6 out Due
More informationAPPLAB User s Guide Version 1.2
APPLAB User s Guide Version 1.2 Elizabeth Bjarnason LU-CS-IR:96-01 Department of Computer Science Lund Institute of Technology Lund University Box 118, S-221 00 Lund, Sweden APPLAB User s Guide (version
More informationData-flow Analysis - Part 2
- Part 2 Department of Computer Science Indian Institute of Science Bangalore 560 012 NPTEL Course on Compiler Design Data-flow analysis These are techniques that derive information about the flow of data
More informationChapter 3. Semantics. Topics. Introduction. Introduction. Introduction. Introduction
Topics Chapter 3 Semantics Introduction Static Semantics Attribute Grammars Dynamic Semantics Operational Semantics Axiomatic Semantics Denotational Semantics 2 Introduction Introduction Language implementors
More informationPlan for Today. Concepts. Next Time. Some slides are from Calvin Lin s grad compiler slides. CS553 Lecture 2 Optimizations and LLVM 1
Plan for Today Quiz 2 How to automate the process of performance optimization LLVM: Intro to Intermediate Representation Loops as iteration spaces Data-flow Analysis Intro Control-flow graph terminology
More informationStatic Program Analysis Part 1 the TIP language
Static Program Analysis Part 1 the TIP language http://cs.au.dk/~amoeller/spa/ Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Questions about programs Does the program terminate
More informationWhy Global Dataflow Analysis?
Why Global Dataflow Analysis? Answer key questions at compile-time about the flow of values and other program properties over control-flow paths Compiler fundamentals What defs. of x reach a given use
More informationGlobal Optimization. Lecture Outline. Global flow analysis. Global constant propagation. Liveness analysis. Local Optimization. Global Optimization
Lecture Outline Global Optimization Global flow analysis Global constant propagation Liveness analysis Compiler Design I (2011) 2 Local Optimization Recall the simple basic-block optimizations Constant
More informationIntermediate representations IR #1: CPS/L 3. Code example. Advanced Compiler Construction Michel Schinz
Intermediate representations Intermediate representations Advanced Compiler Construction Michel Schinz 2016 03 03 The term intermediate representation (IR) or intermediate language designates the data-structure(s)
More informationAn Overview of GCC Architecture (source: wikipedia) Control-Flow Analysis and Loop Detection
An Overview of GCC Architecture (source: wikipedia) CS553 Lecture Control-Flow, Dominators, Loop Detection, and SSA Control-Flow Analysis and Loop Detection Last time Lattice-theoretic framework for data-flow
More informationProgram Analysis. Readings
Program Analysis Class #2 Readings he Program Dependence Graph and Its Use in Optimization Program slicing A Survey of Program Slicing echniques Dragon book Program Analysis Data-low Analysis (wrap up)
More informationChapter 3 (part 3) Describing Syntax and Semantics
Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings
More informationCJC: An Extensible Checker for the CleanJava Annotation Language
University of Texas at El Paso DigitalCommons@UTEP Departmental Technical Reports (CS) Department of Computer Science 5-1-2013 CJC: An Extensible Checker for the CleanJava Annotation Language Cesar Yeep
More informationEnhancing Xtext for General Purpose Languages
Enhancing Xtext for General Purpose Languages Adolfo Sánchez-Barbudo Herrera Department of Computer Science, University of York, UK. asbh500@york.ac.uk Abstract. Xtext is a popular language workbench conceived
More informationA comparison of metacompilation approaches to implementing Modelica
A comparison of metacompilation approaches to implementing Modelica Broman, David; Fritzson, Peter; Hedin, Görel; Åkesson, Johan Published: 2011-01-01 Link to publication Citation for published version
More informationCode Optimization. Code Optimization
161 Code Optimization Code Optimization 162 Two steps: 1. Analysis (to uncover optimization opportunities) 2. Optimizing transformation Optimization: must be semantically correct. shall improve program
More informationWeaving a Debugging Aspect into Domain-Specific Language Grammars
Weaving a Debugging Aspect into Domain-Specific Language Grammars Hui Wu, Jeff Gray, and Suman Roychoudhury Department of Computer and Information Sciences The University of Alabama at Birmingham Birmingham,
More informationCSE P 501 Compilers. SSA Hal Perkins Spring UW CSE P 501 Spring 2018 V-1
CSE P 0 Compilers SSA Hal Perkins Spring 0 UW CSE P 0 Spring 0 V- Agenda Overview of SSA IR Constructing SSA graphs Sample of SSA-based optimizations Converting back from SSA form Sources: Appel ch., also
More informationCombining Analyses, Combining Optimizations - Summary
Combining Analyses, Combining Optimizations - Summary 1. INTRODUCTION Cliff Click s thesis Combining Analysis, Combining Optimizations [Click and Cooper 1995] uses a structurally different intermediate
More informationCOMPILER CONSTRUCTION (Evaluation Orders for SDD s)
COMPILER CONSTRUCTION (Evaluation Orders for SDD s) Prof. K R Chowdhary Email: kr.chowdhary@jietjodhpur.ac.in Campus Director, JIET, Jodhpur Thursday 18 th October, 2018 kr chowdhary Code generation 1/
More informationCompilers and computer architecture: Semantic analysis
1 / 1 Compilers and computer architecture: Semantic analysis Martin Berger Alex Jeffery October 2018 Recall the function of compilers 2 / 1 3 / 1 Recall the structure of compilers Source program Lexical
More informationIntermediate representation
Intermediate representation Goals: encode knowledge about the program facilitate analysis facilitate retargeting facilitate optimization scanning parsing HIR semantic analysis HIR intermediate code gen.
More informationChapter 3. Syntax - the form or structure of the expressions, statements, and program units
Syntax - the form or structure of the expressions, statements, and program units Semantics - the meaning of the expressions, statements, and program units Who must use language definitions? 1. Other language
More informationTopic 1: Introduction
Recommended Exercises and Readings Topic 1: Introduction From Haskell: The craft of functional programming (3 rd Ed.) Readings: Chapter 1 Chapter 2 1 2 What is a Programming Paradigm? Programming Paradigm:
More informationVisitors. Move functionality
Visitors Compiler Construction Visitor pattern, Semantic analysis Lennart Andersson How to modularize in Java (or any other OO language) if we do not have access to AOP mechanisms? Revision 2011-02-08
More informationSyntax Analysis/Parsing. Context-free grammars (CFG s) Context-free grammars vs. Regular Expressions. BNF description of PL/0 syntax
Susan Eggers 1 CSE 401 Syntax Analysis/Parsing Context-free grammars (CFG s) Purpose: determine if tokens have the right form for the language (right syntactic structure) stream of tokens abstract syntax
More informationControl Flow Analysis & Def-Use. Hwansoo Han
Control Flow Analysis & Def-Use Hwansoo Han Control Flow Graph What is CFG? Represents program structure for internal use of compilers Used in various program analyses Generated from AST or a sequential
More informationEDA180: Compiler Construc6on. Top- down parsing. Görel Hedin Revised: a
EDA180: Compiler Construc6on Top- down parsing Görel Hedin Revised: 2013-01- 30a Compiler phases and program representa6ons source code Lexical analysis (scanning) Intermediate code genera6on tokens intermediate
More informationContext-free grammars (CFG s)
Syntax Analysis/Parsing Purpose: determine if tokens have the right form for the language (right syntactic structure) stream of tokens abstract syntax tree (AST) AST: captures hierarchical structure of
More informationFoundations: Syntax, Semantics, and Graphs
Foundations: Syntax, Semantics, and Graphs Testing, Quality Assurance, and Maintenance Winter 2018 Prof. Arie Gurfinkel based on slides by Ruzica Pizkac, Claire Le Goues, Lin Tan, Marsha Chechik, and others
More informationSyntax Errors; Static Semantics
Dealing with Syntax Errors Syntax Errors; Static Semantics Lecture 14 (from notes by R. Bodik) One purpose of the parser is to filter out errors that show up in parsing Later stages should not have to
More informationExamining the Code. [Reading assignment: Chapter 6, pp ]
Examining the Code [Reading assignment: Chapter 6, pp. 91-104] Static white-box testing Static white-box testing is the process of carefully and methodically reviewing the software design, architecture,
More informationControl flow and loop detection. TDT4205 Lecture 29
1 Control flow and loop detection TDT4205 Lecture 29 2 Where we are We have a handful of different analysis instances None of them are optimizations, in and of themselves The objective now is to Show how
More informationIntermediate Representations. Reading & Topics. Intermediate Representations CS2210
Intermediate Representations CS2210 Lecture 11 Reading & Topics Muchnick: chapter 6 Topics today: Intermediate representations Automatic code generation with pattern matching Optimization Overview Control
More informationKay Schlühr.
Kay Schlühr kay@fiber-space.de EE Everything begun...... with a tiny arrow operator as a visual clue >>> -> A0 A4 00 00 3F 00 EE But where do we find arrows? easy to parse as console input easy to parse
More informationFaculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology
Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4020 January 19, 2006 14.00-15.30 This exam (8 pages) consists of 60 True/False
More informationModularity First: A Case for Mixing AOP and Attribute Grammars
Modularity First: A Case for Mixing AOP and Attribute Grammars Pavel Avgustinov, Torbjörn Ekman, Julian Tibble Programming Tools Group University of Oxford United Kingdom ABSTRACT We have reimplemented
More informationData-flow Analysis. Y.N. Srikant. Department of Computer Science and Automation Indian Institute of Science Bangalore
Department of Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course on Compiler Design Data-flow analysis These are techniques that derive information about the flow
More information