[m-dev.] [reuse] diff: annotate compile time gc cells

Peter Ross Peter.Ross at cs.kuleuven.ac.be
Thu Sep 28 01:59:22 AEDT 2000


Hi,


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


Estimated hours taken: 5

Annotate cells which are available for compile time garbage collection.

sr_reuse.m:
    Given the reuse information for a procedure determine which
    variables can be compile time garbage collected after use in a
    deconstruction.

sr_reuse_run.m:
    Annotate all the deconstructions which can be compile time garbage
    collected.
    In create_reuse_pred always keep the annotated goal because it may
    not have reuse but it may have compile time gc.

hlds_goal.m:
    Add a new field to deconstruction unifications which is whether or
    not the top level cell can be compile time garbage collected.

hlds_out.m:
    Print out the compile time garbage collection information.

*.m:
    Handle the new field for deconstruction unifications.

Index: bytecode_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode_gen.m,v
retrieving revision 1.48.2.1
diff -u -r1.48.2.1 bytecode_gen.m
--- bytecode_gen.m	2000/09/25 17:01:43	1.48.2.1
+++ bytecode_gen.m	2000/09/27 14:48:46
@@ -472,8 +472,8 @@
 				Pairs)])
 		)
 	).
-bytecode_gen__unify(deconstruct(Var, ConsId, Args, UniModes, _), _, _, ByteInfo,
-		Code) :-
+bytecode_gen__unify(deconstruct(Var, ConsId, Args, UniModes, _, _), _, _,
+		ByteInfo, Code) :-
 	bytecode_gen__map_var(ByteInfo, Var, ByteVar),
 	bytecode_gen__map_vars(ByteInfo, Args, ByteArgs),
 	bytecode_gen__map_cons_id(ByteInfo, Var, ConsId, ByteConsId),
Index: code_aux.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_aux.m,v
retrieving revision 1.58
diff -u -r1.58 code_aux.m
--- code_aux.m	2000/08/09 07:46:18	1.58
+++ code_aux.m	2000/09/27 14:48:46
@@ -98,7 +98,7 @@
 	;
 		Uni = construct(_, _, _, _, _, _, _)
 	;
-		Uni = deconstruct(_, _, _, _, _)
+		Uni = deconstruct(_, _, _, _, _, _)
 	).
 		% Complicated unifies are _non_builtin_
 
@@ -178,7 +178,7 @@
 	;
 		Uni = construct(_, _, _, _, _, _, _)
 	;
-		Uni = deconstruct(_, _, _, _, _)
+		Uni = deconstruct(_, _, _, _, _, _)
 	).
 		% Complicated unifies are _non_builtin_
 	
Index: common.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/common.m,v
retrieving revision 1.57
diff -u -r1.57 common.m
--- common.m	2000/08/07 07:23:51	1.57
+++ common.m	2000/09/27 14:48:46
@@ -162,7 +162,8 @@
 			common__record_cell(Var, ConsId, ArgVars, Info0, Info)
 		)
 	;
