[m-rev.] for review: dependency tracking

Mark Brown dougl at cs.mu.OZ.AU
Mon Apr 22 07:06:32 AEST 2002


On 19-Apr-2002, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> Index: browser/declarative_analyser.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/browser/declarative_analyser.m,v
> retrieving revision 1.8
> diff -u -b -r1.8 declarative_analyser.m
> --- browser/declarative_analyser.m	23 Apr 2001 17:28:55 -0000	1.8
> +++ browser/declarative_analyser.m	11 Apr 2002 06:54:55 -0000
> @@ -87,57 +95,59 @@
>  			% The analyser desires answers to any of a list
>  			% of queries.
>  			%
> -	;	oracle_queries(list(decl_question))
> +	;	oracle_queries(list(decl_question), maybe(subterm_origin(R)))

You should document the extra argument.

>  
>  :- implementation.
> +
> +:- import_module mdb__declarative_execution.

That module shouldn't need to be imported here.

> @@ -212,16 +222,16 @@
>  	%
>  	(
>  		SubtermMode = subterm_in,
> -		remove_suspects(Store, [truth_value(Query, yes)], Response0,
> -				Analyser0, Analyser)
> +		remove_suspects(Store, yes(Origin), [truth_value(Query, yes)],
> +			Response0, Analyser0, Analyser)
>  	;
>  		SubtermMode = subterm_out,
> -		make_new_prime_suspect(Store, Suspect, Response0, Analyser0,
> -				Analyser)
> +		make_new_prime_suspect(Store, yes(Origin), Suspect, Response0,
> +			Analyser0, Analyser)
>  	),
>  	(
>  		Origin = output(Node, _, _),
> -		Response0 = oracle_queries(_)
> +		Response0 = oracle_queries(_, MaybeOrigin)
>  	->
>  		%
>  		% Replace all of the queries with just the one which output

Rather than thread the maybe(subterm_origin) through these two calls, I
think it would be better to add a field of this type to the analyser
state.  This fits with the intent of the analyser state, which is to
give information about the current set of suspects.

> Index: browser/declarative_debugger.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/browser/declarative_debugger.m,v
> retrieving revision 1.23
> diff -u -b -r1.23 declarative_debugger.m
> --- browser/declarative_debugger.m	4 Apr 2002 06:00:06 -0000	1.23
> +++ browser/declarative_debugger.m	17 Apr 2002 06:06:07 -0000
> @@ -583,430 +591,570 @@
>  % We are given an EDT node, an argument position, and a path to the selected
>  % subterm.  We wish to find the origin of that subterm within the body of the
>  % given node, or within the body of its parent.  We can figure out the mode of
> -% the top of the selected subterm; if the mode is `in', the origin could be:
> -%	- a unification within the body of the parent,
> +% the top of the selected subterm.
> +%
> +% If the mode is `in', the origin could be:
> +%	- a primitive (unification of foreign_proc) within the body of the

s/of/or/

> @@ -1107,3 +1222,56 @@
>  decl_bug_get_event_number(i_bug(IBug), Event) :-
>  	IBug = inadmissible_call(_, _, _, Event).
>  
> +%-----------------------------------------------------------------------------%
> +
> +% :- impure pred dump(string::in, T::in) is det.
> +
> +% dump(Msg, Data) :-
> +% 	impure unsafe_perform_io(io__write_string(Msg)),
> +% 	impure unsafe_perform_io(io__write_string(": ")),
> +% 	impure unsafe_perform_io(io__write(Data)),
> +% 	impure unsafe_perform_io(io__write_string("\n")).

Were you plaaning to do anything with this?  If not, leave it out.

> +
> +:- pred write_origin(wrap(S)::in, subterm_origin(edt_node(R))::in,
> +	io__state::di, io__state::uo) is det <= annotated_trace(S, R).
> +
> +write_origin(wrap(Store), Origin) -->
> +	( { Origin = output(dynamic(NodeId), ArgPos, TermPath) } ->
> +		{ exit_node_from_id(Store, NodeId, ExitNode) },
> +		{ ProcName = ExitNode ^ exit_atom ^ proc_name },
> +		io__write_string("output("),
> +		io__write_string(ProcName),
> +		io__write_string(", "),
> +		io__write(ArgPos),
> +		io__write_string(", "),
> +		io__write(TermPath),
> +		io__write_string(")")
> +	;
> +		io__write(Origin)
> +	).

This would make more sense in declarative_analyser.m, which is where
subterm_origin is defined.  You could get the proc name by calling
edt_root_question instead of exit_node_from_id.

> +
> +:- pragma foreign_code("C",
> +"
> +
> +/*
> +** The declarative debugger will print diagnostic information about the origins
> +** computed by dependency tracking if this flag has a positive value.
> +*/
> +
> +int	MR_DD_debug_origin = 0;
> +
> +").
> +
> +:- pragma foreign_decl("C",
> +"
> +extern	int	MR_DD_debug_origin;
> +").
> +
> +:- pred debug_origin(int::out) is det.
> +
> +:- pragma foreign_proc("C",
> +	debug_origin(Flag::out),
> +	[will_not_call_mercury, promise_pure],
> +"
> +	Flag = MR_DD_debug_origin;
> +").

This promise is a lie.  You should thread the io__state through it, or
else leave it impure and promise that its caller is pure.

To be continued ...

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