This is the mail archive of the
mailing list for the GCC project.
Re: Using C++ in GCC is OK
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Earnshaw <rearnsha at arm dot com>
- Cc: Mark Mitchell <mark at codesourcery dot com>, Richard Guenther <richard dot guenther at gmail dot com>, Robert Dewar <dewar at adacore dot com>, ????????? <chiheng dot xu at gmail dot com>, GCC <gcc at gcc dot gnu dot org>
- Date: Wed, 2 Jun 2010 19:50:05 +0200
- Subject: Re: Using C++ in GCC is OK
- References: <4C030228.firstname.lastname@example.org> <AANLkTimzVEXsE4vOZJuegnHFu-pVyNdKImcasoSX_ZDc@mail.gmail.com> <4C039253.email@example.com> <AANLkTikp-gTh4bCpAFYWhU7fR9tBTxOP6mQp9TAfideB@mail.gmail.com> <4C03EB8D.firstname.lastname@example.org> <email@example.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Jun 02, 2010 at 06:17:25PM +0100, Richard Earnshaw wrote:
> On Mon, 2010-05-31 at 10:02 -0700, Mark Mitchell wrote:
> > I think virtual functions are on the edge; quite useful, but do result
> > in the compiler adding a pointer to data objects and in uninlinable
> > indirect calls at run-time. Therefore, I would avoid them in the
> > initial subset of C++ used in GCC.
> We do, of course, have one very big 'virtual function' table in gcc --
> namely the target hooks. It would be a shame if that couldn't be made
> into a proper class with virtual functions by some arbitrary rule --
> it's a perfect example of when they should be considered.
And the advantage would be?
Currently targetm is a struct with function pointers, so calling
means reading a pointer from &targetm + off, then calling it.
If you make it a class with virtual functions and targetm
would be an object of that class, then
call means reading pointer from &targetm (the vtable pointer), followed
by reading the function pointer from the virtual table, then calling it.
One extra memory read for hook call.