[m-rev.] accurate GC for type class methods

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Sep 25 17:12:39 AEST 2003


On 20-Aug-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Implement accurate GC for type class methods.
> Accurate GC now supports the whole Mercury language.

Testing that change uncovered a few bugs, which I fixed with the following
relative diff.  I will go ahead and commit this now.

--- CVS_LOG_MESSAGE.old	Wed Aug 20 22:31:09 2003
+++ CVS_LOG_MESSAGE	Thu Sep 25 17:06:26 2003
@@ -29,8 +29,15 @@
 	This is similar to MR_materialize_closure_params() except that
 	it works on a typeclass_info rather than an MR_Closure.
 
+compiler/ml_code_util.m:
+	Change ml_bump_function_labels so that it also bumps the constant
+	sequence number, and rename it as ml_bump_counters.  This is needed
+	to avoid clashes between different local closure_layout constants
+	after they get hoisted to the top level by ml_elim_nested.m.
+
 compiler/rtti_to_mlds.m:
-	Update to reflect the changed interface to ml_gen_closure_wrapper.
+	Update to reflect the changed interface to ml_gen_closure_wrapper
+	and ml_code_util.m.
 
 compiler/ml_elim_nested.m:

diff -u compiler/ml_closure_gen.m compiler/ml_closure_gen.m
--- compiler/ml_closure_gen.m	20 Aug 2003 11:49:57 -0000
+++ compiler/ml_closure_gen.m	25 Sep 2003 02:58:31 -0000
@@ -1142,7 +1142,7 @@
 			target_code_output(ClosureLayoutPtrLval),
 			raw_target_code(" = (MR_Box) ((MR_Closure *)\n", []),
 			target_code_input(lval(ClosureArgLval)),
-			raw_target_code("->MR_closure_layout);\n", [])
+			raw_target_code(")->MR_closure_layout;\n", [])
 		] },
 		{ ClosureLayoutPtrGCInit = mlds__statement(atomic(
 			inline_target_code(lang_C,
diff -u compiler/rtti_to_mlds.m compiler/rtti_to_mlds.m
--- compiler/rtti_to_mlds.m	20 Aug 2003 08:08:54 -0000
+++ compiler/rtti_to_mlds.m	25 Sep 2003 05:53:08 -0000
@@ -994,7 +994,7 @@
 	% We start off by creating a fresh MLGenInfo here,
 	% using the pred_id and proc_id of the wrapped procedure.
 	% This requires considerable care.  We need to call
-	% ml_gen_info_bump_func_label to ensure that the
+	% ml_gen_info_bump_counters to ensure that the
 	% function label allocated for the wrapper func
 	% does not overlap with any function labels used
 	% when generating code for the wrapped procedure.
@@ -1002,7 +1002,7 @@
 	PredId = RttiProcId ^ pred_id,
 	ProcId = RttiProcId ^ proc_id,
 	MLGenInfo0 = ml_gen_info_init(ModuleInfo, PredId, ProcId),
-	ml_gen_info_bump_func_label(MLGenInfo0, MLGenInfo1),
+	ml_gen_info_bump_counters(MLGenInfo0, MLGenInfo1),
 
 	%
 	% Now we can safely go ahead and generate the wrapper function
diff -u runtime/mercury_layout_util.c runtime/mercury_layout_util.c
--- runtime/mercury_layout_util.c	20 Aug 2003 10:14:32 -0000
+++ runtime/mercury_layout_util.c	25 Sep 2003 02:58:44 -0000
@@ -156,7 +156,7 @@
 }
 
 MR_TypeInfoParams
-MR_materialize_typeclass_info_params(MR_Word typeclass_info,
+MR_materialize_typeclass_info_type_params(MR_Word typeclass_info,
 	MR_Closure_Layout *closure_layout)
 {
 	const MR_Type_Param_Locns *tvar_locns;
only in patch2:
--- compiler/ml_code_util.m	27 May 2003 05:57:14 -0000	1.72
+++ compiler/ml_code_util.m	25 Sep 2003 05:55:43 -0000
@@ -659,15 +659,15 @@
 :- pred ml_gen_info_new_func_label(ml_label_func, ml_gen_info, ml_gen_info).
 :- mode ml_gen_info_new_func_label(out, in, out) is det.
 
-	% Increase the function label counter by some
-	% amount which is presumed to be sufficient
+	% Increase the function label and const sequence number counters
+	% by some amount which is presumed to be sufficient
 	% to ensure that if we start again with a fresh
 	% ml_gen_info and then call this function,
-	% we won't encounter any already-used function labels.
+	% we won't encounter any already-used function labels or constants.
 	% (This is used when generating wrapper functions
 	% for type class methods.)
-:- pred ml_gen_info_bump_func_label(ml_gen_info, ml_gen_info).
-:- mode ml_gen_info_bump_func_label(in, out) is det.
+:- pred ml_gen_info_bump_counters(ml_gen_info, ml_gen_info).
+:- mode ml_gen_info_bump_counters(in, out) is det.
 
 	% Generate a new commit label number.
 	% This is used to give unique names to the labels
@@ -698,7 +698,8 @@
 
 	% Generate a new `const' sequence number.
 	% This is used to give unique names to the local constants
-	% generated for --static-ground-terms.
+	% generated for --static-ground-terms, closure layouts,
+	% string switch hash tables, etc.
 :- type const_seq == int.
 :- pred ml_gen_info_new_const(const_seq,
 		ml_gen_info, ml_gen_info).
@@ -2708,8 +2709,9 @@
 ml_gen_info_new_func_label(Label, Info, Info^func_label := Label) :-
 	Label = Info^func_label + 1.
 
-ml_gen_info_bump_func_label(Info,
-	Info^func_label := Info^func_label + 10000).
+ml_gen_info_bump_counters(Info,
+	(Info^func_label := Info^func_label + 10000)
+	     ^const_num := Info^const_num + 10000).
 
 ml_gen_info_new_commit_label(CommitLabel, Info,
 		Info^commit_label := CommitLabel) :-

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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