From: Avi Kivity <avi@argo.co.il>
To: Al Viro <viro@ftp.linux.org.uk>
Cc: "J.A. Magall??n" <jamagallon@ono.com>,
Lo??c Greni?? <loic.grenie@gmail.com>,
Ben.Crowhurst@stellatravel.co.uk, linux-kernel@vger.kernel.org
Subject: Re: Kernel Development & Objective-C
Date: Sat, 01 Dec 2007 21:55:59 +0200 [thread overview]
Message-ID: <4751BC4F.3030007@argo.co.il> (raw)
In-Reply-To: <20071201003119.GB8181@ftp.linux.org.uk>
Al Viro wrote:
> On Sat, Dec 01, 2007 at 12:19:50AM +0100, J.A. Magall??n wrote:
>
>> An vtable in C++ takes exactly the same space that the function
>> table pointer present in every driver nowadays... and probably
>> the virtual method call that C++ does itself with
>>
>> thing->do_something(with,this)
>>
>> like
>> push thing
>> push with
>> push this
>> call THING_vtable+indexof(do_something) // constants at compile time
>>
>
> This is not what vtables are. Think for a minute - all codepaths arriving
> to that point in your code will pick the address to call from the same
> location. Either the contents of that location is constant (in which case
> you could bloody well call it directly in the first place) *or* it has to
> somehow be reassigned back and forth, according to the value of this. The
> former is dumb, the latter - outright insane.
>
> The contents of vtables is constant. The whole point of that thing is
> to deal with the situations where we _can't_ tell which derived class
> this ->do_something() is from; if we could tell which vtable it is at
> compile time, we wouldn't need to bother at all.
>
> It's a tradeoff - we pay the extra memory access (fetch vtable pointer, then
> fetch method from vtable) for not having to store a slew of method pointers
> in each instance of base class. But the extra memory access is very much
> there. It can be further optimized away if you have several method calls
> for the same object next to each other (then vtable can be picked once),
> but it's still done at runtime.
>
True. C++ vtables have no performance advantage over C ->ops->function()
calls. But they have no disadvantage either and they do offer many
syntactic advantages (such as automatically casting the object type to
the *correct* derived class.
next prev parent reply other threads:[~2007-12-01 19:58 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-29 12:14 Kernel Development & Objective-C Ben Crowhurst
2007-11-30 10:02 ` Xavier Bestel
2007-11-30 10:09 ` KOSAKI Motohiro
2007-11-30 10:20 ` Xavier Bestel
2007-11-30 10:54 ` Jan Engelhardt
2007-11-30 14:21 ` David Newall
2007-11-30 23:31 ` Bill Davidsen
2007-11-30 23:40 ` Alan Cox
2007-12-01 0:05 ` Arnaldo Carvalho de Melo
2007-12-01 18:27 ` Bill Davidsen
2007-12-01 18:18 ` Alan Cox
2007-12-03 1:23 ` Bill Davidsen
2007-11-30 22:52 ` J.A. Magallón
2007-11-30 10:29 ` Loïc Grenié
2007-11-30 11:16 ` Ben Crowhurst
2007-11-30 11:36 ` Karol Swietlicki
2007-11-30 14:37 ` Lennart Sorensen
2007-12-08 8:54 ` Rogelio M. Serrano Jr.
2007-11-30 23:19 ` J.A. Magallón
2007-11-30 23:53 ` Nicholas Miell
2007-12-01 0:31 ` Al Viro
2007-12-01 0:34 ` Al Viro
2007-12-01 1:09 ` J.A. Magallón
2007-12-01 19:55 ` Avi Kivity [this message]
2007-12-04 17:54 ` Lennart Sorensen
2007-12-04 21:10 ` Avi Kivity
2007-12-04 21:24 ` J.A. Magallón
2007-11-30 11:37 ` Matti Aarnio
2007-11-30 14:34 ` Lennart Sorensen
2007-11-30 15:26 ` Kyle Moffett
2007-11-30 18:40 ` H. Peter Anvin
2007-11-30 19:35 ` Kyle Moffett
2007-12-01 20:03 ` Avi Kivity
2007-12-02 19:01 ` Andi Kleen
2007-12-03 5:12 ` Avi Kivity
2007-12-03 9:50 ` Andi Kleen
2007-12-03 11:46 ` Avi Kivity
2007-12-03 11:50 ` Andi Kleen
2007-12-03 21:13 ` Willy Tarreau
2007-12-03 21:39 ` J.A. Magallón
2007-12-03 21:57 ` Alan Cox
2007-12-04 21:47 ` J.A. Magallón
2007-12-04 22:20 ` Diego Calleja
2007-12-05 10:59 ` Giacomo A. Catenazzi
2007-12-04 21:07 ` Avi Kivity
2007-12-04 22:43 ` Willy Tarreau
2007-12-05 17:05 ` Micro vs macro optimizations (was: Re: Kernel Development & Objective-C) Avi Kivity
2007-12-03 12:35 ` Kernel Development & Objective-C Gilboa Davara
2007-12-03 12:44 ` Gilboa Davara
2007-12-03 16:28 ` Casey Schaufler
2007-12-04 17:50 ` Lennart Sorensen
2007-12-05 10:31 ` Gilboa Davara
2007-12-01 19:59 ` Avi Kivity
2007-12-02 19:44 ` Jörn Engel
2007-12-03 16:53 ` Lennart Sorensen
2007-11-30 15:00 ` Chris Snook
2007-12-01 9:50 ` David Newall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4751BC4F.3030007@argo.co.il \
--to=avi@argo.co.il \
--cc=Ben.Crowhurst@stellatravel.co.uk \
--cc=jamagallon@ono.com \
--cc=linux-kernel@vger.kernel.org \
--cc=loic.grenie@gmail.com \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox