8.2: Runtime Environments

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/23

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

24 Terms

1
New cards

Compiler Task

Must correctly map the high-level constructs of the source language to the low-level target machine constructs.

2
New cards

OS Address mapping

Maps the logical addresses to physical addresses in memory

3
New cards

Virtual Memory Structure

  • Stack

  • Free Memory

  • Heap

  • Static

  • Code

4
New cards

Code contents

Generated target code

5
New cards

Static contents

Global constants and some objects

6
New cards

Stack contents

Stores activation records during procedure calls and starts from a higher address, growing downwards

7
New cards

Heap contents

Stores dynamically allocated data and starts from a lower address before growing upwards

8
New cards

Objects Storage

Stored in consecutive bytes, assigned the address of the first byte. Have to be allocated enough memory to hold them.

9
New cards

Stack

Where local variables are stored inside when the procedure containing the variable is called, then removed from the stack when the procedure finishes

10
New cards

Heap

Variables are stored in here when they outlive a procedure call and are manually de-allocated/garbage collected.

11
New cards

Activation Records/Stack Frames

Pushed onto the stack every time a function is called, and popped when a function returns

12
New cards

Stack Frame Contents

  • Local variables

  • Parameters

  • Return Addresses

  • Other temporaries

13
New cards

Stack pointer

Identifies where the current stack frame is on the stack

14
New cards

Access Link

Stores a link to the closest function surrounding a given function.

15
New cards

Stack Frame Layout

  • Data communicated between caller and callee placed at the bottom of the calleeā€™s record

    • Parameters, return address, return value

  • Fixed-length variables in the middle

  • Variables for which the size is unknown are placed at the end

    • Dynamically sized array

16
New cards

In a calling sequence

  • Caller can store the parameters and return addresses onto the stack - gives control to the callee

    • Value of the program counter, gives control to the callee.

  • Callee saves register values and other status information

  • Callee initialises its local data, begins execution

17
New cards

In a return sequence

  • Callee can store the return value

  • Callee restores old register values

  • Callee jumps to the return address

18
New cards

Memory Manager

Keeps track of free memory

19
New cards

Memory Manager - Requesting Memory

  • Tries to produce some contiguous chunk of free memory

  • If not possible, requests more memory from the OS

  • If not possible, an error is returned

20
New cards

Memory Manager - Program Freeing Memory

  • Returns that memory to the pool of free memory

  • If the OS increased the memory, it is not returned to the OS

21
New cards

Memory Manager - Desired Properties

  • Space efficiency

  • Program efficiency

  • Low overhead

22
New cards

Further Consideration

  • Exploiting locality

  • Reduce fragmentation

  • Garbage Collection

23
New cards

Mark and sweep

Mark all unreachable objects, sweep the entire heap to free them up

24
New cards

Mark and compact

Move reachable objects to eliminate memory fragmentation.