Affiliation:
1. Technion—Israel Institute of Technology, Haifa, Israel
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 CT
d
. 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 CT
1
, CT
2
, CT
3
, …, where CT
d
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 CT
d
suited for languages such as Java.
Publisher
Association for Computing Machinery (ACM)
Reference48 articles.
1. Efficient implementation of Java interfaces
2. Arnold P. and Gosling J. 1996. The Java Programming Language. The Java Series. Addison-Wesley Reading MA. Arnold P. and Gosling J. 1996. The Java Programming Language. The Java Series. Addison-Wesley Reading MA.
3. 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. 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.
4. CommonLoops: merging Lisp and object-oriented programming
5. Testing for the consecutive ones property, interval graphs, and graph planarity using PQ-tree algorithms
Cited by
6 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献