[m-dev.] For review: Add implementation of reference types (global heap)

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Jun 8 16:04:09 AEST 1998


On 08-Jun-1998, Peter Schachte <pets at students.cs.mu.oz.au> wrote:
> > 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.

Yes, they're necessary.  The "transient" registers are the ones that
get clobbered by C function calls and returns.  It's not enough to
save/restore them inside the function, because by that time they've
already been clobbered.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list