- ES Español

- EN English

5.35. Compilers (Mandatory)
- Semester: 6th Sem. Credits: 4
- Hour of this course: Theory: 2 hours; Practice: 2 hours; Laboratory: 2 hours;
- Syllabus:
- htmlonly

Español

English - Prerrequisites:
- CS211 Theory of Computation (4th Sem) itemize
5.35.1. Justification ↑ Back to top
This course provides a deep understanding of how high-level languages are transformed into executable machine code. The study of compilers allows students to understand language semantics, memory management, and code optimization, which are fundamental skills for designing domain-specific languages and high-performance software engineering.
5.35.2. Generales Goals ↑ Back to top
- Understand the phases of a compiler and construction tools.
- Implement lexical and syntactic analyzers based on grammars.
- Generate and optimize intermediate code for a specific architecture.
5.35.3. Contribution to Outcomes ↑ Back to top
- AG-C08) Problem Analysis: Identifies, formulates, and analyzes complex computing problems. (Usage)
- AG-C12) Applies computer science theory and software development fundamentals to produce computer-based solutions. (Usage)
5.35.4. Content ↑ Back to top
5.35.4.1. Program Analysis and Analyzers (20 hours) [Skills AG-C08,AG-C12] ↑ Back to top
Bibliography: (Aho et al., 2006; Appel, 2004)
Topics
- Relevant program representations, such as basic blocks, control-flow graphs, def-use chains, and static single assignment
- Undecidability and consequences for program analysis
- Flow-insensitive analysis, such as type-checking and scalable pointer and alias analysis
- Flow-sensitive analysis, such as forward and backward dataflow analyses
- Path-sensitive analysis, such as software model checking and software verification
- Tools and frameworks for implementing analyzers
- Role of static analysis in program optimization and data dependency analysis during exploitation of concurrency
- Role of program analysis in (partial) verification and bug-finding
- Parallelization:
- Analysis for auto-parallelization
- Analysis for detecting concurrency bugs enumerate
Learning Outcomes
- Explain the difference between dataflow graph and control flow graph [Explain]
- Explain why non-trivial sound program analyses must be approximate [Explain]
- Argue why an analysis is correct (sound and terminating) [Argue]
- Explain why potential aliasing limits sound program analysis and how alias analysis can help [Explain]
- Use the results of a program analysis for program optimization and/or partial program correctness [Use]
5.35.4.2. Language Translation and Execution (24 hours) [Skills AG-C08,AG-C12] ↑ Back to top
Bibliography: (Aho et al., 2006; Appel, 2004)
Topics
- Execution models for JIT (Just-In-Time), compiler, interpreter
- Use of intermediate code, e.g., bytecode
- Limitations and benefits of JIT, compiler, and interpreter
- Cross compilers/transpilers
- BNF and extended BNF representation of context-free grammar
- Parse tree using a simple sentence such as arithmetic expression or if-then-else statement
- Execution as native code or within a virtual machine
- Language translation pipeline: syntax analysis, parsing, optional type-checking, translation/code generation and optimization, linking, loading, execution
- Run-time representation of core language constructs such as objects (method tables) and functions that can be passed as parameters to and returned from functions (closures)
- Secure compiler development
Learning Outcomes
- Explain and understand the differences between compiled, JIT, and interpreted language implementations, including the benefits and limitations of each [Explain]
- Differentiate syntax and parsing from semantics and evaluation [Differentiate]
- Use BNF and extended BNF to specify the syntax of simple constructs such as if-then-else, type declaration and iterative constructs for known languages such as C++ or Python [Use]
- Illustrate the parse tree using a simple sentence/arithmetic expression [Apply]
- Illustrate translation of syntax diagrams to BNF/extended BNF for simple constructs such as if-then-else, type declaration, iterative constructs, etc [Apply]
- Illustrate ambiguity in parsing using nested if-then-else/arithmetic expression and show resolution using precedence order [Apply]
- Discuss the benefits and limitations of garbage collection, including the notion of reachability [Debate]
5.35.4.3. Run-time Behavior and Systems (20 hours) [Skills AG-C08,AG-C12] ↑ Back to top
Bibliography: (Aho et al., 2006; Cooper and Torczon, 2011)
Topics
- Process models using stacks and heaps to allocate and deallocate activation records and recovering environments using frame pointers and return addresses during a procedure call including parameter-passing examples
- Schematics of code lookup using hash tables for methods in implementations of object-oriented programs
- Data layout for objects and activation records
- Object allocation in heap
- Implementing virtual entities and virtual methods; virtual method tables and their application
- Run-time behavior of object-oriented programs
- Compare and contrast allocation of memory during information exchange using parameter-passing and non-local variables (using chain of static links).
- Dynamic memory management approaches and techniques: malloc/free, garbage collection (mark-sweep, copying, reference counting), regions (also known as arenas or zones)
- Just-in-time compilation and dynamic recompilation
- Interface to operating system (e.g., for program initialization)
- Interoperability between programming languages including parameter-passing mechanisms and data representation:
- Big endian, little endian
- Data layout of composite data types such as arrays enumerate
- Other common features of virtual machines, such as class loading, threads, and security checking
- Sandboxing
Learning Outcomes
- Discuss benefits and limitations of automatic memory management [Debate]
- Explain the use of metadata in run-time representations of objects and activation records, such as class pointers, array lengths, return addresses, and frame pointers [Explain]
- Compare and contrast static allocation vs stack-based allocation vs heap-based allocation of data elements [Compare]
- Explain why some data elements cannot be automatically deallocated at the end of a procedure/method call (need for garbage collection) [Explain]
- Discuss advantages, disadvantages, and difficulties of just-in-time and dynamic recompilation [Debate]
- Discuss the use of sandboxing in mobile code [Debate]
- Identify the services provided by modern language run-time systems [Analyze]
5.35.5. Bibliography ↑ Back to top
Aho, A. V., Lam, M. S., Sethi, R., and Ullman, J. D. (2006). Compilers: Principles, Techniques, and Tools. Pearson, 2nd edition.
Appel, A. W. (2004). Modern Compiler Implementation in Java. Cambridge University Press, 2nd edition.
Cooper, K. and Torczon, L. (2011). Engineering a Compiler. Morgan Kaufmann, 2nd edition.