virtual-by-default rant

David Nadlinger see at klickverbot.at
Sun Mar 18 08:08:33 PDT 2012


On Sunday, 18 March 2012 at 14:46:55 UTC, David Nadlinger wrote:
> On Sunday, 18 March 2012 at 14:27:04 UTC, David Nadlinger wrote:
>> Which is wrong as long as you don't do link-time optimization, 
>> and DMD probably won't in the foreseeable future. I tried to 
>> explain that above, think extending Thread, which has already 
>> been compiled into druntime, from your application (which is a 
>> bad example, because thread member method calls are most 
>> probably not performance sensitive, but you get the point).
>
> Also note that this applies to the general case where you get 
> passed in an arbitrary instance only – if the place where an 
> object is created is in the same translation unit where its 
> methods are invoked, the compiler _might_ be able to prove the 
> runtime type of the instance even without LTO.

And thinking even more about it, devirtualization could also be 
performed by present-day DMD when directly generating an 
executable with all the modules being passed in via at the 
command line. This might actually be good enough for smaller 
projects which don't use separate libraries or incremental 
compilation.

David




More information about the Digitalmars-d mailing list