-		Unification0 = deconstruct(Var, ConsId, ArgVars, UniModes, _),
+		Unification0 = deconstruct(Var, ConsId,
+				ArgVars, UniModes, _, _),
 		simplify_info_get_module_info(Info0, ModuleInfo),
 		(
 				% Don't optimise partially instantiated
Index: cse_detection.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/cse_detection.m,v
retrieving revision 1.63
diff -u -r1.63 cse_detection.m
--- cse_detection.m	2000/09/07 01:46:16	1.63
+++ cse_detection.m	2000/09/27 14:48:47
@@ -560,9 +560,10 @@
 		Typemap0, Typemap, Replacements) :-
 	(
 		GoalExpr0 = unify(_, Term, Umode, Unif0, Ucontext),
-		Unif0 = deconstruct(_, Consid, Args, Submodes, CanFail)
+		Unif0 = deconstruct(_, Consid, Args, Submodes, CanFail, CanCGC)
 	->
-		Unif = deconstruct(Var, Consid, Args, Submodes, CanFail),
+		Unif = deconstruct(Var, Consid, Args,
+				Submodes, CanFail, CanCGC),
 		( Term = functor(_, _) ->
 			GoalExpr1 = unify(Var, Term, Umode, Unif, Ucontext)
 		;
@@ -605,9 +606,9 @@
 find_similar_deconstruct(OldUnifyGoal, NewUnifyGoal, Context, Replacements) :-
 	(
 		OldUnifyGoal = unify(_OT1, _OT2, _OM, OldUnifyInfo, OC) - _,
-		OldUnifyInfo = deconstruct(_OV, OF, OFV, _OUM, _OCF),
+		OldUnifyInfo = deconstruct(_OV, OF, OFV, _OUM, _OCF, _OCGC),
 		NewUnifyGoal = unify(_NT1, _NT2, _NM, NewUnifyInfo, _NC) - _,
-		NewUnifyInfo = deconstruct(_NV, NF, NFV, _NUM, _NCF)
+		NewUnifyInfo = deconstruct(_NV, NF, NFV, _NUM, _NCF, _NCGC)
 	->
 		OF = NF,
 		list__length(OFV, OFVC),
Index: dependency_graph.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dependency_graph.m,v
retrieving revision 1.48
diff -u -r1.48 dependency_graph.m
--- dependency_graph.m	2000/08/09 07:46:23	1.48
+++ dependency_graph.m	2000/09/27 14:48:47
@@ -267,7 +267,7 @@
 	; Unify = construct(_, Cons, _, _, _, _, _),
 	    dependency_graph__add_arcs_in_cons(Cons, Caller,
 				DepGraph0, DepGraph)
-	; Unify = deconstruct(_, Cons, _, _, _),
+	; Unify = deconstruct(_, Cons, _, _, _, _),
 	    dependency_graph__add_arcs_in_cons(Cons, Caller,
 				DepGraph0, DepGraph)
 	; Unify = complicated_unify(_, _, _),
Index: det_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_analysis.m,v
retrieving revision 1.145
diff -u -r1.145 det_analysis.m
--- det_analysis.m	2000/08/09 07:46:24	1.145
+++ det_analysis.m	2000/09/27 14:48:48
@@ -900,7 +900,7 @@
 :- pred det_infer_unify_examines_rep(unification::in, bool::out) is det.
 det_infer_unify_examines_rep(assign(_, _), no).
 det_infer_unify_examines_rep(construct(_, _, _, _, _, _, _), no).
-det_infer_unify_examines_rep(deconstruct(_, _, _, _, _), yes).
+det_infer_unify_examines_rep(deconstruct(_, _, _, _, _, _), yes).
 det_infer_unify_examines_rep(simple_test(_, _), yes).
 det_infer_unify_examines_rep(complicated_unify(_, _, _), no).
 	% Some complicated modes of complicated unifications _do_
@@ -922,7 +922,7 @@
 :- pred det_infer_unify_canfail(unification, can_fail).
 :- mode det_infer_unify_canfail(in, out) is det.
 
-det_infer_unify_canfail(deconstruct(_, _, _, _, CanFail), CanFail).
+det_infer_unify_canfail(deconstruct(_, _, _, _, CanFail, _), CanFail).
 det_infer_unify_canfail(assign(_, _), cannot_fail).
 det_infer_unify_canfail(construct(_, _, _, _, _, _, _), cannot_fail).
 det_infer_unify_canfail(simple_test(_, _), can_fail).
Index: goal_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/goal_util.m,v
retrieving revision 1.64
diff -u -r1.64 goal_util.m
--- goal_util.m	2000/09/04 22:33:36	1.64
+++ goal_util.m	2000/09/27 14:48:48
@@ -447,8 +447,9 @@
 		How0 = construct_statically(_),
 		How = How0
 	).
-goal_util__rename_unify(deconstruct(Var0, ConsId, Vars0, Modes, Cat),
-		Must, Subn, deconstruct(Var, ConsId, Vars, Modes, Cat)) :-
+goal_util__rename_unify(deconstruct(Var0, ConsId, Vars0, Modes, Cat, CanCGC),
+		Must, Subn,
+		deconstruct(Var, ConsId, Vars, Modes, Cat, CanCGC)) :-
 	goal_util__rename_var(Var0, Must, Subn, Var),
 	goal_util__rename_var_list(Vars0, Must, Subn, Vars).
 goal_util__rename_unify(assign(L0, R0), Must, Subn, assign(L, R)) :-
@@ -984,7 +985,8 @@
 	list__map(InstToUniMode, ArgInsts, UniModes),
 	UniMode = (Inst0 -> Inst0) - (Inst0 -> Inst0),
 	UnifyContext = unify_context(explicit, []),
-	Unification = deconstruct(Var, ConsId, ArgVars, UniModes, can_fail),
+	Unification = deconstruct(Var, ConsId, ArgVars, UniModes,
+			can_fail, no),
 	ExtraGoal = unify(Var, functor(ConsId, ArgVars),
 		UniMode, Unification, UnifyContext),
 	set__singleton_set(NonLocals, Var),
Index: higher_order.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.71.2.1
diff -u -r1.71.2.1 higher_order.m
--- higher_order.m	2000/09/25 17:02:33	1.71.2.1
+++ higher_order.m	2000/09/27 14:48:51
@@ -647,7 +647,7 @@
 	maybe_add_alias(Var1, Var2).
 
 	% deconstructing a higher order term is not allowed
-check_unify(deconstruct(_, _, _, _, _)) --> [].
+check_unify(deconstruct(_, _, _, _, _, _)) --> [].
 
 check_unify(construct(LVar, ConsId, Args, _Modes, _, _, _), Info0, Info) :-
 	Info0 = info(PredVars0, Requests, NewPreds, PredProcId,
@@ -2056,7 +2056,7 @@
 	goal_info_init(NonLocals, InstMapDelta, det, GoalInfo),
 	Goal = unify(Arg, functor(ConsId, [UnwrappedArg]), In - Out,
 		deconstruct(Arg, ConsId, [UnwrappedArg], UniModes,
-			cannot_fail),
+			cannot_fail, no),
 		unify_context(explicit, [])) - GoalInfo.
 
 %-------------------------------------------------------------------------------
Index: hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.76.2.1
diff -u -r1.76.2.1 hlds_goal.m
--- hlds_goal.m	2000/09/19 10:01:22	1.76.2.1
+++ hlds_goal.m	2000/09/27 14:48:52
@@ -411,6 +411,9 @@
 	;	modes_are_ok
 	.
 
+	% The cell is available for compile time garbage collected.
+:- type can_cgc == bool.
+
 :- type unification
 		% A construction unification is a unification with a functor
 		% or lambda expression which binds the LHS variable,
@@ -477,8 +480,9 @@
 					% e.g. [X] in the above example.
 			list(uni_mode), % The lists of modes of the argument
 					% sub-unifications.
-			can_fail	% Whether or not the unification
+			can_fail,	% Whether or not the unification
 					% could possibly fail.
+			can_cgc		% Can compile time GC this cell
 		)
 
 		% Y = X where the top node of Y is output,
Index: hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.243.2.3
diff -u -r1.243.2.3 hlds_out.m
--- hlds_out.m	2000/09/25 17:02:46	1.243.2.3
+++ hlds_out.m	2000/09/27 14:48:53
@@ -1540,7 +1540,8 @@
 	hlds_out__write_unify_rhs_2(B, ModuleInfo, VarSet, InstVarSet,
 		AppendVarnums, Indent, Follow, VarType, TypeQual),
 	globals__io_lookup_string_option(dump_hlds_options, Verbose),
-	( { string__contains_char(Verbose, 'u') } ->
+	( { string__contains_char(Verbose, 'u') 
+			; string__contains_char(Verbose, 'p') } ->
 		(
 			% don't output bogus info if we haven't been through
 			% mode analysis yet
@@ -1806,8 +1807,12 @@
 		ModuleInfo, ProgVarSet, InstVarSet, AppendVarnums, Indent).
 
 hlds_out__write_unification(deconstruct(Var, ConsId, ArgVars, ArgModes,
-		CanFail), ModuleInfo, ProgVarSet, InstVarSet, AppendVarnums,
-		Indent) -->
+		CanFail, CanCGC),
+		ModuleInfo, ProgVarSet, InstVarSet, AppendVarnums, Indent) -->
+	hlds_out__write_indent(Indent),
+	io__write_string("% Compile time garbage collect: "),
+	io__write(CanCGC),
+	io__nl,
 	hlds_out__write_indent(Indent),
 	io__write_string("% "),
 	mercury_output_var(Var, ProgVarSet, AppendVarnums),
Index: mark_static_terms.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mark_static_terms.m,v
retrieving revision 1.2
diff -u -r1.2 mark_static_terms.m
--- mark_static_terms.m	2000/08/09 07:47:06	1.2
+++ mark_static_terms.m	2000/09/27 14:48:53
@@ -167,7 +167,7 @@
 		)
 	;
 		Unification0 = deconstruct(_Var, _ConsId, _ArgVars, _UniModes,
-			_CanFail),
+			_CanFail, _CanCGC),
 		Unification = Unification0,
 		StaticVars = StaticVars0
 /*****************
Index: ml_unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.16.2.2
diff -u -r1.16.2.2 ml_unify_gen.m
--- ml_unify_gen.m	2000/09/25 17:03:55	1.16.2.2
+++ ml_unify_gen.m	2000/09/27 14:48:55
@@ -134,7 +134,7 @@
 	},
 	ml_gen_construct(Var, ConsId, Args, ArgModes, HowToConstruct, Context,
 		MLDS_Decls, MLDS_Statements).
-ml_gen_unification(deconstruct(Var, ConsId, Args, ArgModes, CanFail),
+ml_gen_unification(deconstruct(Var, ConsId, Args, ArgModes, CanFail, _CanCGC),
 		CodeModel, Context, MLDS_Decls, MLDS_Statements) -->
 	(
 		{ CanFail = can_fail },
Index: mode_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mode_util.m,v
retrieving revision 1.128.2.1
diff -u -r1.128.2.1 mode_util.m
--- mode_util.m	2000/09/25 17:04:00	1.128.2.1
+++ mode_util.m	2000/09/27 14:48:56
@@ -1426,7 +1426,7 @@
 	% that can require updating of the instmap_delta after simplify.m
 	% has been run.
 	(
-		Uni = deconstruct(Var, _ConsId, Vars, UniModes, _)
+		Uni = deconstruct(Var, _ConsId, Vars, UniModes, _, _CanCGC)
 	->
 		% Get the final inst of the deconstructed var, which
 		% will be the same as in the old instmap.
Index: modecheck_unify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modecheck_unify.m,v
retrieving revision 1.42
diff -u -r1.42 modecheck_unify.m
--- modecheck_unify.m	2000/05/22 18:00:22	1.42
+++ modecheck_unify.m	2000/09/27 14:48:56
@@ -133,7 +133,8 @@
 		% fields created by polymorphism.m
 		Unification0 \= construct(_, code_addr_const(_, _),
 			_, _, _, _, _),
-		Unification0 \= deconstruct(_, code_addr_const(_, _), _, _, _)
+		Unification0 \= deconstruct(_,
+				code_addr_const(_, _), _, _, _, _)
 	->
 		%
 		% convert the pred term to a lambda expression
@@ -623,7 +624,7 @@
 				Unification, ArgVars, ExtraGoals) -->
 	(
 		{ Unification0 = deconstruct(X, ConsId, ArgVars0, ArgModes0,
-			Det) }
+			Det, CanCGC) }
 	->
 		(
 			split_complicated_subunifies_2(ArgVars0, ArgModes0,
@@ -632,7 +633,7 @@
 			{ ExtraGoals = ExtraGoals1 },
 			{ ArgVars = ArgVars1 },
 			{ Unification = deconstruct(X, ConsId, ArgVars,
-							ArgModes0, Det) }
+					ArgModes0, Det, CanCGC) }
 		;
 			{ error("split_complicated_subunifies_2 failed") }
 		)
@@ -985,7 +986,7 @@
 	( Unification0 = construct(_, ConsId0, _, _, _, _, AditiInfo0) ->
 		AditiInfo = AditiInfo0,
 		ConsId = ConsId0
-	; Unification0 = deconstruct(_, ConsId1, _, _, _) ->
+	; Unification0 = deconstruct(_, ConsId1, _, _, _, _) ->
 		AditiInfo = no,
 		ConsId = ConsId1
 	;
@@ -1082,7 +1083,7 @@
 	% if we are re-doing mode analysis, preserve the existing cons_id
 	( Unification0 = construct(_, ConsId0, _, _, _, _, _) ->
 		ConsId = ConsId0
-	; Unification0 = deconstruct(_, ConsId1, _, _, _) ->
+	; Unification0 = deconstruct(_, ConsId1, _, _, _, _) ->
 		ConsId = ConsId1
 	;
 		ConsId = NewConsId
@@ -1148,7 +1149,8 @@
 				ModeInfo = ModeInfo0
 			)
 		),
-		Unification = deconstruct(X, ConsId, ArgVars, ArgModes, CanFail)
+		Unification = deconstruct(X, ConsId, ArgVars,
+				ArgModes, CanFail, no)
 	).
 
 	% Check that any type_info or type_class_info variables
Index: modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.132.2.3
diff -u -r1.132.2.3 modules.m
--- modules.m	2000/09/25 17:04:11	1.132.2.3
+++ modules.m	2000/09/27 14:48:59
@@ -1429,7 +1429,7 @@
 		UseDeps = UseDeps1
 	).
 
-:- pred contains_tabling_pragma(item_list).
+:- pred contains_tabling_pragma(item_list::in) is semidet.
 contains_tabling_pragma([Item|Items]) :-
 	(
 		Item = pragma(Pragma) - _Context,
Index: pa_alias.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_alias.m,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 pa_alias.m
--- pa_alias.m	2000/09/19 10:02:06	1.1.2.1
+++ pa_alias.m	2000/09/27 14:48:59
@@ -531,7 +531,7 @@
 	list__foldl( alias_from_unif(VAR,CONS),NUMBEREDARGS, [], AS).
 
 from_unification( _ProcInfo, _HLDS, 
-		deconstruct( VAR, CONS, ARGS, _, _ ), Info, AS) :-
+		deconstruct( VAR, CONS, ARGS, _, _, _ ), Info, AS) :-
 	number_args( ARGS, NUMBEREDARGS),
 	optimize_for_deconstruct(NUMBEREDARGS, Info, ReducedARGS),
 	list__foldl( alias_from_unif(VAR,CONS),ReducedARGS, [], AS).
Index: pd_cost.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/pd_cost.m,v
retrieving revision 1.8
diff -u -r1.8 pd_cost.m
--- pd_cost.m	2000/08/09 07:47:34	1.8
+++ pd_cost.m	2000/09/27 14:49:00
@@ -128,7 +128,7 @@
 		Cost = 0
 	).
 
-pd_cost__unify(NonLocals, deconstruct(_, _, Args, _, CanFail), Cost) :-
+pd_cost__unify(NonLocals, deconstruct(_, _, Args, _, CanFail, _), Cost) :-
 	( CanFail = can_fail ->
 		pd_cost__simple_test(Cost0)
 	;
Index: pd_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/pd_util.m,v
retrieving revision 1.11
diff -u -r1.11 pd_util.m
--- pd_util.m	2000/09/07 01:46:44	1.11
+++ pd_util.m	2000/09/27 14:49:00
@@ -934,9 +934,9 @@
 				NewArgs = [NewVar | NewArgs1]
 			;
 				OldUnification = deconstruct(OldVar, ConsId,
-							OldArgs1, _, _),
+							OldArgs1, _, _, _),
 				NewUnification = deconstruct(NewVar, ConsId,
-							NewArgs1, _, _),
+							NewArgs1, _, _, _),
 				OldArgs = [OldVar | OldArgs1],
 				NewArgs = [NewVar | NewArgs1]
 			)	
Index: prog_rep.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_rep.m,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 prog_rep.m
--- prog_rep.m	2000/09/25 17:04:54	1.1.2.1
+++ prog_rep.m	2000/09/27 14:49:00
@@ -108,7 +108,7 @@
 		list__map(term__var_to_int, Args, ArgsRep),
 		AtomicGoalRep = unify_construct_rep(VarRep, ConsIdRep, ArgsRep)
 	;
-		Uni = deconstruct(Var, ConsId, Args, _, _),
+		Uni = deconstruct(Var, ConsId, Args, _, _, _),
 		term__var_to_int(Var, VarRep),
 		prog_rep__represent_cons_id(ConsId, ConsIdRep),
 		list__map(term__var_to_int, Args, ArgsRep),
Index: rl_exprn.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rl_exprn.m,v
retrieving revision 1.16
diff -u -r1.16 rl_exprn.m
--- rl_exprn.m	2000/08/09 07:47:46	1.16
+++ rl_exprn.m	2000/09/27 14:49:03
@@ -1150,7 +1150,7 @@
 		{ error("rl_exprn__unify: unsupported cons_id - tabling_pointer_const") }
 	).
 		
-rl_exprn__unify(deconstruct(Var, ConsId, Args, UniModes, CanFail),
+rl_exprn__unify(deconstruct(Var, ConsId, Args, UniModes, CanFail, _CanCGC),
 		GoalInfo, Fail, Code) -->
 	rl_exprn_info_lookup_var(Var, VarLoc),
 	rl_exprn_info_lookup_var_type(Var, Type),
Index: rl_key.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rl_key.m,v
retrieving revision 1.6.4.1
diff -u -r1.6.4.1 rl_key.m
--- rl_key.m	2000/09/25 17:04:59	1.6.4.1
+++ rl_key.m	2000/09/27 14:49:05
@@ -793,7 +793,7 @@
 rl_key__extract_key_range_unify(construct(Var, ConsId, Args, _, _, _, _)) -->
 	rl_key__unify_functor(Var, ConsId, Args).
 rl_key__extract_key_range_unify(
-		deconstruct(Var, ConsId, Args, _, _)) -->
+		deconstruct(Var, ConsId, Args, _, _, _)) -->
 	rl_key__unify_functor(Var, ConsId, Args).
 rl_key__extract_key_range_unify(complicated_unify(_, _, _)) -->
 	{ error("rl_key__extract_key_range_unify") }.
Index: simplify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.84.2.1
diff -u -r1.84.2.1 simplify.m
--- simplify.m	2000/09/25 17:05:02	1.84.2.1
+++ simplify.m	2000/09/27 14:49:08
@@ -1730,7 +1730,7 @@
 	UniMode = (Inst0 -> Inst0) - (Inst0 -> Inst0),
 	UnifyContext = unify_context(explicit, []),
 	Unification = deconstruct(Var, ConsId,
-		ArgVars, UniModes, can_fail),
+		ArgVars, UniModes, can_fail, no),
 	ExtraGoal = unify(Var, functor(ConsId, ArgVars),
 		UniMode, Unification, UnifyContext),
 	set__singleton_set(NonLocals, Var),
Index: sr_reuse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_reuse.m,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 sr_reuse.m
--- sr_reuse.m	2000/09/25 09:20:25	1.1.2.4
+++ sr_reuse.m	2000/09/27 14:49:09
@@ -117,7 +117,8 @@
 :- pred try_to_reuse( cons_id, reuses, prog_var, reuses).
 :- mode try_to_reuse( in, in, out, out) is semidet.
 
-%-------------------------------------------------------------------%
+:- pred compile_time_gc_cells(reuses::in, list(prog_var)::out) is det.
+
 %-------------------------------------------------------------------%
 %-- tabled_reuse
 
@@ -1304,5 +1305,24 @@
 
 	io__write_string(")").
 
-	
 	
+%-------------------------------------------------------------------%
+
+compile_time_gc_cells(reuses(_, DirectReuses, _), GcCells) :-
+	GlobalDirectReuses = list__condense(map__values(DirectReuses ^ global)),
+	LocalDirectReuses = list__condense(map__values(DirectReuses ^ local)),
+	list__filter_map(compile_time_gc_canditate,
+			GlobalDirectReuses `list__append` LocalDirectReuses,
+			GcCells).
+
+:- pred compile_time_gc_canditate(direct_reuse::in, prog_var::out) is semidet.
+
+compile_time_gc_canditate(direct(Var, _, Cond, Canditates), Var) :-
+	Canditates = 0,
+	(
+		Cond = always
+	;
+		Cond = condition([], _, _)
+	).
+
+%-------------------------------------------------------------------%
Index: sr_reuse_run.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_reuse_run.m,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 sr_reuse_run.m
--- sr_reuse_run.m	2000/09/22 15:04:14	1.1.2.4
+++ sr_reuse_run.m	2000/09/27 14:49:14
@@ -76,9 +76,12 @@
 		{ hlds_dependency_info_get_dependency_ordering( DepInfo, DepOrdering ) },
 		% perform the analysis, and annotate the procedures
 		run_with_dependencies( DepOrdering, HLDS1, HLDS2),
+		/*
 		process_all_nonimported_procs(
 			update_module_io(process_proc),
 			HLDS2, HLDSout)
+		*/
+		{ HLDSout = HLDS2 }
 	;
 		{ error("(sr_reuse_run) reuse_pass: no dependency info") }
 	).
