Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Contents. 2 Run-Time Storage Organization 3 Static Allocation In many early languages, notably assembly and FORTRAN, all storage allocation is static.

Similar presentations


Presentation on theme: "1 Contents. 2 Run-Time Storage Organization 3 Static Allocation In many early languages, notably assembly and FORTRAN, all storage allocation is static."— Presentation transcript:

1 1 Contents

2 2 Run-Time Storage Organization

3 3 Static Allocation In many early languages, notably assembly and FORTRAN, all storage allocation is static. In many early languages, notably assembly and FORTRAN, all storage allocation is static. Space for data objects is allocated in a fixed location for the lifetime of a program. Space for data objects is allocated in a fixed location for the lifetime of a program. The number and size of all objects to be allocated is known at compile-time. The number and size of all objects to be allocated is known at compile-time. Static allocation is used both for global variables and constants. Static allocation is used both for global variables and constants. Static allocation is also used for local variables, e.g., static and extern in C Static allocation is also used for local variables, e.g., static and extern in C Disadvantage Disadvantage Wasteful of space Wasteful of space

4 4 Stack Allocation (Cont’d.) Recursive procedures, a feature that requires dynamic allocation. Recursive procedures, a feature that requires dynamic allocation. Each recursive call requires the allocation of a new copy of a procedure’s local variables. Each recursive call requires the allocation of a new copy of a procedure’s local variables. The number of data objects required during program execution is not known at compile-time. The number of data objects required during program execution is not known at compile-time. Activation record (AR) Activation record (AR) An AR is used to store all the data space required for a procedure or function. An AR is used to store all the data space required for a procedure or function. An AR is pushed onto a run-time stack when the procedure or function is called An AR is pushed onto a run-time stack when the procedure or function is called When is subporgram returns, the AR is popped. When is subporgram returns, the AR is popped.

5 5 Stack Allocation (Cont’d.)

6 6

7 7 Dynamic arrays Dynamic arrays The bounds of dynamic arrays are determined at run-time rather than compile-time, hence these arrays cannot be allocated within an AR. The bounds of dynamic arrays are determined at run-time rather than compile-time, hence these arrays cannot be allocated within an AR. Dynamic arrays can be allocated as soon as their associated declarations are elaborated. Dynamic arrays can be allocated as soon as their associated declarations are elaborated.

8 8 Stack Allocation (Cont’d.)

9 9

10 10 Stack Allocation (Cont’d.)

11 11 Stack Allocation (Cont’d.)

12 12 Stack Allocation (Cont’d.)

13 13 Stack Allocation (Cont’d.)

14 14 Stack Allocation (Cont’d.)

15 15 Stack Allocation (Cont’d.)

16 16 Stack Allocation (Cont’d.)

17 17 Heap Allocation

18 18 Heap Allocation (Cont’d.) Three methods for deallocation Three methods for deallocation No deallocation No deallocation Explicit deallocation Explicit deallocation

19 19 Heap Allocation (Cont’d.)

20 20 Program Layout in Memory

21 21 Program Layout in Memory (Cont’d.)

22 22 Static and Dynamic Chains

23 23 Static and Dynamic Chains (Cont’d.)

24 24 Formal Procedures

25 25 Formal Procedures (Cont’d.)

26 26 Formal Procedures (Cont’d.)

27 27 Formal Procedures (Cont’d.)

28 28 Formal Procedures (Cont’d.)

29 29 Formal Procedures (Cont’d.)

30 30 Chapter 10 Processing Declarations Declaration Processing Fundamentals Declaration Processing Fundamentals Action Routines for Simple Declarations Action Routines for Simple Declarations Action Routines for Advanced Features Action Routines for Advanced Features

31 31 Chapter 11 Processing Expressions and Data Structure References Action Routines for Simple Names, Expressions, and Structures Action Routines for Simple Names, Expressions, and Structures Array References and Records Array References and Records Action Routines for Advantage Features Action Routines for Advantage Features

32 32 Chapter 12 Translating Control Structures if Statements if Statements loops loops while loops while loops for loops for loops The case Statement The case Statement Short-circuit Boolean Expressions Short-circuit Boolean Expressions

33 33 Chapter 13 Translating Procedures and Functions Simple Subprograms Simple Subprograms Passing Parameters to Subprograms Passing Parameters to Subprograms Processing Subprogram Calls and Parameter Lists Processing Subprogram Calls and Parameter Lists Subprogram Invocation Subprogram Invocation


Download ppt "1 Contents. 2 Run-Time Storage Organization 3 Static Allocation In many early languages, notably assembly and FORTRAN, all storage allocation is static."

Similar presentations


Ads by Google