[m-rev.] for review: I/O actions in the declarative debugger

Fergus Henderson fjh at cs.mu.OZ.AU
Sun May 12 09:17:34 AEST 2002


On 10-May-2002, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> +++ browser/declarative_analyser.m	9 May 2002 04:45:51 -0000
> @@ -38,13 +39,13 @@
>  		
>  		% Gives the root node of an EDT.
>  		%
> -	pred edt_root_question(S, T, decl_question(T)),
> -	mode edt_root_question(in, in, out) is det,
> +	pred edt_root_question(map(int, io_action), S, T, decl_question(T)),
> +	mode edt_root_question(in, in, in, out) is det,
...
> +	pred edt_root_e_bug(map(int, io_action), S, T, decl_e_bug),
> +	mode edt_root_e_bug(in, in, in, out) is det,
...
> +:- pred analyser_state_init(map(int, io_action)::in,
> +	analyser_state(T)::out) is det.
> +
> +:- pred analyser_state_replace_io_map(map(int, io_action)::in,
> +	analyser_state(T)::in, analyser_state(T)::out) is det.
...
> @@ -188,6 +192,10 @@
> +				% This field allows us to map I/O action
> +				% numbers to the actions themselves.
> +			io_action_map		:: map(int, io_action),
> +
...
> +:- pred prime_suspect_get_e_bug(map(int, io_action)::in, S::in,
> +	prime_suspect(T)::in, decl_e_bug::out) is det <= mercury_edt(S, T).
...
> Index: browser/declarative_debugger.m
> +:- pred diagnoser_state_init(map(int, io_action)::in, io__input_stream::in,
> +	io__output_stream::in, diagnoser_state(R)::out) is det.
...
> +:- func exit_node_decl_atom(map(int, io_action)::in, S::in,
> +	trace_node(R)::in(trace_node_exit)) = (final_decl_atom::out) is det
...
> +:- func make_io_actions(map(int, io_action), int, int) = list(io_action).
...
> +:- pred get_answers(map(int, io_action)::in, S::in, R::in,
> +	list(final_decl_atom)::in, list(final_decl_atom)::out) is det
...
> +:- pred trace_root_e_bug(map(int, io_action)::in, wrap(S)::in, edt_node(R)::in,
> +	decl_e_bug::out) is det <= annotated_trace(S, R).
...
> +++ browser/declarative_execution.m	9 May 2002 04:54:52 -0000
> +			call_io_seq_num		:: int
> +						% The I/O action sequence
> +						% number at the time of the
> +						% call.
...
> +			exit_io_seq_num		:: int
> +						% The I/O action sequence
> +						% number at the time of the

The type `map(int, io_action)' occurs in a number of places.
IMHO it would be nicer to abstract this out as an equivalence type:

	:- type io_action_map == map(io_seq_num, io_action).
	:- type io_seq_num == int.

BTW, shouldn't this be `map_cc' rather than `map'?
Also it might perhaps be nicer to use `counter' rather than `int'.

> +						% exit.
...
> +++ trace/mercury_trace.h	9 May 2002 06:07:47 -0000
> @@ -108,8 +108,9 @@
>  ** information.
>  **
>  ** Retry across I/O is unsafe in general, at least for now. It is therefore
> -** only allowed if in_fp and out_fp are both non-NULL, and if the user, when
> -** asked whether he/she wants to perform the retry anyway, says yes.
> +** allowed only if unconditional_allow_io is TRUE, or if in_fp and out_fp are
> +** both non-NULL, and if the user, when asked whether he/she wants to perform
> +** the retry anyway, says yes.
>  */

The wording here "if ..., or if ..., and if ..." is confusing.
Better to change it to "if ..., or if ... and ...", i.e.
s/non-NULL, and if/non-NULL and/

> +++ trace/mercury_trace_declarative.c	9 May 2002 06:08:58 -0000
> @@ -1426,6 +1438,48 @@
...
> +static MR_bool		MR_io_action_map_cache_is_valid = MR_FALSE;
> +static MR_Unsigned	MR_io_action_map_cache_start;
> +static MR_Unsigned	MR_io_action_map_cache_end;
> +static MR_Word		MR_io_action_map_cache_map;

Storing Mercury values in C global variables is tricky to get right,
especially in the presence of accurate GC, and so should be avoided
where possible.

If you really need to do it, that's OK, but you need to call
MR_make_permanent() in appropriate places to ensure that the memory
doesn't get reclaimed on failure.  Otherwise it won't work in grades
that don't use conservative GC, e.g. the `--gc none' grades.

For accurate GC you'd also need to call MR_add_root() to register the
memory with the accurate garbage collector; plus some additional stuff
to register the roots on the C stack.  I guess support for accurate
GC is probably not worth worrying about here at the moment, but an XXX
comment would be helpful.

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