100 likes | 245 Views
CSCE 531 Compiler Construction Final Lecture of the Semester. Spring 2010 Marco Valtorta mgv@cse.sc.edu. Acknowledgment. The slides are based on the textbook and other sources, including slides from Bent Thomsen’s course at the University of Aalborg in Denmark and several other fine textbooks
E N D
CSCE 531Compiler ConstructionFinal Lecture of the Semester Spring 2010 Marco Valtorta mgv@cse.sc.edu
Acknowledgment • The slides are based on the textbook and other sources, including slides from Bent Thomsen’s course at the University of Aalborg in Denmark and several other fine textbooks • The three main other compiler textbooks I considered are: • Aho, Alfred V., Monica S. Lam, Ravi Sethi, and Jeffrey D. Ullman. Compilers: Principles, Techniques, & Tools, 2nd ed. Addison-Welsey, 2007. (The “dragon book”) • First edition, without the second author, was published in 1988 • Appel, Andrew W. Modern Compiler Implementation in Java, 2nd ed. Cambridge, 2002. (Editions in ML and C also available; the “tiger books”) • Grune, Dick, Henri E. Bal, Ceriel J.H. Jacobs, and Koen G. Langendoen. Modern Compiler Design. Wiley, 2000
Efficiency • Efficiency is especially an issue for register machines • Example 9.5 • Hand-developed assembly code is faster • Code transformations (“optimizations”) • Constant folding, including address folding for arrays and records (ex. 9.6) • Common expression elimination (ex. 9.7) • Code movement (ex. 9.8)
Blocks and Data Flow Analysis • Handout (dragon books: 9.4 [1988]) • Partition into basic blocks • Transformation on basic blocks • Common subexpression elimination • Dead code elimination • Renaming of temporary variables • Interchange of two independent adjacent statements • Basic blocks form a flow graph
Live Variable Analysis • Handout (dragon book: 9.2.5 [2007]) • Could variable x at point p be used along some path in the flow graph starting at p?
Language Lifecycle • Language processors do not exist in a vacuum • Waterfall, Iterative Development, RUDE • Support for programming in the large and programming in the small is necessary • This goes beyond compiler design • Waterfall requires support for design-by-contract • Iterative development requires support for prototyping • RUDE may be better supported by weaker typing
Interpreters are everywhere on the web Web-Client Database Server Web-Server HTML-Form (+JavaScript) Call PHP interpreter WWW DBMS Submit Data LAN Web-Browser PHP Script SQL commands Response Response Database Output Reply
Parallel Programming • People still we do not know how to do parallel programming in an imperative style, and the machines are catching up! • Solution 1: use a functional or logical style • Solution 2: concentrate on numerical computation • Solution 3: support specific computer architectures
Compilers, Language Design, and Specifications • It is hard to write informal specifications that are unambiguous • Example: repeat … until exercise • It seems impossible to teach a compiler course without also teaching language design • Example: recursive data types
Why Study PL Concepts? • Increased capacity to express ideas • Improved background for choosing appropriate languages • Increased ability to learn new languages • Better understanding of the significance of implementation • Increased ability to design new languages • Background for compiler writing • Overall advancement of computing • Distinguish essential from accidental features