Secrets of the Glasgow Haskell Compiler inliner

Higher-order languages such as Haskell encourage the programmer to build abstractions by composing functions. A good compiler must inline many of these calls to recover an efficiently executable program. In principle, inlining is dead simple: just replace the call of a function by an instance of its body. But any compiler-writer will tell you that inlining is a black art, full of delicate compromises that work together to give good performance without unnecessary code bloat. The purpose of this paper is, therefore, to articulate the key lessons we learned from a full-scale “production” inliner, the one used in the Glasgow Haskell compiler. We focus mainly on the algorithmic aspects, but we also provide some indicative measurements to substantiate the importance of various aspects of the inliner.

[1]  Andrew W. Appel,et al.  Compiling with Continuations , 1991 .

[2]  Simon Peyton Jones,et al.  The Implementation of Functional Programming Languages (Prentice-hall International Series in Computer Science) , 1987 .

[3]  de Ng Dick Bruijn,et al.  A survey of the project Automath , 1980 .

[4]  Brian T. Howard Inductive, coinductive, and pointed types , 1996, ICFP '96.

[5]  Keith D. Cooper,et al.  Unexpected side effects of inline substitution: a case study , 1992, LOPL.

[6]  Simon Peyton Jones,et al.  Measuring the effectiveness of a simple strictness analyser , 1993, Functional Programming.

[7]  Andrew W. Appel,et al.  Shrinking lambda Expressions in Linear Time , 1997, J. Funct. Program..

[8]  Lennart Augustsson,et al.  Functional Pearl: On generating unique names , 1994, Journal of Functional Programming.

[9]  Manuel Serrano Inline Expansion: When and How? , 1997, PLILP.

[10]  Olivier Danvy,et al.  Lambda-dropping: transforming recursive equations into programs with block structure , 1997, Theor. Comput. Sci..

[11]  Craig Chambers,et al.  The design and implementation of the self compiler, an optimizing compiler for object-oriented programming languages , 1992 .

[12]  Keith D. Cooper,et al.  An experiment with inline substitution , 1991, Softw. Pract. Exp..

[13]  Scott A. Mahlke,et al.  Profile‐guided automatic inline expansion for C programs , 1992, Softw. Pract. Exp..

[14]  S. Jones,et al.  A Transformation-Based Optimiser for Haskell , 1998, Sci. Comput. Program..

[15]  Jack W. Davidson,et al.  Subprogram Inlining: A Study of its Effects on Program Execution Time , 1992, IEEE Trans. Software Eng..

[16]  André L. M. Santos,et al.  Compilation by transformation in non-strict functional languages , 1995 .

[17]  R. K. Dybvig,et al.  Fast and Eeective Procedure Inlining , 1997 .

[18]  Philip J. Fleming,et al.  How not to lie with statistics: the correct way to summarize benchmark results , 1986, CACM.

[19]  Nick Benton,et al.  Compiling standard ML to Java bytecodes , 1998, ICFP '98.

[20]  Zhong Shao,et al.  Implementing typed intermediate languages , 1998, ICFP '98.

[21]  Andrew W. Appel Loop Headers in Lambda-Calculus or CPS , 1994, LISP Symb. Comput..

[22]  Will Partain,et al.  The nofib Benchmark Suite of Haskell Programs , 1992, Functional Programming.

[23]  Simon L. Peyton Jones,et al.  Let-floating: moving bindings to give faster programs , 1996, ICFP '96.

[24]  Andrew W. Appel Loop headers in λ-calculus or CPS , 1994 .

[25]  Olivier Danvy,et al.  Lambda-dropping: transforming recursive equations into programs with block structure , 1997 .

[26]  Simon L. Peyton Jones,et al.  The Implementation of Functional Programming Languages , 1987 .

[27]  Henry G. Baker,et al.  Inlining semantics for subroutines which are recursive , 1992, SIGP.

[28]  R. Kent Dybvig,et al.  Fast and Effective Procedure Inlining , 1997, SAS.

[29]  Henk Barendregt,et al.  The Lambda Calculus: Its Syntax and Semantics , 1985 .

[30]  Simon L. Peyton Jones,et al.  Once upon a polymorphic type , 1999, POPL '99.