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 Monday 10 October 2005 22:29, Mark Mitchell wrote:
> Frans Englich wrote:
> > Followup question: what is the increased cost of calling a non-virtual,
> > inlined function('inline' keyword) on a virtual base?
>
> None, if the function is inlined -- and whether it is inlined or not
> should not be affected by whether or not it is in a virtual base.

Ok, let me check my understanding of Joe's and your's reply, by an example:

//----------------------------------------------
    class Shared {
    public:
	// ....
        inline void ref() { m_ref++; }
	// ...
    protected:
        unsigned int m_ref;
    };

    class B : public virtual Shared {};
    class C : public virtual Shared {};
    class BC : public B, public C {};
//----------------------------------------------

Running the expression "BCinstance->ref()" leads to the penalty that accessing 
the "m_ref" variable requires an indirection, if I've understood correctly.

What can safely be concluded from that? For example, could register allocation 
make it uncertain exactly how much the indirection costs?


Cheers,

		Frans


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