@@ -202,10 +205,14 @@
 		sr_reuse__init(PredArity, ProcInfo, Reuses0),
 		% 5. analyse_goal
 		analyse_goal( ProcInfo, HLDS, 
-					Goal0, Goal, 
+					Goal0, Goal1,
 					Reuses0, Reuses,
 					Alias0, _Alias, 
 					FPin, FP1 ),
+
+		compile_time_gc_cells(Reuses, CgcCells),
+		process_goal(CgcCells, Goal1, Goal, HLDS, _),
+
 		% 	OK
 		% 6. update all kind of information
 		sr_reuse__to_tabled_reuse( Reuses, TREUSE ), 
@@ -491,7 +498,7 @@
 unification_verify_reuse( Unification, Alias0, Reuses0, Reuses,
 				Info0, Info) :- 
 	(
-		Unification = deconstruct( Var, CONS_ID, _, _, _)
+		Unification = deconstruct( Var, CONS_ID, _, _, _, _)
 	->
 		goal_info_get_lfu( Info0, LFU ), 
 		goal_info_get_lbu( Info0, LBU ),
@@ -619,7 +626,8 @@
 		module_info_set_structure_reuse_info(HLDSin,
 				StrReuseInfo, HLDSin1),
 		module_info_set_predicate_table(HLDSin1, PredTable, HLDSout)
-	; contains_unconditional_reuse(TREUSE) ->
+	% ; contains_unconditional_reuse(TREUSE) ->
+	;
 		proc_info_set_reuse_information(ProcInfo0, TREUSE, ProcInfo1),
 		(
 			MaybeHLDS_GOAL = yes(HLDS_GOAL),
@@ -630,8 +638,6 @@
 		),
 		module_info_set_pred_proc_info(HLDSin, PRED_PROC_ID, 
 				PredInfo0, ProcInfo, HLDSout)
-	;
-		HLDSout = HLDSin
 	).
 
 
