Feature Request: nontrivial functions and vtable optimizations
davidl
davidl at 126.com
Tue Aug 12 06:02:26 PDT 2008
在 Tue, 12 Aug 2008 16:45:08 +0800,downs <default_357-line at yahoo.de> 写道:
> The overhead of vtable calls is well known.
>
> For this reason, it may be worthwhile to include an optimization that
> essentially checks if a certain class is only inherited from a few
> times, like, <= three, in the visible program, and if so, replace vtable
> calls with a tree of classinfo pointer comparisons and direct function
> calls.
>
> When I did this manually in some hobbyist path tracing code, I gained
> significant speed-ups, even though I didn't collect any hard numbers.
>
> So, for instance, the equivalent D code would look like so:
>
> class A { ... } class B : A { ... } class C : A { ... }
>
> A a = genSomeObj();
> // a.test();
> if (a.classinfo == typeid(B)) (cast(B)cast(void*) a).test(); // call as
> if final
> else if (a.classinfo == typeid(C)) (cast(C)cast(void*) a).test(); // dito
> else a.test(); // fallback
>
> Ideas?
It's better to show your benchmark examples, there people can observe and
discuss
--
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list