[m-dev.] for review: implementation of --no-allow-hijacks

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jul 29 20:45:25 AEST 1998


On 29-Jul-1998, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> >> Extend the new failure handling method to optionally preserve an invariant
> >> required by accurate gc: always being able to tell with respect to what MR_sp
> >> or MR_curfr to interpret the stackvars and framevars referred to by the label
> >> whose address is the redoip slot of a nondet stack frame.
> > 
> > I don't understand that -- often the redoip slot will be `do_fail'.
> > What happens in that case?
> 
> In that case, the stack frame is effectively not there.

I don't think that is true... consider the following:

	:- mode p(in, out) is nondet.
	:- mode q(in, out) is nondet.

	p(X, L) :-
		q(Z),
		L = [X, Y].

The frame for `p' will have `do_fail' in it's redoip slot.
But the frame is still needed, because it holds the value of `X'.

> When execution
> backtracks to that stack frame, it will remove the frame, and backtrack
> to the one below. Therefore there are no roots reachable from a frame
> with a do_fail redoip that are not reachable from the frames below it,
> which means that such frames can be ignored by the garbage collector.

This conclusion does not hold in the example above.  `X' may be the
only reference to a live data structure.  The caller may look like

	r :-
		A = [42],
		p(A, L),
		s(L).

`A' is not live after the call to `p', so there will be no reference
to the term `[42]' in the stack frame for `r'.  At the call to `q',
the only reference to this term will be the one that holds `X'
in the stack frame for `p'.

> (I believe we never store the address of any of the other labels from
> the runtime in redoip slots, so this issue does not come up for them.)

The exception handling code in extras/exceptions stores
`exception_handler_do_fail' in redoip slots.
However, the layout of frames with that address in their
redip slot is fixed, so I don't think such frames will
pose a problem for accurate gc -- we just need to hard-code
an appropriate stack layout for them.

-- 
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