[m-rev.] for review: LLDS code gen change for AGC

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 13 20:51:12 AEDT 2003


On 07-Nov-2003, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 07-Nov-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > compiler/unify_gen.m:
> > compiler/code_info.m:
> > compiler/var_locn.m:
> > 	When allocating type_infos or typeclass_infos on the heap,
> > 	if accurate garbage collection is enabled then ensure that we
> > 	reserve a word before the start of the object.
> 
> The diff you posted does not use quite the right approach, because your
> modification makes the code generator believe that term size profiling
> and agc are independent, when in fact both want to reserve an extra word
> at offset -1.
...
> The right fix is best discussed in person.

We discussed this in person.  Although term size profiling and agc both
want to reserve an extra word at offset -1, there are some significant
differences: (1) term size profiling wants this word initialized, agc
doesn't, and (2) term size profiling always adds the word, agc only adds
it for structures on the heap, not structures allocated statically.
Trying to use the same mechanism for both, although initially attractive,
doesn't work out so well.

The solution agreed on was therefore to leave the code as is, but to add
some comments to make it a bit clearer.  Hence the following patch.

----------

Estimated hours taken: 1
Branches: main

compiler/code_info.m:
compiler/var_locn.m:
	Add some comments, to address Zoltan's review comments on my
	previous change.

Workspace: /home/jupiter/fjh/ws-jupiter/mercury
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.282
diff -u -d -r1.282 code_info.m
--- compiler/code_info.m	6 Nov 2003 20:14:27 -0000	1.282
+++ compiler/code_info.m	13 Nov 2003 05:23:58 -0000
@@ -3000,6 +3000,9 @@
 
 	% Submodule to deal with var_locn.
 
+	% Most of these procedures just forward to the var_locn module.
+	% See var_locn for documentation.
+
 :- interface.
 
 :- pred code_info__variable_locations(code_info::in,
@@ -3021,7 +3024,7 @@
 	code_info::in, code_info::out) is det.
 
 	% code_info__assign_cell_to_var(Var, ReserveWordAtStart, Ptag, Vector,
-	% 	Size, TypeMsg, Code, !CI)
+	% 	Size, TypeMsg, Code, !CI):
 :- pred code_info__assign_cell_to_var(prog_var::in, bool::in, tag::in,
 	list(maybe(rval))::in, maybe(term_size_value)::in, string::in,
 	code_tree::out, code_info::in, code_info::out) is det.
Index: compiler/var_locn.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/var_locn.m,v
retrieving revision 1.13
diff -u -d -r1.13 var_locn.m
--- compiler/var_locn.m	6 Nov 2003 20:14:28 -0000	1.13
+++ compiler/var_locn.m	13 Nov 2003 05:23:15 -0000
@@ -152,8 +152,8 @@
 	var_locn_info::in, var_locn_info::out) is det.
 
 %	var_locn__assign_cell_to_var(Var, ReserveWordAtStart, Ptag, Vector,
-%			TypeMsg, Code, StaticCellInfo0, StaticCellInfo,
-%			VarLocnInfo0, VarLocnInfo)
+%			SizeInfo, TypeMsg, Code, !StaticCellInfo,
+%			!VarLocnInfo)
 %		Generates code to assign to Var a pointer, tagged by Ptag, to
 %		the cell whose contents are given by the other arguments,
 %		and updates the state of VarLocnInfo0 accordingly.
@@ -161,6 +161,13 @@
 %		the heap (rather than statically), then reserve an extra
 %		word immediately before the allocated object, for the
 %		garbage collector to use to hold a forwarding pointer.
+%		If SizeInfo is yes(SizeVal), then reserve an extra word
+%		immediately before the allocated object (regardless
+%		of whether it is allocated statically or dynamically),
+%		and initialize this word with the value determined by
+%		SizeVal.
+%		NOTE: ReserveWordAtStart and SizeInfo should not both be
+%		yes / yes(_), because that will cause an obvious conflict!
 
 :- pred var_locn__assign_cell_to_var(prog_var::in, bool::in, tag::in,
 	list(maybe(rval))::in, maybe(term_size_value)::in, string::in,

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