Abstract
We have designed and implemented an optimizing source-to-source C++ compiler that reduces the frequency of virtual function calls. Our prototype implementation demonstrates the value of OO-specific optimization for C++. Despite some limitations of our system, and despite the low frequency of virtual function calls in some of the programs, optimization improves the performance of a suite of large C++ applications totalling over 90,000 lines of code by a median of 18% over the original programs and reduces the number of virtual function calls by a median factor of five. For more call-intensive versions of the same programs, performance improved by a median of 26% and the number of virtual calls dropped by a factor of 17.5. Our measurements indicate that inlining barely increases code size, and that for most programs, the instruction cache miss ratio does not increase significantly.
This is a preview of subscription content, log in via an institution.
Preview
Unable to display preview. Download preview PDF.
References
Ole Agesen. The Cartesian Product Algorithm: Simple and Precise Type Inference of Parametric Polymorphism. In ECOOP'95, Ninth European Conference on Object-Oriented Programming, p. 2–26, århus, Denmark, August 1995. Springer-Verlag LNCS 952.
Ole Agesen and Urs Hölzle. Type Feedback vs. Concrete Type Inference: A Comparison of Optimization Techniques for Object-Oriented Languages. In OOPSLA'95, Object-Oriented Programming Systems, Languages and Applications, p. 91–107, Austin, TX, October 1995.
Apple Computer, Inc. Object Pascal User's Manual. Cupertino, 1988.
David Bernstein, Yaroslav Fedorov, Sara Porat, Joseph Rodrigue, and Eran Yahav. Compiler Optimization of C++ Virtual Function Calls. 2nd Conference on Object-Oriented Technologies and Systems, Toronto, Canada, June 1996.
Brad Calder, Dirk Grunwald, and Benjamin Zorn. Quantifying Behavioral Differences Between C and C++ Programs. Journal of Programming Languages 2:313–351, 1994.
Brad Calder and Dirk Grunwald. Reducing Indirect Function Call Overhead in C++ Programs. In 21st Annual ACM Symposium on Principles of Programming Languages, p. 397–408, January 1994.
Craig Chambers, David Ungar, and Elgin Lee. An Efficient Implementation of SELF, a Dynamically-Typed Object-Oriented Language Based on Prototypes. In OOPSLA '89, Object-Oriented Programming Systems, Languages and Applications, p. 49–70, New Orleans, LA, October 1989. Published as SIGPLAN Notices 24(10), October 1989.
Craig Chambers and David Ungar. Iterative Type Analysis and Extended Message Splitting: Optimizing Dynamically-Typed Object-Oriented Programs. In Proceedings of the SIGPLAN '90 Conference on Programming Language Design and Implementation, p. 150–164, White Plains, NY, June 1990. Published as SIGPLAN Notices 25(6), June 1990.
Pohua P. Chang, Scott A. Mahlke, William Y. Chen, and Wen-Mei W. Hwu. Profile-guided automatic inline expansion for C programs. Software—Practice and Experience 22 (5): 349–369, May 1992.
K. D. Cooper, M. W. Hall, and L. Torczon. An experiment with inline substitution. Software—Practice and Experience 21 (6): 581–601, June 1991.
Jack W. Davidson and Anne M. Holler. A study of a C function inliner. Software—Practice and Experience 18(8): 775–90, August 1988.
Jeffrey Dean and Craig Chambers. Towards Better Inlining Decisions using Inlining Trials. In Proceedings of the ACM Symposium on Lisp and Functional Programming Languages (LFP '94), Orlando, FL, June 1994.
Jeffrey Dean, Craig Chambers, and David Grove. Identifying Profitable Specialization in Object-Oriented Languages. In Proceedings of the SIGPLAN '95 Conference on Programming Language Design and Implementation, La Jolla, CA June 1995.
Jeffrey Dean, David Grove, and Craig Chambers. Optimization of Object-Oriented Programs Using Static Class Hierarchy Analysis. In ECOOP '95, Ninth European Conference on Object-Oriented Programming, århus, 1995. Springer-Verlag LNCS 952.
Jeffrey Dean. Corrected Cecil performance numbers. Private communication, May 1995.
Declarative Systems. The C++ Auditor. Palo Alto, 1995. (auditor@declarative.com)
Karel Driesen, Urs Hölzle, and Jan Vitek. Message Dispatch On Pipelined Processors. ECOOP '95 Conference Proceedings, Aarhus, Denmark, August 1995. Published as Springer Verlag Lecture Notes in Computer Science 952, Springer Verlag, Berlin, 1995.
L. Peter Deutsch and Alan Schiffman. Efficient Implementation of the Smalltalk-80 System. In Conference Record of the Eleventh Annual ACM Symposium on Principles of Programming Languages, p. 297–302, Salt Lake City, UT, January 1984.
L. Peter Deutsch. Reusability in the Smalltalk-80 system. Workshop On Reusability In Programming, Newport, RI, 1983.
Margaret A. Ellis and Bjarne Stroustrup. The Annotated C++ Reference Manual. Addison-Wesley, Reading, MA, 1990.
M. F. Fernandez. Simple and effective link-time optimization of Modula-3 programs. In Proceedings of the SIGPLAN '95 Conference on Programming Language Design and Implementation, p. 103–115, La Jolla, CA, June 1995. Published as SIGPLAN Notices 30(6), June 1995.
David Grove, Jeffrey Dean, Charles D. Garrett, and Craig Chambers. Profile-Guided Receiver Class Prediction. In OOPSLA '95, Object-Oriented Programming Systems, Languages and Applications, p. 108–123, Austin, TX, October 1995.
Mary Wolcott Hall. Managing Interprocedural Optimization. Technical Report COMP TR91-157 (Ph.D. Thesis), Computer Science Department, Rice University, April 1991.
Urs Hölzle, Craig Chambers, and David Ungar. Optimizing Dynamically-Typed Object-Oriented Languages with Polymorphic Inline Caches. In ECOOP '91, Fourth European Conference on Object-Oriented Programming, p. 21–38, Geneva, July 1991. Springer-Verlag LNCS 512.
Urs Hölzle. Adaptive Optimization for SELF: Reconciling High Performance with Exploratory Programming. Ph.D. Thesis, Department of Computer Science, Stanford University, August 1994. (Available via http://www.cs.ucsb.edu/~urs.)
Urs Hölzle and David Ungar. Optimizing Dynamically-Dispatched Calls with Run-Time Type Feedback. In Proceedings of the SIGPLAN '94 Conference on Programming Language Design and Implementation, p. 326–336. Published as SIGPLAN Notices 29(6), June 1994.
W. W. Hwu and P. P. Chang. Inline function expansion for compiling C programs. In Proceedings of the SIGPLAN '89 Conference on Programming Language Design and Implementation, p. 246–57, Portland, OR, June 1989. Published as SIGPLAN Notices 24(7), July 1989.
Donald Knuth. An empirical study of FORTRAN programs. Technical Report CS-186, Department of Computer Science, Stanford University, 1970.
Douglas Lea. Customization in C++. In Proceedings of the 1990 Usenix C++ Conference, p. 301–314, San Francisco, CA, April, 1990.
Hemant D. Pande and Barbara G. Ryder. Static Type Determination and Aliasing for C++. Technical Report LCSR-TR-236, Rutgers University, December 1994.
John B. Plevyak and Andrew A. Chien. Precise Concrete Type Inference for Object-Oriented Languages. OOPSLA '94, Object-Oriented Programming Systems, Languages and Applications, p. 324–340, Portland, OR, October 1994. Published as SIGPLAN Notices 29(10), October 1994.
Mauricio Serrano. Virtual function call frequencies in C++ programs. Private communication, 1995.
Amitabh Srivastava and David Wall. A Practical System for Intermodule Code Optimization at Link-Time. DEC WRL Research Report 92/6, December 1992.
David Ungar and Randall B. Smith. SELF: The Power of Simplicity. In OOPSLA '87, Object-Oriented Programming Systems, Languages and Applications, p. 227–241, Orlando, FL, October 1987. Published as SIGPLAN Notices 22(12), December 1987. Also published in Lisp and Symbolic Computation 4(3), Kluwer Academic Publishers, June 1991.
David Wall. Predicting Program Behavior Using Real or Estimated Profiles. In Proceedings of the SIGPLAN '91 Conference on Programming Language Design and Implementation, p. 59–70, Toronto, Canada, June 1991. Published as SIGPLAN Notices 26(6), June 1991.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1996 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Aigner, G., Hölzle, U. (1996). Eliminating virtual function calls in C++ programs. In: Cointe, P. (eds) ECOOP ’96 — Object-Oriented Programming. ECOOP 1996. Lecture Notes in Computer Science, vol 1098. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0053060
Download citation
DOI: https://doi.org/10.1007/BFb0053060
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-61439-5
Online ISBN: 978-3-540-68570-8
eBook Packages: Springer Book Archive