@@ -726,15 +732,15 @@
 process_proc(_PredId, _ProcId, ProcInfo0, ProcInfo, 
 		ModuleInfo0, ModuleInfo) -->
 	{ proc_info_goal(ProcInfo0, Goal0) },
-	{ process_goal(Goal0, Goal, ModuleInfo0, ModuleInfo) },
+	{ process_goal([], Goal0, Goal, ModuleInfo0, ModuleInfo) },
 	{ proc_info_set_goal(ProcInfo0, Goal, ProcInfo) }.
 
 %-----------------------------------------------------------------------------%
 
-:- pred process_goal(hlds_goal::in, hlds_goal::out,
+:- pred process_goal(prog_vars::in, hlds_goal::in, hlds_goal::out,
 		module_info::in, module_info::out) is det.
 
-process_goal(Goal0 - GoalInfo, Goal - GoalInfo) -->
+process_goal(_CGC, Goal0 - GoalInfo, Goal - GoalInfo) -->
 	{ Goal0 = call(PredId0, ProcId0, Args, Builtin, MaybeContext, Name0) },
 	=(ModuleInfo),
 	{ module_info_structure_reuse_info(ModuleInfo, ReuseInfo) },
@@ -751,63 +757,74 @@
 	},
 	{ Goal = call(PredId, ProcId, Args, Builtin, MaybeContext, Name) }.
 
