[m-rev.] for review: refactor mlds_to_il.m

Peter Ross peter.ross at miscrit.be
Wed Jul 11 20:33:05 AEST 2001


On Wed, Jul 11, 2001 at 07:07:48PM +1000, Fergus Henderson wrote:
> On 09-Jul-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > On 10-Jul-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > > On 09-Jul-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > > > 
> > > > Refactor the top level of mlds_to_il so that we only do one pass over
> > > > the MLDS to generate the ILDS.  As a side effect of this change nondet
> > > > code now works again.
> > > 
> > > Ah, fantastic.
> > > 
> > > > compiler/ml_code_util.m:
> > > >     Wrapper functions should be static methods not instance methods.
> > > >     Fix ml_gen_label_func_decl_flags to make this true.
> > > ...
> > > >  ml_gen_label_func_decl_flags = MLDS_DeclFlags :-
> > > >  	Access = private,  % XXX if we're using nested functions,
> > > >  			   % this should be `local' rather than `private'
> > > > -	PerInstance = per_instance,
> > > > +	PerInstance = one_copy,
> > > 
> > > Can you explain in more detail why this is necessary?
> > > I don't think this is the right fix.
> > > 
> > > "label" functions are the nested functions used as continuation labels
> > > for nondeterministic code.  They not "wrapper" functions.
> > > 
> > > Marking nested functions as "one_copy" is wrong,
> > > and will break the --gcc-nested-functions option.
> > 
> > This code is *also* called to generate wrapper functions.
> > 
> > I suspect for the case of continuations they are made one_copy when
> > ml_elim_nested processes them. 
> > 
> > But for wrapper functions they are not.
> > 
> > Perhaps ml_gen_label_func_decl_flags shouldn't be re-used in the case
> > of wrapper functions?
> 
> OK, that sounds good to me.
> 


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


Estimated hours taken: 0.5
Branches: main

compiler/ml_code_util.m:
    Back out the change to make ml_gen_label_func_decl_flags be
    one_copy.

compiler/ml_unify_gen.m:
    Define a new function ml_gen_wrapper_func for generating wrapper
    functions. This function calls ml_gen_label_func but overrides the
    per_instance flag to be one_copy.

Index: ml_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.40
diff -u -r1.40 ml_code_util.m
--- ml_code_util.m	9 Jul 2001 15:55:03 -0000	1.40
+++ ml_code_util.m	11 Jul 2001 10:17:41 -0000
@@ -933,7 +933,7 @@
 ml_gen_label_func_decl_flags = MLDS_DeclFlags :-
 	Access = private,  % XXX if we're using nested functions,
 			   % this should be `local' rather than `private'
-	PerInstance = one_copy,
+	PerInstance = per_instance,
 	Virtuality = non_virtual,
 	Finality = overridable,
 	Constness = modifiable,
Index: ml_unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.37
diff -u -r1.37 ml_unify_gen.m
--- ml_unify_gen.m	8 Jul 2001 15:27:27 -0000	1.37
+++ ml_unify_gen.m	11 Jul 2001 10:17:42 -0000
@@ -746,10 +746,20 @@
 	{ WrapperFuncBody = ml_gen_block(Decls, Statements, Context) },
 	ml_gen_new_func_label(yes(WrapperParams), WrapperFuncName,
 		WrapperFuncRval),
-	ml_gen_label_func(WrapperFuncName, WrapperParams, Context,
+	ml_gen_wrapper_func(WrapperFuncName, WrapperParams, Context,
 		WrapperFuncBody, WrapperFunc),
 	{ WrapperFuncType = mlds__func_type(WrapperParams) },
 	ml_gen_info_add_extra_defn(WrapperFunc).
+
+:- pred ml_gen_wrapper_func(ml_label_func, mlds__func_params, prog_context,
+		mlds__statement, mlds__defn, ml_gen_info, ml_gen_info).
+:- mode ml_gen_wrapper_func(in, in, in, in, out, in, out) is det.
+
+ml_gen_wrapper_func(FuncLabel, FuncParams, Context, Statement, Func) -->
+	ml_gen_label_func(FuncLabel, FuncParams, Context, Statement, Func0),
+	{ Func0 = mlds__defn(Name, Ctxt, DeclFlags, Defn) },
+	{ Func = mlds__defn(Name, Ctxt, set_per_instance(DeclFlags, one_copy),
+			Defn) }.
 
 :- func ml_gen_wrapper_head_var_names(int, int) = list(mlds__var_name).
 ml_gen_wrapper_head_var_names(Num, Max) = Names :-

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