Runtime Organization

Introduction

What lives where?

What:

Where?

Who manages what?

Who

Execution of a program is initially under the control of the operating system

Compiler is responsible for (a) generating code, and (b) orchestrating the use of the data area.

Draw a picture of memory with "code" and "other space".

Programming model

We will assume the following programming model: For now, we are ignoring the following programming constructs: These additional programming constructs will depend on the ideas we will discuss.

Activations

Activation Records

The active activations can be maintained in a stack, also called the call stack. The information for each activation is stored in an activation record, also called a frame. What information to keep in an activation?

Globals and Heap

Heap objects

Usually

Both heap and stack grow. Must take care they don't grow into each other. Simple solution: put them at opposite ends of memory and let them grow towards each other. If the two regions start touching each other, then the program is out of memory (or it may request more memory, etc.). This design allows different programs to use these different areas as they see fit, e.g., some programs may have large stacks, other may have large static data regions.

Alignment

Low-level but important detail that every compiler writer needs to be aware of.

Stack machines

Begin talking about code generation. Stack machines are the simplest model of code generation

In a stack machine