Polyvariance, polymorphism and flow analysis

  • Karl-Filip Faxén
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1192)


Flow analysis is a potentially very useful analysis for higher order functional languages, but its practical application has been slow in coining, partially hindered by shortcomings of the current analysis techniques. Among these are the limited precision, long analysis times, incompatibility with separate compilation, inapplicability to untyped languages and sensitivity to program structure associated with various earlier formulations.

We address these shortcomings with an approach based on a novel type system integrating recursive types, subtyping with liberal union types, and system F style polymorphism, in a constraint based formulation. The type system is “soft” in the sense that it does not reject programs. It is also not decidable, but there is a broad spectrum of sound and terminating, though incomplete, algorithms whose precision can be characterized by restricting the substitutions used for instantiation of type schemes. We give an inference algorithm which simplifies constraints incrementally, rather than postponing all constraint solving until all of the constraints are generated. In this way we hope to avoid in practice the exponential growth in the size of constraint sets caused by repeated instantiation of unsimplified type schemes. Type schemes are also a suitable representation for communicationg the analysis result over module boundaries, making separate compilation feasible.


Flow analysis type systems constraints polymorphism polyvariance inference algorithms functional languages 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    A. V. Aho, R. Sethi, and J. D. Ullman. Compilers principles, techniques, and tools. Addison-Wesley, Reading, MA, 1986.Google Scholar
  2. 2.
    Karl-Filip Faxén. Optimizing lazy functional programs using flow inference. In Alan Mycroft, editor, Proceedings of the Second International Symposium on Static Analysis, pages 136–153, Glasgow, UK, September 1995. Springer-Verlag.Google Scholar
  3. 3.
    Nevin Heintze. Set-based analysis of ML programs. In Proc. ACM Conference on LISP and Functional Programming, 1994.Google Scholar
  4. 4.
    Suresh Jagannathan and Stephen Weeks. A unified treatment of flow analysis in higher-order languages. In Principles of Programming Languages, 1995.Google Scholar
  5. 5.
    Suresh Jagannathan and Andrew Wright. Effective flow analysis for avoiding run-time checks. Technical Report 95-3, NEC Research Institute, May 1995.Google Scholar
  6. 6.
    N. D. Jones and S. S. Muchnick. A flexible approach to interprocedural data flow analysis and programs with recursive data structures. In Conference Record of the 9th Annual ACM Symposium on Principles of Programming Languages, pages 66–74, Albuquerque, NM, January 1982.Google Scholar
  7. 7.
    Neil D. Jones and Steven S. Muchnick. Flow analysis and optimization of Lisp-like structures. In Conference Record of the 6th Annual ACM Symposium on Principles of Programming Languages, pages 244–256, January 1979.Google Scholar
  8. 8.
    Jens Palsberg. Closure analysis in constraint form. In CAAP'94, 1994.Google Scholar
  9. 9.
    Peter Sestoft. Analysis and efficient implementation of functional programs. PhD thesis, DIKU, University of Copenhagen, Denmark, October 1991.Google Scholar
  10. 10.
    O. Shivers. Control flow analysis in Scheme. In Proceedings of the ACM SIGPLAN '88 Conference on Programming Language Design and Implementation, volume 23, pages 164–174, Atlanta, GA, June 1988.Google Scholar
  11. 11.
    O. Shivers. The semantics of Scheme control-flow analysis. In Proceedings of the Symposium on Partial Evaluation and Semantics-Based Program Manipulation, volume 26, pages 190–198, New Haven, CN, June 1991.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1997

Authors and Affiliations

  • Karl-Filip Faxén
    • 1
  1. 1.Dept. of TeleinformaticsRoyal Institute of TechnologyKista

Personalised recommendations