Escape Analysis on reddit

Michel Fortin michel.fortin at michelf.com
Fri Oct 31 20:12:37 PDT 2008


On 2008-10-31 22:47:59 -0400, "Steven Schveighoffer" 
<schveiguy at yahoo.com> said:

> Yes, my point in all this is, if we are going to 'solve' the scope escape
> issue which today causes unnecessary heap allocations, let's not make new
> syntax that makes things harder or impossible to do and *still* have the
> heap allocation problem.

But declaring arguments as scope solve the heap allocation problem, 
except where not heap-allocating would create a bug because of someone 
keeping the reference for too long.

> It's worth a lot, I agree.  But not at the cost of invalidating tested
> efficient designs such as Tango.

If you can't annotate Tango's code to be scope-correct, then there are 
probably hidden bugs in there. If D scope syntax isn't expressive 
enough to annotate valid and efficient designs, then the syntax is 
probably not well enough.

> FWIW, I think with changes to the compiler/linker, this can be all detected
> automatically without any extra syntax.  Consider that the linker currently
> resolves dependencies of symbols.  It could also resolve incomplete escape
> analysis graphs.  If the graphs don't match up, it's a linker error.  This
> would be needed in the case of interfaces and virtual functions.

Here you're expecting the linker to perform escape analysis on comiled 
code, a world where pointers, numbers and raw data are the same thing: 
bytes and values in registers. That's probably a million times harder 
to do than when working on the semantic tree of a D program, if that's 
even possible.

> That would be the ultimate solution IMO, but definitely not in time for D2
> ;)

Indeed. :-)


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list