Posted on January 6, 2018

Compiler Construction Example Sheet IV

  1. This question is about function inlining. It is a common optimisation and most C implementations have directives for it. How can it adversely affect computation time? What sort of functions would be ideal candidates for inlining? (Hint: remember computer design lectures)

  2. What is the scope of peephole optimisations? What are the other class of optimisations and rank them in difficulty with brief justification to your ranking. Give five examples of peephole optimisations.

  3. In C, when you are allocating memory with malloc you need to pass the size of the memory you want to be allocated and the routine returns a pointer. When you later want to free this memory you use the free routine and only pass the pointer. How come libc knows how much memory to deallocate?

  4. After reviewing lecture notes on garbage collection, read Bacon et al. (2004) up to and including section 4.

  5. Cycles in reference counting is a well-known problem. Briefly explain the problem. Suggest a way to solve it without completely changing to a different garbage collection algorithm.

  6. From Mogensen (2009, chap. 13), solve Exercise 13.2.

  7. 2017/3/3

Bacon, D.F., Cheng, P., Rajan, V., 2004. A unified theory of garbage collection. ACM SIGPLAN Notices 39, 50–68.

Mogensen, T.Æ., 2009. Basics of compiler design. Torben Ægidius Mogensen.