Escape analysis (full scope analysis proposal)

Michel Fortin michel.fortin at michelf.com
Tue Nov 4 18:41:49 PST 2008


On 2008-11-04 12:36:15 -0500, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

>> Yeah, that looks pretty much like my idea, in concept, where I call 
>> regions scopes. But I'd have made things simpler by having only local 
>> function regions (on the stack) and the global region 
>> (dynamically-allocated garbage-collected heap), which mean you don't 
>> need templates at all for dealing with them.
> 
> I don't understand that part.

Indeed, I was somewhat mistaken that the <> notation was templates 
(seen to much C++ lately), which somewhat confused my analysis for a 
few things later. And perhaps I should have read a little more about 
Cyclone before attempting a comparison as it seems I got a few things 
wrong from the slides.


>>> My hope was that we can obtain an approximation of that idea by defining
>>> only two regions - "inside this function" and "outside this function".
>>> It looks like that's not much gain for a lot of pain.
>>> 
>>> So the question is - should we introduce region analysis to D, or not?
>> 
>> I think we should at least try. I don't think we need everything 
>> Cyclone does however; we can and should keep things simpler.
> 
> I'm not sure how to read this. For what I can tell, Cyclone's region 
> analysis does not introduce undue complexity. It does the minimum 
> necessary to prove that function manipulating pointers are safe. So if 
> you suggest a simpler scheme, then either it is more limiting, less 
> safe, or both. What are the tradeoffs you are thinking about, and how 
> do they compare to Cyclone?

I guess I'd have to familiarize myself with Cyclone a little more to be 
able to do a good comparison. Right now I've just been scratching the 
surface, but it looks more complicated than what I had in mind for D. 
I'd tend to believe Cyclone may cover some cases that wouldn't be by 
mine, but I'm not sure which one and I am currently under the 
impression that they are not that important (could be handled in other 
manners).

Don't forget that Cyclone is targeted at the C language, which doesn't 
has templates nor garbage collection (although Cyclone supports an 
optional garbage collector). Since D has both, it can leverage some of 
this to simplify things. For instance, because of the garbage collector 
I don't think we need what Cyclone calls dynamic regions: I'd simply 
put everything escaping a function on the heap. It then follows that we 
don't need to propagate region handles.

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




More information about the Digitalmars-d mailing list