Figure 11: Some complex types and classes
The success of these dispatch layout rules is illustrated by the layouts for the classes in the complex hierarchy of Figure 11. Even though their layouts are computed with only local knowledge of the hierarchy, all the classes except C3 require only a single dispatch vector. As shown in Figure 12, the class C3 has just two dispatch vectors in the bidirectional layout, whereas it has five in conventional layouts. The vertical center line in the dispatch vectors for the bidirectional layout represents the separation between the negative and positively-indexed methods. Contrast these header sizes with conventional C++ layouts: classes C1 through C4 have 2, 3, 5, and 2 dispatch vectors, respectively. The disparity between the schemes increases with deeper hierarchies.
Figure 12: Bidirectional and C++ layouts for C3
Andrew C. Myers. Bidirectional Object Layout for Separate Compilation.
Proceedings of OOPSLA '95, pp. 124-139.
Copyright © 1995 Association for Computing Machinery