A little of Partial Compilation

Robert Fraser fraserofthenight at gmail.com
Wed Aug 20 11:56:31 PDT 2008


JAnderson wrote:
> Walter Bright wrote:
>> Don wrote:
>>> Note that even if all parameters to a function are known at compile 
>>> time, doesn't mean it's sensible to run it at compile time. (Example: 
>>> calculating pi to fifty billion decimal places). The programmer needs 
>>> to annotate it somehow to tell the compiler that is suitable for 
>>> compile time.
>>
>> It's one of those impossible problems for the compiler to predict if 
>> it should attempt to execute a function at compile time or not. That's 
>> why compile time function evaluation is initiated with a specific 
>> syntax, rather than tried in general.
> 
> Perhaps that could be solved by automatic profiling.  The worst 
> offenders could be put into a list and the compiler would spend longer 
> on those functions to optimize them.  Also it would be something you 
> could turn on and off with a compiler setting.
> 
> -Joel

Optlink already has a feature like this. You can profile your 
application at runtime and then feed back to optlink a file which will 
cause it to layout the functions optimally in the binary [1]. Possibly a 
similar concept (possibly even the same file) could be fed to DMD to 
prioritize its optimizations.

[1] http://www.digitalmars.com/ctg/trace.html



More information about the Digitalmars-d mailing list