[m-rev.] for review: exists_casts

Mark Brown mark at cs.mu.OZ.AU
Fri Aug 12 15:10:58 AEST 2005


On 12-Aug-2005, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 12-Aug-2005, Mark Brown <mark at cs.mu.OZ.AU> wrote:
> > +			% Update the rtti_varmaps.
> > +			% XXX need to do this
> > +		true
> 
> Is that XXX intended to be fixed in another change, or this one?

I was intending to check before posting for review whether it was needed
for this change.  It isn't, but it will be needed for an upcoming change
which includes more complete information in the rtti_varmaps.  I'll fix
this part then.

The relative diff addressing this and the other points is below.

Cheers,
Mark.

diff -u compiler/hlds_goal.m compiler/hlds_goal.m
--- compiler/hlds_goal.m	5 Aug 2005 08:46:12 -0000
+++ compiler/hlds_goal.m	12 Aug 2005 04:53:32 -0000
@@ -398,17 +398,19 @@
 			% An unsafe type and inst cast.
 
 	;	equiv_type_cast
-			% A safe type cast between equivalent types.
+			% A safe type cast between equivalent types, in
+			% either direction.
 
 	;	exists_cast.
 			% A safe cast between an internal type_info or
 			% typeclass_info variable, for which the bindings of
-			% existential type variables are known, to an external
-			% type_info or typeclass_info head variable, for which
-			% they are not.  These are used instead of assignments
-			% so that the simplification pass does not attempt to
-			% merge the two variables, which could lead to
-			% inconsistencies in the rtti_varmaps.
+			% existential type variables are known statically, to
+			% an external type_info or typeclass_info head
+			% variable, for which they are not.  These are used
+			% instead of assignments so that the simplification
+			% pass does not attempt to merge the two variables,
+			% which could lead to inconsistencies in the
+			% rtti_varmaps.
 
 	% Get a description of a generic_call goal.
 	%
diff -u compiler/polymorphism.m compiler/polymorphism.m
--- compiler/polymorphism.m	11 Aug 2005 15:15:51 -0000
+++ compiler/polymorphism.m	12 Aug 2005 05:05:07 -0000
@@ -580,9 +580,9 @@
 	),
 
 	% Add exists_casts for any head vars which are existentially typed,
-	% and for which the type is bound inside the procedure.  The tsubst
-	% that we pass in represents which existential types are bound.
-	introduce_exists_casts_head(ModuleInfo, Subn, OrigArgTypes,
+	% and for which the type is bound inside the procedure.  Subn
+	% represents which existential types are bound.
+	introduce_exists_casts_for_head(ModuleInfo, Subn, OrigArgTypes,
 		OrigArgModes, OrigHeadVars1, OrigHeadVars, VarSet0, VarSet1,
 		VarTypes0, VarTypes1, [], ExistsCastHeadGoals),
 
@@ -595,24 +595,22 @@
 
 	Body0 = _ - GoalInfo0,
 	goal_to_conj_list(Body0, Goals0),
-	list__append(ExistsCastHeadGoals, ExistsCastExtraGoals,
-		ExistsCastGoals),
-	list__append(Goals0, ExistsCastGoals, Goals),
-	list__append(ExtraHeadVars, OrigHeadVars, HeadVars),
+	Goals = Goals0 ++ ExistsCastHeadGoals ++ ExistsCastExtraGoals,
+	HeadVars = ExtraHeadVars ++ OrigHeadVars,
 	set__list_to_set(HeadVars, NonLocals),
 	goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo),
 	Body = conj(Goals) - GoalInfo,
 	proc_info_set_body(VarSet, VarTypes, HeadVars, Body, RttiVarMaps,
 		!ProcInfo).
 
-:- pred introduce_exists_casts_head(module_info::in, tsubst::in,
+:- pred introduce_exists_casts_for_head(module_info::in, tsubst::in,
 	list(type)::in, list(mode)::in, list(prog_var)::in,
 	list(prog_var)::out, prog_varset::in, prog_varset::out,
 	vartypes::in, vartypes::out, list(hlds_goal)::in, list(hlds_goal)::out)
 	is det.
 
-introduce_exists_casts_head(ModuleInfo, Subn, ArgTypes, ArgModes, !HeadVars,
-		!VarSet, !VarTypes, !ExtraGoals) :-
+introduce_exists_casts_for_head(ModuleInfo, Subn, ArgTypes, ArgModes,
+		!HeadVars, !VarSet, !VarTypes, !ExtraGoals) :-
 	(
 		ArgTypes = [],
 		ArgModes = [],
@@ -624,24 +622,24 @@
 		ArgModes = [ArgMode | ArgModesRest],
 		!.HeadVars = [HeadVar0 | HeadVarsRest0]
 	->
-		introduce_exists_casts_head(ModuleInfo, Subn, ArgTypesRest,
+		introduce_exists_casts_for_head(ModuleInfo, Subn, ArgTypesRest,
 			ArgModesRest, HeadVarsRest0, HeadVarsRest, !VarSet,
 			!VarTypes, !ExtraGoals),
-		introduce_exists_casts_head_2(ModuleInfo, Subn, ArgType,
+		introduce_exists_casts_for_arg(ModuleInfo, Subn, ArgType,
 			ArgMode, HeadVar0, HeadVar, !VarSet, !VarTypes,
 			!ExtraGoals),
 		!:HeadVars = [HeadVar | HeadVarsRest]
 	;
 		unexpected(this_file,
-			"introduce_exists_casts_head: length mismatch")
+			"introduce_exists_casts_for_head: length mismatch")
 	).
 
-:- pred introduce_exists_casts_head_2(module_info::in, tsubst::in,
+:- pred introduce_exists_casts_for_arg(module_info::in, tsubst::in,
 	(type)::in, (mode)::in, prog_var::in, prog_var::out,
 	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out,
 	list(hlds_goal)::in, list(hlds_goal)::out) is det.
 
-introduce_exists_casts_head_2(ModuleInfo, Subn, ExternalType, ArgMode,
+introduce_exists_casts_for_arg(ModuleInfo, Subn, ExternalType, ArgMode,
 		HeadVar0, HeadVar, !VarSet, !VarTypes, !ExtraGoals) :-
 	term__apply_rec_substitution(ExternalType, Subn, InternalType),
 	(
@@ -696,11 +694,11 @@
 		make_new_exist_cast_var(Var0, Var, !VarSet),
 		svmap__det_insert(Var, ExternalType, !VarTypes),
 		generate_cast(exists_cast, Var0, Var, Context, ExtraGoal),
-		ExtraGoals = [ExtraGoal | ExtraGoals0],
-	
-			% Update the rtti_varmaps.
-			% XXX need to do this
-		true
+		ExtraGoals = [ExtraGoal | ExtraGoals0]
+
+			% XXX when rtti_varmaps includes information about
+			% the external view of type_infos and typeclass_infos,
+			% it will need to be updated here.
 	;
 		Var = Var0,
 		ExtraGoals = ExtraGoals0
--------------------------------------------------------------------------
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