[m-rev.] for review:

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Jul 31 12:41:00 AEST 2006


On Fri, 28 Jul 2006, Zoltan Somogyi wrote:

> Implement the trace goal construct for the hlc grades.
>
> compiler/mlds.m:
> 	Extend the MLDS in a similar way to how the previous diff extended
> 	the LLDS. This means extending lvals to allow references to global
> 	variables representing the initial snapshots of environment variables,
> 	and recording the set of environment variables referred to by each
> 	definition.
>
> compiler/mlds_to_c.m:
> 	Handle the extensions to the MLDS.
>
> compiler/llds_out.m:
> util/mkinit.c:
> 	Note that mlds_to_c.m now also depends on the naming scheme for the
> 	global variables representing environment variables.
>
> compiler/ml_code_gen.m:
> 	When generating code for a procedure, remember the set of environment
> 	variables it refers to.
>
> 	When generating code for the special form of call_foreign_proc created
> 	by the transformation of trace goals with runtime conditions by
> 	simplify.m, generate the appropriate boolean expression involving
> 	references to environment variables.
>
> compiler/ml_code_util.m:
> 	Provide storage space for recording the set of environment variables
> 	used in functions.
>
> compiler/mlds_to_il.m:
> compiler/mlds_to_gcc.m:
> compiler/mlds_to_java.m:
> compiler/mlds_to_managed.m:
> 	Abort if asked to translate functions that include references to
> 	environment variables, since this is preferable to silently doing
> 	the wrong thing.
>
> compiler/*.m:
> 	Misc changes required to conform to the change to the MLDS.
>

...

> Index: compiler/ml_code_gen.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_code_gen.m,v
> retrieving revision 1.181
> diff -u -b -r1.181 ml_code_gen.m
> --- compiler/ml_code_gen.m	28 Jul 2006 05:08:10 -0000	1.181
> +++ compiler/ml_code_gen.m	28 Jul 2006 07:16:25 -0000
> @@ -1426,7 +1426,8 @@
>             Decls = list.append(MLDS_LocalVars, Decls0),
>             Statement = ml_gen_block(Decls, Statements, Context),
>             FunctionBody = body_defined_here(Statement)
> -        )
> +        ),
> +        ml_gen_info_get_env_vars(!.Info, EnvVarNames)
>     ),
>
>     pred_info_get_attributes(PredInfo, Attributes),
> @@ -1435,7 +1436,7 @@
>     MLDS_Attributes = attributes_to_mlds_attributes(ModuleInfo, AttributeList),
>
>     ProcDefnBody = mlds_function(yes(proc(PredId, ProcId)), MLDS_Params,
> -        FunctionBody, MLDS_Attributes).
> +        FunctionBody, MLDS_Attributes, EnvVarNames).
>
>     % For model_det and model_semi procedures, figure out which output
>     % variables are returned by value (rather than being passed by reference)
> @@ -2231,8 +2232,6 @@
> ml_gen_goal_expr(call_foreign_proc(Attributes, PredId, ProcId, Args, ExtraArgs,
>         MaybeTraceRuntimeCond, PragmaImpl), CodeModel, OuterContext,
>         Decls, Statements, !Info) :-
> -    require(unify(MaybeTraceRuntimeCond, no),
> -        "ml_gen_goal_expr: MaybeTraceRuntimeCond NYI"),
>     (
>         PragmaImpl = fc_impl_ordinary(ForeignCode, MaybeContext),
>         (
> @@ -2241,15 +2240,24 @@
>             MaybeContext = no,
>             Context = OuterContext
>         ),
> +        (
> +            MaybeTraceRuntimeCond = no,
>         ml_gen_ordinary_pragma_foreign_proc(CodeModel, Attributes,
>             PredId, ProcId, Args, ExtraArgs, ForeignCode,
>             Context, Decls, Statements, !Info)
>     ;
> +            MaybeTraceRuntimeCond = yes(TraceRuntimeCond),
> +            ml_gen_trace_runtime_cond(TraceRuntimeCond, Context,
> +                Decls, Statements, !Info)
> +        )
> +    ;
>         PragmaImpl = fc_impl_model_non(LocalVarsDecls, LocalVarsContext,
>             FirstCode, FirstContext, LaterCode, LaterContext,
>             _Treatment, SharedCode, SharedContext),
>         expect(unify(ExtraArgs, []), this_file,
>             "ml_gen_goal_expr: extra args"),
> +        require(unify(MaybeTraceRuntimeCond, no),
> +            "ml_gen_goal_expr: MaybeTraceRuntimeCond"),

You should call expect/3 rather than require/2 here.

> @@ -2259,6 +2267,8 @@
>         PragmaImpl = fc_impl_import(Name, HandleReturn, Vars, _Context),
>         expect(unify(ExtraArgs, []), this_file,
>             "ml_gen_goal_expr: extra args"),
> +        require(unify(MaybeTraceRuntimeCond, no),
> +            "ml_gen_goal_expr: MaybeTraceRuntimeCond"),

And here.

...

> Index: compiler/mlds.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds.m,v
> retrieving revision 1.135
> diff -u -b -r1.135 mlds.m
> --- compiler/mlds.m	28 Jul 2006 05:08:12 -0000	1.135
> +++ compiler/mlds.m	28 Jul 2006 06:47:20 -0000
> @@ -347,6 +347,7 @@
> :- import_module map.
> :- import_module maybe.
> :- import_module pair.
> +:- import_module set.
>
> %-----------------------------------------------------------------------------%
>
> @@ -570,7 +571,9 @@
>                                         % Mercury procedure, if any.
>                 mlds_func_params,      % The arguments & return types.
>                 mlds_function_body,    % The function body.
> -                list(mlds_attribute)   % Attributes.
> +                list(mlds_attribute),   % Attributes.
> +                set(string)             % The set of environment variables
> +                                        % referred to by the function body.
>             )
>     ;       mlds_class(
>                 % Represents packages, classes, interfaces, structs, enums.
> @@ -1476,6 +1479,14 @@
>                 mlds_type
>             )
>
> +    ;       global_var_ref(
> +                % A reference to the value of the C global variable with the
> +                % given name. At least for now, the global variable's type
> +                % must be MR_Word.
> +

s/C/target language/ in the above.

s/MR_Word/mlds_generic_type/

Add: XXX this is currently only supported for the C backends.

The rest of that looks okay.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list