[m-dev.] diff: fix bug with nested modules & intermod opt

David Glen JEFFERY dgj at cs.mu.OZ.AU
Mon Nov 2 19:03:36 AEDT 1998


On 02-Nov-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> As usual, if anyone wants to review this one, please go ahead...
> 
> --------------------
> 
> Estimated hours taken: 20
> 
> Fix a bug with intermodule optimization of nested modules.
> 
> Previously, the compiler used to just label any
> predicates defined in a module containing sub-modules
> as `exported', since they may be needed by the separately-compiled
> sub-modules.  However, this is a little bit of a lie,
> and it turns out that it doesn't work.  The fix is
> to use a new status `exported_to_submodules' for this case.
> 
> compiler/prog_data.m:
> 	Add a new pseudo-declaration ":- private_interface",
> 	used to mark items in an ":- implementation" section
> 	that will be exported to submodules.
> 
> compiler/modules.m:
> 	Put declarations from modules containing sub-modules into
> 	`private_interface' sections rather than into `interface' sections.
> 
> compiler/hlds_pred.m:
> 	Add a new alternative `exported_to_submodules' to the
> 	`import_status' data type.  Add several new procedures
> 	for testing particular aspects of this type.
> 
> compiler/module_qual.m:
> 	Set the import_status of items in a `private_interface'
> 	section to `exported_to_submodules'.
> 
> compiler/intermod.m:
> 	Handle procedures with status `exported_to_submodules'
> 	specially.  Also reorganize the code here a bit to make
> 	it more maintainable.
> 
> compiler/base_type_info.m:
> compiler/base_type_info.m:
> compiler/base_typeclass_info.m:
> compiler/code_util.m:
> compiler/dead_proc_elim.m:
> compiler/hlds_out.m:
> compiler/make_hlds.m:
> compiler/termination.m:
> compiler/unused_args.m:
> 	Minor changes to reflect the above changes to data-structures;
> 	in particular, use the new procedures defined in hlds_pred.m
> 	instead of hard-coded tests.
> 
> tests/hard_coded/Mmakefile:
> tests/hard_coded/nested_intermod.m:
> tests/hard_coded/nested_intermod_main.m:
> tests/hard_coded/nested_intermod_main.exp:
> 	Add a regression test for the bug mentioned above.

Generally, looks fine.

> Index: compiler/termination.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/termination.m,v
> retrieving revision 1.16
> diff -u -r1.16 termination.m
> --- termination.m	1998/10/02 20:12:22	1.16
> +++ termination.m	1998/10/27 16:32:44
> @@ -390,10 +390,7 @@
>  	->
>  		ProcTable2 = ProcTable1
>  	;
> -		( ImportStatus = exported
> -		; ImportStatus = local
> -		; ImportStatus = pseudo_exported
> -		)
> +		status_defined_in_this_module(ImportStatus, yes)
>  	->
>  		( check_marker(Markers, terminates) ->
>  			change_procs_termination_info(ProcIds, yes,
> @@ -402,11 +399,8 @@
>  			ProcTable2 = ProcTable0
>  		)
>  	;
> -		( ImportStatus = imported
> -		; ImportStatus = opt_imported
> -		; ImportStatus = pseudo_imported  % should this be here?
> -		)
> -	->
> +		% Not defined in this module.
> +

I don't understand what's going on here, though.

>  		% All of the predicates that are processed in this section
>  		% are imported in some way.
>  		% With imported predicates, any 'check_termination'
> @@ -435,13 +429,6 @@
>  		ArgSizeInfo = infinite([Context - ArgSizeError]),
>  		change_procs_arg_size_info(ProcIds, no, ArgSizeInfo,
>  			ProcTable1, ProcTable2)
> -	;
> -%		( ImportStatus = abstract_imported
> -%		; ImportStatus = abstract_exported
> -%		),
> -		% This should not happen, as procedures are being processed
> -		% here, and these import_status' refer to abstract types.
> -		error("termination__check_preds: Unexpected import status")

Nor here. Your log message just says you made changes to termination.m to
reflect the changes in the data structures. Those last two changes seem
to be changing the behaviour.

Otherwise it looks fine.



dgj
-- 
David Jeffery (dgj at cs.mu.oz.au) |  Marge: Did you just call everyone "chicken"?
PhD student,                    |  Homer: Noooo.  I swear on this Bible!
Department of Computer Science  |  Marge: That's not a Bible; that's a book of
University of Melbourne         |         carpet samples!
Australia                       |  Homer: Ooooh... Fuzzy.



More information about the developers mailing list