SlideShare ist ein Scribd-Unternehmen logo
1 von 14
1.Explain the different phases of a Compiler. Compiler: Compiler is a program which translates a program written in one language (Source language) to an equivalent program in other language (the target language). Source program-CompilerTarget program Compiler is  a Software for translating high level language (HLL) to machine level language. It is nothing but a translator and it should know both the high level language and the architecture of the computer. Most of the compilers are machine dependant but some compilers are machine independent. Eg: java. Turbo C, common for both C & C++ Need for a Compiler: We need Compilers, because the source program does not understand by the Computer. So, it has to convert into machine understandable language. So we use Compilers for this purpose. We cannot use the same compiler for all computers. Because every HLL has its own syntaxes. Phases of a Compiler: A Compiler takes as input a source program and produces as output an equivalent Sequence of machine instructions. This process is so complex that it is divided into a series of sub process called Phases. The different phases of a compiler are as follows Analysis Phases :        1. Lexical Analysis                                      2. Syntax Analysis                                      3. Semantic Analysis Synthesis Phases:      4.Intermediate Code generator                                       5. Code Optimization                                       6. Code generation. 1. Lexical Analysis: It is the first phase of a Compiler. Lexical analyzer or Scanner reads the characters in the source program and groups them into a stream of tokens. The usual tokens are identifiers, keywords, Constants, Operators and Punctuation Symbols such as Comma and Parenthesis. Each token is a Sub-String of the source program that is to be treated as a single unit. Tokens are of two types: ,[object Object]
Classes of Strings Eg: identifier, Constants, Label.A token is treated as a pair consisting of two parts. ,[object Object]
Token Value. The character sequence forming a token is called the lexeme for the token. Certain tokens will be increased by a lexical value. The lexical analyser not only generates a token, but also it enters the lexeme into the symbol table.             Symbol table ,[object Object]
b
cToken values are represented by pairs in square brackets. The second component of the pair is an index to the symbol table where the information’s are kept.  For eg., Consider the expression a = b + c * 20 After lexical Analysis it will be. id1 = id2 + id3 *20 The lexical phase can detect errors where the characters remaining in the input do not form any token of the language. Eg: Unrecognized Keyword. 2. Syntax Analysis: It groups tokens together into Syntactic Structures called an Expression. Expressions might further be combined to form statements. Often the syntactic structure can be regarded as a tree where leaves are tokens, called as parse trees. The parser has two functions. It checks if the tokens, occur in pattern that are permitted by the specification of the source language. Ie., Syntax checking. For eg., Consider the expire the each position A+/B. After lexical Analysis this will be, as the token sequence id+/id in the Syntax analyzer. On seeing / the syntax analyzer should detect an error. Because the presence of two adjacent binary operators violates the formulation rules. The second aspect is to make explicit the hierarchical Structure of incoming token stream by identifying which parts of the token stream should be  grouped. The Syntax analysis can detect syntax errors.  Eg., Syntax error. 3.Semantic Analysis: An important role of semantic analysis is type checking. Here the computer checks that the each operator has operands that are permitted by the source language specification. Consider the eg:  x= a+b Diagram The language specification may permit some operand coercions. For eg: When a binary arithmetic operator is applied to an integer and real. In this case, the compiler array need to convert the integer to a real. In this phase, the compiler detects type mismatch error. 4. Intermediate Code generation: It uses the structure produced by the syntax analyzer to create a stream of simple instructions. Many styles are possible. One common style uses instruction with one operator and a small number of operands. The output of the previous phase is some representation of a parse tree. This phase transforms this parse tree into an intermediate language. One popular type of intermediate language is called Three address code. A typical three- address code statement is A = B op C. Where A, B, C are operands. OP is a binary Operator. Eg: A = B + c * 20 Here, T1, T2, T3 are temporary variables. Id1, id2, id3 are the identifiers corresponding to A, B, C. 5. Code Optimization: It  is designed to improve the intermediate code. So that the  Object program less space. Optimization may involve: 1. Detection & removal of dead code. 2. Calculation of constant expressions & terms. 3. Collapsing of repeated expressions into temporary storage. 4. Loop unrolling. 5. Moving code outside the loops. 6. Removal of unnecessary temporary-variables. For e.g.: A: = B+ C * 20 will be T1 = id3 * 20.0 Id1 = id2 + T1 6. Code generation: Once optimizations are completed, the intermediate code is mapped into the target languages. This involves, Allocation of registers & memory Generation of connect references. Generation of correct types. Generation of machine code. Eg:   MOVF   id3, R2          MULF # 20.0, R2         MOVF id2, R1        ADDF R2, R1       MOVF R1, id1. 2.Compiler Construction Tools: A number of tools have been developed for helping implement various phases of a compiler. Some useful compiler construction tools are a follow, 1.Parser generators. 2.Scanner generators. 3.Syntax Directed Translation Engines. 4.Automatic Code generators. 5.Data flow engines. 1.Parser Generators: These produce syntax analyzers, normally from input that is based on a context-free grammar. In early compilers, Syntax analysis not only consumed a large function of the running time of a compiler, but a large fraction of the interrectual effort of writing a compiler. This phase is very easy to implement. Many parser generations utilize powerful parsing algorithms that are too complex to be carried. 2.Scanner Generators: These automatically generate lexical analyzers, normally from a specification based on regular expressions. The basic organization of the resulting lexical analyzer is in effect a finite automation. 3.Syntax – Directed Translation Engines: These produce collection of routines that walk the parse tree such as intermediate code. The basic idea is that one or more translations are associated with each node of the parse tree. Each translation is defined in terms of translations at its neighbour nodes in the tree. 4.Automatic Code Generators: This tool takes a collection of rules that define the translation of each operation of the intermediate language into the machine language for the target machine. The rules must include sufficient detail that we can handle the different possible access methods for data, Eg. Variables may be in registers, in a fixed location in memory or may be allocated a position on a stack. The basic technique is “template matching”. The intermediate code statements are replaced by templates. That  templates represent sequences of machine instructions. The assumptions about storage of variables match from template to template. 5.Data Flow Engines: Much of the information needed to perform good code optimization involves “data flow analysis”. The gathering of information about how values are transmitted from one part of a program to each other part. 3.Issues in the design of a Code Generator: Since the code generation phase is system dependent, the following issues arises during the code generation. ,[object Object]
Target  Program.
Memory Management.
Instruction Selection.
Register Allocation.
Evaluation Order.1.Input to the code generator: It is an intermediate code that may be of several forms. ,[object Object]
Three-address representation-quadruples
Virtual machine representation-stack machine code.
Graphical representation-syntax tree, dags.The intermediate language can be represented by quantities that the target machine can directly manipulate. By inserting type – conversion operations, the type – checking has to be taken place and the semantic errors have to be detected already.  Thus the input to the code generator. Must be free of errors. 2.Target Programs: The output of the code generator is the target program that may be of several forms. ,[object Object]
Relocatable machine language

