Abstract
After two decades of effort, type inference for dynamically typed languages scales to programs of a few tens of thousands of lines of code, but no further. For larger programs, this paper proposes using a kind of demand-driven analysis where the number of active goals is carefully restricted. To achieve this restriction, the algorithm occasionally prunes goals by giving them solutions that are trivially true and thus require no further subgoals to be solved; the previous subgoals of a newly pruned goal may often be discarded from consideration, reducing the total number of active goals. A specific algorithm DDP is described which uses this approach. An experiment on DDP shows that it infers precise types for roughly 30% to 45% of the variables in a program with hundreds of thousands of lines; the percentage varies with the choice of pruning threshold, a parameter of the algorithm. The time required varies from an average of one-tenth of one second per variable to an unknown maximum, again depending on the pruning threshold. These data suggest that 50 and 2000 are both good choices of pruning threshold, depending on whether speed or precision is more important.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
American National Standards Institute: ANSI NCITS 319-1998: Information Technology — Programming Languages — Smalltalk. American National Standards Institute, 1430 Broadway, New York, NY 10018, USA (1998)
Kay, A.C.: The early history of smalltalk. In: The second ACM SIGPLAN conference on History of programming languages, pp. 69–95. ACM Press, New York (1993)
Kogge, P.M.: The Architecture of Symbolic Computers. McGraw-Hill, New York (1991)
Opdyke, W.F.: Refactoring object-oriented frameworks. PhD thesis, University of Illinois at Urbana-Champaign (1992)
Grove, D., Defouw, G., Dean, J., Chambers, C.: Call graph construction in objectoriented languages. In: ACM Conference on Object-Oriented Programming, Systems, Language, and Applications, OOPSLA (1997)
Shivers, O.: The semantics of scheme control-flow analysis. In: Partial Evaluation and Semantic-Based Program Manipulation., pp. 190–198 (1991)
Suzuki, N.: Inferring types in smalltalk. In: Conference record of the 8th ACM Symposium on Principles of Programming Languages (POPL), pp. 187–199 (1981)
Barnard, A.J.: From types to dataflow: code analysis for an OO language. PhD thesis, Manchester University (1993)
Agesen, O.: The cartesian product algorithm: Simple and precise type inference of parametric polymorphism. In: Olthoff, W. (ed.) ECOOP 1995. LNCS, vol. 952, pp. 2–26. Springer, Heidelberg (1995)
Flanagan, C., Felleisen, M.: Componential set-based analysis. ACM Transactions on Programming Languages and Systems (TOPLAS) 21, 370–416 (1999)
Garau, F.: Inferencia de tipos concretos en squeak. Master’s thesis, Universidad de Buenos Aires (2001)
Shivers, O.: Control-Flow Analysis of Higher-Order Languages. PhD thesis, Carnegie Mellon University (1991)
Heintze, N., McAllester, D.A.: On the cubic bottleneck in subtyping and flow analysis. Logic in Computer Science, 342–351 (1997)
Tip, F., Palsberg, J.: Scalable propagation-based call graph construction algorithms. ACM SIGPLAN Notices 35, 281–293 (2000)
Reps, T.W.: Demand interprocedural program analysis using logic databases. In: Workshop on Programming with Logic Databases (Book), ILPS, pp. 163–196 (1993)
Duesterwald, E., Gupta, R., Soffa, M.L.: Demand-driven computation of interprocedural data flow. In: Symposium on Principles of Programming Languages, pp. 37–48 (1995)
: Simultaneous demand-driven data-flow and call graph analysis. In: ICSM, pp. 453–462 (1999)
Heintze, N., Tardieu, O.: Demand-driven pointer analysis. In: SIGPLAN Conference on Programming Language Design and Implementation, pp. 24–34 (2001)
Dubé, D., Feeley, M.: A demand-driven adaptive type analysis. In: Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming, pp. 84–97. ACM Press, New York (2002)
Rich, E.: Artificial Intelligence. McGraw-Hill Book Company, New York (1983)
Spoon, S.A., Shivers, O.: Classification of inferred types in ddp experiment (2003), http://www.cc.gatech.edu/~lex/ti
Spoon, S.A.: Subgoal Pruning in Demand-Driven Analysis of a Dynamically Typed Object-Oriented Language. PhD thesis, Georgia Institute of Technology (forthcoming)
Wang, T., Smith, S.F.: Precise constraint-based type inference for Java. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 99–117. Springer, Heidelberg (2001)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2004 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Spoon, S.A., Shivers, O. (2004). Demand-Driven Type Inference with Subgoal Pruning: Trading Precision for Scalability. In: Odersky, M. (eds) ECOOP 2004 – Object-Oriented Programming. ECOOP 2004. Lecture Notes in Computer Science, vol 3086. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-24851-4_3
Download citation
DOI: https://doi.org/10.1007/978-3-540-24851-4_3
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-22159-3
Online ISBN: 978-3-540-24851-4
eBook Packages: Springer Book Archive