Browse Prior Art Database

Recording Virtual Function Table Offsets in External Variables

IP.com Disclosure Number: IPCOM000119277D
Original Publication Date: 1991-Jan-01
Included in the Prior Art Database: 2005-Apr-01
Document File: 2 page(s) / 90K

Publishing Venue

IBM

Related People

Conner, MH: AUTHOR

Abstract

A technique is given for accessing the methods of an object that avoids the necessity for recompile of programs that use a dynamically loaded object definition when the definition is changed in certain ways.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 52% of the total text.

Recording Virtual Function Table Offsets in External Variables

      A technique is given for accessing the methods of an
object that avoids the necessity for recompile of programs that use a
dynamically loaded object definition when the definition is changed
in certain ways.

      Background: Some programming languages support object-oriented
programming using a concept called virtual functions in the C++
programming language.  The technique involves associating a table of
function pointers with each object instance.  The compiler then
converts symbolic method references into indirect calls through these
tables with an offset determined at compile time based on the
method's name. This technique is appealing in that different objects
can reference different implementations of the same methods at the
same offset in the table, thus supporting the critical object concept
of overriding. This technique has a considerable performance
advantage over the name look- up techniques used in such programming
languages as Smalltalk or Objective-C.  One crippling disadvantage to
this technique arises when dynamically loaded object class libraries
are employed.  The problem is that one would like to be able to
update the dynamically loaded class definitions without requiring
recompile of the programs that use them. However, if the compiler
generates code with fixed offsets for the various object methods then
no changes can be made that would cause methods, to be moved in the
virtual function table, thus greatly limiting the type of changes
that could be made.  This invention gives a technique for accessing
the methods in a virtual function table that is almost as fast and
avoids this problem.

      Description: In C++ one could code o.m()" to mean execute the
method named m" as defined for the object contained in the variable
o".  C++ compilers typically determine at compile time where in the
virtual function table for any object that might be assigned to o"
the m" method should be. They then generate code that includes this
compile time computed offset to look up the actual function to be
called in the actual object's virtual function table.  However, this
offset mu...