Abstract
Modern compilers for ML-like polymorphic languages have used explicit run-time type passing to support advanced optimizations such as intensional type analysis, representation analysis and tagless garbage collection. Unfortunately, maintaining type information at run time can incur a large overhead to the time and space usage of a program. In this paper, we present an optimal type-lifting algorithm that lifts all type applications in a program to the top level. Our algorithm eliminates all run-time type constructions within any core-language functions. In fact, it guarantees that the number of types built at run time is strictly a static constant. We present our algorithm as a type-preserving source-to-source transformation and show how to extend it to handle the entire SML’97 with higher-order modules.
This research was sponsored in part by the DARPA ITO under the title “Software Evolution using HOT Language Technology”, DARPA Order No. D888, issued under Contract No. F30602-96-2-0232, and in part by an NSF CAREER Award CCR-9501624, and NSF Grant CCR-9633390. The views and conclusions contained in this document are those of the authors and should not be interpreted as representing the official policies, either expressed or implied, of the Defense Advanced Research Projects Agency or the U.S. Government.
Preview
Unable to display preview. Download preview PDF.
References
A. V. Aho, R. Sethi, and J. D. Ullman. Compilers: Principles, Techniques, and Tools. Addison-Wesley, Reading, MA, 1986.
A. W. Appel. Compiling with Continuations. Cambridge University Press, 1992.
N. de Bruijn. A survey of the project AUTOMATH. In To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, pages 579–606. Edited by J. P. Seldin and J. R. Hindley, Academic Press, 1980.
C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The essence of compiling with continuations. In Proc. ACM SIGPLAN ’93 Conf. on Prog. Lang. Design and Implementation, pages 237–247, New York, June 1993. ACM Press.
J. Y. Girard. Interpretation Fonctionnelle et Elimination des Coupures dans l’Arithmetique d’Ordre Superieur. PhD thesis, University of Paris VII, 1972.
R. Harper and J. C. Mitchell. On the type structure of Standard ML. ACM Trans. Prog. Lang. Syst., 15(2): 211–252, April 1993.
R. Harper and G. Morrisett. Compiling polymorphism using intensional type analysis. In Twenty-second Annual ACM Symp. on Principles of Prog. Languages, pages 130–141, New York, Jan 1995. ACM Press.
P. Hudak, S. P. Jones, and P. W. et al. Report on the programming language Haskell, a non-strict, purely functional language version 1.2. SIGPLAN Notices, 21(5), May 1992.
R. Hughes. The design and implementation of programming languages. PhD thesis, Programming Research Group, Oxford University, Oxford, UK, 1983.
T. Johnsson. Lambda Lifting: Transforming Programs to Recursive Equations. In The Second International Conference on Functional Programming Languages and Computer Architecture, pages 190–203, New York, September 1985. Springer-Verlag.
M. P. Jones. Qualified Types: Theory and Practice. PhD thesis, Oxford University Computing Laboratory, Oxford, July 1992. Technical Monograph PRG-106.
M. P. Jones. A theory of qualified types. In The 4th European Symposium on Programming, pages 287–306, Berlin, February 1992. Spinger-Verlag.
M. P. Jones. Dictionary-free overloading by partial evaluation. In Proceedings of the ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, pages 107–117. University of Melbourne TR 94/9, June 1994.
X. Leroy. Unboxed objects and polymorphic typing. In Nineteenth Annual ACM Symp. on Principles of Prog. Languages, pages 177–188, New York, Jan 1992. ACM Press. Longer version available as INRIA Tech Report.
X. Leroy and M. Mauny. Dynamics in ML. In The Fifth International Conference on Functional Programming Languages and Computer Architecture, pages 406–426, New York, August 1991. Springer-Verlag.
R. Milner, M. Tofte, and R. Harper. The Definition of Standard ML. MIT Press, Cambridge, Massachusetts, 1990.
R. Milner, M. Tofte, R. Harper, and D. MacQueen. The Definition of Standard ML (Revised). MIT Press, Cambridge, Massachusetts, 1997.
Y. Minamide. Full lifting of type parameters. Technical report, RIMS, Kyoto University, 1997.
R. Morrison, A. Dearie, R. C. H. Connor, and A. L. Brown. An ad hoc approach to the implementation of polymorphism. ACM Trans. Prog. Lang. Syst., 13(3), July 1991.
G. Nadathur. A notation for lambda terms II: Refinements and applications. Technical Report CS-1994-01, Duke University, Durham, NC, January 1994.
A. Ohori. A compilation method for ML-style polymorphic record calculi. In Nineteenth Annual ACM Symp. on Principles of Prog. Languages, New York, Jan 1992. ACM Press.
S. Peyton Jones. Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine. Journal of Functional Programming, 2(2): 127–202, April 1992.
S. Peyton Jones. Compiling haskell by program transformation: a report from trenches. In Proceedings of the European Symposium on Programming, Linkoping, April 1996.
S. Peyton Jones and D. Lester. A modular fully-lazy lambda lifter in haskell. Software — Practice and Experience, 21: 479–506, 1991.
S. Peyton Jones, W. Partain, and A. Santos. Let-floating: moving bindings to give faster programs. In Proc. International Conference on Functional Programming (ICFP’96), New York, June 1996. ACM Press.
J. C. Reynolds. Towards a theory of type structure. In Proceedings, Colloque sur la Programmation, Lecture Notes in Computer Science, volume 19, pages 408–425. Springer-Verlag, Berlin, 1974.
Z. Shao. Flexible representation analysis. In Proc. 1997 ACM SIGPLAN International Conference on Functional Programming (ICFP’97), pages 85–98. ACM Press, June 1997.
Z. Shao. An overview of the FLINT/ML compiler. In Proc. 1997 ACM SIGPLAN Workshop on Types in Compilation, June 1997.
Z. Shao. Typed cross-module compilation. Technical Report YALEU/DCS/RR-1126, Dept. of Computer Science, Yale University, New Haven, CT, November 1997.
Z. Shao and A. W. Appel. A type-based compiler for Standard ML. In Proc. ACM SIGPLAN ’95 Conf. on Prog. Lang. Design and Implementation, pages 116–129. ACM Press, 1995.
D. Tarditi, G. Morrisett, P. Cheng, C. Stone, R. Harper, and P. Lee. TIL: A type-directed optimizing compiler for ML. In Proc. ACM SIGPLAN ’96 Conf. on Prog. Lang. Design and Implementation, pages 181–192. ACM Press, 1996.
A. Tolmach. Tag-free garbage collection using explicit type parameters. In Proc. 1994 ACM Conf. on Lisp and Functional Programming, pages 1–11, New York, June 1994. ACM Press.
A. K. Wright. Polymorphism for imperative languages without imperative types. Technical Report Tech Report TR 93-200, Dept. of Computer Science, Rice University, Houston, Texas, February 1993.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1998 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Saha, B., Shao, Z. (1998). Optimal type lifting. In: Leroy, X., Ohori, A. (eds) Types in Compilation. TIC 1998. Lecture Notes in Computer Science, vol 1473. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0055517
Download citation
DOI: https://doi.org/10.1007/BFb0055517
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-64925-0
Online ISBN: 978-3-540-68308-7
eBook Packages: Springer Book Archive