[m-dev.] for review: a replacement of code_exprn.m

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Aug 22 01:51:34 AEST 2000


On 06-Aug-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> +++ code_gen.m	2000/07/26 01:56:58
> +		(
> +			{ pred_info_module(PredInfo, PredModule) },
> +			{ mercury_public_builtin_module(PredModule)
> +			; mercury_private_builtin_module(PredModule)
> +			}
> +		->
> +				% Procedures defined in the builtin modules
> +				% should never be traced, since they do not
> +				% have to obey typeinfo_liveness. Since they
> +				% may be opt_imported into other modules, we
> +				% must switch off the tracing of such preds
> +				% on a pred-by-pred basis.
> +			{ module_info_globals(ModuleInfo0, Globals0) },
> +			{ globals__get_trace_level(Globals0, TraceLevel) },
> +			{ globals__set_trace_level(Globals0, none, Globals1) },
> +			{ module_info_set_globals(ModuleInfo0, Globals1,
> +				ModuleInfo1) },
> +			generate_pred_code(ModuleInfo1, ModuleInfo2,
> +				GlobalData0, GlobalData,
> +				PredId, PredInfo, ProcIds, Predicates),
> +			{ module_info_globals(ModuleInfo2, Globals2) },
> +			{ globals__set_trace_level(Globals2, TraceLevel,
> +				Globals) },
> +			{ module_info_set_globals(ModuleInfo2, Globals,
> +				ModuleInfo) }

I don't think this is the best way of handling that problem.

First, the condition that you're checking here is not really
the right one.  The condition that the code really cares about
is whether the predicate is a "no-type-info builtin", i.e.
a polymorphic predicate which does not get passed type-infos.
This is not necessarily related to which module the predicate
occurs in.  So rather than just checking the module name, you should
use the `no_type_info_builtin' predicate from hlds_pred.m.

Second, as discussed earlier I think you should set the globals
in the io__state too, rather than just in the module_info.

>  generate_pred_code(ModuleInfo0, ModuleInfo, GlobalData0, GlobalData,
>  		PredId, PredInfo, ProcIds, Code) -->
> -	globals__io_lookup_bool_option(very_verbose, VeryVerbose),
> +	{ module_info_globals(ModuleInfo0, Globals) },
> +	{ globals__lookup_bool_option(Globals, very_verbose, VeryVerbose) },

... and then changes like this one would not be necessary.
Note that this change makes the code more verbose and as a
result, a little less maintainable.

[... to be continued ...]

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list