CSc 453 Compilers Systems Software Saumya Debray The
CSc 453 Compilers & Systems Software Saumya Debray The University of Arizona Tucson, AZ 85721
Course Objectives l l l Understand the design and implementation of compilers and related systems software. Understand how source language programs are implemented at the machine level. Understand compilation as an instance of language translation. CSc 453: Background 2
Compilers A compiler (more generally, translator) maps source language strings to “equivalent” target language strings. E. g. : l l l gcc : C/C++ programs to assembly/machine code f 2 c : Fortran programs to C programs latex 2 html: Latex documents to HTML documents javac : Java programs to JVM byte code ps 2 pdf: Post. Script files to PDF files CSc 453: Background 3
Languages l Syntax: l l l “structural” aspects of program units. specified by a grammar. Semantics: l l the “meaning, ” i. e. , behavior, of program units. specified using actions associated with grammar rules. CSc 453: Background 4
Phases of a Compiler 1. Lexical analysis (“scanning”) l 2. Syntax analysis (“parsing”) l 3. Translates to “lower level” representation. Program analysis and code optimization l 6. Checks semantic constraints of the language. Intermediate code generation l 5. Structures token sequence according to grammar rules of the language. Semantic analysis l 4. Reads in program, groups characters into “tokens” Improves code quality. Final code generation. CSc 453: Background 5
Grouping of Phases l Front end : machine independent phases l l l Lexical analysis Syntax analysis Semantic analysis Intermediate code generation Some code optimization Back end : machine dependent phases l l Final code generation Machine-dependent optimizations CSc 453: Background 6
A very commonly used translator: The Web Browser Gecko Webkit (rendering engine for Firefox): (rendering engine for Safari and Chrome): front end back end Source: How Browsers Work: Behind the Scenes of Modern Web Browsers, by Tali Garsiel & Paul Irish. http: //www. html 5 rocks. com/en/tutorials/internals/howbrowserswork/ CSc 453: Background 7
Costs of different phases l Typically, a compiler spends most of its time doing I/O and lexical analysis: l l ~ 35 -40% of time spent in I/O ~ 30% in lexical analysis ~ 10% in symbol table management ~ 7 -15% in parsing and other control CSc 453: Background 8
- Slides: 8