topic 5: activation records - princeton university computer science · 2018. 5. 1. · activation...

28
1 Topic 5: Activation Records COS 320 Compiling Techniques Princeton University Spring 2018 Prof. David August

Upload: others

Post on 24-Jan-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

1

Topic 5: Activation Records

COS 320

Compiling Techniques

Princeton University Spring 2018

Prof. David August

Page 2: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

2

Activation Records

Page 3: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

3

The Stack

Page 4: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

4

Example

Page 5: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

5

Example

Page 6: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

6

Example

Page 7: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

7

Recursive Example

Page 8: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

8

Recursive Example

Page 9: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

9

Recursive Example

Page 10: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

10

Functional Languages

Page 11: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

11

Functional Languages

Page 12: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

12

Functional Languages

Page 13: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

13

Stack Frame Organizations

Page 14: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

14

Typical Stack Frame

Page 15: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

15

Stack Frame Example

Page 16: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

16

Stack Frame Example

Page 17: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

17

Stack Frame Example

Page 18: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

18

Parameter Passing

Page 19: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

19

Parameter Passing

Page 20: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

20

Registers

Page 21: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

21

Registers

Page 22: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

22

Registers

Page 23: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

23

Return Address and Return Value

Page 24: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

24

Frame Resident Variables

Page 25: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

25

Static Links

Page 26: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

26

Static Links

Page 27: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

27

Static Links

Page 28: Topic 5: Activation Records - Princeton University Computer Science · 2018. 5. 1. · Activation records must be allocated on heap, not stack. Concentrate on languages which use

28

Static Links