Higher-order value flow graphs
The concepts of value- and control-flow graphs are important for program analysis of imperative programs. An imperative value flow graph can be constructed by a single pass over the program text. No similar concepts exist for higher-order languages: we propose a method for constructing value flow graphs for typed higher-order functional languages. A higher-order value flow graph is constructed by a single pass over an explicitly typed program. By using standard methods, single source and single use value flow problems can be answered in linear time and all sources-all uses can be answered in quadratic time (in the size of the flow graph, which is equivalent to the size of the explicitly typed program). On simply typed programs, the precision of the resulting analysis is equivalent to closure analysis [10,11,8]. In practice, it is a reasonable assumption that typed programs are only bigger than their untyped equivalent by a constant factor, hence this is an asymptotic improvement over previous algorithms.
We extend the analysis to handle polymorphism, sum types and recursive types. As a consequence, the analysis can handle (explicit) dynamically typed programs. The analysis is polyvariant for polymorphic definitions.
Keywordsprogram analysis type system efficiency polymorphism recursive types polyvariance
Unable to display preview. Download preview PDF.
- 1.A. Asperti and C. Laneve. Paths, computations and labels in the λ-calculus. In RTA'93, volume 690 of LNCS, pages 152–167. Springer-Verlag, 1993.Google Scholar
- 2.A. Ayers. Efficient closure analysis with reachability. In Proc. Workshop on Static Analysis (WSA), Bordeaux, France, pages 126–134, Sept. 1992.Google Scholar
- 3.N. Heintze. Control-flow analysis and type systems. In A. Mycroft, editor, Symposium on Static Analysis (SAS), volume 983 of LNCS, pages 189–206, Glasgow, 1995.Google Scholar
- 4.N. Heintze and D. McAllester. Control-flow analysis for ML in linear time. In International Conference on Functional Programming (ICFP), 1997. To appear.Google Scholar
- 5.F. Henglein. Dynamic typing: Syntax and proof theory. Science of Computer Programming (SCP), 22(3):197–230, 1994.Google Scholar
- 6.C. Mossin. Flow Analysis of Typed Higher-Order Programs. PhD thesis, DIKU, University of Copenhagen, January 1997.Google Scholar
- 7.C. Mossin. Higher-order value flow graphs. Technical report, DIKU, 1997.Google Scholar
- 8.J. Palsberg. Global program analysis in constraint form. In S. Tison, editor, 19th International Colloquium on Trees in Algebra and Programming (CAAP), volume 787 of LNCS, pages 276–290. Springer-Verlag, 1994.Google Scholar
- 9.T. Reps, S. Horwitz, and M. Sagiv. Precise interprocedural dataflow analysis via graph reachability. In Conference Record of the 22nd ACM Symposium on Principles of Programming Languages, pages 49–61, San Francisco, CA, Jan. 1995.Google Scholar
- 10.P. Sestoft. Replacing function parameters by global variables. Master's thesis, DIKU, University of Copenhagen, Denmark, October 1988.Google Scholar
- 11.P. Sestoft. Analysis and Efficient Implementation of Functional Languages. PhD thesis, DIKU, University of Copenhagen, Oct. 1991.Google Scholar
- 12.P. Wadler. Theorems for free! In Proc. Functional Programming Languages and Computer Architecture (FPCA), London, England, pages 347–359. ACM Press, Sept. 1989.Google Scholar