Weitere ähnliche Inhalte

Was ist angesagt?

Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
Sumit Sinha
 
Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1
bolovv
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recovery
Tech_MX
 

Was ist angesagt? (20)

Lecture1 introduction compilers
Lecture1 introduction compilersLecture1 introduction compilers
Lecture1 introduction compilers
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler design
 
Compilers
CompilersCompilers
Compilers
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Cs6660 compiler design
Cs6660 compiler designCs6660 compiler design
Cs6660 compiler design
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
 
Ch1
Ch1Ch1
Ch1
 
Compiler design
Compiler designCompiler design
Compiler design
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
 
Chapter 1 1
Chapter 1 1Chapter 1 1
Chapter 1 1
 
Passes of compilers
Passes of compilersPasses of compilers
Passes of compilers
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recovery
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Compiler
CompilerCompiler
Compiler
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
 
Introduction to Compiler Construction
Introduction to Compiler Construction Introduction to Compiler Construction
Introduction to Compiler Construction
 

Ähnlich wie Compiler Design Material

2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
venkatapranaykumarGa
 
Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02
Anil Thakral
 
Language translators
Language translatorsLanguage translators
Language translators
Aditya Sharat
 

Ähnlich wie Compiler Design Material (20)

Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
 
Assignment1
Assignment1Assignment1
Assignment1
 
