Estimated hours taken: 30
Branches: main
Make tabling statistics much more useful, and avoid core dumps while printing
them (thereby fixing bug #23 in Mantis).
runtime/mercury_tabling.h:
Expand the set of statistics we can gather about tabling (starting
to gather information about memory consumption).
Put the statistics into logical groups: enum functors, non-enum
du functors, hash tables, and the expandable table used for I/O
tabling. For du types and polymorphic types, we can gather different
statistics for different parts of a term. We used to use one field
to gather more than one related kind of count, but these are now
separated.
Group the MR_ProcTableInfo struct fields relating to statistics
into substructures. The substructures describing a call or answer
table have their own substructures giving the statistics about the
individual steps; put these in parallel with the descriptions of the
steps themselves.
Put those substructures into two-element arrays to allow them
to be handled uniformly.
runtime/mercury_types.h:
Add the typedefs needed by mercury_tabling.h.
runtime/mercury_tabling_macros.h:
Conform to the modified classification of tabling categories.
runtime/mercury_tabling.c:
runtime/mercury_hash_lookup_or_add_body.h:
runtime/mercury_table_int_fix_index_body.h:
runtime/mercury_table_int_start_index_body.h:
runtime/mercury_table_type_body.h:
runtime/mercury_tabling_stats_defs.h:
runtime/mercury_tabling_stats_nodefs.h:
runtime/mercury_tabling_stats_undefs.h:
Gather the modified and expanded set of statistics.
Use more meaningful names (with MR_ prefixes) for macros.
library/table_builtin.m:
library/table_statistics.m:
Move the material relating to statistics that used to be in
table_builtin.m to the new module table_statistics.m. This is
necessary because table_builtin.m is deliberately not included
in the library documentation, yet users needs to know how to
print out and interpret tabling statistics.
Expand the code for handling statistics, adding predicates for printing
them together with (hopefully explanatory) labels.
Make it all work with the new runtime data structures.
library/library.m:
Include the new library module.
mdbcomp/prim_data.m:
Provide a way to refer to the tabling statistics module.
compiler/hlds_pred.m:
Add utility function to compute the kind of statistics we gather
for a given kind of tabling step.
compiler/rtti.m:
Change the compiler's representation of tabling's runtime data
structures to conform to the change to runtime/mercury_tabling.h.
Replace a bool with a purpose-designed type (is_array),
and add other similar types (call_or_answer_table, curr_or_prev_table).
compiler/rtti_out.m:
compiler/llds_out.m:
Output the updated data structures.
compiler/ml_code_gen.m:
Generate the updated data structures.
compiler/table_gen.m:
Update the C code we generate to gather statistics.
Gather the extra information needed by the updated data structures
in the compiler (to fill in the updated data structures in the
runtime).
compiler/mlds.m:
Add a new kind of constant, one that has just a name. This allows
ml_code_gen.m to avoid lying about the type of constants of enum tyes
(such as the kind of tabling stats we gather for a step).
compiler/modules.m:
Import the new table_statistics module automatically if any tabling
pragma asks for statistics.
compiler/add_pragma.m:
compiler/hlds_out.m:
compiler/llds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
trace/mercury_trace_cmd_developer.c:
Conform to the changes above.
tests/tabling/fib_stats.{m,exp}:
tests/tabling/specified_stats.{m,exp}:
New test cases to the test tabling statistics.
tests/tabling/Mmakefile:
Enable the new test cases.
tests/tabling/fib.m:
tests/tabling/specified.m:
Clean up the code of these test cases, which were used as the basis
of the new test cases.