Skip to main content

Demand-Driven Type Inference with Subgoal Pruning: Trading Precision for Scalability

  • Conference paper
ECOOP 2004 – Object-Oriented Programming (ECOOP 2004)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 3086))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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)

    Google Scholar 

  2. 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)

    Chapter  Google Scholar 

  3. Kogge, P.M.: The Architecture of Symbolic Computers. McGraw-Hill, New York (1991)

    Google Scholar 

  4. Opdyke, W.F.: Refactoring object-oriented frameworks. PhD thesis, University of Illinois at Urbana-Champaign (1992)

    Google Scholar 

  5. 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)

    Google Scholar 

  6. Shivers, O.: The semantics of scheme control-flow analysis. In: Partial Evaluation and Semantic-Based Program Manipulation., pp. 190–198 (1991)

    Google Scholar 

  7. Suzuki, N.: Inferring types in smalltalk. In: Conference record of the 8th ACM Symposium on Principles of Programming Languages (POPL), pp. 187–199 (1981)

    Google Scholar 

  8. Barnard, A.J.: From types to dataflow: code analysis for an OO language. PhD thesis, Manchester University (1993)

    Google Scholar 

  9. 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)

    Google Scholar 

  10. Flanagan, C., Felleisen, M.: Componential set-based analysis. ACM Transactions on Programming Languages and Systems (TOPLAS) 21, 370–416 (1999)

    Article  Google Scholar 

  11. Garau, F.: Inferencia de tipos concretos en squeak. Master’s thesis, Universidad de Buenos Aires (2001)

    Google Scholar 

  12. Shivers, O.: Control-Flow Analysis of Higher-Order Languages. PhD thesis, Carnegie Mellon University (1991)

    Google Scholar 

  13. Heintze, N., McAllester, D.A.: On the cubic bottleneck in subtyping and flow analysis. Logic in Computer Science, 342–351 (1997)

    Google Scholar 

  14. Tip, F., Palsberg, J.: Scalable propagation-based call graph construction algorithms. ACM SIGPLAN Notices 35, 281–293 (2000)

    Article  Google Scholar 

  15. Reps, T.W.: Demand interprocedural program analysis using logic databases. In: Workshop on Programming with Logic Databases (Book), ILPS, pp. 163–196 (1993)

    Google Scholar 

  16. 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)

    Google Scholar 

  17. : Simultaneous demand-driven data-flow and call graph analysis. In: ICSM, pp. 453–462 (1999)

    Google Scholar 

  18. Heintze, N., Tardieu, O.: Demand-driven pointer analysis. In: SIGPLAN Conference on Programming Language Design and Implementation, pp. 24–34 (2001)

    Google Scholar 

  19. 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)

    Chapter  Google Scholar 

  20. Rich, E.: Artificial Intelligence. McGraw-Hill Book Company, New York (1983)

    Google Scholar 

  21. Spoon, S.A., Shivers, O.: Classification of inferred types in ddp experiment (2003), http://www.cc.gatech.edu/~lex/ti

  22. Spoon, S.A.: Subgoal Pruning in Demand-Driven Analysis of a Dynamically Typed Object-Oriented Language. PhD thesis, Georgia Institute of Technology (forthcoming)

    Google Scholar 

  23. 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)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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

Publish with us

Policies and ethics