EECS 665 Compiler Construction 1
Concepts Introduced in Chapter 7
- Storage Allocation Strategies
– Static – Stack – Heap
- Activation Records
- Access to Nonlocal Names
– Access links
followed by Fig. 7.1
Concepts Introduced in Chapter 7 Storage Allocation Strategies - - PowerPoint PPT Presentation
Concepts Introduced in Chapter 7 Storage Allocation Strategies Static Stack Heap Activation Records Access to Nonlocal Names Access links followed by Fig. 7.1 1 EECS 665 Compiler Construction Activation Records An
EECS 665 Compiler Construction 1
– Static – Stack – Heap
– Access links
followed by Fig. 7.1
EECS 665 Compiler Construction 2
– Static data: FORTRAN – Stack: ALGOL, C, Pascal, Ada, C++ – Heap: Functional Languages
followed by Fig. 7.2, 7.3, 7.4
EECS 665 Compiler Construction 3
followed by Fig. 7.5
EECS 665 Compiler Construction 4
– caller assigns the actual arguments. – caller stores return address. – caller jumps to callee. – callee adjusts stack pointer for the activation record. – callee saves nonscratch register values it will use.
– callee assigns the return value. – callee restores nonscratch register values and stack pointer address. – callee jumps to the return address. – caller accesses the return value.
EECS 665 Compiler Construction 5
– Restrictions
EECS 665 Compiler Construction 6
– Activation record is pushed on as function is entered. – Activation record is popped off as function is exited. – Restrictions
followed by Fig. 7.6, 7.7
EECS 665 Compiler Construction 7
– stack pointer, frame pointer, return address
– callee save, caller save
– through registers, on the stack
followed by Fig. 7.8
EECS 665 Compiler Construction 8
EECS 665 Compiler Construction 9
– Most flexible – Most inefficient
EECS 665 Compiler Construction 10 10
– used in Pascal, Ada, C, C++ – complicates programming
– used in Lisp and Java – reference counts – mark and sweep (garbage collection)
EECS 665 Compiler Construction 11 11
– The scope of a declaration in a block B includes B. – If a name X is not declared in a block B, then an
EECS 665 Compiler Construction 12 12
EECS 665 Compiler Construction 13 13
EECS 665 Compiler Construction 14 14
followed by Fig. 7.10
EECS 665 Compiler Construction 15 15
– Np is the nesting depth of procedure p that refers to a
– Na is the nesting depth of procedure that contains a.
followed by Fig. 7.11, 7.12, 7.13
EECS 665 Compiler Construction 16 16
– If Np < Nx
– If Np ≥ Nx
followed by Fig. 7.14