Pointers-to-members

Coleen Phillimore coleen at zko.dec.com
Thu Mar 30 22:35:44 UTC 2000


Jim Dehnert wrote:
> 
> > Date: Thu, 30 Mar 2000 16:58:16 -0500
> > From: Coleen Phillimore <coleen at zko.dec.com>
> >
> > For pointers to virtual functions, the ABI used to say multiply
> > by two and add one.  I thought the purpose of this was to be able
> > to distinguish between non-virtual and virtual functions.
> >
> > It appears that the multiplication by two was removed.  Why?
> > If a virtual function occupies slot 3 in the vtable, you can't OR
> > with '1' to determine whether the function is virtual anymore.
> > Also, if you have a virtual function in slot 7 in the vtable, then add
> > one, it'll look like a quadword aligned address from the lower bytes.
> >
> > Was there a new way to distinguish between non-virtual and virtual
> > functions in pointer to member functions, that I missed?
> 
> Yes.  We're using a slot offset, not a slot index.  So the low-order
> 2-3 bits are always zero, and we just OR in the virtual flag, and just
> mask it off.  We did this because on most modern processors, shifting
> is something to be avoided, and we don't want to require the divide-
> by-two.

Yes, definitely a good change, once I figured out what was changed.

Coleen

> 
> Jim
> 
> -           Jim Dehnert         dehnert at sgi.com
>                                 (650)933-4272

-- 
-----------------------------------------------------------------------
Coleen Phillimore                  | mailto:coleen at zko.dec.com
Compaq Computer Corp.   Nashua, NH | COMPAQ C++ Compiler Development
-----------------------------------------------------------------------




More information about the cxx-abi-dev mailing list