[m-rev.] accurate GC & --nondet-copy-out

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Mar 4 01:10:33 AEDT 2003


Estimated hours taken: 2
Branches: main

Support `--gc accurate --nondet-copy-out'.

compiler/ml_call_gen.m:
	Fix an XXX: change ml_gen_cont_params so that rather than
	aborting if accurate GC is enabled, we just document that it is
	the caller's responsibility to fill in the maybe_gc_trace_code
	if needed.

compiler/ml_call_gen.m:
compiler/ml_code_util.m:
	Document why it is safe to not bother filling in the
	maybe_gc_trace_code after calls to ml_gen_cont_params.

compiler/handle_options.m:
	Don't abort if --gc accurate and --nondet-copy-out are both enabled.
	Also, update some of the comments.

compiler/ml_elim_nested.m:
	Delete `--nondet-copy-out' from the TODO list for accurate GC.

Workspace: /home/earth/fjh/ws-earth2/mercury
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.175
diff -u -d -r1.175 handle_options.m
--- compiler/handle_options.m	21 Feb 2003 05:13:25 -0000	1.175
+++ compiler/handle_options.m	28 Feb 2003 15:25:15 -0000
@@ -336,17 +336,26 @@
 	%	  representation (`object[]') for all data types,
 	%	  which is required to avoid type errors for code using
 	%	  abstract data types.
-	%	  XXX It should not be needed once we have a general solution
-	%	  to the abstract equivalence type problem.
+	%	  XXX It should not be needed now that we have a general
+	%	  solution to the abstract equivalence type problem
+	%	  (intermodule optimization).
+	%	  But currently it is still needed, otherwise
+	%         RTTI (e.g. construct, deconstruct) doesn't work
+	%	  for these types.
+	%   - XXX it should also imply num_reserved_addresses = 1
+	%     (we can use null pointers), but currently it doesn't,
+	%     again because this causes problems with RTTI
 	%   - no static ground terms
 	%         XXX Previously static ground terms used to not work with
 	%             --high-level-data.  But this has been (mostly?) fixed now.
 	%             So we should investigate re-enabling static ground terms.
+	%	      Currently mlds_to_il.m doesn't support them yet?
 	%   - intermodule optimization
 	%	  This is only required for high-level data and is needed
 	%	  so that abstract equivalence types can be expanded.  They
 	%	  need to be expanded because .NET requires that the structural
 	%	  representation of a type is known at all times.
+
 	( { Target = il } ->
 		globals__io_set_gc_method(none),
 		globals__io_set_option(reclaim_heap_on_nondet_failure,
@@ -359,6 +368,7 @@
 		globals__io_set_option(num_tag_bits, int(0)),
 		globals__io_set_option(unboxed_enums, bool(no)),
 		globals__io_set_option(unboxed_no_tag_types, bool(no)),
+		% globals__io_set_option(num_reserved_addresses, int(1))
 		globals__io_set_option(static_ground_terms, bool(no)),
 
 		( { HighLevelData = yes, AutoIntermodOptimization = yes } ->
@@ -861,19 +871,6 @@
 	->
 		usage_error("--gc accurate is incompatible with " ++
 			"--put-nondet-env-on-heap")
-	;
-		[]
-	),
-	% ml_gen_cont_params in ml_call_gen.m will call sorry/1
-	% if --gc accurate and --nondet-copy-out are both enabled.
-	globals__io_lookup_bool_option(nondet_copy_out, NondetCopyOut),
-	(
-		{ HighLevel = yes },
-		{ GC_Method = accurate },
-		{ NondetCopyOut = yes }
-	->
-		usage_error("--gc accurate is incompatible with " ++
-			"--nondet-copy-out")
 	;
 		[]
 	),
Index: compiler/ml_call_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_call_gen.m,v
retrieving revision 1.38
diff -u -d -r1.38 ml_call_gen.m
--- compiler/ml_call_gen.m	14 Feb 2003 09:59:21 -0000	1.38
+++ compiler/ml_call_gen.m	28 Feb 2003 15:21:23 -0000
@@ -103,6 +103,10 @@
         % Generate the appropriate MLDS type for a continuation function
         % for a nondet procedure whose output arguments have the
         % specified types.
+	%
+	% WARNING: this does not fill in the maybe_gc_trace_code for the
+	% function parameters.  It is the caller's responsibility to fill
+	% these in properly if needed.
         %
 :- pred ml_gen_cont_params(list(mlds__type), mlds__func_params,
 		ml_gen_info, ml_gen_info).
@@ -507,7 +511,13 @@
 		% 
 		% Create a new continuation function
 		% that just copies the outputs to locals
-		% and then calls the original current continuation
+		% and then calls the original current continuation.
+		%
+		% Note that ml_gen_cont_params does not fill in the
+		% maybe_gc_trace_code for the parameters.  This is OK,
+		% because the parameters of the continuation function
+		% will not be live across any heap allocations or
+		% procedure calls.
 		%
 		ml_gen_cont_params(OutputArgTypes, Params),
 		ml_gen_new_func_label(yes(Params),
@@ -547,20 +557,12 @@
 ml_gen_cont_params_2([], _, []) --> [].
 ml_gen_cont_params_2([Type | Types], ArgNum, [Argument | Arguments]) -->
 	{ ArgName = ml_gen_arg_name(ArgNum) },
-	% XXX Figuring out the correct GC code here is difficult,
+	% Figuring out the correct GC code here is difficult,
 	% since doing that requires knowing the HLDS types, but
-	% here we only have the MLDS types.
-	% Fortunately this code should only get executed
-	% if --nondet-copy-out is enabled, which is not normally
-	% the case when --gc accurate is enabled, so handling this
-	% is not very important.
-	ml_gen_info_get_globals(Globals),
-	{ globals__get_gc_method(Globals, GC) },
-	( { GC = accurate } ->
-		{ sorry(this_file, "--gc accurate & --nondet-copy-out") }
-	;
-		{ Maybe_GC_TraceCode = no }
-	),
+	% here we only have the MLDS types.  So here we just
+	% leave it blank.  The caller of ml_gen_cont_param has the
+	% reponsibility of fillling this in properly if needed.
+	{ Maybe_GC_TraceCode = no },
 	{ Argument = mlds__argument(data(var(ArgName)), Type,
 		Maybe_GC_TraceCode) },
 	ml_gen_cont_params_2(Types, ArgNum + 1, Arguments).
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.68
diff -u -d -r1.68 ml_code_util.m
--- compiler/ml_code_util.m	28 Feb 2003 06:40:42 -0000	1.68
+++ compiler/ml_code_util.m	28 Feb 2003 15:11:10 -0000
@@ -1976,6 +1976,13 @@
 		% All we do is change the call rvals to be the input
 		% variables, and the func rval to be the input variable
 		% for the continuation.
+		%
+		% Note that ml_gen_cont_params does not fill in the
+		% gc_trace_code for the parameters.  This is OK, because
+		% the parameters will not be used again after the call.
+		% (Also currently this is only used for IL, for which GC
+		% is the .NET CLR implementation's problem, not ours.)
+		% 
 	ml_gen_cont_params(ArgTypes0, InnerFuncParams0),
 	{ InnerFuncParams0 = func_params(InnerArgs0, Rets) },
 	{ InnerArgRvals = list__map(
Index: compiler/ml_elim_nested.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_elim_nested.m,v
retrieving revision 1.59
diff -u -d -r1.59 ml_elim_nested.m
--- compiler/ml_elim_nested.m	21 Jun 2002 13:26:40 -0000	1.59
+++ compiler/ml_elim_nested.m	28 Feb 2003 15:33:07 -0000
@@ -170,7 +170,6 @@
 %	- support type classes: currently we generate code for type class
 %	  method wrappers which calls MR_materialize_closure_type_params(),
 %	  which only works for closures, not for typeclass_infos.
-%	- support --nondet-copy-out (see comment in flatten_nested_defn)
 %	- support --high-level-data (fixup_newobj_in_atomic_statement
 %	  gets the types wrong; see comment in ml_code_util.m)
 %

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