Skip to main content
Log in

Flattening tuples in an SSA intermediate representation

  • Published:
Higher-Order and Symbolic Computation

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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  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)

  2. Davis, M.K.: Deforestation: Transformation of functional program to eliminate intermediate trees (1987)

  3. Elsman, M.: Program modules, separate compilation, and intermodule optimization (1999)

  4. Hall, C.V., Peyton Jones, S.L., Sansom, P.M.: Unboxing using specialisation. In: GLA (1994)

  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)

  6. Kelsey, R.A.: A correspondence between continuation passing style and static single assignment form. SIGPLAN Not. 30(3), 13–22 (1993)

    Article  Google Scholar 

  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)

  8. Leroy, X.: The effectiveness of type-based unboxing (1997)

  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)

  10. Mogensen, T.A.: Glossary for partial evaluation and related topics. High.-Order Symb. Comput. 13(4), 355–368 (2000)

    Article  Google Scholar 

  11. Morrissett, G.: Compiling with types (1995)

  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)

  13. Shao, Z.: Compiling standard ML for efficient execution on modern machines (1994)

  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)

  15. Shao, Z., Appel, A.W.: Efficient and safe-for-space closure conversion. ACM Trans. Program. Lang. Syst. 22(1), 129–161 (2000)

    Article  Google Scholar 

  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)

  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)

  18. Steckler, P.A., Wand, M.: Lightweight closure conversion. ACM Trans. Program. Lang. Syst. 19(1), 48–86 (1997)

    Article  Google Scholar 

  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)

    Article  Google Scholar 

  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)

  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)

    Article  MATH  Google Scholar 

  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)

    Article  MATH  Google Scholar 

  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)

  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)

  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

    Article  MathSciNet  Google Scholar 

  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)

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Lukasz Ziarek.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Ziarek, L., Weeks, S. & Jagannathan, S. Flattening tuples in an SSA intermediate representation. Higher-Order Symb Comput 21, 333–358 (2008). https://doi.org/10.1007/s10990-008-9035-3

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10990-008-9035-3

Keywords

Navigation