This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Speed impact of virtual inheritance


On Mon, Oct 10, 2005 at 09:25:15PM +0000, Frans Englich wrote:
> Followup question: what is the increased cost of calling a non-virtual, 
> inlined function('inline' keyword) on a virtual base?

If the function is successfully inlined, then the question really refers
to the cost of the code inside the function.

If this code accesses a member of a virtual base object, from a pointer
or reference to the derived object, this involves an extra level of
dereferencing that would not be present for a non-virtual base.  The
derived part of the object has a pointer to the virtual base, so this
pointer must be dereferenced to find the base object, then the actual
member is found using a constant offset from the beginning of the base.
If nonvirtual inheritance were used, the member could be found directly,
at an offset from the address of the object as a whole.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]