Escape Analysis on reddit

ore-sama spam at here.lot
Sat Nov 1 03:32:56 PDT 2008


Andrei Alexandrescu Wrote:

> In this case it's not even conservative, it's doing the correct thing. 
> To illustrate the effects of a conservative approach, consider:
> 
> scope int *foo(scope int *p)
> {
>     int x;
>     auto r = &x;
>     r = p;
>     return r;
> }
> 
> This function won't compile if the compiler employs flow-insensitive 
> escape analysis (see e.g. 
> http://en.wikipedia.org/wiki/Data_flow_analysis ) because r will be 
> marked as escaping regardless of order of statements.

If compiler is able to mark data as escaping and compare escape marks of variables, isn't it able to derive parameters' marks rather than requesting them from programmers? Thus it can build function's precise signature and reading it from obj file (another long-announced feature) it can decide whether that function is callable from current context, but compiler should also check objs before linking to make sure that their metadata don't conflict.



More information about the Digitalmars-d mailing list