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

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Aug 23 13:34:06 AEST 2000


On 22-Aug-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> 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.

I have changed the condition.

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

However, this comment is still off base: the code invoked with the modified
globals structure does not use the globals in the I/O state at all. I have
changed the structure of the code slightly to make this clearer, by eliminating
*all* references to the I/O state in that code. The code of the predicate
you quoted from is now the following.

generate_maybe_pred_code(ModuleInfo0, ModuleInfo, GlobalData0, GlobalData,
		PredId, Predicates) -->
	{ module_info_preds(ModuleInfo0, PredInfos) },
		% get the pred_info structure for this predicate
	{ map__lookup(PredInfos, PredId, PredInfo) },
		% extract a list of all the procedure ids for this
		% predicate and generate code for them
	{ pred_info_non_imported_procids(PredInfo, ProcIds) },
	(
		{ ProcIds = []
		; hlds_pred__pred_info_is_aditi_relation(PredInfo)
		}
	->
		{ Predicates = [] },
		{ ModuleInfo = ModuleInfo0 },
		{ GlobalData = GlobalData0 }
	;
		{ module_info_globals(ModuleInfo0, Globals0) },
		{ globals__lookup_bool_option(Globals0, very_verbose,
			VeryVerbose) },
		( { VeryVerbose = yes } ->
			io__write_string("% Generating code for "),
			hlds_out__write_pred_id(ModuleInfo0, PredId),
			io__write_string("\n"),
			{ globals__lookup_bool_option(Globals0,
				statistics, Statistics) },
			maybe_report_stats(Statistics)
		;
			[]
		),
		{
			pred_info_module(PredInfo, PredModule),
			pred_info_name(PredInfo, PredName),
			pred_info_arity(PredInfo, PredArity),
			no_type_info_builtin(PredModule, PredName, PredArity)
		->
				% These predicates should never be traced,
				% since they do not 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.
			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)
		;
			generate_pred_code(ModuleInfo0, ModuleInfo,
				GlobalData0, GlobalData,
				PredId, PredInfo, ProcIds, Predicates)
		}
	).

In mercury_compile.m, which has similar code for compilation by preds,
I will update the I/O state, since eliminating references to it would
complicate the code a lot.

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