Abstract
Object-oriented languages have suffered from poor performance caused by frequent and slow dynamically-bound procedure calls. The best way to speed up a procedure call is to compile it out, but dynamic binding of object-oriented procedure calls without static receiver type information precludes inlining.Iterative type analysis andextended message splitting are new compilation techniques that extract much of the necessary type information and make it possible to hoist run-time type tests out of loops.
Our system compiles code on-the-fly that is customized to the actual data types used by a running program. The compiler constructs a control flow graph annotated with type information by simultaneously performing type analysis and inlining. Extended message splitting preserves type information that would otherwise be lost by a control-flow merge by duplicating all the code between the merge and the place that uses the information. Iterative type analysis computes the types of variables used in a loop by repeatedly recompiling the loop until the computed types reach a fix-point. Together these two techniques enable our SELF compiler to split off a copy of an entire loop, optimized for the common-case types.
By the time our SELF compiler generates code for the graph, it has eliminated many dynamically-dispatched procedure calls and type tests. The resulting machine code is twice as fast as that generated by the previous SELF compiler, four times faster than ParcPlace Systems Smalltalk-80, the fastest commercially available dynamically-typed object-oriented language implementation, and nearly half the speed of optimized C. Iterative type analysis and extended message splitting have cut the performance penalty for dynamically-typed object-oriented languages in half.
Similar content being viewed by others
References
Aho, A. V., Sethi, R., and Ullman, J. D.Compilers: Principles, Techniques, and Tools. Addison-Wesley, Reading, MA (1986).
Chambers, C., and Ungar, D. Customization: Optimizing Compiler Technology for SELF, a Dynamically-Typed Object-Oriented Programming Language. InProceedings of the SIGPLAN '89 Conference on Programming Language Design and Implementation. Published asSIGPLAN Notices, 24, 7 (1989) 146–160.
Chambers, C., Ungar, D., and Lee, E. An Efficient Implementation of SELF, a Dynamically-Typed Object-Oriented Language Based on Prototypes. InOOPSLA '89 Conference Proceedings. Published asSIGPLAN Notices, 24, 10 (1989) 49–70. Also inLisp and Symbolic Computation, 4, 3 (1991) 243–281.
Deutsch, L. P., and Schiffman, A. M. Efficient Implementation of the Smalltalk-80 System. InProceedings of the 11th Annual ACM Symposium on the Principles of Programming Languages (1984) 297–302.
Goldberg, A., and Robson, D.Smalltalk-80: The Language and Its Implementation. Addison-Wesley, Reading, MA (1983).
Graver, J. O.Type-Checking and Type-Inference for Object-Oriented Programming Languages. Ph.D. thesis, University of Illinois at Urbana-Champaign (1989).
Graver, J. O., and Johnson, R. E. A Type System for Smalltalk. InConference Record of the 17th Annual ACM Symposium on Principles of Programming Languages (1990) 136–150.
Heintz, R. L., Jr.Low Level Optimizations for an Object-Oriented Programming Language. Master's thesis, University of Illinois at Urbana-Champaign (1990).
Hennessy, J. Stanford integer benchmarks. Personal communication (1988).
Johnson, R. E. Type-Checking Smalltalk. InOOPSLA '86 Conference Proceedings. Published asSIGPLAN Notices, 21, 11 (1986) 315–321.
Johnson, R. E., Graver, J. O., and Zurawski, L. W. TS: An Optimizing Compiler for Smalltalk. InOOPSLA '88 Conference Proceedings. Published asSIGPLAN Notices, 23, 11 (1988) 18–26.
Lee, E.Object Storage and Inheritance for SELF, a Prototype-Based Object-Oriented Programming Language. Engineer's thesis, Stanford University (1988).
McConnell, C. D.The Design of the RTL System. Master's thesis, University of Illinois at Urbana-Champaign (1989).
Milner, R., Tofte, M., and Harper, R.The Definition of Standard ML. MIT Press, Cambridge, MA (1990).
Mitchell, J. Personal communication (1989).
Ohori, A., and Buneman, P. Static Type Inference for Parametric Classes. InOOPSLA '89 Conference Proceedings. Published asSIGPLAN Notices, 24, 10 (1989) 445–456.
Padua, D. A., and Wolfe, M. J. Advanced Compiler Optimizations for Supercomputers. InCommunications of the ACM, 29, 12 (1986) 1184–1201.
Rees, J., and Clinger, W., editors.Revised 3 Report on the Algorithmic Language Scheme (1986).
Sestoft, P., and Søndergaard, H. A Bibliography on Partial Evaluation. InSIGPLAN Notices, 23, 2 (1988) 19–27.
Ungar, D. M.The Design and Evaluation of a High-Performance Smalltalk System. Ph.D. thesis, the University of California at Berkeley (1986). Published by the MIT Press, Cambridge, MA (1987).
Ungar, D. A Performance Comparison of C, SELF, and Smalltalk Implementations. Unpublished manuscript (1989).
Ungar, D., and Smith, R. B. SELF: The Power of Simplicity. InOOPSLA '87 Conference Proceedings. Published asSIGPLAN Notices, 22, 12 (1987) 227–241. Also inLisp and Symbolic Computation, 4, 3 (1991) 187–205.
Wand, M. Complete Type Inference for Simple Objects. InProceedings of the 2nd IEEE Symposium on Logic in Computer Science (1987) 37–44.
Wand, M. Type Inference for Record Concatenation and Multiple Inheritance. InProceedings of the 4th IEEE Symposium on Logic in Computer Science (1989) 92–97.
Author information
Authors and Affiliations
Additional information
This work has been generously supported by National Science Foundation Presidential Young Investigator Grant #CCR-8657631, and by Sun Microsystems, IBM, Apple Computer, Tandem Computers, NCR, Texas Instruments, the Powell Foundation, and DEC.
This paper was originally published in theProceedings of the ACM SIGPLAN '90 Conference on Programming Language Design and Implementation (SIGPLAN Notices, 25, 6 (1990) 150–160).
Rights and permissions
About this article
Cite this article
Chambers, C., Ungar, D. Iterative type analysis and extended message splitting: Optimizing dynamically-typed object-oriented programs. Lisp and Symbolic Computation 4, 283–310 (1991). https://doi.org/10.1007/BF01806109
Issue Date:
DOI: https://doi.org/10.1007/BF01806109