Missed optimisation case - internal use of STCin

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 19 05:37:06 PDT 2014


On 19 April 2014 13:02, Artur Skawina via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On 04/19/14 13:03, Iain Buclaw via Digitalmars-d wrote:
>> On Saturday, 19 April 2014 at 10:49:22 UTC, Iain Buclaw wrote:
>>> Hi,
>>>
>>> I'm currently testing out a GCC optimisation that allows you to set call argument flags.  The current assumptions being:
>>>
>>> in parameters  =>  Assume no escape, no clobber (read-only).
>>> ref parameters, classes and pointers  =>  Assume worst case.
>>> default  =>  Assume no escape.
>>>
>>
>> That should read:
>>
>> ref parameters, inout parameters, classes and pointers.
>>
>> The default of assuming no escape is an experiment - I may limit this to only scalar types, and parameters marked as 'scope'  (So long as no one plans on deprecating it soon :)
>
> What does "assume no escape" actually mean?
> [The above list doesn't really make sense. W/o context, it's
> hard to even tell why, hence the question.]
>

Actually, I might change the default to assume worst case.  I've just
tried this out, which is still valid.

class C {
   int * p;
   this(int x) {
     p = &x; // escapes the address of the parameter.
   }
}


Worse, scope doesn't error on the general case either.

class D {
   int * p;
   this(scope int x) {
     p = &x; // escapes the address of the scope parameter.
   }
}


Do these examples give you a good example?


More information about the Digitalmars-d mailing list