Performance improvements for D / DMD compiler.

janderson askme at me.com
Fri Jan 19 23:08:04 PST 2007


I believe this is possible.  In particular since D generates its own 
header files.

I think it would be simple when the compiler knows the intentional (just 
like inlining works).  Perhaps with a DLL/lib the compiler could mark 
the functions as constant (or inout) and deal with it differently like 
you say.

Bill Baxter wrote:

> 
> I'm not really sure why that would be a problem, as long as the compiler 
> has really determined that s1 and s2 aren't being modified by the 
> function.  Maybe you can elaborate?  If it's effectively the same as a 
> const reference, how can the aliasing make a big difference?
> 
> But anyway, I don't think it's possible to change way arguments are 
> passed on what the function body does with them.  Say all you have is a 
> .di file with this signature in it:
>   void foo(LargeStruct s1, LargeStruct s2);
> 
> How is the compiler going to know how to push the parameters on the 
> stack to call foo?
> 
> I think it may be possible, however, to establish a rule like "all 
> struct parameters larger than a 'real' are actually passed by 
> reference".  Then it would be up to the compiler to make copies of any 
> modified arguments within the body of the function.
> 
> So the code generated for something like
> 
> void foo(LargeStruct s1) {
>    s1.x = 10;
>    ...use s1...
> }
> 
> would look more like:
> 
> void foo(inout LargeStruct s1) {
>    LargeStruct s1tmp = s1;
>    s1tmp.x = 10;
>    ...use s1tmp...
> }
> 
> I guess you could call that "parameter copy-on-write".
> 
> --bb
> 



More information about the Digitalmars-d mailing list