December 28, 2003 How good is DMD at inlining? | ||||
---|---|---|---|---|
| ||||
I have a question about the way inlining works in D. If a base class function contains a call to a function that is overridden in a child class, can that call be inlined if the compiler knows the full type of the object? I.e. will it generate a new version for the base class function? Example: interface I { void a(); void b(); } class A : I { void a() { b(); } //b() is left unimplemented } class B : A { void b() { ... do stuff } } B ob=new B(); ob.a(); Will the b() call in a() be inlined by DMD? My gut tells me that this should be possible if the ob.a() call is inlined as well, but maybe the compiler does enough magic that this is also possible if it is not? And if DMD does not do it: is it possible in theory? I.e. can we expect this to work sometime in the foreseeable future? Hauke |
December 28, 2003 Re: How good is DMD at inlining? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hauke Duden | "Hauke Duden" <H.NS.Duden@gmx.net> wrote in message news:bsmr3u$1hbr$1@digitaldaemon.com... > I have a question about the way inlining works in D. If a base class function contains a call to a function that is overridden in a child class, can that call be inlined if the compiler knows the full type of the object? I.e. will it generate a new version for the base class function? > > Example: > > interface I > { > void a(); > void b(); > } > > class A : I > { > void a() > { > b(); > } > > //b() is left unimplemented > } > > class B : A > { > void b() > { > ... do stuff > } > } > > B ob=new B(); > > ob.a(); > > Will the b() call in a() be inlined by DMD? No. > My gut tells me that this > should be possible if the ob.a() call is inlined as well, but maybe the > compiler does enough magic that this is also possible if it is not? > > And if DMD does not do it: is it possible in theory? I.e. can we expect this to work sometime in the foreseeable future? I think it's possible to do, but at the moment I'm working on a big upgrade to the templates! |
Copyright © 1999-2021 by the D Language Foundation