Run-time Environments

Status

Run-time Environments

Run-Time Organization Outline

Run-time Resources

Program Memory Layout

Notes

Organization of Code Space

Organization of Code Space

What is Other Space?

Code Execution Goals

Assumptions about Flow of Control

Language Issues that Affect the Compiler

Activations

Lifetimes of Variables

Activation Trees

Example 1

Class Main {
    g() : Int { 1 };
    f() : Int { g() };
    main() : Int { {g(); f();} };
};

Example 2

Class Main {
    g() : Int { 1 };
    f(x : Int) : {
        if x = 0 then g() else f(x - 1) fi
    };
    main() : Int { {f(3);} };
};

Notes

Example

Class Main {
    g() : Int { 1 };
    f() : Int { g() };
    main (): Int { {g(); f();} };
};

Example

Class Main {
    g() : Int { 1 };
    f() : Int { g() };
    main (): Int { {g(); f();} };
};

Example

Class Main {
    g() : Int { 1 };
    f() : Int { g() };
    main (): Int { {g(); f();} };
};

Example

Class Main {
    g() : Int { 1 };
    f() : Int { g() };
    main (): Int { {g(); f();} };
};

Example

Class Main {
    g() : Int { 1 };
    f() : Int { g() };
    main (): Int { {g(); f();} };
};

Revised Memory Layout

Activation Records

What is in \(G\)’s AR when \(F\) calls \(G\)?

The Contents of a Typical AR for \(G\)

Example 2 Revisited

Stack After Two Calls to f

Stack After Second Call to f Returns

Notes

The Main Point

Discussion

Storage Allocation Strategies for Activation Records

Storage Allocation Strategies for Activation Records

Globals

Memory Layout with Static Data

Heap Storage

Review of Runtime Organization

Notes

Memory Layout with Heap

Data Layout

Summary