Control ow analysis : a compilation paradigm for functional languageManuel

Revised version of "SAC 95" 31/08/95] Abstract Control ow analysis (cfa) is now well known but is not widely used in real compilers since optimizations that can be achieved via cfa are not so clear. This paper aims at showing that control ow analysis is very valuable in practice by presenting a fundamental optimization based on cfa: the closure representation algorithm, the essential optimizing phase of a-language compiler. Since na ve and regular scheme to represent functions as heap allocated structures is far too ineecient, the main eeort of modern functional languages compilers is devoted to minimize the amount of memory allocated for functions. In particular, compilers try to discover when a procedure can safely be handled without any allocation at all. Previously described methods to do so are ad hoc, depending on the language compiled, and not very precise. Using cfa, we present a general approach which produces better results. This reened closure analysis subsumes previously known ones and optimizes more than 80 % of closure on the average. We also present another analysis based on cfa which is useful for dynamically typed languages: the type investigation algorithm. Modifying Shivers' cfa, we realized a type inference algorithm that eliminates more than 60 % of dynamic type tests. These two optimizations are fully integrated into a real compiler, so that we can report reliable measures obtained for real world programs. Time gures show that analyses based on cfa can be very eecient: when the compiler uses the improved closure allocation scheme and the type investigation algorithm, the resulting executable programs run more than two time faster.