You are on page 1of 2

Compiler Optimizations

Quiz - 1
Time 10 minutes
Q1: True/False: Mark each question as true (T) or false (F). Each correct answer has one marks and
wrong answer has zero marks.
Total Marks: 15 (one bonus point)
1. It is impossible to know all the objects to be created during program execution, at the compile-time, for
all the programs.
T
2. Intra-procedural data-flow analysis is usually slower than inter-procedural data-flow analysis.

3. Inter-procedural data-flow analysis usually takes more memory than intra-procedural data-flow analysis.
T
4. Point of No return (PNR) can deallocate objects inside a loop and inside recursive method calls. F
5. Disconnect All Uses (DAU) can deallocate objects inside a loop and inside recursive method calls.

6. Offline-GC Data-flow analysis (OGC-DFA) group ALL the object created by a single new instructions
thus cannot differentiate between ten object created by a same new instruction. T
7. Finding the tail (FTT) cannot disconnect objects inside a loop or recursive method call. F
8. Finding the tail (FTT) uses method flow graph. T
9. Offline GC increases program speed because online garbage collection needs to be invoked fewer
number of time.
T
10. Offline GC replaces online garbage collection algorithm thus when Offline GC is used then online
garbage collection algorithm is never needed to be invoked.
F
11. A typical online GC cannot ALWAYS deallocate an object after a point after where it is last used in the
program and never be used again.
T

12. Offline GC cannot ALWAYS deallocate an object after a point after where it is last used in the program
and never be used again.

13. A typical online GC can NEVER deallocate an object after a point after where it is last used in the
program and never be used again. (ambiguous statement)
A typical online GC can NEVER deallocate an object after a point after where it is last used in the
program and never be used again, if that object is still reachable.
T
14. A reachable object is one that has been referred at least once from any other object.

15. A reachable object cannot be deallocated by a typical online garbage collection algorithm.
16. Offline GC may deallocate reachable objects too.

Question 2: In the flow graph below apply Point of No Return (PNR) algorithm and insert
OFFLINE_GC_FREE and OFFLINE_GC_NEW instructions. The graph shows new instruction and use of each
new instruction. For example a "Use of 1" means that a object created by the new instruction at location 1 is
being use. "New A" means that the instruction has created a new object of class A.
Total Marks: 5
Assumption: New instructions are added at the end of a block.

You might also like