[m-rev.] [reuse] trivial diff: bugfix, reuse-goal-info initialisation

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Sat Jun 19 17:34:45 AEST 2004


Hi,


===================================================================


Estimated hours taken: 0.5
Branches: reuse

compiler/hlds_goal.m:
	Initialise the reuse-goal-info whenever needed. 

compiler/sr_direct.m:
	Remove explicit initialisation of the reuse-goal-info.


Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.76.2.16
diff -u -r1.76.2.16 hlds_goal.m
--- compiler/hlds_goal.m	2 Jun 2004 10:30:33 -0000	1.76.2.16
+++ compiler/hlds_goal.m	19 Jun 2004 07:02:04 -0000
@@ -774,7 +774,6 @@
 :- pred goal_info_get_outscope(hlds_goal_info::in, set(prog_var)::out) is det.
 :- pred goal_info_get_reuse(hlds_goal_info::in, reuse_goal_info::out) is det.
 
-:- pred goal_info_reuse_init(hlds_goal_info::in, hlds_goal_info::out) is det.
 :- pred goal_info_set_lfu(set(prog_var)::in, hlds_goal_info::in,
 	hlds_goal_info::out) is det.
 :- pred goal_info_set_lbu(set(prog_var)::in, hlds_goal_info::in,
@@ -1383,56 +1382,56 @@
 		error("goal_info_get_reuse: no goal_reuse_info")
 	).
 
-goal_info_reuse_init(GoalInfo0, GoalInfo) :- 
-	ReuseInfo = goal_reuse_info(set__init, set__init, set__init, empty),
-	GoalInfo = GoalInfo0 ^ goal_reuse_info := yes(ReuseInfo).
+:- pred goal_reuse_info_init(hlds_goal_reuse_info::out) is det.
+goal_reuse_info_init(ReuseInfo) :- 
+	ReuseInfo = goal_reuse_info(set__init, set__init, set__init, empty).
 
 goal_info_set_lfu(LFU, GoalInfo0, GoalInfo) :-
 	MaybeSub0 = GoalInfo0 ^ goal_reuse_info,
 	(
-		MaybeSub0 = yes(Sub0),
-		Sub = Sub0 ^ lfu := LFU,
-		MaybeSub = yes(Sub)
-	;
-		MaybeSub0 = no,
-		error("goal_info_set_lfu: no goal_reuse_info")
+		MaybeSub0 = yes(Sub0)
+	; 
+		MaybeSub0 = no, 
+		goal_reuse_info_init(Sub0)
 	),
+	Sub = Sub0 ^ lfu := LFU,
+	MaybeSub = yes(Sub),
 	GoalInfo = GoalInfo0 ^ goal_reuse_info := MaybeSub.
 
 goal_info_set_lbu(LBU, GoalInfo0, GoalInfo) :- 
 	MaybeSub0 = GoalInfo0 ^ goal_reuse_info,
 	(
-		MaybeSub0 = yes(Sub0),
-		Sub = Sub0 ^ lbu := LBU,
-		MaybeSub = yes(Sub)
-	;
+		MaybeSub0 = yes(Sub0)
+	; 
 		MaybeSub0 = no,
-		error("goal_info_set_lbu: no goal_reuse_info")
+		goal_reuse_info_init(Sub0)
 	),
+	Sub = Sub0 ^ lbu := LBU,
+	MaybeSub = yes(Sub),
 	GoalInfo = GoalInfo0 ^ goal_reuse_info := MaybeSub.
 
 goal_info_set_outscope(Outscope, GoalInfo0, GoalInfo) :- 
 	MaybeSub0 = GoalInfo0 ^ goal_reuse_info,
 	(
-		MaybeSub0 = yes(Sub0),
-		Sub = Sub0 ^ outscope := Outscope,
-		MaybeSub = yes(Sub)
+		MaybeSub0 = yes(Sub0)
 	;
-		MaybeSub0 = no,
-		error("goal_info_set_outscope: no goal_reuse_info")
-	),
+		MaybeSub0 = no, 
+		goal_reuse_info_init(Sub0)
+	), 
+	Sub = Sub0 ^ outscope := Outscope,
+	MaybeSub = yes(Sub),
 	GoalInfo = GoalInfo0 ^ goal_reuse_info := MaybeSub.
 
 goal_info_set_reuse(Reuse, GoalInfo0, GoalInfo):- 
 	MaybeSub0 = GoalInfo0 ^ goal_reuse_info,
 	(
-		MaybeSub0 = yes(Sub0),
-		Sub = Sub0 ^ reuse := Reuse,
-		MaybeSub = yes(Sub)
-	;
-		MaybeSub0 = no,
-		error("goal_info_set_reuse: no goal_reuse_info")
+		MaybeSub0 = yes(Sub0)
+	; 
+		MaybeSub0 = no, 
+		goal_reuse_info_init(Sub0)
 	),
