mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-17 06:47:17 +00:00
Add a mechanism for collecting information about how many times each event
Estimated hours taken: 8 Branches: main Add a mechanism for collecting information about how many times each event is executed. Later changes will exploit this information, for coverage testing and for better search strategies in the declarative debugger. runtime/mercury_stack_layout.h: Extend the module layout structure to contain a pointer to an array of counters, with one counter for each label layout structure corresponding an event. Extend label layout structures to contain the label's index into this array. The new field fits into a hole in the existing structure required by alignment considerations, so the size of label layout structures is unaffected. The memory cost of the new facility is thus only one word per event. Extend the macros for defining label layout structures to take an extra argument for the new field. runtime/mercury_grade.m: Update the binary compatibility version number for debug grades, since runtimes before this change and the compiler-generated C files in debug grades from after this change are not compatible, and neither are runtimes after this change and the compiler-generated C files in debug grades from before this change. runtime/mercury_trace_base.[ch]: Add a third alternative function to call from MR_trace; besides MR_trace_real (in the trace directory) and MR_trace_fake (in this module), add MR_trace_count, which returns after incrementing the counter of the event's label layout structure. Instead of a single variable, MR_trace_enabled, controlling whether MR_trace is enabled or not and debugging is enabled or not, use two separate variables: MR_trace_func_enabled controlling whether MR_trace is enabled or not, and MR_debug_enabled controlling whether debugging is enabled or not. MR_trace_func_enabled is always set to the disjunction of MR_debug_enabled and a new variable MR_trace_count_enabled, the variable controlling whether the facility for counting label executions is enabled. Add a function for writing out the gathered execution counts. runtime/mercury_trace_base.[ch]: trace/mercury_trace_tables.[ch]: Move the table of module_infos from mercury_trace_tables to mercury_trace_base, since the code to write out execution counts needs it. runtime/mercury_wrapper.c: When MERCURY_OPTIONS contains --trace-count and debugging is not, enable the mechanism for counting the execution of events, and write out the results. library/exception.m: library/io.m: library/table_builtin.m: runtime/mercury_tabling_preds.h: trace/mercury_trace_declarative.c: trace/mercury_trace_external.c: trace/mercury_trace_vars.c: Conform to the changes involving the replacement of MR_trace_enabled. tools/bootcheck: Add an new option, --trace-count, for enabling the new mechanism. compiler/layout.m: Change the compiler's data structures for label layouts and module layouts to conform to the changes in mercury_stack_layout.h. compiler/layout_out.m: Update the code for writing out label layouts and module layouts. compiler/stack_layout.m: Allocate slots in the execution count array to the label layout structures of all events. Delete the unnecessary last arguments of `get' field access predicates. compiler/llds_out.m: compiler/opt_debug.m: Conform to the changes in layout.m.
This commit is contained in:
@@ -531,6 +531,11 @@ dump_layout_name(module_layout_proc_vector(ModuleName), Str) :-
|
||||
ModuleNameStr = sym_name_mangle(ModuleName),
|
||||
string__append_list(["module_layout_proc_vector(", ModuleNameStr, ")"],
|
||||
Str).
|
||||
dump_layout_name(module_layout_label_exec_count(ModuleName, NumLabels), Str) :-
|
||||
ModuleNameStr = sym_name_mangle(ModuleName),
|
||||
NumLabelsStr = int_to_string(NumLabels),
|
||||
string__append_list(["module_layout_label_exec_count(",
|
||||
ModuleNameStr, ", ", NumLabelsStr, ")"], Str).
|
||||
dump_layout_name(module_layout(ModuleName), Str) :-
|
||||
ModuleNameStr = sym_name_mangle(ModuleName),
|
||||
string__append_list(["module_layout(", ModuleNameStr, ")"], Str).
|
||||
|
||||
Reference in New Issue
Block a user