[m-dev.] For review: Add implementation of reference types (global heap)
Peter Schachte
pets at students.cs.mu.OZ.AU
Mon Jun 8 15:57:55 AEST 1998
> Index: runtime/mercury_memory.c
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory.c,v
> retrieving revision 1.8
> diff -u -r1.8 mercury_memory.c
...
> +
> + global_heap_zone = create_zone("global_heap", 1, global_heap_size,
> + next_offset(), global_heap_zone_size, default_handler);
> + global_hp = global_heap_zone->min;
Maybe this zone should only be created on demand. Perhaps set
global_heap_zone = NULL, and put something like
if (global_heap_zone == NULL) {
global_heap_zone = create_zone("global_heap", 1, global_heap_size,
next_offset(), global_heap_zone_size, default_handler);
global_hp = global_heap_zone->min;
}
in the code for making permanent copies. I guess it depends on the
cost of allocating a big chunk of memory you'll never need vs. the
cost of an extra test for every permanent copy.
> NEW FILE: extras/references/nb_reference.m
> ===================================================================
...
> :- pragma inline(new_nb_reference/2).
> :- pragma c_code(new_nb_reference(X::in, Ref::out), will_not_call_mercury, "
> incr_hp(Ref, 1);
> save_transient_registers();
> *(Word *)Ref = MR_make_partially_permanent(X, (Word *) TypeInfo_for_T,
> (Word *) Ref);
> restore_transient_registers();
> ").
Are the save_ and restore_transient_registers(); calls really
necessary here? MR_make_partially_permanent() already does this, so I
wouldn't have thought this could would have to do it too. Similarly
for update/2.
> NEW FILE: extras/references/scoped_update.m
> ===================================================================
This file has a lot of commented-out debugging code. I think it would
be better to write a macro or two, defined insides #ifdefs, that do
the printing, so that the printing can be turned on and off without
editing the file.
-Peter Schachte | ... law reflects the interests and ideology
mailto:pets at cs.mu.OZ.AU | of those who frame it.
http://www.cs.mu.oz.au/~pets/ | -- Robert Hughes, The Fatal Shore
PGP: finger pets at 128.250.37.3 |
More information about the developers
mailing list