[m-rev.] [reuse] diff: improve fixpoint table

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Wed Mar 28 23:33:31 AEST 2001


Hi,


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


Estimated hours taken: 0.5
Branches: reuse

Improve the fixpoint-table implementation so that it can only be unstable
in the case of recursive data dependencies. This avoids doing extra
runs even in the case of non-recursive data (procedures). 

fixpoint_table.m:
	Rename the old field from `stable' to `recursive'. This field
	now expresses whether the dependencies are recursive or not. 
	Initially it is set to non-recursive. When information is
	retreived from the fixpoint-table, recursivity is set to yes. 
	The table can then only be unstable if the data is recursive. 
	


Index: fixpoint_table.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/fixpoint_table.m,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 fixpoint_table.m
--- fixpoint_table.m	2001/03/27 19:15:59	1.1.2.4
+++ fixpoint_table.m	2001/03/28 13:29:39
@@ -83,7 +83,7 @@
 	--->	ft(  
 		     keys	:: list(K),	% list of allowed keys
 		     run	:: int,		% number of runs
-		     stable	:: bool,	% is stable (default = yes)
+		     recursive	:: bool,	% is recursive or not
 		     mapping 	:: map(K, fp_entry(E))
 		).
 
@@ -101,9 +101,9 @@
 fp_entry_stability(entry(S, _)) = S. 
 fp_entry_elem(entry(_, Elem)) = Elem. 
 
-fp_init(Init, Ks, ft(Ks, Run, Stable, Map)) :- 
+fp_init(Init, Ks, ft(Ks, Run, IsRecursive, Map)) :- 
 	Run = 0,
-	Stable = yes,
+	IsRecursive = no,
 	map__init(Map0),
 	list__foldl(
 		(pred(K::in, M0::in, M::out) is det :- 
@@ -119,18 +119,24 @@
 fp_which_run(T0) = T0 ^ run.
 
 fp_stable(T) :- 
-	map__foldl(
-		pred(_K::in, Entry::in, S0::in, S::out) is det :- 
-		(
-			( S0 = no -> 
-				S = no
-			;
-				S = fp_entry_stability(Entry)
-			)
-		),
-		T ^ mapping,
-		yes, 
-		yes). 
+	(
+		T ^ recursive = yes
+	->
+		map__foldl(
+			pred(_K::in, Entry::in, S0::in, S::out) is det :- 
+			(
+				( S0 = no -> 
+					S = no
+				;
+					S = fp_entry_stability(Entry)
+				)
+			),
+			T ^ mapping,
+			yes, 
+			yes)
+	;
+		true
+	). 
 	
 fp_add(Equal, Index, Elem, Tin, Tout) :- 
 	Map = Tin ^ mapping, 
@@ -178,7 +184,7 @@
 	;
 		require__error("(fixpoint_table): key not in map")
 	),
-	Tout = (Tin ^ mapping := Mapout).
+	Tout = (Tin ^ mapping := Mapout) ^ recursive := yes.
 
 fp_get_final(Index, Elem, T) :- 
 	(

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