Lecture 011

Runtime Organization

Frontend: enforce semantics

Backend: generating code

Two Separation:

Activation

The goal is to solve two problems simultaneously:

Two Assumptions: for simplicity for now

Activation: the act of invoking a procedure P is called activation of P

Lifetime:

Lifetime is dynamic (run-time) concept and scope is static concept

Activation Tree shows containment of lifetime. Recursive call can have same function containing in itself. Activation Tree might look different on different input (since it is  a run-time concept)

Activation Tree shows containment of lifetime. Recursive call can have same function containing in itself. Activation Tree might look different on different input (since it is a run-time concept)

We can use a stack to track activation, since activations can be arranged into a tree.

Frame (Activation Record)

Frame (Activation Record): data kept so that when F() calls G(), frame has the proper information to complete execution of G() and resume execution of F(). So frame store things both related to G() and F()

Frame: Example Code

Frame: Example Code

Frame: the stack

Frame: the stack

Compiler must determine the layout of activation record and generate code that correctly access location in the activation record. So activation layout and code generation must be designed together.

Memory Layout:

Stack Machine

Stack Machine: only stack memory, no heap

In a pure stack machine, add has 3 operation: 2 reads from stack and 1 write to stack. However, in 1-register stack machine, add has only 1 operation: 1 read from stack since the other input number and the returning number is already on the register.

Table of Content