3.2
3.23.2
3.2
 
unit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdfunit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdf
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptx
 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdf
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 
Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
Language translators
Language translatorsLanguage translators
Language translators
 
How a Compiler Works ?
How a Compiler Works ?How a Compiler Works ?
How a Compiler Works ?
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Code generation errors and recovery
Code generation errors and recoveryCode generation errors and recovery
Code generation errors and recovery
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
System software module 4 presentation file
System software module 4 presentation fileSystem software module 4 presentation file
System software module 4 presentation file
 
SSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdfSSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdf
 
Ch 1.pptx
Ch 1.pptxCh 1.pptx
Ch 1.pptx
 

Mehr von Dr. C.V. Suresh Babu

Mehr von Dr. C.V. Suresh Babu (20)

Data analytics with R
Data analytics with RData analytics with R
Data analytics with R
 
Association rules
Association rulesAssociation rules
Association rules
 
Clustering
ClusteringClustering
Clustering
 
Classification
ClassificationClassification
Classification
 
Blue property assumptions.
Blue property assumptions.Blue property assumptions.
Blue property assumptions.
 
Introduction to regression
Introduction to regressionIntroduction to regression
Introduction to regression
 
DART
DARTDART
DART
 
Mycin
MycinMycin
Mycin
 
Expert systems
Expert systemsExpert systems
Expert systems
 
Dempster shafer theory
Dempster shafer theoryDempster shafer theory
Dempster shafer theory
 
Bayes network
Bayes networkBayes network
Bayes network
 
Bayes' theorem
Bayes' theoremBayes' theorem
Bayes' theorem
 
Knowledge based agents
Knowledge based agentsKnowledge based agents
Knowledge based agents
 
Rule based system
Rule based systemRule based system
Rule based system
 
Formal Logic in AI
Formal Logic in AIFormal Logic in AI
Formal Logic in AI
 
Production based system
Production based systemProduction based system
Production based system
 
Game playing in AI
Game playing in AIGame playing in AI
Game playing in AI
 
Diagnosis test of diabetics and hypertension by AI
Diagnosis test of diabetics and hypertension by AIDiagnosis test of diabetics and hypertension by AI
Diagnosis test of diabetics and hypertension by AI
 
A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”
 
