- Mention the issues to be considered while applying the techniques for code optimization.
- · The semantic equivalence of the source program must not be changed.
- · The improvement over the program efficiency must be achieved without changing the algorithm of the program.
- · The machine dependent optimization is based on the characteristics of the target machine for the instruction set used and addressing modes used for the instructions to produce the efficient target code.
- · The machine independent optimization is based on the characteristics of the programming languages for appropriate programming structure and usage of efficient arithmetic properties in order to reduce the execution time.
- · Available expressions
- · Reaching definitions
- · Live variables
- · Busy variables
- What are the basic goals of code movement?
- To reduce the size of the code i.e. to obtain the space complexity.
- To reduce the frequency of execution of code i.e. to obtain the time complexity.
- What do you mean by machine dependent and machine independent optimization?
- What are the different data flow properties?
- List the different storage allocation strategies.
The strategies are:
- · Static allocation
- · Stack allocation
- · Heap allocation
- What are the contents of activation record?
The activation record is a block of memory used for managing the information needed by a single execution of a procedure. Various fields f activation record are:
- · Temporary variables
- · Local variables
- · Saved machine registers
- · Control link
- · Access link
- · Actual parameters
- · Return values
- What is dynamic scoping?
In dynamic scoping a use of non-local variable refers to the non-local data declared in most recently called and still active procedure. Therefore each time new findings are set up for local names called procedure. In dynamic scoping symbol tables can be required at run time.
- Define symbol table.
Symbol table is a data structure used by the compiler to keep track of semantics of the variables. It stores information about scope and binding information about names.
- What is code motion?
Code motion is an optimization technique in which amount of code in a loop is decreased. This transformation is applicable to the expression that yields the same result independent of the number of times the loop is executed. Such an expression is placed before the loop.
- What are the properties of optimizing compiler?
The source code should be such that it should produce minimum amount of target code.
There should not be any unreachable code.
Dead code should be completely removed from source language.
The optimizing compilers should apply following code improving transformations on source language.
i) common subexpression elimination
ii) dead code elimination
iii) code movement
iv) strength reduction
- What are the various ways to pass a parameter in a function?
- · Call by value
- · Call by reference
- · Copy-restore
- · Call by name
- Suggest a suitable approach for computing hash function.
Using hash function we should obtain exact locations of name in symbol table.
The hash function should result in uniform distribution of names in symbol table.
The hash function should be such that there will be minimum number of collisions. Collision is such a situation where hash function results in same location for storing the names.
No comments:
Post a Comment