lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Fri, 30 Nov 2007 15:53:38 -0800 From: Nicholas Miell <nmiell@...cast.net> To: "J.A." Magallón <jamagallon@....com> Cc: Loïc Grenié <loic.grenie@...il.com>, Ben.Crowhurst@...llatravel.co.uk, linux-kernel@...r.kernel.org Subject: Re: Kernel Development & Objective-C On Sat, 2007-12-01 at 00:19 +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 > > is much more efficient that what gcc can mangle to do with > > thing->do_something(with,this,thing) > > push with > push this > push thing > get thing+offsetof(do_something) // not constant at compile time > dereference it > call it > > (that is, get a generic field on a structure and use it as jump address) > > In short, the kernel is object oriented, implements OO programming by > hand, but the compiler lacks the knowledge that it is object oriented > programming so it could do some optimizations. struct test; struct testVtbl { int (*fn1)(struct test *t, int x, int y); int (*fn2)(struct test *t, int x, int y); }; struct test { struct testVtbl *vtbl; int x, y; }; void testCall(struct test *t, int x, int y) { t->vtbl->fn1(t, x, y); t->vtbl->fn2(t, x, y); } and struct test { virtual int fn1(int x, int y); virtual int fn2(int x, int y); int x, y; }; void testCall(struct test *t, int x, int y) { t->fn1(x, y); t->fn2(x, y); } generate instruction-for-instruction identical code. -- Nicholas Miell <nmiell@...cast.net> - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists