[m-rev.] diff: cleanups for deep profiler
Julien Fischer
juliensf at cs.mu.OZ.AU
Thu Jun 23 18:06:07 AEST 2005
Estimated hours taken: 1
Branches: main
Cleanup the deep profiler.
There are no changes to any algorithms.
deep_profiler/*.m:
Switch to state variable notation throughout. Rearrange
the order of some procedure arguments to facilitate this.
Remove some unnecessary module imports.
Reformat comments according to our current coding standard.
Update comments that refer to modules that no longer exist.
Julien.
Index: array_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/array_util.m,v
retrieving revision 1.6
diff -u -r1.6 array_util.m
--- array_util.m 25 Apr 2005 06:51:57 -0000 1.6
+++ array_util.m 22 Jun 2005 12:22:18 -0000
@@ -15,16 +15,20 @@
:- import_module array.
:- import_module list.
+%-----------------------------------------------------------------------------%
+
% Perform a mode cast on the given array, making the compiler believe
% that the ground array is unique. Should be used only if the only use
% of the old value is as input to the upcoming destructive operation
% that needs the array to be unique. Otherwise, calling this function
% is dangerous.
+ %
:- func u(T) = T.
:- mode (u(in) = array_uo) is det.
% Performs a foldl on all the elements of the given array,
% starting at index 1.
+ %
:- pred array_foldl_from_1(pred(int, T, U, U), array(T), U, U).
:- mode array_foldl_from_1(pred(in, in, di, uo) is det, in, di, uo) is det.
:- mode array_foldl_from_1(pred(in, in, array_di, array_uo) is det, in,
@@ -33,6 +37,7 @@
% Performs a foldl on all the elements of the given array,
% starting at index 0.
+ %
:- pred array_foldl_from_0(pred(int, T, U, U), array(T), U, U).
:- mode array_foldl_from_0(pred(in, in, di, uo) is det, in, di, uo) is det.
:- mode array_foldl_from_0(pred(in, in, array_di, array_uo) is det, in,
@@ -42,6 +47,7 @@
% Performs a foldl on all the elements of the given array
% between the two index values given by the first two arguments,
% both inclusive.
+ %
:- pred array_foldl(int, int, pred(int, T, U, U), array(T), U, U).
:- mode array_foldl(in, in, pred(in, in, di, uo) is det, in, di, uo) is det.
:- mode array_foldl(in, in, pred(in, in, array_di, array_uo) is det, in,
@@ -50,6 +56,7 @@
% Performs a foldl2 on all the elements of the given array,
% starting at index 1.
+ %
:- pred array_foldl2_from_1(pred(int, T, U, U, V, V), array(T), U, U, V, V).
:- mode array_foldl2_from_1(pred(in, in, di, uo, di, uo) is det,
in, di, uo, di, uo) is det.
@@ -66,6 +73,7 @@
% Performs a foldl2 on all the elements of the given array
% between the two index values given by the first two arguments,
% both inclusive.
+ %
:- pred array_foldl2(int, int, pred(int, T, U, U, V, V), array(T), U, U, V, V).
:- mode array_foldl2(in, in, pred(in, in, di, uo, di, uo) is det, in,
di, uo, di, uo) is det.
@@ -82,6 +90,7 @@
% Performs the same computation as list__foldl; the only difference
% is that the accumulator is an array and has an array mode.
+ %
:- pred array_list_foldl(pred(T, array(U), array(U)), list(T),
array(U), array(U)).
:- mode array_list_foldl(pred(in, array_di, array_uo) is det, in,
@@ -89,6 +98,7 @@
% Performs the same computation as list__foldl2; the only difference
% is that the accumulators are arrays and have array modes.
+ %
:- pred array_list_foldl2(pred(T, array(U), array(U), array(V), array(V)),
list(T), array(U), array(U), array(V), array(V)).
:- mode array_list_foldl2(pred(in, array_di, array_uo, array_di, array_uo)
@@ -96,21 +106,26 @@
% Performs a map on all the elements of the given array,
% starting at index 0.
+ %
:- pred array_map_from_0(pred(T, T), array(T), array(T)).
:- mode array_map_from_0(pred(in, out) is det, array_di, array_uo) is det.
% Performs a map on all the elements of the given array,
% starting at index 1.
+ %
:- pred array_map_from_1(pred(T, T), array(T), array(T)).
:- mode array_map_from_1(pred(in, out) is det, array_di, array_uo) is det.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
:- import_module int.
:- import_module string.
+%-----------------------------------------------------------------------------%
+
:- pragma foreign_proc("C",
u(A::in) = (B::array_uo),
[will_not_call_mercury, thread_safe, promise_pure],
@@ -118,64 +133,67 @@
B = A;
").
-array_foldl_from_1(P, A, U0, U) :-
+array_foldl_from_1(P, A, !AccU) :-
array__max(A, Max),
- array_foldl(1, Max, P, A, U0, U).
+ array_foldl(1, Max, P, A, !AccU).
-array_foldl_from_0(P, A, U0, U) :-
+array_foldl_from_0(P, A, !AccU) :-
array__max(A, Max),
- array_foldl(0, Max, P, A, U0, U).
+ array_foldl(0, Max, P, A, !AccU).
-array_foldl(N, Max, P, A, U0, U) :-
+array_foldl(N, Max, P, A, !AccU) :-
( N =< Max ->
array__lookup(A, N, E),
- call(P, N, E, U0, U1),
- array_foldl(N + 1, Max, P, A, U1, U)
+ P(N, E, !AccU),
+ array_foldl(N + 1, Max, P, A, !AccU)
;
- U = U0
+ true
).
-array_foldl2_from_1(P, A, U0, U, V0, V) :-
+array_foldl2_from_1(P, A, !AccU, !AccV) :-
array__max(A, Max),
- array_foldl2(1, Max, P, A, U0, U, V0, V).
+ array_foldl2(1, Max, P, A, !AccU, !AccV).
-array_foldl2(N, Max, P, A, U0, U, V0, V) :-
+array_foldl2(N, Max, P, A, !AccU, !AccV) :-
( N =< Max ->
array__lookup(A, N, E),
- call(P, N, E, U0, U1, V0, V1),
- array_foldl2(N + 1, Max, P, A, U1, U, V1, V)
+ P(N, E, !AccU, !AccV),
+ array_foldl2(N + 1, Max, P, A, !AccU, !AccV)
;
- U = U0,
- V = V0
+ true
).
-array_list_foldl(_, [], Acc, Acc).
-array_list_foldl(P, [X | Xs], Acc0, Acc) :-
- call(P, X, Acc0, Acc1),
- array_list_foldl(P, Xs, Acc1, Acc).
-
-array_list_foldl2(_, [], AccU, AccU, AccV, AccV).
-array_list_foldl2(P, [X | Xs], AccU0, AccU, AccV0, AccV) :-
- call(P, X, AccU0, AccU1, AccV0, AccV1),
- array_list_foldl2(P, Xs, AccU1, AccU, AccV1, AccV).
-
-array_map_from_0(P, U0, U) :-
- array__max(U0, Max),
- array_map(0, Max, P, U0, U).
-
-array_map_from_1(P, U0, U) :-
- array__max(U0, Max),
- array_map(1, Max, P, U0, U).
+array_list_foldl(_, [], !Acc).
+array_list_foldl(P, [X | Xs], !Acc) :-
+ P(X, !Acc),
+ array_list_foldl(P, Xs, !Acc).
+
+array_list_foldl2(_, [], !AccU, !AccV).
+array_list_foldl2(P, [X | Xs], !AccU, !AccV) :-
+ P(X, !AccU, !AccV),
+ array_list_foldl2(P, Xs, !AccU, !AccV).
+
+array_map_from_0(P, !AccU) :-
+ array__max(!.AccU, Max),
+ array_map(0, Max, P, !AccU).
+
+array_map_from_1(P, !AccU) :-
+ array__max(!.AccU, Max),
+ array_map(1, Max, P, !AccU).
:- pred array_map(int, int, pred(T, T), array(T), array(T)).
:- mode array_map(in, in, pred(in, out) is det, array_di, array_uo) is det.
-array_map(N, Size, Closure, Array0, Array) :-
+array_map(N, Size, Closure, !Array) :-
( N >= Size ->
- Array = Array0
+ true
;
- array__lookup(Array0, N, OldElem),
+ array__lookup(!.Array, N, OldElem),
Closure(OldElem, NewElem),
- array__set(Array0, N, NewElem, Array1),
- array_map(N + 1, Size, Closure, Array1, Array)
+ array__set(!.Array, N, NewElem, !:Array),
+ array_map(N + 1, Size, Closure, !Array)
).
+
+%-----------------------------------------------------------------------------%
+:- end_module array_util.
+%-----------------------------------------------------------------------------%
Index: callgraph.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/callgraph.m,v
retrieving revision 1.5
diff -u -r1.5 callgraph.m
--- callgraph.m 24 Mar 2005 01:10:26 -0000 1.5
+++ callgraph.m 22 Jun 2005 12:19:41 -0000
@@ -19,6 +19,8 @@
:- import_module array.
:- import_module list.
+%-----------------------------------------------------------------------------%
+
:- pred find_cliques(initial_deep::in, list(list(proc_dynamic_ptr))::out)
is det.
@@ -27,20 +29,25 @@
is det.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
:- import_module array_util.
:- import_module cliques.
-:- import_module int.
:- import_module profile.
+
+:- import_module int.
:- import_module set.
+:- import_module svarray.
% :- import_module io.
% :- import_module require.
% :- import_module string.
% :- import_module unsafe.
+%-----------------------------------------------------------------------------%
+
find_cliques(InitDeep, BottomUpPDPtrCliqueList) :-
make_graph(InitDeep, Graph),
topological_sort(Graph, TopDownPDICliqueList),
@@ -82,24 +89,23 @@
:- pred add_pd_arcs(initial_deep::in, int::in, proc_dynamic::in,
graph::in, graph::out) is det.
-add_pd_arcs(InitDeep, PDI, PD, Graph0, Graph) :-
+add_pd_arcs(InitDeep, PDI, PD, !Graph) :-
CallSiteRefArray = PD ^ pd_sites,
array__to_list(CallSiteRefArray, CallSiteRefList),
- list__foldl(add_call_site_arcs(InitDeep, PDI),
- CallSiteRefList, Graph0, Graph).
+ list__foldl(add_call_site_arcs(InitDeep, PDI), CallSiteRefList,
+ !Graph).
:- pred add_call_site_arcs(initial_deep::in, int::in, call_site_array_slot::in,
graph::in, graph::out) is det.
-add_call_site_arcs(InitDeep, FromPDI, CallSiteSlot, Graph0, Graph) :-
+add_call_site_arcs(InitDeep, FromPDI, CallSiteSlot, !Graph) :-
(
CallSiteSlot = normal(CSDPtr),
- add_csd_arcs(InitDeep, FromPDI, CSDPtr, Graph0, Graph)
+ add_csd_arcs(InitDeep, FromPDI, CSDPtr, !Graph)
;
CallSiteSlot = multi(_, CSDPtrArray),
array__to_list(CSDPtrArray, CSDPtrs),
- list__foldl(add_csd_arcs(InitDeep, FromPDI), CSDPtrs,
- Graph0, Graph)
+ list__foldl(add_csd_arcs(InitDeep, FromPDI), CSDPtrs, !Graph)
).
:- pred add_csd_arcs(initial_deep::in, int::in, call_site_dynamic_ptr::in,
@@ -107,16 +113,16 @@
% :- pragma promise_pure(add_csd_arcs/5).
-add_csd_arcs(InitDeep, FromPDI, CSDPtr, Graph0, Graph) :-
+add_csd_arcs(InitDeep, FromPDI, CSDPtr, !Graph) :-
CSDPtr = call_site_dynamic_ptr(CSDI),
( CSDI > 0 ->
array__lookup(InitDeep ^ init_call_site_dynamics, CSDI, CSD),
ToPDPtr = CSD ^ csd_callee,
ToPDPtr = proc_dynamic_ptr(ToPDI),
% impure unsafe_perform_io(write_arc(FromPDI, ToPDI, CSDI)),
- add_arc(Graph0, FromPDI, ToPDI, Graph)
+ add_arc(!.Graph, FromPDI, ToPDI, !:Graph)
;
- Graph = Graph0
+ true
).
%-----------------------------------------------------------------------------%
@@ -132,23 +138,24 @@
:- pred index_clique(int::in, list(proc_dynamic_ptr)::in,
array(clique_ptr)::array_di, array(clique_ptr)::array_uo) is det.
-index_clique(CliqueNum, CliqueMembers, CliqueIndex0, CliqueIndex) :-
+index_clique(CliqueNum, CliqueMembers, !CliqueIndex) :-
array_list_foldl(index_clique_member(CliqueNum),
- CliqueMembers, CliqueIndex0, CliqueIndex).
+ CliqueMembers, !CliqueIndex).
:- pred index_clique_member(int::in, proc_dynamic_ptr::in,
array(clique_ptr)::array_di, array(clique_ptr)::array_uo) is det.
% :- pragma promise_pure(index_clique_member/4).
-index_clique_member(CliqueNum, PDPtr, CliqueIndex0, CliqueIndex) :-
+index_clique_member(CliqueNum, PDPtr, !CliqueIndex) :-
PDPtr = proc_dynamic_ptr(PDI),
% impure unsafe_perform_io(write_pdi_cn(PDI, CliqueNum)),
- array__set(CliqueIndex0, PDI, clique_ptr(CliqueNum), CliqueIndex).
+ svarray.set(PDI, clique_ptr(CliqueNum), !CliqueIndex).
%-----------------------------------------------------------------------------%
-
+%
% Predicates for use in debugging.
+%
% :- pred write_arc(int::in, int::in, int::in, io::di, io::uo)
% is det.
@@ -166,3 +173,8 @@
% io__write_int(CN, !IO),
% io__nl(!IO),
% io__flush_output(!IO).
+%
+
+%-----------------------------------------------------------------------------%
+:- end_module callgraph.
+%-----------------------------------------------------------------------------%
Index: canonical.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/canonical.m,v
retrieving revision 1.6
diff -u -r1.6 canonical.m
--- canonical.m 25 Apr 2005 06:51:57 -0000 1.6
+++ canonical.m 22 Jun 2005 12:12:39 -0000
@@ -18,21 +18,27 @@
:- pred canonicalize_cliques(initial_deep::in, initial_deep::out) is det.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
-:- import_module array.
:- import_module array_util.
-:- import_module bool.
:- import_module callgraph.
+:- import_module measurements.
+
+:- import_module array.
+:- import_module bool.
:- import_module int.
:- import_module io.
:- import_module list.
:- import_module map.
-:- import_module measurements.
:- import_module require.
:- import_module set.
:- import_module std_util.
+:- import_module svarray.
+:- import_module svmap.
+
+%-----------------------------------------------------------------------------%
% :- import_module unsafe.
@@ -50,63 +56,55 @@
% index: proc_dynamic_ptr
).
-canonicalize_cliques(InitDeep0, InitDeep) :-
- MaxCSDs = array__max(InitDeep0 ^ init_call_site_dynamics),
- MaxPDs = array__max(InitDeep0 ^ init_proc_dynamics),
+canonicalize_cliques(!InitDeep) :-
+ MaxCSDs = array__max(!.InitDeep ^ init_call_site_dynamics),
+ MaxPDs = array__max(!.InitDeep ^ init_proc_dynamics),
NumCSDs = MaxCSDs + 1,
NumPDs = MaxPDs + 1,
- find_cliques(InitDeep0, CliqueList),
+ find_cliques(!.InitDeep, CliqueList),
make_clique_indexes(NumPDs, CliqueList, Cliques, CliqueIndex),
MergeInfo = merge_info(Cliques, CliqueIndex),
CSDRedirect0 = array__init(NumCSDs, call_site_dynamic_ptr(0)),
PDRedirect0 = array__init(NumPDs, proc_dynamic_ptr(0)),
Redirect0 = redirect(CSDRedirect0, PDRedirect0),
- merge_cliques(CliqueList, MergeInfo, InitDeep0, Redirect0,
- InitDeep1, Redirect1),
- compact_dynamics(InitDeep1, Redirect1, NumCSDs, NumPDs, InitDeep).
+ merge_cliques(CliqueList, MergeInfo, !InitDeep, Redirect0, Redirect1),
+ compact_dynamics(Redirect1, NumCSDs, NumPDs, !InitDeep).
:- pred merge_cliques(list(list(proc_dynamic_ptr))::in,
- merge_info::in, initial_deep::in, redirect::in,
- initial_deep::out, redirect::out) is det.
+ merge_info::in, initial_deep::in, initial_deep::out,
+ redirect::in, redirect::out) is det.
-merge_cliques([], _, InitDeep, Redirect, InitDeep, Redirect).
-merge_cliques([Clique | Cliques], MergeInfo, InitDeep0, Redirect0,
- InitDeep, Redirect) :-
- merge_clique(Clique, MergeInfo, InitDeep0, Redirect0,
- InitDeep1, Redirect1),
- merge_cliques(Cliques, MergeInfo, InitDeep1, Redirect1,
- InitDeep, Redirect).
+merge_cliques([], _, !InitDeep, !Redirect).
+merge_cliques([Clique | Cliques], MergeInfo, !InitDeep, !Redirect) :-
+ merge_clique(Clique, MergeInfo, !InitDeep, !Redirect),
+ merge_cliques(Cliques, MergeInfo, !InitDeep, !Redirect).
:- pred merge_clique(list(proc_dynamic_ptr)::in,
- merge_info::in, initial_deep::in, redirect::in,
- initial_deep::out, redirect::out) is det.
+ merge_info::in, initial_deep::in, initial_deep::out,
+ redirect::in, redirect::out) is det.
-merge_clique(CliquePDs0, MergeInfo, InitDeep0, Redirect0,
- InitDeep, Redirect) :-
+merge_clique(CliquePDs0, MergeInfo, !InitDeep, !Redirect) :-
( CliquePDs0 = [_, _ | _] ->
map__init(ProcMap0),
- list__foldl(cluster_pds_by_ps(InitDeep0), CliquePDs0,
+ list__foldl(cluster_pds_by_ps(!.InitDeep), CliquePDs0,
ProcMap0, ProcMap1),
map__values(ProcMap1, PDsList1),
list__filter(two_or_more, PDsList1, ToMergePDsList1),
( ToMergePDsList1 = [_ | _] ->
- complete_clique(InitDeep0, Redirect0,
+ complete_clique(!.InitDeep, !.Redirect,
ProcMap1, ProcMap, Clique),
map__values(ProcMap, PDsList),
list__filter(two_or_more, PDsList, ToMergePDsList),
list__foldl2(merge_proc_dynamics_ignore_chosen(
MergeInfo, Clique),
- ToMergePDsList, InitDeep0, InitDeep,
- Redirect0, Redirect)
+ ToMergePDsList, !InitDeep, !Redirect)
;
- InitDeep = InitDeep0,
- Redirect = Redirect0
+ true
)
;
- InitDeep = InitDeep0,
- Redirect = Redirect0
+ true
).
:- pred insert_pds(list(T)::in, set(T)::in, set(T)::out) is det.
@@ -123,17 +121,16 @@
map(proc_static_ptr, list(proc_dynamic_ptr))::out,
set(proc_dynamic_ptr)::out) is det.
-complete_clique(InitDeep, Redirect, ProcMap0, ProcMap, Clique) :-
- map__values(ProcMap0, PDsList0),
+complete_clique(InitDeep, Redirect, !ProcMap, Clique) :-
+ map__values(!.ProcMap, PDsList0),
list__foldl(insert_pds, PDsList0, set__init, Clique0),
- complete_clique_pass(InitDeep, Redirect, Clique0, ProcMap0, ProcMap1,
- no, AddedPD),
+ complete_clique_pass(InitDeep, Redirect, Clique0, !ProcMap, no,
+ AddedPD),
(
AddedPD = yes,
- complete_clique(InitDeep, Redirect, ProcMap1, ProcMap, Clique)
+ complete_clique(InitDeep, Redirect, !ProcMap, Clique)
;
AddedPD = no,
- ProcMap = ProcMap1,
Clique = Clique0
).
@@ -143,11 +140,10 @@
map(proc_static_ptr, list(proc_dynamic_ptr))::out,
bool::in, bool::out) is det.
-complete_clique_pass(InitDeep, _Redirect, Clique, ProcMap0, ProcMap,
- AddedPD0, AddedPD) :-
- map__to_assoc_list(ProcMap0, PSPDs0),
+complete_clique_pass(InitDeep, _Redirect, Clique, !ProcMap, !AddedPD) :-
+ map__to_assoc_list(!.ProcMap, PSPDs0),
list__foldl2(complete_clique_ps(InitDeep, Clique),
- PSPDs0, ProcMap0, ProcMap, AddedPD0, AddedPD).
+ PSPDs0, !ProcMap, !AddedPD).
:- pred complete_clique_ps(initial_deep::in,
set(proc_dynamic_ptr)::in,
@@ -156,17 +152,14 @@
map(proc_static_ptr, list(proc_dynamic_ptr))::out,
bool::in, bool::out) is det.
-complete_clique_ps(InitDeep, Clique, PSPtr - PDPtrs, ProcMap0, ProcMap,
- AddedPD0, AddedPD) :-
+complete_clique_ps(InitDeep, Clique, PSPtr - PDPtrs, !ProcMap, !AddedPD) :-
( PDPtrs = [_, _ | _] ->
lookup_proc_statics(InitDeep ^ init_proc_statics, PSPtr, PS),
list__map(lookup_pd_site(InitDeep), PDPtrs, PDSites),
complete_clique_slots(array__max(PS ^ ps_sites), InitDeep,
- Clique, PS ^ ps_sites, PDSites, ProcMap0, ProcMap,
- AddedPD0, AddedPD)
+ Clique, PS ^ ps_sites, PDSites, !ProcMap, !AddedPD)
;
- ProcMap = ProcMap0,
- AddedPD = AddedPD0
+ true
).
:- pred lookup_pd_site(initial_deep::in, proc_dynamic_ptr::in,
@@ -184,7 +177,7 @@
bool::in, bool::out) is det.
complete_clique_slots(SlotNum, InitDeep, Clique, PSSites, PDSites,
- ProcMap0, ProcMap, AddedPD0, AddedPD) :-
+ !ProcMap, !AddedPD) :-
( SlotNum >= 0 ->
array__lookup(PSSites, SlotNum, CSSPtr),
lookup_call_site_statics(InitDeep ^ init_call_site_statics,
@@ -203,25 +196,22 @@
CalleePDPtrSet = set__list_to_set(CalleePDPtrs),
set__intersect(CalleePDPtrSet, Clique, Common),
( set__empty(Common) ->
- ProcMap1 = ProcMap0,
- AddedPD1 = AddedPD0
+ true
;
set__difference(CalleePDPtrSet, Clique, NewMembers),
( set__empty(NewMembers) ->
- ProcMap1 = ProcMap0,
- AddedPD1 = no
+ !:AddedPD = no
;
set__to_sorted_list(NewMembers, NewMemberList),
list__foldl(cluster_pds_by_ps(InitDeep),
- NewMemberList, ProcMap0, ProcMap1),
- AddedPD1 = yes
+ NewMemberList, !ProcMap),
+ !:AddedPD = yes
)
),
complete_clique_slots(SlotNum - 1, InitDeep, Clique,
- PSSites, PDSites, ProcMap1, ProcMap, AddedPD1, AddedPD)
+ PSSites, PDSites, !ProcMap, !AddedPD)
;
- ProcMap = ProcMap0,
- AddedPD = AddedPD0
+ true
).
:- pred merge_proc_dynamics_ignore_chosen(merge_info::in,
@@ -230,9 +220,9 @@
is det.
merge_proc_dynamics_ignore_chosen(MergeInfo, Clique, CandidatePDPtrs,
- InitDeep0, InitDeep, Redirect0, Redirect) :-
+ !InitDeep, !Redirect) :-
merge_proc_dynamics(MergeInfo, Clique, CandidatePDPtrs, _ChosenPDPtr,
- InitDeep0, InitDeep, Redirect0, Redirect).
+ !InitDeep, !Redirect).
:- pred merge_proc_dynamics(merge_info::in, set(proc_dynamic_ptr)::in,
list(proc_dynamic_ptr)::in, proc_dynamic_ptr::out,
@@ -240,15 +230,14 @@
is det.
merge_proc_dynamics(MergeInfo, Clique, CandidatePDPtrs, ChosenPDPtr,
- InitDeep0, InitDeep, Redirect0, Redirect) :-
- ProcDynamics0 = InitDeep0 ^ init_proc_dynamics,
+ !InitDeep, !Redirect) :-
+ ProcDynamics0 = !.InitDeep ^ init_proc_dynamics,
list__filter(valid_proc_dynamic_ptr_raw(ProcDynamics0),
CandidatePDPtrs, ValidPDPtrs, InvalidPDPtrs),
require(unify(InvalidPDPtrs, []),
"merge_proc_dynamics: invalid pdptrs"),
( ValidPDPtrs = [PrimePDPtr | RestPDPtrs] ->
- record_pd_redirect(RestPDPtrs, PrimePDPtr,
- Redirect0, Redirect1),
+ record_pd_redirect(RestPDPtrs, PrimePDPtr, !Redirect),
lookup_proc_dynamics(ProcDynamics0, PrimePDPtr, PrimePD0),
list__map(lookup_proc_dynamics(ProcDynamics0),
RestPDPtrs, RestPDs),
@@ -257,20 +246,18 @@
array__max(PrimeSites0, MaxSiteNum),
merge_proc_dynamic_slots(MergeInfo, MaxSiteNum, Clique,
PrimePDPtr, u(PrimeSites0), RestSites, PrimeSites,
- InitDeep0, InitDeep1, Redirect1, Redirect),
+ !InitDeep, !Redirect),
PrimePD = PrimePD0 ^ pd_sites := PrimeSites,
- ProcDynamics1 = InitDeep1 ^ init_proc_dynamics,
+ ProcDynamics1 = !.InitDeep ^ init_proc_dynamics,
update_proc_dynamics(PrimePDPtr, PrimePD,
u(ProcDynamics1), ProcDynamics),
- InitDeep = InitDeep1 ^ init_proc_dynamics := ProcDynamics,
+ !:InitDeep = !.InitDeep ^ init_proc_dynamics := ProcDynamics,
ChosenPDPtr = PrimePDPtr
;
% This could happen when merging the callees of CSDs
% representing special calls, but only before we added callcode
% to the unify/compare routines of builtin types.
% ChosenPDPtr = proc_dynamic_ptr(0),
- % InitDeep = InitDeep0,
- % Redirect = Redirect0
error("merge_proc_dynamics: no valid pdptrs")
).
@@ -284,7 +271,7 @@
merge_proc_dynamic_slots(MergeInfo, SlotNum, Clique, PrimePDPtr,
PrimeSiteArray0, RestSiteArrays, PrimeSiteArray,
- InitDeep0, InitDeep, Redirect0, Redirect) :-
+ !InitDeep, !Redirect) :-
( SlotNum >= 0 ->
array__lookup(PrimeSiteArray0, SlotNum, PrimeSite0),
(
@@ -292,7 +279,7 @@
merge_proc_dynamic_normal_slot(MergeInfo, SlotNum,
Clique, PrimePDPtr, PrimeCSDPtr0,
RestSiteArrays, PrimeCSDPtr,
- InitDeep0, InitDeep1, Redirect0, Redirect1),
+ !InitDeep, !Redirect),
array__set(PrimeSiteArray0, SlotNum,
normal(PrimeCSDPtr), PrimeSiteArray1)
;
@@ -301,7 +288,7 @@
merge_proc_dynamic_multi_slot(MergeInfo, SlotNum,
Clique, PrimePDPtr, PrimeCSDPtrList0,
RestSiteArrays, PrimeCSDPtrList,
- InitDeep0, InitDeep1, Redirect0, Redirect1),
+ !InitDeep, !Redirect),
PrimeCSDPtrArray = array(PrimeCSDPtrList),
array__set(PrimeSiteArray0, SlotNum,
multi(IsZeroed, PrimeCSDPtrArray),
@@ -309,12 +296,9 @@
),
merge_proc_dynamic_slots(MergeInfo, SlotNum - 1, Clique,
PrimePDPtr, PrimeSiteArray1, RestSiteArrays,
- PrimeSiteArray, InitDeep1, InitDeep,
- Redirect1, Redirect)
+ PrimeSiteArray, !InitDeep, !Redirect)
;
- PrimeSiteArray = PrimeSiteArray0,
- InitDeep = InitDeep0,
- Redirect = Redirect0
+ PrimeSiteArray = PrimeSiteArray0
).
:- pred merge_proc_dynamic_normal_slot(merge_info::in, int::in,
@@ -325,11 +309,11 @@
merge_proc_dynamic_normal_slot(MergeInfo, SlotNum, Clique,
PrimePDPtr, PrimeCSDPtr0, RestSiteArrays, PrimeCSDPtr,
- InitDeep0, InitDeep, Redirect0, Redirect) :-
+ !InitDeep, !Redirect) :-
lookup_normal_sites(RestSiteArrays, SlotNum, RestCSDPtrs),
merge_call_site_dynamics(MergeInfo, Clique, PrimePDPtr,
[PrimeCSDPtr0 | RestCSDPtrs], PrimeCSDPtr,
- InitDeep0, InitDeep, Redirect0, Redirect).
+ !InitDeep, !Redirect).
:- pred accumulate_csd_owns(call_site_dynamic::in,
own_prof_info::in, own_prof_info::out) is det.
@@ -354,16 +338,15 @@
merge_proc_dynamic_multi_slot(MergeInfo, SlotNum, Clique,
ParentPDPtr, PrimeCSDPtrs0, RestSiteArrays, PrimeCSDPtrs,
- InitDeep0, InitDeep, Redirect0, Redirect) :-
+ !InitDeep, !Redirect) :-
lookup_multi_sites(RestSiteArrays, SlotNum, RestCSDPtrLists),
list__condense([PrimeCSDPtrs0 | RestCSDPtrLists], AllCSDPtrs),
map__init(ProcMap0),
- list__foldl(cluster_csds_by_ps(InitDeep0), AllCSDPtrs,
+ list__foldl(cluster_csds_by_ps(!.InitDeep), AllCSDPtrs,
ProcMap0, ProcMap),
map__values(ProcMap, CSDPtrsClusters),
list__foldl3(merge_multi_slot_cluster(MergeInfo, ParentPDPtr, Clique),
- CSDPtrsClusters, [], PrimeCSDPtrs, InitDeep0, InitDeep,
- Redirect0, Redirect).
+ CSDPtrsClusters, [], PrimeCSDPtrs, !InitDeep, !Redirect).
:- pred merge_multi_slot_cluster(merge_info::in, proc_dynamic_ptr::in,
set(proc_dynamic_ptr)::in, list(call_site_dynamic_ptr)::in,
@@ -385,16 +368,14 @@
redirect::in, redirect::out) is det.
merge_call_site_dynamics(MergeInfo, Clique, ParentPDPtr, CandidateCSDPtrs,
- ChosenCSDPtr, InitDeep0, InitDeep, Redirect0, Redirect) :-
- CallSiteDynamics0 = InitDeep0 ^ init_call_site_dynamics,
+ ChosenCSDPtr, !InitDeep, !Redirect) :-
+ CallSiteDynamics0 = !.InitDeep ^ init_call_site_dynamics,
list__filter(valid_call_site_dynamic_ptr_raw(CallSiteDynamics0),
CandidateCSDPtrs, ValidCSDPtrs),
(
ValidCSDPtrs = [],
% This signifies that there is no call here.
- ChosenCSDPtr = call_site_dynamic_ptr(0),
- InitDeep = InitDeep0,
- Redirect = Redirect0
+ ChosenCSDPtr = call_site_dynamic_ptr(0)
;
ValidCSDPtrs = [FirstCSDPtr | LaterCSDPtrs],
lookup_call_site_dynamics(CallSiteDynamics0, FirstCSDPtr,
@@ -402,17 +383,14 @@
FirstCSD = FirstCSD0 ^ csd_caller := ParentPDPtr,
update_call_site_dynamics(FirstCSDPtr, FirstCSD,
u(CallSiteDynamics0), CallSiteDynamics),
- InitDeep1 = InitDeep0 ^ init_call_site_dynamics
+ !:InitDeep = !.InitDeep ^ init_call_site_dynamics
:= CallSiteDynamics,
(
- LaterCSDPtrs = [],
- InitDeep = InitDeep1,
- Redirect = Redirect0
+ LaterCSDPtrs = []
;
LaterCSDPtrs = [_ | _],
merge_call_site_dynamics_2(MergeInfo, Clique,
- FirstCSDPtr, LaterCSDPtrs, InitDeep1, InitDeep,
- Redirect0, Redirect)
+ FirstCSDPtr, LaterCSDPtrs, !InitDeep, !Redirect)
),
ChosenCSDPtr = FirstCSDPtr
).
@@ -479,8 +457,8 @@
redirect::in, redirect::out) is det.
merge_call_site_dynamics_descendants(MergeInfo, PrimeCSDPtr, RestCSDPtrs,
- ChosenPDPtr, InitDeep0, InitDeep, Redirect0, Redirect) :-
- CallSiteDynamics = InitDeep0 ^ init_call_site_dynamics,
+ ChosenPDPtr, !InitDeep, !Redirect) :-
+ CallSiteDynamics = !.InitDeep ^ init_call_site_dynamics,
lookup_call_site_dynamics(CallSiteDynamics, PrimeCSDPtr, PrimeCSD),
extract_csd_callee(PrimeCSD, PrimeCSDCallee),
list__map(lookup_call_site_dynamics(CallSiteDynamics),
@@ -489,22 +467,22 @@
PDPtrs = [PrimeCSDCallee | RestCSDCallees],
list__foldl(union_cliques(MergeInfo), PDPtrs, set__init, CliqueUnion),
merge_proc_dynamics(MergeInfo, CliqueUnion, PDPtrs, ChosenPDPtr,
- InitDeep0, InitDeep, Redirect0, Redirect).
+ !InitDeep, !Redirect).
:- pred union_cliques(merge_info::in, proc_dynamic_ptr::in,
set(proc_dynamic_ptr)::in, set(proc_dynamic_ptr)::out) is det.
-union_cliques(MergeInfo, PDPtr, CliqueUnion0, CliqueUnion) :-
+union_cliques(MergeInfo, PDPtr, !CliqueUnion) :-
( PDPtr = proc_dynamic_ptr(0) ->
% This can happen with calls to the unify/compare preds
% of builtin types.
- CliqueUnion = CliqueUnion0
+ true
;
lookup_clique_index(MergeInfo ^ merge_clique_index, PDPtr,
CliquePtr),
lookup_clique_members(MergeInfo ^ merge_clique_members,
CliquePtr, Members),
- set__insert_list(CliqueUnion0, Members, CliqueUnion)
+ set__insert_list(!.CliqueUnion, Members, !:CliqueUnion)
).
:- pred lookup_normal_sites(list(array(call_site_array_slot))::in, int::in,
@@ -540,16 +518,15 @@
:- pred record_pd_redirect(list(proc_dynamic_ptr)::in, proc_dynamic_ptr::in,
redirect::in, redirect::out) is det.
-record_pd_redirect(RestPDPtrs, PrimePDPtr, Redirect0, Redirect) :-
+record_pd_redirect(RestPDPtrs, PrimePDPtr, !Redirect) :-
% impure unsafe_perform_io(io__write_string("pd redirect: ")),
% impure unsafe_perform_io(io__print(RestPDPtrs)),
% impure unsafe_perform_io(io__write_string(" -> ")),
% impure unsafe_perform_io(io__print(PrimePDPtr)),
% impure unsafe_perform_io(io__nl),
- lookup_pd_redirect(Redirect0 ^ pd_redirect, PrimePDPtr, OldRedirect),
+ lookup_pd_redirect(!.Redirect ^ pd_redirect, PrimePDPtr, OldRedirect),
( OldRedirect = proc_dynamic_ptr(0) ->
- record_pd_redirect_2(RestPDPtrs, PrimePDPtr,
- Redirect0, Redirect)
+ record_pd_redirect_2(RestPDPtrs, PrimePDPtr, !Redirect)
;
error("record_pd_redirect: prime is redirected")
).
@@ -557,10 +534,9 @@
:- pred record_pd_redirect_2(list(proc_dynamic_ptr)::in, proc_dynamic_ptr::in,
redirect::in, redirect::out) is det.
-record_pd_redirect_2([], _, Redirect, Redirect).
-record_pd_redirect_2([RestPDPtr | RestPDPtrs], PrimePDPtr,
- Redirect0, Redirect) :-
- ProcRedirect0 = Redirect0 ^ pd_redirect,
+record_pd_redirect_2([], _, !Redirect).
+record_pd_redirect_2([RestPDPtr | RestPDPtrs], PrimePDPtr, !Redirect) :-
+ ProcRedirect0 = !.Redirect ^ pd_redirect,
lookup_pd_redirect(ProcRedirect0, RestPDPtr, OldRedirect),
( OldRedirect = proc_dynamic_ptr(0) ->
set_pd_redirect(u(ProcRedirect0), RestPDPtr, PrimePDPtr,
@@ -568,23 +544,22 @@
;
error("record_pd_redirect_2: already redirected")
),
- Redirect1 = Redirect0 ^ pd_redirect := ProcRedirect,
- record_pd_redirect_2(RestPDPtrs, PrimePDPtr, Redirect1, Redirect).
+ !:Redirect = !.Redirect ^ pd_redirect := ProcRedirect,
+ record_pd_redirect_2(RestPDPtrs, PrimePDPtr, !Redirect).
% :- pragma promise_pure(record_csd_redirect/4).
:- pred record_csd_redirect(list(call_site_dynamic_ptr)::in,
call_site_dynamic_ptr::in, redirect::in, redirect::out) is det.
-record_csd_redirect(RestCSDPtrs, PrimeCSDPtr, Redirect0, Redirect) :-
+record_csd_redirect(RestCSDPtrs, PrimeCSDPtr, !Redirect) :-
% impure unsafe_perform_io(io__write_string("csd redirect: ")),
% impure unsafe_perform_io(io__print(RestCSDPtrs)),
% impure unsafe_perform_io(io__write_string(" -> ")),
% impure unsafe_perform_io(io__print(PrimeCSDPtr)),
% impure unsafe_perform_io(io__nl),
- lookup_csd_redirect(Redirect0 ^ csd_redirect, PrimeCSDPtr, OldRedirect),
+ lookup_csd_redirect(!.Redirect ^ csd_redirect, PrimeCSDPtr, OldRedirect),
( OldRedirect = call_site_dynamic_ptr(0) ->
- record_csd_redirect_2(RestCSDPtrs, PrimeCSDPtr,
- Redirect0, Redirect)
+ record_csd_redirect_2(RestCSDPtrs, PrimeCSDPtr, !Redirect)
;
error("record_pd_redirect: prime is redirected")
).
@@ -592,10 +567,9 @@
:- pred record_csd_redirect_2(list(call_site_dynamic_ptr)::in,
call_site_dynamic_ptr::in, redirect::in, redirect::out) is det.
-record_csd_redirect_2([], _, Redirect, Redirect).
-record_csd_redirect_2([RestCSDPtr | RestCSDPtrs], PrimeCSDPtr,
- Redirect0, Redirect) :-
- CallSiteRedirect0 = Redirect0 ^ csd_redirect,
+record_csd_redirect_2([], _, !Redirect).
+record_csd_redirect_2([RestCSDPtr | RestCSDPtrs], PrimeCSDPtr, !Redirect) :-
+ CallSiteRedirect0 = !.Redirect ^ csd_redirect,
lookup_csd_redirect(CallSiteRedirect0, RestCSDPtr, OldRedirect),
( OldRedirect = call_site_dynamic_ptr(0) ->
set_csd_redirect(u(CallSiteRedirect0), RestCSDPtr, PrimeCSDPtr,
@@ -603,8 +577,8 @@
;
error("record_csd_redirect_2: already redirected")
),
- Redirect1 = Redirect0 ^ csd_redirect := CallSiteRedirect,
- record_csd_redirect_2(RestCSDPtrs, PrimeCSDPtr, Redirect1, Redirect).
+ !:Redirect = !.Redirect ^ csd_redirect := CallSiteRedirect,
+ record_csd_redirect_2(RestCSDPtrs, PrimeCSDPtr, !Redirect).
:- pred two_or_more(list(proc_dynamic_ptr)::in) is semidet.
@@ -614,26 +588,25 @@
map(proc_static_ptr, list(proc_dynamic_ptr))::in,
map(proc_static_ptr, list(proc_dynamic_ptr))::out) is det.
-cluster_pds_by_ps(InitDeep, PDPtr, ProcMap0, ProcMap) :-
+cluster_pds_by_ps(InitDeep, PDPtr, !ProcMap) :-
ProcDynamics = InitDeep ^ init_proc_dynamics,
( valid_proc_dynamic_ptr_raw(ProcDynamics, PDPtr) ->
lookup_proc_dynamics(ProcDynamics, PDPtr, PD),
PSPtr = PD ^ pd_proc_static,
- ( map__search(ProcMap0, PSPtr, PDPtrs0) ->
- map__det_update(ProcMap0, PSPtr, [PDPtr | PDPtrs0],
- ProcMap)
+ ( map__search(!.ProcMap, PSPtr, PDPtrs0) ->
+ svmap.det_update(PSPtr, [PDPtr | PDPtrs0], !ProcMap)
;
- map__det_insert(ProcMap0, PSPtr, [PDPtr], ProcMap)
+ svmap.det_insert(PSPtr, [PDPtr], !ProcMap)
)
;
- ProcMap = ProcMap0
+ true
).
:- pred cluster_csds_by_ps(initial_deep::in, call_site_dynamic_ptr::in,
map(proc_static_ptr, list(call_site_dynamic_ptr))::in,
map(proc_static_ptr, list(call_site_dynamic_ptr))::out) is det.
-cluster_csds_by_ps(InitDeep, CSDPtr, ProcMap0, ProcMap) :-
+cluster_csds_by_ps(InitDeep, CSDPtr, !ProcMap) :-
CallSiteDynamics = InitDeep ^ init_call_site_dynamics,
( valid_call_site_dynamic_ptr_raw(CallSiteDynamics, CSDPtr) ->
lookup_call_site_dynamics(CallSiteDynamics, CSDPtr, CSD),
@@ -645,14 +618,14 @@
;
PSPtr = proc_static_ptr(0)
),
- ( map__search(ProcMap0, PSPtr, CSDPtrs0) ->
- map__det_update(ProcMap0, PSPtr, [CSDPtr | CSDPtrs0],
- ProcMap)
+ ( map__search(!.ProcMap, PSPtr, CSDPtrs0) ->
+ svmap.det_update(PSPtr, [CSDPtr | CSDPtrs0],
+ !ProcMap)
;
- map__det_insert(ProcMap0, PSPtr, [CSDPtr], ProcMap)
+ svmap.det_insert(PSPtr, [CSDPtr], !ProcMap)
)
;
- ProcMap = ProcMap0
+ true
).
:- pred lookup_pd_redirect(array(proc_dynamic_ptr)::in,
@@ -690,35 +663,35 @@
:- pred deref_call_site_dynamic(redirect::in, call_site_dynamic_ptr::in,
call_site_dynamic_ptr::out) is det.
-deref_call_site_dynamic(Redirect, CSDPtr0, CSDPtr) :-
- lookup_csd_redirect(Redirect ^ csd_redirect, CSDPtr0, RedirectCSDPtr),
+deref_call_site_dynamic(Redirect, !CSDPtr) :-
+ lookup_csd_redirect(Redirect ^ csd_redirect, !.CSDPtr, RedirectCSDPtr),
RedirectCSDPtr = call_site_dynamic_ptr(RedirectCSDI),
( RedirectCSDI > 0 ->
- deref_call_site_dynamic(Redirect, RedirectCSDPtr, CSDPtr)
+ deref_call_site_dynamic(Redirect, RedirectCSDPtr, !:CSDPtr)
;
- CSDPtr = CSDPtr0
+ true
).
:- pred deref_proc_dynamic(redirect::in, proc_dynamic_ptr::in,
proc_dynamic_ptr::out) is det.
-deref_proc_dynamic(Redirect, PDPtr0, PDPtr) :-
- lookup_pd_redirect(Redirect ^ pd_redirect, PDPtr0, RedirectPDPtr),
+deref_proc_dynamic(Redirect, !PDPtr) :-
+ lookup_pd_redirect(Redirect ^ pd_redirect, !.PDPtr, RedirectPDPtr),
RedirectPDPtr = proc_dynamic_ptr(RedirectPDI),
( RedirectPDI > 0 ->
- deref_proc_dynamic(Redirect, RedirectPDPtr, PDPtr)
+ deref_proc_dynamic(Redirect, RedirectPDPtr, !:PDPtr)
;
- PDPtr = PDPtr0
+ true
).
%-----------------------------------------------------------------------------%
-:- pred compact_dynamics(initial_deep::in, redirect::in, int::in, int::in,
- initial_deep::out) is det.
+:- pred compact_dynamics(redirect::in, int::in, int::in,
+ initial_deep::in, initial_deep::out) is det.
-compact_dynamics(InitDeep0, Redirect0, MaxCSD0, MaxPD0, InitDeep) :-
+compact_dynamics(Redirect0, MaxCSD0, MaxPD0, !InitDeep) :-
Redirect0 = redirect(CSDredirect0, PDredirect0),
- InitDeep0 = initial_deep(Stats, Root0, CSDs0, PDs0, CSSs, PSs),
+ !.InitDeep = initial_deep(Stats, Root0, CSDs0, PDs0, CSSs, PSs),
compact_csd_redirect(1, 1, MaxCSD0, NumCSD,
u(CSDredirect0), CSDredirect),
compact_pd_redirect(1, 1, MaxPD0, NumPD,
@@ -731,29 +704,27 @@
array__shrink(CSDs1, NumCSD, CSDs),
array__shrink(PDs1, NumPD, PDs),
lookup_pd_redirect(PDredirect, Root0, Root),
- InitDeep = initial_deep(Stats, Root, CSDs, PDs, CSSs, PSs).
+ !:InitDeep = initial_deep(Stats, Root, CSDs, PDs, CSSs, PSs).
:- pred compact_csd_redirect(int::in, int::in, int::in, int::out,
array(call_site_dynamic_ptr)::array_di,
array(call_site_dynamic_ptr)::array_uo) is det.
-compact_csd_redirect(CurOld, CurNew, MaxOld, NumNew,
- CSDredirect0, CSDredirect) :-
+compact_csd_redirect(CurOld, CurNew, MaxOld, NumNew, !CSDredirect) :-
( CurOld > MaxOld ->
- NumNew = CurNew,
- CSDredirect = CSDredirect0
+ NumNew = CurNew
;
- array__lookup(CSDredirect0, CurOld, Redirect0),
+ array__lookup(!.CSDredirect, CurOld, Redirect0),
( Redirect0 = call_site_dynamic_ptr(0) ->
- array__set(CSDredirect0, CurOld,
- call_site_dynamic_ptr(CurNew), CSDredirect1),
+ svarray.set(CurOld, call_site_dynamic_ptr(CurNew),
+ !CSDredirect),
compact_csd_redirect(CurOld + 1, CurNew + 1,
- MaxOld, NumNew, CSDredirect1, CSDredirect)
+ MaxOld, NumNew, !CSDredirect)
;
% Since this CSD is being redirected, its slot is
% available for another (non-redirected) CSD.
compact_csd_redirect(CurOld + 1, CurNew,
- MaxOld, NumNew, CSDredirect0, CSDredirect)
+ MaxOld, NumNew, !CSDredirect)
)
).
@@ -761,42 +732,40 @@
array(proc_dynamic_ptr)::array_di,
array(proc_dynamic_ptr)::array_uo) is det.
-compact_pd_redirect(CurOld, CurNew, MaxOld, NumNew,
- PDredirect0, PDredirect) :-
+compact_pd_redirect(CurOld, CurNew, MaxOld, NumNew, !PDredirect) :-
( CurOld > MaxOld ->
- NumNew = CurNew,
- PDredirect = PDredirect0
+ NumNew = CurNew
;
- array__lookup(PDredirect0, CurOld, Redirect0),
+ array__lookup(!.PDredirect, CurOld, Redirect0),
( Redirect0 = proc_dynamic_ptr(0) ->
- array__set(PDredirect0, CurOld,
- proc_dynamic_ptr(CurNew), PDredirect1),
+ svarray.set(CurOld, proc_dynamic_ptr(CurNew),
+ !PDredirect),
compact_pd_redirect(CurOld + 1, CurNew + 1,
- MaxOld, NumNew, PDredirect1, PDredirect)
+ MaxOld, NumNew, !PDredirect)
;
% Since this PD is being redirected, its slot is
% available for another (non-redirected) PD.
compact_pd_redirect(CurOld + 1, CurNew,
- MaxOld, NumNew, PDredirect0, PDredirect)
+ MaxOld, NumNew, !PDredirect)
)
).
:- pred subst_in_call_site_dynamic(redirect::in, call_site_dynamic::in,
call_site_dynamic::out) is det.
-subst_in_call_site_dynamic(Redirect, CSD0, CSD) :-
- CSD0 = call_site_dynamic(Caller0, Callee0, Own),
+subst_in_call_site_dynamic(Redirect, !CSD) :-
+ !.CSD = call_site_dynamic(Caller0, Callee0, Own),
lookup_pd_redirect(Redirect ^ pd_redirect, Caller0, Caller),
lookup_pd_redirect(Redirect ^ pd_redirect, Callee0, Callee),
- CSD = call_site_dynamic(Caller, Callee, Own).
+ !:CSD = call_site_dynamic(Caller, Callee, Own).
:- pred subst_in_proc_dynamic(redirect::in, proc_dynamic::in,
proc_dynamic::out) is det.
-subst_in_proc_dynamic(Redirect, PD0, PD) :-
- PD0 = proc_dynamic(PDPtr, Slots0),
+subst_in_proc_dynamic(Redirect, !PD) :-
+ !.PD = proc_dynamic(PDPtr, Slots0),
array__map(subst_in_slot(Redirect), u(Slots0), Slots),
- PD = proc_dynamic(PDPtr, Slots).
+ !:PD = proc_dynamic(PDPtr, Slots).
:- pred subst_in_slot(redirect::in, call_site_array_slot::in,
call_site_array_slot::out) is det.
@@ -897,18 +866,14 @@
proc_dynamics::array_di, proc_dynamics::array_uo) is det.
concatenate_profiles([], _PrevMaxCSD, _PrevMaxPD,
- ConcatCallSiteDynamics, ConcatCallSiteDynamics,
- ConcatProcDynamics, ConcatProcDynamics).
+ !ConcatCallSiteDynamics, !ConcatProcDynamics).
concatenate_profiles([InitDeep | InitDeeps], PrevMaxCSD, PrevMaxPD,
- ConcatCallSiteDynamics0, ConcatCallSiteDynamics,
- ConcatProcDynamics0, ConcatProcDynamics) :-
+ !ConcatCallSiteDynamics, !ConcatProcDynamics) :-
concatenate_profile(InitDeep,
PrevMaxCSD, PrevMaxPD, NextMaxCSD, NextMaxPD,
- ConcatCallSiteDynamics0, ConcatCallSiteDynamics1,
- ConcatProcDynamics0, ConcatProcDynamics1),
+ !ConcatCallSiteDynamics, !ConcatProcDynamics),
concatenate_profiles(InitDeeps, NextMaxCSD, NextMaxPD,
- ConcatCallSiteDynamics1, ConcatCallSiteDynamics,
- ConcatProcDynamics1, ConcatProcDynamics).
+ !ConcatCallSiteDynamics, !ConcatProcDynamics).
:- pred concatenate_profile(initial_deep::in,
int::in, int::in, int::out, int::out,
@@ -916,38 +881,33 @@
proc_dynamics::array_di, proc_dynamics::array_uo) is det.
concatenate_profile(InitDeep, PrevMaxCSD, PrevMaxPD, NextMaxCSD, NextMaxPD,
- ConcatCallSiteDynamics0, ConcatCallSiteDynamics,
- ConcatProcDynamics0, ConcatProcDynamics) :-
+ !ConcatCallSiteDynamics, !ConcatProcDynamics) :-
extract_max_csd(InitDeep, MaxCSD),
extract_max_pd(InitDeep, MaxPD),
NextMaxCSD = PrevMaxCSD + MaxCSD,
NextMaxPD = PrevMaxPD + MaxPD,
concatenate_profile_csds(1, MaxCSD, PrevMaxCSD, PrevMaxPD,
- InitDeep ^ init_call_site_dynamics,
- ConcatCallSiteDynamics0, ConcatCallSiteDynamics),
+ InitDeep ^ init_call_site_dynamics, !ConcatCallSiteDynamics),
concatenate_profile_pds(1, MaxPD, PrevMaxCSD, PrevMaxPD,
- InitDeep ^ init_proc_dynamics,
- ConcatProcDynamics0, ConcatProcDynamics).
+ InitDeep ^ init_proc_dynamics, !ConcatProcDynamics).
:- pred concatenate_profile_csds(int::in, int::in, int::in, int::in,
call_site_dynamics::in,
call_site_dynamics::array_di, call_site_dynamics::array_uo) is det.
concatenate_profile_csds(Cur, Max, PrevMaxCSD, PrevMaxPD, CallSiteDynamics,
- ConcatCallSiteDynamics0, ConcatCallSiteDynamics) :-
+ !ConcatCallSiteDynamics) :-
( Cur =< Max ->
array__lookup(CallSiteDynamics, Cur, CSD0),
CSD0 = call_site_dynamic(CallerPDPtr0, CalleePDPtr0, Own),
concat_proc_dynamic_ptr(PrevMaxPD, CallerPDPtr0, CallerPDPtr),
concat_proc_dynamic_ptr(PrevMaxPD, CalleePDPtr0, CalleePDPtr),
CSD = call_site_dynamic(CallerPDPtr, CalleePDPtr, Own),
- array__set(ConcatCallSiteDynamics0, PrevMaxCSD + Cur, CSD,
- ConcatCallSiteDynamics1),
+ svarray.set(PrevMaxCSD + Cur, CSD, !ConcatCallSiteDynamics),
concatenate_profile_csds(Cur + 1, Max, PrevMaxCSD, PrevMaxPD,
- CallSiteDynamics,
- ConcatCallSiteDynamics1, ConcatCallSiteDynamics)
+ CallSiteDynamics, !ConcatCallSiteDynamics)
;
- ConcatCallSiteDynamics = ConcatCallSiteDynamics0
+ true
).
:- pred concatenate_profile_pds(int::in, int::in, int::in, int::in,
@@ -955,7 +915,7 @@
proc_dynamics::array_di, proc_dynamics::array_uo) is det.
concatenate_profile_pds(Cur, Max, PrevMaxCSD, PrevMaxPD, ProcDynamics,
- ConcatProcDynamics0, ConcatProcDynamics) :-
+ !ConcatProcDynamics) :-
( Cur =< Max ->
array__lookup(ProcDynamics, Cur, PD0),
PD0 = proc_dynamic(PSPtr, Sites0),
@@ -963,22 +923,20 @@
concatenate_profile_slots(0, MaxSite, PrevMaxCSD, PrevMaxPD,
u(Sites0), Sites),
PD = proc_dynamic(PSPtr, Sites),
- array__set(ConcatProcDynamics0, PrevMaxPD + Cur, PD,
- ConcatProcDynamics1),
+ svarray.set(PrevMaxPD + Cur, PD, !ConcatProcDynamics),
concatenate_profile_pds(Cur + 1, Max, PrevMaxCSD, PrevMaxPD,
- ProcDynamics,
- ConcatProcDynamics1, ConcatProcDynamics)
+ ProcDynamics, !ConcatProcDynamics)
;
- ConcatProcDynamics = ConcatProcDynamics0
+ true
).
:- pred concatenate_profile_slots(int::in, int::in, int::in, int::in,
array(call_site_array_slot)::array_di,
array(call_site_array_slot)::array_uo) is det.
-concatenate_profile_slots(Cur, Max, PrevMaxCSD, PrevMaxPD, Sites0, Sites) :-
+concatenate_profile_slots(Cur, Max, PrevMaxCSD, PrevMaxPD, !Sites) :-
( Cur =< Max ->
- array__lookup(Sites0, Cur, Slot0),
+ array__lookup(!.Sites, Cur, Slot0),
(
Slot0 = normal(CSDPtr0),
concat_call_site_dynamic_ptr(PrevMaxCSD,
@@ -991,33 +949,33 @@
u(CSDPtrs0), CSDPtrs),
Slot = multi(IsZeroed, CSDPtrs)
),
- array__set(Sites0, Cur, Slot, Sites1),
+ svarray.set(Cur, Slot, !Sites),
concatenate_profile_slots(Cur + 1, Max, PrevMaxCSD, PrevMaxPD,
- Sites1, Sites)
+ !Sites)
;
- Sites = Sites0
+ true
).
:- pred concat_call_site_dynamic_ptr(int::in, call_site_dynamic_ptr::in,
call_site_dynamic_ptr::out) is det.
-concat_call_site_dynamic_ptr(PrevMaxCSD, CSDPtr0, CSDPtr) :-
- CSDPtr0 = call_site_dynamic_ptr(CSDI0),
+concat_call_site_dynamic_ptr(PrevMaxCSD, !CSDPtr) :-
+ !.CSDPtr = call_site_dynamic_ptr(CSDI0),
( CSDI0 = 0 ->
- CSDPtr = CSDPtr0
+ true
;
- CSDPtr = call_site_dynamic_ptr(CSDI0 + PrevMaxCSD)
+ !:CSDPtr = call_site_dynamic_ptr(CSDI0 + PrevMaxCSD)
).
:- pred concat_proc_dynamic_ptr(int::in, proc_dynamic_ptr::in,
proc_dynamic_ptr::out) is det.
-concat_proc_dynamic_ptr(PrevMaxPD, PDPtr0, PDPtr) :-
- PDPtr0 = proc_dynamic_ptr(PDI0),
+concat_proc_dynamic_ptr(PrevMaxPD, !PDPtr) :-
+ !.PDPtr = proc_dynamic_ptr(PDI0),
( PDI0 = 0 ->
- PDPtr = PDPtr0
+ true
;
- PDPtr = proc_dynamic_ptr(PDI0 + PrevMaxPD)
+ !:PDPtr = proc_dynamic_ptr(PDI0 + PrevMaxPD)
).
%-----------------------------------------------------------------------------%
@@ -1025,6 +983,7 @@
% array_match_elements(Min, Max, BaseArray, OtherArrays):
% Succeeds iff all the elements of all the OtherArrays are equal to the
% corresponding element of BaseArray.
+ %
:- pred array_match_elements(int::in, int::in, array(T)::in,
list(array(T))::in) is semidet.
@@ -1040,6 +999,7 @@
% match_element(TestElement, Index, Arrays):
% Succeeds iff the elements of all the Arrays at index Index
% are equal to TestElement.
+ %
:- pred match_element(T::in, int::in, list(array(T))::in) is semidet.
match_element(_, _, []).
@@ -1052,3 +1012,7 @@
int_add(A, B, C) :-
C = A + B.
+
+%----------------------------------------------------------------------------%
+:- end_module canonical.
+%----------------------------------------------------------------------------%
Index: conf.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/conf.m,v
retrieving revision 1.5
diff -u -r1.5 conf.m
--- conf.m 24 Mar 2005 01:10:27 -0000 1.5
+++ conf.m 22 Jun 2005 11:23:02 -0000
@@ -18,19 +18,26 @@
% Given a pathname, return a shell command that will create
% a named pipe with that pathname.
+ %
:- func make_pipe_cmd(string) = string.
% The name of the server on which mdprof is being run.
+ %
:- pred server_name(string::out, io::di, io::uo) is det.
:- func getpid = int.
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
:- implementation.
:- import_module list.
:- import_module require.
:- import_module string.
+%-----------------------------------------------------------------------------%
+
make_pipe_cmd(PipeName) = Cmd :-
mkfifo_cmd(CmdName),
( CmdName = "" ->
@@ -110,3 +117,7 @@
MR_fatal_error(""the deep profiler is not supported"");
#endif
").
+
+%-----------------------------------------------------------------------------%
+:- end_module conf.
+%-----------------------------------------------------------------------------%
Index: exclude.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/exclude.m,v
retrieving revision 1.4
diff -u -r1.4 exclude.m
--- exclude.m 24 Mar 2005 01:10:27 -0000 1.4
+++ exclude.m 22 Jun 2005 11:25:29 -0000
@@ -41,8 +41,10 @@
:- import_module profile.
-:- import_module std_util.
:- import_module io.
+:- import_module std_util.
+
+%-----------------------------------------------------------------------------%
:- type exclude_file.
@@ -53,6 +55,7 @@
= call_site_dynamic_ptr.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
@@ -64,6 +67,8 @@
:- import_module set.
:- import_module string.
+%-----------------------------------------------------------------------------%
+
:- type exclude_file == set(exclude_spec).
:- type exclude_spec
@@ -204,3 +209,7 @@
;
CSDPtr = CSDPtr0
).
+
+%-----------------------------------------------------------------------------%
+:- end_module exclude.
+%-----------------------------------------------------------------------------%
Index: html_format.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/html_format.m,v
retrieving revision 1.6
diff -u -r1.6 html_format.m
--- html_format.m 22 Jun 2005 07:25:12 -0000 1.6
+++ html_format.m 22 Jun 2005 12:39:04 -0000
@@ -8,6 +8,7 @@
%
% This module contains code that sets the format of the HTML tables
% we generate for individual queries.
+%-----------------------------------------------------------------------------%
:- module html_format.
@@ -22,6 +23,8 @@
:- import_module list.
:- import_module std_util.
+%-----------------------------------------------------------------------------%
+
:- func table_start(preferences) = string.
:- func table_end(preferences) = string.
@@ -128,10 +131,9 @@
:- func escape_html_string(string) = string.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
-
-:- import_module top_procs.
:- import_module char.
:- import_module float.
Index: io_combinator.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/io_combinator.m,v
retrieving revision 1.3
diff -u -r1.3 io_combinator.m
--- io_combinator.m 24 Mar 2005 01:10:27 -0000 1.3
+++ io_combinator.m 22 Jun 2005 12:20:47 -0000
@@ -560,9 +560,12 @@
out, di, uo) is det.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
+%-----------------------------------------------------------------------------%
+
io_combinator__sequence_2(P1, P2, Combine, Res) -->
call(P1, Res1),
(
@@ -1972,4 +1975,6 @@
{ Res = error(Err) }
).
+%-----------------------------------------------------------------------------%
+:- end_module io_combinator.
%-----------------------------------------------------------------------------%
Index: mdprof_cgi.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/mdprof_cgi.m,v
retrieving revision 1.10
diff -u -r1.10 mdprof_cgi.m
--- mdprof_cgi.m 25 Apr 2005 07:55:54 -0000 1.10
+++ mdprof_cgi.m 22 Jun 2005 12:34:47 -0000
@@ -9,6 +9,7 @@
%
% This file contains the CGI "script" that is executed by the web server
% to handle web page requests implemented by the Mercury deep profiler server.
+%-----------------------------------------------------------------------------%
:- module mdprof_cgi.
@@ -16,8 +17,13 @@
:- import_module io.
+%-----------------------------------------------------------------------------%
+
:- pred main(io::di, io::uo) is cc_multi.
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
:- implementation.
:- import_module profile.
@@ -42,6 +48,8 @@
:- import_module std_util.
:- import_module string.
+%-----------------------------------------------------------------------------%
+
% The web server should always set QUERY_STRING. It may also pass its contents
% as arguments, but if any characters special to the shell occur in the query,
% they will screw up the argument list. We therefore look at the argument list
@@ -744,4 +752,6 @@
Cmd = menu
).
+%-----------------------------------------------------------------------------%
+:- end_module mdprof_cgi.
%-----------------------------------------------------------------------------%
Index: mdprof_dump.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/mdprof_dump.m,v
retrieving revision 1.1
diff -u -r1.1 mdprof_dump.m
--- mdprof_dump.m 25 Apr 2005 06:51:58 -0000 1.1
+++ mdprof_dump.m 22 Jun 2005 12:37:19 -0000
@@ -10,12 +10,15 @@
% of a deep profiling data file (Deep.data file) for the purpose of debugging
% the deep profiler or the part of the Mercury runtime that generates Deep.data
% files.
+%-----------------------------------------------------------------------------%
:- module mdprof_dump.
:- interface.
:- import_module io.
+
+%-----------------------------------------------------------------------------%
:- pred main(io::di, io::uo) is det.
Index: mdprof_test.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/mdprof_test.m,v
retrieving revision 1.7
diff -u -r1.7 mdprof_test.m
--- mdprof_test.m 25 Apr 2005 06:51:58 -0000 1.7
+++ mdprof_test.m 22 Jun 2005 12:36:18 -0000
@@ -9,6 +9,7 @@
% Author: zs.
%
% This file contains a tool for testing the behavior of the deep profiler.
+%-----------------------------------------------------------------------------%
:- module mdprof_test.
@@ -16,8 +17,13 @@
:- import_module io.
+%-----------------------------------------------------------------------------%
+
:- pred main(io::di, io::uo) is cc_multi.
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
:- implementation.
:- import_module conf.
@@ -41,6 +47,8 @@
:- import_module std_util.
:- import_module string.
+%-----------------------------------------------------------------------------%
+
main(!IO) :-
io__progname_base("mdprof_test", ProgName, !IO),
io__command_line_arguments(Args0, !IO),
@@ -259,4 +267,6 @@
defaults(verbose, bool(no)).
defaults(version, bool(no)).
+%-----------------------------------------------------------------------------%
+:- end_module mdprof_test.
%-----------------------------------------------------------------------------%
Index: measurements.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/measurements.m,v
retrieving revision 1.5
diff -u -r1.5 measurements.m
--- measurements.m 25 Apr 2005 06:51:58 -0000 1.5
+++ measurements.m 22 Jun 2005 11:27:44 -0000
@@ -15,6 +15,8 @@
:- import_module list.
+%-----------------------------------------------------------------------------%
+
:- type own_prof_info.
:- type inherit_prof_info.
@@ -52,19 +54,21 @@
:- func compress_profile(int, int, int, int, int, int, int) = own_prof_info.
:- func compress_profile(own_prof_info) = own_prof_info.
- % decompress_profile
:- pred decompress_profile(own_prof_info::in, int::out, int::out, int::out,
int::out, int::out, int::out, int::out, int::out) is det.
:- func own_to_string(own_prof_info) = string.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
:- import_module int.
:- import_module string.
+%-----------------------------------------------------------------------------%
+
:- type own_prof_info
---> all(int, int, int, int, int, int, int)
% exits, fails, redos, excps, quanta, allocs, words
@@ -90,7 +94,7 @@
int, % quanta
int, % allocs
int % words
- ).
+ ).
calls(fast_nomem_semi(Exits, Fails)) = Exits + Fails.
exits(fast_nomem_semi(Exits, _)) = Exits.
@@ -314,3 +318,7 @@
string__int_to_string(Exits) ++ ", " ++
string__int_to_string(Fails) ++
")".
+
+%----------------------------------------------------------------------------%
+:- end_module measurements.
+%----------------------------------------------------------------------------%
Index: profile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/profile.m,v
retrieving revision 1.7
diff -u -r1.7 profile.m
--- profile.m 25 Apr 2005 06:51:58 -0000 1.7
+++ profile.m 22 Jun 2005 11:29:12 -0000
@@ -15,6 +15,7 @@
% at index 0; their first real element is at index 1. The arrays in
% proc_static and proc_dynamic structures, being reflections of arrays created
% in C code, start at index 0.
+%-----------------------------------------------------------------------------%
:- module profile.
@@ -28,6 +29,8 @@
:- import_module map.
:- import_module std_util.
+%-----------------------------------------------------------------------------%
+
:- type profile_stats --->
profile_stats(
max_csd :: int,
@@ -427,6 +430,7 @@
:- func root_own_info(deep) = own_prof_info.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
@@ -895,4 +899,6 @@
root_own_info(Deep) = RootOwn :-
deep_lookup_pd_own(Deep, Deep ^ root, RootOwn).
+%-----------------------------------------------------------------------------%
+:- end_module profile.
%-----------------------------------------------------------------------------%
Index: query.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/query.m,v
retrieving revision 1.7
diff -u -r1.7 query.m
--- query.m 22 Jun 2005 07:25:12 -0000 1.7
+++ query.m 22 Jun 2005 12:15:09 -0000
@@ -8,6 +8,7 @@
%
% This module contains the top level predicates for servicing individual
% queries.
+%-----------------------------------------------------------------------------%
:- module query.
@@ -18,6 +19,8 @@
:- import_module io.
+%-----------------------------------------------------------------------------%
+
:- pred try_exec(cmd::in, preferences::in, deep::in, string::out,
io::di, io::uo) is cc_multi.
@@ -1971,3 +1974,7 @@
Str = string__format("<A HREF=%s>%s</A>",
[s(URL), s(escape_html_string(Str0))])
).
+
+%----------------------------------------------------------------------------%
+:- end_module query.
+%----------------------------------------------------------------------------%
Index: startup.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/startup.m,v
retrieving revision 1.9
diff -u -r1.9 startup.m
--- startup.m 25 Apr 2005 06:51:58 -0000 1.9
+++ startup.m 22 Jun 2005 11:31:42 -0000
@@ -9,9 +9,10 @@
% Authors: conway, zs.
%
% This module contains the code for turning the raw list of nodes read in by
-% read_profile.m into the data structure that server.m needs to service
+% read_profile.m into the data structure that mdprof_cgi.m needs to service
% requests for web pages. The algorithm it implements is documented in the
% deep profiling paper.
+%-----------------------------------------------------------------------------%
:- module startup.
@@ -24,11 +25,14 @@
:- import_module list.
:- import_module std_util.
+%-----------------------------------------------------------------------------%
+
:- pred read_and_startup(string::in, list(string)::in, bool::in,
maybe(io__output_stream)::in, list(string)::in, maybe_error(deep)::out,
io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
@@ -46,13 +50,14 @@
:- import_module map.
:- import_module require.
:- import_module set.
-:- import_module std_util.
:- import_module string.
:- import_module svarray.
:- import_module svmap.
% :- import_module unsafe.
+%-----------------------------------------------------------------------------%
+
read_and_startup(Machine, DataFileNames, Canonical, MaybeOutputStream,
DumpStages, Res, !IO) :-
(
@@ -891,4 +896,6 @@
flush_output(OutputStream, !IO).
maybe_report_msg(no, _, !IO).
+%-----------------------------------------------------------------------------%
+:- end_module startup.
%-----------------------------------------------------------------------------%
Index: timeout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/timeout.m,v
retrieving revision 1.12
diff -u -r1.12 timeout.m
--- timeout.m 25 Apr 2005 07:55:54 -0000 1.12
+++ timeout.m 22 Jun 2005 11:34:04 -0000
@@ -20,6 +20,7 @@
% created, but we don't want the parent process after the fork to delete them
% while they are still in use by the child process. This is prevented by the
% boolean flag process_is_detached_server.
+%-----------------------------------------------------------------------------%
:- module timeout.
@@ -28,6 +29,8 @@
:- import_module bool.
:- import_module io.
+%-----------------------------------------------------------------------------%
+
% Add the given file name to the list of files to be cleaned up.
%
:- pred register_file_for_cleanup(string::in, io::di, io::uo)
@@ -79,11 +82,16 @@
%
:- pred remove_want_file(string::in, io::di, io::uo) is det.
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
:- implementation.
:- import_module int.
:- import_module string.
+%-----------------------------------------------------------------------------%
+
:- pragma foreign_decl("C",
"
#ifdef MR_DEEP_PROFILER_ENABLED
@@ -668,3 +676,7 @@
MR_fatal_error(""deep profiler not enabled"");
#endif
").
+
+%----------------------------------------------------------------------------%
+:- end_module timeout.
+%----------------------------------------------------------------------------%
Index: top_procs.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/top_procs.m,v
retrieving revision 1.2
diff -u -r1.2 top_procs.m
--- top_procs.m 24 Mar 2005 01:10:28 -0000 1.2
+++ top_procs.m 22 Jun 2005 11:37:55 -0000
@@ -10,6 +10,7 @@
%
% For comparisons on costs, we sort highest first. For comparisons on names and
% contexts, we sort lowest first. This is consistently what users want.
+%-----------------------------------------------------------------------------%
:- module top_procs.
@@ -22,6 +23,8 @@
:- import_module list.
:- import_module std_util.
+%-----------------------------------------------------------------------------%
+
:- func find_top_procs(cost_kind, include_descendants, measurement_scope,
display_limit, deep) = maybe_error(list(int)).
@@ -49,6 +52,7 @@
own_prof_info::out, inherit_prof_info::out) is det.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
@@ -58,6 +62,8 @@
:- import_module int.
:- import_module require.
+%-----------------------------------------------------------------------------%
+
find_top_procs(Sort, InclDesc, Scope, Limit, Deep) = MaybeTopPSIs :-
find_top_sort_predicate(Sort, InclDesc, Scope, SortCompatible,
RawSortFunc, FilterPred),
@@ -122,8 +128,7 @@
%-----------------------------------------------------------------------------%
-:- type compare_proc_statics ==
- (func(deep, int, int) = comparison_result).
+:- type compare_proc_statics == (func(deep, int, int) = comparison_result).
:- func compare_procs_fallback(compare_proc_statics, deep, int, int)
= comparison_result.
@@ -886,4 +891,6 @@
Own = add_own_to_own(Own0, LineGroup ^ group_own),
Desc = add_inherit_to_inherit(Desc0, LineGroup ^ group_desc).
+%-----------------------------------------------------------------------------%
+:- end_module top_procs.
%-----------------------------------------------------------------------------%
Index: util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/util.m,v
retrieving revision 1.3
diff -u -r1.3 util.m
--- util.m 24 Mar 2005 01:10:28 -0000 1.3
+++ util.m 22 Jun 2005 11:39:38 -0000
@@ -6,8 +6,8 @@
%
% Authors: conway, zs.
%
-% This module defines utility predicates for both the CGI program and
-% for the server.
+% This module defines utility predicates for the CGI program.
+%-----------------------------------------------------------------------------%
:- module util.
@@ -16,6 +16,8 @@
:- import_module char.
:- import_module list.
+%-----------------------------------------------------------------------------%
+
% split(Str, Char, Pieces): splits Str into pieces at every occurrence
% of Char, and returns the pieces in order. No piece will contain Char.
% If two Chars occur in a row, split will return the empty string as
@@ -23,11 +25,16 @@
%
:- pred split(string::in, char::in, list(string)::out) is det.
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
:- implementation.
:- import_module require.
:- import_module string.
+%-----------------------------------------------------------------------------%
+
split(Str0, SplitChar, Strs) :-
string__to_char_list(Str0, Chars0),
split_2(Chars0, SplitChar, Strs).
@@ -68,3 +75,7 @@
find_split_char_2(Chars, SplitChar, [Char | BeforeRev0],
BeforeRev, After)
).
+
+%-----------------------------------------------------------------------------%
+:- end_module util.
+%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
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