mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-18 15:26:31 +00:00
faa18a15bd332b51ec6d6fdae4d999ec2bf3fa82
73 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9d8ca0ad37 |
Remove residual parts of the Aditi backend that weren't deleted the other day.
Estimated hours taken: 1.5 Branches: main Remove residual parts of the Aditi backend that weren't deleted the other day. configure.in: Mmake.common.in: Remove support for enabling the Aditi backend. runtime/mercury_aditi.h: Remove this file. runtime/Mmakefile: runtime/mercury.h: runtime/mercury_imp.h: runtime/mercury_ho_call.[ch]: runtime/mercury_wrapper.[ch]: Delete support for Aditi in the runtime. scripts/Mmake.rules: scripts/Mmake.vars.in: scripts/c2init.in: scripts/parse_ml_options.sh-subr.in: Remove mmake support for building .rlo files, etc. util/mkinit.c: Remove Aditi specific code. compiler/bytecode_data.m: compiler/closure_analysis.m: compiler/code_model.m: compiler/compile_target_code.m: compiler/det_analysis.m: compiler/handle_options.m: compiler/hlds_goal.m: compiler/hlds_module.m: compiler/make.dependencies.m: compiler/make.m: compiler/make.module_target.m: compiler/make.program_target.m: compiler/make.util.m: compiler/make_hlds_error.m: compiler/make_hlds_passes.m: compiler/mercury_to_mercury.m: compiler/mlds_to_gcc.m: compiler/modecheck_call.m: compiler/modules.m: compiler/opt_debug.m: compiler/options.m: compiler/prog_data.m: compiler/prog_foreign.m: compiler/prog_mode.m: compiler/prog_type.m: compiler/rtti.m: compiler/rtti_out.m: compiler/rtti_to_mlds.m: compiler/term_errors.m: compiler/unify_proc.m: mdbcomp/prim_data.m: Remove residual support for Aditi. library/ops.m: Remove the 'aditi_bottom_up' and 'aditi_top_down' operators from the ops table. doc/reference_manual.texi: doc/user_guide.texi: Delete the sections on the Aditi interface. extras/aditi/*: Delete this. |
||
|
|
29c44a3e93 |
Add the initial stage of finalise declarations.
Estimated hours taken: 2 Branches: main Add the initial stage of finalise declarations. These are a counterpart to the recently added intialise declarations; they allow the user to specify predicates that are to be run after main/2 exits. util/mkinit.c: Add support for `REQUIRED_FINAL' directives. These are similar to `REQUIRED_INIT' directives except that the specified functions are run after main/2. Any functions specified using this directive are gathered into bunches and called from the final_module_required function. runtime/mercury_wrapper.h: runtime/mercury_wrapper.c: Export a new global that points to the final_module_required function for the program. |
||
|
|
99293279e6 |
This is step 1 of eliminating the arguments of the type_ctor_info, type_info,
Estimated hours taken: 8 Branches: main This is step 1 of eliminating the arguments of the type_ctor_info, type_info, base_typeclass_info and typeclass_info type constructors. This step doesn't delete those arity-1 type constructors yet; that will be done in step 2. This delay due to bootstrapping issues: installed compilers still generate references to those type constructors. However, after this change, compilers will instead generate references to arity-0 versions of those types named zero_type_ctor_info, zero_type_info, zero_base_typeclass_info and zero_typeclass_info. library/private_builtin.m: Add the new type constructors. For each predicate that operates on the old arity-1 type constructors, add a version that operates on the new type arity-0 onstructors, and whose implementation is identical. runtime/mercury_builtin_types.m: Add the unify and compare predicates of the new type constructors. runtime/mercury_wrapper.[ch]: runtime/mercury_init.h: util/mkinit.c: Change the C type of the variable that holds the types of type_infos and pseudo_type_infos, since their representation is now simpler (no dummy argument). trace/mercury_trace_vars.c: Modify data structures that recognize the four old types to recognize their new variants as well. compiler/higher_order.m: compiler/polymorphism.m: Generate references to the new versions of predicates that manipulate type_infos and typeclass_infos. compiler/hlds_pred.m: compiler/ml_code_util.m: compiler/type_ctor_info.m: Modify predicates that recognize the four old types to recognize their new variants as well. compiler/type_util.m: Modify the predicates that construct the types of type_infos to create references to the new arity-0 type constructors. Modify predicates that recognize the four old types to recognize their new variants as well. Delete the predicate whose job was to replace the dummy arguments of the arity-1 type constructors with the void type, since it is not needed anymore. Delete the unused predicate cell_type_name. compiler/stack_layout.m: Fix comment. compiler/size_prof.m: Conform to the changes in type_util. compiler/pseudo_type_info.m: Conform to the changes in type_util. Convert to four-space indentation. |
||
|
|
1ed891b7b1 |
Introduce a mechanism for extending the det and nondet stacks when needed.
Estimated hours taken: 24
Branches: main
Introduce a mechanism for extending the det and nondet stacks when needed.
The mechanism takes the form of a new grade component, .exts ("extend stacks").
While the new mechanism may be useful in its own right, it is intended mainly
to support a new implementation of minimal model tabling, which will use a
separate Mercury context for each distinct subgoal. Each context has its own
det and nondet stack. Clearly, we can't have hundreds of contexts each with
megabyte sized det stacks. The intention is that the stacks of the subgoals
will start small, and be expanded when needed.
The runtime expansion of stacks doesn't work yet, but it is unnecessarily
hard to debug without an installed compiler that understands the new grade
component, which is why this diff will be committed before that is fixed.
compiler/handle_options.m:
compiler/options.m:
runtime/mercury_grade.h:
scripts/canonical_grade.sh-subr
scripts/init_grade_options.sh-subr
scripts/parse_grade_options.sh-subr
scripts/mgnuc.in
Handle the new grade component.
runtime/mercury_memory_zones.h:
Add MR_ prefixes to the names of the fields of the zone structure.
Record not just the actual size of each zone, which includes various
kinds of buffers, but also the desired size of the zone exclusive of
buffers.
Format the documentation of the zone structure fields more
comprehensibly.
runtime/mercury_memory_zones.c:
Instead of implementing memalign if it is not provided by the operating
system, implement a function that allows us to reallocate the returned
area of memory.
Provide a prototype implementation of memory zone extension. It doesn't
work yet.
Factor out the code for setting up redzones, since it is now needed
in more than place.
Convert to four space indentation.
Make the debugging functions a bit more flexible.
runtime/mercury_wrapper.c:
Conform to the improved interface of the debugging functions.
runtime/mercury_overflow.h:
runtime/mercury_std.h:
Move a generally useful macro from mercury_overflow.h to mercury_std.h.
runtime/mercury_stacks.c:
Add functions to extend the stacks.
runtime/mercury_stacks.h:
Add the tests required to invoke the functions that extend the stacks.
Add the macros needed by the change to compiler/llds.m.
Convert to four space indentation.
runtime/mercury_conf.h.in:
Prepare for the use of the posix_memalign function, which is the
current replacement of the obsolete memalign library function.
We don't yet use it.
runtime/mercury_context.h:
Format the documentation of the context structure fields more
comprehensibly.
Put MR_ prefixes on the names of the fields of some structures
that didn't previously have them.
Conform to the new names of the fields of the zone structure.
runtime/mercury_context.c:
runtime/mercury_debug.c:
runtime/mercury_deep_copy.c:
runtime/mercury_engine.c:
runtime/mercury_memory_handlers.c:
library/benchmarking.m:
library/exception.m:
Conform to the new names of the fields of the zone structure.
In some cases, add missing MR_ prefixes to function names
and/or convert to four space indentation.
runtime/mercury_engine.h:
Add a new low level debug flag for debugging stack extensions.
Format the documentation of the engine structure fields more
comprehensibly.
Convert to four space indentation.
runtime/mercury_conf_param.h:
Document a new low level debug flag for debugging stack extensions.
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/options.m:
Handle the new grade component.
compiler/llds.m:
Add two new kinds of LLDS instructions, save_maxfr and restore_maxfr.
These are needed because the nondet stack may be relocated between
saving and the restoring of maxfr, and the saved maxfr may point to
the old stack. In .exts grades, these instructions will save not a
pointer but the offset of maxfr from the start of the nondet stack,
since offsets are not affected by the movement of the nondet stack.
compiler/code_info.m:
Use the new instructions where relevant. (Some more work may be
needed on this score; the relevant places are marked with XXX.)
compiler/dupelim.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/reassign.m:
compiler/use_local_vars.m:
Handle the new LLDS instructions.
tools/bootcheck:
Provide a mechanism for setting the initial stack sizes for a
bootcheck.
|
||
|
|
88b75863dc |
Add support for initialisation predicates to be called before main/2 is
Estimated hours taken: 16 Branches: main Add support for initialisation predicates to be called before main/2 is invoked. The new directive is `:- initialise initpredname.' NEWS: Mention the new functionality. compiler/export.m: `:- pragma export' also adds a C function declaration in the generated C wrapper code to avoid C compiler warnings about missing declarations. compiler/hlds_module.m: Added a new user_init_preds field to the module_info to record the preds named in `initialise' directives. Added predicates to access and update the new field. The exported names are generated automatically. compiler/llds.m: Added a new field cfile_num_user_inits to c_file structure. compiler/llds_out.m: Add code to include the `REQUIRED_INIT initpredexportname' lines in the comment section of the generated C that is recognised by mkinit. compiler/make_hlds_passes.m: Handle the new `initialise' directives. compiler/mercury_compile.m: Make sure the list of user defined init pred export names is passed to the C code construction preds. compiler/mercury_to_mercury.m: Handle the output of `initialise' directives. compiler/module_qual.m: compiler/modules.m: compiler/recompilation.check.m: compiler/recompilation.version.m: Handle the new `initialise' item. compiler/prog_data.m: Add a new `initialise(sym_name)' item. compiler/prog_io.m: Add code to parse `initialise' directives. compiler/prog_mode.m: Add di_mode pred and func. compiler/transform_llds.m: Handle the extra field in c_file. doc/reference_manual.texi: Update the operator table in the reference manual. Document the new `initialise' directive. library/list.m: Added index[01]_of_first_occurrence preds and det_index[01]_of_first_occurrence funcs. I've often had a need for these and they are used in looking up initprednames in the new module_info field. library/ops.m: Add `initialise' as a prefix operator. runtime/mercury_wrapper.c: runtime/mercury_wrapper.h: Add a new exported variable, MR_address_of_init_modules_required. Call the function pointed to by this variable at the right point during module initialisation. test/hard_coded/Mmakefile: test/hard_coded/initialise_decl.exp: test/hard_coded/initialise_decl.m: test/invalid/Mmakefile: test/invalid/bad_initialise_decl.err_exp: test/invalid/bad_initialise_decl.m: Added test cases. util/mkinit.c: Now always checks C files for extra inits (previously you had to explicitly supply the -x flag). |
||
|
|
db00e2afa6 |
Provide a mechanism to shut up progress messages from the declarative debugger
Estimated hours taken: 1 Branches: main Provide a mechanism to shut up progress messages from the declarative debugger for use in bootchecks, to remove a potential source of spurious test case failures. runtime/mercury_wrapper.[ch]: Add a new global, MR_mdb_decl_print_progress, that controls whether we print progress messages. Disable it if the new option --mdb-disable-progress is given. tools/bootcheck: Set the new option. trace/mercury_trace_declarative.c: Obey MR_mdb_decl_print_progress. Fix a bunch of departures from our coding standards. |
||
|
|
86ac840326 |
Implement a mechanism to generate the information required to determine the
Estimated hours taken: weeks Branches: main Implement a mechanism to generate the information required to determine the algorithmic complexity of selected procedures. The basis of the mechanism is a program transformation that wraps up the body of each selected procedure in code that detects top-level (non-recursive) calls, and for each top-level call, records the sizes of the input arguments and information about the cost of the call. For now, the cost information consists only of the number of cells and words allocated during the call, but there is provision for later adding information from a real-time clock. compiler/complexity.m: A new module containing the new transformation. compiler/transform_hlds.m: Add complexity.m to the list of submodules. compiler/mercury_compile.m: Invoke the new module. compiler/notes/compiler_design.html: Mention the new module. compiler/options.m: Add an option, --experimental-complexity. Its argument is a filename that specifies the list of procedures to transform. Add an option, --no-allow-inlining, to disallow all inlining. This is simpler to use than specifying several options to turn off each potential reason to inline procedures. doc/user_guide.texi: Document the new options. The documentation present now is only a shell; it will be expanded later. compiler/table_gen.m: compiler/goal_util.m: Move the predicate for creating renamings from table_gen.m to goal_util.m, since complexity.m also needs it now. In the process, make it more general by allowing outputs to have more complex modes than simply `out'. compiler/goal_util.m: Fix a bug exposed by the new transformation: when renaming goals (e.g. for quantification), rename the variables holding information about term sizes. compiler/handle_options.m: Disable inlining if experimental complexity analysis is enabled. compiler/compile_target_code.m: Pass the --experimental-complexity option on to the linker. library/term_size_prof_builtin.m: Add the Mercury predicates that serve as interfaces to the primitives needed by the experimental complexity transformation. runtime/mercury_term_size.[ch]: Add the implementations of the primitives needed by the experimental complexity transformation. runtime/mercury_wrapper.[ch]: Add global variables holding counters of the numbers of words and cells allocated so far. runtime/mercury_heap.h: Update these global variables when allocating memory. runtime/mercury_complexity.h: New file that contains the definition of the data structures holding the data collected by the experimental complexity transformation. This is separate from mercury_term_size.h, because it needs to be #included in mercury_init.h, the header file of the mkinit-generated <program>_init.c files. runtime/mercury_init.h: runtime/mercury_imp.h: #include mercury_complexity.h. util/mkinit.c: Define and initialize the data structures holding complexity information when given the -X option (mkinit doesn't have long options). Fix some deviations from our coding style. scripts/parse_ml_options.sh-subr.in: Accept the --experiment-complexity option. scripts/c2init.in: Pass the --experiment-complexity option on to mkinit.c. tools/bootcheck: Preserve the files containing the results of complexity analysis, if they exist. tools/makebatch: Allow the specification of EXTRA_MLFLAGS in the generated Mmake.stage.params files. |
||
|
|
e4da5e1c94 |
Fix performance problems in the compiler when handling automatically generated
Estimated hours taken: 10 Branches: main Fix performance problems in the compiler when handling automatically generated code (specifically, code generated by caribou). These depend on new facilities in the library. Fix a problem with the debugger: get the debugger to stop when given an interrupt signal. (I needed this fix to find the performance problems above.) The problem was that the variable set by the interrupt handler wasn't the right one. library/map.m: The map__overlay predicate takes time linear in the new map. However, sometimes the compiler wants to overlay a large map on a small one. Add a new version, map__overlay_large_map, which does the same job but whose complexity is linear in the size of the old map. library/set.m: library/set__ordlist.m: Add a new version of set__divide specialized to a situation that occurs in some performance-critical code in the compiler. This lowers the complexity from quadratic to linear. library/bag.m: Add predicates for operating on sets alongside for predicates for operating on lists. These should be able to exploit the sortedness of the set, although we don't do so yet. library/svbag.m: Add this new module to make some of the changes to the compiler easier. library/library.m: NEWS: Mention the new module. compiler/instmap.m: Use either map__overlay or map__overlay_large_map, depending on which one is likely to be more efficient. compiler/deforest.m: compiler/goal_util.m: compiler/mode_util.m: compiler/simplify.m: compiler/table_gen.m: Conform to the changes in instmap.m. compiler/liveness.m: Use the specialized version of set__divide. compiler/mode_info.m: The original representation of liveness information in the mode analyzer had a fast insert operation, but a slow delete operation and a lookup operation that is *very* slow when analyzing long conjunctions. Replace that representation with a more direct and more compact representation with slower insert operation but much faster lookup operation and significantly faster delete operation. compiler/modes.m: compiler/unique_modes.m: Conform to the changes in mode_info.m. trace/mercury_trace.c: Make the debugger's interrupt handler set the variable actually used by MR_trace to select which function to call. runtime/mercury_trace_base.[ch]: Make MR_selected_trace_func_ptr volatile, since it is now set from an interrupt handler. runtime/mercury_wrapper.[ch]: Make MR_trace_handler non-volatile, since it is no longer set from an interrupt handler. Change its name to MR_exec_trace_handler to reflect the fact that it is not the only trace handler. util/mkinit.c: Refer to MR_trace_handler by its new name. |
||
|
|
abc7d6b22b |
Add two runtime options useful in benchmarking I/O tabling.
Estimated hours taken: 2 Branches: main Add two runtime options useful in benchmarking I/O tabling. runtime/mercury_wrapper.[ch]: Recognize the two new runtime options, and implement the first: When --mem-usage-report is included in MERCURY_OPTIONS, write a report on the memory usage of the program when the program exits. trace/mercury_trace_internal.c: Implement the other option, --mdb-benchmark-silent. When this option is given, the debugger will generate no output to stdout (and neither will the program). This is to avoid mixing prompts (e.g. "mdb>" with the timing data output by tools/speedtest, allowing the output of tools/speedtest to be processed automatically. doc/user_guide.texi: Document the new options, with the documentation of --mdb-benchmark-silent being for developers only. Fix a documentation bug on an existing option. |
||
|
|
941be20e27 |
Type_desc__get_functor looks up the types of the arguments of a function
Estimated hours taken: 16
Branches: main
Type_desc__get_functor looks up the types of the arguments of a function
symbol. This predicate used to abort when an argument has an existential
type. This diff makes type_desc__get_functor work even in that case.
However, since in such cases the type of an argument is not a ground type,
this diff has to add the concept of a pseudo_type_desc, a descriptor for
a not necessarily ground type. Pseudo_type_descs are implemented as
MR_PseudoTypeInfos.
runtime/mercury_type_info.[ch]:
Add new macros to operate on pseudo_type_infos. Most have a structure
modelled on corresponding macros operating on type_infos.
Provide versions of MR_get_arg_type_info, MR_compare_type_info,
MR_unify_type_info, MR_collapse_equivalences,
MR_type_params_vector_to_list, MR_create_type_info and
MR_create_type_info_maybe_existq that work on pseudo_type_infos,
not type_infos.
Change MR_pseudo_type_info_vector_to_type_info_list, which implements
the core of get_functor, to return pseudo_type_infos instead of
type_infos, and rename it to reflect this fact.
Change to four-space indentation to reduce the number of lines
that have to be wrapped.
runtime/mercury_make_type_info_body.h:
Generalize the code for creating type_infos to also be handle
pseudo_type_infos.
Change to four-space indentation to reduce the number of lines
that have to be wrapped.
runtime/mercury_type_desc.[ch]:
Provide versions of MR_make_type_ctor_desc and MR_type_ctor_and_args
that work on pseudo_type_infos, not type_infos.
Change to four-space indentation to reduce the number of lines
that have to be wrapped.
runtime/mercury_builtin_types.[ch]:
runtime/mercury_builtin_types_proc_layouts.h:
runtime/mercury_hlc_types.h:
runtime/mercury_unify_compare_body.h:
Add the C types, global variables and functions necessary for the
new builtin Mercury type pseudo_type_desc. This type must be builtin,
because its structure (MR_PseudoTypeInfo) is defined in C, and as such
cannot be unified, compared, deconstructed etc without hand-written
C code.
runtime/mercury_deep_copy.c:
runtime/mercury_deep_copy_body.h:
Handle the copying of pseudo_type_infos/pseudo_type_descs. This code
is almost the same as the code to copy type_infos, but must of course
handle type variables, and the arguments are themselves copied as
pseudo_type_infos, not type_infos.
runtime/mercury_types.h:
Since deep copy needs to create pseudo_type_infos, provide a version
of the MR_PseudoTypeInfo type without const.
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
Handle pseudo_type_descs just as we handle type_descs: neither can be
constructed, nor do they have function symbols with named arguments.
runtime/mercury_ml_expand_body.c:
Provide code to deconstruct pseudo_type_descs. This code is almost
the same as the code to deconstruct type_descs, but must of course
handle type variables, and the arguments are themselves
pseudo_type_descs, not type_descs.
runtime/mercury_tabling.c:
Catch attempts to table pseudo_type_infos.
runtime/mercury_tags.h:
Add macros for constructing lists of
pseudo_type_infos/pseudo_type_descs.
runtime/mercury_wrapper.[ch]:
Define global variables holding the addresses of the typeinfos for
describing pseudo_type_descs and lists of pseudo_type_descs.
runtime/mercury_init.c:
Add the extern declarations required by new code in mkinit.c.
util/mkinit.c:
Make the addresses of the typeinfos for describing pseudo_type_descs
and lists of pseudo_type_descs, defined in the library, known to the
runtime.
library/type_desc.m:
Add a new builtin type, pseudo_type_desc, for describing possibly
nonground types.
Add utility predicates for operating on pseudo_type_descs.
library/private_builtin.m:
Handle the new builtin type.
Add builtin typeinfos for describing pseudo_type_descs and lists of
pseudo_type_descs, since some functions in the runtime need them
for memory profiling.
library/rtti_implementation.m:
Handle the new builtin type, mostly by ignoring it, since the backends
that use this module do not have any notion of pseudo_type_infos.
Bring the module up to date with our formatting guidelines.
library/construct.m:
Make get_functor return a list of pseudo_type_descs instead of
type_descs.
Change the name of the version of get_functor that returns argument
names, to distinguish it from the base version by more than just the
arity.
Make the order of predicates more logical.
library/std_util.m:
Change the name of the version of get_functor that returns argument
names, to distinguish it from the base version by more than just the
arity.
However, this name change is effectively the only change: both
get_functor and get_functor_with_names still return lists of
type_descs. This means that they will throw exceptions in the presence
of existential types, but code using them need no algorithmic changes.
library/term.m:
library/term_to_xml.m:
Add module qualifiers as necessary; no algorithmic changes.
library/list.m:
Add two general-purpose predicates, all_true and all_false,
for use in the other library modules.
compiler/ml_util.m:
compiler/mlds_to_gcc.m:
compiler/rtti.m:
compiler/type_ctor_info.m:
Make sure we handle the new builtin type as a builtin type, and not
try to have the compiler create a type_ctor_info for it.
deep_profiler/canonical.m:
Delete the local definition of all_true.
tests/hard_coded/construct_test.{m,exp}:
Update this test case to test the ability to retrieve the names of the
fields of function symbols with existential types.
Add module qualifications as necessary.
tests/hard_coded/construct_test_exist.{m,exp}:
Add a tougher test case to print the types of the arguments of
function symbols with existential types.
tests/hard_coded/Mmakefile:
Add the new test case, and sort the names of the tests.
|
||
|
|
e854a5f9d9 |
Major improvements to tabling, of two types.
Estimated hours taken: 32
Branches: main
Major improvements to tabling, of two types. The first is the implementation
of the loopcheck and memo forms of tabling for model_non procedures, and the
second is a start on the implementation of a new method of implementing
minimal model tabling, one that has the potential for a proper fix of the
problem that we currently merely detect with the pneg stack (the detection
is followed by a runtime abort). Since this new method relies on giving each
own generator its own stack, the grade component denoting it is "mmos"
(minimal model own stack). The true name of the existing method is changed
from "mm" to "mmsc" (minimal model stack copy). The grade component "mm"
is now a shorthand for "mmsc"; when the new method works, "mm" will be changed
to be a shorthand for "mmos".
configure.in:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/final_grade_options.sh-subr:
compiler/options.m:
Handle the new way of handling minimal model grades.
scripts/mgnuc.in:
compiler/compile_target_code.m:
Conform to the changes in minimal model grade options.
compiler/table_gen.m:
Implement the transformations required by the loopcheck and memo
tabling of model_non procedures, and the minimal model own stack
transformation.
The new implementation transformations use foreign_procs with extra
args, since there is no point in implementing them both that way and
with separate calls to library predicates. This required making the
choice of which method to use at the top level of each transformation.
Fix an oversight that hasn't caused problems yet but may in the future:
mark goals wrapping the original goals as not impure for determinism
computations.
compiler/handle_options.m:
Handle the new arrangement of the options for minimal model tabling.
Detect simultaneous calls for both forms of minimal model tabling,
and generate an error message. Allow for more than one error message
generated at once; report them all once rather than separately.
compiler/globals.m:
Add a mechanism to allow a fix a problem detected by the changes
to handle_options: the fact that we currently may generate a usage
message more than once for invocations with more than one error.
compiler/mercury_compile.m:
compiler/make.program_target.m:
compiler/make.util.m:
Use the new mechanism in handle_options to avoid generating duplicate
usage messages.
compiler/error_util.m:
Add a utility predicate for use by handle_options.
compiler/hlds_pred.m:
Allow memo tabling for model_non predicates, and handle own stack
tabling.
compiler/hlds_out.m:
Print information about the modes of the arguments of foreign_procs,
since this is useful in debugging transformations such as tabling
that generate them.
compiler/prog_data.m:
compiler/layout_out.m:
compiler/prog_out.m:
runtime/mercury_stack_layout.h:
Mention the new evaluation method.
compiler/goal_util.m:
Change the predicates for creating calls and foreign_procs to allow
more than one goal feature to be attached to the new goal. table_gen.m
now uses this capability.
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/polymorphism.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/typecheck.m:
compiler/unify_proc.m:
Conform to the changes in goal_util.
compiler/code_info.m:
compiler/make_hlds.m:
compiler/modules.m:
compiler/prog_io_pragma.m:
Conform to the new the options controlling minimal model
tabling.
compiler/prog_util.m:
Add a utility predicate for use by table_gen.m.
library/std_util.m:
Conform to the changes in the macros for minimal model tabling grades.
library/table_builtin.m:
Add the types and predicates required by the new transformations.
Delete an obsolete comment.
runtime/mercury_grade.h:
Handle the new minimal model grade component.
runtime/mercury_conf_param.h:
List macros controlling minimal model grades.
runtime/mercury_tabling.[ch]:
Define the types needed by the new transformations,
Implement the performance-critical predicates that need to be
hand-written for memo tabling of model_non predicates.
Add utility predicates for debugging.
runtime/mercury_tabling_preds.h:
Add the implementations of the predicates required by the new
transformations.
runtime/mercury_mm_own_stacks.[ch]:
This new module contains the first draft of the implementation
of the own stack implementation of minimal model tabling.
runtime/mercury_imp.h:
Include the new file if the grade needs it.
runtime/Mmakefile:
Mention the new files, and sort the lists of filenames.
runtime/mercury_tabling_macros.h:
Add a macro for allocating answer blocks without requiring them to be
pointed to directly by trie nodes.
runtime/mercury_minimal_model.[ch]:
The structure type holding answer lists is now in mercury_tabling.h,
since it is now also needed by memo tabling of model_non predicates.
It no longer has a field for an answer num, because while it is ok
to require a separate grade for debugging minimal model tabling,
it is not ok to require a separate grade for debugging memo tabling
of model_non predicates. Instead of printing the answer numbers,
print the answers themselves when we need to identify solutions
for debugging.
Change function names, macro names, error messages etc where this is
useful to distinguish the two kinds of minimal model tabling.
Fix some oversights wrt transient registers.
runtime/mercury_context.[ch]:
runtime/mercury_engine.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
With own stack tabling, each subgoal has its own context, so record
the identity of the subgoal owning a context in the context itself.
The main computation's context is the exception: it has no owner.
Record not just the main context, but also the contexts of subgoals
in the engine.
Add variables for holding the sizes of the det and nondet stacks
of the contexts of subgoals (which should in general be smaller
than the sizes of the corresponding stacks of the main context),
and initialize them as needed.
Initialize the variables holding the sizes of the gen, cut and pneg
stacks, even in grades where the stacks are not used, for safety.
Fix some out-of-date documentation, and conform to our coding
guidelines.
runtime/mercury_memory_zones.[ch]:
Add a function to test whether a pointer is in a zone, to help
debugging.
runtime/mercury_debug.[ch]:
Add some functions to help debugging in the presence of multiple
contexts, and factor out some common code to help with this.
Delete the obsolete, unused function MR_printdetslot_as_label.
runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
Move a bootstrapping #define from mercury_context.h to
mercury_bootstrap.h.
runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
Move a bootstrapping #define from mercury_context.h to
mercury_bootstrap.h.
runtime/mercury_types.h:
Add some more forward declarations of type names.
runtime/mercury_dlist.[ch]:
Rename a field to avoid assignments that dereference NULL.
runtime/mercury_debug.c:
runtime/mercury_memory.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_stacks.[ch]:
trace/mercury_trace_util.c
Update uses of the macros that control minimal model tabling.
runtime/mercury_stack_trace.c:
Provide a mechanism to allow stack traces to be suppressed entirely.
The intention is that by using this mechanism, by the testing system
won't have to provide separate .exp files for hlc grades, nondebug
LLDS grades and debug LLDS grades, as we do currently. The mechanism
is the environment variable MERCURY_SUPPRESS_STACK_TRACE.
tools/bootcheck:
tools/test_mercury:
Specify MERCURY_SUPPRESS_STACK_TRACE.
trace/mercury_trace.c:
When performing retries across tabled calls, handle memo tabled
model_non predicates, for which the call table tip variable holds
a record with a back pointer to a trie node, instead of the trie node
itself.
trace/mercury_trace_internal.c:
When printing tables, handle memo tabled model_non predicates. Delete
the code now moved to runtime/mercury_tabling.c.
Add functions for printing the data structures for own stack minimal
model tabling.
tests/debugger/print_table.{m,inp,exp}:
Update this test case to also test the printing of tables for
memo tabled model_non predicates.
tests/debugger/retry.{m,inp,exp}:
Update this test case to also test retries across memo tabled
model_non predicates.
tests/tabling/loopcheck_nondet.{m,exp}:
tests/tabling/loopcheck_nondet_non_loop.{m,exp}:
New test cases to test loopcheck tabled model_non predicates.
One test case has a loop to detect, one doesn't.
tests/tabling/memo_non.{m,exp}:
tests/tabling/tc_memo.{m,exp}:
tests/tabling/tc_memo2.{m,exp}:
New test cases to test memo tabled model_non predicates.
One test case has a loop to detect, one has a need for minimal model
tabling to detect, and the third doesn't have either.
tests/tabling/Mmakefile:
Add the new test cases, and reenable the existing tc_loop test case.
Rename some make variables and targets to make them better reflect
their meaning.
tests/tabling/test_mercury:
Conform to the change in the name of the make target.
|
||
|
|
72a1de2b8a |
Various improvements for accurate GC in LLDS grades:
Estimated hours taken: 12
Branches: main
Various improvements for accurate GC in LLDS grades:
- allow the active heap size to vary
(XXX currently we still allocate a fixed-size heap, and allow
the active heap size to vary within that; it would be better
to avoid that, by reallocating a bigger heap if the heap
fills up)
- some bug fixes.
runtime/mercury_wrapper.c:
Increase the default heap size from 4Mb to 32Mb.
This is OK because we only touch the parts of it that we use.
If accurate GC is enabled, set the other parameters
(MR_heap_redzone_size for LLDS, MR_heap_margin for MLDS)
so that initially we still only use 4Mb of the heap
before doing (the first) garbage collection.
runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
Add a new runtime option --heap-expansion-factor,
for use by mercury_accurate_gc.c.
runtime/mercury_accurate_gc.c:
Only allocate forwarding pointer bitmap entries for the part of
the heap which has been used, not the whole heap. This is to
avoid allocating (and touching) an unnecessarily large bitmap
in cases where we have allocated a large amount of address space
to the heap, but are only using a small part of it before doing
each GC.
For the LLDS back-end, recompute the heap red zone size after
each collection (using MR_heap_expansion_factor).
In MR_schedule_agc(), handle the case where entry_label and/or
proc_layout are NULL.
Also, add some comments.
runtime/mercury_memory_zones.c:
Change MR_reset_redzone() so that it can handle changes in the
size of the red zone. In particular, make sure that we unprotect
all of the normal area, as well as protecting the red zone.
runtime/mercury_label.c:
Fix two bugs in MR_prev_entry_by_addr(): it was not correctly
handling the case where the entry table was empty, and it was
not correctly handling the case where the address searched for
was higher than any address in the entry table.
runtime/mercury_goto.h:
For native GC grades, record the addresses of the end of modules
in the entry table, so that we know where each procedure finishes when
mapping from instruction pointer values to stack layout entries.
Without this, we might think that the following C function was
actually part of the preceding Mercury procedure, and then incorrectly
use the stack layout of the Mercury procedure if we happened to
get a heap overflow signal (SIGSEGV) while in that C function.
|
||
|
|
f7dae76f87 |
Remove a long unused global variable.
Estimated hours taken: 0.1 Branches: main runtime/mercury_wrapper.[ch]: Remove a long unused global variable. |
||
|
|
f007b45df8 |
Implement the infrastructure for term size profiling.
Estimated hours taken: 400
Branches: main
Implement the infrastructure for term size profiling. This means adding two
new grade components, tsw and tsc, and implementing them in the LLDS code
generator. In grades including tsw (term size words), each term is augmented
with an extra word giving the number of heap words it contains; in grades
including tsc (term size cells), each term is augmented with an extra word
giving the number of heap cells it contains. The extra word is at the start,
at offset -1, to leave almost all of the machinery for accessing the heap
unchanged.
For now, the only way to access term sizes is with a new mdb command,
"term_size <varspec>". Later, we will use term sizes in conjunction with
deep profiling to do experimental complexity analysis, but that requires
a lot more research. This diff is a necessary first step.
The implementation of term size profiling consists of three main parts:
- a source-to-source transform that computes the size of each heap cell
when it is constructed (and increments it in the rare cases when a free
argument of an existing heap cell is bound),
- a relatively small change to the code generator that reserves the extra
slot in new heap cells, and
- extensions to the facilities for creating cells from C code to record
the extra information we now need.
The diff overhauls polymorphism.m to make the source-to-source transform
possible. This overhaul includes separating type_ctor_infos and type_infos
as strictly as possible from each other, converting type_ctor_infos into
type_infos only as necessary. It also includes separating type_ctor_infos,
type_infos, base_typeclass_infos and typeclass_infos (as well as voids,
for clarity) from plain user-defined type constructors in type categorizations.
This change needs this separation because values of those four types do not
have size slots, but they ought to be treated specially in other situations
as well (e.g. by tabling).
The diff adds a new mdb command, term_size. It also replaces the proc_body
mdb command with new ways of using the existing print and browse commands
("print proc_body" and "browse proc_body") in order to make looking at
procedure bodies more controllable. This was useful in debugging the effect
of term size profiling on some test case outputs. It is not strictly tied
to term size profiling, but turns out to be difficult to disentangle.
compiler/size_prof.m:
A new module implementing the source-to-source transform.
compiler/notes/compiler_design.html:
Mention the new module.
compiler/transform_hlds.m:
Include size_prof as a submodule of transform_hlds.
compiler/mercury_compile.m:
If term size profiling is enabled, invoke its source-to-source
transform.
compiler/hlds_goal.m:
Extend construction unifications with an optional slot for recording
the size of the term if the size is a constant, or the identity of the
variable holding the size, if the size is not constant. This is
needed by the source-to-source transform.
compiler/quantification.m:
Treat the variable reference that may be in this slot as a nonlocal
variable of construction unifications, since the code generator needs
this.
compiler/compile_target_code.m:
Handle the new grade components.
compiler/options.m:
Implement the options that control term size profiling.
doc/user_guide.texi:
Document the options and grade components that control term size
profiling, and the term_size mdb command. The documentation is
commented out for now.
Modify the wording of the 'u' HLDS dump flag to include other details
of unifications (e.g. term size info) rather than just unification
categories.
Document the new alternatives of the print and browse commands. Since
they are for developers only, the documentation is commented out.
compiler/handle_options.m:
Handle the implications of term size profiling grades.
Add a -D flag value to print HLDS components relevant to HLDS
transformations.
compiler/modules.m:
Import the new builtin library module that implements the operations
needed by term size profiling automatically in term size profiling
grades.
Switch the predicate involved to use state var syntax.
compiler/prog_util.m:
Add predicates and functions that return the sym_names of the modules
needed by term size profiling.
compiler/code_info.m:
compiler/unify_gen.m:
compiler/var_locn.m:
Reserve an extra slot in heap cells and fill them in in unifications
marked by size_prof.
compiler/builtin_ops.m:
Add term_size_prof_builtin.term_size_plus as a builtin, with the same
implementation as int.+.
compiler/make_hlds.m:
Disable warnings about clauses for builtins while the change to
builtin_ops is bootstrapped.
compiler/polymorphism.m:
Export predicates that generate goals to create type_infos and
type_ctor_infos to add_to_construct.m. Rewrite their documentation
to make it more detailed.
Make orders of arguments amenable to the use of state variable syntax.
Consolidate knowledge of which type categories have builtin unify and
compare predicates in one place.
Add code to leave the types of type_ctor_infos alone: instead of
changing their types to type_info when used as arguments of other
type_infos, create a new variable of type type_info instead, and
use an unsafe_cast. This would make the HLDS closer to being type
correct, but this new code is currently commented out, for two
reasons. First, common.m is currently not smart enough to figure out
that if X and Y are equal, then similar unsafe_casts of X and Y
are also equal, and this causes the compiler do not detect some
duplicate calls it used to detect. Second, the code generators
are also not smart enough to know that if Z is an unsafe_cast of X,
then X and Z do not need separate stack slots, but can use the same
slot.
compiler/type_util.m:
Add utility predicates for returning the types of type_infos and
type_ctor_infos, for use by new code in polymorphism.m.
Move some utility predicates here from other modules, since they
are now used by more than one module.
Rename the type `builtin_type' as `type_category', to better reflect
what it does. Extend it to put the type_info, type_ctor_info,
typeclass_info, base_typeclass_info and void types into categories
of their own: treating these types as if they were a user-defined
type (which is how they used to be classified) is not always correct.
Rename the functor polymorphic_type to variable_type, since types
such as list(T) are polymorphic, but they fall into the user-defined
category. Rename user_type as user_ctor_type, since list(int) is not
wholly user-defined but falls into this category. Rename pred_type
as higher_order_type, since it also encompasses functions.
Replace code that used to check for a few of the alternatives
of this type with code that does a full switch on the type,
to ensure that they are updated if the type definition ever
changes again.
compiler/pseudo_type_info.m:
Delete a predicate whose updated implementation is now in type_util.m.
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Still treat type_infos, type_ctor_infos, typeclass_infos and
base_typeclass_infos as user-defined types, but prepare for when
they won't be.
compiler/hlds_pred.m:
Require interface typeinfo liveness when term size profiling is
enabled.
Add term_size_profiling_builtin.increase_size as a
no_type_info_builtin.
compiler/hlds_out.m:
Print the size annotations on unifications if HLDS dump flags call
for unification details. (The flag test is in the caller of the
modified predicate.)
compiler/llds.m:
Extend incr_hp instructions and data_addr_consts with optional fields
that allow the code generator to refer to N words past the start of
a static or dynamic cell. Term size profiling uses this with N=1.
compiler/llds_out.m:
When allocating memory on the heap, use the macro variants that
specify an optional offset, and specify the offset when required.
compiler/bytecode_gen.m:
compiler/dense_switch.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/goal_form.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/inst_match.m:
compiler/intermod.m:
compiler/jumpopt.m:
compiler/lambda.m:
compiler/livemap.m:
compiler/ll_pseudo_type_info.m:
compiler/lookup_switch.m:
compiler/magic_util.m:
compiler/middle_rec.m:
compiler/ml_code_util.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modecheck_unify.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/post_typecheck.m:
compiler/reassign.m:
compiler/rl.m:
compiler/rl_key.m:
compiler/special_pred.m:
compiler/stack_layout.m:
compiler/static_term.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
Minor updates to conform to the changes above.
library/term_size_prof_builtin.m:
New module containing helper predicates for term size profiling.
size_prof.m generates call to these predicates.
library/library.m:
Include the new module in the library.
doc/Mmakefile:
Do not include the term_size_prof_builtin module in the library
documentation.
library/array.m:
library/benchmarking.m:
library/construct.m:
library/deconstruct.m:
library/io.m:
library/sparse_bitset.m:
library/store.m:
library/string.m:
Replace all uses of MR_incr_hp with MR_offset_incr_hp, to ensure
that we haven't overlooked any places where offsets may need to be
specified.
Fix formatting of foreign_procs.
Use new macros defined by the runtime system when constructing
terms (which all happen to be lists) in C code. These new macros
specify the types of the cell arguments, allowing the implementation
to figure out the size of the new cell based on the sizes of its
fields.
library/private_builtin.m:
Define some constant type_info structures for use by these macros.
They cannot be defined in the runtime, since they refer to types
defined in the library (list.list and std_util.univ).
util/mkinit.c:
Make the addresses of these type_info structures available to the
runtime.
runtime/mercury_init.h:
Declare these type_info structures, for use in mkinit-generated
*_init.c files.
runtime/mercury_wrapper.[ch]:
Declare and define the variables that hold these addresses, for use
in the new macros for constructing typed lists.
Since term size profiling can refer to a memory cell by a pointer
that is offset by one word, register the extra offsets with the Boehm
collector if is being used.
Document the incompatibility of MR_HIGHTAGS and the Boehm collector.
runtime/mercury_tags.h:
Define new macros for constructing typed lists.
Provide macros for preserving the old interface presented by this file
to the extent possible. Uses of the old MR_list_cons macro will
continue to work in grades without term size profiling. In term
size profiling grades, their use will get a C compiler error.
Fix a bug caused by a missing backslash.
runtime/mercury_heap.h:
Change the basic macros for allocating new heap cells to take
an optional offset argument. If this is nonzero, the macros
increment the returned address by the given number of words.
Term size profiling specifies offset=1, reserving the extra
word at the start (which is ignored by all components of the
system except term size profiling) for holding the size of the term.
Provide macros for preserving the old interface presented by this file
to the extent possible. Since the old MR_create[123] and MR_list_cons
macros did not specify type information, they had to be changed
to take additional arguments. This affects only hand-written C code.
Call new diagnostic macros that can help debug heap allocations.
Document why the macros in this files must expand to expressions
instead of statements, evn though the latter would be preferable
(e.g. by allowing them to declare and use local variables without
depending on gcc extensions).
runtime/mercury_debug.[ch]:
Add diagnostic macros to debug heap allocations, and the functions
behind them if MR_DEBUG_HEAP_ALLOC is defined.
Update the debugging routines for hand-allocated cells to print the
values of the term size slot as well as the other slots in the relevant
grades.
runtime/mercury_string.h:
Provide some needed variants of the macro for copying strings.
runtime/mercury_deconstruct_macros.h:
runtime/mercury_type_info.c:
Supply type information when constructing terms.
runtime/mercury_deep_copy_body.h:
Preserve the term size slot when copying terms.
runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
Reduce code duplication by using a now standard macro for copying
strings.
runtime/mercury_grade.h:
Handle the two new grade components.
runtime/mercury_conf_param.h:
Document the C macros used to control the two new grade components,
as well as MR_DEBUG_HEAP_ALLOC.
Detect incompatibilities between high level code and profiling.
runtime/mercury_term_size.[ch]:
A new module to house a function to find and return term sizes
stored in heap cells.
runtime/mercury_proc_id.h:
runtime/mercury_univ.h:
New header files. mercury_proc_id.h contains the (unchanged)
definition of MR_Proc_Id, while mercury_univ.h contains the
definitions of the macros for manipulating univs that used to be
in mercury_type_info.h, updated to use the new macros for allocating
memory.
In the absence of these header files, the following circularity
would ensue:
mercury_deep_profiling.h includes mercury_stack_layout.h
- needs definition of MR_Proc_Id
mercury_stack_layout.h needs mercury_type_info.h
- needs definition of MR_PseudoTypeInfo
mercury_type_info.h needs mercury_heap.h
- needs heap allocation macros for MR_new_univ_on_hp
mercury_heap.h includes mercury_deep_profiling.h
- needs MR_current_call_site_dynamic for recording allocations
Breaking the circular dependency in two places, not just one, is to
minimize similar problems in the future.
runtime/mercury_stack_layout.h:
Delete the definition of MR_Proc_Id, which is now in mercury_proc_id.h.
runtime/mercury_type_info.h:
Delete the macros for manipulating univs, which are now in
mercury_univ.h.
runtime/Mmakefile:
Mention the new files.
runtime/mercury_imp.h:
runtime/mercury.h:
runtime/mercury_construct.c:
runtime/mercury_deep_profiling.h:
Include the new files at appropriate points.
runtime/mercury.c:
Change the names of the functions that create heap cells for
hand-written code, since the interface to hand-written code has
changed to include type information.
runtime/mercury_tabling.h:
Delete some unused macros.
runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
Use the new macros supplying type information when constructing lists.
scripts/canonical_grade_options.sh-subr:
Fix an undefined sh variable bug that could cause error messages
to come out without identifying the program they were from.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade_options.sh-subr:
scripts/mgnuc.in:
Handle the new grade components and the options controlling them.
trace/mercury_trace_internal.c:
Implement the mdb command "term_size <varspec>", which is like
"print <varspec>", but prints the size of a term instead of its value.
In non-term-size-profiling grades, it prints an error message.
Replace the "proc_body" command with optional arguments to the "print"
and "browse" commands.
doc/user_guide.tex:
Add documentation of the term_size mdb command. Since the command is
for implementors only, and works only in grades that are not yet ready
for public consumption, the documentation is commented out.
Add documentation of the new arguments of the print and browse mdb
commands. Since they are for implementors only, the documentation
is commented out.
trace/mercury_trace_vars.[ch]:
Add the functions needed to implement the term_size command, and
factor out the code common to the "size" and "print"/"browse" commands.
Decide whether to print the name of a variable before invoking the
supplied print or browse predicate on it based on a flag design for
this purpose, instead of overloading the meaning of the output FILE *
variable. This arrangement is much clearer.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
Supply type information when constructing terms.
browser/program_representation.m:
Since the new library module term_size_prof_builtin never generates
any events, mark it as such, so that the declarative debugger doesn't
expect it to generate any.
Do the same for the deep profiling builtin module.
tests/debugger/term_size_words.{m,inp,exp}:
tests/debugger/term_size_cells.{m,inp,exp}:
Two new test cases, each testing one of the new grades.
tests/debugger/Mmakefile:
Enable the two new test cases in their grades.
Disable the tests sensitive to stack frame sizes in term size profiling
grades.
tests/debugger/completion.exp:
Add the new "term_size" mdb command to the list of command completions,
and delete "proc_body".
tests/debugger/declarative/dependency.{inp,exp}:
Use "print proc_body" instead of "proc_body".
tests/hard_coded/nondet_c.m:
tests/hard_coded/pragma_inline.m:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
tests/valid/Mmakefile:
Disable the IL tests in term size profiling grades, since the term size
profiling primitives haven't been (and probably won't be) implemented
for the MLDS backends, and handle_options causes a compiler abort
for grades that combine term size profiling and any one of IL, Java
and high level C.
|
||
|
|
3e766fcd11 |
Print streams sensibly in the debugger.
Estimated hours taken: 6
Branches: main
Print streams sensibly in the debugger.
runtime/mercury_library_types.h:
Define MercuryFilePtr as a shorthand for MercuryFile *.
library/io.m:
Define a user-friendly representation for streams that includes not
just the stream's name but all the info about the stream that user
using mdb may wish to know about the stream, as well as a unique stream
id.
Make the changes required to maintain this improved stream database.
If the program is being executed under mdb, then do not ever delete
items from the stream database, since e.g. the declarative debugger
may need to print the stream's representation even after the stream
is closed. (If executing outside mdb, then we delete a stream's entry
from the stream database when the stream is closed, as before.)
To allow the debugger to detect which variables are I/O streams,
change the stream types from being equivalent to c_pointer (and thus
indistinguishable from other c_pointers) to their own type. Implement
this type as MercuryFilePtr in the C backend. In the IL backend, we
represent it as Object[], the minimum representation change possible.
Use the C type definition to get rid of many casts.
When writing streams, write the user-friendly representation, not
a meaningless <<c_pointer>>.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
runtime/mercury_layout_util.c:
The change in stream's representation changes the types of some of the
arguments of functions exported to C from io.m; conform to those
changes.
browser/browse.m:
browser/sized_pretty.m:
In each of the mechanisms that the debugger can use to display terms,
pass along the stream name database.
browser/browser_info.m:
When deconstructing terms that are streams, return the stream's
user-friendly id, not a c_pointer.
browser/browse_test.m:
Update this test program to test the new way of printing streams.
runtime/mercury_trace_base.[ch]:
Define the MR_trace_ever_enabled variable to let io.m know whether
it is allowed to ever discard stream info.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
Update the types of the functions dealing with streams to use
MercuryFilePtr to refer to streams instead of MR_Word. These functions
are implemented by Mercury predicates exported to C.
runtime/mercury_wrapper.c:
Set MR_trace_ever_enabled to true when execution tracing is enabled.
This is the only assigment to MR_trace_ever_enabled after
initialization to the default (false).
tests/debugger/declarative/io_stream_test.{m,inp,exp,exp}:
A new test case to test the debugger's printing of I/O streams.
tests/debugger/declarative/Mmakefile:
Enable the new test case.
|
||
|
|
ea33d1945c |
The Aditi API has been re-implemented. This change updates
Estimated hours taken: 40
Branches: main
The Aditi API has been re-implemented. This change updates
the Mercury->Aditi interface to work with the new API.
compiler/aditi_builtin_ops.m:
Pass aditi__states to the builtin predicates implementing
calls to Aditi procedures.
compiler/mode_util.m:
Add a function aditi_ui_mode.
compiler/type_util.m:
Add a function aditi_state_type.
runtime/mercury_wrapper.{c,h}:
util/mkinit.c:
Pass the connection and a transaction in which to
store the Aditi-RL modules.
extras/aditi/aditi.m:
extras/aditi/aditi_private_builtin.m:
util/mkinit.c:
Use the new API.
|
||
|
|
168500343c |
This change adds new facilities for debugging minimal model tabling, and
Estimated hours taken: 160 Branches: main This change adds new facilities for debugging minimal model tabling, and has several bug fixes found with the aid of those facilities. Most of the diff affects the behavior of the system only in minimal model grades and/or when debugging flags are defined. compiler/ite_gen.m: In minimal model grades, surround the conditions of if-then-elses with calls to three functions. These functions detect when a condition fails due to one or more suspensions, and abort the program. (After resumptions, the condition may actually have solutions, but by then the computation has committed to the wrong path.) compiler/table_gen.m: Change the program transformation for model_non predicates to use a switch instead of nested if-then-elses, to avoid the overhead of wrapping the condition. The version with switches is also a bit easier to debug. The transformation for model_det and model_semi predicates stays as before, because for such predicates finding the status (which we want to switch on) requires computation, not just a lookup. Switch to state variable syntax in the affected predicates. Make the error message for an internal error in loopcheck predicates more precise. Mark the code fragments that modify tabling data structures as impure and code fragments that examine tabling data structures as semipure. runtime/mercury_stacks.[ch]: Implement the new stack of possibly negated contexts that we use to detect false failures due to suspensions in negated contexts. Fix a bug: don't refer to MR_cut_stack[-1]. Shorten the name of the generator stack. runtime/mercury_context.[ch]: runtime/mercury_memory.c: runtime/mercury_wrapper.[ch]: Allocate memory for the new stack of possibly negated contexts. Use the shortened name of the generator stack. runtime/mercury_regorder.h: Allocate a pointer for the new stack of possibly negated contexts. runtime/mercury_minimal_model.[ch]: A new module holding the part of mercury_tabling.[ch] that is specific to minimal model tabling. This version contains tools to help debugging of minimal model tabling, as well as some bug fixes found with the aid of those tools. runtime/mercury_tabling.[ch]: Remove the code moved to mercury_minimal_model.[ch], and add the code moved here from trace/mercury_trace_internal.c. Add prefixes to a bunch of structure fields to make it easier to read code accessing those fields. Add mechanisms to allocate and copy tabling structures with type safety. runtime/mercury_imp.h: #include the new header file, if it is needed. runtime/Mmakefile: Mention the new module, and fix sortedness errors. runtime/mercury_stack_trace.c: Fix a bug that sometimes caused stack traces to abort in minimal model grades: they were trying to get layout information from labels that do not have them, such as do_fail. If MR_TABLE_DEBUG is defined, print the locations of stack frames when doing stack dumps. runtime/mercury_trace_base.h: Export to mercury_stack_trace.c the labels that we use to let the debugger get control at redos and fails, since they don't have layout information. runtime/mercury_types.h: Move typedefs here from mercury_tabling.h, and add typedefs for some newly added types. runtime/mercury_engine.[ch]: Add a table mapping debugging flags to their offsets in the MR_debugflag array, for use in the debugger. runtime/mercury_misc.c: Make the formatting of det stack pointers the same as nondet stack pointers in debugging output. runtime/mercury_debug.[ch]: Add conditionally compiled debugging output when creating temp frames on the nondet stack. library/table_builtin.m: Conform to the new names of some fields. Add a predicate to return the status of a subgoal. Add conditionally compiled debugging code. library/Mmakefile: Make table_builtin.m depend on runtime/mercury_minimal_model.h. trace/mercury_trace.c: Conform to the new names of some fields. trace/mercury_trace_internal.c: Add two new mdb commands, to print the cut stack and the new possibly negated context stack. Add two new mdb commands to print a subgoal and a consumer. Move some of the code to print tabling-related data structures to runtime/mercury_tabling.[ch]. Add a new mdb command to report the values of debugging flags and to set and clear them. Previously, one had to turn on these debugging flags with environment variables, which were problematic because they turned on diagnostic printouts even in Mercury programs that *weren't* being debugged, such as the Mercury compiler when being used to generate the program to be debugged. Now the flags can be turned on from a .mdbrc file, which eliminates much setting and unsetting of environment variables. doc/user_guide.tex: Document the new mdb commands. tests/debugger/mdb_command_test.inp: Test the documentation of the new mdb commands. tests/debugger/completion.exp: Expect the new commands in the command completion test. tests/debugger//nondet_stack.exp*: Expect the new format of det stack pointers. tests/debugger/all_solutions.exp3: tests/debugger/exception_value.exp3: tests/debugger/declarative/catch.exp3: tests/debugger/declarative/ho5.exp3: tests/debugger/declarative/throw.exp3: New expected test cases for use in minimal model grades. They differ from existing expected output files only in the precise phrasing of error messages. tests/debugger/declarative/Mmakefile: Disable the untraced_subgoal test case in .mm grades, since we don't pass it yet. tests/tabling/Mmakefile: Enable the mday test case, now that we pass it. |
||
|
|
1315102d7c |
Fix several occurrences of a bug that prevented the compiler from passing
Estimated hours taken: 20 Branches: main Fix several occurrences of a bug that prevented the compiler from passing all the tests in deep profiling grades. We now pass all the tests in deep profiling grades. Some additional changes were useful in tracking this bug down. Using C types to represent deep profiling data structures allowed us to delete a bunch of casts and thus eliminate them as potential bug locations. Another was to fix some bugs in low level debugging support. In light of the fragility of the deep profiling invariants, always check them when writing out deep profiling data files. Since mdprof depends on these invariants, they have to be checked somewhere, and we already have code for the checks in the runtime. Reenable tail recursion support in deep profiling grades, since it now works. (The bug this change fixes used to occur most in tail recursive procedures, which is why previously I turned it off.) compiler/options.m: Reenable tail recursion support in deep profiling grades. runtime/mercury_unify_compare_body.h: Fix the bug that prevented us from passing all the tests with invariants checked and tail recursion support enabled. The bug was that in several cases, the code in mercury_unify_compare_body.h did not invoke the appropriate deep profiling routines and thus did not fill in the deep profiling data structure they were supposed to fill in, breaking an invariant. There were several instances of this bug: unify, compare and compare_representation on tuples, and compare_representation on functions, predicates and user-defined types. These oversights were possible because the actions of returning an answer and filling in the deep profiling data structures (in deep profiling grades) were separate. If one omitted the latter, tests could still work in all grades except deep profiling grades. The fix therefore uses one macro (return_compare_answer or return unify_answer, depending on the the operation) to fill in the deep profiling data structure (in deep profiling grades) and return the answer, making it impossible to forget to do the former. The new approach treats compare_representation the same as compare, and gathers the same information for it. runtime/mercury_ho_call.c: Factor out some commonalities in the definitions of the MR_ProcStatic data structures used by the code in mercury_unify_compare_body.h. Change a macro name to support the changes in mercury_unify_compare_body.h. Change the module name of compare_representation/3 from std_util to builtin, to match unify/2 and compare/3. compiler/deep_profiling.m: Treat compare_representation/3 the same way as we treat compare/3. library/builtin.m library/std_util.m Move the declaration of compare_representation/3 from std_util to builtin, to make it easier to handle it the same way as compare/3. Since it is just a variant of compare/3 and is at least as built into the implementation, it belongs there anyway. library/profiling_builtin.m: Use C types to represent deep profiling data structures. Delete the casts that are redundant after this change. Fix formatting of foreign_procs. runtime/mercury_deep_profiling.c: As mentioned above, always check the invariants of the deep profiling data structures when writing them out. runtime/mercury_deep_profiling.h: Avoid a warning about nested declarations of variable "i". runtime/mercury_deep_rec_depth_body.h: Delete a bunch of casts we don't need anymore. runtime/mercury_wrapper.[ch]: Initialize a couple of predicate names in the low level debug support to "" instead of NULL. The code that accesses these variables passes them to strcmp directly, which lead to core dumps. We could change the accessing code to test for NULL, but since that code is executed on every call when low level debugging is enabled, that would lead to even greater slowdowns, which we can do without. To avoid a warning about casting away const, make the variables involved "const char *" instead of plain "char *"; we don't want to update the pointed-to strings anyway. tools/bootcheck: In profiling grades, write out profiling data files by default, and require the use of an option to turn them off. This is needed to make sure that the deep profiling invariants are checked by default. tests/hard_coded/compare_rep_usereq.m: tests/hard_coded/compare_representation.m: Avoid hard-coding the name of the module defining compare_representation/3. |
||
|
|
f00567129e |
Do not generate assignments to the variables that used to hold the
Estimated hours taken: 0.5 Branches: main util/mkinit.c: Do not generate assignments to the variables that used to hold the address of the type_ctor_infos of the variable arity type_ctor_infos, since those variables aren't needed anymore. runtime/mercury_wrapper.[ch]: Delete those variables. |
||
|
|
17d5aa732e |
Add support for interfacing Mercury with the MPS garbage collector.
Estimated hours taken: 20
Branches: main
Add support for interfacing Mercury with the MPS garbage collector.
This change is broken into three parts:
1. Import version 1.100.1 of the MPS kit into the Mercury
CVS repository, in the directory `mps_gc'.
2. Make some changes to the MPS kit for Mercury,
to support fully-conservative collection and tagged pointers,
and to wrap it in an interface that is similar to that of
the Boehm collector.
3. Modify the rest of the Mercury implementation
to support linking with the MPS kit instead
of the Boehm collector. This involved defining
`mps' as a new GC method and a new grade component.
This is part 3 of 3.
Mmake.workspace:
Include the MPS directories in the header file and library search
paths.
tools/bootcheck:
Link the mps_gc directory into the stage2 and stage3 directories.
Mmake.workspace:
runtime/Mmakefile:
scripts/ml.in:
For *.mps grades, link in mps.a.
(XXX ml.in is linking in libmps.a, which is wrong.)
runtime/Mmakefile:
trace/Mmakefile:
In the rule for `check_headers', which checks macro namespace
cleanliness, allow names to start with `MPS_' or `mps_'.
runtime/RESERVED_MACRO_NAMES:
Add `mercury_mps_h', which is used by mps_gc/code/mercury_mps.h
for its header guard. (Normally it would be better to use
uppercase for header guard macro names, but that would be
inconsistent with the coding style used in mps_gc/code.)
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade.sh-subr:
Handle the new `mps' GC method and grade component.
compiler/globals.m:
compiler/options.m:
doc/user_guide.texi:
Replace gc_method `conservative' with two alternatives
`boehm' and `mps'. ("--gc conservative" is still allowed,
and treated as equivalent to "--gc boehm".)
Add new function `gc_is_conservative' to globals.m.
compiler/mercury_compile.m:
compiler/handle_options.m:
Use `gc_is_conservative' rather than `= conservative'.
compiler/handle_options.m:
Handle the "mps" grade component.
(XXX need to document this in options.m and user_guide.texi)
compiler/compile_target_code.m:
Pass the appropriate C defines for the new GC methods.
compiler/mercury_compile.m:
Wrap the work-around for a Boehm GC bug inside `#ifndef MR_MPS_GC'.
library/array.m:
Use GC_FREE() rather than GC_free().
This is needed for two reasons:
- so that it works with MPS, which only defines GC_FREE
- so that it works with then Boehm collector when
GC debugging is enabled
library/benchmarking.m:
Output GC statistics for the MPS collector.
runtime/mercury.h:
runtime/mercury_heap.h:
runtime/mercury_init.h:
runtime/mercury_memory.h:
If MR_MPS_GC is defined, use mercury_mps.h rather than gc.h.
runtime/mercury_conf_param.h:
Add configuration macros MR_BOEHM_GC and MR_MPS_GC.
Set MR_CONSERVATIVE_GC if either of these is set.
Default to MR_BOEHM_GC if only MR_CONSERVATIVE_GC is set.
runtime/mercury_context.h:
runtime/mercury_deep_copy.h:
runtime/mercury_engine.h:
runtime/mercury_float.h:
runtime/mercury_heap.h:
Explictly #include "mercury_conf.h", so that
MR_CONSERVATIVE_GC will be set properly before it is tested.
runtime/mercury_grade.h:
Handle the .mps grade component.
runtime/mercury_memory.c:
runtime/mercury_wrapper.c:
runtime/mercury_memory_handlers.c:
Move the call to MR_setup_signals() earlier in the
initialization sequence, so that the MPS signal handlers
get installed after our signal handlers. This is needed
because our signal handlers assume that any signals that
they can't handle are fatal errors, which interfere's
with MPS's use of signal handlers for memory barriers.
runtime/mercury_wrapper.c:
Add code to initialize the MPS collector.
Put code which is specific to the Boehm collector inside
#ifdef MR_BOEHM_GC rather than #ifdef MR_CONSERVATIVE_GC.
runtime/mercury_wrapper.h:
Update a comment.
|
||
|
|
010a9ecf74 |
Fix several bugs in deep profiling. These allow the compiler to bootstrap
Estimated hours taken: 30
Branches: main
Fix several bugs in deep profiling. These allow the compiler to bootstrap
again, *including* writing out the profiling data, with sanity checks enabled.
Some test cases still fail, but significantly fewer than before.
These fixes required several improvements in the infrastructure for low
level debugging in the LLDS grades.
compiler/deep_profiling.m:
Mark calls that have a prepare_for_{normal,ho,...}_call inserted before
them as impure, to prevent simplify from optimizing them away, e.g. as
duplicate calls. This is needed because a prepare_for_{...}_call that
is not followed immediately by the call port code of the callee leaves
the profiling tree in a state that violates its invariants.
Mark the redo port code of model_non predicates as needing to be
preserved, even if determinism analysis would normally cause it to be
cut by marking the disjunction it is part of (whose two disjuncts are
the det exit port code and the failure redo port code) as det.
Fix the generation of goal paths to match what the rest of the compiler
does. Start number conjuncts, disjuncts and switch arms from 1, not 0,
and do not reverse goal paths before attaching them to goals; they will
be reversed when they are converted to strings.
compiler/det_analysis.m:
If a disjunct has determinism failure but is impure, treat it as being
able to succeed when computing the max number of solutions of the
disjunction as a whole, *provided* that some earlier disjuct could
succeed. The idea is that ( impure failure ; det ) should be treated
as det, since all backtracking is local within it, while disjunctions
of the form ( det ; impure failure ) should be treated as multi, since
we want to be able to backtrack to the second disjunct from *outside*
the disjunction.
At the moment, we do this not for all impure goals, but only for the
impure goals that deep_profiling marks with the preserve_backtrack_into
feature.
compiler/hlds_goal.m:
Add the preserve_backtrack_into feature.
Add utility predicates for handling the features of a goal directly,
without explicitly dealing with its goal_info.
runtime/mercury_debug.[ch]:
Add mechanisms for turning the printing of low level debugging messages
on and off. Without this, enabling low level debugging can generate
literally gigabytes of debugging output.
The mechanisms all depend on numbering calls.
One mechanism allows messages to be printed starting from calls in
given ranges, by including e.g. -di100-200,300-400 in MERCURY_OPTIONS.
Another mechanism allows N messages to be printed starting from calls
to a given procedure or from calls at which next_call_site_dynamic
has a given value. The value of N (the size of the block of calls)
can be specified by include -dB<num> in MERCURY_OPTIONS. The name of
the given procedure (actually the name of its entry label) can be
specified by including -dj<entrylabel> in MERCURY_OPTIONS. The address
of the call_site_dynamic structure to watch for is specified with the
-dW<addr> option in MERCURY_OPTIONS, as before.
runtime/mercury_wrapper.[ch]:
Add the global variables required to implement the new low level
debugging functionality, as well as the option processing code required
to set those global variables.
Separate the flags controlling the printing of the values of stack
control registers (sp, curfr etc) and ordinary registers (r1, r2 etc).
Print ordinary registers only if explicitly requested.
runtime/mercury_engine.h:
Add the required global flags.
runtime/mercury_deep_profiling.[ch]:
Add two extra arguments to MR_deep_assert, and print them if an
assertion fails. This makes it easier to decide what parameters to give
to the new low level debugging mechanisms.
runtime/mercury_deep_*_port_body.h:
runtime/mercury_deep_rec_depth_*.h:
library/profiling_builtin.m:
Pass the extra arguments to MR_deep_assert, and print low level
debugging messages only if the relevant flag is set.
tools/lmc:
Add mechanisms to add to the list of C compiler flags the program is
compiled with by lmc.
|
||
|
|
32051f5467 |
Add support for command line completion to mdb.
Estimated hours taken: 40
Branches: main
Add support for command line completion to mdb.
NEWS:
Document the change.
trace/mercury_trace_completion.{c,h}:
Define the framework for completion.
Examine command lines to determine which completers to use.
trace/mercury_trace_alias.{c,h}:
trace/mercury_trace_help.{c,h}:
trace/mercury_trace_internal.{c,h}:
trace/mercury_trace_tables.{c,h}:
trace/mercury_trace_vars.{c,h}:
Define context-specific completers.
trace/mercury_trace_help.c:
Record all help topics in an array for use by the completer.
trace/mercury_trace_internal.c:
Add completion information to the list of commands.
Add a function MR_trace_command_completion_info to access
that information.
runtime/mercury_wrapper.{c,h}
Add a runtime option `--force-readline', which tells mdb to
use readline even if MR_mdb_in is not a tty. This is needed
for tests/debugger/completion. `--force-readline' is not
documented because I'm not sure that it will work properly
in all situations (it's fine for the test).
Fix capitalisation in references to the Mercury User's Guide
in error messages.
trace/mercury_trace_readline.c:
Tell Readline to use our completer.
Handle `--force-readline'. Disable some Readline terminal
initialisation code which reports spurious warnings if the
input stream is not a tty.
trace/Mmakefile:
Add mercury_trace_completion.{c,h}.
runtime/mercury_array_macros.h:
Define a macro MR_find_first_match, which is like MR_bsearch
except that it finds the first match, not an arbitrary match.
runtime/mercury_memory.c:
Handle NULL pointers in MR_copy_string();
runtime/mercury_memory.h:
Add a macro MR_free_func which returns the address of free().
Used where it is necessary to pass the address of MR_free().
tests/debugger/Mmakefile:
tests/debugger/completion.m:
tests/debugger/completion.exp:
tests/debugger/completion.inp:
tests/debugger/completion.inputrc:
tests/debugger/completion.sub1.m:
tests/debugger/completion.sub2.m:
tests/debugger/completion.sub2.sub3.m:
Test case.
|
||
|
|
b51c742885 |
Allow the debugger to print higher order values and typeinfos, mainly by
Estimated hours taken: 50
Branches: main
Allow the debugger to print higher order values and typeinfos, mainly by
making the committed choice modes of the predicates in deconstruct.m to
deconstruct higher order values and typeinfos. (The non committed choice
versions will continue to return only placeholders.)
Having the debugger print typeinfos is occasionally useful but more often
it is just distracting. This change therefore adds a new debugger command,
"print_optionals", that toggles the printing of optional values. For now,
the only optional values are typeinfos.
NEWS:
Mention the new capability and the new predicates in the library.
Mention the predicates added previously that allow the caller to
specify how non-canonical terms should be handled, since the change
in their semantics that we anticipated when they were added has now
happened, and their semantics should now be more stable.
browser/browser_info.m:
Use the predicates in the deconstruct.m instead of std_util,
to make the choice of noncanonical term method handling explicit.
browser/browse.m:
When writing small terms using io__write_univ, explicitly use
the same noncanonical term handling method as browser_info.m
library/io.m:
Add predicates to retrieve the current input and output streams.
Add versions of io__write_univ that specify the stream and maybe
the method of handling noncanonical terms.
Add a mode to io__write_list that allows the closure that prints the
list elements to be cc_multi.
All of these are for the new functionality in the browser.
runtime/mercury_ml_expand_body.h:
In committed choice contexts, deconstruct closures as if they were
ordinary terms, with the function symbol being the name of the
predicate/function and the arguments being the terms stored in
the closure.
In committed choice contexts, deconstruct typeinfos as if they were
ordinary terms, with the function symbol being the name of the type
constructor and the arguments being the type constructor's arguments.
runtime/mercury_type_info.[ch]:
Add a new function, MR_collapse_ctor_equivalences, for use by
mercury_ml_expand_body.h.
Delete a redundant function comment.
library/deconstruct.m:
Document the changes in the behavior of the predicates defined in this
module as a result of the change to mercury_ml_expand_body.h.
runtime/mercury_ho_call.h:
runtime/mercury_stack_layout.h:
Add prefixes on structure field names that did not have them.
browser/dl.m:
Add prefixes where needed by the changes to mercury_ho_call.h.
runtime/mercury_layout_util.[ch]:
Remove the first argument of MR_materialize_closure_typeinfos, since
its correct value is always the same part of the second argument.
runtime/mercury_deep_copy_body.h:
Do not pass the first argument of MR_materialize_closure_typeinfos.
Add field name prefixes where necessary.
compiler/modules.m:
The mercury_builtin module is no longer part of the library.
compiler/pd_debug.m:
compiler/rl_analyze.m:
Minor updates to avoid trying to take the address of io__write_list,
since it now has more than one mode.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
trace/mercury_trace_vars.[ch]:
Add a parameter to MR_trace_browse_all_on_level that specifies
whether we should print values of type type_info.
trace/mercury_trace_vars.c:
Do not ignore predicates and functions anymore.
runtime/mercury_stack_trace.c:
trace/mercury_trace.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
Pass the new parameter of MR_trace_browse_all_on_level.
trace/mercury_trace_internal.c:
Implement the "print_optionals" command.
doc/user_guide.texi:
Document the "print_optionals" command.
tests/debugger/mdb_command_test.inp:
Test the documentation of "print_optionals".
tests/debugger/higher_order.{m,inp,exp,exp2}:
A new test case to exercise the ability to print higher order values.
Note that the format of the predicate names in the output should be
improved, but that is a separate change since doing it the right way
requires bootstrapping.
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/nondet_stack.exp*:
Update the expected output to reflect the fact that nondet stack dumps,
being intended for debugging, include type_infos.
tests/debugger/tabled_read_decl.exp*:
Update the expected output to reflect the fact that for maximum
usefulness, the printing of I/O action atoms prints meaningful
type_infos.
tests/hard_coded/deconstruct_arg.*:
tests/hard_coded/write_reg1.*:
Expand these tests to check that we handle higher order values
correctly not just when canonicalizing but also in committed choice
modes.
|
||
|
|
b7c4a317e9 |
Add MR_ prefixes to the remaining non-prefixed symbols.
Estimated hours taken: 4 Branches: main Add MR_ prefixes to the remaining non-prefixed symbols. This change will require all workspaces to be updated The compiler will start generating references to MR_TRUE, MR_bool, etc., which are not defined in the old runtime header files. runtime/mercury_std.h: Add MR_ prefixes to bool, TRUE, FALSE, max, min, streq, strdiff, strtest, strntest, strneq, strndiff, strntest, NO_RETURN. Delete a commented out definition of `reg'. runtime/mercury_tags.h: Add an MR_ prefix to TAGBITS. configure.in: runtime/mercury_goto.h: runtime/machdeps/i386_regs.h/mercury_goto.h: Add an MR_ prefix to PIC. runtime/mercury_conf_param.h: Allow non-prefixed PIC and HIGHTAGS to be defined on the command line. runtime/mercury_bootstrap.h: Add backwards compatibility definitions. RESERVED_MACRO_NAMES: Remove the renamed macros. compiler/export.m: compiler/ml_code_gen.m: Use MR_bool rather than MR_Bool (MR_Bool is meant to be for references to the Mercury type bool__bool). runtime/mercury_types.h: Add a comment the MR_Bool is for references to bool__bool. */*.c: */*.h: */*.m: Add MR_ prefixes. |
||
|
|
c66cea0665 |
Add MR_ prefixes to uses of configuration macros.
Estimated hours taken: 2.5 Branches: main Add MR_ prefixes to uses of configuration macros. Bootcheck now succeeds with MR_NO_CONF_BACKWARDS_COMPAT. Mmake.common.in: Define MR_NO_CONF_BACKWARDS_COMPAT when checking for namespace cleanliness. RESERVED_MACRO_NAMES: Remove the configuration macros. runtime/mercury_conf_bootstrap.h: Remove a duplicate definition of BOXED_FLOAT. configure.in: */*.c: */*.h: */*.m: Add MR_ prefixes. |
||
|
|
af62036bff |
Two related changes for accurate GC with the MLDS->C back-end:
Estimated hours taken: 2 Branches: main Two related changes for accurate GC with the MLDS->C back-end: - Add a new runtime option --heap-margin-size for the threshold of free heap space before a collection is invoked, rather than the previous hack of reusing --heap-zone-size for that purpose. - A minor optimization to reduce the cost of MR_gc_check(): cache the value of MR_zone_end - MR_heap_margin_size. runtime/mercury_wrapper.h: runtime/mercury_wrapper.c: runtime/mercury_memory.c: Add new variable `MR_heap_margin_size', and add a new runtime option `--heap-margin-size' to set it. runtime/mercury_memory_zones.h: Add new field `gc_threshold' to the MR_MemoryZone struct. runtime/mercury_memory_zones.c: Initialize the new field to point to the zone end minus MR_heap_margin_size. runtime/mercury.h: Change MR_GC_check() to use the `gc_threshold' field. |
||
|
|
1b127a6111 |
Improve the handling of the mdb's `--window' option.
Estimated hours taken: 10 Improve the handling of the mdb's `--window' option. `mdb --window' now creates a window for mdb, not the program. The main advantage of this is that redirection of the program's input and output now works. The new behaviour should also be implementable using the Windows API. The old behaviour is still available with `mdb --program-in-window'. Unfortunately, the code to open a pseudo-terminal for mdb's I/O isn't very portable. It works on everything we run nightly tests on, but isn't likely to work on older systems or BSD systems. NEWS: Document the change. scripts/mdb.in: Handle the new behaviour of `--window'. Add `--program-in-window'. trace/mercury_trace_internal.c: If `--window' was passed in MERCURY_OPTIONS, redirect mdb's I/O to a window created using `xterm -S'. Rename occurrences of `close' to avoid gcc warnings. runtime/mercury_trace_base.h: runtime/mercury_trace_base.c: Kill the mdb window on exit. runtime/mercury_wrapper.h: runtime/mercury_wrapper.c: Add a runtime options `--mdb-in-window' for use by the mdb script. runtime/mercury_signal.h: runtime/mercury_signal.c: Add a version of MR_setup_signal which doesn't cause system calls to be restarted after a signal is received. This is needed to allow a read() from the mdb window to timeout if the window failed to start. Add functions to get and set the action for a given signal. configure.in: runtime/mercury_conf.h.in: runtime/RESERVED_MACRO_NAMES. Check for functions open, close, dup, dup2, fdopen, setpgid, fork, execlp, wait, kill, grantpt, unlockpt, pstname, tcgetattr, tcsetattr and ioctl. Check for type pid_t. Check for header files <fcntl.h>, <termios.h>, <sys/ioctl.h>, <sys/stropts.h>. Check for /dev/ptmx, used to open pseudo-terminals. runtime/mercury_misc.c: runtime/mercury_misc.h: Add MR_mdb_warning, which prefixes messages from the debugger with "mdb: ". Add MR_perror and MR_mdb_perror, which are versions of perror which prefix the printed message with "Mercury runtime: " and "mdb: " respectively. runtime/mercury_prof_time.c: runtime/mercury_prof.c: runtime/mercury_memory_handlers.c: Don't prefix error messages passed to MR_setup_signal with "Mercury runtime:". MR_setup_signal now uses MR_perror. |
||
|
|
2b559ad054 |
Move the RTTI-related parts of std_util.m to three new modules in the standard
Estimated hours taken: 8
Branches: main
Move the RTTI-related parts of std_util.m to three new modules in the standard
library, and (in the case of embedded C code) to new modules in the runtime.
The main reason for this is to allow a reorganization of some of the
RTTi-related functionality without breaking backward compatibility. However,
the new arrangement should also be easier to maintain.
Use a separate type_ctor_rep for functions, to distinguish them from predicates
for RTTI code. (At one point, I thought this could avoid the need for the
change to the initialization files mentioned below. It can't, but it is a good
idea in any case.)
library/std_util.m:
Remove the functionality moved to the new modules, and replace them
with type equivalences and forwarding code. There are no changes in
the meanings of the user-visible predicates, with two exceptions.
- First, the true, equivalence-expanded names of what used to be
std_util:type_desc and std_util:type_ctor_desc are now
type_desc:type_desc and type_desc: type_ctor_desc.
- Second, deconstructing a function term now yields
"<<function>>" instead of "<<predicate>>".
The intention is that the RTTI predicates in std_util.m will continue
to work in a backwards-compatible manner for the near future, i.e. as
the new modules are updated, the code in std_util will be updated to
maintain the same functionality, modulo improvements such as avoiding
unwanted exceptions. When the RTTI functionality in the other modules
has stabilised, the RTTI predicates in std_util.m should be marked
obsolete.
The exported but non-documented functionality of std_util has been
moved to one of the new modules without forwarding code, with one
of the moved predicates being turned into the function it should have
been in the first place.
library/construct.m:
library/deconstruct.m:
library/type_desc.m:
Three new modules for the code moved from std_util.m.
library/library.m:
compiler/modules.m:
Record the names of the three new library modules.
runtime/mercury.[ch]:
compiler/mlds_to_il.m:
Record that type_desc is now in type_desc.m, not std_util.m.
compiler/static_term.m:
Import the deconstruct module, since we are using its undocumented
facilities.
runtime/Mmakefile:
Mention the two new modules.
runtime/mercury_construct.[ch]:
runtime/mercury_type_desc.[ch]:
Two new modules holding the C functions that used to be in foreign_code
in std_util, now using MR_ instead of ML_ prefixes, and being more
consistent about indentation.
runtime/mercury_type_info.h:
Add a new type_ctor_rep for functions, separate from predicates.
(It reuses the EQUIV_VAR type_ctor_rep, which hasn't been used
in ages.)
Use type_ctor_reps to distinguish between the type_ctor_infos of
pred/0 and func/0. However, to create higher order typeinfos, we
still need to know the addresses of the type_ctor_infos for
pred/0 and func/0, and we still need to know the address of the
type_ctor_info for tuples to create typeinfos for tuples. Since
these three type_ctor_infos are defined in the library,
we cannot access them directly from the runtime. We therefore need
to access them indirectly in the usual manner, via address_of
variables initialized by mkinit-generated code.
library/builtin.m:
library/private_builtin.m:
library/rtti_implementation.m:
runtime/mercury.c:
runtime/mercury_mcpp.{h,cpp}:
java/TypeCtorRep.java:
Updates to accommondate the new function type_ctor_rep.
runtime/mercury_type_info.[ch]:
Add some functions from foreign_code in std_util that fit in best here.
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.h:
runtime/mercury_unify_compare_body.h:
Delete the code for handling EQUIV_VAR, and add code for handling
functions.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
Add three variables holding the address of the type_ctor_infos
representing functions, predicates and tuples.
util/mkinit.c:
Fill in these three variables.
tests/general/accumulator/construct.{m,exp}:
tests/general/accumulator/deconstruct.{m,exp}:
tests/hard_coded/construct.{m,exp}:
Rename these tests by adding a _test at the ends of their names,
in order to avoid collisions with the names of the new standard library
modules. The test cases have not changed, with the exception of the :-
module declaration of course.
tests/general/accumulator/Mmakefile:
tests/general/accumulator/INTRODUCED:
tests/hard_coded/Mmakefile:
Record the name changes.
tests/hard_coded/existential_float.exp:
Updated the expected output to reflect that deconstructions now print
"<<function>>" instead of "<<predicate>>" when appropriate.
tests/hard_coded/higher_order_type_manip.exp:
Updated the expected output to reflect the new name of what used to be
std_util:type_desc.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
#include type_desc.h instead of std_util.h, since the C functions
we want to call are now defined there.
trace/mercury_trace_vars.c:
Update to account for the movement of type_desc from std_util to
type_desc, and ensure that we don't refer to any type_ctor_infos
in MLDS grades.
|
||
|
|
dead626652 |
Allow Mercury runtime options to be set at compile time.
Estimated hours taken: 1.5 Branches: main Allow Mercury runtime options to be set at compile time. scripts/parse_ml_options.sh-subr.in: Add an initialization option `--runtime-flags'. runtime/mercury_wrapper.h: Add a global variable MR_runtime_flags. util/mkinit.c: Set MR_runtime_flags. runtime/mercury_wrapper.c: Add the value of MR_runtime_flags to the dummy command line passed to getopt(). tests/hard_coded/Mmakefile: Use `--runtime-flags' rather than MERCURY_OPTIONS. |
||
|
|
fbfd4970df |
Make the debugging of minimal model tabling easier by providing a mechanism
Estimated hours taken: 32
Branches: main
Make the debugging of minimal model tabling easier by providing a mechanism
to print the contents of the nondet stack, *including* the values of the
variables in its stack frames, even for frames which are not ancestors
of the currently executing call.
runtime/mercury_stack_trace.[ch]:
Add functions for traversing the nondet stack, and for keeping track of
through which label control returns to each nondet stack frame, so that
we know which label's layout structure to interpret the stack frame's
contents. For some, this will be the return label of a call; for
others, it will be the label of a resumption point stored in a
redoip slot.
Rename an old function to allow the new one to fit into our naming
scheme.
runtime/mercury_stack_trace.[ch]:
runtime/mercury_tabling.c:
library/exception.m:
trace/mercury_trace.c:
Add MR_ prefixes to the values of the enum returned by
MR_stack_walk_step.
Rename references to the renamed function.
runtime/mercury_conf_param.h:
Add macros for debugging label names and for debugging retries (which
needs label names, just as debugging tabling does).
Add a macro for controlling whether mercury_debug.c prints raw
addresses as well as offsets (for stack pointers) or label names (for
labels). The raw pointers can be useful in debugging, but they need to
be turned off in test cases one wants to be reproducible.
runtime/mercury_label.h:
runtime/mercury_conf_param.h:
Move the MR_NEED_ENTRY_LABEL_ARRAY and MR_NEED_ENTRY_LABEL_INFO macros
from mercury_label.h to mercury_conf_param.h, since mercury_debug.c
also needs them now.
runtime/mercury_debug.c:
addresses as well as offsets (for stack pointers) or label names (for
labels). The raw pointers can be useful in debugging, but they need to
be turned off in test cases one wants to be reproducible.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
util/mkinit.c:
Add a global variable pointing to a function through which the stack
walk code in runtime/mercury_stack_trace.c can invoke code from the
debugger to print the values of the variables in nondet stack frames
without breaking the rule prohibiting references to the trace directory
from the runtime directory.
runtime/mercury_wrapper.c:
Define the succip of the dummy frame at the bottom of the nondet stack,
to avoid dereferencing a garbage pointer during detailed stack dumps.
runtime/mercury_goto.h:
Add a mechanism for always registering the name of a specific label,
even if label names are not being registered in general. This mechanism
is intended to be used for labels such as do_fail, which occur
frequently in nondet stack traces.
runtime/mercury_context.c:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_trace_base.c:
runtime/mercury_wrapper.c:
Use this mechanism for the labels defined in these modules.
library/builtin.m:
Define type_ctor_infos for the pseudotypes representing nondet stack
frame slots unconditionally, since the debugger may now need them.
trace/mercury_trace.c:
Add conditionally enabled to code to make debugging retry easier.
trace/mercury_trace_internal.c:
Add a -d option to the nondet_stack command that causes it to print
detailed nondet stack dumps, including the names and values of the
variables in each nondet stack frame.
trace/mercury_trace_vars.c:
Provide a mechanism for printing the variables of a stack frame
even when that stack frame is not an ancestor of the current call.
doc/user_guide.texi:
Document the new option of the nondet_stack command.
tests/debugger/nondet_stack.{m,inp,exp,exp2}:
A new test case to test "nondet_stack -d".
tests/debugger/Mmakefile:
Enable the new test case.
|
||
|
|
04e614485d |
Implement deep profiling; merge the changes on the deep2 branch back
Estimated hours taken: 500 Branches: main Implement deep profiling; merge the changes on the deep2 branch back onto the trunk. The main documentation on the general architecture of the deep profiler is the deep profiling paper. doc/user_guide.texi: Document how to use the deep profiler. deep_profiler: deep_profiler/Mmakefile: A new directory holding the deep profiler and its mmakefile. Mmakefile: Add targets for the new directory. Add support for removing inappropriate files from directories. deep_profiler/interface.m: The deep profiler consists of two programs: mdprof_cgi.m, which acts as a CGI "script", and mdprof_server.m, which implements the server process that the CGI script talks to. Interface.m defines the interface between them. script/mdprof.in: A shell script template. ../configure uses it to generate mdprof, which is a wrapper around mdprof_cgi that tells it how to find mdprof_server. deep_profiler/mdprof_cgi.m: The CGI "script" program. deep_profiler/mdprof_server.m: The top level predicates of the server. deep_profiler/profile.m: The main data structures of the server and their operations. deep_profiler/read_profile.m: Code for reading in profiling data files. deep_profiler/startup.m: Code for post-processing the information in profiling data files, propagating costs from procedures to their ancestors and performing various kinds of summaries. deep_profiler/server.m: Code for responding to requests from the CGI script. deep_profiler/cliques.m: Code to find cliques in graphs. deep_profiler/array_util.m: deep_profiler/util.m: Utility predicates. deep_profiler/dense_bitset.m: An implementation of (part of) the set ADT with dense bit vectors. deep_profiler/measurements.m: Operations on profiling measurements. deep_profiler/timeout.m: An implementation of a timeout facility. deep_profiler/conf.m: Functions that depend on autoconfigured settings. configure.in: Find out what command to use to find the name of the local host. Install deep profiling versions of the standard library along with the other profiling versions. runtime/mercury_conf.h.in: Add some macros for deep_profiler/conf.m to use. library/profiling_builtin.m: runtime/mercury_deep_call_port_body.h: runtime/mercury_deep_leave_port_body.h: runtime/mercury_deep_redo_port_body.h: A new library module that implements deep profiling primitives. Some of these primitives have many versions, whose common code is factor is factored out in three new include files in the runtime. compiler/deep_profiling.m: New module to perform the program transformations described in the paper. compiler/notes/compiler_design.html: Document the new compiler module. compiler/mercury_compiler.m: Invoke the new module in deep profiling grades. Allow global static data to be generated by deep_profiling.m. compiler/options.m: Add options to turn on deep profiling and (for benchmarking purposes) control its implementation. Add an optiooption disable tailcall optimization in the LLDS backend, to help benchmarking deep profiling. compiler/jumpopt.m: compiler/optimize.m: Obey the option to disable tailcalls. compiler/handle_options.m: Handle the implications of deep profiling. compiler/modules.m: In deep profiling grades, automatically import profiling_builtin.m. compiler/prog_util.m: doc/Makefile: library/library.m: Handle the new builtin module. compiler/export.m: In deep profiling grades, wrap deep profiling code around exported procedures to handle the "unscheduled call" aspects of callbacks to Mercury from the foreign language. compiler/higher_order.m: profiler/demangle.m: util/demangle.c: When creating a name for a higher-order-specialized predicate, include the mode number in the name. compiler/add_trail_ops.m: compiler/type_util.m: Move c_pointer_type from add_trail_ops to type_util, so it can also be used by deep_profiling.m. compiler/hlds_goal.m: Add a new goal feature that marks a tail call, for use by deep_profiling.m. compiler/hlds_pred.m: Add a new field to proc_info structures for use by deep_profiling.m. Add a mechanism for getting proc_ids for procedure clones. Remove next_proc_id, an obsolete and unused predicate. compiler/hlds_data.m: Add a new cons_id to refer to the proc_static structure of a procedure. compiler/bytecode_gen.m: compiler/code_util.m: compiler/dependency_graph.m: compiler/hlds_out.m: compiler/mercury_to_mercury.m: compiler/ml_unify_gen.m: compiler/opt_debug.m: compiler/prog_rep.m: compiler/rl_exprn.m: compiler/switch_util.m: compiler/unify_gen.m: Trivial changes to handle the new cons_id, goal feature and/or proc_info argument. compiler/rtti.m: Add a utility predicate for extracting pred_id and proc_id from an rtti_proc_label, for use by hlds_out.m compiler/layout.m: compiler/layout_out.m: compiler/llds.m: compiler/llds_common.m: Add support for proc_static and call_site_static structures. compiler/layout_out.m: compiler/llds_out.m: Add code for the output of proc_static structures. compiler/code_util.m: Make code_util__make_proc_label_from_rtti a function, and export it. util/mkinit.c: compiler/llds_out.m: compiler/layout.m: compiler/modules.m: Add support for a fourth per-module C function, for writing out proc_static structures (and the call_site_static structures they contains). Since proc_static structures can be referred to from LLDS code (and not just from other static structures and compiler-generated C code), reorganize the declarations of static structures slightly. Change the schema for the name of the first per-module C function slightly, to make it the addition of the fourth function easier. The scheme now is: mercury__<modulename>__init mercury__<modulename>__init_type_tables mercury__<modulename>__init_debugger mercury__<modulename>__write_out_proc_statics Improve formatting of the generated C code. library/*.m: runtime/mercury.c: runtime/mercury_context.c: runtime/mercury_engine.c: runtime/mercury_ho_call.c: runtime/mercury_tabling.c: runtime/mercury_trace_base.c: runtime/mercury_wrapper.c: trace/mercrury_trace.[ch]: trace/mercrury_trace_declarative.c: trace/mercrury_trace_external.c: trace/mercrury_trace_internal.c: Conform to the new scheme for initialization functions for hand-written modules. compiler/mercury_compile.m: library/benchmarking.m: runtime/mercury_conf_param.h: runtime/mercury.h: runtime/mercury_engine.c: runtime/mercury_goto.c: runtime/mercury_grade.h: runtime/mercury_ho_call.c: runtime/mercury_label.[ch]: runtime/mercury_prof.[ch]: Add an MR_MPROF_ prefix in front of the C macros used to control the old profiler. compiler/handle_options.m: runtime/mercury_grade.h: scripts/canonical_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: Make deep profiling completely separate from the old profiling system, by making the deep profiling grade independent of MR_MPROF_PROFILE_TIME and the compiler option --profile-time. library/array.m: library/builtin.m: library/std_util.m: runtime/mercury_hand_unify_body.h: runtime/mercury_hand_compare_body.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of hand-written unification and comparison procedures. Make the reporting of array bounds violations switchable between making them fatal errors, as we currently, and reporting them by throwing an exception. Throwing an exception makes debugging code using arrays easier, but since exceptions aren't (yet) propagated across engine boundaries, we keep the old behaviour as the default; the new behaviour is for implementors. runtime/mercury_deep_profiling_hand.h: New file that defines macros for use in Mercury predicates whose definition is in hand-written C code. library/exception.m: runtime/mercury_exception_catch_body.h: runtime/mercury_stacks.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of the various modes of builtin_catch. Provide a function that C code can use to throw exceptions. library/benchmarking.m: library/exception.m: library/gc.m: library/std_util.m: runtime/mercury_context.[ch]: runtime/mercury_engine.[ch]: runtime/mercury_debug.c: runtime/mercury_deep_copy.c: runtime/mercury_overflow.h: runtime/mercury_regs.h: runtime/mercury_stacks.h: runtime/mercury_thread.c: runtime/mercury_wrapper.c: Add prefixes to the names of the fields in the engine and context structures, to make code using them easier to understand and modify. runtime/mercury_deep_profiling.[ch]: New module containing support functions for deep profiling and functions for writing out a deep profiling data file at the end of execution. runtime/mercury_debug.[ch]: Add support for debugging deep profiling. Add support for watching the value at a given address. Make the buffered/unbuffered nature of debugging output controllable via the -du option. Print register contents only if -dr is specified. runtime/mercury_goto.h: runtime/mercury_std.h: Use the macros in mercury_std.h instead of defining local variants. runtime/mercury_goto.h: runtime/mercury_stack_layout.h: runtime/mercury_stack_trace.c: runtime/mercury_tabling.c: trace/mercury_trace.c: trace/mercury_trace_declarative.c: trace/mercury_trace_external.c: trace/mercury_trace_vars.c: Standardize some of the macro names with those used in the debugger paper. runtime/mercury_heap.h: Add support for memory profiling with the deep profiler. runtime/mercury_prof.[ch]: runtime/mercury_prof_time.[ch]: Move the functionality that both the old profiler and the deep profiler need into the new module mercury_prof_time. Leave mercury_prof containing stuff that is only relevant to the old profiler. runtime/mercury_prof.[ch]: runtime/mercury_strerror.[ch]: Move the definition of strerror from mercury_prof to its own file. runtime/mercury_wrapper.[ch]: Add support for deep profiling. Add suppory for controlling whether debugging output is buffered or not. Add support for watching the value at a given address. runtime/Mmakefile: Mention all the added files. scripts/mgnuc.in: Add an option for turning on deep profiling. Add options for controlling the details of deep profiling. These are not documented because they are intended only for benchmarking the deep profiler itself, for the paper; they are not for general use. tools/bootcheck: Compile the deep_profiler directory as well as the other directories containing Mercury code. Turn off the creation of deep profiling data files during bootcheck, since all but one of these in each directory will be overwritten anyway. Add support for turning on --keep-objs by default in a workspace. tools/speedtest: Preserve any deep profiling data files created by the tests. trace/mercury_trace.c: Trap attempts to perform retries in deep profiling grades, since they would lead to core dumps otherwise. util/Mmakefile: Avoid compile-time warnings when compiling getopt. tests/*/Mmakefile: tests/*/*/Mmakefile: In deep profiling grades, switch off the tests that test features that don't work with deep profiling, either by design or because the combination hasn't been implemented yet. |
||
|
|
2498d9d3fd |
Instead of generating the layout structures of labels, procs and modules
Estimated hours taken: 36 Instead of generating the layout structures of labels, procs and modules as rvals, generate them almost entirely as C structures. This will make future modifications much easier, since mismatches between what the runtime expects and what the compiler generates will now be pointed out by the C compiler. (It also reduces the size of the C source files generated with debugging enabled by about 5%.) Layout structures contain a few components that are not well-typed in C; we continue to generate these as rvals. Closure layout structures used to have a well-typed part and a non-well-typed part. We now generate the well-typed part as a separate structure, pointed to from the other. We also extend the well-typed part, so that instead of just giving the name the called procedure, it also identifies the source location where the closure was constructed. This could be useful for the debugger and for deep profiling. This diff also includes a change to get the compiler to bootstrap with lcc in grade none.gc.debug.tr: initializing the string tables in module layouts not as a string but as an array of characters. runtime/mercury_stack_layout.h: Reorganize the definitions of layout structures. Rename Stack_Layout_Entry structures as Proc_Layout structures, and Stack_Layout_Label structures as Label_Layout structures. (The debugger paper refers to the structures by the new names.) Fold the Stack_Layout_Vars structure into the structure that contains it, the Label_Layout structure. Add a Closure_Id structure that contains a Proc_Id structure as well as extra information identifying the source location where the closure was created. Create "short" versions of the Proc_Layout structures, which contain only the first one or two of the three groups of fields. Previously, the Mercury compiler would define new C types when it generated such short structures. Since we are not defining new C types anymore, there must be a C type for every kind of structure the Mercury compiler can generate. We now also have separate variants for the layouts of user-defined and compiler-generated procedures, since the format of their procedure id information is different. While the runtime system refers to their procedure id information through a union, the C types of the structures generated by the Mercury compiler do not use a union, since a union cannot be initialized through its second member. Make the constant fields of structures const, since we now generate values of those structure types, and initialize them with constant data. Move the documentation of layout structures here from stack_layout.m. runtime/mercury_ho_call.h: Instead of bodily including an MR_Proc_Id structure in closures, include a pointer to the more detailed MR_Closure_Id structure. runtime/mercury_accurate_gc.c: runtime/mercury_agc_debug.c: runtime/mercury_init.h: runtime/mercury_label.[ch]: runtime/mercury_layout_util.[ch]: Minor updates to conform to changes in mercury_stack_layout.h. runtime/mercury_goto.h: Use separate naming schemes for label layout structures and proc layout structures. library/exception.m: Minor updates to conform to changes in mercury_stack_layout.h. compiler/layout.m: A new module that defines data structures for label, proc and module layout structures and for closure id structures. compiler/layout_out.m: A new module that converts the Mercury data structures of layout.m into declarations and definitions of C data structures. compiler/stack_layout.m: Generate the new layout structures instead of rvals. Move the documentation of layout structures from here to runtime/mercury_stack_layout.h, since this module is no longer aware of some of their details. compiler/llds.m: Make layout structures a separate kind of compiler-generated data. compiler/llds_out.m: Remove the code for the output of layout structures; call layout_out.m instead. compiler/llds_out.m: compiler/rtti_out.m: Turn some predicates into functions. compiler/code_gen.m: compiler/code_info.m: compiler/llds.m: compiler/mercury_compile.m: compiler/unify_gen.m: Instead of handling closure layouts like other static data, handle them separately. Add a counter to the code_info structure in order to allow closure id structures to be identified uniquely by a pair consisting of the id of the procedure that generates them and a closure sequence number within that procedure. compiler/llds_common.m: Look for common rvals among the rvals in layout structures. compiler/opt_debug.m: Generate developer-friendly names for layout structure references. browser/dl.m: Update the code for constructing closure layouts. |
||
|
|
3de6904858 |
Merge my recent changes on the gcc-backend-branch back onto
Estimated hours taken: 0.5 mercury/Mmake.common.in: mercury/configure.in: mercury/compiler/Mmakefile: mercury/compiler/maybe_mlds_to_gcc.pp: mercury/compiler/mercury_compile.m: mercury/compiler/mlds_to_gcc.m: mercury/compiler/modules.m: mercury/runtime/mercury_type_info.h: mercury/runtime/mercury_wrapper.c: mercury/runtime/mercury_wrapper.h: mercury/scripts/Mmake.rules: mercury/scripts/Mmake.vars.in: mercury/scripts/final_grade_options.sh-subr: mercury/scripts/init_grade_options.sh-subr: mercury/scripts/mmake.in: mercury/scripts/parse_grade_options.sh-subr: gcc/Make-lang.in: gcc/Makefile: gcc/Mmakefile: gcc/lang-specs.h: gcc/mercury-gcc.c: Merge my recent changes on the gcc-backend-branch back onto the main branch. |
||
|
|
1e9195b4f3 |
Add some Mmake rules to the runtime and some code to tools/bootcheck
Estimated hours taken: 16 Add some Mmake rules to the runtime and some code to tools/bootcheck so that we automatically check that the namespace remains clean. Also add some `MR_' prefixes that Zoltan missed in his earlier change. tools/bootcheck: Add an option, which is enabled by default, to build the check_namespace target in the runtime. runtime/RESERVED_MACRO_NAMES: New file. Contains a list of the macros names that don't start with `MR_' or the like. runtime/Mmakefile: Change the rule for `check_headers' so that it checks for macros that don't occur in the RESERVED_MACRO_NAMES files, as well as not starting with `MR_' prefixes, and reports errors for such macros. Also add a rule for check_objs that checks whether the object files define any global symbols that don't have the right prefixes, and a rule `check_namespace' that does both of the above. runtime/mercury_bootstrap.h: #include "mercury_types.h" and "mercury_float.h", to ensure that this header file is self-contained. Also make sure that all the old names are disabled if you compile with `-DMR_NO_BACKWARDS_COMPAT'. runtime/mercury_context.c: runtime/mercury_thread.h: runtime/mercury_thread.c: Use `bool' rather than `MR_Bool' for the argument to MR_check_pending_contexts() and the return type of MR_init_thread(), since these are C bools, not Mercury bools, and there's no requirement that they have the same size as MR_Integer. runtime/mercury_type_info.h: runtime/mercury_deep_copy_body.h: runtime/mercury_tabling.c: library/std_util.m: trace/mercury_trace_declarative.c: trace/mercury_trace_external.c: trace/mercury_trace_internal.c: tests/hard_coded/existential_types_test.m: Add MR_ prefixes to UNIV_OFFSET_FOR_TYPEINFO and UNIV_OFFSET_FOR_VALUE. trace/mercury_trace_external.c: trace/mercury_trace_internal.c: trace/mercury_trace_tables.c: Add MR_ prefixes to do_init_modules(). runtime/mercury_tabling.h: runtime/mercury_tabling.c: runtime/mercury_overflow.h: runtime/mercury_debug.h: Add MR_ prefixes to table_*. runtime/mercury_overflow.h: runtime/mercury_debug.h: Add MR_ prefixes to IF(). runtime/mercury_context.h: Add MR_ prefixes to IF_MR_THREAD_SAFE(). runtime/mercury_engine.h: Add MR_ prefixes to IF_NOT_CONSERVATIVE_GC(). runtime/mercury_engine.h: runtime/mercury_engine.c: library/exception.m: extras/aditi/aditi.m: Add MR_ prefixs to do_fail, do_redo, do_not_reached, etc. compiler/trace.m: compiler/fact_table.m: compiler/llds_out.m: Add MR_ prefixes to the generated code. |
||
|
|
e05f2a4780 |
Add support for using a different C calling convention for the
Estimated hours taken: 16 Add support for using a different C calling convention for the C functions generated by the MLDS back-end, if you're on x86 and you define MR_USE_REGPARM. The code do to this uses GNU C's function attributes extension; it will only work if you have the latest snapshot versions of gcc. So MR_USE_REGPARM is not enabled by default. compiler/ml_call_gen.m: For higher-order calls and class method calls, assign the function pointer to a local variable. This is needed for current versions of gcc, since gcc doesn't support function attributes on function types in function pointer type casts. compiler/mlds_to_c.m: Output "MR_CALL" in function declarations. Also output a reference to MR_GRADE_VAR, like we do for the LLDS back-end. runtime/mercury_std.h: Define MR_CALL. This is a macro that can expand to some implementation-specific C extension to specify the calling convention used for the MLDS back-end. E.g. for gcc, on x86, if MR_USE_REGPARM is defined it expands to `__attribute__((__regparm__(3), __stdcall__))'. runtime/mercury_conf_param.h: Document MR_USE_REGPARM. runtime/mercury_grade.h: Encode the setting of MR_USE_REGPARM in the mangled grade name. runtime/mercury_types.h: runtime/mercury.h: runtime/mercury.c: runtime/mercury_wrapper.h: runtime/mercury_wrapper.c: util/mkinit.c: library/array.m: library/builtin.m: library/exception.m: Use MR_CALL for functions that should have the Mercury calling convention. runtime/mercury_types.h: runtime/mercury.h: Move the definition of MR_Cont and MR_NestedCont from mercury_types.h to mercury.h. This was needed to avoid a cyclic header dependency problem and is also a good idea anyway, since MR_Cont and MR_NestedCont are specific to the MLDS back-end. |
||
|
|
090552c993 |
Make everything in the runtime use MR_ prefixes, and make the compiler
Estimated hours taken: 10 Make everything in the runtime use MR_ prefixes, and make the compiler bootstrap with -DMR_NO_BACKWARDS_COMPAT. runtime/mercury_*.[ch] Add MR_ prefixes to all functions, global variables and almost all macros that could pollute the namespace. The (intentional) exceptions are 1. some function, variable, type and label names that already start with MR_, mercury_, Mercury or _entry; 2. some standard C macros in mercury_std.h; 3. the macros used in autoconfiguration (since they are used in scripts as well as the runtime, the MR_ prefix may not be appropriate for those). In some cases, I deleted things instead of adding prefixes if the "things" were obsolete and not user visible. runtime/mercury_bootstrap.h: Provide MR_-less forms of the macros for bootstrapping and for backward compatibility for user code. runtime/mercury_debug.[ch]: Add a FILE * parameter to a function that needs it. compiler/code_info.m: compiler/export.m: compiler/fact_table.m: compiler/llds.m: compiler/llds_out.m: compiler/pragma_c_gen.m: compiler/trace.m: Add MR_ prefixes to the C code generated by the compiler. library/*.m: Add MR_ prefixes to handwritten code. trace/mercury_trace_*.c: util/mkinit.c: Add MR_ prefixes as necessary. extras/concurrency/semaphore.m: Add MR_ prefixes as necessary. |
||
|
|
a947a3c84f |
Fix a bug in the implementation of `pragma export': map polymorphic
Estimated hours taken: 1 Fix a bug in the implementation of `pragma export': map polymorphic arguments to `MR_Word', as the Mercury language reference manual requires, rather than to `MR_Box'. compiler/export.m: Map polymorphic arguments to `MR_Word' rather than `MR_Box'. runtime/mercury.h: runtime/mercury_init.h: runtime/mercury_wrapper.h: runtime/mercury_wrapper.c: Use `MR_Word' rather than `MR_Box' in various type declarations, to match what the compiler now outputs for `pragma export' procedures. library/exception.m: Add a comment. |
||
|
|
5bf9171cf1 |
Fix a type error in MLDS grades: the parameters to
Estimated hours taken: 0.5 runtime/mercury_wrapper.h: Fix a type error in MLDS grades: the parameters to MR_io_print_to_cur_stream and MR_io_print_to_stream that represent polymorphically typed arguments in Mercury should have type `MR_Box' rather than `MR_Word'. |
||
|
|
b32f9e573e |
This is part 1 of a change that provides a register of all the types defined
Estimated hours taken: 6
This is part 1 of a change that provides a register of all the types defined
in the program. After this change, every .c file generated by the compiler
will have three separate initialization functions:
- One that does the initializations that must be performed before
any code is executed, such as recording the addresses of labels
in grades that don't allow direct jumps and filling in the code_addr
slots of type_ctor_infos.
- One that registers the type_ctor_infos of the types defined in this
module in a global table.
- One that initializes the data structures needed by the debugger;
i.e. registers the module layout in a global table.
For now, the first function calls the third, since this is required for
backwards compatibility of traced code; this call will go away later.
For now, the second function is not called from anywhere. Part 2 of this
change will add two functions to the _init.c file generated by c2init that
call the second function and third function respectively in each module
in the program.
This change affects only the LLDS backend; Fergus or Tyson should look into
providing this functionality for the MLDS backend as well.
This change only registers type_ctor_infos; it does not register
base_typeclass_infos. DJ and I have discussed this and agree that adding code
to register base_typeclass_infos would wasteful, because the work would almost
certainly have to be redone when constructor classes are implemented;
therefore registering base_typeclass_infos should be postponed until then.
compiler/llds_out.m:
compiler/rtti_out.m:
Generate the code for the two new initialization functions.
runtime/mercury_wrapper.[ch]:
Add the functions do_init_modules_{type_tables,debugger},
which are intended to eventually invoke the corresponding
initialization functions in the compiler-generated .c files
through the c2init-generated _init.c file, which themselves
are accessed through pointers in accordance with the link-order
convention. For now, these pointers will be NULL; part 2
will change that.
runtime/mercury_type_tables.[ch]:
New module that provides a capability of looking up MR_TypeCtorInfos
specified by a modulename/typename pair.
runtime/Mmakefile:
runtime/mercury_imp.h:
Include the new header file.
runtime/mercury_tabling.[ch]:
Allow a trie node to contain a list pointer; the type table is
implemented as a expandable hash table whose slots are lists of
type_ctor_infos.
runtime/mercury_dlist.[ch]:
Make this module conform to our naming conventions. Make the type of
list elements const, in order to avoid warnings when using lists in
mercury_type_tables.c.
runtime/mercury_hash_table.[ch]:
Minor changes to conform to the new names in mercury_dlist.[ch].
runtime/*.[ch]:
Fix indentation problems caused by past automatic substitutions.
|
||
|
|
7d66a930c7 |
Allow multiple browser commands on one line, separated by semicolons.
Estimated hours taken: 3 Allow multiple browser commands on one line, separated by semicolons. trace/mercury_trace_internal.c: trace/mercury_trace_internal.h: Separate the code for splitting lines and checking for EOF into a new function, MR_trace_get_command. browser/parse.m: Call util__trace_get_command to read each command. browser/util.m: Implement util__trace_get_command, which calls the function in the trace directory via an indirect pointer. runtime/mercury_init.h: runtime/mercury_wrapper.c: runtime/mercury_wrapper.h: util/mkinit.c: Set up the indirect pointer to the new function. tests/debugger/browser_test.inp: tests/debugger/browser_test.exp: tests/debugger/browser_test.exp2: Test the new feature. |
||
|
|
db64a3588d |
Add MR_ prefixes to the types used when generating C code.
Estimated hours taken: 4 Add MR_ prefixes to the types used when generating C code. This means types such as Word, String, Bool, Float become MR_Word, MR_String, MR_Bool, MR_Float. Also define MR_Box for both the LLDS and MLDS backends so we can use it uniformly. This is very important in environments where String or Bool have already been used as system types (for example, managed C++). And besides, we should do it anyway as part of the grand namespace cleanup. I have fixed all of the uses of the non-prefixed types in the runtime and trace directories. I haven't done it for the library and compiler directories yet (no promises that I will do it in future either). But if you see a non-prefixed type in code from now on, please consider it a bug and fix it. mercury_bootstrap.h contains #defines to map the non-prefixed types into the prefixed ones. Like many of the other namespace cleaning backwards compatibility macros, this can be turned off with MR_NO_BACKWARDS_COMPAT. This shouldn't break any code, but this kind of change affects so many things that of course there could be problems lurking in there somewhere. If you start getting errors from the C compiler after this change is installed, you will want to make sure you at least have the runtime system updated so that you are getting the backwards compatibility definitions in mercury_bootstrap.h. Then if you continue to have problems you can bug me about it. compiler/export.m: compiler/llds_out.m: compiler/mlds_to_c.m: Use MR_Word, MR_Float, MR_Bool, etc when generating C. doc/reference_manual.texi: Update the reference manual to talk about MR_Word, MR_String, MR_Char, etc. runtime/mercury_bootstrap.h: Add bootstrapping typedefs. runtime/*: trace/*: Change Word, Float, Bool, Code, String, etc to MR_Word, MR_Float, MR_Bool, MR_Code, MR_String. |
||
|
|
aa3f54f73f |
More work on the MLDS back-end.
Estimated hours taken: 6
More work on the MLDS back-end.
runtime/mercury.c:
Fix a cut-and-paste bug in the code for compare/3:
I forgot to add `break' after each case of a `switch' statement.
library/builtin.m:
library/private_builtin.m:
Replace the hand-coded definition of builtin_{compare,unify}_pred
in builtin.m with ordinary Mercury clauses in private_builtin.m.
This ensures that it works with the MLDS back-end.
(It also means that these procedures call error/1 rather than
MR_fatal_error(), so you get an exception rather than a
program abort.)
runtime/mercury.h:
runtime/mercury.c:
Add declarations and definitions of the compare and unify
procedures for the builtin types. (For some types,
the definitions here are still just stubs.)
runtime/mercury.h:
runtime/mercury.c:
runtime/mercury_init.h:
Add some hacks to work-around the current lack of support
for `pragma export'.
runtime/mercury_type_info.c:
If MR_HIGHLEVEL_CODE is defined, don't #include "mercury_imp.h",
since it is not needed.
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
Add support for the MLDS back-end to the program start-up
code.
|
||
|
|
72456eb509 |
Delete the variables that supported statistics about index operations,
Estimated hours taken: 0.1 runtime/mercury_wrapper.[ch]: Delete the variables that supported statistics about index operations, since the runtime is not involved in index operations any more, and thus cannot collect statistics. |
||
|
|
184e4710b1 |
Get the system to work with --no-special-preds, relying on RTTI interpretation
Estimated hours taken: 30
Get the system to work with --no-special-preds, relying on RTTI interpretation
to perform unifications and comparisons, in almost all cases. The only thing
that doesn't work is comparisons involving types with user-defined equality;
the generated exception does not get propagated across MR_call_engine
boundaries properly.
compiler/make_hlds.m:
With --no-special-spreds, do not generate even declarations for
type-specific index and compare predicates. Generate declarations
and clauses for type-specific unify predicates, since we may need
them for unifications that are not (in,in). However, we prevent
the generation of code for the (in,in) case (i.e. mode 0) by pretending
that the unify predicate is pseudo_imported, even in the module
defining the type. There is one exception to this: for types with
user-defined equality, we do generate a proper __Unify__ predicate,
since this is the only convenient way to convert the specified
sym_name of the equality predicate into a pred_id and proc_id,
and a proper __Compare__ predicate, since this is the only convenient
way to generate the full type name for the error message at runtime
(due to polymorphism, the full type may not be known at compile time).
(Finding the pred_id may require resolving type overloading,
and finding the proc_id may require mode checking.)
compiler/simplify.m:
When converting complicated unifications to calls, call the generic
unify/2 and compare/3 predicates instead of the type-specific
__Unify__ and __Compare__ predicates, if the latter do not exist.
compiler/higher_order.m:
Do not specialize calls to the generic unify/2 and compare/3 predicates
to type-specific __Unify__ and __Compare__ predicates, if the latter
do not exist.
Previously, we were not specializing comparisons of builtins and
enumerations here, leaving it to inlining. In the absence of
--special-preds, that doesn't work for enumerations, since there
is no compiler-generated comparison predicate to do the inlining in.
We therefore now perform both specializations.
compiler/polymorphism.m:
Fix a bug: the code for looking up the special preds for user defined
types was handling enums as builtins, which they are not: they can have
user-defined equality.
compiler/type_ctor_info.m:
Even with --no-special-preds, the type has type-specific __Unify_
and __Compare__ predicates if it has user-defined equality. These
predicates must be, and now are, put into the type_ctor_info.
runtime/mercury_wrapper.[ch]:
Expand the facilities for collecting statistics about unify, index
and compare operations. We used to collect only counts of operations
for each type_ctor_rep; we now also collect counts of operations
for each specific type. Rename MR_CTOR_REP_STATS as MR_TYPE_CTOR_STATS
to reflect this expansion.
runtime/mercury_conf_param.h:
Document MR_TYPE_CTOR_STATS instead of MR_CTOR_REP_STATS.
runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
Fix a bug that showed with --no-special-preds: the Mercury predicate
unify_2_0 cannot call the MR_generic_compare function to handle the
arguments of a function symbol, because comparison is not defined
on types with user-defined equality. Instead, we need to call the new
MR_generic_unify C function, which does work on such types.
Fix a bug that showed with --no-special-preds: the MR_succip register
has to be saved and restored across calls to MR_generic_unify, since
for types with user-defined equality, such calls involve a recursive
invocation of the Mercury engine.
Optimize the unification of du types by performing only one
functor_desc lookup instead of two, and failing as early as possible.
Use the new statistics facilities provided by mercury_wrapper.c.
tools/bootcheck
If the new --type-stats option is given, preserve the type constructor
statistics derived from (a) the stage 3 compilation process, and (b)
compiling the test suite, for later analysis.
tools/type_ctor_stats:
A new shell script to analyze type constructor statistics in their
new, expanded format.
tests/hard_coded/user_defined_equality.{m,exp}:
Test comparisons as well as unifications on enums with user-defined
equality.
|
||
|
|
7898c7529f |
Split the code to initialize the conservative
Estimated hours taken: 0.5 runtime/mercury_wrapper.h: runtime/mercury_wrapper.c: Split the code to initialize the conservative garbage collector out into a separate function, for use by the --high-level-code back-end. |
||
|
|
914cb6de16 |
Remove the dependency of the Aditi interface library in
Estimated hours taken: 1 Remove the dependency of the Aditi interface library in extras/aditi/aditi.m on code in the automatically generated C init file. runtime/mercury_wrapper.h: Add a global variable `MR_address_of_do_load_aditi_rl_code'. Add a function `MR_load_aditi_rl_code', which calls the function pointed to by `MR_address_of_do_load_aditi_rl_code', aborting if it is not set. runtime/mercury_init.h: Remove the declaration for `mercury__load_aditi_rl_code()' -- that is now local to the `<module>_init.c' file. util/mkinit.c: Rename `mercury__load_aditi_rl_code' to `MR_do_load_aditi_rl_code()' in the `<module>_init.c' file, and add a static prototype for it. Add a statement to `mercury_init()' to fill in the `MR_address_of_do_load_aditi_rl_code' variable. extras/aditi/aditi.m: Rename `mercury__load_aditi_rl_code()' to `MR_load_aditi_rl_code()'. |
||
|
|
c9b940ed69 |
Add support for catching interrupts (i.e. SIGINT signals,
Estimated hours taken: 2 Add support for catching interrupts (i.e. SIGINT signals, normally generated by control-C) in the debugger. runtime/mercury_wrapper.h: runtime/mercury_wrapper.c: Add declaration and definition of a new variable MR_address_of_trace_interrupt_handler. runtime/mercury_trace_base.c: Add code to MR_trace_start() to call MR_setup_signal() to install the function pointed to by MR_address_of_trace_interrupt_handler as the signal handler for SIGINT signals. runtime/mercury_init.h: Add declaration for MR_trace_interrupt_handler(). util/mkinit.c: Add code to initialize MR_address_of_trace_interrupt_handler to point to MR_trace_interrupt_handler(). trace/mercury_trace.c: Add MR_trace_interrupt(), which is like MR_trace_real(), except that it enters the interactive debugger unconditionally. Add MR_trace_interrupt_handler(); this function just sets MR_trace_func_ptr to MR_trace_interrupt(), so that a SIGINT will cause the interactive debugger to be entered at the next call to MR_trace(). trace/mercury_trace_internal.h: trace/mercury_trace_internal.c: Add MR_trace_interrupt_message(), which prints a message indicating that the debugger caught an interrupt. |
||
|
|
0642a10ff8 |
Reduce the number of arguments of MR_trace() to one.
Estimated hours taken: 24 WARNING: this change affects binary compatibility for debuggable code; the debuggable modules of the program and the runtime linked into the executable must either all come from before this change, or they must all come from after this change. However, this change does *not* affect binary compatibility for non-debuggable executables. Reduce the number of arguments of MR_trace() to one. Two of the arguments, the port and the goal path, move into the label layout structure, as 16-bit numbers; the port as a simple enumeration type, and the goal path as an index into the module-wide string table. (The latter will eventually allow the debugger to support the placement of breakpoints on labels with specific goal paths.) The third argument, the number of the highest-numbered rN register in use at the label, has been moved into the proc layout structure. In theory, this will require more register saves and restores, since the number in the proc layout is conservative (it is the max of the numbers that would be required at the individual labels). However, this is not important, for two reasons. First, we always save and restore all the rM registers that appear in the mrM array before the last special-purpose register, and in most cases this dictates how many registers we save/restore. Second, we save/restore registers only when the debugger starts interaction, so save/restore is a time critical activity only for the external debugger. This change reduces the execution time of debuggable executables by about 4-5% when executing outside mdb and 3-4% when executing under mdb. It also reduces executable sizes, but only by about 0.7% on x86. This change eliminates the --trace-just-in-case compiler option, since we now have the best of both --trace-just-in-case and --no-trace-just-in-case. The drawback of this scheme is slightly increased executable size with the accurage garbage collector, but that seems a small enough price to pay. compiler/code_gen.m: compiler/code_info.m: Record the number of the highest numbered rN register live at a trace label. compiler/continuation_info.m: Record the number of the highest numbered rN register live at a trace label, and the port and goal path associated with the labels of trace events. compiler/stack_layout.m: Put the number of the highest numbered rN register live at a trace label into proc layouts, and the port and goal path into label layouts. Since we are breaking binary compatibility with old debuggable modules anyway, compress the procedure id parts of proc layouts by using only 16 bits to store the procedure's arity and mode number, instead of 32 or 64. compiler/trace.m: Update the handling of ports, goal paths and max live register numbers, so that instead of being passed as MR_trace arguments, they are recorded in data structures. Generate separate labels and layouts for the fail and redo events. Although they still have the same layout information, they now record different ports. compiler/llds.m: Since trace.m now generates a label layout structure for the redo event, we must include redo events in the llds goal path type. compiler/hlds_goal.m: Since the code for handling the port type for nondet pragma events has moved from the nondet-pragma-specific to the generic part of trace.m, we must now include their event types in the hlds goal path type. compiler/llds_out.m: Add a predicate for converting ports into numbers, now that we must store ports in static data. Using their symbolic names would be better, but that would require complications in the llds type system, which would be inadvisable just before the release. compiler/options.m: compiler/handle_options.m: doc/user_guide.texi: Eliminate --trace-just-in-case. compiler/llds.m: compiler/llds_common.m: compiler/llds_out.m: Eliminate the data structure needed by --trace-just-in-case. compiler/optimize.m: Trivial update to conform to data structure changes. library/exception.m: Update the call to MR_trace. runtime/mercury_stack_layout.h: Update the C structure declarations for the layout structures as discussed above. runtime/mercury_init.h: Update the declarations of MR_trace_real and MR_trace_fake to use only one argument. runtime/mercury_wrapper.[ch]: Update the declaration of MR_trace_func to use only one argument. runtime/mercury_trace_base.[ch]: Update the declarations of MR_trace, MR_trace_real and MR_trace_fake to use only one argument. Delete MR_trace_struct(); since we deleted --trace-just-in-case, there will not be calls to it anymore. Since we are breaking binary compatibility anyway, move the exception port to be with the other interface ports. This should speed up a frequently executed test in the debugger. Update the handling of redo events. trace/mercury_trace.h: Simplify and speed up the macro that tests a port for being an interface port, now that exceptions are grouped with other interface events. trace/mercury_trace.c: Update the definition of MR_trace_real to use only one argument. The port is pulled out of the label layout structure only when needed to perform the termination tests for the current debugger command, and the goal path and the max live register number are looked up only when the termination test succeeds. |
||
|
|
9179be5e15 |
Implement a new data structure for declarative debugging.
Estimated hours taken: 160
Implement a new data structure for declarative debugging. The
major differences between this and the old implementation are:
- The data structure is implemented in Mercury. The definition
of the type, and procedures for constructing values of that
type, have been moved from trace/mercury_trace_declarative.{c,h}
to browser/declarative_execution.m (which is a new module).
- The front end no longer needs to call the back end via an
indirect pointer---the front end does not call the back end at
all.
- The data structure is not specifically for wrong answer
analysis, it is intended to be used for any sort of analysis.
- The data structure represents execution at a lower level---the
new front end defines a more abstract view in terms of this
data structure.
Implement a test harness for debugging the front end code. This allows
the front end to run as a stand-alone program, which can then be
debugged using `mdb'.
The code in the front end does not currently handle the new structure
very nicely. This is because that code is about to undergo some major
structural changes, so there is little point cleaning it up now.
Consequently:
- Some of the code in the front end is incorrect (eg. the
user interface does not print missing answer nodes
properly).
- The tests have not been reinstated.
These things will be fixed in subsequent changes.
Likewise the compiler still reserves two stack slots, even though
only one is required. After this change the algorithm should be able
to get away with using no stack slots, so modifications to the compiler
will be postponed until then.
browser/declarative_execution.m:
New module. Implement the execution_tree typeclass, which
represents the execution of a Mercury program. Implement
two instances of this typeclass, one for normal use and one for
testing purposes.
browser/declarative_test.m:
New module. A test harness that can be compiled as a
stand-alone program, enabling the front end to be debugged.
trace/mercury_trace_declarative.c:
trace/mercury_trace_declarative.h:
- Remove the definition of the old data structure.
- Add some macros which enable the new Mercury data structure
to be destructively updated by C code.
- Change the interface to this module so that it reflects more
general diagnosis, not just wrong answer analysis.
- Implement the new algorithm.
- Call an alternative front end if in test mode.
- Update comments.
trace/mercury_trace_internal.h:
Add a new mode for debugging the declarative debugger.
trace/mercury_trace_internal.c:
Change the command from `dd_wrong' to `dd', since it is not
specifically for wrong answer analysis. Add a new command
`dd_dd' which calls the alternative front end used for testing.
runtime/mercury_init.h:
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
util/mkinit.c:
Remove any reference to `MR_edt_root_node', since it is no
longer used.
browser/declarative_debugger.m:
- Add a case for missing answer nodes to `edt_node'.
- Change the `evaluation_tree' typeclass into `mercury_edt'
typeclass. This is to make it more distinct from the new
`execution_tree' typeclass, which is a lower level concept.
- New interface to the diagnoser: types `diagnoser_response'
and `diagnoser_state', and procedure `diagnosis'.
- Define an instance of `mercury_edt' from an instance of
`execution_tree'.
- Updates to the analyser to get it to compile---further changes
will be forthcoming.
browser/declarative_user.m:
- Updates to the user interface to get it to compile---further
changes will be forthcoming.
browser/browser_library.m:
Import the new module (declarative_execution.m).
browser/debugger_interface.m:
browser/util.m:
Move the definitions of trace_port_type and goal_path_string
to browser/util.m, since they are now used by more than just
the external debugger.
browser/Mmakefile:
Add the test harness as a `depend' target.
browser/browse_test.m:
Use the correct interface to the browser.
|
||
|
|
9c5f356c1c |
If MR_CTOR_REP_STATS is defined, collect statistics about the
Estimated hours taken: 2 runtime/mercury_ho_call.c: If MR_CTOR_REP_STATS is defined, collect statistics about the type_ctor_reps that the builtin unify, index and compare preds are invoked with. runtime/mercury_wrapper.h: If MR_CTOR_REP_STATS is defined, export three arrays for these statistics. runtime/mercury_wrapper.c: If MR_CTOR_REP_STATS is defined, define these three arrays, and append their contents at the end of execution to the file whose name is given by the MR_CTOR_REP_STATS macro. runtime/mercury_conf_param.h: Document MR_CTOR_REP_STATS. runtime/mercury_type_info.h: Document the dependency of MR_CTOR_REP_STATS on UNKNOWN as the last alternative in MR_TypeCtorRepresentation. tools/ctor_rep_stats: An awk swcript for analyzing the statistics. |