-process_goal(Goal0 - GoalInfo, Goal - GoalInfo) -->
-	{ Goal0 = unify(_, _, _, _, _) },
-	{ Goal = Goal0 }.
-process_goal(Goal0 - GoalInfo, Goal - GoalInfo) -->
+process_goal(CGC, Goal0 - GoalInfo, Goal - GoalInfo) -->
+	{ Goal0 = unify(Var, Rhs, Mode, Unification0, Ctxt) },
+	{ Unification0 = deconstruct(Var, ConsId, Vars, Modes, CanFail, _) ->
+		( list__member(Var, CGC) ->
+			Unification = deconstruct(Var, ConsId, Vars,
+					Modes, CanFail, yes)
+		;
+			Unification = deconstruct(Var, ConsId, Vars,
+					Modes, CanFail, no)
+		),
+		Goal = unify(Var, Rhs, Mode, Unification, Ctxt)
+	;
+		Goal = Goal0
+	}.
+process_goal(_CGC, Goal0 - GoalInfo, Goal - GoalInfo) -->
 	{ Goal0 = generic_call(_, _, _, _) },
 	{ Goal = Goal0 }.
-process_goal(Goal0 - GoalInfo, Goal - GoalInfo) -->
+process_goal(_CGC, Goal0 - GoalInfo, Goal - GoalInfo) -->
 	{ Goal0 = pragma_foreign_code(_, _, _, _, _, _, _, _) },
 	{ Goal = Goal0 }.
