mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
This patch separates the coverage annotated procedure report into two
reports, one with dynamic coverage data and one with static coverage data.
This restores the functionality of the static coverage report since my last
change, and provides access to the dynamic report via new controls only
visible to developers.
deep_profiler/query.m:
In the cmd data-type:
Rename deep_cmd_procrep_coverage constructor to
deep_cmd_static_procrep_coverage.
Add deep_cmd_procrep_dynamic_coverage.
In the preferences data-type:
Add a new field pref_developer_mode which indicates if developer-only
options are visible or not.
Add code to parse and print the new command and preference option.
deep_profiler/create_report.m:
Specialise create_procrep_coverage_report/3 into
create_{static,dynamic}_coverage_report/4.
Created a new exported function deep_get_maybe_procrep. This is useful for
getting a procedure representation from the deep data-structure in one
step.
deep_profiler/display.m:
Add a new display item, display_developer. This wraps another display
item but is only displayed when developer mode is active.
deep_profiler/display_report.m:
Add a control to the main screen that enables or disabled developer mode.
This control has been placed at the bottom of the screen so that it's out
of the way.
Put the developer controls on the main screen into their own list (there's
only one at the moment).
For now the coverage-annotated procedure representation link on a (static)
procedure's page is not a developer option. Should this be a developer
option?
Added a link to the dynamic coverage annotated procedure representation
report from the dump proc dynamic report.
Added a link to the clique dump report from the clique report, the dynamic
coverage annotated procedure representation report can be accessed
transitively through this link.
Added a link the variable use analysis report and proc static report to the
procedure report and static coverage annotated procedure representation
report.
deep_profiler/html_format.m:
Support the new display_developer item.
Refactor the item_to_html code for lists.
deep_profiler/profile.m:
Include a new field in the deep data-structure for storing coverage data
that is indexed by a proc_static_ptr. When dynamic coverage information is
used this field is populated by adding per ProcDynamic data for each static
procedure.
deep_profiler/startup.m:
Fill in the per ProcStatic coverage data when the deep profiler starts up.
deep_profiler/measurements.m:
Create a new data type static_coverage_info which represents per ProcStatic
coverage information.
Include functions that are used when calculating per ProcStatic coverage
information from per ProcDynamic coverage information.
deep_profiler/mdprof_cgi.m:
Remove rarely used command line option rather making it conform to changes
in query.m.
deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
Conform to changes in query.m.
deep_profiler/mdprof_test.m:
deep_profiler/mdprof_fb.automatic_parallelism.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
Conform to changes in create_report.
deep_profiler/array_util.m:
Add a new predicate, array_foldl3_from_1 to support propagation of coverage
information from proc dynamics to proc statics.
266 lines
9.9 KiB
Mathematica
266 lines
9.9 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=4 sw=4 et
|
|
%-----------------------------------------------------------------------------%
|
|
% Copyright (C) 2001, 2005-2006, 2008, 2010 The University of Melbourne.
|
|
% This file may only be copied under the terms of the GNU General
|
|
% Public License - see the file COPYING in the Mercury distribution.
|
|
%-----------------------------------------------------------------------------%
|
|
%
|
|
% Authors: conway, zs.
|
|
%
|
|
% This module contains utility predicates for handling arrays.
|
|
|
|
:- module array_util.
|
|
|
|
:- interface.
|
|
|
|
:- 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,
|
|
array_di, array_uo) is det.
|
|
:- mode array_foldl_from_1(pred(in, in, in, out) is det, in, in, out) is det.
|
|
|
|
% 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,
|
|
array_di, array_uo) is det.
|
|
:- mode array_foldl_from_0(pred(in, in, in, out) is det, in, in, out) is det.
|
|
|
|
% 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,
|
|
array_di, array_uo) is det.
|
|
:- mode array_foldl(in, in, pred(in, in, in, out) is det, in, in, out) is det.
|
|
|
|
% 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.
|
|
:- mode array_foldl2_from_1(pred(in, in, array_di, array_uo,
|
|
array_di, array_uo) is det,
|
|
in, array_di, array_uo, array_di, array_uo) is det.
|
|
:- mode array_foldl2_from_1(pred(in, in, array_di, array_uo, in, out) is det,
|
|
in, array_di, array_uo, in, out) is det.
|
|
:- mode array_foldl2_from_1(pred(in, in, in, out, di, uo) is det,
|
|
in, in, out, di, uo) is det.
|
|
:- mode array_foldl2_from_1(pred(in, in, in, out, in, out) is det,
|
|
in, in, out, in, out) is det.
|
|
|
|
% 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.
|
|
:- mode array_foldl2(in, in, pred(in, in,
|
|
array_di, array_uo, array_di, array_uo) is det, in,
|
|
array_di, array_uo, array_di, array_uo) is det.
|
|
:- mode array_foldl2(in, in, pred(in, in,
|
|
array_di, array_uo, in, out) is det, in,
|
|
array_di, array_uo, in, out) is det.
|
|
:- mode array_foldl2(in, in, pred(in, in, in, out, di, uo) is det, in,
|
|
in, out, di, uo) is det.
|
|
:- mode array_foldl2(in, in, pred(in, in, in, out, in, out) is det, in,
|
|
in, out, in, out) is det.
|
|
|
|
% Performs a foldl3 on all the elements of the given array, starting at
|
|
% index 1.
|
|
%
|
|
:- pred array_foldl3_from_1(pred(int, T, U, U, V, V, W, W), array(T), U, U,
|
|
V, V, W, W).
|
|
:- mode array_foldl3_from_1(pred(in, in, array_di, array_uo,
|
|
array_di, array_uo, array_di, array_uo) is det,
|
|
in, array_di, array_uo, array_di, array_uo, array_di, array_uo) is det.
|
|
|
|
% 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,
|
|
array_di, array_uo) is det.
|
|
|
|
% 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)
|
|
is det, in, array_di, array_uo, array_di, array_uo) is det.
|
|
|
|
% 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.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- pragma foreign_proc("C",
|
|
u(A::in) = (B::array_uo),
|
|
[will_not_call_mercury, thread_safe, promise_pure],
|
|
"
|
|
B = A;
|
|
").
|
|
|
|
array_foldl_from_1(P, A, !AccU) :-
|
|
array.max(A, Max),
|
|
do_array_foldl(1, Max, P, A, !AccU).
|
|
|
|
array_foldl_from_0(P, A, !AccU) :-
|
|
array.max(A, Max),
|
|
do_array_foldl(0, Max, P, A, !AccU).
|
|
|
|
array_foldl(N, Max, P, A, !AccU) :-
|
|
do_array_foldl(N, Max, P, A, !AccU).
|
|
|
|
% This clone of array_foldl exists to allow looping to take place
|
|
% within a shallow traced predicate in debug grades. This avoids
|
|
% blowing the stack with deep recursion.
|
|
%
|
|
:- pred do_array_foldl(int, int, pred(int, T, U, U), array(T), U, U).
|
|
:- mode do_array_foldl(in, in, pred(in, in, di, uo) is det, in, di, uo) is det.
|
|
:- mode do_array_foldl(in, in, pred(in, in, array_di, array_uo) is det, in,
|
|
array_di, array_uo) is det.
|
|
:- mode do_array_foldl(in, in, pred(in, in, in, out) is det, in,
|
|
in, out) is det.
|
|
|
|
do_array_foldl(N, Max, P, A, !AccU) :-
|
|
( N =< Max ->
|
|
array.lookup(A, N, E),
|
|
P(N, E, !AccU),
|
|
do_array_foldl(N + 1, Max, P, A, !AccU)
|
|
;
|
|
true
|
|
).
|
|
|
|
array_foldl2_from_1(P, A, !AccU, !AccV) :-
|
|
array.max(A, Max),
|
|
do_array_foldl2(1, Max, P, A, !AccU, !AccV).
|
|
|
|
array_foldl2(N, Max, P, A, !AccU, !AccV) :-
|
|
do_array_foldl2(N, Max, P, A, !AccU, !AccV).
|
|
|
|
% This clone of array_foldl2 exists to allow looping to take place
|
|
% within a shallow traced predicate in debug grades. This avoids
|
|
% blowing the stack with deep recursion.
|
|
%
|
|
:- pred do_array_foldl2(int, int, pred(int, T, U, U, V, V), array(T),
|
|
U, U, V, V).
|
|
:- mode do_array_foldl2(in, in, pred(in, in, di, uo, di, uo) is det, in,
|
|
di, uo, di, uo) is det.
|
|
:- mode do_array_foldl2(in, in, pred(in, in,
|
|
array_di, array_uo, array_di, array_uo) is det, in,
|
|
array_di, array_uo, array_di, array_uo) is det.
|
|
:- mode do_array_foldl2(in, in, pred(in, in,
|
|
array_di, array_uo, in, out) is det, in,
|
|
array_di, array_uo, in, out) is det.
|
|
:- mode do_array_foldl2(in, in, pred(in, in, in, out, di, uo) is det, in,
|
|
in, out, di, uo) is det.
|
|
:- mode do_array_foldl2(in, in, pred(in, in, in, out, in, out) is det, in,
|
|
in, out, in, out) is det.
|
|
|
|
do_array_foldl2(N, Max, P, A, !AccU, !AccV) :-
|
|
( N =< Max ->
|
|
array.lookup(A, N, E),
|
|
P(N, E, !AccU, !AccV),
|
|
do_array_foldl2(N + 1, Max, P, A, !AccU, !AccV)
|
|
;
|
|
true
|
|
).
|
|
|
|
%----------------------------------------------------------------------------%
|
|
|
|
array_foldl3_from_1(P, Array, !A, !B, !C) :-
|
|
array.max(Array, Max),
|
|
do_array_foldl3(1, Max, P, Array, !A, !B, !C).
|
|
|
|
:- pred do_array_foldl3(int, int, pred(int, T, U, U, V, V, W, W), array(T),
|
|
U, U, V, V, W, W).
|
|
:- mode do_array_foldl3(in, in, pred(in, in, array_di, array_uo,
|
|
array_di, array_uo, array_di, array_uo) is det, in,
|
|
array_di, array_uo, array_di, array_uo, array_di, array_uo) is det.
|
|
|
|
do_array_foldl3(N, Max, P, Array, !A, !B, !C) :-
|
|
( N =< Max ->
|
|
array.lookup(Array, N, E),
|
|
P(N, E, !A, !B, !C),
|
|
do_array_foldl3(N + 1, Max, P, Array, !A, !B, !C)
|
|
;
|
|
true
|
|
).
|
|
|
|
%----------------------------------------------------------------------------%
|
|
|
|
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, !Array) :-
|
|
( N >= Size ->
|
|
true
|
|
;
|
|
array.lookup(!.Array, N, OldElem),
|
|
Closure(OldElem, NewElem),
|
|
array.set(!.Array, N, NewElem, !:Array),
|
|
array_map(N + 1, Size, Closure, !Array)
|
|
).
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
:- end_module array_util.
|
|
%-----------------------------------------------------------------------------%
|