public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* New vtable ABI (was Re: Strange behaviour in C++...)
@ 1999-08-26 15:59 Jason Merrill
  1999-08-26 16:38 ` Jason Merrill
                   ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Jason Merrill @ 1999-08-26 15:59 UTC (permalink / raw)
  To: Joe Buck; +Cc: David Edelsohn, law, mrs, oliva, cj, gcc-patches, gcc

I should point out here that the proposed mechanism is not the classic ARM
vtable.  In fact, it doesn't have any more space overhead for single
inheritance code than thunks, and may have less for multiple inheritance
code.  It works like this:

Rather than per-function offsets, we have per-target type offsets.  These
offsets (if any) are stored at a negative index from the vptr.  When a
derived class D overrides a virtual function F from a base class B, if no
previously allocated offset slot can be reused, we add one to the
beginning of the vtable(s) of the closest base(s) which are non-virtually
derived from B.  In the case of non-virtual inheritance, that would be D's
vtable; in simple virtual inheritance, it would be B's.  The vtables are
written out in one large block, laid out like an object of the class, so if
B is a non-virtual base of D, we can find the D vtable from the B vptr.

D::f then recieves a B*, loads the offset from the vtable, and makes the
adjustment to get a D*.  The plan is to also have a non-adjusting vtable
entry in D's vtable, so we don't have to do two adjustments to call D::f
with a D*; the implementation of this is up to the compiler.  I expect that
for g++, we will do the adjustment in a thunk which just falls into the
main function.

The performance problems with classic thunks occur when the thunk is
not close enough to the function it jumps to for a pc-relative branch.
This cannot be avoided in certain cases of virtual inheritance, where a
derived class must whip up a thunk for a new adjustment to a method it
doesn't override.

In this case, we will only ever have one thunk per function, so we don't
even have to jump.

Jason

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~1999-09-30 18:02 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-26 15:59 New vtable ABI (was Re: Strange behaviour in C++...) Jason Merrill
1999-08-26 16:38 ` Jason Merrill
1999-08-31 23:20   ` Jason Merrill
1999-08-26 17:05 ` Joe Buck
1999-08-26 17:13   ` Jason Merrill
1999-08-26 17:26     ` Mumit Khan
1999-08-31 23:20       ` Mumit Khan
1999-08-31 23:20     ` Jason Merrill
1999-08-31 23:20   ` Joe Buck
1999-08-31 23:20 ` Jason Merrill
1999-09-07 18:42 ` Per Bothner
1999-09-07 23:14   ` Martin v. Loewis
1999-09-07 23:53     ` Per Bothner
1999-09-08  0:49       ` Martin v. Loewis
1999-09-08  6:33         ` Per Bothner
1999-09-09  1:39           ` Martin v. Loewis
1999-09-09  9:28             ` Per Bothner
1999-09-30 18:02               ` Per Bothner
1999-09-30 18:02             ` Martin v. Loewis
1999-09-30 18:02           ` Per Bothner
1999-09-30 18:02         ` Martin v. Loewis
1999-09-30 18:02       ` Per Bothner
1999-09-30 18:02     ` Martin v. Loewis
1999-09-30 18:02   ` Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).