-process_goal(Goal0 - _GoalInfo, _) -->
+process_goal(_CGC, Goal0 - _GoalInfo, _) -->
 	{ Goal0 = bi_implication(_, _) },
 	{ error("structure_reuse: bi_implication.\n") }.
 
-process_goal(Goal0 - GoalInfo, Goal - GoalInfo) -->
+process_goal(CGC, Goal0 - GoalInfo, Goal - GoalInfo) -->
 	{ Goal0 = if_then_else(Vars, If0, Then0, Else0, SM) },
-	process_goal(If0, If),
-	process_goal(Then0, Then),
-	process_goal(Else0, Else),
+	process_goal(CGC, If0, If),
+	process_goal(CGC, Then0, Then),
+	process_goal(CGC, Else0, Else),
 	{ Goal = if_then_else(Vars, If, Then, Else, SM) }.
 
-process_goal(Goal0 - GoalInfo, Goal - GoalInfo) -->
+process_goal(CGC, Goal0 - GoalInfo, Goal - GoalInfo) -->
 	{ Goal0 = switch(Var, CanFail, Cases0, StoreMap) },
-	process_goal_cases(Cases0, Cases),
+	process_goal_cases(CGC, Cases0, Cases),
 	{ Goal = switch(Var, CanFail, Cases, StoreMap) }.
 
