[m-rev.] for review: make deep profiling bootstrap again

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Feb 5 16:59:57 AEDT 2002


On 05-Feb-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> 1.  s/could remove some()s from around/could compute the wrong determinism for/
>     or something along those lines.
>     (det_analysis.m doesn't remove the `some's -- the problem is that
>     it doesn't treat them as cuts for determinism analysis.)
> 
> 2.  It would probably be cleaner to introduce a new goal_feature for `some'
>     goals that represent cuts, and to have det_analysis check that,
>     rather than having det_analysis treat cannot_remove `some' goals
>     as cuts.

Here is the updated log file and the relative diff. I will commit it if and
when it finishes bootchecking.

Zoltan.

Allow the deep profiling grade to bootstrap again.

compiler/deep_profiling.m:
	Fix an omission from a nonlocals set.

	Mark transformed some() goals that act as cuts as being non-removable.
	Without this, determinism analysis (reinvoked by simplify after the
	deep profiling transformation) could compute wrong determinism
	for some() goals with no output arguments. This happened if
	originally, the some() represented a cut, but after the goal being
	cut across was made inpure by the deep profiling transformation,
	determinism analysis decided that it needed to find all solutions
	to that goal to avoid removing some side effects.

compiler/det_analysis.m:
	Respect the non-removable markers placed by deep_profiling.m.

compiler/hlds_goal.m:
	Add a goal feature that acts as this marker.

tests/general/Mmakefile:
	In deep profiling grades, disable a test case that requires catching
	exceptions, which we can't do (yet) in those grades.

tests/recompilation/Mmakefile:
tests/recompilation/runtests:
	In deep profiling grades, disable all test cases in this directory,
	since the compiler's handling of recompilation requires catching
	exceptions.

diff -u compiler/deep_profiling.m compiler/deep_profiling.m
--- compiler/deep_profiling.m	4 Feb 2002 22:59:11 -0000
+++ compiler/deep_profiling.m	5 Feb 2002 05:11:05 -0000
@@ -951,13 +951,13 @@
 	transform_goal([neg | Path], Goal0, Goal, AddedImpurity),
 	{ add_impurity_if_needed(AddedImpurity, Info0, Info) }.
 
-transform_goal(Path, some(QVars, CanRemove0, Goal0) - Info0,
+transform_goal(Path, some(QVars, CanRemove, Goal0) - Info0,
 		some(QVars, CanRemove, Goal) - Info, AddedImpurity) -->
 	{ Goal0 = _ - InnerInfo },
 	{ goal_info_get_determinism(Info0, OuterDetism) },
 	{ goal_info_get_determinism(InnerInfo, InnerDetism) },
 	{ InnerDetism = OuterDetism ->
-		CanRemove = CanRemove0,
+		Info1 = Info0,
 		MaybeCut = no_cut
 	;
 		% Given a subgoal containing both nondet code and impure code, 
@@ -965,11 +965,12 @@
 		% that subgoal if it is allowed to. If we get here, then the
 		% subgoal inside the `some' contains nondet code, and the deep
 		% profiling transformation will make it impure as well.
-		CanRemove = cannot_remove,
+
+		goal_info_add_feature(Info0, keep_this_commit, Info1),
 		MaybeCut = cut
 	},
 	transform_goal([exist(MaybeCut) | Path], Goal0, Goal, AddedImpurity),
-	{ add_impurity_if_needed(AddedImpurity, Info0, Info) }.
+	{ add_impurity_if_needed(AddedImpurity, Info1, Info) }.
 
 transform_goal(Path, if_then_else(IVars, Cond0, Then0, Else0, SM) - Info0,
 		if_then_else(IVars, Cond, Then, Else, SM) - Info,
diff -u compiler/det_analysis.m compiler/det_analysis.m
--- compiler/det_analysis.m	4 Feb 2002 22:54:24 -0000
+++ compiler/det_analysis.m	5 Feb 2002 05:06:12 -0000
@@ -311,14 +311,16 @@
 		SolnContext = SolnContext0
 	),
 
+	% Some other part of the compiler has determined that we need to keep
+	% the cut represented by this quantification. This can happen e.g.
+	% when deep profiling adds impure code to the goal inside the some;
+	% it doesn't want to change the behavior of the some, even though
+	% the addition of impurity would make the if-then-else treat it
+	% differently.
+
 	(
-		Goal0 = some(_, cannot_remove, _ - InsideGoalInfo),
-		goal_info_get_determinism(GoalInfo0, OutsideDetism),
-		goal_info_get_determinism(InsideGoalInfo, InsideDetism),
-		determinism_components(OutsideDetism, _, OutsideSolns),
-		determinism_components(InsideDetism, _, InsideSolns),
-		OutsideSolns = at_most_one,
-		InsideSolns = at_most_many
+		Goal0 = some(_, _, _),
+		goal_info_has_feature(GoalInfo0, keep_this_commit)
 	->
 		Prune = yes
 	;
only in patch2:
--- compiler/hlds_goal.m	9 Jan 2002 06:12:39 -0000	1.91
+++ compiler/hlds_goal.m	5 Feb 2002 05:01:15 -0000
@@ -745,6 +745,16 @@
 				% the value of this variable in its stack slot
 				% as soon as it is generated; this marker
 				% tells the code generator when this happens.
+	;	keep_this_commit
+				% This feature should be attached only to goals
+				% that represent commits (i.e. some() goals in
+				% which the inner and outer determinisms
+				% differ). It tells determinism analysis that
+				% some other part of the compiler wants the
+				% commit to stay, even if the usual rules of
+				% determinism analysis say that the
+				% nondeterminism inside the some() should be
+				% exposed to the environment outside.
 	;	tailcall.	% This goal represents a tail call. This marker
 				% is used by deep profiling.
 
--------------------------------------------------------------------------
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