article

Using types to analyze and optimize object-oriented programs

Abstract

Object-oriented programming languages provide many software engineering benefits, but these often come at a performance cost. Object-oriented programs make extensive use of method invocations and pointer dereferences, both of which are potentially costly on modern machines. We show how to use types to produce effective, yet simple, techniques that reduce the costs of these features in Modula-3, a statically typed, object-oriented language. Our compiler performs type-based alias analysis to disambiguate memory references. It uses the results of the type-based alias analysis to eliminate redundant memory references and to replace monomorphic method invocation sites with direct calls. Using limit, static, and running time evaluation, we demonstrate that these techniques are effective, and sometimes perfect for a set of Modula-3 benchmarks.

References

  1. Agesen, O. and Holzle, U. 1995. Type feedback vs. concrete type inference: A comparison of optimization techniques for object-oriented languages. In Proceedings of the ACM SIGPLAN '95 Conference on Object-Oriented Programming Systems, Languages, and Applications. ACM, Austin, Texas, 91-107. Google ScholarGoogle Scholar
  2. Aho, A. V., Sethi, R., and Ullman, J. D. 1986. Compilers: Principles, Techniques, and Tools. Addison-Wesley. Google ScholarGoogle Scholar
  3. Aigner, G. and Holzle, U. 1996. Eliminating virtual function calls in C++ programs. In Proceedings of European Conference on Object-Oriented Programming. Linz, Austria, 142-166. Google ScholarGoogle Scholar
  4. Anderson, L. O. 1994. Program analysis and specialization for the C programming language. Ph.D. thesis, DIKU.Google ScholarGoogle Scholar
  5. Bacon, D. and Sweeney, P. 1996. Fast static analysis of C++ virtual function calls. In Proceedings of the ACM SIGPLAN '96 Conference on Object-Oriented Programming Systems, Languages, and Applications. ACM, ACM Press, San Jose, CA, 324-341. Google ScholarGoogle Scholar
  6. Banning, J. 1979. An efficient way to effnd side effects of procedure calls and aliases of variables. In Conference Record of the Sixth Annual ACM SIGACT/SIGPLAN Symposium on Principles of Programming Languages. San Antonio, Texas, 29-41. Google ScholarGoogle Scholar
  7. Bates, R. M. 1994. K-trees. Personal communication.Google ScholarGoogle Scholar
  8. Burke, M., Carini, P. R., Choi, J.-D., and Hind, M. 1994. Ecient ow-insensitive alias analysis in the presence of pointers. Tech. Rep. 19546, IBM T.J. Watson Research Center, Yorktown Heights, NY. Sept.Google ScholarGoogle Scholar
  9. Calder, B. and Grunwald, D. 1994. Reducing indirect function call overhead in C++ programs. In 21st Symposium on Principles of Programming Languages. ACM, Portland, Oregon, 397- 408. Google ScholarGoogle Scholar
  10. Calder, B., Grunwald, D., and Emer, J. 1995. A system level perspective on branch architecture performance. In 28th International Symposium on Microarchitecture. 199-206. Google ScholarGoogle Scholar
  11. Calder, B., Grunwald, D., and Zorn, B. 1994. Quantifying behavioral differences between C and C++ programs. Tech. Rep. CU-CS-698-94, University of Colorado, Boulder, CO. Jan.Google ScholarGoogle Scholar
  12. Chambers, C. 1992. The design and evaluation of the SELF compiler, an optimizing compiler for object-oriented programming languages. Ph.D. thesis, Stanford University, CA. Google ScholarGoogle Scholar
  13. Chambers, C., Dean, J., and Grove, D. 1996. Whole-program optimization of object-oriented languages. Tech. Rep. 96-06-02, University of Washington, Seattle, Washington. June. Google ScholarGoogle Scholar
  14. Chambers, C. and Ungar, D. 1989. Customization: Optimizing compiler technology for SELF, a dynamically-typed object-oriented programming language. In Proceedings of the ACM SIG- PLAN '89 Conference on Programming Language Design and Implementation. 146-160. Google ScholarGoogle Scholar
  15. Chambers, C. and Ungar, D. 1991. Making pure object oriented languages practical. In Proceedings of the ACM SIGPLAN '91 Conference on Object-Oriented Programming Systems, Languages, and Applications. 1-15. Google ScholarGoogle Scholar
  16. Chase, D. R., Wegman, M., and Zadeck, F. K. 1990. Analysis of pointers and structures. In Proceedings of the ACM SIGPLAN '90 Conference on Programming Language Design and Implementation. 296-310. Google ScholarGoogle Scholar
  17. Chatterjee, R., Ryder, B. G. , and Landi, W. A. 1999. Relevant context inference. In Proceedings of 26th ACM SIGACT/SIGPLAN Symposium on Principles of Programming Languages. ACM, 133-146. Google ScholarGoogle Scholar
  18. Chatterjee, R. K. and Ryder, B. G. 1997a. Modular concrete type-inference for statically typed object-oriented programming languages. Tech. Rep. DCS-TR-349, Rutgers University. Nov.Google ScholarGoogle Scholar
  19. Chatterjee, R. K. and Ryder, B. G. 1997b. Scalable, ow-sensitive type-inference for statically typed object-oriented programming languages. Tech. Rep. DCS-TR-326, Rutgers University. July.Google ScholarGoogle Scholar
  20. Choi, J.-D., Burke, M., and Carini, P. 1993. Efficient ow-sensitive interprocedural computation of pointer-induced aliases and side effects. In Conference Record of the Twentieth Annual ACM SIGACT/SIGPLAN Symposium on Principles of Programming Languages. Charleston, SC, 232-245. Google ScholarGoogle Scholar
  21. Cooper, K.andLu, J.1997. Register promotion in C programs. In Proceedings of the ACM SIGPLAN '97 Conference on Programming Language Design and Implementation. Las Vegas, Nevada, 308-319. Google ScholarGoogle Scholar
  22. Cooper, K. D. and Kennedy, K. 1989. Fast interprocedural alias analysis. In Conference Record of the Sixteenth Annual ACM SIGACT/SIGPLAN Symposium on Principles of Programming Languages. 49-59. Google ScholarGoogle Scholar
  23. Dean, J., Chambers, C., and Grove, D. 1994. Identifying profitable specialization in objectoriented languages. In ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation. Association of Computing Machinery, Orlando, FL.Google ScholarGoogle Scholar
  24. Dean, J., DeFouw, G., Grove, D., Litvinov, V., and Chambers, C. 1996. Vortex: An optimizing compiler for object-oriented languages. In Proceedings of the ACM SIGPLAN '96 Conference on Object-Oriented Programming Systems, Languages, and Applications. San Jose, CA, 83-100. Google ScholarGoogle Scholar
  25. Dean, J., Grove, D., and Chambers, C. 1995. Optimization of object-oriented programs using static class hierarchy analysis. In Proceedings of European Conference on Object-Oriented Programming. Aarhus, Denmark, 77-101. Google ScholarGoogle Scholar
  26. Debray, S., Muth, R., and Weippert, M. 1998. Alias analysis of executable code. In Conference Record of the Twenty Fifth Annual ACM SIGPLAN/SIGACT Symposium on Principles of Programming Languages. Google ScholarGoogle Scholar
  27. DeFouw, G., Grove, D., and Chambers, C. 1998. Fast interprocedural class analysis. In Proceedings of the 25th ACM SIGPLAN-SIGACT symposium on Principles of programming languages. ACM, 222-236. Google ScholarGoogle Scholar
  28. Deutsch, A. 1994. Interprocedural May-Alias analysis for pointers: Beyond k-limiting. In Proceedings of the ACM SIGPLAN '94 Conference on Programming Language Design and Implementation. 230-241. Google ScholarGoogle Scholar
  29. Diwan, A. 1996. Understanding and improving the performance of modern programming languages. Ph.D. thesis, University of Massachusetts, Amherst, MA 01003. Google ScholarGoogle Scholar
  30. Diwan, A., McKinley, K. S., and Moss, J. E. B. 1998. Type-based alias analysis. In Proceedings of the ACM SIGPLAN '98 Conference on Programming Language Design and Implementation. Montreal, 106-117. Google ScholarGoogle Scholar
  31. Diwan, A., Moss, E., and McKinley, K. S. 1996. Simple and effective analysis of statically typed object-oriented programs. In Proceedings of the ACM SIGPLAN '96 Conference on Object-Oriented Programming Systems, Languages, and Applications. San Jose, CA, 292-305. Google ScholarGoogle Scholar
  32. Driesen, K. and Holzle, U. 1996. The direct cost of virtual function calls in C++. In Proceedings of the ACM SIGPLAN '96 Conference on Object-Oriented Programming Systems, Languages, and Applications. San Jose, CA, 306-323. Google ScholarGoogle Scholar
  33. Emami, M., Ghiya, R., and Hendren, L. J. 1994. Context-sensitive interprocedural Pointsto analysis in the presence of function pointers. In Proceedings of the ACM SIGPLAN '94 Conference on Programming Language Design and Implementation. 242-256. Google ScholarGoogle Scholar
  34. Emer, J., Webb, D., and McCallig, M. 1996. Zippy simulator for alpha workstations. Software.Google ScholarGoogle Scholar
  35. Fernandez, M. F. 1995. Simple and effective link-time optimization of Modula-3 programs. In Proceedings of Conference on Programming Language Design and Implementation. SIGPLAN, ACM Press, La Jolla, CA, 103-115. Google ScholarGoogle Scholar
  36. Ghiya, R. and Hendren, L. J. 1998. Putting pointer analysis to work. In Conference Record of the Twenty Fifth Annual ACM SIGPLAN/SIGACT Symposium on Principles of Programming Languages. 121-133. Google ScholarGoogle Scholar
  37. Grove, D., Dean, J., Garrett, C., and Chambers, C. 1995. Profile-guided receiver class prediction. In Proceedings of the ACM SIGPLAN '95 Conference on Object-Oriented Programming Systems, Languages, and Applications. ACM, Austin, Texas, 108-123. Google ScholarGoogle Scholar
  38. Hall, M. W. 1991. Managing interprocedural optimizations. Ph.D. thesis, Rice University, Houston, Texas. Google ScholarGoogle Scholar
  39. Hennessy, J. and Patterson, D. 1995. Computer Architecture A Quantitative Approach. Morgan-Kaufmann. Google ScholarGoogle Scholar
  40. Hind, M., Burke, M., Carini, P., and Choi, J.-D. 1999. Interprocedural pointer alias analysis. ACM Transactions on Programming Languages and Systems 21, 4 (July), 848-894. Google ScholarGoogle Scholar
  41. Holzle, U. and Ungar, D. 1994. Optimizing dynamically-dispatched calls with run-time type feedback. In Proceedings of the ACM SIGPLAN '94 Conference on Programming Language Design and Implementation. ACM, 326-336. Google ScholarGoogle Scholar
  42. Hummel, J., Hendren, L. J., and Nicolau, A. 1994. A general data dependence test for dynamic, pointer-based data structures. In Proceedings of the ACM SIGPLAN '94 Conference on Programming Language Design and Implementation. 218-229. Google ScholarGoogle Scholar
  43. Kalsow, B. and Muller, E. 1995. SRC Modula-3 Version 3.5. Systems Research Center, Digital Equipment Corporation, Palo Alto, CA.Google ScholarGoogle Scholar
  44. Kam, J. B. and Ullman, J. D. 1976. Global data ow analysis and iterative algorithms. Journal of the ACM 7, 3, 305-318. Google ScholarGoogle Scholar
  45. Landi, W. and Ryder, B. G. 1991. Pointer-induced aliasing: a problem classification. In Conference Record of the Eighteenth Annual ACM SIGACT/SIGPLAN Symposium on Principles of Programming Languages. Orlando, FL, 93-103. Google ScholarGoogle Scholar
  46. Landi, W. and Ryder, B. G. 1992. Interprocedural side effect analysis with pointer aliasing. In Proceedings of the ACM SIGPLAN '92 Conference on Programming Language Design and Implementation. San Francisco, CA, 235-248. Google ScholarGoogle Scholar
  47. Larus, J. R. and Chandra, S. 1993. Using tracing and dynamic slicing to tune compilers. University of Wisconsin Technical Report 1174.Google ScholarGoogle Scholar
  48. Larus, J. R. and Hilfinger, P. N. 1988. Detecting con icts between structure accesses. In Proceedings of the ACM SIGPLAN '88 Conference on Programming Language Design and Implementation. Atlanta, GA, 21-34. Google ScholarGoogle Scholar
  49. Liskov, B. and Guttag, J. 1986. Abstraction and Specification in Program Development. MIT Press. Google ScholarGoogle Scholar
  50. Lucassen, J. M. and Gifford, D. 1988. Polymorphic effect systems. In 15th ACM SIGPLAN- SIGACT Symposium on Principles of Programming Languages. ACM, 47-57. Google ScholarGoogle Scholar
  51. Nayeri, F., Hurwitz, B., and Manola, F. 1994. Generalizing dispatching in a distributed object system. In Proceedings of European Conference on Object-Oriented Programming. Bologna, Italy, 450-473. Google ScholarGoogle Scholar
  52. Nelson, G., Ed. 1991. Systems Programming with Modula-3. Prentice Hall, New Jersey. Google ScholarGoogle Scholar
  53. Nystrom, N., Hosking, A. L., Whitlock, D., Cutts, Q., and Diwan, A. 1999. Partial redundancy elimination for access path expressions. In Proceedings of the International Workshop on Aliasing in Object-Oriented Systems. Lisbon, Portugal. Revision of Purdue University Computer Sciences Technical Report 98-044.Google ScholarGoogle Scholar
  54. Palsberg, J. and Schwartzbach, M. I. 1991. Object-oriented type inference. In Proceedings of the ACM SIGPLAN '91 Conference on Object-Oriented Programming Systems, Languages, and Applications. SIGPLAN, ACM Press, Pheonix, Arizona, 146-162. Google ScholarGoogle Scholar
  55. Pande, H. and Ryder, B. G. 1995. Static type determination and aliasing for C++. Tech. Rep. LCSR-TR-250, Rutgers University. July. A version of this appeared in Proceedings of the Third International Static Analysis Symposium (SAS'96).Google ScholarGoogle Scholar
  56. Plevyak, J. and Chien, A. 1994. Precise concrete type inference for object-oriented languages. In Proceedings of the ACM SIGPLAN '94 Conference on Object-Oriented Programming Systems, Languages, and Applications. ACM, 324-340. Google ScholarGoogle Scholar
  57. Reinig, A. G. 1998. Alias analysis in the DEC C and DIGITAL C++ compilers. DIGITAL Technical Journal 10, 1 (Dec.).Google ScholarGoogle Scholar
  58. Rinard, M. C. and Diniz, P. C. 1996. Commutativity analysis: A new analysis framework for parallelizing compilers. In Proceedings of the ACM SIGPLAN '96 Conference on Programming Language Design and Implementation. Philadelphia, PA, 54-67. Google ScholarGoogle Scholar
  59. Ruf, E. 1995. Context-insensitive alias analysis reconsidered. In Proceedings of the ACM SIG- PLAN '95 Conference on Programming Language Design and Implementation. La Jolla, CA, 13-22. Google ScholarGoogle Scholar
  60. Ruf, E. 1997. Partitioning data ow analyses using types. In Conference Record of the Twenty Fourth Annual ACM SIGPLAN/SIGACT Symposium on Principles of Programming Languages. Paris, France, 15-26. Google ScholarGoogle Scholar
  61. Shapiro, M. and Horwitz, S. 1997a. The effects of the precision of pointer analysis. In Lecture Notes in Computer Science, 1302, P. V. Hentenryck, Ed. Springer-Verlag, 16-34. Proceedings from the 4th International Static Analysis Symposium. Google ScholarGoogle Scholar
  62. Shapiro, M. and Horwitz, S. 1997b. Fast and accurate ow-insensitive points-to analysis. In Conference Record of the Twenty Fourth Annual ACM SIGPLAN/SIGACT Symposium on Principles of Programming Languages. Paris, France, 1-14. Google ScholarGoogle Scholar
  63. Shivers, O. 1991. Control-Flow Analysis of Higher-Order Languages. Ph.D. thesis, Carnegie- Mellon University, Pittsburgh, PA. Google ScholarGoogle Scholar
  64. Srivastava, A. and Eustace, A. 1994. ATOM: A system for building customized program analysis tools. In Proceedings of the ACM SIGPLAN '94 Conference on Programming Language Design and Implementation. Association of Computing Machinery, Orlando, FL, 196-205. Google ScholarGoogle Scholar
  65. Stallman, R. M. 1989. Gnu C Compiler. Free Software Foundation, Cambridge, MA. Software distribution.Google ScholarGoogle Scholar
  66. Steensgaard, B. 1996. Points-to analysis in almost linear time. In Conference Record of the Twenty Third Annual ACM SIGPLAN/SIGACT Symposium on Principles of Programming Languages. Association of Computing Machinery, 32-41. Google ScholarGoogle Scholar
  67. Sun Microsystems Computer Corporation 1995. The Java language specification, 1.0 Beta ed. Sun Microsystems Computer Corporation.Google ScholarGoogle Scholar
  68. Tarjan, R. E. 1975. On the efficiency of a good but not linear set union algorithm. Journal of the ACM 22, 2, 215-225. Google ScholarGoogle Scholar
  69. Wall, D. W. 1991. Limits of instruction-level parallelism. In Proceedings of the Fourth International Conference on Architectural Support for Programming Languages and Operating Systems. Santa Clara, California, 176-189. Google ScholarGoogle Scholar
  70. Weihl, W. E. 1980. Interprocedural data ow analysis in the presence of pointers, procedure variables and label variables. In Conference Record of the Seventh Annual ACM SIGACT/SIGPLAN Symposium on Principles of Programming Languages. Las Vegas, Nevada, 83-94. Google ScholarGoogle Scholar
  71. Wilson, R. P. 1997. Efficient context-sensitive pointer analysis for C programs. Ph.D. thesis, Stanford University, Palo Alto, CA. Google ScholarGoogle Scholar
  72. Wilson, R. P. and Lam, M. S. 1995. Efficient context-sensitive pointer analysis for C programs. In Proceedings of the ACM SIGPLAN '95 Conference on Programming Language Design and Implementation. Association of Computing Machinery, La Jolla, CA, 1-12. Google ScholarGoogle Scholar

Index Terms

  1. Using types to analyze and optimize object-oriented programs

    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

    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!