Higher-Order and Symbolic Computation

, Volume 21, Issue 3, pp 333–358 | Cite as

Flattening tuples in an SSA intermediate representation

Article

Abstract

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.

Keywords

Compilation Optimization Unboxing Flattening Tuples SSA 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Cejtin, H., Jagannathan, S., Weeks, S.: Flow-directed closure conversion for typed languages. In: ESOP ’00: Proceedings of the 9th European Symposium on Programming Languages and Systems, London, UK, pp. 56–71 (2000) Google Scholar
  2. 2.
    Davis, M.K.: Deforestation: Transformation of functional program to eliminate intermediate trees (1987) Google Scholar
  3. 3.
    Elsman, M.: Program modules, separate compilation, and intermodule optimization (1999) Google Scholar
  4. 4.
    Hall, C.V., Peyton Jones, S.L., Sansom, P.M.: Unboxing using specialisation. In: GLA (1994) Google Scholar
  5. 5.
    Jagannathan, S., Thiemann, P., Weeks, S., Wright, A.: Single and loving it: must-alias analysis for higher-order languages. In: POPL ’98: Proceedings of the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, New York, NY, USA, pp. 329–341 (1998) Google Scholar
  6. 6.
    Kelsey, R.A.: A correspondence between continuation passing style and static single assignment form. SIGPLAN Not. 30(3), 13–22 (1993) CrossRefGoogle Scholar
  7. 7.
    Leroy, X.: Unboxed objects and polymorphic typing. In: POPL ’92: Proceedings of the 19th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, New York, NY, USA, pp. 177–188 (1992) Google Scholar
  8. 8.
    Leroy, X.: The effectiveness of type-based unboxing (1997) Google Scholar
  9. 9.
    Minamide, Y., Garrigue, J.: On the runtime complexity of type-directed unboxing. In: ICFP ’98: Proceedings of the Third ACM SIGPLAN International Conference on Functional Programming, New York, NY, USA, pp. 1–12 (1998) Google Scholar
  10. 10.
    Mogensen, T.A.: Glossary for partial evaluation and related topics. High.-Order Symb. Comput. 13(4), 355–368 (2000) CrossRefGoogle Scholar
  11. 11.
    Morrissett, G.: Compiling with types (1995) Google Scholar
  12. 12.
    Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: Proceedings of 25th ACM National Conference, Boston, Massachusetts, pp. 717–740. Reprinted in High.-Order Symb. Comput. 11(4), 363–397 (1998) Google Scholar
  13. 13.
    Shao, Z.: Compiling standard ML for efficient execution on modern machines (1994) Google Scholar
  14. 14.
    Shao, Z., Appel, A.W.: A type-based compiler for standard ML. In: PLDI ’95: Proceedings of the ACM SIGPLAN 1995 Conference on Programming Language Design and Implementation, New York, NY, USA, pp. 116–129 (1995) Google Scholar
  15. 15.
    Shao, Z., Appel, A.W.: Efficient and safe-for-space closure conversion. ACM Trans. Program. Lang. Syst. 22(1), 129–161 (2000) CrossRefGoogle Scholar
  16. 16.
    Shivers, O.: Control flow analysis in scheme. In: PLDI ’88: Proceedings of the ACM SIGPLAN 1988 Conference on Programming Language Design and Implementation, New York, NY, USA, pp. 164–174 (1988) Google Scholar
  17. 17.
    Shivers, O.: Control-flow analysis of higher-order languages or taming lambda. Ph.D. thesis, School of Computer Science, Carnegie Mellon University, Pittsburgh, Pennsylvania. Technical Report CMU-CS-91-145 (1991) Google Scholar
  18. 18.
    Steckler, P.A., Wand, M.: Lightweight closure conversion. ACM Trans. Program. Lang. Syst. 19(1), 48–86 (1997) CrossRefGoogle Scholar
  19. 19.
    Tarditi, D., Morrisett, G., Cheng, P., Stone, C., Harper, R., Lee, P.: TIL: a type-directed, optimizing compiler for ML. SIGPLAN Not. 39(4), 554–567 (2004) CrossRefGoogle Scholar
  20. 20.
    Tofte, M.: A brief introduction to regions. In: ISMM ’98: Proceedings of the 1st International Symposium on Memory Management, New York, NY, USA, pp. 186–195 (1998) Google Scholar
  21. 21.
    Tofte, M., Birkedal, L., Elsman, M., Hallenberg, N.: A retrospective on region-based memory management. High.-Order Symb. Comput. 17(3), 245–265 (2004) MATHCrossRefGoogle Scholar
  22. 22.
    Tolmach, A., Oliva, D.P.: From ML to Ada: Strongly-typed language interoperability via source translation. J. Funct. Program. 8(4), 367–412 (1998) MATHCrossRefGoogle Scholar
  23. 23.
    Wadler, P.: Listlessness is better than laziness: Lazy evaluation and garbage collection at compile-time. In: LFP ’84: Proceedings of the 1984 ACM Symposium on LISP and Functional Programming, New York, NY, USA, pp. 45–52 (1984) Google Scholar
  24. 24.
    Wadler, P.: Listlessness is better than laziness II: composing listless functions In: On Programs as Data Objects, New York, NY, USA, pp. 282–305 (1985) Google Scholar
  25. 25.
    Wadler, P.: Deforestation: Transforming programs to eliminate trees. Theor. Comput. Sci. 73(2), 231–248 (1989). Special issue on ESOP’88, the Second European Symposium on Programming, Nancy, France, March 21–24, 1988 CrossRefMathSciNetGoogle Scholar
  26. 26.
    Wand, M., Siveroni, I.: Constraint systems for useless variable elimination. In: POPL ’99: Proceedings of the 26th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, New York, NY, USA, pp. 291–302 (1999) Google Scholar

Copyright information

© Springer Science+Business Media, LLC 2008

Authors and Affiliations

  • Lukasz Ziarek
    • 1
  • Stephen Weeks
    • 2
  • Suresh Jagannathan
    • 1
  1. 1.Department of Computer SciencePurdue UniversityWest LafayetteUSA
  2. 2.Jane Street CapitalNew YorkUSA

Personalised recommendations