[m-rev.] for review: heap reclamation on failure for MLDS back-end

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Nov 26 17:30:08 AEDT 2001


> On 22-Nov-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > On Fri, Nov 23, 2001 at 02:51:55AM +1100, Fergus Henderson wrote:
> > > +goal_expr_add_heap_ops(if_then_else(A, Cond0, Then0, Else0, E), GoalInfo,
> > > +		Goal - GoalInfo) -->
> > > +	goal_add_heap_ops(Cond0, Cond),
> > > +	goal_add_heap_ops(Then0, Then),
> > > +	goal_add_heap_ops(Else0, Else1),
> > > +	%
> > > +	% Save the heap pointer so that we can
> > > +	% restore it if the condition fails.
> > > +	%
> > > +	new_saved_hp_var(SavedHeapPointerVar),
> > > +	{ goal_info_get_context(GoalInfo, Context) },
> > > +	gen_mark_hp(SavedHeapPointerVar, Context, MarkHeapPointerGoal),
> > > +	%
> > > +	% Generate code to restore the heap pointer,
> > > +	% and insert that code at the start of the Else branch.
> > > +	%
> > > +	gen_restore_hp(SavedHeapPointerVar, Context, RestoreHeapPointerGoal),
> > > +	{ Else1 = _ - Else1GoalInfo },
> > > +	{ Else = conj([RestoreHeapPointerGoal, Else1]) - Else1GoalInfo },
> > > +	{ IfThenElse = if_then_else(A, Cond, Then, Else, E) - GoalInfo },
> > > +	{ Goal = conj([MarkHeapPointerGoal, IfThenElse]) }.
> >
> > Isn't it a condition of the HLDS that all the conjunctions have been
> > flattened?

In this case MarkHeapPointerGoal will always be a `call' goal
and IfThenElse will always be an `if_then_else' call, so the
result is already fully flattened.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list