skip to main content
research-article

Call graphs for languages with parametric polymorphism

Published:19 October 2016Publication History
Skip Abstract Section

Abstract

The performance of contemporary object oriented languages depends on optimizations such as devirtualization, inlining, and specialization, and these in turn depend on precise call graph analysis. Existing call graph analyses do not take advantage of the information provided by the rich type systems of contemporary languages, in particular generic type arguments. Many existing approaches analyze Java bytecode, in which generic types have been erased. This paper shows that this discarded information is actually very useful as the context in a context-sensitive analysis, where it significantly improves precision and keeps the running time small. Specifically, we propose and evaluate call graph construction algorithms in which the contexts of a method are (i) the type arguments passed to its type parameters, and (ii) the static types of the arguments passed to its term parameters. The use of static types from the caller as context is effective because it allows more precise dispatch of call sites inside the callee.

Our evaluation indicates that the average number of contexts required per method is small. We implement the analysis in the Dotty compiler for Scala, and evaluate it on programs that use the type-parametric Scala collections library and on the Dotty compiler itself. The context-sensitive analysis runs 1.4x faster than a context-insensitive one and discovers 20% more monomorphic call sites at the same time. When applied to method specialization, the imprecision in a context-insensitive call graph would require the average method to be cloned 22 times, whereas the context-sensitive call graph indicates a much more practical 1.00 to 1.50 clones per method.

We applied the proposed analysis to automatically specialize generic methods. The resulting automatic transformation achieves the same performance as state-of-the-art techniques requiring manual annotations, while reducing the size of the generated bytecode by up to 5x.

References

  1. O. Agesen. The Cartesian product algorithm. In ECOOP ’95, Object-Oriented Programming: 9th European Conference, volume 952 of Lecture Notes in Computer Science, pages 2–51, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. K. Ali and O. Lhoták. Application-only call graph construction. In J. Noble, editor, ECOOP 2012 - Object-Oriented Programming - 26th European Conference, Beijing, China, June 11-16, 2012. Proceedings, volume 7313 of Lecture Notes in Computer Science, pages 688–712. Springer, 2012. ISBN 978-3-642-31056-0. K. Ali and O. Lhoták. Averroes: Whole-program analysis without the whole program. In G. Castagna, editor, ECOOP 2013 - Object-Oriented Programming - 27th European Conference, Montpellier, France, July 1-5, 2013. Proceedings, volume 7920 of Lecture Notes in Computer Science, pages 378–400. Springer, 2013. ISBN 978-3-642-39037-1. doi: 10. 1007/978-3-642-39038-8. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 286957.Google ScholarGoogle Scholar
  4. I. Dragos. Compiling Scala for Performance. PhD thesis, IC, Lausanne, 2010.Google ScholarGoogle Scholar
  5. I. Dragos and M. Odersky. Compiling generics through userdirected type specialization. In Proceedings of the 4th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pages 42–47. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Y. Feng, X. Wang, I. Dillig, and C. Lin. EXPLORER : query- and demand-driven exploration of interprocedural control flow properties. In Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2015, part of SLASH 2015, Pittsburgh, PA, USA, October 25-30, 2015, pages 520– 534. ACM, 2015. doi: 10.1145/2814270.2814284. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. F. Henglein and J. Jørgensen. Formally optimal boxing. In Proceedings of the 21st ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 213–226. ACM, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. T. Johnsson. Lambda lifting: Transforming programs to recursive equations. In Functional programming languages and computer architecture, pages 190–203. Springer, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. G. Kastrinis and Y. Smaragdakis. Hybrid context-sensitivity for points-to analysis. In H. Boehm and C. Flanagan, editors, ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’13, Seattle, WA, USA, June 16-19, 2013, pages 423–434. ACM, 2013. ISBN 9781-450-3201-4- 6. doi: 10.1145/2462156.2462191. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. O. Lhoták and L. Hendren. Context-sensitive points-to analysis: is it worth it? In A. Mycroft and A. Zeller, editors, Compiler Construction, 15th International Conference, volume 3923 of LNCS, pages 47–64, Vienna, Mar. 2006. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. O. Lhoták and L. Hendren. Evaluating the benefits of contextsensitive points-to analysis using a BDD-based implementation. ACM Trans. Softw. Eng. Methodol., 18(1):1–53, 2008. ISSN 1049-331X. doi: http://doi.acm.org/10.1145/1391984.1391987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. A. Milanova, A. Rountev, and B. G. Ryder. Parameterized object sensitivity for points-to and side-effect analyses for Java. In Proceedings of the 2002 ACM SIGSOFT International Symposium on Software Testing and Analysis, pages 1–11. ACM Press, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. ISBN 1-58113-562-9. doi: http://doi.acm.org/10.1145/566172.Google ScholarGoogle Scholar
  14. 566174.Google ScholarGoogle Scholar
  15. A. Milanova, A. Rountev, and B. G. Ryder. Parameterized object sensitivity for points-to analysis for Java. ACM Trans. Softw. Eng. Methodol., 14(1):1–41, 2005. ISSN 1049-331X. doi: http://doi.acm.org/10.1145/1044834.1044835. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. R. Morrison, A. Dearle, R. C. H. Connor, and A. L. Brown. An Ad Hoc Approach to the Implementation of Polymorphism. ACM Trans. Program. Lang. Syst., 13(3):342–371, July 1991. ISSN 0164-0925. doi: 10.1145/117009.117017. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. O. Sallenave and R. Ducournau. Lightweight generics in embedded systems through static analysis. In R. Wilhelm, H. Falk, and W. Yi, editors, SIGPLAN/SIGBED Conference on Languages, Compilers and Tools for Embedded Systems 2012, LCTES ’12, Beijing, China - June 12 - 13, 2012, pages 11–20. ACM, 2012. ISBN 9781-450-3121-2-7. doi: 10.1145/2248418.2248421. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. ISBN 0-89791-269-1. doi: http://doi.acm.org/10.1145/53990.Google ScholarGoogle Scholar
  19. 54007.Google ScholarGoogle Scholar
  20. ISBN 1-59593-320-4. doi: http: //doi.acm.org/10.1145/1133981.1134027.Google ScholarGoogle Scholar
  21. V. Ureche, C. Talau, and M. Odersky. Miniboxing: improving the speed to code size tradeoff in parametric polymorphism translations. In Proceedings of the 2013 ACM SIGPLAN International Conference on Object Oriented Programming Systems Languages & Applications, OOPSLA 2013, part of SPLASH 2013, Indianapolis, IN, USA, October 26-31, 2013, pages 73– 92, 2013. doi: 10.1145/2509136.2509537. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Call graphs for languages with parametric polymorphism

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 51, Issue 10
          OOPSLA '16
          October 2016
          915 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/3022671
          Issue’s Table of Contents
          • cover image ACM Conferences
            OOPSLA 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications
            October 2016
            915 pages
            ISBN:9781450344449
            DOI:10.1145/2983990

          Copyright © 2016 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 19 October 2016

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!