Unit 7: Runtime Environment
Runtime environment considerations include organization of the compiled program, storage, building blocks of a compiled program, and different runtime configurations. This unit has some overlap with Unit 8. The emphasis in this unit is on representation of needed data structures and techniques for objects and inheritance. The emphasis of Unit 8 is on instruction generation.
Completing this unit should take you approximately 14 hours.
Upon successful completion of this unit, you will be able to:
- Describe the role of intermediate representation and runtime environments in the compilation process.
- Explain the encoding of data structures in runtime memory.
- Explain the encoding of procedures, functions, and parameters at runtime.
- Explain how objects, inheritance, and exceptions are encoded at runtime.
7.1: Overview of Runtime Environments
Read this handout, which discusses data representations and their organization in memory for a program. After semantic analysis, intermediate representations are encoded. This is the last step of the "front-end" of the compilation process. The relationship of front ends to back ends can be many-to-one or one-to-many. In the former case, a single back end is used for several languages, each handled by its own front end. In the latter case, one front end handles the input, source language, and the back end is used for several target machines, each having its own back end.
Read the functions of IR generation on slides 6 and 7. Some requirements for IR generation are on slide 8. Encoding of primitive types and arrays are discussed on slides 19 through 37 for additional coverage.
Scope of a variable is the lexical area of a program in which the variable can be used. Extent, or lifetime, is the period of time that a variable exists.
See slides 38 through 118 for a discussion of the stack, activation trees, closure and coroutines, and parameter passing.
Read these notes. In this presentation, IR is treated as part of code generation, and it has a lot of detail on the run-time encoding for procedures and functions.
Watch these lectures
7.2: More Complicated Representations: Objects and Inheritance
Read these slides, which describe the encoding of objects, inheritance, and dynamic type checking, including difficulties and solutions.
7.3: Encoding of Exceptions and OOP (Object-Oriented Programs)
Read these notes.
Scan over these and watch the parts that will benefit you.