+	Sub = Sub0 ^ reuse := Reuse,
+	MaybeSub = yes(Sub),
 	GoalInfo = GoalInfo0 ^ goal_reuse_info := MaybeSub.
 
 %-----------------------------------------------------------------------------%
Index: compiler/sr_direct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_direct.m,v
retrieving revision 1.1.2.19
diff -u -r1.1.2.19 sr_direct.m
--- compiler/sr_direct.m	10 Jun 2004 05:21:44 -0000	1.1.2.19
+++ compiler/sr_direct.m	19 Jun 2004 07:02:25 -0000
@@ -67,8 +67,7 @@
 	% unifications, later in the choice analysis)
 	% XXX these goal-paths should become the main way of identifying the
 	% places of reuse, instead of annotating the actual goals.
-	{ initialise_reuse_info(ProcInfo0, ProcInfo00) },
-	{ sr_lfu__process_proc(ProcInfo00, ProcInfo1) },
+	{ sr_lfu__process_proc(ProcInfo0, ProcInfo1) },
 	{ sr_lbu__process_proc(ModuleInfo0, ProcInfo1, ProcInfo2b) },
 	{ goal_path__fill_slots(ProcInfo2b, ModuleInfo0, ProcInfo2) }, 
 
@@ -134,47 +133,4 @@
 			ProcInfo3) },
 	{ proc_info_set_goal(ProcInfo3, Goal, ProcInfo) }.
 
-
-:- pred initialise_reuse_info(proc_info::in, proc_info::out) is det.
-
-initialise_reuse_info(ProcInfo0, ProcInfo) :- 
-	proc_info_goal(ProcInfo0, Goal0), 
-	initialise_reuse_info_in_goal(Goal0, Goal),
-	proc_info_set_goal(ProcInfo0, Goal, ProcInfo).
-
-:- pred initialise_reuse_info_in_goal(hlds_goal::in, hlds_goal::out) is det.
-
-initialise_reuse_info_in_goal(Expr0 - Info0, Expr - Info) :- 
-	goal_info_reuse_init(Info0, Info),
-	initialise_reuse_info_in_subgoal(Expr0, Expr). 
-
-:- pred initialise_reuse_info_in_subgoal(hlds_goal_expr::in, 
-		hlds_goal_expr::out) is det.
-
-initialise_reuse_info_in_subgoal(conj(Goals0), conj(Goals)):- 
-	list__map(initialise_reuse_info_in_goal, Goals0, Goals).
-initialise_reuse_info_in_subgoal(call(A,B,C,D,E,F), call(A,B,C,D,E,F)).
-initialise_reuse_info_in_subgoal(generic_call(A,B,C,D), generic_call(A,B,C,D)).
-initialise_reuse_info_in_subgoal(switch(A,B,Cases0),switch(A,B,Cases)) :-
-	list__map(
-		pred(Case0::in, Case::out) is det :- 
-			( Case0 = case(C,G0), 
-			initialise_reuse_info_in_goal(G0,G),
-			Case = case(C,G)), Cases0, Cases).
-initialise_reuse_info_in_subgoal(unify(A,B,C,D,E), unify(A,B,C,D,E)).
-initialise_reuse_info_in_subgoal(disj(Goals0), disj(Goals)):- 
-	list__map(initialise_reuse_info_in_goal, Goals0, Goals).
-initialise_reuse_info_in_subgoal(not(Goal0), not(Goal)):- 
-	initialise_reuse_info_in_goal(Goal0, Goal).
-initialise_reuse_info_in_subgoal(some(A,B,G0),some(A,B,G)):- 
-	initialise_reuse_info_in_goal(G0, G).
-initialise_reuse_info_in_subgoal(if_then_else(A,I0,T0,E0),
-		if_then_else(A,I,T,E)):- 
-	initialise_reuse_info_in_goal(I0, I),
-	initialise_reuse_info_in_goal(T0, T),
-	initialise_reuse_info_in_goal(E0, E).
-initialise_reuse_info_in_subgoal(foreign_proc(A,B,C,D,E,F,G),
-		foreign_proc(A,B,C,D,E,F,G)).
-initialise_reuse_info_in_subgoal(par_conj(G),par_conj(G)).
-initialise_reuse_info_in_subgoal(shorthand(G),shorthand(G)).
 


-- 
nancy.mazur at cs.kuleuven.ac.be ------------ Katholieke Universiteit Leuven -
tel: +32-16-327596 - fax: +32-16-327996 ------- Dept. of Computer Science -
--------------------------------------------------------------------------
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