[m-dev.] for review: direct reuse
Peter Ross
peter.ross at miscrit.be
Thu Sep 21 20:37:34 AEDT 2000
On Thu, Sep 21, 2000 at 02:23:41AM -0700, Ralph Becket wrote:
> >From Fergus Henderson on 21/09/2000 07:18:03
> > On 20-Sep-2000, Peter Ross <Peter.Ross at cs.kuleuven.ac.be> wrote:
> > > + %
> > > + % Currently structure reuse will only reuse a cell that
> > > + % is using the same cons_id, so it is safe to just do an
> > > + % assignment.
> > > + %
> > > + ml_gen_unification(assign(Var, ReuseVar), model_det,
> Context,
> > > + MLDS_Decls, MLDS_StatementsA),
> >
> > That is a somewhat fragile assumption. I think it would be a very
> > good idea to document that the MLDS back-end relies on this assumption
> > in the definition of the reuse_cell/1 constructor in hlds_goal.m.
> >
> Moreover, I presume this is just a temporary measure to get something
> up and working? Eventually it would be good if reuse applied to either
> (a) any cell of the same size or, preferably, (b) any cell of sufficient
> size [modulo some sensible heuristic to avoid excessive waste].
>
By any chance did you come to a meeting where we discussed this?
(Ralph and Nancy came and visited us at MC last week).
Yes it is just a temporary measure. First step proof of concept and
then next start to optimize it.
For those that are interested here are some code snippets for the two
cases Ralph mentioned that we currently plan to look at
case a)
:- pred flip(rbtree(T)::in, rbtree::out) is det.
flip(X, Y) :-
X => red(L, K, R),
Y <= black(L, K, R). % reuse the red cell as it is the same size.
This example also shows another optimization. All we need to do here
is change the tag since all the fields already contain the correct
value.
case b)
:- pred split(tree23(T)::in, tree23(T)::out) is det.
split(X, Y) :-
X => three(L, LK, M, RK, R),
T <= two(L, LK, M), % reuse the three cell, but waste the two extra
% words at the end of the cell.
Y <= two(T, RK, R).
Pete
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list