Abstract
Constraint-based analysis is a technique for inferring implementation types. Traditionally it has been described using mathematical formalisms. We explain it in a different and more intuitive way as a flow problem. The intuition is facilitated by a direct correspondence between run-time and analysis-time concepts.
Precise analysis of polymorphism is hard; several algorithms have been developed to cope with it. Focusing on parametric polymorphism and using the flow perspective, we analyze and compare these algorithms, for the first time directly characterizing when they succeed and fail.
Our study of the algorithms lead us to two conclusions. First, designing an algorithm that is either efficient or precise is easy, but designing an algorithm that is efficient and precise is hard. Second, to achieve efficiency and precision simultaneously, the analysis effort must be actively guided towards the areas of the program with the highest pay-off. We define a general class of algorithms that do this: the adaptive algorithms. The two most powerful of the five algorithms we study fall in this class.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Agesen, O., L. Bak, C. Chambers, B.W. Chang, U. Hölzle, J. Maloney, R.B. Smith, D. Ungar, M. Wolczko. How to use Self 3.0 & The Self 3.0 Programmer's Reference Manual. 1993. Sun Microsystems Laboratories, 2550 Garcia Avenue, Mountain View, CA 94043, USA. Available by anonymous ftp from self.stanford.edu or www: http://self.stanford.edu/.
Agesen, O., J. Palsberg, and M.I. Schwartzbach, Type Inference of Self: Analysis of Objects with Dynamic and Multiple Inheritance. In ECOOP '93, Seventh European Conference on Object-Oriented Programming. 1993. Kaiserslautern. Springer-Verlag (LNCS 707).
Agesen, O. and D. Ungar, Sifting Out the Gold: Delivering Compact Applications from an Object-Oriented Exploratory Programming Environment. To be presented at OOPSLA'94.
Bondorf, A., Automatic Autoprojection of Higher Order Recursive Equations. In Science of Computer Programming, 17(1–3), 1991, p. 3–34.
Chambers, C., D. Ungar, and E. Lee, An Efficient Implementation of SELF, a Dynamically-Typed Object-Oriented Language Based on Prototypes. In OOPSLA '89, Object-Oriented Programming Systems, Languages and Applications. 1989. New Orleans, LA. Also published in Lisp and Symbolic Computation 4(3), Kluwer Academic Publishers, June, 1991.
Chien, A.A., V. Karamcheti, and J. Plevyak, The Concert System — Compiler and Run-time Support for Efficient, Fine-Grained Concurrent Object-Oriented Programs. Department of Computer Science, University of Illinois Urbana-Champaign, Technical Report UIUCDCS-R-93-1815,1993.
Consel, C., Polyvariant Binding-Time Analysis For Applicative Languages, ACM-PEPM'93, Copenhagen, Denmark.
Cousot, P. and R. Cousot, Abstract Interpretation: A Unified Lattice Model for Static Analysis of Programs by Construction or Approximation of Fixpoints. In Symposium on Principles of Programming Languages. 1977.
Graver, J.O. and R.E. Johnson, A Type System for Smalltalk. In Seventeenth Symposium on Principles of Programming Languages. 1990. ACM Press.
Hall, M.W., and K. Kennedy, Efficient Call Graph Analysis. ACM Letters on Programming Languages and Systems, 1992. 1(3) p. 227–242.
Hense, A.V., Polymorphic Type Inference for a Simple Object Oriented Programming Language With State. Tech. Bericht Nr. A 20/90 (Technical Report), Universität des Saarlandes, 1990.
Hölzle, U. and D. Ungar, Optimizing Dynamically-Dispatched Calls with Run-Time Type Feedback. To appear in PLDI'94, June 1994.
Johnson, R.E., Type-Checking Smalltalk. In OOPSLA '86 Object-Oriented Programming Systems, Languages and Applications. 1986.
Milner, R., A Theory of Type Polymorphism in Programming. Journal of Computer and System Sciences, 17, 1978, p. 348–375.
Oxhøj, N., J. Palsberg, and M.I. Schwartzbach, Making Type Inference Practical. In ECOOP '92, Sixth European Conference on Object-Oriented Programming. 1992. Utrecht, The Netherlands. Springer-Verlag (LNCS 615).
Palsberg, J., and M.I. Schwartzbach, Object-Oriented Type Inference. In OOPSLA'91, ACM SIGPLAN Sixth Annual Conference on Object-Oriented Programming Systems, Languages and Applications. 1991. Phoenix, Arizona.
Palsberg, J., and M.I. Schwartzbach, Polyvariant Analysis of the Untyped Lambda Calculus. Technical Report, Daimi PB-386, Computer Science Department, Aarhus University, Denmark, 1992.
Palsberg, J., and M.I. Schwartzbach, Safety Analysis versus Type Inference for Partial Types. Information Processing Letters, 43, 1992, p. 175–180.
Phillips, G., and T. Shepard, Static Typing Without Explicit Types. Submitted for publication. Dept. of Electrical and Computer Engineering, Royal Military College of Canada, Kingston, Ontario, Canada, 1994.
Plevyak, J.. and A.A. Chien, Incremental Inference of Concrete Types, Department of Computer Science, University of Illinois Urbana-Champaign, Technical Report UIUCDCS-R-93-1829,1993.
Sestoft, P., Replacing Function Parameters by Global Variables, M.Sc. thesis 88-7-2, DIKU, University of Copenhagen, Denmark, 1988.
Sestoft, P., Replacing Function Parameters by Global Variables. Proceedings of the Fourth International Conference on Functional Programming and Computer Architecture, London, UK, p. 39–53, ACM Press, September 1989.
Shivers, O., Control-Flow Analysis of Higher-Order Languages, Ph.D. thesis. School of Computer Science, Carnegie-Mellon University, Pittsburgh, PA 15213. 1991.
Ungar, D. and R.B. Smith, SELF: The Power of Simplicity. Lisp and Symbolic Computing, 4(3), Kluwer Academic Publishers, June 1991. Originally published in OOPSLA '87, Object-Oriented Programming Systems, Languages and Applications, p. 227–241, 1987.
Wand, M., A Simple Algorithm and Proof for Type Inference. Fundamenta Informaticae, X, 1987, p. 115–121.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1994 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Agesen, O. (1994). Constraint-based type inference and parametric polymorphism. In: Le Charlier, B. (eds) Static Analysis. SAS 1994. Lecture Notes in Computer Science, vol 864. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-58485-4_34
Download citation
DOI: https://doi.org/10.1007/3-540-58485-4_34
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-58485-8
Online ISBN: 978-3-540-49005-0
eBook Packages: Springer Book Archive