run time storage organization l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Run-Time Storage Organization PowerPoint Presentation
Download Presentation
Run-Time Storage Organization

Loading in 2 Seconds...

play fullscreen
1 / 16

Run-Time Storage Organization - PowerPoint PPT Presentation


  • 150 Views
  • Uploaded on

Run-Time Storage Organization. 66.648 Compiler Design Lecture (03/23/98) Computer Science Rensselaer Polytechnic. Lecture Outline. Run-Time Storage Organization Examples Administration. Run-Time Storage Organization.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Run-Time Storage Organization' - annick


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
run time storage organization
Run-Time Storage Organization
  • 66.648 Compiler Design Lecture (03/23/98)
  • Computer Science
  • Rensselaer Polytechnic
lecture outline
Lecture Outline
  • Run-Time Storage Organization
  • Examples
  • Administration
run time storage organization3
Run-Time Storage Organization

A program obtains a single contiguous block of storage (virtual memory) from the operating system at the start of program execution. The generated code assumes a subdivision of the storage into different areas/

Code -- this area contains the generated target code for all procedures in the program. The size of this can be determined statically by the compiler/linker.

static data
Static Data

Static Data-- this area contains global data objects whose size can be determined statically at compile time. Static variables are mapped to offsets in the static data area.

stack
Stack

Stack--runtime stack of activation records reflecting the stack structure of dynamic procedure calls and returns. An activation record contains the information needed by a single procedure call. Local variables are mapped to offsets in the activation record.

slide6
Heap

Heap -- used to store all other program data (data that is dynamically sized or data with lifetime pattern that cannot be represented in the run-time stack). Heap data allocation incurs more overhead than static or stack data allocation.

languages and storage organization
Languages and Storage Organization
  • Fortran - Static
  • Pascal - Stack/heap
  • C Stack/Heap
activation record
Activation Record
  • Public class X {
  • public static void main(String argsv[]) {
  • int n;
  • n =10;
  • System.out.println(fib(n));
  • }
  • int fib(int n) {
  • if (n==0) return 1 else if (n==1) return 1 else return(fib(n-1)+fib(n-2)); }}
compile time layout of local data
Compile Time Layout of Local Data
  • Local variables offsets are calculated depending on its size. These offsets can be computed relative to the start of the stack frame, and can be used to specify the layout of local data in the stack frame.
  • Local variables accesses get translated to negative-valued offsets on the stack pointer.
non local variable
Non-Local Variable
  • An access to a lexically scoped nonlocal variable gets translated to <level-count,frame-offset>.
  • Level-count = k indicates that the variable can be found in the kth enclosing scope.
variable field of unknown size
Variable/Field of Unknown Size
  • How do we allocate storage for a variable/ field with statically unknown size e.g. an array or an adt (abstract Data Type).
  • By allocating storage separately (on the heap or on top of the AR on the stack) and storing a pointer to the storage in the AR.
other basic concepts in runtime structues
Other Basic Concepts in Runtime Structues
  • Call Sequence -- instruction Sequences that allocates AR for callee procedures and fills in some of the fields.
  • Return Sequence- instruction sequence that restores machine state so that caller procedure can continue execution.
  • Lexical scope -- Nonlocal names are resolved via static nesting.
  • Dynamic Scope: nonlocal names are resolved by inhering name bindings (following control links)
parameter passing
Parameter Passing
  • Call by value -- caller places r-value for actual parameter in the storage formal parameter.
  • Call by reference -- caller places l-value for actual parameter in the storage for formal parameter.
  • Call by value result -- caller places r-value for the actual parameter in the storage for formal parameter and also determines the l-value of the actual parameter. On return, the current r-value of the formal parameter is copied to the l-value of the actual parameter.
comments and feedback
Comments and Feedback
  • Project 3 is out. Please start working. PLEASE do not wait for the due date to come.
  • We are in chapter 8. Please read that chapter and read the relevant portion of Java. Please keep studying this material and work exercises.