[m-rev.] diff: fix bug in smart recompilation
Simon Taylor
stayl at cs.mu.OZ.AU
Mon Nov 5 01:42:23 AEDT 2001
Estimated hours taken: 0.5
Fix a bug in smart recompilation which caused unnecessary recompilations.
compiler/recompilation_check.m:
The code to check whether a new functor could cause an
ambiguity wasn't properly checking whether the functor
could have matched a functor seen during the previous
compilation.
Simplify similar code to handle types, insts, predicates, etc.
tests/recompilation/TESTS:
tests/recompilation/add_constructor_nr*:
Test case.
Index: compiler/recompilation_check.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/recompilation_check.m,v
retrieving revision 1.5
diff -u -u -r1.5 recompilation_check.m
--- compiler/recompilation_check.m 24 Oct 2001 05:56:29 -0000 1.5
+++ compiler/recompilation_check.m 4 Nov 2001 12:37:35 -0000
@@ -1018,33 +1018,27 @@
recompilation_check_info::out) is det.
check_for_simple_item_ambiguity(ItemType, Name, NeedQualifier, SymName, Arity,
- ModuleQualifier, MatchingModuleName) -->
+ OldModuleQualifier, OldMatchingModuleName) -->
(
% XXX This is a bit conservative in the
% case of partially qualified names but that
% hopefully won't come up too often.
{ NeedQualifier = must_be_qualified },
- { ModuleQualifier = unqualified("") }
+ { OldModuleQualifier = unqualified("") }
->
[]
;
- { QualifiedName = module_qualify_name(ModuleQualifier, Name) },
- { match_sym_name(QualifiedName, SymName) }
+ { QualifiedName = module_qualify_name(OldModuleQualifier,
+ Name) },
+ { match_sym_name(QualifiedName, SymName) },
+ \+ { SymName = qualified(OldMatchingModuleName, _) }
->
- (
- { SymName = qualified(MatchingModuleName, _) }
- ->
- []
- ;
- { OldMatchingName =
- qualified(MatchingModuleName, Name) },
- { Reason = item_ambiguity(
- item_id(ItemType, SymName - Arity),
+ { OldMatchingName = qualified(OldMatchingModuleName, Name) },
+ { Reason = item_ambiguity(item_id(ItemType, SymName - Arity),
[item_id(ItemType, OldMatchingName - Arity)]
) },
- =(Info),
- { throw(recompile_exception(Reason, Info)) }
- )
+ =(Info),
+ { throw(recompile_exception(Reason, Info)) }
;
[]
).
@@ -1055,41 +1049,36 @@
recompilation_check_info::out) is det.
check_for_pred_or_func_ambiguity(ItemType, Name, NeedQualifier,
- SymName, Arity, ModuleQualifier, MatchingModuleNames) -->
+ SymName, Arity, OldModuleQualifier, OldMatchingModuleNames) -->
(
% XXX This is a bit conservative in the
% case of partially qualified names but that
% hopefully won't come up too often.
{ NeedQualifier = must_be_qualified },
- { ModuleQualifier = unqualified("") }
+ { OldModuleQualifier = unqualified("") }
->
[]
;
- { QualifiedName = module_qualify_name(ModuleQualifier, Name) },
- { match_sym_name(QualifiedName, SymName) }
+ { QualifiedName = module_qualify_name(OldModuleQualifier,
+ Name) },
+ { match_sym_name(QualifiedName, SymName) },
+ \+ {
+ SymName = qualified(PredModuleName, _),
+ set__member(_ - PredModuleName,
+ OldMatchingModuleNames)
+ }
->
- (
- { SymName = qualified(PredModuleName, _) },
- { set__member(_ - PredModuleName,
- MatchingModuleNames) }
- ->
- []
- ;
- { AmbiguousDecls = list__map(
- (func(_ - OldMatchingModule) = Item :-
- OldMatchingName =
- qualified(OldMatchingModule, Name),
- Item = item_id(ItemType,
- OldMatchingName - Arity)
- ),
- set__to_sorted_list(MatchingModuleNames)) },
- { Reason = item_ambiguity(
- item_id(ItemType, SymName - Arity),
+ { AmbiguousDecls = list__map(
+ (func(_ - OldMatchingModule) = Item :-
+ OldMatchingName = qualified(OldMatchingModule, Name),
+ Item = item_id(ItemType, OldMatchingName - Arity)
+ ),
+ set__to_sorted_list(OldMatchingModuleNames)) },
+ { Reason = item_ambiguity(item_id(ItemType, SymName - Arity),
AmbiguousDecls
- ) },
- =(Info),
- { throw(recompile_exception(Reason, Info)) }
- )
+ ) },
+ =(Info),
+ { throw(recompile_exception(Reason, Info)) }
;
[]
).
@@ -1220,29 +1209,31 @@
recompilation_check_info::in, recompilation_check_info::out) is det.
check_functor_ambiguity(NeedQualifier, SymName, Arity, ResolvedCtor,
- Qualifier, ResolvedCtors) -->
+ OldModuleQualifier, OldResolvedCtors) -->
(
% XXX This is a bit conservative in the
% case of partially qualified names but that
% hopefully won't come up too often.
{ NeedQualifier = must_be_qualified },
- { Qualifier = unqualified("") }
+ { OldModuleQualifier = unqualified("") }
->
[]
;
- { set__member(ResolvedCtor, ResolvedCtors) }
- ->
- []
- ;
{ unqualify_name(SymName, Name) },
+ { OldName = module_qualify_name(OldModuleQualifier, Name) },
+ { match_sym_name(OldName, SymName) },
+ \+ { set__member(ResolvedCtor, OldResolvedCtors) }
+ ->
{ Reason = functor_ambiguity(
- module_qualify_name(Qualifier, Name),
+ module_qualify_name(OldModuleQualifier, Name),
Arity,
ResolvedCtor,
- set__to_sorted_list(ResolvedCtors)
+ set__to_sorted_list(OldResolvedCtors)
) },
=(Info),
{ throw(recompile_exception(Reason, Info)) }
+ ;
+ []
).
%-----------------------------------------------------------------------------%
Index: tests/recompilation//TESTS
===================================================================
RCS file: /home/mercury1/repository/tests/recompilation/TESTS,v
retrieving revision 1.5
diff -u -u -r1.5 TESTS
--- tests/recompilation//TESTS 24 Oct 2001 05:56:37 -0000 1.5
+++ tests/recompilation//TESTS 3 Nov 2001 20:25:18 -0000
@@ -3,6 +3,7 @@
# commands for the realclean target in the Mmakefile.
TESTS_SHOULD_SUCCEED="\
+ add_constructor_nr \
add_constructor_r \
add_instance_r \
add_instance_2_r \
Index: tests/recompilation//add_constructor_nr.err_exp.2
===================================================================
RCS file: tests/recompilation//add_constructor_nr.err_exp.2
diff -N tests/recompilation//add_constructor_nr.err_exp.2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation//add_constructor_nr.err_exp.2 3 Nov 2001 21:26:13 -0000
@@ -0,0 +1 @@
+Not recompiling module add_constructor_nr.
Index: tests/recompilation//add_constructor_nr.exp.1
===================================================================
RCS file: tests/recompilation//add_constructor_nr.exp.1
diff -N tests/recompilation//add_constructor_nr.exp.1
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation//add_constructor_nr.exp.1 3 Nov 2001 19:46:09 -0000
@@ -0,0 +1 @@
+c(1)
Index: tests/recompilation//add_constructor_nr.exp.2
===================================================================
RCS file: tests/recompilation//add_constructor_nr.exp.2
diff -N tests/recompilation//add_constructor_nr.exp.2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation//add_constructor_nr.exp.2 3 Nov 2001 19:46:14 -0000
@@ -0,0 +1 @@
+c(1)
Index: tests/recompilation//add_constructor_nr.m.1
===================================================================
RCS file: tests/recompilation//add_constructor_nr.m.1
diff -N tests/recompilation//add_constructor_nr.m.1
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation//add_constructor_nr.m.1 3 Nov 2001 19:45:28 -0000
@@ -0,0 +1,22 @@
+:- module add_constructor_nr.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module add_constructor_nr_2.
+
+:- type t
+ ---> c(int).
+
+main -->
+ output(add_constructor_nr__c(1)).
+
+:- pred output(t::in, io__state::di, io__state::uo) is det.
+
+output(X) --> io__write(X), io__nl.
+
Index: tests/recompilation//add_constructor_nr_2.err_exp.2
===================================================================
RCS file: tests/recompilation//add_constructor_nr_2.err_exp.2
diff -N tests/recompilation//add_constructor_nr_2.err_exp.2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation//add_constructor_nr_2.err_exp.2 3 Nov 2001 19:46:14 -0000
@@ -0,0 +1,2 @@
+Recompiling module `add_constructor_nr_2':
+ file `add_constructor_nr_2.m' has changed.
Index: tests/recompilation//add_constructor_nr_2.m.1
===================================================================
RCS file: tests/recompilation//add_constructor_nr_2.m.1
diff -N tests/recompilation//add_constructor_nr_2.m.1
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation//add_constructor_nr_2.m.1 3 Nov 2001 19:44:47 -0000
@@ -0,0 +1,8 @@
+:- module add_constructor_nr_2.
+
+:- interface.
+
+:- type foo
+ ---> a
+ ; b(int).
+
Index: tests/recompilation//add_constructor_nr_2.m.2
===================================================================
RCS file: tests/recompilation//add_constructor_nr_2.m.2
diff -N tests/recompilation//add_constructor_nr_2.m.2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation//add_constructor_nr_2.m.2 3 Nov 2001 19:45:04 -0000
@@ -0,0 +1,10 @@
+:- module add_constructor_nr_2.
+
+:- interface.
+
+:- type foo
+ ---> a
+ ; b(int).
+
+:- type bar
+ ---> c(float).
--------------------------------------------------------------------------
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