[m-dev.] For review: Add implementation of reference types (global heap)
Warwick Harvey
wharvey at cs.monash.edu.au
Wed Jun 10 13:32:31 AEST 1998
Fergus Henderson <fjh at cs.mu.OZ.AU> writes:
> > +/* MR_make_permanent:
> > +**
>
> Should be
>
> /*
> ** ...
> **
Fair enough. I would have done it that way, but instead just copied the
style used for deep_copy(). I'll fix that too while I'm at it. :-)
> > :- 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_long_lived(X, (Word *) TypeInfo_for_T,
> > (Word *) Ref);
> > restore_transient_registers();
> > ").
> >
> > :- pragma inline(value/2).
> > :- pragma c_code(value(Ref::in, X::out), will_not_call_mercury, "
> > X = *(Word *) Ref;
> > ").
> >
> > :- pragma inline(update/2).
> > :- pragma c_code(update(Ref::in, X::in), will_not_call_mercury, "
> > save_transient_registers();
> > *(Word *)Ref = MR_make_long_lived(X, (Word *) TypeInfo_for_T,
> > (Word *) Ref);
> > restore_transient_registers();
> > ").
>
> If you were concerned about efficiency, you could wrap `#ifndef
> CONSERVATIVE_GC ... #endif' around those calls to
> save_transient_registers() and restore_transient_registers().
I was concerned about this initially, because it implies that this code (in
extras) knows some details about the implementation of this function (in
runtime). But I suppose it would not be unreasonable to document this as
part of the function's interface.
Thanks for your other comments, they were quite valuable. I'll post the
relative diff when it's done.
Warwick
More information about the developers
mailing list