A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Compiler Design Material

  • 1.
  • 2.
  • 3.
  • 4. b
  • 5.
  • 10.
  • 13.
  • 15.
  • 16.
  • 17. Call –by – reference
  • 18. Copy – by – Restore
  • 19. Call – by – Name1.Call – by – Value: Call – by – value is the simplest method of passing parameters. The actual parameters are evaluated and their r – values are passed to the called procedure. This method is used in pascal and C. l- value: It refers to the storage represented by an expression. r-value: It refers to the value contained in the storage. Call – by – value can be implemented as follows: (i)A formal parameter to treated just like a local name, So the storage for the formals is in the activation record of the called procedure. (ii)The caller evaluates the actual parameters and places their r-values in the storage for the formals. 2.Call – by – reference: This method is otherwise called as call-by-address or call-by-location. The caller passes a pointer to each location of actual parameters. It an actual parameter is a name or an expression having an l-value then that l-value itself is passed. However, if the actual parameter is an expression like a +b or 5, that has no l-value, than the expression is evaluated in a new location and the address of that location is passed. 3.Copy – Restore: This method is a hybrid between Call – by – value and Call – by – reference. This is also known as copy – in – copy – out or value reset. This Calling procedure calculates the value of the actual parameter and it is then copied to activation record for the called procedure. The l – values of these actual parameters having l-values are determined before the call. When control returns, the current r- values of the formal parameters are copied back into the l-values of the actual, using the i-values computed before the call. 4. Call – by – Name: This procedure is treated like a macro, that is, its body is substituted for the call in the caller, with the actual parameters literally substituted for the formals. Such a literal substitution is called macro- expansion or in- line expansion. The local names of the called procedure are kept distinct from the names of the calling procedure. The actual parameters are surrounded by parenthesis if necessary to presence their integrity. 6.Storage allocation strategies: A different storage – allocation strategy is used in run – time memory organization. They are, 1.Static allocation: Lays out storage at compile time for all data objects. 2.Stack allocation: Manages the run time storage. 3.Heap allocation: Allocates and de-allocates storage as needed at run time from heap. These allocation strategies are applied to allocate memory for activation records. Different languages use different strategies for this purpose. For eg: FORTRANStatic allocation Algol Stack allocation LISP Heap allocation 1.Static allocation: The fundamental characteristics of static allocation are as follows: (i)Name binding occurs during compilation there is no need for a run-time support package. (ii)Bindings do not change at run time. (iii)On every invocation of procedure, its names are bound to the same storage locations. When control returns to a procedure, the values of the locals are the same as they were when control left the last time.(ie., this property allows the values of local names to be retained across activations of a procedure). Eg: Function F() { int a; Print (a); a=10; } After calling F() once, if it was called a second time, the value of ‘a’ would initially be 10, and this will be printed. (iv)The type of a name determines its storage requirement. The address for this storage is an offset from the procedures activation record and the compiler must decide where the activation records go, relative to the target code and to one another. After this position has been decided, the address of the activation records and hence of the storage for each name in the records are fixed. Thus at compile time, the addresses at which the target code can find the data it operates upon can be filled in. The addresses at which information is to be saved when a procedure call takes places are also known at compile time. Static allocation have some limitations are: (i)Size of data objects, as well as any constraints on their positions in memory, must be available at compile time. (ii)No recursion, because all activations of a given procedure use the same bindings for local names. (iii)No dynamic data structures, since no mechanism is provided for run-time storage allocation. 2.Stack allocation: It is based on the idea of a control stack. Storage is organized as stack, and activation records are pushed and popped as activations begin and end respectively. Storage for the locals in each call of a procedure is contained in the activation record for that call. Thus locals are bounds to fresh storage in each activation, because a new activation record is pushed on to the stack when a call is made. The values of locals are deleted when the activation ends. ie., the values are lost because the storage for locals disappears when the activation record is popped. Eg: Activation tree, DIAGRAM Calling Sequences: A call sequence allocates an activation records and enters information into its fields. A return sequences and activation records differ, even for the same language. The code in the calling sequence is often divided between the calling procedure and the procedure it calls. There is no exact division of run time tasks between the caller and the callee. DIAGRAM The register stack top points to the end of the machine status field in the activation records. This position is known to the Caller, So it can be made responsible for setting up stack top before control flows to the called procedure. This code for the callee can access its temporaries and the local data using offsets from stack top. The call sequence is: Caller: Evaluates actual Stores return address & old values of top-SP Increments top-SP Callee: Saves register values & other status information. Initializes local data & begins execution. The return sequence is Callee: Places return value next to callers Activation Record. Restores top-SP & other registers. Branches to return address. Caller: Copies returned value into its own Activation Record. Limitations of Stack allocation: Values of locals cannot be retained when activation ends. A called activation cannot outlive the caller. 3. Heap Allocation: Limitations of stack allocation are mentioned already, in those cases de-allocation of Activation records cannot occur in last in first out fashion. Heap gives out pieces of contiguous storage for activation records. Pieces may be de-allocated in any order over time the heap will consist of alternate areas that are free and in use. Heap manager is supposed to make use of the free space. For efficiency reasons it may be helpful to handle small activations as a special case. For each size of interest keep a linked list of tree blocks of that size. Fill a request of size S with block of size S where S is the smallest size greater than or equal to S. DIAGRAM For large blocks of storage use heap manager. For large amount of storage computation may take some time to use up the memory So that time taken by the manager be negligible compared to the computation. Heap manage will dynamically allocate memory. This will come a run time overhead. As heap manager will have to take care of defragmentation and garbage collection.