[m-rev.] diff: fix term size profiling bootstrap problems
Zoltan Somogyi
zs at cs.mu.OZ.AU
Fri Jan 21 14:18:12 AEDT 2005
compiler/size_prof.m:
Fix problems that prevented us from bootstrapping with term size
profiling. The first problem was the there were small periods of time
when pairs of maps that were supposed to have the same information
indexed in differents ways could become inconsistent. The second
problem was an overzealous sanity check.
runtime/mercury_term_size.c:
Handle the relatively recent pseudo_type_desc type_ctor_rep.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/size_prof.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/size_prof.m,v
retrieving revision 1.12
diff -u -b -r1.12 size_prof.m
--- compiler/size_prof.m 19 Jan 2005 03:10:55 -0000 1.12
+++ compiler/size_prof.m 19 Jan 2005 05:09:52 -0000
@@ -293,6 +293,7 @@
% because saving/restoring them is more expensive than defining
% them again.
!:Info = !.Info ^ type_ctor_map := map__init,
+ !:Info = !.Info ^ rev_type_ctor_map := map__init,
GoalExpr = GoalExpr0
;
GoalExpr0 = generic_call(_, _, _, _),
@@ -300,6 +301,7 @@
% because saving/restoring them is more expensive than defining
% them again.
!:Info = !.Info ^ type_ctor_map := map__init,
+ !:Info = !.Info ^ rev_type_ctor_map := map__init,
GoalExpr = GoalExpr0
;
GoalExpr0 = foreign_proc(_, _, _, _, _, _),
@@ -316,6 +318,7 @@
% better transformation while parallel conjunctions are rare.
TargetTypeInfoMap0 = !.Info ^ target_type_info_map,
TypeInfoMap0 = !.Info ^ type_info_map,
+ RevTypeInfoMap0 = !.Info ^ rev_type_info_map,
TypeCtorMap0 = !.Info ^ type_ctor_map,
KnownSizeMap0 = !.Info ^ known_size_map,
process_par_conj(Goals0, Goals, !Info,
@@ -323,7 +326,9 @@
KnownSizeMap0),
!:Info = !.Info ^ target_type_info_map := TargetTypeInfoMap0,
!:Info = !.Info ^ type_info_map := TypeInfoMap0,
+ !:Info = !.Info ^ rev_type_info_map := RevTypeInfoMap0,
!:Info = !.Info ^ type_ctor_map := map__init,
+ !:Info = !.Info ^ rev_type_ctor_map := map__init,
!:Info = !.Info ^ known_size_map := KnownSizeMap0,
GoalExpr = par_conj(Goals)
;
@@ -332,13 +337,20 @@
Cases0 = [First0 | Later0],
TargetTypeInfoMap0 = !.Info ^ target_type_info_map,
TypeInfoMap0 = !.Info ^ type_info_map,
+ RevTypeInfoMap0 = !.Info ^ rev_type_info_map,
TypeCtorMap0 = !.Info ^ type_ctor_map,
+ RevTypeCtorMap0 = !.Info ^ rev_type_ctor_map,
KnownSizeMap0 = !.Info ^ known_size_map,
process_switch(First0, First, Later0, Later, !Info,
- TargetTypeInfoMap0, TypeInfoMap0, TypeCtorMap0,
- KnownSizeMap0, TypeInfoMap, KnownSizeMap),
+ TargetTypeInfoMap0,
+ TypeInfoMap0, RevTypeInfoMap0,
+ TypeCtorMap0, RevTypeCtorMap0,
+ TypeInfoMap, KnownSizeMap0, KnownSizeMap),
!:Info = !.Info ^ type_info_map := TypeInfoMap,
+ % The rev_type_info_map field is updated by
+ % the call to update_rev_maps below.
!:Info = !.Info ^ type_ctor_map := map__init,
+ !:Info = !.Info ^ rev_type_ctor_map := map__init,
!:Info = !.Info ^ known_size_map := KnownSizeMap,
Cases = [First | Later]
;
@@ -354,20 +366,29 @@
Disjuncts0 = [First0 | Later0],
TargetTypeInfoMap0 = !.Info ^ target_type_info_map,
TypeInfoMap0 = !.Info ^ type_info_map,
+ RevTypeInfoMap0 = !.Info ^ rev_type_info_map,
TypeCtorMap0 = !.Info ^ type_ctor_map,
+ RevTypeCtorMap0 = !.Info ^ rev_type_ctor_map,
KnownSizeMap0 = !.Info ^ known_size_map,
process_disj(First0, First, Later0, Later, !Info,
- TargetTypeInfoMap0, TypeInfoMap0, TypeCtorMap0,
- KnownSizeMap0, TypeInfoMap, KnownSizeMap),
+ TargetTypeInfoMap0,
+ TypeInfoMap0, RevTypeInfoMap0,
+ TypeCtorMap0, RevTypeCtorMap0,
+ TypeInfoMap, KnownSizeMap0, KnownSizeMap),
!:Info = !.Info ^ type_info_map := TypeInfoMap,
+ % The rev_type_info_map field is updated by
+ % the call to update_rev_maps below.
!:Info = !.Info ^ type_ctor_map := map__init,
+ !:Info = !.Info ^ rev_type_ctor_map := map__init,
!:Info = !.Info ^ known_size_map := KnownSizeMap,
Disjuncts = [First | Later]
;
Disjuncts0 = [],
% An empty disj represents `fail'.
!:Info = !.Info ^ type_info_map := map__init,
- !:Info = !.Info ^ type_ctor_map := map__init,
+ !:Info = !.Info ^ rev_type_ctor_map := map__init,
+ !:Info = !.Info ^ type_info_map := map__init,
+ !:Info = !.Info ^ rev_type_ctor_map := map__init,
Disjuncts = []
),
update_rev_maps(!Info),
@@ -377,7 +398,9 @@
GoalExpr0 = if_then_else(Quant, Cond0, Then0, Else0),
TargetTypeInfoMap0 = !.Info ^ target_type_info_map,
TypeInfoMap0 = !.Info ^ type_info_map,
+ RevTypeInfoMap0 = !.Info ^ rev_type_info_map,
TypeCtorMap0 = !.Info ^ type_ctor_map,
+ RevTypeCtorMap0 = !.Info ^ rev_type_ctor_map,
KnownSizeMap0 = !.Info ^ known_size_map,
!:Info = !.Info ^ target_type_info_map := map__init,
@@ -388,12 +411,14 @@
TypeInfoMapThen = !.Info ^ type_info_map,
KnownSizeMapThen = !.Info ^ known_size_map,
- map__det_union(insist_on_same, TargetTypeInfoMapThen,
+ map__union(select_first, TargetTypeInfoMapThen,
TargetTypeInfoMap0, ElseTargetTypeInfoMap),
!:Info = !.Info ^ target_type_info_map :=
ElseTargetTypeInfoMap,
!:Info = !.Info ^ type_info_map := TypeInfoMap0,
+ !:Info = !.Info ^ rev_type_info_map := RevTypeInfoMap0,
!:Info = !.Info ^ type_ctor_map := TypeCtorMap0,
+ !:Info = !.Info ^ rev_type_ctor_map := RevTypeCtorMap0,
!:Info = !.Info ^ known_size_map := KnownSizeMap0,
process_goal(Else0, Else, !Info),
TypeInfoMapElse = !.Info ^ type_info_map,
@@ -413,7 +438,9 @@
GoalExpr0 = not(NegGoal0),
TargetTypeInfoMap0 = !.Info ^ target_type_info_map,
TypeInfoMap0 = !.Info ^ type_info_map,
+ RevTypeInfoMap0 = !.Info ^ rev_type_info_map,
TypeCtorMap0 = !.Info ^ type_ctor_map,
+ RevTypeCtorMap0 = !.Info ^ rev_type_ctor_map,
KnownSizeMap0 = !.Info ^ known_size_map,
process_goal(NegGoal0, NegGoal, !Info),
% Variables constructed in negated goals are not available
@@ -422,7 +449,9 @@
% fails.
!:Info = !.Info ^ target_type_info_map := TargetTypeInfoMap0,
!:Info = !.Info ^ type_info_map := TypeInfoMap0,
+ !:Info = !.Info ^ rev_type_info_map := RevTypeInfoMap0,
!:Info = !.Info ^ type_ctor_map := TypeCtorMap0,
+ !:Info = !.Info ^ rev_type_ctor_map := RevTypeCtorMap0,
!:Info = !.Info ^ known_size_map := KnownSizeMap0,
GoalExpr = not(NegGoal)
;
@@ -475,27 +504,31 @@
:- pred process_disj(hlds_goal::in, hlds_goal::out,
list(hlds_goal)::in, list(hlds_goal)::out, info::in, info::out,
- type_info_map::in, type_info_map::in, type_ctor_map::in,
- known_size_map::in, type_info_map::out, known_size_map::out) is det.
+ type_info_map::in, type_info_map::in, rev_type_info_map::in,
+ type_ctor_map::in, rev_type_ctor_map::in,
+ type_info_map::out, known_size_map::in, known_size_map::out) is det.
process_disj(First0, First, Later0, Later, !Info, TargetTypeInfoMap,
- TypeInfoMap0, TypeCtorMap0, KnownSizeMap0,
- TypeInfoMap, KnownSizeMap) :-
+ TypeInfoMap0, RevTypeInfoMap0, TypeCtorMap0, RevTypeCtorMap0,
+ TypeInfoMap, KnownSizeMap0, KnownSizeMap) :-
!:Info = !.Info ^ type_info_map := TypeInfoMap0,
+ !:Info = !.Info ^ rev_type_info_map := RevTypeInfoMap0,
!:Info = !.Info ^ type_ctor_map := TypeCtorMap0,
+ !:Info = !.Info ^ rev_type_ctor_map := RevTypeCtorMap0,
!:Info = !.Info ^ known_size_map := KnownSizeMap0,
process_goal(First0, First, !Info),
TypeInfoMapFirst = !.Info ^ type_info_map,
KnownSizeMapFirst = !.Info ^ known_size_map,
(
Later0 = [Head0 | Tail0],
- map__det_union(insist_on_same, TypeInfoMapFirst,
+ map__union(select_first, TypeInfoMapFirst,
TargetTypeInfoMap, LaterTargetTypeInfoMap),
!:Info = !.Info ^ target_type_info_map :=
LaterTargetTypeInfoMap,
process_disj(Head0, Head, Tail0, Tail, !Info,
- TargetTypeInfoMap, TypeInfoMap0, TypeCtorMap0,
- KnownSizeMap0, TypeInfoMapLater, KnownSizeMapLater),
+ TargetTypeInfoMap, TypeInfoMap0, RevTypeInfoMap0,
+ TypeCtorMap0, RevTypeCtorMap0,
+ TypeInfoMapLater, KnownSizeMap0, KnownSizeMapLater),
TypeInfoMap = map__common_subset(TypeInfoMapFirst,
TypeInfoMapLater),
KnownSizeMap = map__common_subset(KnownSizeMapFirst,
@@ -512,14 +545,17 @@
:- pred process_switch(case::in, case::out,
list(case)::in, list(case)::out, info::in, info::out,
- type_info_map::in, type_info_map::in, type_ctor_map::in,
- known_size_map::in, type_info_map::out, known_size_map::out) is det.
+ type_info_map::in, type_info_map::in, rev_type_info_map::in,
+ type_ctor_map::in, rev_type_ctor_map::in,
+ type_info_map::out, known_size_map::in, known_size_map::out) is det.
process_switch(First0, First, Later0, Later, !Info, TargetTypeInfoMap,
- TypeInfoMap0, TypeCtorMap0, KnownSizeMap0,
- TypeInfoMap, KnownSizeMap) :-
+ TypeInfoMap0, RevTypeInfoMap0, TypeCtorMap0, RevTypeCtorMap0,
+ TypeInfoMap, KnownSizeMap0, KnownSizeMap) :-
!:Info = !.Info ^ type_info_map := TypeInfoMap0,
+ !:Info = !.Info ^ rev_type_info_map := RevTypeInfoMap0,
!:Info = !.Info ^ type_ctor_map := TypeCtorMap0,
+ !:Info = !.Info ^ rev_type_ctor_map := RevTypeCtorMap0,
!:Info = !.Info ^ known_size_map := KnownSizeMap0,
First0 = case(FirstConsId, FirstGoal0),
process_goal(FirstGoal0, FirstGoal, !Info),
@@ -528,13 +564,15 @@
First = case(FirstConsId, FirstGoal),
(
Later0 = [Head0 | Tail0],
- map__det_union(insist_on_same, TypeInfoMapFirst,
- TargetTypeInfoMap, LaterTargetTypeInfoMap),
+ map__union(select_first, TargetTypeInfoMap,
+ TypeInfoMapFirst, LaterTargetTypeInfoMap),
!:Info = !.Info ^ target_type_info_map :=
LaterTargetTypeInfoMap,
process_switch(Head0, Head, Tail0, Tail, !Info,
- TargetTypeInfoMap, TypeInfoMap0, TypeCtorMap0,
- KnownSizeMap0, TypeInfoMapLater, KnownSizeMapLater),
+ TargetTypeInfoMap,
+ TypeInfoMap0, RevTypeInfoMap0,
+ TypeCtorMap0, RevTypeCtorMap0,
+ TypeInfoMapLater, KnownSizeMap0, KnownSizeMapLater),
TypeInfoMap = map__common_subset(TypeInfoMapFirst,
TypeInfoMapLater),
KnownSizeMap = map__common_subset(KnownSizeMapFirst,
@@ -1035,7 +1073,7 @@
record_known_type_info(Var, TypeCtorInfoVar, ArgTypeInfoVars, !Info) :-
RevTypeCtorMap0 = !.Info ^ rev_type_ctor_map,
- map__lookup(RevTypeCtorMap0, TypeCtorInfoVar, TypeCtor0),
+ ( map__search(RevTypeCtorMap0, TypeCtorInfoVar, TypeCtor0) ->
RevTypeInfoMap0 = !.Info ^ rev_type_info_map,
(
list__map(map__search(RevTypeInfoMap0), ArgTypeInfoVars,
@@ -1050,6 +1088,15 @@
record_type_info_var(Type, Var, !Info)
;
!:Info = !.Info
+ )
+ ;
+ % We don't know what type is being constructed, because we have
+ % forgotten what type constructor the type constructor variable
+ % stands for due to an intervening call. This cannot happen
+ % for HLDS code constructed directly by polymorphism.m, but
+ % can happen after that code has been rearranged by other
+ % compiler passes.
+ true
).
:- pred record_type_info_var((type)::in, prog_var::in, info::in, info::out)
@@ -1238,9 +1285,9 @@
%---------------------------------------------------------------------------%
-:- pred insist_on_same(T::in, T::in, T::out) is semidet.
+:- pred select_first(T::in, T::in, T::out) is det.
-insist_on_same(X, X, X).
+select_first(X, _, X).
%---------------------------------------------------------------------------%
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_term_size.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_term_size.c,v
retrieving revision 1.2
diff -u -b -r1.2 mercury_term_size.c
--- runtime/mercury_term_size.c 28 Jun 2004 04:50:07 -0000 1.2
+++ runtime/mercury_term_size.c 20 Jan 2005 02:49:25 -0000
@@ -262,6 +262,7 @@
case MR_TYPECTOR_REP_BASETYPECLASSINFO:
case MR_TYPECTOR_REP_TYPEDESC:
case MR_TYPECTOR_REP_TYPECTORDESC:
+ case MR_TYPECTOR_REP_PSEUDOTYPEDESC:
#ifdef MR_DEBUG_TERM_SIZES
if (MR_heapdebug && MR_lld_print_enabled) {
printf("MR_term_size: type_info etc %p\n", (void *) term);
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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