[m-dev.] Help: Changes to memory zone allocation affecting my changes

Warwick Harvey wharvey at cs.monash.edu.au
Thu Jun 11 18:32:21 AEST 1998


Hi,

Well, I was all ready to commit my reference/global var changes, and did a
final update, only to discover some rather nasty conflicts.  :-)

The place where memory zones are allocated has been moved, and quite a few
related things have changed (for parallelism/thread support, as far as I can
see).  As a result, I have a few questions/problems I would like answers
to/help with.

Firstly, in the original version, the heap pointer for the global heap was
just another global variable, like the pointers to the various heap zones.
I'm now wondering whether it would be more appropriate to have it as a
virtual register (or whatever you call them), like the other heap pointers.
If so, how does one go about setting this up?  I've had a look at
mercury_regs.h et al., and I'm not game to touch anything without
instructions.  :-)  If not, how would I set up "global" variable for this
pointer for each thread (other than the one stored in the engine
structure)?

Secondly, the MR_make_permanent() and similar calls worked by fiddling with
the heap pointers and zone pointers, and then calling deep_copy() to copy
the term from the normal heap to the "global" heap.  The heap pointer
fiddling is still fine, but what is the approved way of obtaining the zone
pointers for the thread?  This (I suspect) is just a case of obtaining a
pointer to the correct engine structure, but what's the right way to do
this?  Also, do I really need to fiddle the zone pointers for calling
deep_copy, or will just exchanging the heap pointers do?  I suspect I might
be able to get away with the latter, but that for safety's sake (e.g. a
change in implementation, or for heap overflow checking) I'd better stick
with the former.

Thirdly, there still seems to be a few remnants of the old system floating
around.  E.g. mercury_memory.c still declares the zone pointers, and a
number of places refer to them if various "non-standard" options are being
used (I include non-GC grades as "non-standard" here, just coz they always
seem to give me more trouble ;-).  I provide a (possibly incomplete and
possibly erroneous) list of stray references to heap_zone below:

mercury_memory.c:111:  MemoryZone *heap_zone;
mercury_misc.c:241:             if ( (Integer) heap_zone->min <= x
mercury_misc.c:242:                             && x < (Integer) heap_zone->
top) {
mercury_misc.c:243:                     x -= (Integer) heap_zone->min;
mercury_misc.c:282:             (const void *) h, (long) (Integer) (h - 
heap_zone->min));
mercury_misc.c:398:             if ((Integer) heap_zone->min <= value
mercury_misc.c:399:                             && value < (Integer) 
heap_zone->top) {
mercury_overflow.h:29:                          IF (MR_hp >= heap_zone->
top,(  \
mercury_overflow.h:32:                          IF (MR_hp > heap_zone->max,( 
  \
mercury_overflow.h:33:                                  heap_zone->max = 
MR_hp \
mercury_wrapper.c:797:  heap_zone->max      = heap_zone->min;
mercury_wrapper.c:834:                  (long) (heap_zone->max - heap_zone->
min));


Obviously, after I've fixed all this stuff up, the runtime component of my 
changes will need to be re-reviewed.

Warwick





More information about the developers mailing list