Flattening tuples in an SSA intermediate representation

For functional programs, unboxing aggregate data structures such as tuples removes memory indirections and frees dead components of the decoupled structures. To explore the consequences of such optimizations in a whole-program compiler, this paper presents a tuple flattening transformation and a framework that allows the formal study and comparison of different flattening schemes.We present our transformation over functional SSA, a simply-typed, monomorphic language and show that the transformation is type-safe. The flattening algorithm defined by our transformation has been incorporated into MLton, a whole-program, optimizing compiler for SML. Experimental results indicate that aggressive tuple flattening can lead to substantial improvements in runtime performance, a reduction in code size, and a decrease in total allocation without a significant increase in compilation time.

[1]  John C. Reynolds,et al.  Definitional Interpreters for Higher-Order Programming Languages , 1972, ACM '72.

[2]  Olin Shivers,et al.  Control flow analysis in scheme , 1988, PLDI '88.

[3]  Greg Morrisett,et al.  Compiling with Types , 1995 .

[4]  Suresh Jagannathan,et al.  Single and loving it: must-alias analysis for higher-order languages , 1998, POPL '98.

[5]  Torben Æ. Mogensen Glossary for Partial Evaluation and Related Topics , 2000, High. Order Symb. Comput..

[6]  Richard A. Kelsey A correspondence between continuation passing style and static single assignment form , 1995 .

[7]  Mads Tofte A brief introduction to regions , 1998, ISMM '98.

[8]  Peter Lee,et al.  TIL: a type-directed, optimizing compiler for ML , 2004, SIGP.

[9]  Mitchell Wand,et al.  Lightweight closure conversion , 1997, TOPL.

[10]  Philip Wadler,et al.  Listlessness is better than laziness: Lazy evaluation and garbage collection at compile-time , 1984, LFP '84.

[11]  Simon Peyton Jones,et al.  Unboxing using Specialisation , 1994, Functional Programming.

[12]  Philip Wadler,et al.  Deforestation: Transforming Programs to Eliminate Trees , 1990, Theor. Comput. Sci..

[13]  Robert Harper,et al.  TIL: a type-directed optimizing compiler for ML , 1996, PLDI '96.

[14]  Martin Elsman,et al.  A Retrospective on Region-Based Memory Management , 2004, High. Order Symb. Comput..

[15]  Mitchell Wand,et al.  Constraint systems for useless variable elimination , 1999, POPL '99.

[16]  Andrew W. Appel,et al.  Efficient and safe-for-space closure conversion , 2000, TOPL.

[17]  Olin Shivers,et al.  Control-flow analysis of higher-order languages of taming lambda , 1991 .

[18]  Suresh Jagannathan,et al.  Flow-Directed Closure Conversion for Typed Languages , 2000, ESOP.

[19]  Richard Kelsey,et al.  A correspondence between continuation passing style and static single assignment form , 1995, IR '95.

[20]  Andrew P. Tolmach,et al.  From ML to Ada: Strongly-typed language interoperability via source translation , 1998, Journal of Functional Programming.

[21]  Andrew W. Appel,et al.  A type-based compiler for standard ML , 1995, PLDI '95.

[22]  Zhong Shao,et al.  Compiling standard ML for efficient execution on modern machines , 1994 .

[23]  Philip Wadler Listlessness is better than laziness II: composing listless functions , 1985, Programs as Data Objects.

[24]  Xavier Leroy,et al.  Unboxed objects and polymorphic typing , 1992, POPL '92.

[25]  Xavier Leroy,et al.  The effectiveness of type-based unboxing , 1997 .

[26]  Jacques Garrigue,et al.  On the runtime complexity of type-directed unboxing , 1998, ICFP '98.