[m-dev.] Re: for review: deep copy cleanup.

Tyson Dowd trd at stimpy.cs.mu.oz.au
Tue Jun 2 17:18:24 AEST 1998


On 02-Jun-1998, Lee Naish <lee at cs.mu.OZ.AU> wrote:
> Tyson Dowd <trd at cs.mu.OZ.AU> writes:
> 
> >Here's a cleanup of deep copy.  This should make it easier to add
> >other functions that need to do similar things. 
> 
> Prompted by a brief discussion on the tram last night about doing a
> binary dump of the HLDS in order to save information for declarative
> debugging:

Which tram do you catch?!

> 
> It would be nice to document what happens if the original version of the
> data structure contains sharing.  With a (reasonably quick) look at the
> code it seems like 1) its not documented and 2) nothing clever is done,
> resulting in sharing being lost (ie, subterms get copied multiple times
> rather than shared) - in the worst case this can lead to a exponential
> increase in memory consumption.

You are right, nothing clever is done (except static terms not on the
heap are not copied).  What needs to be changed is the "in_range" tests
need to be modified a little to do a "need_to_copy" test (which should
return the address of the previously copied or static term, or NULL if
the term needs to be copied).  However, the implementation of such
a system is a little more complicated.  For some applications you can
use destructive mechanisms to do this, for others you might need to
be more careful.

Fixing 1) is easy, and I will do it soon.  Fixing 2) might take a little
longer.  I'm open to suggestions and ideas.

-- 
       Tyson Dowd           # So I asked Sarah: what's the serial number on
                            # your computer? She replied:
     trd at cs.mu.oz.au        #          A-C-2-4-0-V-/-5-0-H-Z
http://www.cs.mu.oz.au/~trd #



More information about the developers mailing list