Abstract
A fundamental problem in the implementation of object-oriented languages is that of a frugal implementation of dynamic dispatching, that is, a small footprint data structure that supports quick response to runtime dispatching queries of the following format: which method should be executed in response to a certain message sent to a given object. Previous theoretical algorithms for this problem tend to be impractical due to their conceptual complexity and large hidden constants. In contrast, successful practical heuristics lack theoretical support.
The contribution of this article is in a novel type slicing technique, which results in two dispatching schemes: TS and CTd. We make the case for these schemes both practically and theoretically. The empirical findings on a corpus of 35 hierarchies totaling some 64 thousand types from eight different languages, demonstrate improvement over previous results in terms of the space required for the representation, and the time required for computing it.
The theoretical analysis is with respect to ι, the best possible compression factor of the dispatching matrix. The results are expressed as a function of a parameter κ, which can be thought of as a metric of the complexity of the topology of a multiple inheritance hierarchy. In single inheritance hierarchies κ = 1, but although κ can be in the order of the size of the hierarchy, it is typically a small constant in actual use of inheritance; in our corpus, the median value of κ is 5, while its average is 6.4.
The TS scheme generalizes the famous interval containment technique to multiple inheritance. TS achieves a compression factor of ι/κ, that is, our generalization comes with an increase to the space requirement by a small factor of κ. The pay is in the dispatching time, which is no longer constant as in a naive matrix implementation, but logarithmic in the number of different method implementations. In practice, dispatching uses one indirect branch and, on average, only 2.5 binary branches.
The CT schemes are a sequence of algorithms CT1, CT2, CT3, …, where CTd uses d memory dereferencing operations during dispatch, and achieves a compression factor of 1/dι1−1/d in a single inheritance setting. A generalization of these algorithms to a multiple inheritance setting, increases the space by a factor of (2κ)1−1/d. This trade-off represents the first bounds on the compression ratio of constant-time dispatching algorithms. We also present an incremental variant of the CTd suited for languages such as Java.
- Alpern, B., Cocchi, A., Fink, S., Grove, D., and Lieber, D. 2001. Efficient implementation of Java interfaces: invokeinterface considered harmless. In Proceedings of the 14th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA '01) (Tampa Bay, FL). ACM SINGLAN Notices 38, 11, ACM, New York. Google Scholar
Digital Library
- Arnold, P. and Gosling, J. 1996. The Java Programming Language. The Java Series. Addison-Wesley, Reading, MA. Google Scholar
Digital Library
- Bobrow, D. G., DeMichiel, L. G., Gabriel, R. P., Keene, S. E., Kiczales, G., and Moon, D. A. 1988. Common LISP object system specification. X3J13 Document 88-002R.Google Scholar
- Bobrow, D. G., Kahn, K., Kiczales, G., Masinter, L., Stefik, M., and Zdybel, F. 1986. CommonLoops: Merging LISP and object-oriented programming. In Proceedings of the 1st Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'86) (Portland, OR), N. K. Meyrowitz, Ed. ACM SIGPLAN Notices 21, 11, ACM, New York, 17--29. Google Scholar
Digital Library
- Booth, K. S. and Leuker, G. S. 1976. Testing for the consecutive ones property, interval graphs, and graph planarity using PQ-tree algorithms. J. Comput. Syst. Sci. 13, 3 (Dec.), 335--379.Google Scholar
Digital Library
- Chambers, C. 1993. The Cecil language, specification and rationale. Tech. Rep. TR-93-03-05, University of Washington, Seattle, WA.Google Scholar
- Chambers, C. and Chen, W. 1999. Efficient multiple and predicate dispatching. In Proceedings of the 14th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA '99) (Denver, CD). ACM SIGPLAN Notices 34, 10, ACM, New York, 238--255. Google Scholar
Digital Library
- Cohen, T. and Gil, J. 2000. Self-calibration of metrics of Java methods. In Proceedings of the 37th International Conference on Technology of Object-Oriented Languages and Systems (TOOLS'00 Pacific) (Sydney, Australia). Prentice-Hall, Englewood Cliffs, NJ, 94--106.Google Scholar
- Conroy, T. J. and Pelegri-Llopart, E. 1983. An assessment of method-lookup caches for Smalltalk-80 implementations. In Smalltalk-80: Bits of History, Words of Advice. Addison-Wesley, Reading, MA.Google Scholar
- Cox, B. J. 1986. Object-Oriented Programming---An Evolutionary Approach. Addison-Wesley, Reading, MA. Google Scholar
Digital Library
- Deutsch, P. and Schiffman, A. 1984. Efficient implementation of the Smalltalk-80 system. In Proceedings of the 11th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL'84) (Salt Lake City, VT). ACM, New York, 297--302. Google Scholar
Digital Library
- Dietz, P. F. and Sleator, D. D. 1987. Two algorithms for maintaining order in a list. In Proceedings of the 19th Annual ACM Symposium on Theory of Computing (STOC'87), (New York, NY). ACM, New York, 365--372. Google Scholar
Digital Library
- Dietzfelbinger, M., Karlin, A. R., Mehlhorn, K., Meyer auf der Heide, F., Rohnert, H., and Tarjan, R. E. 1994. Dynamic perfect hashing: Upper and lower bounds. SIAM J. Comput. 23, 4 (Aug.), 738--761. Google Scholar
Digital Library
- Dixon, R., McKee, T., Vaughan, M., and Schweizer, P. 1989. A fast method dispatcher for compiled languages with multiple inheritance. In Proceedings of the 4th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'89), N. K. Meyrowitz, Ed., New Orleans, ACM SIGPLAN Notices 24, 10, ACM, New York, 211--214. Google Scholar
Digital Library
- Driesen, K. 1993. Selector table indexing & sparse arrays. In Proceedings of the 8th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'93), A. Paepcke, Ed., (Washington, DC). ACM SIGPLAN Notices 28, 10. ACM, New York, 259--270. Google Scholar
Digital Library
- Driesen, K. 1999. Software and hardware techniques for efficient polymorphic calls. Tech. Rep. TRCS99-24, Computer Sciences Department, University of California, Santa Barbara, CA. Google Scholar
Digital Library
- Driesen, K. and Hölzle, U. 1995. Minimizing row displacement dispatch tables. In Proceedings of the 10th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'95) (Austin, TX). ACM SIGPLAN Notices 30, 10, ACM, New York, 141--155. Google Scholar
Digital Library
- Driesen, K. and Hölzle, U. 1996. The direct cost of virtual functions calls in C++. In Proceedings of the 11th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'96) (San Jose, CA). ACM SIGPLAN Notices 31, 10, ACM, New York, 306--323. Google Scholar
Digital Library
- Driesen, K., Hölzle, U., and Vitek, J. 1995a. Message dispatch on modern computer architectures. Technical Report TRCS94-20, University of California, Santa Barbara, CA. Comput. Sci,. Feb. 9. Google Scholar
Digital Library
- Driesen, K., Hölzle, U., and Vitek, J. 1995b. Message dispatch on pipelined processors. In Proceedings of the 9th European Conference on Object-Oriented Programming (ECOOP'95), W. G. Olthoff, Ed. (Åarhus, Denmark). Lecture Notes in Computer Science, vol. 952. Springer Verlag, New York, 253--282. Google Scholar
Digital Library
- Dujardin, E. 1996. Efficient dispatch of multimethods in constant time using dispatch trees. Tech. Rep. RR-2892. Inria, Institut National de Recherche en Informatique et en Automatique.Google Scholar
- Dujardin, E., Amiel, E., and Simon, E. 1998. Fast algorithms for compressed multimethod dispatch table generation. ACM Trans. Prog. Lang. Syst. 20, 1 (Jan.), 116--165. Google Scholar
Digital Library
- Eckel, N. and Gil, J. 2000. Empirical study of object-layout strategies and optimization techniques. In Proceedings of the 14th European Conference on Object-Oriented Programming (ECOOP'00) E. Bertino, Ed. (Sophia Antipolis and Cannes, France). Lecture Notes in Computer Science, vol. 1850. Springer Verlag, New York, 394--421. Google Scholar
Digital Library
- Ellis, M. A. and Stroustrup, B. 1994. The Annotated C++ Reference Manual. Addison-Wesley, Reading, MA. Google Scholar
Digital Library
- Ferragina, P. and Muthukrishnan, S. 1996. Efficient dynamic method-lookup for object oriented languages (extended abstract). In Proceedings of the 4th Annual European Symposium on Algorithms (ESA'96) (Barcelona, Spain), J. Díaz and M. J. Serna, Eds. Lecture Notes in Computer Science, vol. 1136. Springer Verlag, New York, 107--120. Google Scholar
Digital Library
- Gabow, H. N., Bentley, J. L., and Tarjan, R. E. 1984. Scaling and related techniques for geometry problems. In Proceedings of the 16th Annual ACM Symposium on Theory of Computing (STOC'84) (Washington, DC). ACM Press, New York, 135--143. Google Scholar
Digital Library
- Gil, J. and Itai, A. 1998. The complexity of type analysis of object oriented programs. In Proceedings of the 12th European Conference on Object-Oriented Programming (ECOOP'98) E. Jul, Ed. (Brussels, Belgium), Lecture Notes in Computer Science, vol. 1445. Springer Verlag, New York, 601--634. Google Scholar
Digital Library
- Gil, J. and Sweeney, P. F. 1999. Space- and time-efficient memory layout for multiple inheritance. In Proceedings of the 14th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA '99) (Denver, CO). ACM SIGPLAN Notices 14, 10. ACM, New York, 256--275. Google Scholar
Digital Library
- Goldberg, A. 1984. Smalltalk-80: The Interactive Programming Environment. Addison-Wesley, Reading, MA. Google Scholar
Digital Library
- Holst, W., Szafron, D., Leontiev, Y., and Pang, C. 1998. Multi-method dispatch using single-receiver projections. Tech. Rep. TR-98-03, University of Alberta, Edmonton, Alb., Canada.Google Scholar
- Hölzle, U., Chambers, C., and Ungar, D. 1991. Optimizing dynamically-typed object-oriented languages with polymorphic inline caches. In Proceedings of the 5th European Conference on Object-Oriented Programming (ECOOP'91), P. America, Ed. (Geneva, Switzerland). Lecture Notes in Computer Science, vol. 512. Springer Verlag, New York, 21--38. Google Scholar
Digital Library
- ISE. 1997. ISE EIFFEL The Language Reference. ISE, Santa Barbara, CA.Google Scholar
- Kiczales, G. and Rodriguez, L. 1990. Efficient method dispatch in PCL. In Proceedings of the ACM Conference on LISP and Functional Programming (Nice, France). ACM Press, New York, 99--105. Google Scholar
Digital Library
- Muthukrishnan, S. and Müller, M. 1996. Time and space efficient method-lookup for object-oriented programs. In Proceedings of the 7th Soda, Giovanni (SODA'96). Society for Industrial and Applied Mathematics, New York/Philadelphia, 42--51. Google Scholar
Digital Library
- Naik, M. and Kumar, R. 2000. Efficient message dispatch in object-oriented systems. ACM SIGPLAN Notices 35, 3 (Mar.), 49--58. Google Scholar
Digital Library
- Pang, C., Holst, W., Leontiev, Y., and Szafron, D. 1999. Multi-method dispatch using multiple row displacement. In Proceedings of the 13th European Conference on Object-Oriented Programming (ECOOP'99), R. Guerraoui, Ed. (Lisbon, Portugal). Lecture Notes in Computer Science, vol. 1628. Springer Verlag, New York, 304--328. Google Scholar
Digital Library
- Pascal, A. and Royer, J. 1992. Optimizing method search with lookup caches and incremental coloring. In Proceedings of the 7th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'92), A. Paepcke, Ed. (Vancouver, BC, Canada), ACM SIGPLAN Notices 27, 10. ACM, New York, 110--126. Google Scholar
Digital Library
- Shalit, A. 1997. The Dylan Reference Manual: The Definitive Guide to the New Object-Oriented Dynamic Language. Addison-Wesley, Reading, MA. Google Scholar
Digital Library
- Sleator, D. and Tarjan, R. 1985. Self-adjusting binary search trees. J. ACM 32, 3 (July), 652--686. Google Scholar
Digital Library
- Stroustrup, B. 1994. The Design and Evolution of C++. Addison-Wesley, Reading, MA. Google Scholar
Digital Library
- Stroustrup, B. 1997. The C++ Programming Language, 3rd Ed. Addison-Wesley, Reading, MA. Google Scholar
Digital Library
- van Emde Boas, P. E. 1977. Preserving order in a forest in less than logarithmic time and linear space. Inf. Proc. Lett. 6, 3, 80--82.Google Scholar
Cross Ref
- van Emde Boas, P. E., Kaas, R., and Zijlstra, E. 1977. Design and implementation of an efficient priority queue. Math. Syst. Theory 10, 99--127.Google Scholar
Cross Ref
- Vitek, J. 1995. Compact dispatch tables for dynamically typed programming languages. M.S. thesis, University of Victoria, Victoria, BC, Canada.Google Scholar
- Vitek, J. and Horspool, R. N. 1994. Taming message passing: Efficient method look-up for dynamically typed languages. In Proceedings of the 8th European Conference on Object-Oriented Programming (ECOOP'94), M. Tokoro and R. Pareschi, Eds. (Bologna, Italy). Lecture Notes in Computer Science, vol. 821. Springer Verlag, New York, 432--449. Google Scholar
Digital Library
- Vitek, J. and Horspool, R. N. 1996. Compact dispatch tables for dynamically typed object oriented languages. In Proceedings of the 6th International Conference on Compiler Construction (CC'96), T. Gyimothy, Ed. (Linköping, Sweden), Lecture Notes in Computer Science, vol. 1060. Springer Verlag, New York, 309--325. Google Scholar
Digital Library
- Willard, D. E. 1984. New trie data structures which support very fast search operations. J. Comput. Syst. Sci. 28, 379--394. Google Scholar
Digital Library
- Zendra, O., Colnet, D., and Collin, S. 1997. Efficient dynamic dispatch without virtual function tables: The SmallEiffel compiler. In Proceedings of the 12th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'97) (Atlanta, GA). ACM SIGPLAN Notices 32, 10, ACM, New York, 125--141. Google Scholar
Digital Library
- Zibin, Y. and Gil, J. 2001. Efficient subtyping tests with PQ-encoding. In Proceedings of the 14th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA '99) (Tampa Bay, FL). ACM SIGPLAN Notices. 36, 11, ACM, New York, 96--107. Google Scholar
Digital Library
- Zibin, Y. and Gil, J. 2002. Fast algorithm for creating space efficient dispatching tables with application to multi-dispatching. In Proceedings of the 17th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'02) (Seattle, WA). ACM SIGPLAN Notices 37, 11, ACM, New York, 142--160. Google Scholar
Digital Library
- Zibin, Y. and Gil, J. 2003. Incremental algorithms for dispatching in dynamically typed languages. In Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL'03) (New Orleans, LA). ACM, New York, 126--138. Google Scholar
Digital Library
Index Terms
Efficient dynamic dispatching with type slicing
Recommendations
Incremental algorithms for dispatching in dynamically typed languages
A fundamental problem in the implementation of object-oriented languages is that of a frugal dispatching data structure, i.e., support for quick response to dispatching queries combined with compact representation of the type hierarchy and the method ...
Incremental algorithms for dispatching in dynamically typed languages
POPL '03: Proceedings of the 30th ACM SIGPLAN-SIGACT symposium on Principles of programming languagesA fundamental problem in the implementation of object-oriented languages is that of a frugal dispatching data structure, i.e., support for quick response to dispatching queries combined with compact representation of the type hierarchy and the method ...
Efficient subtyping tests with PQ-encoding
Given a type hierarchy, a subtyping test determines whether one type is a direct or indirect descendant of another type. Such tests are a frequent operation during the execution of object-oriented programs. The implementation challenge is in a space-...








Comments