[m-dev.] .NET back-end test results

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Nov 9 04:23:25 AEDT 2002

On 08-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> On Sat, Oct 26, 2002 at 01:20:31AM +1000, Fergus Henderson wrote:
> > B9
> > - tests/valid/soln_context dies with "stack underflow"
> >   due to problem with "free->free" modes
> Hmmm I had a look at this one and I am not clear enough on how nondet works on
> the IL backend to debug this.

Here's a simpler test case which demonstrates the same problem:

	:- module free_free_nondet.
	:- interface.

	:- pred q is semidet.

	:- implementation.

	q :- p(X).

	:- pred p(int).
	:- mode p(free -> free) is nondet.
	:- external(p/1).

The problem can also be reproduced with the C back-end, if you
specify --nondet-copy-out (which is implied by the `il' grade).
The symptom in that case is "passing too few arguments to

The HLDS->MLDS code generator needs to consider whether arguments are
inputs, outputs or unused when deciding how to pass them.  There are
three kinds of arg_mode: top_in, top_out, and top_unused.  Arguments
with arg_mode "top_in" should be passed by value to the procedure.
Arguments with arg_mode "top_out" should be passed by reference, with two
exceptions: for model_det and model_semidet procedures, if --det-copy-out is
specified or the argument is a function result, the argument is returned
by value; and for model_nondet procedures, if --nondet-copy-out is specified,
the argument is passed by value to the continuation.

Arguments with arg_mode "top_unused" don't need to get passed at all.
Currently, however, for simplicity we do pass them, by reference.
But as you can see this doesn't work for nondet procedures with
--nondet-copy-out, where the MLDS code generator just gets it wrong.
It also doesn't work for det/semidet procedures with --det-copy-out.

Grepping for "top_in" and "top_out" in ml*.m should find all the places
that need to be modified.

I will have a go at this one at some point.  It's not a particularly high
priority though, since free>>free modes are not used much in practice ;-)

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