-process_goal(Goal0 - GoalInfo, Goal - GoalInfo) -->
+process_goal(CGC, Goal0 - GoalInfo, Goal - GoalInfo) -->
 	{ Goal0 = some(Vars, CanRemove, SomeGoal0) },
-	process_goal(SomeGoal0, SomeGoal),
+	process_goal(CGC, SomeGoal0, SomeGoal),
 	{ Goal = some(Vars, CanRemove, SomeGoal) }.
 
-process_goal(not(Goal0) - GoalInfo, not(Goal) - GoalInfo) -->
-	process_goal(Goal0, Goal).
-process_goal(conj(Goal0s) - GoalInfo, conj(Goals) - GoalInfo) -->
-	process_goal_list(Goal0s, Goals).
-process_goal(disj(Goal0s, SM) - GoalInfo, disj(Goals, SM) - GoalInfo) -->
-	process_goal_list(Goal0s, Goals).
-process_goal(par_conj(Goal0s, SM) - GoalInfo,
+process_goal(CGC, not(Goal0) - GoalInfo, not(Goal) - GoalInfo) -->
+	process_goal(CGC, Goal0, Goal).
+process_goal(CGC, conj(Goal0s) - GoalInfo, conj(Goals) - GoalInfo) -->
+	process_goal_list(CGC, Goal0s, Goals).
+process_goal(CGC, disj(Goal0s, SM) - GoalInfo, disj(Goals, SM) - GoalInfo) -->
+	process_goal_list(CGC, Goal0s, Goals).
+process_goal(CGC, par_conj(Goal0s, SM) - GoalInfo,
 		par_conj(Goals, SM) - GoalInfo) -->
-	process_goal_list(Goal0s, Goals).
+	process_goal_list(CGC, Goal0s, Goals).
 
-:- pred process_goal_cases(list(case)::in, list(case)::out,
+:- pred process_goal_cases(prog_vars::in, list(case)::in, list(case)::out,
 		module_info::in, module_info::out) is det.
 
-process_goal_cases([], []) --> [].
-process_goal_cases([Case0 | Case0s], [Case | Cases]) -->
+process_goal_cases(_CGC, [], []) --> [].
+process_goal_cases(CGC, [Case0 | Case0s], [Case | Cases]) -->
 	{ Case0 = case(ConsId, Goal0) },
-	process_goal(Goal0, Goal),
+	process_goal(CGC, Goal0, Goal),
 	{ Case = case(ConsId, Goal) },
-	process_goal_cases(Case0s, Cases).
+	process_goal_cases(CGC, Case0s, Cases).
 
-:- pred process_goal_list(hlds_goals::in, hlds_goals::out,
+:- pred process_goal_list(prog_vars::in, hlds_goals::in, hlds_goals::out,
 		module_info::in, module_info::out) is det.
 
-process_goal_list([], []) --> [].
-process_goal_list([Goal0 | Goal0s], [Goal | Goals]) -->
-	process_goal(Goal0, Goal),
-	process_goal_list(Goal0s, Goals).
+process_goal_list(_CGC, [], []) --> [].
+process_goal_list(CGC, [Goal0 | Goal0s], [Goal | Goals]) -->
+	process_goal(CGC, Goal0, Goal),
+	process_goal_list(CGC, Goal0s, Goals).
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
Index: switch_detection.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/switch_detection.m,v
retrieving revision 1.90
diff -u -r1.90 switch_detection.m
--- switch_detection.m	2000/08/09 07:47:53	1.90
+++ switch_detection.m	2000/09/27 14:49:14
@@ -436,14 +436,14 @@
 		_Result0, Result, _, unit) :-
 	(
 		Goal0 = unify(A, B, C, UnifyInfo0, E) - GoalInfo,
-		UnifyInfo0 = deconstruct(A, Functor, F, G, _)
+		UnifyInfo0 = deconstruct(A, Functor, F, G, _, I)
 	->
 		Result = yes(Functor),
 			% The deconstruction unification now becomes
 			% deterministic, since the test will get
 			% carried out in the switch.
 		UnifyInfo = deconstruct(A, Functor, F, G,
-			cannot_fail),
+			cannot_fail, I),
 		Goals = [unify(A, B, C, UnifyInfo, E) - GoalInfo]
 	;
 		error("find_bind_var_for_switch_in_deconstruct")
@@ -479,7 +479,7 @@
 		(
 			% check whether the unification is a deconstruction
 			% unification on Var or a variable aliased to Var
-			UnifyInfo0 = deconstruct(UnifyVar, _, _, _, _),
+			UnifyInfo0 = deconstruct(UnifyVar, _, _, _, _, _),
 			term__apply_rec_substitution(
 				term__variable(Var),
 				Substitution0, term__variable(Var1)),
Index: term_traversal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/term_traversal.m,v
retrieving revision 1.13
diff -u -r1.13 term_traversal.m
--- term_traversal.m	2000/08/09 07:47:56	1.13
+++ term_traversal.m	2000/09/27 14:49:14
@@ -130,7 +130,7 @@
 			Info = Info0
 		)
 	;
-		Unification = deconstruct(InVar, ConsId, Args, Modes, _),
+		Unification = deconstruct(InVar, ConsId, Args, Modes, _, _),
 		(
 			unify_change(InVar, ConsId, Args, Modes, Params,
 				Gamma0, InVars0, OutVars)
Index: unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.108.2.1
diff -u -r1.108.2.1 unify_gen.m
--- unify_gen.m	2000/09/25 17:05:48	1.108.2.1
+++ unify_gen.m	2000/09/27 14:49:15
@@ -70,7 +70,8 @@
 			{ Code = empty }
 		)
 	;
-		{ Uni = deconstruct(Var, ConsId, Args, Modes, _CanFail) },
+		{ Uni = deconstruct(Var, ConsId, Args, Modes,
+				_CanFail, _CanCGC) },
 		( { CodeModel = model_det } ->
 			unify_gen__generate_det_deconstruction(Var, ConsId,
 				Args, Modes, Code)
Index: unused_args.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unused_args.m,v
retrieving revision 1.67.2.1
diff -u -r1.67.2.1 unused_args.m
--- unused_args.m	2000/09/20 09:24:45	1.67.2.1
+++ unused_args.m	2000/09/27 14:49:16
@@ -455,7 +455,8 @@
 	).
 
 traverse_goal(ModuleInfo,
-		unify(Var1, _, _, deconstruct(_, _, Args, Modes, CanFail), _),
+		unify(Var1, _, _,
+			deconstruct(_, _, Args, Modes, CanFail, _), _),
 		UseInf0, UseInf) :-
 	partition_deconstruct_args(ModuleInfo, Args,
 		Modes, InputVars, OutputVars),
@@ -1353,7 +1354,7 @@
 	\+ list__member(LVar, UnusedVars).
 	
 fixup_unify(ModuleInfo, UnusedVars, Changed, Unify, Unify) :-
-	Unify =	deconstruct(LVar, _, ArgVars, ArgModes, CanFail),
+	Unify =	deconstruct(LVar, _, ArgVars, ArgModes, CanFail, _CanCGC),
 	\+ list__member(LVar, UnusedVars),
 	(
 			% are any of the args unused, if so we need to 	

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list