Space and time-efficient memory layout for multiple inheritance

Traditional implementations of multiple inheritance bring about not only an overhead in terms of run-time but also a significant increase in object space. For example, the number of compiler-generated fields in a certain object can be as large as quadratic in the number of its subobjects. The problem of efficient object layout is compounded by the need to support two different semantics of multiple inheritance: shared, in which a base class inherited along distinct paths occurs only once in the derived class, and repeated, in which this base has multiple distinct occurrences in the derived. In this theoretical and foundational paper, we introduce two new techniques to optimize memory layout for multiple inheritance. The main ideas behind these techniques are the inlining of virtual bases and bidirectional memory layout. Our techniques never increase time overhead, and usually even decrease it. We show that in some example hierarchies, more than ten-fold reduction in the space overhead can be achieved. We analyze the complexity of the algorithms to apply these techniques, and give theorems to estimate the efficacy of this application. For concreteness, techniques and examples are discussed in the context of C++.

[1]  B. Martin The Separation of Interface and Implementation in C++ , 1991, C++ Conference.

[2]  Bjarne Stroustrup,et al.  The Design and Evolution of C , 1994 .

[3]  Larry Carter,et al.  Universal Classes of Hash Functions , 1979, J. Comput. Syst. Sci..

[4]  Lee R. Nackman,et al.  Base-Class Composition with Multiple Derivation and Virtual Bases , 1994, C++ Conference.

[5]  Bertrand Meyer,et al.  Object-Oriented Software Construction, 2nd Edition , 1997 .

[6]  David F. Bacon,et al.  Fast and effective optimization of statically typed object-oriented languages , 1997 .

[7]  Bjarne Stroustrup,et al.  The C++ programming language (2nd ed.) , 1991 .

[8]  Bjarne Stroustrup,et al.  Multiple Inheritance for C++ , 1989, Comput. Syst..

[9]  Frank Tip,et al.  Class hierarchy specialization , 1997, OOPSLA '97.

[10]  William Pugh,et al.  Two-directional record layout for multiple inheritance , 1990, PLDI '90.

[11]  Ken Arnold,et al.  The Java Programming Language , 1996 .

[12]  R. Nigel Horspool,et al.  Near Optimal Hierarchical Encoding of Types , 1997, ECOOP.

[13]  Stein Krogdahl Multiple inheritance in Simula-like languages , 1985, BIT Comput. Sci. Sect..

[14]  簡聰富,et al.  物件導向軟體之架構(Object-Oriented Software Construction)探討 , 1989 .

[15]  Craig Chambers,et al.  Whole-program optimization of object-oriented languages , 1996 .

[16]  Michael S. Karasick The architecture of Montana: an open and extensible programming environment with an incremental C++ compiler , 1998, SIGSOFT '98/FSE-6.

[17]  Andrew Shalit,et al.  The Dylan Reference Manual , 1996 .

[18]  Andrew C. Myers,et al.  Bidirectional object layout for separate compilation , 1995, OOPSLA.

[19]  Stanley B. Lippman,et al.  Inside the C++ Object Model , 1996 .

[20]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

[21]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[22]  Jonathan G. Rossie,et al.  An algebraic semantics of subobjects , 1995, OOPSLA.

[23]  Alon Itai,et al.  The Complexity of Type Analysis of Object Oriented Programs , 1998, ECOOP.

[24]  Matthias Felleisen,et al.  Classes and mixins , 1998, POPL '98.

[25]  Richard M. Stallman,et al.  Using and Porting GNU CC , 1998 .

[26]  Mark A. Linton,et al.  Interface Translation and Implementation Filtering , 1994, C++ Conference.

[27]  David S. Johnson,et al.  Computers and Intractability: A Guide to the Theory of NP-Completeness , 1978 .

[28]  Bjarne Stroustrup,et al.  The Annotated C++ Reference Manual , 1990 .