Pointers-to-members

Jim Dehnert dehnert at baalbek.engr.sgi.com
Thu Mar 30 22:33:06 UTC 2000


> 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.

Jim

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




More information about the cxx-abi-dev mailing list