Type-directed flow analysis for typed intermediate languages

  • Suresh Jagannathan
  • Stephen Weeks
  • Andrew Wright
Functional Programming II
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1302)

Abstract

Flow analysis is especially valuable for optimizing functional languages because control-flow information is not syntactically apparent in higher-order programs. Flow analyses typically operate on untyped languages. However, recent compilers for typed functional languages such as ML and Haskell use a typed intermediate language to expose data representations for optimization. This paper presents a polyvariant flow analysis framework for the predicative subset of system F, a common basis for typed intermediate languages. Analyses in this framework can take advantage of types to analyze programs more precisely. We study a specific analysis called SRT that uses types to control polyvariance. We prove that SRTrespects types: whenever it assigns abstract value \(\hat \upsilon\)to a variable and the type system assigns type σ to the same variable, then \(\left[ {\hat \upsilon } \right] \subseteq \left[ \sigma \right]\), where [ · ] denotes a set of values. SRT does not terminate 1569 1655 V 3 for some programs. We present several variants of SRT that are better suited to practical use.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Aiken, A., and Wimmers, E. L. Type inclusion constraints and type inference. Proceedings of the International Conference on Functional Programming Languages and Computer Architecture (1993), 31–41.Google Scholar
  2. 2.
    Aiken, A., Wimmers, E. L., and Lakshman, T. K. Soft typing with conditional types. In Proc. ACM Symp. Principles of Programming Languages (Jan. 1993), pp. 163–173.Google Scholar
  3. 3.
    Bacon, D. F., and Sweeney, P. F. Fast static analyses of C++ virtual function calls. In OOPSLA (1996).Google Scholar
  4. 4.
    Banerjee, A. A modular, polyvariant, and type-based closure analysis. In Intl. Conf. Functional Programming (June 1997).Google Scholar
  5. 5.
    Chambers, C., and Ungar, D. Iterative type analysis and extended messagesplitting: Optimizing dynamically-typed object-oriented programs. Lisp and Symbolic Computation 4, 3 (1991).Google Scholar
  6. 6.
    Dimock, A., Muller, R., Turbak, F., and Wells, J. Strongly typed flow-directed representation transformations. In Proceedings of the International Conference on Functional Programming Languages (1997), pp. 11–24.Google Scholar
  7. 7.
    Flanagan, C., and Felleisen, M. Componential set-based analysis. In Proc. ACM Conf. Programming Language Design and Implementation (June 1997).Google Scholar
  8. 8.
    Girard, J.-Y. Une extension de l'interprétation de Gödel à l'analyse, et son application à l'élimination des coupures dans l'analyse et la théorie des types. In Proceedings of the 2nd Scandinavian Logic Symposium (1971), J. E. Fenstad, Ed., North-Holland, pp. 63–92.Google Scholar
  9. 9.
    Harper, R., and Mitchell, J. C. On the type structure of Standard ML. ACM Transactions on Programming Languages and Systems 15, 2 (Apr. 1993), 211–252.Google Scholar
  10. 10.
    Harper, R., and Morrisett, J. G. Compiling polymorphism using intensional type analysis. In Proc. ACM Symp. Principles of Programming Languages (Jan. 1995), ACM, pp. 130–141.Google Scholar
  11. 11.
    Heintze, N. Set-based analysis of ML programs. In Proc. ACM Symp. Lisp and Functional Programming (1994), pp. 306–317.Google Scholar
  12. 12.
    Heintze, N. Control-flow analysis and type systems. In Proc. Intl. Static Analysis Symposium (Sept. 1995), pp. 189–206. Also appears as CMU-CS-94-227.Google Scholar
  13. 13.
    Heintze, N., and McAllester, D. Linear-time subtransitive control flow analysis. In Proc. ACM Conf. Programming Language Design and Implementation (June 1997).Google Scholar
  14. 14.
    Henglein, F., and Mossin, C. Polymorphic binding-time analysis. In Proc. European Symp. Programming (Apr. 1994), D. Sannella, Ed., vol. 788 of Lecture Notes in Computer Science, pp. 287–301.Google Scholar
  15. 15.
    Jagannathan, S., and Weeks, S. T. A unified treatment of flow analysis in higher-order languages. In Proc. ACM Symp. Principles of Programming Languages (Jan. 1995), pp. 393–407.Google Scholar
  16. 16.
    Jagannathan, S., and Wright, A. K. Effective flow analysis for avoiding runtime checks. In Proc. Intl. Static Analysis Symposium (Sept. 1995), mycroft, Ed., no. 983 in Lecture Notes in Computer Science, Springer-Verlag, pp. 207–224.Google Scholar
  17. 17.
    Jagannathan, S., and Wright, A. K. Flow-directed inlining. In Proc. ACM Conf. Programming Language Design and Implementation (May 1996), pp. 193–205.Google Scholar
  18. 18.
    Nielson, F., and Nielson, H. R. Infinitary control flow analysis: a collecting semantics for closure analysis. In Proc. ACM Symp. Principles of Programming Languages (Jan. 1997), ACM, pp. 332–345.Google Scholar
  19. 19.
    Palsberg, J., and O'Keefe, P. A type system equivalent to flow analysis. In Proc. ACM Symp. Principles of Programming Languages (Jan. 1995), ACM, pp. 367–378.Google Scholar
  20. 20.
    Peyton Jones, S. L. Compiling Haskell by program transformation: a report from the trenches. In Proc. European Symp. Programming (Apr. 1996).Google Scholar
  21. 21.
    Plevyak, J., and Chien, A. A. Precise concrete type inference of object-oriented programs. In OOPSLA (1994).Google Scholar
  22. 22.
    Reynolds, J. C. Towards a theory of type structure. In Paris Colloquium on Programming (1974), no. 19 in Lecture Notes in Computer Science, Springer-Verlag, pp. 408–425.Google Scholar
  23. 23.
    Schmidt, D. Natural-semantics-based abstract interpretation (preliminary version). In Proc. Intl. Static Analysis Symposium (Sept. 1995), A. Mycroft, Ed., no. 983 in Lecture Notes in Computer Science, Springer-Verlag, pp. 1–18.Google Scholar
  24. 24.
    Sharir, M., and Pnueli, A. Two approaches to interprocedural dataflow analysis. In Program Flow Analysis: Theory and Applications, S. S. Muchnick and N. D. Jones, Eds. Prentice-Hall, 1981, pp. 189–235.Google Scholar
  25. 25.
    Shivers, O.Control-Flow Analysis of Higher-Order Languages or Taming Lambda. PhD thesis, Carnegie Mellon University, Computer Science Department, 1991.Google Scholar
  26. 26.
    Tarditi, D., Morrisett, J. G., Cheng, P., Stone, C., Harper, R., and Lee, P. TIL: A type-directed optimizing compiler for ML. In Proc. ACM Conf. Programming Language Design and Implementation (May 1996).Google Scholar
  27. 27.
    Turner, D. N., Wadler, P., and Mossin, C. Once upon a type. In Proc. Conf. Functional Programming and Computer Architecture (June 1995). *** DIRECT SUPPORT *** A0008C44 00006Google Scholar

Copyright information

© Springer-Verlag 1997

Authors and Affiliations

  • Suresh Jagannathan
    • 1
  • Stephen Weeks
    • 1
  • Andrew Wright
    • 1
  1. 1.NEC Research InstitutePrinceton

Personalised recommendations