DV1465 / DV1505 / DV1511:

Compiler and Interpreter Technology

13:15 Friday 8th April, 2016

Runtime memory organisation.

Table of Contents
Data and MemoryProcedure Activations
Issues in the runtimeStack Organisation
Runtime techniquesCall Sequences

1. Roadmap type stuff

2. The Program and the Machine

3. Runtime issues: naming

4. Runtime issues: change

5. Runtime issues: lifetimes

6. Runtime issues: fixed / static / dynamic

7. Runtime techniques: precompute offsets

8. Runtime techniques: managing the heap

9. Runtime techniques: partition the space

Testing for real

10. Runtime techniques: handles

11. Runtime techniques: handles

12. Runtime techniques: garbage collection

13. Runtime techniques: garbage collection

14. Summary of runtime

Break (15mins)





Intermission

15. Procedure calls

16. Activation Trees

function fib(n) if n<3 then return 1 else return fib(n-1) + fib(n-2) end end .... some initial call n=4 ....

17. Activation Trees as traces

18. Paths in the tree are stacks

19. Activation Records (general theory)

20. Activation Records (SYS V on x86_64)

21. Example Call Sequence

long f1(long a, long b, long c, long d) { long x=a*b, y=c*d; return f2(x,y); }
f1: pushq %rbp movq %rsp, %rbp ...

22. Example Call Sequence

subq $48, %rsp movq %rdi, -24(%rbp) movq %rsi, -32(%rbp) movq %rdx, -40(%rbp) movq %rcx, -48(%rbp) movq -24(%rbp), %rax imulq -32(%rbp), %rax movq %rax, -8(%rbp) movq -40(%rbp), %rax imulq -48(%rbp), %rax movq %rax, -16(%rbp)

23. Example Call Sequence

movq -16(%rbp), %rdx movq -8(%rbp), %rax movq %rdx, %rsi movq %rax, %rdi call f2 leave ret

24. More complex frames

25. Security Issues: return addresses

26. Security Issues: buffer overruns

27. Summary

28. Final Thoughts