mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 13:23:53 +00:00
ada4e26dd11e052f8f244cb0af94208f4d329452
170 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
637c76926d |
Add some preliminary infrastructure for an HLDS->Erlang code generator.
Estimated hours take: 4
Branches: main
Add some preliminary infrastructure for an HLDS->Erlang code generator.
compiler/globals.m:
compiler/options.m:
Recognise "erlang" as a valid compilation target.
Add new options: `--erlang' and `--erlang-only' as synonyms
for `--target erlang' and `--target erlang --target-code-only'.
XXX the new options are currently undocumented.
compiler/hlds_data.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
Recognise "Erlang" as a valid language for foreign code.
compiler/handle_options.m:
For erlang targets, set the gc_method to automatic and disable
optimize_constructor_last_call.
compiler/add_pragma.m:
compiler/add_type.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/export.m:
compiler/foreign.m:
compiler/granularity.m:
compiler/intermod.m:
compiler/llds_out.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_gen.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/modules.m:
compiler/pragma_c_gen.m:
compiler/prog_foreign.m:
compiler/simplify.m:
Conform to the above changes.
|
||
|
|
ba93a52fe7 |
This diff changes a few types from being defined as equivalent to a pair
Estimated hours taken: 10 Branches: main This diff changes a few types from being defined as equivalent to a pair to being discriminated union types with their own function symbol. This was motivated by an error message (one of many, but the one that broke the camel's back) about "-" being used in an ambiguous manner. It will reduce the number of such messages in the future, and will make compiler data structures easier to inspect in the debugger. The most important type changed by far is hlds_goal, whose function symbol is now "hlds_goal". Second and third in importance are llds.instruction (function symbol "llds_instr") and prog_item.m's item_and_context (function symbol "item_and_context"). There are some others as well. In several places, I rearranged predicates to factor the deconstruction of goals into hlds_goal_expr and hlds_goal_into out of each clause into a single point. In many places, I changed variable names that used "Goal" to refer to just hlds_goal_exprs to use "GoalExpr" instead. I also changed variable names that used "Item" to refer to item_and_contexts to use "ItemAndContext" instead. This should make reading such code less confusing. I renamed some function symbols and predicates to avoid ambiguities. I only made one algorithmic change (at least intentionally). In assertion.m, comparing two goals for equality now ignores goal_infos for all kinds of goals, whereas previously it ignored them for most kinds of goals, but for shorthand goals it was insisting on them being equal. This seemed to me to be a bug. Pete, can you confirm this? |
||
|
|
d66ed699a1 |
Add fields to structures representing the C code itself that says whether
Estimated hours taken: 4 Branches: main Add fields to structures representing the C code itself that says whether or not the C code affects the liveness of lvals. This is intended as the basis for future improvements in the optimization of such code. Implement a new foreign_proc attribute that allows programmers to set the value of this field. Eliminate names referring to `pragma c_code' in the LLDS backend in favor of names referring to foreign_procs. compiler/llds.m: Make the changes described above. Consistently put the field containing C code last in the function symbols that contain them. compiler/prog_data.m: Make the changes described above. Rename some other function symbols to avoid ambiguity. compiler/prog_io_pragma.m: Parse the new foreign_proc attribute. doc/reference_manual.texi: Document the new attribute. compiler/pragma_c_gen.m: Rename the main predicates. compiler/opt_util.m: Change some predicates into functions, for more convenient invocation. compiler/livemap.m: Rename the predicates in this module to avoid ambiguity and the need for module qualification. compiler/*.m: Conform to the changes above. |
||
|
|
b4c3bb1387 |
Clean up in unused module imports in the Mercury system detected
Estimated hours taken: 3 Branches: main Clean up in unused module imports in the Mercury system detected by --warn-unused-imports. analysis/*.m: browser/*.m: deep_profiler/*.m: compiler/*.m: library/*.m: mdbcomp/*.m: profiler/*.m: slice/*.m: Remove unused module imports. Fix some minor departures from our coding standards. analysis/Mercury.options: browser/Mercury.options: deep_profiler/Mercury.options: compiler/Mercury.options: library/Mercury.options: mdbcomp/Mercury.options: profiler/Mercury.options: slice/Mercury.options: Set --no-warn-unused-imports for those modules that are used as packages or otherwise break --warn-unused-imports, e.g. because they contain predicates with both foreign and Mercury clauses and some of the imports only depend on the latter. |
||
|
|
f5b9218821 |
Switch on the foreign_language type rather than using an if-then-else
Estimated hours taken: 0.2 Branches: main Switch on the foreign_language type rather than using an if-then-else wherever we can. This makes it easier for the compiler to identify spots that might need to be changed when adding support for new backends or foreign languages. compiler/mlds.m: Rename the type target_lang to mlds_target_lang. Rename the constructors of the above type so they don't clash with those of the foreign_language type. Also comment out some of those that don't correspond to any language that we currently target. compiler/code_gen.m: compiler/export.m: compiler/llds_out.m: compiler/ml_closure_gen.m: compiler/ml_code_gen.m: compiler/mlds_to_c.m: compiler/mlds_to_gcc.m: compiler/mlds_to_java.m: Switch on foreign languages rather than using if then-elses. Conform to the above change. compiler/mlds_to_io.m: As above, also abort if we encounter any MLDS trail ops rather than generating a comment. (Trail ops for the MLDS backends are currently handled as a HLDS->HLDS pass.) |
||
|
|
00741b0162 |
This diff contains no algorithmic changes.
Estimated hours taken: 6 Branches: main This diff contains no algorithmic changes. It merely renames apart a bunch more function symbols to reduce ambiguity. After this diff, the summary line from the mdb command "ambiguity -f" is Total: 351 names used 975 times, maximum 31, average: 2.78 browser/*.m: compiler/*.m: Rename function symbols to eliminate ambiguities. tests/debugger/declarative/dependency.exp: tests/debugger/declarative/dependency2.exp: Update the expected out where some internal function symbol names appear in the output of the debugger. (This output is meant for implementors only.) |
||
|
|
2b2f3d3cbe |
This diff contains no algorithmic changes.
Estimated hours taken: 8 Branches: main This diff contains no algorithmic changes. It merely renames apart a bunch of function symbols to reduce ambiguity. Basically I went through prog_data.m, prog_item.m, hlds_data.m, hlds_goal.m and hlds_pred.m looking for type definitions containing function symbol names that were either language "keywords" (e.g. "terminates", which is an annotation on foreign_procs), used with slightly different meanings in several types (e.g. "sym"), or both (e.g. "call"). When I found such type definitions, I changed the names of the function symbols, usually by adding a prefix or suffix indicating the type to all function symbols of the type. For example, the old function symbol "foreign_proc" in type "pragma_type" is now named "pragma_foreign_proc", and the names of all other function symbols in that type also start with "pragma_". All of this should yield simpler compiler error messages when we make mistakes, and will make it more likely that looking up a function symbol using a tags file will take you to the actual definition of the relevant instance of that function symbol. However, the most important benefit is the increase in the readability of unfamiliar code; the reader won't have to emulate the compiler's type ambiguity resolution algorithm (which in many cases used to require distinguishing between f/14 and f/15 by counting the arguments, e.g. for "pred_or_func"). compiler/prog_data.m: compiler/prog_item.m: compiler/hlds_data.m: compiler/hlds_goal.m: compiler/hlds_pred.m: Rename function symbols as explained above. compiler/*.m: Conform to the function symbol renames. In some cases, rename other function symbols as well. Minor style fixes, e.g. replace if-then-elses with switches, or simple det predicates with functions. |
||
|
|
aeeedd2c13 |
Standardize formatting of comments at the beginning of modules.
compiler/*.m: Standardize formatting of comments at the beginning of modules. |
||
|
|
9d23d8e2e7 |
Implement the trace goal construct we discussed, for now for the LLDS backends
Estimated hours taken: 70
Branches: main
Implement the trace goal construct we discussed, for now for the LLDS backends
only.
Since the syntax of trace goals is non-trivial, useful feedback on syntax
errors inside trace goal attributes is essential. With the previous setup, this
wasn't possible, since the code that turned terms into parse tree goals turned
*all* terms into goals; it couldn't recognize any errors, sweeping them under
the rug as calls. This diff changes that. Now, if this code recognizes a
keyword that indicates a particular construct, it insists on the rest of the
code following the syntax required for that construct, and returns error
messages if it doesn't.
We handle the trace goal attributes that specify state variables to be threaded
through the trace goal (either the I/O state or a mutable variable) in
add_clause.m, at the point at which we transform the list of items to the HLDS.
We handle the compile-time condition on trace goals in the invocation of
simplify at the end of semantics analysis, by eliminating the goal if the
compile-time condition isn't met. We handle run-time conditions on trace goals
partially in the same invocation of simplify: we transform trace goals with
runtime conditions into an if-then-else with the trace goal as the then part
and `true' as the else part, the condition being a foreign_proc that is handled
specially by the code generator, that special handling being to replace
the actual code of the foreign_proc (which is a dummy) with the evaluation of
the runtime condition.
Since these changes require significant changes to some of our key data
structures, I took the liberty of doing some renaming of function symbols
at the same time to avoid using ambiguities with respect to language keywords.
library/ops.m:
Add "trace" as an operator.
compiler/prog_data.m:
Define data types to represent the various attributes of trace goals.
Rename some function symbols to avoid ambiguities.
compiler/prog_item.m:
Extend the parse tree representation of goals with a trace goal.
compiler/mercury_to_mercury.m:
Output the new kind of goal and its components.
compiler/hlds_goal.m:
Extend the HLDS representation of scopes with a scope_reason
representing trace goals.
Add a mechanism (an extra argument in foreign_procs) to allow
the representation of goals that evaluate runtime trace conditions.
Since this requires modifying all code that traverses the HLDS,
do some renames that were long overdue: rename not as negation,
rename call as plain_call, and rename foreign_proc as
call_foreign_proc. These renames all avoid using language keywords
as function symbols.
Change the way we record goals' purities. Instead of optional features
to indicate impure or semipure, which is error-prone, use a plain
field in the goal_info, accessed in the usual way.
Add a way to represent that a goal contains a trace goal, and should
therefore be treated as if it were impure when considering whether to
optimize it away.
Reformat some comments describing function symbols.
compiler/hlds_out.m:
Output the new construct in the HLDS.
compiler/prog_io_util.m:
Generalize the maybe[123] types to allow the representation of more
than one error message. Add functions to extract the error messages.
Add a maybe4 type. Rename the function symbols of these types to
avoid massive ambiguity.
Change the order of some predicates to bring related predicates
next to each other.
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
Rework these modules almost completely to find and accumulate syntax
errors as terms are being parsed. In some cases, this allowed us to
replace "XXX this is a hack" markers with meaningful error-reporting
code.
In prog_io_goal.m, add code for parsing trace goals.
In a bunch of places, update obsolete coding practices, such as using
nested chains of closures instead of simple sequential code, and
using A0 and A to refer to values of different types (terms and goals
respectively). Use more meaningful variable names.
Break up some too-large predicates.
compiler/superhomogeneous.m:
Find and accumulate syntax errors as terms are being parsed.
compiler/add_clause.m:
Add code to transform trace goals from the parse tree to the HLDS.
This is where the IO state and mutable variable attributes of trace
goals are handled.
Eliminate the practice of using the naming scheme Body0 and Body
to refer to values of different types (prog_item.goal and hlds_goal
respectively).
Use error_util for some error messages.
library/private_builtin.m:
Add the predicates referred to by the transformation in add_clause.m.
compiler/goal_util.m:
Rename a predicate to avoid ambiguity.
compiler/typecheck.m:
Do not print error messages about missing clauses if some errors have
been detected previously.
compiler/purity.m:
Instead of just computing purity, compute (and record) also whether
a goal contains a trace goal. However, treat trace goals as pure.
compiler/mode_info.m:
Add trace goals as a reason for locking variables.
Rename some function symbols to avoid ambiguity.
compiler/modes.m:
When analyzing trace goal scopes, lock the scope's nonlocal variables
to prevent them from being further instantiated.
compiler/det_analysis.m:
Insist on the code in trace goal scopes being det or cc_multi.
compiler/det_report.m:
Generate the error message if the code in a trace goal scope isn't det
or cc_multi.
compiler/simplify.m:
At the end of the front end, eliminate trace goal scopes if their
compile-time condition is false. Transform trace goals with runtime
conditions as described at the top.
Treat goals that contain trace goals as if they were impure when
considering whether to optimize them away.
compiler/mercury_compile.m:
Tell simplify when it is being invoked at the end of the front end.
Rename a predicate to avoid ambiguity.
compiler/trace_params.m:
Provide the predicates simplify.m need to be able to evaluate the trace
goal conditions regarding trace levels.
compiler/trace.m:
compiler/trace_gen.m:
Rename the trace module as trace_gen, since "trace" is now an operator.
Rename some predicates exported by the module, now that it is no longer
possible to preface calls with "trace." as a module qualifier.
compiler/notes/compiler_design.html:
Document this name change.
compiler/options.m:
Rename the trace option as trace_level internally, since "trace"
is now an operator. The user-visible name remains the same.
Add the new --trace-flag option.
Delete an obsolete option.
compiler/handle_options.m:
Rename the function symbols of the grade_component type,
since "trace" is now an operator.
compiler/llds.m:
Extend the LLDS with a mechanism to refer to C global variables.
For now, these are used to refer to C globals that will be created
by mkinit to represent the initial values of the environment variables
referred to by trace goals.
compiler/commit_gen.m:
Check that no trace goal with a runtime condition survives to code
generation; they should have been transformed by simplify.m.
compiler/code_gen.m:
Tell commit_gen.m what kind of scope it is generating code for.
compiler/pragma_c_gen.m:
Generate code for runtime conditions when handling the foreign_procs
created by simplify.m.
compiler/code_info.m:
Allow pragma_c_gen.m to record what environment variables it has
generated references to.
compiler/proc_gen.m:
Record the set of environment variables a procedure refers to
in the LLDS procedure header, for efficient access by llds_out.m.
compiler/llds_out.m:
Handle the new LLDS construct, and tell mkinit which environment
variables need C globals created for them.
compiler/pd_util.m:
Rename some predicates to avoid ambiguity.
compiler/*.m:
Conform to the changes above, mainly the renames of function symbols
and predicates, the changed signatures of some predicates, and the new
handling of purity.
util/mkinit.c:
Generate the definitions and the initializations of any C globals
representing the initial status (set or not set) of environment
variables needed by trace goals.
library/assoc_list.m:
Add some predicates that are useful in prog_io*.m.
library/term_io.m:
Minor cleanup.
tests/hard_coded/trace_goal_{1,2}.{m,exp}:
New test cases to test the new construct, identical except for whether
the trace goal is enabled at compile time.
tests/hard_coded/trace_goal_env_{1,2}.{m,exp}:
New test cases to test the new construct, identical except for whether
the trace goal is enabled at run time.
tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
Enable the new test cases.
tests/invalid/*.err_exp:
Update the expected output for the new versions of the error messages
now being generated.
|
||
|
|
74ce85d476 |
Provide a mechanism for collecting statistics about tabling operations,
Estimated hours taken: 60
Branches: main
Provide a mechanism for collecting statistics about tabling operations,
and provide a much more convenient mechanism for resetting tables.
Since it would too complex to do this while preserving the capability
of setting --tabling-via-extra-args to no, eliminate that capability
and the option. That option was useful only for measurements of the
performance boost from setting --tabling-via-extra-args to yes in any case,
so users lose no functionality.
Previously, the only way to debug the low level details of the tabling
mechanism was to build a runtime with a specific C macro (MR_TABLE_DEBUG)
and link with that runtime; this was cumbersome. Change that so that
every one of the debuggable tabling macros has a bool argument that says
whether debugging is enabled or not. The compiler can then set this to
MR_TRUE if the new option --table-debug is given, and to MR_FALSE otherwise.
If set to MR_FALSE, the C compiler should optimize away the debug code,
with zero impact on program size or speed.
Since these changes to macros require nontrivial bootstrapping, which we don't
want to do unnecessarily, modify the interface of the tabling macros as
required to support size limits on tables. This diff also implements the
parsing of size limit specifications on tables, but does not implement them
yet; that is for a future change.
To make the syntax simpler, this diff deletes the free-standing fast_loose_memo
pragma. The same functionality is now available with a fast_loose annotation
on an ordinary memo pragma.
Make a bunch of changes to improve readability and maintainability
in the process. These mostly take the form of renaming ambiguous and/or
not sufficiently expressive function symbols.
runtime/mercury_stack_layout.h:
runtime/mercury_tabling.h:
Move the description of structure of tables from mercury_stack_layout.h
to mercury_tabling.h, since we now need it for statistics even if
execution tracing is not enabled.
Modify those data structures to have room for the statistics.
Don't distinguish "strict", "fast_loose" and "specified" memoing
as separate eval methods; treat them as just different kinds
of the same eval method: "memo".
Remove underscores from the names of some types that the style guide
says shouldn't be there.
runtime/mercury_tabling_preds.h:
runtime/mercury_tabling_macros.h:
Modify the approach we use for macros that implement the predicates
of library/table_builtin.m. Instead of selecting between debug and
nondebug based on whether MR_TABLE_DEBUG is defined or not, add
an explicit argument controlling this to each debuggable macro.
The advantage of the new arrangement is that it scales. Another
argument controls whether we are computing statistics (and if yes,
where do we put it), and a third argument controls whether we maintain
back links in the tries and hash tables (this last argument is present
but is ignored for now).
Since the values of the arguments will be known when the .c files
containing calls to these macros are compiled, we pay the space and
time cost of debugging, statistics gathering and the maintenance of
back links if and only we need the revelant functionality.
Provide macros for limited backward compatibility with the old set
of macros; these allow workspaces created by old compilers to work
with the new macros in the runtime. The old macros followed the
naming scheme MR_table_*, the new ones are named MR_tbl_*.
runtime/mercury_table_int_fix_index_body.h:
runtime/mercury_table_int_start_index_body.h:
runtime/mercury_table_type_body.h:
New files containing parts of the old mercury_tabling.c. Each of these
files contains the body of the functions that used to be in
mercury_tabling.c. The new mercury_tabling.c #includes each of these
files more than once, to provide more than one variant of the old
function. These variants differ in aspects such as whether debugging
is enabled or statistics is being collected. Each variant therefore
incurs only the time costs it needs to. (We pay the space cost of
having all these variants all the time of course, but this cost
is negligible.)
runtime/mercury_tabling_stats_defs.h:
runtime/mercury_tabling_stats_nodefs.h:
runtime/mercury_tabling_stats_undefs.h:
New files that serve as wrappers around the newly #included files,
controlling how they handle statistics.
runtime/mercury_tabling.c:
Delete functions now in the new files, and #include them instead.
Delete the data structures that used to contain summary statistics;
the new approach keeps statistics in compiler-generated,
procedure-specific data structures.
runtime/mercury_trace_base.c:
Use the new versions of the tabling macros to access the I/O table.
runtime/mercury_type_info.h:
Update some documentation for the movement of code out of
mercury_tabling.c.
runtime/mercury_types.h:
Provide forward declarations of the identifiers denoting the new types
in mercury_tabling.h.
runtime/mercury_grade.h:
Increment the exec trace version number, since we have changed
a part of the exec trace structure.
runtime/mercury_bootstrap.h:
Fix some temporary issues that arise from some renames above.
runtime/mercury_hash_lookup_or_add_body.h:
Fix comment.
runtime/Mmakefile:
Mention the new files and the dependencies that involve them.
library/table_builtin.m:
Provide a type for representing statistics and a predicate for
printing statistics.
Use the updated versions of the macros in
runtime/mercury_tabling_preds.h.
compiler/prog_item.m:
Change representation of tabling pragmas to allow room for the new
attributes.
Allow an item to be marked as being generated by the compiler
as a result of a pragma memo attribute. We use this for the reset
and statistics predicates.
compiler/mercury_to_mercury.m:
Write out the new attributes of the tabling pragma.
compiler/prog_data.m:
compiler/hlds_data.m:
Change the cons_id that used to refer to a procedure's call table root
to refer to the entirety of the new data structure now containing it.
The compiler now needs a way to refer to the other components of this
new data structure, since it contains the statistics.
As in the runtime, don't distinguish "strict", "fast_loose" and
"specified" memoing as separate eval methods; treat them as just
different kinds of the same eval method: "memo".
Rename some of the uses of the function symbols "c", "java", "il".
compiler/hlds_pred.m:
Add an extra field in proc_infos for storing any tabling attributes.
Change the existing proc_info field that records information about
the kinds of arguments of tabled procedures to record the information
needed by the debugger too. This was needed to allow us to shift all
the RTTI for procedure-specific tables (as opposed to the RTTI for
the global I/O table) from mercury_stack_layout.h to mercury_tabling.h
without duplicating the data (which would be a maintenance problem).
Reformat some comments to make them easier to read.
compiler/layout.m:
compiler/layout_out.m:
Delete the part of the exec trace information that used to record
RTTI for tables, since this information is not generated only as
part of the debugger data structures anymore.
compiler/prog_io_pragma.m:
Recognize the updated syntax for tabling pragmas.
compiler/add_pragma.m:
When processing tabling pragmas for inclusion in the HLDS, create
any reset and statistics predicates they ask for.
compiler/make_hlds_passes.m:
Export a predicate now needed by add_pragma.m.
Handle the new attributes on tabling pragmas
compiler/globals.m:
Change the function symbols of the types describing backends and
foreign languages to say what they are. Previously, both types (as well
as several others) included the function symbol "c"; now, they are
target_c and lang_c respectively.
compiler/table_gen.m:
Implement the changes described at the top.
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/goal_util.m:
compiler/hlds_goal.m:
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/rtti.m:
Provide types for representing the runtime's data structures for
tabling (which are now significantly more complex than a single word)
and predicates for manipulating them, for use by both the ml and ll
backends.
compiler/llds.m:
Replace the comp_gen_c_var type with the tabling_info_struct type,
which contains the information needed to create the per-procedure
tabling data structures.
Replace references to call tables with references to the various
components of the new tabling data structures.
compiler/llds_out.m:
Add code to write out tabling_info_structs.
Delete the code required for the old, hacky way of resetting tables.
Reorder some code more logically.
compiler/proc_gen.m:
Generate tabling_info_structs.
compiler/stack_layout.m:
Don't generate the information now generated in proc_gen.m.
compiler/mlds.m:
Give mlds_proc_labels their own function symbols, instead of using
a pair. Rename some other function symbols to avoid ambiguity and add
expressiveness.
Provide for the representation of references to the various components
of the new tabling data structures, and for the representation of their
types.
compiler/ml_code_gen.m:
When generating code for a tabled procedure, generate also the data
structures required for its table.
compiler/rtti_to_mlds.m:
compiler/ml_util.m:
Move some predicates from rtti_to_mlds.m to ml_util.m, since we
now also want to call them from ml_code_gen.m.
compiler/name_mangle.m:
Add some utility predicates.
compiler/options.m:
Delete the old --allow-table-reset option.
Add the new --table-debug option.
Comment out an implementor-only option.
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_trail_ops.m:
compiler/add_type.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/dependency_graph.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/foreign.m:
compiler/global_data.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/proc_label.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_util.m:
compiler/recompilation.version.m:
compiler/size_prof.m:
compiler/special_pred.m:
compiler/switch_util.m:
compiler/transform_llds.m:
compiler/tupling.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
Conform to the changes above, and/or improve some comments.
mdbcomp/prim_data.m:
Make the names of the function symbols of the proc_label type more
expressive and less ambiguous.
mdbcomp/prim_data.m:
mdbcomp/mdbcomp.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
Use . instead of __ as module qualifier.
Conform to the change to prim_data.m.
browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
Conform the change to mdbcomp/prim_data.m.
tests/debugger/Mercury.options:
Don't specify --allow-table-reset for fib.m, since that option
doesn't exist anymore.
tests/debugger/fib.m:
Use the new mechanism for resetting the table.
tests/debugger/print_table.m:
Use the new syntax for pragma memo attributes.
tests/invalid/specified.{m,err_exp}:
Use to the new syntax and reset method for pragma memo attributes.
Test the handling of errors in the new attribute syntax.
tests/tabling/Mercury.options:
Don't specify --allow-table-reset for specified.m, since that option
doesn't exist anymore.
tests/tabling/specified.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables. We could also use this test case
for testing the printing of statistics, but the format of that
output is still not final.
tests/tabling/fast_loose.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables.
trace/mercury_trace.c:
trace/mercury_trace_cmd_developer.c:
Conform to the changes in the RTTI data structures regarding tabling.
Remove underscores from the names of some types that the style guide
says shouldn't be there.
library/robdd.m:
Comment out the tabling pragma until this change is bootstrapped.
Without this, the conflict between the old calls to macros generated
by the existing compiler and the new definition of those macros
in the runtime would cause errors from the C compiler.
|
||
|
|
4e6c603d30 |
Fix two bugs that caused test case failures in deep profiling grades.
Estimated hours taken: 3 Branches: main compiler/lookup_switch.m: Fix two bugs that caused test case failures in deep profiling grades. One bug was that an acquired register wasn't being released before the creation of a resume point, which rebuilds the code generator state (and thus forgets about acquired registers). The other bug was that is_lookup_switch wasn't performing the actions generate_goal would have when processing goals. In particular, it wasn't invoking pre_goal_update and post_goal_update on disjunctions inside the switch. compiler/lookup_util.m: Do not standardize goals by removing scopes from around other goals, because this could also remove the effects of the code generator annotations (e.g. liveness changes such as pre-births) on the scope goal. compiler/simplify.m: Eliminate those redundant scopes if asked to do so. Since this is done before the code generator annotations are put on goals, this is safe. compiler/code_gen.m: compiler/proc_gen.m: Divide the old code_gen.m into two modules: the new code_gen.m concerned with generating code for goals, and the new module proc_gen.m concerned with generating code for procedures. Without this, the code for handling goals is lost inside the old code_gen.m module. compiler/ll_backend.m: Include the new module. compiler/mercury_compile.m: Import proc_gen instead of code_gen, and ask simplify to eliminate unnecessary scopes before code generation. compiler/middle_rec.m: Update a reference to a predicate now in proc_gen.m. compiler/notes/compiler_design.html: Document the new module. |
||
|
|
d5d5986472 |
Implement lookup switches in which a switch arm may contain more than one
Estimated hours taken: 40
Branches: main
Implement lookup switches in which a switch arm may contain more than one
solution, such as this code here:
p(d, "four", f1, 4.4).
p(e, "five", f2, 5.5).
p(e, "five2", f3(5), 55.5).
p(f, "six", f4("hex"), 6.6).
p(g, "seven", f5(77.7), 7.7).
p(g, "seven2", f1, 777.7).
p(g, "seven3", f2, 7777.7).
Such code occurs frequently in benchmark programs used to evaluate the
performance of tabled logic programming systems.
Change frameopt.m, which previously worked only on det and semidet code,
to also work for nondet code. For predicates such as the one above, frameopt
can now arrange for the predicate's nondet stack frame to be created only
when a switch arm that has more than one solution is selected.
compiler/lookup_switch.m:
Extend the existing code for recognizing and implementing lookup
switches to recognize and implement them even if they are model_non.
compiler/lookup_util.m:
New module containing utility predicates useful for implementing
both lookup switches, and in the future, lookup disjunctions (i.e.
disjunctions that correspond to a nondet arm of a lookup switch).
compiler/ll_backend.m:
Include the new module.
compiler/notes/compiler_design.html:
Mention the new module.
compiler/global_data.m:
Move the job of filling in dummy slots to our caller, in this case
lookup_switch.m.
compiler/frameopt.m:
Generalize the existing code for delaying stack frame creation,
which worked only on predicates that live on the det stack, to work
also on predicates that live on the nondet stack. Without this,
predicates whose bodies are model_non lookup switches would create
a nonstack stack frame before the switch is ever entered, which
is wasteful if the selected switch arm has at most one solution.
Since the structure of model_non predicates is more complex (you can
cause a branch to a label by storing its address in a redoip slot,
you can succeed from the frame without removing the frame), this
required considerable extra work. To make the new code debuggable,
record, for each basic block that needs a stack frame, *why* it
needs that stack frame.
compiler/opt_util.m:
Be more conservative about what refers to the stack. Export some
previously internal functionality for frameopt. Turn some predicates
into functions, and rename them to better reflect their purpose.
compiler/opt_debug.m:
Print much more information about pragma_c and call LLDS instructions.
compiler/prog_data.m:
Add an extra attribute to foreign_procs that says that the code
of the foreign_proc assumes the existence of a stack frame.
This is needed to avoid frameopt optimizing the stack frame away.
compiler/add_pragma.m:
When processing fact tables, we create foreign_procs that assume
the existence of the stack frame, so set the new attribute.
compiler/pragma_c_gen.m:
When processing foreign_procs, transmit the information in the
attribute to the generated LLDS code.
compiler/llds.m:
Rename the function symbols referring to the fixed slots in nondet
stack frames to make them clearer and to avoid overloading function
symbols such as curfr and succip.
Rename the function symbols of the call_model type to avoid overloading
the function symbols of the code_model type.
Add a new field to the c_procedure type giving the code_model of the
procedure, and give names to all the fields.
Describe the stack slots used by lookup switches to the debugger
and native gc.
compiler/options.m:
doc/user_guide.texi:
Add a new option, --debug-opt-pred-name, that does when the existing
--debug-opt-pred-id options does, but taking a user-friendly predicate
name rather than a pred_id as its argument.
compiler/handle_options.m:
Process --debug-opt-pred-name, and make --frameopt-comments imply
--auto-comments, since it is not useful without it.
Reformat some existing comments that were written in the days of
8-space indentation.
compiler/optimize.m:
Implement the new option.
Use the new field of the c_procedure type to try only the version
of frameopt appropriate for the code model of the current procedure.
Do a peephole pass after frameopt, since frameopt can generate code
sequences that peephole can optimize.
Make the mechanism for recording the process of optimizing procedure
bodies more easily usable by including the name of the optimization
that created a given version of the code in the name of the file
that contains that version of the code, and ensuring that all numbers
are two characters long, so that "vi procname*.opt*" looks at the
relevant files in the proper chronological sequence, instead of having
version 11 appear before version 2.
compiler/peephole.m:
Add a new optimization pattern: a "mkframe, goto fail" pair (which
can be generated by frameopt) should be replaced by a simple "goto
redo".
compiler/code_gen.m:
Factor out some common code.
compiler/llds_out.m:
Ensure that C comments nested inside comment(_) LLDS instructions
aren't emitted as nested C comments, since C compilers cannot handle
these.
compiler/code_info.m:
compiler/code_util.m:
compiler/continuation_info.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/mercury_compile.m:
compiler/middle_rec.m:
compiler/ml_code_gen.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/peephole.m:
compiler/stack_layout.m:
compiler/transform_llds.m:
compiler/var_locn.m:
Conform to the change to prog_data.m, opt_util.m and/or llds.m.
compiler/handle_options.m:
Don't execute the code in stdlabel.m if doing so would cause a compiler
abort.
tests/hard_coded/dense_lookup_switch_non.{m,exp}:
New test case to exercise the new algorithm.
tests/hard_coded/Mmakefile:
Enable the new test case.
tests/hard_coded/cycles.m:
Make this test case conform to our coding convention.
|
||
|
|
46a67b0b48 |
When the typechecker finds highly ambiguous overloading, print what symbols
Estimated hours taken: 16
Branches: main
When the typechecker finds highly ambiguous overloading, print what symbols
were overloaded, and where they occurred. Without this information, it is
very hard to fix the error if the predicate body is at all large.
Fix some software engineering problems encountered during this process.
Modify some predicates in error_util in order to simplify their typical usage.
Change the type_ctor type to be not simply a sym_name - int pair but a type
with its own identifying type constructor. Change several other types that
were also sym_name - int pairs (mode_id, inst_id, item_name, module_qual.id
and the related simple_call_id) to have their own function symbols too.
compiler/typecheck_info.m:
Add a field to the typecheck_info structure that records the overloaded
symbols encountered.
compiler/typecheck.m:
When processing ambiguous predicate and function symbols, record this
fact in the typecheck_info.
Add a field to the cons_type_info structure to make this possible.
compiler/typecheck_errors.m:
When printing the message about highly ambiguous overloading,
what the overloaded symbols were and where they occurred.
compiler/error_util.m:
Make error_msg_specs usable with plain in and out modes by separating
out the capability requiring special modes (storing a higher order
value in a function symbol) into its own, rarely used type.
Make component_list_to_line_pieces a bit more flexible.
compiler/prog_data.m:
compiler/module_qual.m:
compiler/recompilation.m:
Change the types listed above from being equivalence types (pairs)
to being proper discriminated union types.
compiler/*.m:
Conform to the changes above.
In some cases, simplify the code's use of error_util.
tests/warnings/ambiguous_overloading.{m,exp}:
Greatly extend this test case to test the new functionality.
tests/recompilation/*.err_exp.2
Reflect the fact that the expected messages now use the standard
error_util way of quoting sym_name/arity pairs.
|
||
|
|
90f2724738 |
Don't test whether we are emitting trail operations when generating
Estimated hours taken: 0.5 Branches: main compiler/code_gen.m: Don't test whether we are emitting trail operations when generating *every* goal; test it only when generating goals that may want to emit trailing operations. Make the test itself more efficient by doing option lookups and boolean operations on option values once per procedure rather than once per affected goal. compiler/code_info.m: Extend the code_info structure to provide storage space for the result of this per-procedure computation. compiler/code_util.m: Delete a function whose functionality is now in code_info.m. compiler/goal_form.m: Turn the predicates that test whether a goal can modify the trail into functions, since that is how they were being used. Make them take only the goal_info as the argument, since the goal expression isn't needed, and creating the expression/goal_info pair would be an unnecessary cost on the code generator. compiler/add_trail_ops.m: compiler/disj_gen.m: Conform to the change in goal_form.m. compiler/mercury_compile.m: Fix formatting. compiler/assertion.m: Address some old review comments: fix some bad predicate names, and put some predicate's arguments into a more conventional order. Remove some redundant and slightly inconsistent documentation. compiler/accumulator.m: compiler/typecheck.m: Conform to the change in assertion.m. |
||
|
|
459847a064 |
Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18 Branches: main Move the univ, maybe, pair and unit types from std_util into their own modules. std_util still contains the general purpose higher-order programming constructs. library/std_util.m: Move univ, maybe, pair and unit (plus any other related types and procedures) into their own modules. library/maybe.m: New module. This contains the maybe and maybe_error types and the associated procedures. library/pair.m: New module. This contains the pair type and associated procedures. library/unit.m: New module. This contains the types unit/0 and unit/1. library/univ.m: New module. This contains the univ type and associated procedures. library/library.m: Add the new modules. library/private_builtin.m: Update the declaration of the type_ctor_info struct for univ. runtime/mercury.h: Update the declaration for the type_ctor_info struct for univ. runtime/mercury_mcpp.h: runtime/mercury_hlc_types.h: Update the definition of MR_Univ. runtime/mercury_init.h: Fix a comment: ML_type_name is now exported from type_desc.m. compiler/mlds_to_il.m: Update the the name of the module that defines univs (which are handled specially by the il code generator.) library/*.m: compiler/*.m: browser/*.m: mdbcomp/*.m: profiler/*.m: deep_profiler/*.m: Conform to the above changes. Import the new modules where they are needed; don't import std_util where it isn't needed. Fix formatting in lots of modules. Delete duplicate module imports. tests/*: Update the test suite to confrom to the above changes. |
||
|
|
25b8b1abc3 |
Fix several performance bugs that showed up when the compiler was invoked on
Estimated hours taken: 20 Branches: main Fix several performance bugs that showed up when the compiler was invoked on Douglas Auclair's training_cars example. Also fix some minor problems that made it harder to find the information needed to localize those problems. training_cars.m is hard to compile quickly because it is big in two dimensions: it has lots of clauses, and each clause has big terms. My laptop still tries to swap itself to death on the full version of training_cars.m (it has only 512 Mb), but the compiler now works fine on a version containing about 20% of its clauses, whereas previously it couldn't compile it at all. In most cases, the changes convert N^2 algorithms to NlogN algorithms. They probably have higher constant factors and may yield small slowdowns for small N, but this is probably not noticeable. Avoiding bad worst case behavior is more important. compiler/superhomogeneous.m: Record the number of goals inserted in each goal being converted to superhomogeneous form. If this exceeds a threshold, wrap a from_ground_term scope around it. Put the predicates into a more cohesive sequence. compiler/field_access.m: Work with the code in superhomogeneous to record the number of inserted goals. Reorder the arguments of some performances to be consistent with the predicates in superhomogeneous.m. compiler/modes.m: Use the from_ground_term scope to reverse the list of inserted unifications if necessary. It is much more efficient to do this here than to let it happen by sequences of delays and wakeups. That would have quadratic complexity; this is linear. This is what I originally introduced from_ground_term scopes for. Then, the overhead was too high, because I added one scope per function symbol. This version should be fine, since there is at most one scope added per argument of an atom (clause head or call). compiler/modes.m: compiler/unique_modes.m: When we are processing goals inside a from_ground_term scope, record this fact. compiler/mode_info.m: Make it possible to record this fact. compiler/modecheck_unify.m: When we are inside a from_ground_term scope, don't try to update the insts of vars on the right hand sides of construction unifications. Since these variables came from expansion to superhomogeneous form, those variables won't occur in any following code, so updating their state is useless, and the algorithm we used to do so is linear in the size of the inst. Since the size of an inst of a variable that results from superhomogeneous expansion is itself on average proportional to the size of the original term, this change turns a quadratic algorithm into a linear one. compiler/inst_match.m: Use balanced trees instead of ordered lists to represents sets of expansions, since these sets can be large. Note an opportunity for further improvement. compiler/inst_util.m: Note another opportunity for further improvement. compiler/instmap.m: Rename several predicates to avoid ambiguities. compiler/cse_detection.m: We used to print statistics for the processing of each procedure without saying which procedure it is for; fix this. compiler/switch_detection.m: Don't print progress messages for predicates with no procedures, since they would be misleading. compiler/higher_order.m: Change an algorithm that was quadratic in the number of arms for merging the information from the different arms of disjunctions and switches to an NlogN algorithm. Change the algorithm for merging the info from two branches that quadratic in the number of variables per arm to an NlogN algorithm. Changed some type equivalences to notag types to aid robustness. compiler/quantification.m: Rename several predicates to avoid ambiguities. The sets of variables in different arms of disjunctions and switches tend to have relatively small intersections. Yet the algorithms we used to compute the set of variables free in the disjunction or switch included the variables from the already processed arms in the sets being accumulated when processing later arms, leading to the quadratic behavior. This diff changes the algorithm to process each arm independently, and then use a more balanced algorithm to summarize the result. Specialize the predicates that compute sets of free vars in various HLDS fragments to work either with ordinary_nonlocals or code_gen_nonlocals without making the same decision repeatedly. Move some code out of large predicates into predicates of their own. compiler/Mercury.options: Specify the compiler option that can exploit this specialization to make the code run faster. compiler/simplify.m: Use a more efficient data structure for recording the parameters of an invocation of simplification. Change some predicate names and function symbol names to avoid ambiguity. compiler/common.m: compiler/deforest.m: compiler/deforest.m: compiler/make_hlds_warn.m: compiler/mercury_compile.m: compiler/pd_util.m: compiler/stack_opt.m: compiler/term_constr_build.m: Conform to the changes in simplify.m and/or instmap.m. compiler/mercury_compile.m: Fix a bug in progress messages for polymorphism.m. compiler/equiv_type_hlds.m: Most of the time, substitutions inside insts have no effect, because very few insts include any reference to a types. Instead of the old approach of building new insts and then throwing them away if they are the same as the old ones, don't build new insts at all if the old inst contains no types. compiler/common.m: Change some predicate names to make them clearer. compiler/hlds_clauses.m: Record the number of clauses so far, to allow a more informative progress message to be printed. compiler/add_clause.m: Print this more informative progress message. Conform to the changes in superhomogeneous.m. compiler/code_gen.m: Use the context of the predicate's first clause (which will be the context of the first clause head) as the context of the predicate's interface events. Unlike the context of the body goal, this won't be affected by program transformations such as wrapping a from_ground_term scope around some goals. It is better for users anyway, since the old policy lead to contexts in the middle of procedure bodies if the top level goal was a disjunction, switch or if-then-else. tests/debugger/*.exp: Update the expected outputs to conform to the change to code_gen.m. |
||
|
|
12deb40264 |
Rename all the get access predicates in these modules that don't
Estimated hours taken: 0.1 Branches: main compiler/hlds_clauses.m: compiler/hlds_pred.m: Rename all the get access predicates in these modules that don't already have put "get" in their name. (The names of the set access predicates were OK already.) compiler/*.m: Conform to the above. All this was done by this sed script: s/clauses_info_varset/clauses_info_get_varset/ s/clauses_info_explicit_vartypes/clauses_info_get_explicit_vartypes/ s/clauses_info_vartypes/clauses_info_get_vartypes/ s/clauses_info_headvars/clauses_info_get_headvars/ s/clauses_info_clauses_rep/clauses_info_get_clauses_rep/ s/clauses_info_rtti_varmaps/clauses_info_get_rtti_varmaps/ s/pred_info_import_status/pred_info_get_import_status/ s/pred_info_arg_types/pred_info_get_arg_types/ s/pred_info_typevarset/pred_info_get_typevarset/ s/pred_info_tvar_kinds/pred_info_get_tvar_kinds/ s/pred_info_procedures/pred_info_get_procedures/ s/proc_info_context/proc_info_get_context/ s/proc_info_varset/proc_info_get_varset/ s/proc_info_vartypes/proc_info_get_vartypes/ s/proc_info_headvars/proc_info_get_headvars/ s/proc_info_inst_varset/proc_info_get_inst_varset/ s/proc_info_maybe_declared_argmodes/proc_info_get_maybe_declared_argmodes/ s/proc_info_argmodes/proc_info_get_argmodes/ s/proc_info_maybe_arglives/proc_info_get_maybe_arglives/ s/proc_info_declared_determinism/proc_info_get_declared_determinism/ s/proc_info_inferred_determinism/proc_info_get_inferred_determinism/ s/proc_info_goal/proc_info_get_goal/ s/proc_info_can_process/proc_info_get_can_process/ s/proc_info_rtti_varmaps/proc_info_get_rtti_varmaps/ s/proc_info_eval_method/proc_info_get_eval_method/ s/proc_info_is_address_taken/proc_info_get_is_address_taken/ s/proc_info_stack_slots/proc_info_get_stack_slots/ s/proc_info_liveness_info/proc_info_get_liveness_info/ s/proc_info_context/proc_info_get_context/ s/proc_info_context/proc_info_get_context/ s/proc_info_context/proc_info_get_context/ s/proc_info_context/proc_info_get_context/ s/proc_info_context/proc_info_get_context/ s/proc_info_context/proc_info_get_context/ s/proc_info_context/proc_info_get_context/ |
||
|
|
a4519ed079 |
Move the all-solutions predicates from the library module std_util into their
Estimated hours taken: 4 Branches: main Move the all-solutions predicates from the library module std_util into their own module, solutions. Move semidet_fail, semidet_succeed, cc_multi_equal and dynamic cast from std_util.m into builtin.m. Add some more utility functions for performing determinism or purity casts. (The later are primarily intended for use by solver implementors.) library/std_util.m: Move the all-solutions predicates into their own module, solutions.m. For now there are (obsolete) forwarding predicates from this module to the new one. The forwarding predicates will be included in the upcoming 0.13 release and then removed in later versions. Move semidet_succeed, semidet_fail, cc_multi_equal and dynamic_cast to builtin.m library/solutions.m: New file. This is the new home for the all-solutions predicates. This is pretty much cut and pasted from std_util (with module qualifiers updated accordingly). I've rearranged the code in a more top-down fashion as per our current coding standard. library/builtin.m: Move semidet_fail/0, semidet_succeed/0, cc_multi_equal/2 and dynamic_cast/2 to this module. Add semidet_true/0 and semidet_false/0 as synonyms for semidet_fail/0 and semidet_succeed/0. Add impure_true/0 and semipure_true/0. These are useful for performing purity casts, e.g. in solver implementations. library/library.m: Add the new module. NEWS: Announce the changes. library/*.m: Update to conform to the above. compiler/const_prop.m: Update evaluate_semidet_call/5 with the new module name for dynamic_cast. compiler/*.m: Module qualify calls to solutions to either disambiguate them from the versions in std_util (where they weren't module qualified) or change the module qualifier where they were (to avoid warnings about calls to the now deprecated versions). tests/debugger/declarative/solutions.*: Rename this module as the name conflicts with the new library module. tests/debugger/declarative/solns.*: Renamed version of above (with updated expected output). tests/debugger/declarative/Mmakefile: Handle the renamed version of the solutions test. tests/debugger/all_solutions.m: tests/debugger/declarative/args.m: tests/debugger/declarative/library_forwarding.m: tests/hard_coded/constant_prop_2.m: tests/invalid/multisoln_func.m: tests/invalid/one_member.m: tests/invalid/promise_equivalent_claueses.m: tests/valid/simplify_bug2.m: tests/valid/solv.m: Update to conform to the above changes. sample/solutions/*.m: Update to conform to the above changes. |
||
|
|
be5b71861b |
Convert almost all the compiler modules to use . instead of __ as
Estimated hours taken: 6 Branches: main compiler/*.m: Convert almost all the compiler modules to use . instead of __ as the module qualifier. In some cases, change the names of predicates and types to make them meaningful without the module qualifier. In particular, most of the types that used to be referred to with an "mlds__" prefix have been changed to have a "mlds_" prefix instead of changing the prefix to "mlds.". There are no algorithmic changes. |
||
|
|
5b8f96f61d |
Prepare for an extension of promise_equivalent_solutions that will allow us
Estimated hours taken: 5 Branches: main Prepare for an extension of promise_equivalent_solutions that will allow us to better handle values of user-defined types. The problem is that currently, the deconstruction of a value of such a type can be followed only by code that cannot fail, otherwise the cc_multi deconstruction is not in the required single-solution context. If the following code is naturally semidet, this can be worked around by turning it into det code returning a maybe and testing the maybe outside the promise_equivalent_solutions, but this is inefficient, and in any case it does not generalize to nondet code without even more horrendous inefficiency and inconvenience. (You have to create a nondet closure and call it outside the promise_equivalent_solutions.) The solution I came up with is something is to have a construct that contains - a list of deconstructions on types with user-defined equality, - a goal, and - the list of outputs of that goal. The idea is that this would be transformed into a conjunction of the first and second items, and wrapped inside a special kind of conj that provides a scope for the implicit promise, which is that the set of solutions of the goal in the second item doesn't depend on what concrete terms the deconstructions in the first item return out of the set of concrete terms they *could* return. The deconstructions in the first item would be marked to tell determinism analysis to effectively ignore the fact that they involve user-defined equality. The actual addition of that construct is left for a future change, after we agree on the syntax. compiler/hlds_goal.m: Generalize the existing promise_equivalent_solutions scope to a promise_solutions scope with a flag that says whether in the source code it was originally the existing "promise_equivalent_solutions" construct or the new construct (which doesn't exist yet, but is indicated by the symbol "same_solutions" for now). Replace the conj and par_conj hlds_goal_exprs with a single goal expression: conj with an additional argument which is either plain_conj or parallel_conj. This was part of an earlier design in which a third kind of disjunction took the role now assigned to the new kind of promise_solutions scope, but turned out to be a good idea anyway, since in many places the compiler does treat the two kinds of conjunctions the same. This part of the change is responsible for the fact that this change results in a net *reduction* of about 40 lines. Move the most frequently used kinds of goal expressions to the front of the type declaration to allow the compiler to make better decisions about tag allocation. Add the goal marker we will add to the deconstructions in the first item. Replace the true_goal and fail_goal predicates with functions to make them easier to use, and rename their variants that take a context argument to avoid unnecessary ambiguity. compiler/*.m: Conform to the change in hlds_goal.m. Misc changes to make code more robust, e.g. replacing semidet predicates on goal expressions with functions returning bool. Misc cleanups, e.g. removal of unnecessary module qualifications that made lines too long, renaming predicates whose names include "disj" if they are also used to process parallel conjunctions (since in both parallel conjunctions and in disjunctions the goals are independent), and turning semidet predicates that switch on goal expressions into bool functions (to make similar changes more rebust in the future). |
||
|
|
5af71b60ac |
Remove support for the Aditi backend. It is a pain to have to update it every
Estimated hours taken: 2 Branches: main Remove support for the Aditi backend. It is a pain to have to update it every time a data structure changes when we don't see any benefit from it, and its presence makes compilation of the compiler directory take about 10% longer (since the Aditi backend modules are roughly 10% of the code in the compiler directory). Deleting the Aditi-specific data structures from the HLDS should also speed up compilation a little bit. I have spoken to Rao and he is fine with this step. Aditi users, if there are any, can continue to use the Aditi support in release 0.12.*. I also tagged the last version on the trunk to support aditi with the name "last_aditi". The need for modifications in this Aditi support is likely to be very rare to nonexistent, if the recent past is any guide: the Aditi backend hasn't seen a nontrivial modification in a year or more. This diff removes a net 31492 lines. compiler/add_aditi.m: compiler/aditi_backend.pp: compiler/aditi_builtin_ops.m: compiler/context.m: compiler/dnf.m: compiler/magic.m: compiler/magic_util.m: compiler/rl.m: compiler/rl_analyse.m: compiler/rl_block.m: compiler/rl_block_opt.m: compiler/rl_code.m: compiler/rl_dump.m: compiler/rl_exprn.m: compiler/rl_file.pp: compiler/rl_gen.m: compiler/rl_info.m: compiler/rl_key.m: compiler/rl_liveness.m: compiler/rl_loop.m: compiler/rl_opt.m: compiler/rl_out.pp: compiler/rl_relops.m: compiler/rl_sort.m: compiler/rl_stream.m: Remove these compiler modules, since they existed only to support the Aditi backend. compiler/hlds_goal.m: Delete the Aditi-specific components of goals (e.g. the aditi-builtin kind of generic calls and Aditi-evaluated lambdas). compiler/hlds_pred.m: Delete the Aditi-specific components of pred_infos. compiler/prog_data.m: Delete the Aditi-specific items. compiler/passes_aux.m: Don't worry about processing all procedures or just all non-Aditi procedures. compiler/add_clause.m: Add a predicate from a deleted module that is now used only here. compiler/*.m: Conform to the data structure changes above. compiler/notes/*.html: Remove references to the Aditi backend. tests/invalid/aditi.m: tests/invalid/aditi_errors.err_exp: tests/invalid/aditi_errors.m: tests/invalid/aditi_private_builtin.m: tests/invalid/aditi_state_errors.err_exp: tests/invalid/aditi_state_errors.m: tests/invalid/aditi_update_derived_relation.err_exp: tests/invalid/aditi_update_derived_relation.m: tests/invalid/aditi_update_errors.err_exp: tests/invalid/aditi_update_errors.m: tests/invalid/aditi_update_mode_errors.err_exp: tests/invalid/aditi_update_mode_errors.m: tests/valid/aditi.m: tests/valid/aditi_calls_mercury.m: tests/valid/aditi_error_bug.m: tests/valid/aditi_error_bug2.m: tests/valid/aditi_error_bug3.m: tests/valid/aditi_private_builtin.m: tests/valid/aditi_query.m: tests/valid/aditi_update.m: tests/valid/base_relation.m: tests/valid/base_relation2.m: tests/valid/ite_to_disj.m: Remove these Aditi-specific tests. tests/*/Mmakefile: Remove the references to these Aditi-specific tests. |
||
|
|
d47e633804 |
Trace builtin and private_builtin (with the exception of external predicates
Estimated hours taken: 4 Branches: main Trace builtin and private_builtin (with the exception of external predicates and those that are polymorhphic, but have no extra type_info arguments). This allows subterms to be traced through calls to predicates in builtin and private_builtin and fixes an assertion failure in the declarative debugger that was triggered when an untraced builtin called a traced predicate (the debugger would then think the events from the traced predicate were child events of the parent of the untraced predicate, which would cause the assertion failure). compiler/code_gen.m: compiler/hlds_pred.m: compiler/mercury_compile.m: compiler/ml_code_util.m: compiler/polymorphism.m: compiler/stack_layout.m: compiler/term_constr_initial.m: mdbcomp/prim_data.m: mdbcomp/program_representation.m: Move no_type_info_builtin from compiler/hlds_pred.m to mdbcomp/program_representation.m, so that the debugger can call it to see what builtin polymorphic predicates do not have extra type_info arguments. Define pred_is_external to be true for predicates defined with :- external. The debugger needs to know not to expect any events for such predicates. Trace the builtin and private_builtin modules. tests/debugger/loopcheck.exp3: tests/debugger/uci.exp2: tests/debugger/uci_index.exp: Changes to expected output due to the fact that builtins are now traced. tests/debugger/declarative/Mmakefile: tests/debugger/declarative/typed_unify.exp: tests/debugger/declarative/typed_unify.inp: tests/debugger/declarative/typed_unify.m: Test tracking of a subterm through a builtin. |
||
|
|
6129c79d03 |
Attach trail usage information to the goal_info rather than recomputing it on
Estimated hours taken: 10 Branches: main Attach trail usage information to the goal_info rather than recomputing it on demand. This avoids repeated traversals of the goal structure during trail usage optimization. compiler/trailing_analysis.m: Add an optional second pass to trail usage analysis that annotates goals with trail usage information. The second pass is optional because we only run it when we are generating code; when building the optimization interfaces we don't run it. Factor out code that is common to both passes into separate procedures. Fix some problems with the documentation in this module. Update the TODO list in this module. Add exception.rethrow/1 to the known procedures table. compiler/hlds_goal.m: Add a new goal feature `will_not_modify_trail' that can be used to mark goals that will not modify the trail. compiler/goal_form.m: Instead of traversing the a goal to work out if it may modify the trail, just look for the will_not_modify_trail feature in the goal_info. compiler/saved_vars.m: compiler/add_trail_ops.m: compiler/code_gen.m: compiler/code_util.m: compiler/disj_gen.m: Minor change to conform to the above. |
||
|
|
45fdb6c451 |
Use expect/3 in place of require/2 throughout most of the
Estimated hours taken: 4 Branches: main compiler/*.m: Use expect/3 in place of require/2 throughout most of the compiler. Use unexpected/2 (or sorry/2) in place of error/1 in more places. Fix more dodgy assertion error messages. s/map(prog_var, mer_type)/vartypes/ where the latter is meant. |
||
|
|
dae82a8409 |
Implement trail usage optimization for the lowlevel backend.
Estimated hours taken: 5 Branches: main Implement trail usage optimization for the lowlevel backend. compiler/code_gen.m: As we generate code for each HLDS goal check if it is safe to omit trailing operations. Do so, if trail usage optimization is enabled. Reformat some code for the purposes of readability. compiler/commit_gen.m: compiler/disj_gen.m: compiler/ite_gen.m: compiler/code_info.m: Thread the above information down to the relevant parts of the code generator. Misc. cleanups: reduce unnecessary module qualification and minor layout fixes. compiler/code_util.m: Add a utility predicate the tests if we are allowed to omit trailing primitives for a given HLDS goal. compiler/llds.m: Add the equivalence type: add_trail_ops == bool. compiler/hlds_goal.m: compiler/prog_data.m: Unrelated changes: fix typos in comments. Add an end_module declaration to the former. |
||
|
|
f9fe8dcf61 |
Improve the error messages generated for determinism errors involving committed
Estimated hours taken: 8
Branches: main
Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.
The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.
compiler/det_analysis.m:
Keep track of goals to the right of the current goal that could fail,
and include them in the error representation if required.
compiler/det_report.m:
Include the list of failing goals to the right in the representations
of determinism errors involving committed committed choice goals.
Convert the last part of this module that wasn't using error_util
to use error_util. Make most parts of this module just construct
error message specifications; print those specifications (using
error_util) in only a few places.
compiler/hlds_out.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
compiler/compiler_util.m:
Error_util is still changing reasonably often, and yet it is
included in lots of modules, most of which need only a few simple
non-parse-tree-related predicates from it (e.g. unexpected).
Move those predicates to a new module, compiler_util.m. This also
eliminates some undesirable dependencies from libs to parse_tree.
compiler/libs.m:
Include compiler_util.m.
compiler/notes/compiler_design.html:
Document compiler_util.m, and fix the documentation of some other
modules.
compiler/*.m:
Import compiler_util instead of or in addition to error_util.
To make this easier, consistently use . instead of __ for module
qualifying module names.
tests/invalid/det_errors_cc.{m,err_exp}:
Add this new test case to test the error messages for cc contexts.
tests/invalid/det_errors_deet.{m,err_exp}:
Add this new test case to test the error messages for unifications
inside function symbols.
tests/invalid/Mmakefile:
Add the new test cases.
tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
Change the expected output to conform to the change in det_report.m,
which is now more consistent.
|
||
|
|
c745c93c1d |
Fix an old bug: when invoking the compiler with -vS, many of the statistics
Estimated hours taken: 1 Branches: main Fix an old bug: when invoking the compiler with -vS, many of the statistics printed didn't say what they are for, because the relevant messages were enabled only with -V. compiler/options.m: Add a new option, detailed_statistics. This option is not visible to users. compiler/handle_options.m: Set detailed_statistics only if -v and -S are both set. compiler/mercury_compile.m: compiler/modes.m: compiler/modules.m: compiler/optimize.m: compiler/typecheck_errors.m: In a bunch of places where progress messages are enabled only with -V and not with -v, consult detailed_statistics instead of statistics to decide whether to print statistics, in order to make sure you get only interpretable statistics. compiler/make_hlds_passes.m: Print messages before two statistics reports, because otherwise the statistics are not interpretable. Don't print stats for module optimization, since it is now a no-op. compiler/cse_detection.m: Print statistics if detailed_statistics is set. This is useful because in some cases, cse_detection can be expensive (it reruns mode analysis). compiler/simplify.m: Print statistics if detailed_statistics is set. This is useful because in some cases, simplify can be expensive. |
||
|
|
b2012c0c0e |
Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst'
Estimated hours taken: 8 Branches: main compiler/*.m: Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst' and 'mer_mode'. This is to avoid the need to parenthesize these type names in some contexts, and to prepare for the possibility of a parser that considers those words to be reserved words. Rename some other uses of those names (e.g. as item types in recompilation.m). Delete some redundant synonyms (prog_type, mercury_type) for mer_type. Change some type names (e.g. mlds__type) and predicate names (e.g. deforest__goal) to make them unique even without module qualification. Rename the function symbols (e.g. pure, &) that need to be renamed to avoid the need to parenthesize them. Make their replacement names more expressive. Convert some more modules to four space indentation. Avoid excessively long lines, such as those resulting from the automatic substitution of 'mer_type' for 'type'. |
||
|
|
d609181cb9 |
Consider types of the form
Estimated hours taken: 30
Branches: main
Consider types of the form
:- type x ---> f.
to be dummy types, since they contain no information. Optimize them the same
way we currently optimize io.state and store.store.
runtime/mercury_type_info.h:
Add a new type_ctor_rep for dummy types.
runtime/mercury_tabling.h:
Add a representation for "tabled" dummy types, which don't actually
have a level in the trie, so that the runtime system can handle that
fact.
runtime/mercury_ml_expand_body.h:
When deconstructing a value of a dummy type, ignore the actual value
(since it will contain garbage) and instead return the only possible
value of the type.
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.c:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
library/rtti_implementation.m:
Handle the type_ctor_rep of dummy types.
runtime/mercury_builtin_types.c:
Provide a place to record profiling information about unifications and
comparisons for dummy types.
runtime/mercury_mcpp.h:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
Add a new type_ctor_rep for dummy types, and fix some previous
discrepancies in type_ctor_reps.
mdbcomp/prim_data.m:
Move a bunch of predicates for manipulating special_pred_ids here from
the browser and compiler directories.
Rename the function symbols of the special_pred_id type to avoid the
need to parenthesize the old `initialise' function symbol.
Convert to four-space indentation.
mdbcomp/rtti_access.m:
Don't hardcode the names of special preds: use the predicates in
prim_data.m.
Convert to four-space indentation.
browser/declarative_execution.m:
Delete some predicates whose functionality is now in
mdbcomp/prim_data.m.
compiler/hlds_data.m:
Replace the part of du type that says whether a type an enum, which
used to be a bool, with something that also says whether the type is a
dummy type.
Convert to four-space indentation.
compiler/make_tags.m:
Compute the value for the new field of du type definitions.
compiler/hlds_out.m:
Write out the new field of du type definitions.
compiler/rtti.m:
Modify the data structures we use to create type_ctor_infos to allow
for dummy types.
Convert to four-space indentation.
compiler/type_ctor_info.m:
Modify the code that generates type_ctor_infos to handle dummy types.
compiler/type_util.m:
Provide predicates for recognizing dummy types.
Convert to four-space indentation.
compiler/unify_proc.m:
Generate the unify and compare predicates of dummy types using a new
code scheme that avoids referencing arguments that contain garbage.
When generating code for unifying or comparing other types, ignore
any arguments of function symbols that are dummy types.
Don't use DCG style access predicates.
compiler/higher_order.m:
Specialize the unification and comparison of values of dummy types.
Break up an excessively large predicate, and factor out common code
from the conditions of a chain of if-then-elses.
compiler/llds.m:
For each input and output of a foreign_proc, include a field saying
whether the value is of a dummy type.
compiler/pragma_c_gen.m:
Fill in the new fields in foreign_proc arguments.
compiler/hlds_goal.m:
Rename some predicates for constructing unifications to avoid
unnecessary ad-hoc overloading. Clarify their documentation.
Rename a predicate to make clear the restriction on its use,
and document the restriction.
Add a predicate for creating simple tests.
Add a utility predicate for setting the context of a goal directly.
compiler/modules.m:
Include dummy types interface files, even if they are private to the
module. This is necessary because with the MLDS backend, the generated
code inside the module and outside the module must agree whether a
function returning a value of the type returns a real value or a void
value, and this requires them to agree on whether the type is dummy
or not.
The impact on interface files is minimal, since very few types are
dummy types, and changing a type from a dummy type to a non-dummy type
or vice versa is an ever rarer change.
compiler/hlds_pred.m:
Provide a representation in the compiler of the trie step for dummy
types.
compiler/layout_out.m:
Print the trie step for dummy types.
compiler/table_gen.m:
Don't table values of dummy types, and record the fact that we don't
by including a dummy trie step in the list of trie steps.
compiler/add_pragma.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/aditi_builtin_ops.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/det_report.m:
compiler/exception_analysis.m:
compiler/inst_match.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/opt_util.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/qual_info.m:
compiler/rl.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/rtti_out.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_norm.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_gen.m:
Conform to the changes above.
compiler/export.m:
compiler/exprn_aux.m:
compiler/foreign.m:
compiler/polymorphism.m:
compiler/proc_label.m:
compiler/rtti_to_mlds.m:
compiler/special_pred.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/state_var.m:
compiler/switch_util.m:
compiler/trace_params.m:
Conform to the changes above.
Convert to four-space indentation.
compiler/mlds_to_java.m:
compiler/var_locn.m:
Conform to the changes above, which requires threading the module_info
through the module.
Convert to four-space indentation.
compiler/mercury_compile.m:
Pass the module_info to mlds_to_java.m.
compiler/ml_util.m:
compiler/polymorphism.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
Delete some previously missed references to the temporary types used
to bootstrap the change to the type_info type's arity.
compiler/polymorphism.m:
Turn back on an optimization that avoids passing parameters (such as
type_infos) to foreign_procs if they are not actually referred to.
compiler/prog_data.m:
Convert to four-space indentation.
library/svvarset.m:
Add a missing predicate.
trace/mercury_trace.c:
Delete the unused function that used to check for dummy types.
tests/debugger/field_names.{m,inp,exp}:
Add to this test case a test of the handling of dummy types. Check that
their values can be printed out during normal execution, and that the
debugger doesn't consider them live nondummy variables, just as it
doesn't consider I/O states live nondummy variables.
|
||
|
|
b54ab42d70 |
A simple tool for performing substitutions on the source files of the
Estimated hours taken: 0.5 Branches: main tools/subst: A simple tool for performing substitutions on the source files of the compiler. compiler/*.m: Change the names of the get predicates operating on module_infos to include "get" in the name, for uniformity. This was done mostly by the following sed script, with some manual cleanup afterwards to reduce excessive line lengths. s/module_info_types/module_info_get_type_table/ s/module_info_set_types/module_info_set_type_table/ s/module_info_insts/module_info_get_inst_table/ s/module_info_set_insts/module_info_set_inst_table/ s/module_info_modes/module_info_get_mode_table/ s/module_info_set_modes/module_info_set_mode_table/ s/module_info_ctors/module_info_get_cons_table/ s/module_info_set_ctors/module_info_set_cons_table/ s/module_info_classes/module_info_get_class_table/ s/module_info_set_classes/module_info_set_class_table/ s/module_info_instances/module_info_get_instance_table/ s/module_info_set_instances/module_info_set_instance_table/ s/module_info_superclasses/module_info_get_superclass_table/ s/module_info_set_superclasses/module_info_set_superclass_table/ s/module_info_assertion_table/module_info_get_assertion_table/ s/module_info_exclusive_table/module_info_get_exclusive_table/ s/module_info_ctor_field_table/module_info_get_ctor_field_table/ s/module_info_name/module_info_get_name/ s/module_info_globals/module_info_get_globals/ s/module_info_contains_foreign_types/module_info_get_contains_foreign_types/ s/module_info_num_errors/module_info_get_num_errors/ s/module_info_type_ctor_gen_infos/module_info_get_type_ctor_gen_infos/ s/module_info_stratified_preds/module_info_get_stratified_preds/ s/module_info_unused_arg_info/module_info_get_unused_arg_info/ s/module_info_exception_info/module_info_get_exception_info/ s/module_info_type_spec_info/module_info_get_type_spec_info/ s/module_info_no_tag_types/module_info_get_no_tag_types/ s/module_info_analysis_info/module_info_get_analysis_info/ s/module_info_aditi_top_down_procs/module_info_get_aditi_top_down_procs/ |
||
|
|
df0d9036cf |
Optimize calls that would be tail calls in Prolog but are followed by
Estimated hours taken: 40 Branches: main Optimize calls that would be tail calls in Prolog but are followed by construction unifications in Mercury: last call modulo construction. For now, the optimization is available only for the LLDS backend. compiler/lco.m: Turn this module from a placeholder to a real implementation of the optimization. compiler/hlds_goal.m: Allow lco.m to attach to construction unifications a note that says that certain arguments, instead of being filled in by the unification, should have their addresses taken and stored in the corresponding variables. Group this note together with the note that asks for term size profiling to avoid an increase in the sizes of goals in the compiler in most cases. compiler/hlds_pred.m: Provide a predicate for setting the name of a predicate after its creation. This functionality is used by lco.m. Extend the pred_transformation part of the pred_origin type to allow it to express that a procedure was created by lco.m. List the new primitive store_at_ref as a no-typeinfo builtin. Fix some problems with indentation. compiler/layout_out.m: Handle the new pred_transformation. compiler/unify_gen.m: When processing construction unifications that have the new feaure turned on, perform the requested action. Fix some departures from coding style. Shorten lines by deleting unnecessary module qualifications. Add some auxiliary predicates to make the code easier to read. compiler/var_locn.m: Fix an earlier oversight: when materializing variables inside rvals and lvals, look inside memory references too. Previously, the omission didn't matter, since we didn't generate such references, but now we do. Fix some departures from coding style. compiler/llds_out.m: Fix some old XXXs in code handling memory references. We didn't use to generate such references, but now we do. Move some functionality here from code_aux.m. compiler/code_info.m: Provide some primitive operations needed by the new code in var_locn.m. Delete an unneeded predicate. compiler/options.m: Rename the existing option optimize_constructor_last_call as optimize_constructor_last_call_accumulator, since that optimization is done by accumulator.m. Make optimize_constructor_last_call be the option that calls for the new optimization. compiler/handle_options.m: Handle the implications of the new option. compiler/mercury_compile.m: Invoke the lco module by its new interface. librrary/private_builtin.m: Add a new primitive operation, store_at_ref, for use by the new optimization. Switch the module to four-space indentation. compiler/add_clause.m: Comment out the warning for clauses for builtin, since this is needed to bootstrap the addition of the new builtin. compiler/term_constr_initial.m: Handle the new builtin. compiler/accumulator.m: Conform to the change in options. compiler/builtin_ops.m: Provide a third template for builtins, for use by store_at_ref. Convert the file to four-space indentation. compiler/call_gen.m: Generate code following the new builtin template. compiler/rl_exprn.m: Minor changes to conform to the changes in builtin templates. compiler/quantification.m: Minor changes to conform to the changes in construct unifications. Don't make the "get" predicates operating on quantification_infos to return the "new" quantification_info: it is always the same as the old one. compiler/aditi_builtin_ops.m: compiler/common.m: compiler/deep_profiling.m: compiler/higher_order.m: compiler/hlds_out.m: compiler/lambda.m: compiler/magic_util.m: compiler/ml_unify_gen.m: compiler/modecheck_unify.m: compiler/polymorphism.m: compiler/size_prof.m: Minor changes to conform to the changes in construct unifications. compiler/dependency_graph.m: Add a new predicate to recompute the dependency information, even if a previous (and possibly now inaccurate) version is present. Change the interface to make it clearer, by changing bools into types specific to the situation. Convert the file to four-space indentation. compiler/mode_constraints.m: Minor changes to conform to the changes in dependency_graph.m. compiler/code_aux.m: Delete this module. Half its functionality has been moved into llds_out.m, half to middle_rec.m (its only user). compiler/goal_form.m: Move the predicates in this module that are used only by middle_rec.m to middle_rec.m. Convert the file to four-space indentation. compiler/goal_util.m: compiler/det_util.m: Move update_instmap from det_util to goal_util, since it is usefulness extends beyond determinism analysis. Convert det_util.m to four-space indentation. compiler/middle_rec.m: Move here the code required only here from code_aux and goal_form. Update the moved code for the changes in construct unifications. The updates are specific to middle_rec.m: they wouldn't be of use to other modules. They basically say that any code that takes the addresses of fields cannot be handled by middle_rec.m. compiler/code_gen.m: compiler/det_analysis.m: compiler/live_vars.m: compiler/ll_backend.m: compiler/loop_inv.m: compiler/switch_detection.m: compiler/switch_gen.m: compiler/notes/compiler_design.html: Minor changes to conform to the deletion of code_aux.m and/or the movement of code from det_util to goal_util.m. compiler/opt_debug.m: Print info for vars in rvals. compiler/hlds_module.m: Convert a lambda to an explicit predicate to make some code easier to read. Switch the module to four-space indentation. |
||
|
|
f0dbbcaa34 |
Generate better code for base relations such as the ones in the transitive
Estimated hours taken: 16 Branches: main Generate better code for base relations such as the ones in the transitive closure benchmarkings in the paper on minimal model tabling. These improvements yield speedups ranging from 5 to 25% on those benchmarks. compiler/use_local_vars.m: Make this optimization operate on extended basic blocks instead of plain basic blocks. The greater length of extended basic blocks allows the local variables to have maximum scope possible. The price is that the test for whether assignment to a given lvalue can be avoided or not is now dependent on which of the constituent basic blocks of extended basic block contains the assignment, and thus the test has to be evaluate once for each assignment we try to optimize instead of once per block. Don't allocate temporary variables if the optimization they are intended for turns out not to be allowed. This change avoids having declarations for unused temporary variables in the resulting C code. If --auto-comments is set, insert use_local_vars.m's main data structure, the livemap, into the generated LLDS code as a comment. compiler/peephole.m: Look for the pattern mkframe(Size, Redoip) <straight line instructions that don't use stack slots> succeed and optimize away the mkframe. This pattern always arises for procedures that are actually semidet but are declared nondet (such as the base relations in the tabling benchmarks), and may also arise for semidet branches of nondet procedures. compiler/llds.m: Allow an existing peephole pattern to work better. The pattern is mkframe(Seize, do_fail) <straight line instructions> redoip(curfr) = Redoip Previously, if some compiler-generated C code was among the straight line instructions, the pattern couldn't be applied, since peephole.m couldn't know whether it branched away through the redoip slot of the frame. This diff adds an extra slot to the relevant pragma_c component that tells peephole.m (actually, the predicate in opt_util.m that peephole relies on) whether this is the case. compiler/basic_block.m: Provide functionality for merging basic blocks into extended basic blocks. compiler/dupelim.m: Conform to the change in basic_block.m's interface. Convert to four-space indentation, and fix departures from our style guidelines. compiler/opt_util.m: Provide extra information now needed by use_local_vars. Convert to four-space indentation, and fix departures from our style guidelines. compiler/opt_debug.m: Show the user friendly versions of label names when dumping livemaps and instructions. Shorten the dumped descriptions of registers and stack slots. Dump instructions inside blocks. compiler/frameopt.m: Conform to the changes in opt_util and opt_debug's interfaces. compiler/optimize.m: Use the facilities of opt_debug instead of llds_out when dumping the LLDS after each optimization, since these are now more compact and thus reader friendly. Print unmangled names when writing progress messages. Put the dump files we generate with --opt-debug in a separate subdirectory, since when compiling e.g. tree234.m, the process can generate more than a thousand files. Give the dump files minimally mangled names. compiler/code_gen.m: compiler/pragma_c_gen.m: Convert to four-space indentation, and fix departures from our style guidelines. Conform to the change in llds.m. compiler/code_info.m: compiler/exprn_aux.m: compiler/ite_gen.m: compiler/jumpopt.m: compiler/livemap.m: compiler/llds_out.m: compiler/middle_rec.m: compiler/trace.m: Conform to the change in llds.m. |
||
|
|
0c45dc9188 |
Ensure the variable numbers we use procedure layouts are consistent across
Estimated hours taken: 1 Branches: main Ensure the variable numbers we use procedure layouts are consistent across trace levels. compiler/continuation_info.m: compiler/code_gen.m: Record procedure bodies even if the trace level is not --trace rep, to allow it to be used to compute the variable number compression map. compiler/stack_layout.m: Always compute and use the variable number compression map. tests/debugger/field_names.exp: tests/debugger/declarative/dependency.exp: Update the expected variable numbers. tests/debugger/declarative/loopcheck.exp: Expect fewer events in declarative debugging grades after my previous change to buultin.unify. |
||
|
|
8b8b3b7d3f |
Replace the some() HLDS goal with a more general scope() goal, which can be
Estimated hours taken: 12
Branches: main
Replace the some() HLDS goal with a more general scope() goal, which can be
used not just for existential quantification but also for other purposes.
The main such purposes are new goal types that allow the programmer
to annotate arbitrary goals, and not just whole procedure bodies, with the
equivalents of promise_pure/promise_semipure and promise_only_solution:
promise_pure ( <impure/semipure goal> )
promise_semipure ( <impure goal> )
promise_equivalent_solutions [OutVar1, OutVar2] (
<cc_multi/cc_nondet goal that computed OutVar1 & OutVar2>
)
Both are intended to be helpful in writing constraint solvers, as well as in
other situations.
doc/reference_manual.texi:
Document the new constructs.
library/ops.m:
Add the keywords of the new constructs to the list of operators.
Since they work similarly to the "some" operator, they have the same
precedence.
compiler/hlds_goal.m:
Replace the some(Vars, SubGoal) HLDS construct, with its optional
keep_this_commit attribute, with the new scope(Reason, SubGoal)
construct. The Reason argument may say that this scope is an
existential quantification, but it can also say that it represents
a purity promise, the introduction of a single-solution context
with promise_equivalent_solutions, or a decision by a compiler pass.
It can also say that the scope represents a set of goals that all arise
from the unraveling of a unification between a variable and a ground
term. This was intended to speed up mode checking by significantly
reducing the number of delays and wakeups, but the cost of the scopes
themselves turned out to be bigger than the gain in modechecking speed.
Update the goal_path_step type to refer to scope goals instead of just
existential quantification.
compiler/prog_data.m:
Add new function symbols to the type we use to represent goals in items
to stand for the new Mercury constructs.
compiler/prog_io_goal.m:
Add code to read in the new language constructs.
compiler/prog_io_util.m:
Add a utility predicate for use by the new code in prog_io_goal.m.
compiler/make_hlds.m:
Convert the item representation of the new constructs to the HLDS
representation.
Document how the from_ground_term scope reason would work, but do not
enable the code.
compiler/purity.m:
When checking the purity of goals, respect the new promise_pure and
promise_semipure scopes. Generate warnings if such scopes are
redundant.
compiler/det_analysis.m:
Make the insides of promise_equivalent_solutions goals single solution
contexts.
compiler/det_report.m:
Provide mechanisms for reporting inappropriate usage of
promise_equivalent_solutions goals.
compiler/instmap.m:
Add a utility predicate for use by one of the modules above.
compiler/deep_profiling.m:
Use one of the new scope reasons to prevent simplify from optimizing
away commits of goals that have been made impure, instead of the old
keep_this_commit goal feature.
compiler/modes.m:
Handle from_ground_term scopes when present; for now, they won't be
present, since make_hlds isn't creating them.
compiler/options.m:
Add two new compiler options, for use by implementors only, to allow
finer control over the amount of output one gets with --debug-modes.
(I used them when debugging the performance of the from_ground_term
scope reason.) The options are --debug-modes-minimal and
--debug-modes-verbose.
compiler/handle_options.m:
Make the options that are meaningful only in the presence of
--debug-modes imply --debug-modes, since this allows more convenient
(shorter) invocations.
compiler/mode_debug.m:
Respect the new options when deciding how much data to print
when debugging of the mode checking process is enabled.
compiler/switch_detect.m:
Rename a predicate to make it differ from another predicate by more
than just its arity.
compiler/passes_aux.m:
Bring this module up to date with our current style guidelines,
by using state variable syntax where appropriate.
compiler/*.m:
Minor changes to conform to the change in the HLDS and/or parse tree
goal type.
mdbcomp/program_representation.m:
Rename the some goal to the scope goal, and the same for path steps,
to keep them in sync with the HLDS.
browser/declarative_tree.m:
Conform to the change in goal representations.
tests/hard_coded/promise_equivalent_solutions_test.{m,exp}:
A new test case to test the handling of the
promise_equivalent_solutions construct.
tests/hard_coded/Mmakefile:
Enable the new test.
tests/hard_coded/purity/promise_pure_test.{m,exp}:
A new test case to test the handling of the promise_pure and
promise_semipure constructs.
tests/hard_coded/purity/Mmakefile:
Enable the new test.
tests/invalid/promise_equivalent_solutions.{m,err_exp}:
A new test case to test the error messages for improper use of the
promise_pure and promise_semipure constructs.
tests/invalid/Mmakefile:
Enable the new test.
|
||
|
|
c08ca7fbc8 |
Import only one module per line in the modules of the compiler
Estimated hours taken: 3 Branches: main compiler/*.m: Import only one module per line in the modules of the compiler where my previous diff did not already do so. Misc other cleanups. Where relevant, use the new mechanism in tree.m. compiler/tree.m: Fix a performance problem I noticed while update :- import_module items. Instead of supplying a function to convert lists of trees to a tree, make the tree data structure able to hold a list of subtrees directly. This reduces the number of times where we have to convert list of trees to trees that are sticks just to stay within the old definition of what a tree is. |
||
|
|
4970242093 |
Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id
Estimated hours taken: 4 Branches: main Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id defined in mdb.declarative_execution and delete proc_id, since these data structures are almost identical. browser/declarative_execution.m Remove proc_id and flat_module_name types. Use mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name instead. browser/declarative_debugger.m browser/declarative_oracle.m browser/declarative_tree.m browser/declarative_user.m Use mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name instead of mdb.declarative_execution.proc_id and mdb.declarative_execution.module_name. mdbcomp/prim_data.m compiler/prog_out.m Move sym_name_to_string from prog_out to prim_data. Fix comment for prog_out.sym_name_and_arity_to_string. compiler/bytecode.m compiler/check_typeclass.m compiler/code_gen.m compiler/deforest.m compiler/higher_order.m compiler/hlds_code_util.m compiler/hlds_error_util.m compiler/hlds_module.m compiler/hlds_out.m compiler/intermod.m compiler/layout_out.m compiler/make.module_target.m compiler/make_hlds.m compiler/mercury_compile.m compiler/mercury_to_mercury.m compiler/ml_elim_nested.m compiler/mlds_to_c.m compiler/mlds_to_gcc.m compiler/mlds_to_il.m compiler/mlds_to_java.m compiler/mlds_to_managed.m compiler/modes.m compiler/modules.m compiler/opt_debug.m compiler/options_file.m compiler/polymorphism.m compiler/prog_io.m compiler/prog_rep.m compiler/rl.m compiler/rl_exprn.m compiler/rl_gen.m compiler/rl_info.m compiler/rl_out.pp compiler/rtti.m compiler/rtti_out.m compiler/rtti_to_mlds.m compiler/source_file_map.m compiler/table_gen.m compiler/trans_opt.m compiler/unify_gen.m compiler/unique_modes.m compiler/unused_args.m Use mdbcomp.prim_data.sym_name_to_string instead of prog_out.sym_name_to_string. |
||
|
|
9521818650 |
Get the purity check pass to not issue warnings about unnecessary purity
Estimated hours taken: 16 Branches: main Get the purity check pass to not issue warnings about unnecessary purity annotations on compiler-generated predicates. The problem I am addressing is that when an optimization such as type specialization creates a clone of a predicate, that predicate gets all the original predicate's annotations. During the creation of a .opt file, purity checking sees the clauses of the original predicate and knows that the annotation is not redundant, but doesn't know that about the copy, since it has no definition at all (it doesn't need one). The fix is to put into each pred_info an indication of where the predicate came from, and to never warn about unnecessary purity annotations of predicates that the programmer didn't write. This diff also uses the origin indication to record human-usable names of compiler-generated or compiler-transformed predicates in RTTI for use by the debugger. compiler/hlds_pred.m: Replace two fields in pred_infos, that say (a) whether the predicate is a special (unify/compare/index/init) predicate and (b) whether it is a type class method implementation, with an origin field saying where the predicate came from. This field has several alternatives, special preds and type class method implementation being only two. Make the predicates that create pred_infos take an argument specifing where the predicate comes from. Replace a copy of one of the old fields in rtti_proc_labels with the new one. Make the name of the existing function more descriptive. compiler/purity.m: Use the origin field to suppress unnecessary annotation warnings for compiler-generated predicates. compiler/layout_out.m: Use the origin field to generate more human-friendly names for predicates, instead of the existing linker-friendly names. The debugger doesn't insist on predicate names being unique, even within a module. compiler/*.m: Conform to the changed interface of hlds_pred.m. The most significant changes were for recording the origin of new predicates. In one case (dnf.m) it also involved passing the required information down to the place where the new predicates were created through the dnf_info tuple instead of separate arguments, and switching to state variable notation. tests/debugger/*.exp*: tests/debugger/declarative/*.exp*: tests/hard_coded/*.exp*: Update the expected outputs to expect human-friendly predicate names. |
||
|
|
59d2d4a573 |
This adds a module mdbcomp__trace_counts that reads in the
Estimated hours taken: 17 Branches: main This adds a module mdbcomp__trace_counts that reads in the .mercury_trace_counts files produced by the compiler's trace mechanism. The format of said files was slightly changed. As the new module is to be used by the compiler and the debugger, it is placed in the mdbcomp module. This required bringing some types from the compiler into a new module within mdbcomp. browser/trace_counts.m: New module for reading execution trace summaries. browser/prim_data.m: New module holding types and predicates moved in from the compiler. Types: pred_or_func, sym_name, module_name, proc_label, special_pred_id, trace_port Predicates: string_to_sym_name, insert_module_qualifier The mode field of proc_label is now an int instead of a proc_id to avoid pulling proc_id into mdbcomp. browser/mdbcomp.m: Add trace_counts and prim_data to the mdbcomp module. browser/declarative_execution.m: Renamed mdb's definition of module_name to flat_module_name to avoid conflicts with the definition in mdbcomp__prim_data. runtime/mercury_trace_base.c: In the format of .mercury_trace_counts, write module and predicate names now use quoted atom syntax so that names with spaces and non-printable characters can be machine-parsed. browser/: compiler/: Many changes to account for movement of types, and the change to proc_label. |
||
|
|
6c9e970f5b |
Fix formatting.
Estimated hours taken: 0.1 Branches: main compiler/code_gen.m: Fix formatting. |
||
|
|
d03ce7dbc0 |
Fix some bugs in my previous diff that optimized away stack slots storing
Estimated hours taken: 8 Branches: main Fix some bugs in my previous diff that optimized away stack slots storing dummy values that manifested themselves as warnings from the C compiler about integers too big to fit into 8 or 16 bits being implicitly truncated. They did not lead to the failure of any test case, since it doesn't matter whether the debugger gets the values it ignores (I/O states or stores) from valid stack slots or not. When generating RTTI for gc and the debugger, the compiler had three places that generated references to stack slots: the return sites of calls, resume points, and trace events. The previous diff updated only the first of these. This diff updates the other two, and ensures there are no more. Since the debugger needs to know whether a procedure has a pair of I/O state arguments (e.g. when performing a retry), we add a field to proc layouts to hold this information. runtime/mercury_grade.h: Increment the debug grade runtime compatibility version number to reflect the change in layout structures. runtime/mercury_stack_layout.h: Add an extra field to proc layouts to specify flags. At the moment, the only flag says whether the procedure has a pair of I/O state arguments. Add an extra field to proc layouts to specify the trace level of a procedure. This used to be the same as the module's trace level, but one of my bug fixes a couple of months ago broke that link. We don't yet use this field, but it makes sense to do it at the same time as the increment of the compatibility version number. compiler/continuation_info.m: Attach to every description of a live value a description of where in the compiler that description was created. Rename the type involved to avoid an ambiguity. Ignore dummy types when generating resume layouts. Add some sanity checks. Add new fields to the continuation_info data structure to allow stack_layout.m to fill in the new fields in proc layout structures. compiler/trace.m: Do not generate references to dummy values at trace events, except at call ports. At those ports, all live variables should be in registers. compiler/stack_layout.m: Make the check for whether a value fits into an unsigned 8 bit value a direct rather than an indirect one. The indirect one assumed that stack slot numbers are all positive, which is now a bad assumption. Check for negative stack slot numbers in all RTTI stack slot descriptions. Fill in the two new slots in proc layout structures. compiler/layout.m: Reserve space for the two new slots in proc layout structures. compiler/layout_out.m: Output the two new slots in proc layout structures. compiler/code_gen.m: Preserve the information needed by stack_layout.m for the two new fields. compiler/llds_out.m: Add some code that ensures that we never output an integer constant that doesn't fit into the range of its type. Since this code is executed many millions of times, it is designed to be enabled only when the checking is manually enabled. It is normally off, but I got a clean bootcheck in the debug grade (which is the best stress test) with it enabled. compiler/trace_params.m: Update a comment. compiler/code_info.m: Export a function for use by trace.m. compiler/hlds_pred.m: Export a predicate for use by stack_layout.m. compiler/Mercury.options: Enable inlining for llds_out.m, to get rid of the sanity checking overhead if it is not enabled. tests/debugger/completion.exp*: tests/debugger/interpreter.exp*: tests/debugger/multi_parameter.exp*: tests/debugger/queens.exp*: tests/debugger/print_goal.exp*: tests/debugger/tabled_read.exp*: tests/debugger/tabled_read_decl.exp*: tests/debugger/declarative/io_stream_test.exp*: tests/debugger/declarative/tabled_read_decl.exp*: Update these expected output files to not expect dummy values that aren't kept anymore. |
||
|
|
f76c4823e5 |
Fix a problem reported by Ian: the debugger ignored information about the head
Estimated hours taken: 2
Branches: main
Fix a problem reported by Ian: the debugger ignored information about the head
variables of the predicates generated by the compiler from lambda expressions
because they didn't have names.
compiler/hlds_pred.m:
Add a predicate to ensure that all headvars have names.
compiler/lambda.m:
Call that predicate to give names to the predicates created from lambda
expressions.
compiler/code_gen.m:
Call that predicate to give names to the predicates created from lambda
expressions, in case other transformations also create predicates
with unnamed head variables.
doc/user_guide.texi:
Add a new mdb command, var_details, and a new method of invocation of
an existing mdb command, flag. I used them to track down this bug.
trace/mercury_trace_internal.c:
Implement the var_details mdb command, and the new method of invocation
of the flag command.
trace/mercury_trace_vars.[ch]:
Add a function to print variable details.
tests/debugger/mdb_command_test.inp:
Test the documentation of the new command.
tests/debugger/completion.exp:
Expect the new command.
tests/debugger/lambda_expr.{m,inp,exp}:
Add the new test case to test for the bug.
tests/debugger/Mmakefile:
Enable the new test case.
|
||
|
|
d332038ee1 |
Bring these modules up to date with our coding guidelines.
Estimated hours taken: 16 Branches: main compiler/aditi_builtin_ops.m: compiler/bytecode.m: compiler/bytecode_backend.m: compiler/bytecode_gen.m: compiler/c_util.m: compiler/code_gen.m: compiler/deep_profiling.m: compiler/deforest.m: compiler/dependency_graph.m: compiler/fact_table.m: compiler/follow_code.m: compiler/handle_options.m: compiler/hlds_out.m: compiler/il_peephole.m: compiler/ilasm.m: compiler/java_util.m: compiler/liveness.m: compiler/magic.m: compiler/magic_util.m: compiler/make.dependencies.m: compiler/make.m: compiler/make.module_dep_file.m: compiler/make.program_target.m: compiler/make.util.m: compiler/matching.m: compiler/name_mangle.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/options.m: compiler/options_file.m: compiler/prog_io.m: compiler/rtti_out.m: compiler/rtti_to_mlds.m: compiler/saved_vars.m: compiler/source_file_map.m: compiler/stack_alloc.m: compiler/stack_layout.m: compiler/stratify.m: compiler/switch_detection.m: compiler/term_errors.m: compiler/type_ctor_info.m: compiler/unify_proc.m: compiler/unique_modes.m: Bring these modules up to date with our coding guidelines. Use predmode syntax for declarations. Use state variable syntax where appropriate, and reorder arguments where this is needed for the use of state variable syntax. Remove module qualification from the names of defined predicates when the module qualification was used inconsistently (causing problems for the use of tags) or was causing problems with indentation. There are no changes in algorithms. |
||
|
|
885fd4a387 |
Remove almost all dependencies by the modules of parse_tree.m on the modules
Estimated hours taken: 12 Branches: main Remove almost all dependencies by the modules of parse_tree.m on the modules of hlds.m. The only such dependencies remaining now are on type_util.m. compiler/hlds_data.m: compiler/prog_data.m: Move the cons_id type from hlds_data to prog_data, since several parts of the parse tree data structure depend on it (particularly insts). Remove the need to import HLDS modules in prog_data.m by making the cons_ids that refer to procedure ids refer to them via a new type that contains shrouded pred_ids and proc_ids. Since pred_ids and proc_ids are abstract types in hlds_data, add predicates to hlds_data to shroud and unshroud them. Also move some other types, e.g. mode_id and class_id, from hlds_data to prog_data. compiler/hlds_data.m: compiler/prog_util.m: Move predicates for manipulating cons_ids from hlds_data to prog_util. compiler/inst.m: compiler/prog_data.m: Move the contents of inst.m to prog_data.m, since that is where it belongs, and since doing so eliminates a circular dependency. The separation doesn't serve any purpose any more, since we don't need to import hlds_data.m anymore to get access to the cons_id type. compiler/mode_util.m: compiler/prog_mode.m: compiler/parse_tree.m: Move the predicates in mode_util that don't depend on the HLDS to a new module prog_mode, which is part of parse_tree.m. compiler/notes/compiler_design.m: Mention prog_mode.m, and delete the mention of inst.m. compiler/mercury_to_mercury.m: compiler/hlds_out.m: Move the predicates that depend on HLDS out of mercury_to_mercury.m to hlds_out.m. Export from mercury_to_mercury.m the predicates needed by the moved predicates. compiler/hlds_out.m: compiler/prog_out.m: Move predicates for printing parts of the parse tree out of hlds_out.m to prog_out.m, since mercury_to_mercury.m needs to use them. compiler/purity.m: compiler/prog_out.m: Move predicates for printing purities from purity.m, which is part of check_hlds.m, to prog_out.m, since mercury_to_mercury.m needs to use them. compiler/passes_aux.m: compiler/prog_out.m: Move some utility predicates (e.g. for printing progress messages) from passes_aux.m to prog_out.m, since some predicates in submodules of parse_tree.m need to use them. compiler/foreign.m: compiler/prog_data.m: Move some types from foreign.m to prog_data.m to allow the elimination of some dependencies on foreign.m from submodules of parse_tree.m. compiler/*.m: Conform to the changes above, mostly by updating lists of imported modules and module qualifications. In some cases, also do some local cleanups such as converting predicate declarations to predmode syntax and fixing white space. |
||
|
|
7bf0cd03af |
Reduce the overhead of all forms of tabling by eliminating in many cases
Estimated hours taken: 32
Branches: main
Reduce the overhead of all forms of tabling by eliminating in many cases
the overhead of transferring data across the C/Mercury boundary. These
involve lots of control transfers as well as assignments to and from
Mercury abstract machine registers, which are not real machine registers
on x86 machines. Benchmarking in Uppsala revealed this overhead to be
a real problem.
The way we do that is by changing the tabling transformation so that instead
of generating sequences of calls to predicates from library/table_builtin.m,
we generate sequences of calls to C macros from runtime/mercury_tabling_pred.h,
and emit the resulting code string as the body of a foreign_proc goal.
(The old transformation is still available via a new option,
--no-tabling-via-extra-args.)
Since the number of inputs and outputs of the resulting C code sequences
are not always fixed (they can depend on the number of input or output
arguments of predicate being transformed), implementing this required
adding to foreign_procs a new field that allows the specification of extra
arguments to be passed to and from the given foreign code fragment. For now,
this mechanism is implemented only by the C backends, since it is needed
only by the C backends. (We don't support yet tabling on other backends.)
To simplify the new implementation of the field on foreign_procs, consolidate
three existing fields into one. Each of these fields was a list with one
element per argument, so turning them into a single list with a combined record
per argument should also improve reliability, since it reduces the likelyhood
of updates leaving the data structure inconsistent.
The goal paths of components of a tabled predicate depend on whether
-no-tabling-via-extra-args was specified. To enable the expected outputs
of the debugger test cases testing tabling, we add a new mdb command,
goal_paths, that controls whether goal paths are printed by the debugger
at events, and turn off the printing of events in the relevant test cases.
Also, prepare for a future change to optimize the trie structure for
user-defined types by handling type_infos (and once we support them,
typeclass_infos) specially.
compiler/table_gen.m:
Change the tabling transformation along the lines described above.
To allow us to factor out as much of the new code as possible,
we change the meaning of the call_table_tip variable for minimal
model subgoals: instead of the trie node at the end of the answer
table, it is not now the subgoal reachable from it. This change
has no effect as yet, because we use call_table_tip variables
only to perform resets across retries in the debugger, and we
don't do retries across calls to minimal model tabled predicates.
Put predicates into logical groups.
library/table_builtin.m:
runtime/mercury_tabling_preds.h:
When the new transformations in table_gen.m generate foreign_procs
with variable numbers of arguments, the interfaces of those
foreign_procs often do not match the interfaces of the existing
library predicates at their core: they frequently have one more
or one fewer argument. To prevent any possible confusion, in such
cases we add a new variant of the predicate. These predicates
have the suffix _shortcut in their name. Their implementations
are dummy macros that do nothing; they serve merely as placeholders
before or after which the macros that actually do the work are
inserted.
Move the definitions of the lookup, save and restore predicates
into mercury_tabling_preds.h. Make the naming scheme of their
arguments more regular.
runtime/mercury_minimal_model.c:
runtime/mercury_tabling_preds.h:
Move the definition of a predicate from mercury_minimal_model.c
to mercury_tabling_preds.h, since the compiler now needs to be
able to generate an inlined version of it.
compiler/hlds_goal.m:
Replace the three existing fields describing the arguments of
foreign_procs with one, and add a new field describing the extra
arguments that may be inserted by table_gen.m.
Add utility predicates for processing the arguments of foreign_procs.
Change the order of some existing groups of declarations make it
more logical.
compiler/hlds_pred.m:
runtime/mercury_stack_layout.h:
Extend the data structures recording the structure of tabling tries
to allow the representation of trie steps for type_infos and
typeclass_infos.
runtime/mercury_tabling_macros.c:
Fix a bug regarding the tabling of typeclass_infos, which is now
required for a clean compile.
compiler/pragma_c_gen.m:
compiler/ml_code_gen.m:
Modify the generation of code for foreign_procs to handle extra
arguments, and to conform to the new data structures for foreign_proc
arguments.
compiler/llds.m:
The tabling transformations can now generate significantly sized
foreign_procs bodies, which the LLDS code generator translates to
pragma_c instructions. Duplicating these by jump optimization
may lose more by worsening locality than it gains in avoiding jumps,
so we add an extra field to pragma_c instructions that tells jumpopt
not to duplicate code sequences containing such pragma_cs.
compiler/jumpopt.m:
Respect the new flag on pragma_cs.
compiler/goal_util.m:
Add a predicate to create foreign_procs with specified contents,
modelled on the existing predicate to create calls.
Change the order of the arguments of that existing predicate
to make it more logical.
compiler/polymorphism.m:
Conform to the new definition of foreign_procs. Try to simplify
the mechanism for generating the type_info and typeclass_info
arguments of foreign_proc goals, but it is not clear that this
code is even ever executed.
compiler/aditi_builtin_ops.m:
compiler/assertion.m:
compiler/bytecode_gen.m:
compiler/clause_to_proc.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/code_util.m:
compiler/constraint.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/dnf.m:
compiler/dupelim.m:
compiler/equiv_type_hlds.m:
compiler/exprn_aux.m:
compiler/follow_code.m:
compiler/follow_vars.m:
compiler/frameopt.m:
compiler/goal_form.m:
compiler/goal_path.m:
compiler/higher_order.m:
compiler/higher_order.m:
compiler/hlds_module.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/ite_gen.m:
compiler/layout_out.m:
compiler/livemap.m:
compiler/liveness.m:
compiler/llds_out.m:
compiler/loop_inv.m:
compiler/magic.m:
compiler/make_hlds.m:
compiler/mark_static_terms.m:
compiler/middle_rec.m:
compiler/modes.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/pd_cost.m:
compiler/prog_rep.m:
compiler/purity.m:
compiler/quantification.m:
compiler/reassign.m:
compiler/rl_exprn.m:
compiler/saved_vars.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/store_alloc.m:
compiler/stratify.m:
compiler/switch_detection.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unneeed_code.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
Conform to the new definition of foreign_procs, pragma_cs and/or
table trie steps, or to changed argument orders.
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/cse_detection.m:
compiler/dead_proc_elim.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/lco.m:
compiler/module_util.m:
compiler/opt_util.m:
compiler/stack_opt.m:
compiler/trans_opt.m:
Conform to the new definition of foreign_procs.
Bring these modules up to date with our current code style guidelines,
using predmode declarations, state variable syntax and unification
expressions as appropriate.
compiler/mercury_compile.m:
Conform to the changed argument order of a predicate in trans_opt.m.
compiler/options.m:
Add the --no-tabling-via-extra-args option, but leave the
documentation commented out since the option is for developers only.
doc/user_guide.texi:
Document --no-tabling-via-extra-args option, though leave the
documentation commented out since the option is for developers only.
doc/user_guide.texi:
doc/mdb_categories:
Document the new goal_paths mdb command.
trace/mercury_trace_internals.c:
Implement the new goal_paths mdb command.
tests/debugger/completion.exp:
Conform to the presence of the goal_paths mdb command.
tests/debugger/mdb_command_test.inp:
Test the existence of documentation for the goal_paths mdb command.
tests/debugger/print_table.{inp,exp*}:
tests/debugger/retry.{inp,exp*}:
Use the goal_paths command to avoid having the expected output
depend on the presence or absence of --tabling-via-extra-args.
tests/tabling/table_foreign_output.{m,exp}:
Add a new test case to test the save/restore of arguments of foreign
types.
tests/tabling/Mmakefile:
Enable the new test case.
tests/tabling/test_tabling:
Make this script more robust.
Add an option for testing only the standard model forms of tabling.
|
||
|
|
cc508c83de |
Perform frame optimization on nondet predicates.
Estimated hours taken: 6 Branches: main Perform frame optimization on nondet predicates. The need for this was revealed by benchmarking in Uppsala, which initially showed Mercury to take three to five times as long as XSB on some tabling benchmarks. One major contributor was the fact that the predicate returning answers out of answer table was creating and destroying a nondet stack frame for every answer it returned. To make this change easier, make the representation of labels more reader friendly, classifying them primarily on whether they represent entry or internal labels, and only secondarily on the scope in which they represent valid references to the label. compiler/frameopt.m: Add a predicate to perform frame optimization on model_non predicates. This optimization involves separating the steps of creating the frame (done once) and setting the redoip (potentially done on every iteration). compiler/optimize.m: Invoke this new predicate. Reorder the arguments of predicates in this file, and the top level predicates of the optimizations it invokes, to allow the use of state variable notation. runtime/mercury_stacks.h: Provide macros for creating nondet stack frames that do not fill in the redoip slot. compiler/llds.m: Make the setting of redoip optional in mkframe operations. Make the representation of labels more reader friendly. compiler/layout_out.m: Change the representation of label layouts to enforce the invariant that these can refer only to internal labels. (The layout structures of entry labels are proc layout structures, whose design enforces the relevant invariant already.) compiler/jumpopt.m: Add an optimization that improves code that matches a new pattern: % Attempt to transform code such as % % if (Cond) L1 % goto L2 % % into % % if (! Cond) L2 % <code at L1> % % when we know the code at L1 and don't know the code at L2. The new frame optimization creates instances of this pattern, usually with L2 being do_fail. compiler/*.m: Minor diffs to conform to the changes above. |
||
|
|
642c902c90 |
Reduce the sizes of .c and .o files in debug grades by 8%.
Estimated hours taken: 4
Branches: main
Reduce the sizes of .c and .o files in debug grades by 8%.
Add to mdb the capability of putting breakpoints on unify, compare and index
predicates.
compiler/code_gen.m:
Since compiler-generated unify, index and compare pred can be presumed
to be correct, compile them with shallow tracing instead of deep
tracing even if the user asks for deep tracing of the rest of the
module. This saves disk space, compile time and run time.
Move the code for setting the trace level to generate_proc_code,
where it is executed whether we generate code by predicates or by
phases.
compiler/trace_params.m:
Provide a function for use by code_gen.m.
Consider unify and compare predicates to behave as if their address
were taken, since they may be called from builtin.unify or
builtin.compare.
compiler/jumpopt.m:
Do not replace jumps with the block being jumped to if the block
contains an instruction that represents a call to the debugger.
In such cases, the jump is a minor cost in runtime compared to the
call, and the locality benefit from not increasing the code size is
quite likely to exceed that cost.
compiler/llds.m:
Add field names to pragma_c instructions to make the change to jumpopt
easier.
tests/debugger/uci.{inp,exp}:
Update this test case. An update is required since we now generate
fewer events from unify and compare preds due to their now being
shallow traced.
To make this the update easier, use the new capability of putting
breakpoints on unify and compare predicates.
trace/mercury_trace_tables.[ch]:
Expand procedure specifications to allow the specification of unify,
compare and index predicates, and expand the function that checks for
matches between a procedure layout and a procedure specification
accordingly.
Fix two instances of a bug: if a procedure specification has no name,
represent it as NULL, not as a non-NULL pointer to a null character,
since the match function expects only the former.
doc/user_guide.texi:
Document the new definition of procedure specifications.
NEWS:
Mention the new definition of procedure specifications, and expand
on some previous additions to the debugger.
runtime/mercury_stack_trace.c:
Allow mdb breakpoint specifications on uci predicates to be saved.
Factor out some common data structure accesses.
runtime/mercury_proc_id.h:
Change the name of a macro from MR_PROC_ID_COMPILER_GENERATED to
MR_PROC_ID_IS_UCI, for consistency with other names dealing with
unify, compare and index predicates.
runtime/*.[ch]:
trace/*.[ch]:
Conform to the change in mercury_proc_id.h.
|
||
|
|
c80d143cc8 |
The following change is only 98% complete, not 100%.
Estimated hours taken: 120
Branches: main
The following change is only 98% complete, not 100%. I am committing it in
this state because (1) we pass many more test cases in deep profiling grade
with it than without it, and (2) the double maintanance involved in fixing
CVS conflicts is preventing me from doing the last 2%.
Get the deep profiler to work for code that sets up to catch exceptions,
which for the last year or more has included the compiler, and to get it
almost working for code that actually catching exceptions.
The basic problem is that code that throws exceptions will in general cause
several calls to "return" without executing the exit or fail port codes that
the deep profiling transformation inserted into their bodies, and this leaves
the data structure being built by the deep profiling inconsistent. The solution
uses the same approach as we have adopted for the debugger: have the code that
handles the throwing of exceptions simulate a return from each call between
the throw and the catch, updating the deep profiling data structures as needed.
This requires us to be able to walk the stack at runtime not just in debugging
grades but also in deep profiling grades. Since the debugger already has the
mechanisms required for this, we reuse them. The procedure layouts used by the
debugger were designed to have three segments: the procedure stack walk
information, the procedure id, and the execution tracing information. We now
modify this design to make the third segment contain two pointers: to the
execution tracing information (for use by the debugger), and to the procedure's
proc_static structure (for use by deep profiling). Each pointer will be null
unless the pointed-to structure is required by compile-time options.
This common use by the debugger and by deep profiling of the stack-walk
structure and the procedure id structure (which deep profiling used to
generate independently and possibly redundantly) required some rearrangement
of the compiler's version of these data structures.
To make this rearrangement simpler, this diff removes a capability that
we theoretically supported but never used: turning on stack traces without
turning on execution tracing and vice versa. After this diff, stack tracing
is enabled if and only if either execution tracing or deep profiling is
enabled.
The diff also includes improvements in the debugging infrastructure for
debugging deep profiling, which were necessary for the implementation of the
rest of the changes.
compiler/deep_profiling.m:
The code in exception.m needs to know the locations of the variables
that we would pass to the exit or fail port code, so it can simulate
leaving the procedure invocation through the exception port. Without
this information, throwing an exception leaves the deep profiling
data structures of the procedure invocations between throw and catch
in an inconsistent state.
Deep_profiling.m creates these variables, but it doesn't know where
they will be at runtime, so it records their identities; the code
generator will allocate them stack slots and record the numbers of
these stack slots for placement in the now expanded proc layout
structures. Deep profiling used to generate static data structures
separately from the HLDS, but since the code generator now needs
access to them, we store their information in proc_infos in the HLDS.
Instead of passing the addresses of proc_static structures to the deep
profiling port procedures, pass the address of proc_layout structures,
since the information about the identities of procedures are now stored
not in the proc_static structure, but in the proc_layout structure
that points to the proc_static structure.
compiler/hlds_pred.m:
compiler/layout.m:
Move the definitions of the static data structures generated by deep
profiling from layout.m to hlds_pred.m, to allow deep_profiling.m
to store them in proc_infos.
compiler/hlds_pred.m:
compiler/rtti.m:
Move the definition of rtti_proc_label from rtti.m to hlds_pred.m,
since some of the new data structures in hlds_pred.m need it. Despite
its name, the rtti_proc_label type doesn't contain any info that
doesn't belong in the HLDS.
Add some information to the rtti_proc_label type that is now needed
by deep profiling, e.g. record determinisms instead of just code
models. Record explicitly the outcome of some tests that used to be
duplicated in more than one place in the compiler, e.g. for whether
the procedure (as opposed to the predicate) is imported. Change some
of the field names to be more precise about the field's meaning.
compiler/code_gen.m:
Transmit the contents of the deep profiling data structures stored in
the proc_info by deep_profiling.m to continuation_info.m, together
with the layout structures created for execution tracing and the
identities of the variables needed for handling exceptions,
when code generation for a procedure is complete.
After the goal that generates these variables, save them to stack
for use by the exception handler.
compiler/hlds_goal.m:
Add a feature to mark the goal that generates the deep profiling
variables needed by the exception handler.
compiler/hlds_llds.m:
Add a utility predicate for new code in code_gen.m
compiler/continuation_info.m:
Hold the deep profiling information computed by code_gen.m for use by
stack_layout.m.
compiler/layout.m:
compiler/layout_out.m:
Update the definitions of the data structures describing procedure
layouts, and the code writing them out, to reflect the use of some
parts of procedure layouts by deep profiling as well as debugging.
Change the layout structures generated by deep profiling to use
rtti_proc_labels, which are backend independent, instead of
proc_labels, which are specific to the LLDS backend.
Conform to the changes in runtime/mercury_stack_layout.h.
compiler/stack_layout.m:
Generate the updated version of proc_layout structures.
compiler/mercury_compile.m:
compiler/global_data.m:
Conform to the fact that deep profiling no longer generates layout
structures separate from proc_infos.
compiler/llds_out.m:
Register proc_layout structures instead of proc_static structures
for use by runtime/mercury_deep_profiling.c.
compiler/options.m:
compiler/handle_options.m:
Rename the require_tracing option as exec_trace, since this more
directly reflects its meaning.
Instead of having --debug set both require_tracing and stack_trace,
make it set (be the user-visible name of) just exec_trace;
the value of stack_trace is implied.
Turn off the specialization of deep profiling for self-tail-recursive
procedures for now. Due to the changes made by this diff in the data
structures involved in debugging, it cannot be debugged until this
change has been installed. Handling the full language is more important
than a specialization that reduces only stack space overheads, not
runtime overheads.
compiler/compile_target_code.m:
Conform to the changes in options.m and runtime/mercury_grade.h.
compiler/hlds_data.m:
Replace the deep_profiling_proc_static cons_id, and its associated tag,
to deep_profiling_proc_layout, since we now generate addresses of proc
layout structures, not of proc_static structures.
compiler/code_util.m:
Simplify some code based on the new info in rtti_proc_labels.
compiler/bytecode_gen.m:
compiler/dependency_graph.m:
compiler/higher_order.m:
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_util.m:
compiler/ml_unify_gen.m:
compiler/opt_debug.m:
compiler/proc_label.m:
compiler/prog_rep.m:
compiler/rl_exprn.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/switch_util.m:
compiler/unify_gen.m:
Minor changes to conform to the change from deep_profiling_proc_static
to deep_profiling_proc_layout, to the change in the structure of
rtti_proc_labels, to the changes in types of layout.m, and/or to the
new goal feature.
deep_profiler/measurements.m:
Reserve space for exception counts.
deep_profiler/html_format.m:
Add a column for exception counts.
deep_profiler/profile.m:
deep_profiler/read_profile.m:
Rename the data structures referring to compiler generated unify,
compare and index predicates to avoid misleading names: they are
not the only compiler generated predicates.
deep_profiler/read_profile.m:
runtime/mercury_deep_profiling.c:
Update the string that identifies deep profiling data files.
This is necessary because the format has changed: it now includes
information about exception port counts.
library/exception.m:
In deep profiling grades, execute the exception port code for every
procedure invocation between a throw and a catch, using the procedure
layout structures now generated by the compiler for every procedure.
Rename the function involved to reflect its new, more general purpose.
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code.
Indent C preprocessor directives and foreign_procs according to our
coding standards.
library/profiling_builtin.m:
Change the parameters of the call port code procedures from proc_static
to proc_layout. Reach the proc_static structure from the proc_layout
structure when needed. Include the proc_layout structure in any
messages from assertion failures.
Add some conditionally compiled debugging code.
Give some variables better names.
runtime/mercury_type_info.h:
runtime/mercury_builtin_types.c:
Move the macros required to create the proc_static structures
of unify and compare predicates from mercury_type_info.h
to mercury_builtin_types.c, since the latter is the only file
that needs them.
Use the same macros for creating the proc_static structures
of hand-written unify, compare and compare_reprentation predicates
as for user defined predicates. This required changing their naming
scheme.
runtime/mercury_unify_compare_body.h:
Conform to the new naming scheme.
runtime/mercury_ho_call.c:
Provide the mechanism for mercury_unify_compare_body.h to conform
to the new naming scheme.
Remove the definitions of the proc_static structures for
hand-written unify, compare and compare_reprentation predicates,
since these now have to be defined together with the corresponding
proc_layout structures in mercury_builtin_types.c.
runtime/mercury_builtin_types.[ch]:
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code,
and add the required declarations first.
Handle deep profiling of compare_representation as well as unify
and compare predicates on builtin types.
Handle deep profiling of compare_representation on user-defined types,
since this is done entirely in the runtime, not by compiler generated
predicates.
runtime/mercury_builtin_types_proc_layouts.h:
New header file containing the declarations of the proc layout
structures of the unify, compare and index predicates of builtin types.
Logically, these declarations belong in mercury_builtin_types.h,
but putting them there causes problems for the linker; the details
are explained in the file itself.
runtime/Mmakefile:
Add the new header file.
runtime/mercury_minimal_model.[ch]:
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code,
and add the required declarations first.
runtime/mercury_grade.h:
Replace the MR_REQUIRE_TRACING grade option with MR_EXEC_TRACING.
Besides being better named, the MR_EXEC_TRACING option implies
MR_STACK_TRACE.
Besides the overall binary compatibility version number, add subsidiary
version numbers for binary compatibility in deep profiling and
debugging grades. These will make it easier to bootstrap changes
(such as this) that affect binary compatibility only in such grades.
runtime/mercury_trace_base.c:
trace/mercury_trace.c:
Conform to the new names of the configuration parameters.
runtime/mercury_hand_compare_body.h:
runtime/mercury_hand_unify_body.h:
runtime/mercury_hand_unify_compare_body.h:
runtime/mercury_ho_call.c:
tools/make_port_code:
Pass proc_layout structures instead of proc_static structures
to deep profiling port routines.
runtime/mercury_conf_param.h:
Make MR_DEEP_PROFILING as well as MR_EXEC_TRACING imply MR_STACK_TRACE,
since deep profiling now needs stack tracing. (MR_STACK_TRACE needs
to be set in this file, because tests in this file depend on knowing
its value, and this file is among the first files included (in this
case indirectly) in mercury_imp.h.)
Document the macros controlling the debugging of deep profiling.
Enable printing of label names when the relevant deep profiling
debugging macro is set.
runtime/mercury_debug.c:
runtime/mercury_deep_rec_depth_actions.h:
runtime/mercury_deep_rec_depth_body.h:
runtime/mercury_exception_catch_body.h:
Get to proc_statics via proc_layouts.
runtime/mercury_deep_call_port_body.c:
runtime/mercury_deep_leave_port_body.c:
Get to proc_statics via proc_layouts.
Allow the debugger to disable deep profiling in Mercury code that is
part of the debugger, not of the user program being executed.
Add some more assertions.
runtime/mercury_engine.[ch]:
Add a new debugging flag that controls at runtime whether we generate
a human readable Deep.debug equivalent to the binary Deep.data files.
(We already had a mechanism for controlling this at compile time,
but this isn't flexible enough.)
runtime/mercury_wrapper.c:
Allow this new debugging flag to be set from MERCURY_OPTIONS.
runtime/mercury_deep_profiling.[ch]:
Respect this new debugging flag.
Update the hand-written proc_static structures representing the runtime
system.
Print out addresses of proc_layout as well as proc_static structures
when assertions fail.
Add a field to the measurement structure for exception port counts,
and write out this field with the other port counts.
Remove procedure id information from proc_static structures,
deep profiling now uses the procedure id in the proc_layout structure.
Add to proc_static structures fields that specify where, if anywhere,
the variables needed by exception.m to executed the exception port code
are in the procedure's stack frame.
Define a global flag that allows the debugger to disable deep
profiling in Mercury code that is part of the debugger, not of the
user program being executed.
Increase type safety by providing two versions of the function
for registering proc_layouts, one for the proc_layout structures
of user-defined predicates and one for unify, compare and index
predicates.
Fix a bug that occurs only if MR_DEEP_PROFILING_EXPLICIT_CALL_COUNTS is
defined (which it usually isn't): the initial call count was wrong.
runtime/mercury_deep_profiling_hand.h:
Fix a bug: the handwritten code saving deep profiling variables was
saving them in slots that didn't belong to the relevant stack frame.
Update to conform to the modified definitions of proc_static structures
and the fact that we now reach them via proc_layout structures.
runtime/mercury_exception_catch_body.h:
runtime/mercury_stacks.h:
Fix the other side of the bug in mercury_deep_profiling_hand.h
by reserving the right number of stack slots in the stack frames
of the various modes of exception__catch. Make it harder to make
the same bug in the future by getting the needed info from the
place in mercury_stacks.h that defines the structure of the relevant
stack frame.
runtime/mercury_proc_id.h:
Rename the procedure id structure fields referring to compiler
generated unify, compare and index predicates: they are not the only
compiler-generated predicates.
runtime/mercury_stack_layout.h:
Change procedure layout structures to allow them to be used for deep
profiling as well as for debugging, as described in the prologue above.
We don't need the capability to support label layout structures with
links to misnamed proc layout structures, and supporting it is
inconvenient, so delete the capability.
runtime/mercury_debug.c:
runtime/mercury_deep_profiling_hand.h:
runtime/mercury_layout_util.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_types.h:
trace/mercury_trace_external.c:
Conform to the new names of the procedure id structure fields.
runtime/mercury_std.h:
Add some more arities for MR_PASTE for use in some of the modified
modules in the runtime.
trace/mercury_trace_internal.c:
Disable deep profiling actions in Mercury code that is part of the
debugger, not of the program being debugged.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Make changes parallel to the ones in runtime/mercury_grade.h: delete
--stack-trace as an independent option, and make --debug set its
own option, not --require-tracing.
scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/c2init.in:
scripts/mgnuc.in:
scripts/ml.in:
Conform to the changes in grade options for debugging and for deep
profiling.
tools/bootcheck:
If Mmake.stage.{browser,deep,library,runtime,trace}.params exist,
copy them to become the file Mmake.$dir.params in stage2/$dir
(where dir is derived from the name of the original file in the obvious
way). This allows more flexibility in the creation of the stage2;
for example, it allows some directories (e.g. runtime or library)
to be compiled with more debugging than other directories (e.g.
compiler). This may be required because compiling all directories
with lots of debugging may cause the linker to thrash.
Add an option, --disable-debug-libs, that clobbers the libraries
that should be linked in only in debugging grades.
To conserve disk space, remove Deep.data files created by the bootcheck
by default. Add an option, --keep-deep-data, to preserve these files.
Use a consistent mechanism (test -f) for testing the existence of
all files whose existence is tested.
When recording modification times, record the modification times
of some more files.
tests/hard_coded/Mmakefile:
In deep profiling grades, disable the test cases that we don't now
pass in such grades, and document the reasons for their failure.
Fix the misclassification of the write_binary test case.
|
||
|
|
bd1ea24cc3 |
Remove the dependence of this module on ll_backend.llds by defining
Estimated hours taken: 6 Branches: main compiler/hlds_llds.m: Remove the dependence of this module on ll_backend.llds by defining types using abstract descriptions of LLDS storage locations. These have the added advantage that they express the intent of the affected data structures more directly. For example, the stack slot type used to be able to map a variable to a register or to a field of a cell on the heap, which doesn't make sense. This is no longer the case. The cost of the conversion operations now required is partly paid for by our new ability to avoid some old sanity checks. compiler/llds.m: compiler/code_util.m: Add some utility predicates to operate on the new data structures. compiler/code_aux.m: compiler/code_gen.m: compiler/code_info.m: compiler/continuation_info.m: compiler/follow_vars.m: compiler/lookup_switch.m: compiler/par_conj_gen.m: compiler/stack_alloc.m: compiler/store_alloc.m: compiler/var_locn.m: Conform to the changes in hlds_llds.m. In some cases, improve the style of the affected predicates, e.g. by introducing state variable syntax. compiler/hlds_out.m: Conform to the changes in hlds_llds.m, and avoid importing ll_backend. |
||
|
|
ff60134ee9 |
Bring these modules up to our current coding standards.
Estimated hours taken: 8 Branches: main analysis/analysis.m: browser/browse.m: compiler/accumulator.m: compiler/assertion.m: compiler/atsort.m: compiler/c_util.m: compiler/check_typeclass.m: compiler/clause_to_proc.m: compiler/code_gen.m: compiler/code_model.m: compiler/const_prop.m: compiler/constraint.m: compiler/dead_proc_elim.m: compiler/delay_construct.m: compiler/dependency_graph.m: compiler/det_analysis.m: compiler/det_report.m: compiler/export.m: compiler/fact_table.m: compiler/follow_code.m: compiler/graph_colour.m: compiler/hlds_module.m: compiler/inlining.m: compiler/llds.m: compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/ml_tailcall.m: compiler/ml_unify_gen.m: compiler/mmc_analysis.m: compiler/mode_errors.m: compiler/passes_aux.m: compiler/post_typecheck.m: compiler/size_prof.m: compiler/switch_util.m: compiler/table_gen.m: compiler/term_errors.m: compiler/transform_llds.m: compiler/type_util.m: compiler/unify_gen.m: compiler/unneeded_code.m: compiler/unused_args.m: Bring these modules up to our current coding standards. Use predmode declarations and state variable syntax where relevant. Reorder arguments where this is needed for the use state variables. Make the orders of predicate definitions correspond to the order of their declarations. Replace some overly large lambda expressions with named predicates. Convert some predicates to functions where this makes their use more convenient. Use field access notation where convenient. Fix any inconsistent indentation. Remove module prefixes on predicate names where this is necessary to allow sane indentation. In several places, use predicates from error_util.m to print error messages. Apart from this, there are no changes in algorithms. In some places, conform to the changes below. compiler/error_util.m: compiler/hlds_error_util.m: Add new variants of existing predicates for use in some of the changed modules above. compiler/hlds_out.m: Add some functions to convert values of some HLDS types as strings, for use in preparing the arguments of the new calls to predicates in error_util.m. Change the implementations of the predicates that print values of those types to call those functions instead of allowing code duplication. compiler/llds.m: Add some field names to allow use of field updates where relevant. tests/invalid/assert_in_interface.err_exp: tests/invalid/multisoln_func.err_exp: tests/invalid/tricky_assert1.err_exp: Update the expected outputs of these test cases to allow for them being generated by error_util.m, and hence being better formatted than before. |
||
|
|
5d6fd3bd6f |
Reduce the dependence of earlier parts of the compiler on the later ones.
Estimated hours taken: 4 Branches: main Reduce the dependence of earlier parts of the compiler on the later ones. Unnecessary import_module declarations in top level modules such as hlds.m cause unnecessary recompilations when adding new types in later modules, such as submodules of ll_backend.m. This change reduces the number of such unnecessary imports. There are no changes in algorithms, only functionality being moved around. compiler/code_model.m: Change this module from being a submodule of backend_libs.m to being a submodule of hlds.m, since nothing in it is dependent on any backend. compiler/arg_info.m: compiler/code_util.m: Change arg_info.m from being a submodule of ll_backend.m to being a submodule of hlds.m, since most of it is applicable to all current and foreseeable backends. Move the one exported predicate that is ll_backend dependent, and its support predicates, to code_util.m. compiler/backend_libs.m: compiler/ll_backend.m: compiler/hlds.m: Update include_module declarations in accordance with the above. compiler/prog_data.m: compiler/term_util.m: Instead of defining two separate types for holding argument size and termination information, one including HLDS-specific information (in term_util.m) and one not (in prog_data.m), use a polymorphic type defined in prog_data.m and two monomorphic instances. compiler/termination.m: compiler/mercury_to_mercury.m: Change the predicates for writing out argument size and termination information to handle the polymorphic type (we don't need special handling of the monomorphic versions), and move them from termination.m to mercury_to_mercury.m, since this allows us to avoid some undesirable dependencies. compiler/base_typeclass_info.m: compiler/hlds_code_util.m: Move the predicate make_instance_string from base_typeclass_info.m to hlds_code_util.m, again because it allows us to remove some undesirable dependencies. compiler/top_level.m: compiler/backend_libs.m: compiler/check_hlds.m: compiler/hlds.m: compiler/ll_backend.m: compiler/parse_tree.m: compiler/transform_hlds.m: Delete some import_module declarations of other top level modules in these top level modules. Some imports were totally unnecessary. Some imports were useful in only a small minority of submodules; those submodules now import the necessary top level modules directly. Move remaining import_module declarations to the implementation section where this is feasible. Where we still need to import modules we ideally shouldn't, note why. compiler/*.m: Update imports of code_util and arg_info. In some cases, import top level modules no longer imported by the parent module. In some cases, delete unnecessary imports. |