This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Allocatable components (was Re: [gfortran,patch] Fix wrong-code for ASSOCIATED)


On Sun, Jun 18, 2006 at 02:07:04AM +0200, Paul Thomas wrote:
> Tobias
> 
> My contribution to the TR 15581: ALLOCATABLE components patch has been 
> to provide the code that nullifies components on entry and deallocates 
> on exit from a scope.  At present, this does a brutal job of visiting 
> every allocatable component of every structure and every substructure 
> that is suspected of possessing such a thing.  The code looks horrible 
> but it does work and is guaranteed to clean up completely.
> 
> I had promised Erik that I would outline a better scheme and, since this 
> discussion about pointers is connected, I will do so here:
> 
> (i) Within every scope, there should be a binary tree of allocated objects.
> (ii) On allocation of an allocatable component, it is entered into the tree.
> (iii) The address of the data field of the component descriptor is the 
> key and its value is the field in the tree.
> (iv) On deallocation, the tree field is set to zero. (A variant has a 
> block at the beginning of the allocated memory used as the tree member.  
> This has the disadvantage that the tree needs to be reorganised before 
> the memory is freed.)
> (v) On leaving the scope, the tree is cleaned up and non-zero fields freed.
> 
> This has the advantage over the present scheme that the initial 
> nullification of every last allocatable component is unnecessary - the 
> component is not allocated if it is not present in the tree or its value 
> is zero.

While you don't say so explicitely, I gather that these trees would be
something that the binary keeps track of at runtime (rather than
something the compiler does at compile time)?

Also, what are your plans for the "programming interface" to this
scheme.  Would it be possible to have person X working on (other aspects
of) allocatable components using the current memory management scheme,
while person Y implements this new scheme, and then just plug in the new
scheme when it's done with small or no changes to the code written by
X?  Or do you think it's better to first implement the new scheme, and
continue with the allocatable components stuff only when it's done?


        Erik


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]