mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 10:53:40 +00:00
083d376e6598628362ee91c2da170febd83590f4
142 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
307b1dc148 |
Split up error_util.m into five modules.
compiler/error_spec.m:
This new module contains the part of the old error_util.m that defines
the error_spec type, and some functions that can help construct pieces
of error_specs. Most modules of the compiler that deal with errors
will need to import only this part of the old error_util.m.
This change also renames the format_component type to format_piece,
which matches our long-standing naming convention for variables containing
(lists of) values of this type.
compiler/write_error_spec.m:
This new module contains the part of the old error_util.m that
writes out error specs, and converts them to strings.
This diff marks as obsolete the versions of predicates that
write out error specs to the current output stream, without
*explicitly* specifying the intended stream.
compiler/error_sort.m:
This new module contains the part of the old error_util.m that
sorts lists of error specs and error msgs.
compiler/error_type_util.m:
This new module contains the part of the old error_util.m that
convert types to format_pieces that generate readable output.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new modules.
compiler/error_util.m:
The code remaining in the original error_util.m consists of
general utility predicates and functions that don't fit into
any of the modules above.
Delete an unneeded pair of I/O states from the argument list
of a predicate.
compiler/file_util.m:
Move the unable_to_open_file predicate here from error_util.m,
since it belongs here. Mark another predicate that writes
to the current output stream as obsolete.
compiler/hlds_error_util.m:
Mark two predicates that wrote out error_spec to the current output
stream as obsolete, and add versions that take an explicit output stream.
compiler/Mercury.options:
Compile the modules that call the newly obsoleted predicates
with --no-warn-obsolete, for the time being.
compiler/*.m:
Conform to the changes above, mostly by updating import_module
declarations, and renaming format_component to format_piece.
|
||
|
|
4615e7f559 |
Fix an argument number in a mode error.
This fixes an issue reported on m-users on sep 23, which was caused by
the compiler counting a type_info argument added by the polymorphism pass.
compiler/hlds_pred.m:
Add a field for recording the number of arguments added by the
polymorphism transformation. We could try to figure this out
by counting how many type_info and/or typeclass info args
the argument list contains as an initial subsequence,
and the compiler has code that does that, but this approach
is vulnerable if user code ever passes around e.g. type_infos
*explicitly*, which would be very unusual, but not impossible.
compiler/polymorphism.m:
Fill in this new field.
compiler/mode_errors.m:
Use the new field to fix the argument number in the error message.
(This seems to be the only mode error that makes such a reference.)
compiler/direct_arg_in_out.m:
Conform to the change in hlds_pred.m above.
compiler/mode_info.m:
Clarify some comments.
compiler/modes.m:
Fix indentation.
tests/invalid/mode_error_arg_number.{m,err_exp}:
The code in the original bug report, made into a new test case.
tests/invalid/Mmakefile:
Enable the new test case.
tests/invalid/bug278.err_exp:
tests/invalid/bug415.err_exp:
tests/invalid/merge_ground_any.err_exp:
Expect the correct argument number in these test cases. The old
expected argument numbers were wrong, which means that we had missed
at least three chances to find the bug that this diff fixes. The
wrong argument number was in merge_ground_any.err_exp at its creation
in 2001.
|
||
|
|
d787ee9355 |
Store var_tables in proc_infos.
This fixes the performance problem reported in Mantis bug #562. compiler/hlds_pred.m: Instead of storing a varset and a vartypes in each proc_info, store just a var_table. Update the predicates that create or clone procedures accordingly. Where we had operations on proc_infos that had two versions, one operating on a varset/vartypes pair and one operating on var_table, keep only the latter, with the (shorter) name of the former. Delete the arity argument of proc_info_init, because the only valid value of that argument is the length of the list of the argument types. (In other words, this arg has been redundant all along.) Change the operations that create new variables in a procedure to get the caller to specify the (base) name of the new variable up front. Delete the unused predicate proc_info_ensure_unique_names. compiler/type_util.m: Due to the change above, we now construct var_tables during the construction of the HLDS. The code that does that needs to fill in the field that says whether the type of each variable in the table is a dummy type or not. However, at this time, the pass that decides type representations has not been run yet. The code of is_type_a_dummy used to throw an exception in such situations. Change this so that in such situations, is_type_a_dummy returns a placeholder, not-guaranteed-to-be-correct value. Document why this is ok. compiler/post_typecheck.m: Replace the placeholder values in vte_is_dummy fields in all the entries in the var_tables in all (valid) predicates with valid data. (If there are any invalid predicates, the compilation will fail anyway.) The clause_to_proc pass will copy these updated var_tables to be the initial var_tables in procedures. compiler/make_goal.m: Change the operations that create new variables in a procedure to get the caller to specify the (base) name of the new variable up front. This is simpler than the old method, which created new variables without a name, and had the caller give them a name as a separate operation. And since var_tables need this info, get the caller to also specify whether the type is a dummy, if the type is not a builtin type which is known not to be a dummy. compiler/var_table.m: Document the times when the types and is_dummy fields in var_table entries become meaningful. Fix a potential bug: when performing type substitutions in var_table entries, updating a variable's type may change whether that variable is a dummy or not, so recompute that info. It is quite possible that we *never* replace a nondummy type with a dummy type or vice versa, but in the absence of a convincing correctness argument for that proposition, better safe than sorry. Export the previously-private predicate transform_var_table to post_typecheck. Add code to implement the unused predicate deleted from hlds_pred.m: at the time I wrote it, I haven't yet realised that it was unused. The code I wrote here is therefore unused as well, so it is commented out. I did not delete it, because it may be useful later on. compiler/direct_arg_in_out.m: Don't make and split var_tables, since it is no longer needed. compiler/accumulator.m: compiler/add_class.m: compiler/add_clause.m: compiler/add_heap_ops.m: compiler/add_pred.m: compiler/add_special_pred.m: compiler/add_trail_ops.m: compiler/arg_info.m: compiler/build_mode_constraints.m: compiler/bytecode_gen.m: compiler/check_typeclass.m: compiler/clause_to_proc.m: compiler/closure_analysis.m: compiler/code_gen.m: compiler/code_loc_dep.m: compiler/complexity.m: compiler/continuation_info.m: compiler/cse_detection.m: compiler/ctgc.livedata.m: compiler/deep_profiling.m: compiler/default_func_mode.m: compiler/deforest.m: compiler/delay_construct.m: compiler/delay_partial_inst.m: compiler/dep_par_conj.m: compiler/det_analysis.m: compiler/det_report.m: compiler/distance_granularity.m: compiler/equiv_type_hlds.m: compiler/exception_analysis.m: compiler/float_regs.m: compiler/follow_code.m: compiler/goal_mode.m: compiler/goal_path.m: compiler/higher_order.m: compiler/hlds_out_pred.m: compiler/hlds_rtti.m: compiler/hlds_statistics.m: compiler/inlining.m: compiler/intermod.m: compiler/intermod_analysis.m: compiler/introduce_exists_casts.m: compiler/introduce_parallelism.m: compiler/lambda.m: compiler/lco.m: compiler/live_vars.m: compiler/liveness.m: compiler/loop_inv.m: compiler/mark_tail_calls.m: compiler/ml_accurate_gc.m: compiler/ml_args_util.m: compiler/ml_closure_gen.m: compiler/ml_gen_info.m: compiler/ml_proc_gen.m: compiler/mode_errors.m: compiler/mode_info.m: compiler/modecheck_goal.m: compiler/par_loop_control.m: compiler/pd_debug.m: compiler/pd_info.m: compiler/pd_util.m: compiler/polymorphism_info.m: compiler/post_typecheck.m: compiler/proc_gen.m: compiler/proc_requests.m: compiler/purity.m: compiler/push_goals_together.m: compiler/quantification.m: compiler/rbmm.add_rbmm_goal_infos.m: compiler/rbmm.live_variable_analysis.m: compiler/rbmm.points_to_analysis.m: compiler/rbmm.points_to_graph.m: compiler/rbmm.points_to_info.m: compiler/rbmm.region_liveness_info.m: compiler/rbmm.region_transformation.m: compiler/recompute_instmap_deltas.m: compiler/saved_vars.m: compiler/simplify_goal_unify.m: compiler/simplify_info.m: compiler/simplify_proc.m: compiler/size_prof.m: compiler/ssdebug.m: compiler/stack_alloc.m: compiler/stack_layout.m: compiler/stack_opt.m: compiler/stm_expand.m: compiler/store_alloc.m: compiler/structure_reuse.analysis.m: compiler/structure_reuse.direct.choose_reuse.m: compiler/structure_reuse.direct.detect_garbage.m: compiler/structure_reuse.domain.m: compiler/structure_reuse.indirect.m: compiler/structure_reuse.lbu.m: compiler/structure_reuse.lfu.m: compiler/structure_reuse.versions.m: compiler/structure_sharing.analysis.m: compiler/structure_sharing.domain.m: compiler/switch_detection.m: compiler/table_gen.m: compiler/tabling_analysis.m: compiler/term_constr_build.m: compiler/term_constr_initial.m: compiler/term_errors.m: compiler/term_pass1.m: compiler/term_pass2.m: compiler/trace_gen.m: compiler/trailing_analysis.m: compiler/try_expand.m: compiler/tupling.m: compiler/unneeded_code.m: compiler/untupling.m: compiler/unused_args.m: compiler/unused_imports.m: Conform to the changes above. Mostly this means - not passing a module_info to get a var_table out of a proc_info, but - having to pass a module_info to code that either constructs a var_table, or adds entries to a var_table (since we now need the type table to figure out whether variables' types are dummies). |
||
|
|
ce2fae3565 | Fix grammar. | ||
|
|
edf9d4fa1b |
Document how two fields of mode_info work.
compiler/mode_info.m:
Replace the documentation of the mi_mode_context field,
which was a misleading short comment, with a description of how
the field is actually used. Rename one of the function symbols,
which was misleading, in its type.
Add some documentation of the mi_inst_varset field. The documentation
says how that field is actually handled in practice, though I don't know
*why* it is handled that way.
compiler/modecheck_call.m:
Replace a strange way of getting a proc_info.
Improve some variable names.
compiler/modecheck_goal.m:
Improve some variable names.
compiler/mode_errors.m:
compiler/modecheck_util.m:
Conform to the changes above.
compiler/rbmm.region_transformation.m:
Delete an already-handled ZZZ.
|
||
|
|
0ab6993894 |
Convert mode analysis to use var_tables.
compiler/instmap.m:
compiler/mode_comparison.m:
compiler/mode_debug.m:
compiler/mode_info.m:
compiler/modecheck_call.m:
compiler/modecheck_coerce.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/unique_modes.m:
Convert these modules to use var_tables.
compiler/mode_errors.m:
Convert this module to use var_tables.
Fix an ancient error that I think has escaped detection until now
because it arises only in the presence of a mode error in a procedure
whose mode is being inferred. The bug is that when we modecheck a call,
say from p to q, and find no matching modes in the callee because
its mode inference has generated errors, then we report those errors
in the callee as part of the explanation of the error in the caller.
That is fine. What was not fine is that we printed any variables
in the callee's mode_error using the *caller's* varset. We now
print them using the callee's var table.
compiler/type_util.m:
Add a var_table-using variant of an existing predicate,
for use in new code above.
compiler/pd_util.m:
Conform to the changes above.
tests/invalid/mode_inf.m:
Modify this test case to make the caller and callee use disjoint
sets of variable names, which is probably why the incorrect variables
in the error message about the callee has not been noticed.
tests/invalid/mode_inf.err_exp:
Expect the updated, and now correct, version of that error message.
|
||
|
|
ea4f95a7ed |
Use var_tables in lco.m, and when dumping goals.
Since this is the first converted module that dumps out goals when
debugging trace flags are enabled, this required generalizing the code
that does that, to take either varsets or var_tables as a means of
specifying the names of variables. We do this via a new type,
var_name_source, which contains either a varset or a var_table.
Almost all of this diff is there to implement this generalization.
A large part of it affects code in the parse_tree package that we use
to write out the parts of HLDS goals that are defined by types defined
in that package. Since we want to avoid making any part of the parse_tree
package dependent on the hlds package, this required defining the
var_name_source type in the parse_tree package, which in turn requires
var_table.m to be in that same package.
compiler/lco.m:
Convert this module to use var_tables instead of varsets and vartypes.
compiler/var_table.m:
Move this module from the hlds package to the parse_tree package.
To make this, possible, move the parts that required access to the HLDS
to hlds_pred.m, from where it was usually invoked.
Export some utility predicates to allow the moved code to work
in hlds_pred.m without access to the actual definition of the
var_table type.
Define the var_name_source type.
Add some utility functions for use by code writing out variable names.
compiler/hlds_pred.m:
Add the code moved from var_table.m.
compiler/vartypes.m:
Move this module from the hlds package to the parse_tree package,
for symmetry with var_table.m. It did not depend on being in hlds
in any way.
compiler/hlds.m:
compiler/parse_tree.m:
Move vartypes.m and var_table.m from the hlds package
to the parse_tree package.
compiler/hlds_out_goal.m:
Change all the predicates in this module to take a var_name_source
instead of a prog_varset.
Fix some comments.
compiler/hlds_out_util.m:
Change some of the predicates in this module (those called from
hlds_out_goal.m) to take a var_name_source instead of a prog_varset.
compiler/parse_tree_out_term.m:
Provide variants of some existing predicates and functions that take
var_name_sources instead of varsets. The code of the copies
duplicates the logic of the originals, though I hope that this
duplication can be done away with at the end of the transition.
(The best solution would be to use a typeclass with methods
that convert vars to their names, but we would want to ensure
that the compiler can specialize all the affected predicates
and functions to the two instances of this typeclass, which is
something that we cannot do yet. In the meantime, the lack of
any generalization in the old versions preserves their performance.)
tools/sort_imports:
tools/filter_sort_imports:
A new tool that automatically sorts any occurrences of consecutive
":- import_module" declarations in the named files. The sorting is done
in filter_sort_imports; sort_imports loops over the named files.
After automatically replacing all occurrences of hlds.{vartypes,var_table}
in import_module declarations with their parse_tree versions, the updated
import_module declarations were usually out of order with respect to
their neighbours. I used this script to fix that, and some earlier
out-of-order imports.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_heap_ops.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_trail_ops.m:
compiler/analysis.m:
compiler/arg_info.m:
compiler/build_mode_constraints.m:
compiler/bytecode_gen.m:
compiler/call_gen.m:
compiler/check_promise.m:
compiler/closure_analysis.m:
compiler/closure_gen.m:
compiler/code_info.m:
compiler/code_loc_dep.m:
compiler/common.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/const_prop.m:
compiler/constraint.m:
compiler/continuation_info.m:
compiler/convert_parse_tree.m:
compiler/coverage_profiling.m:
compiler/cse_detection.m:
compiler/ctgc.datastruct.m:
compiler/ctgc.util.m:
compiler/dead_proc_elim.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/det_util.m:
compiler/direct_arg_in_out.m:
compiler/disj_gen.m:
compiler/distance_granularity.m:
compiler/equiv_type_hlds.m:
compiler/exception_analysis.m:
compiler/file_names.m:
compiler/float_regs.m:
compiler/follow_vars.m:
compiler/format_call.m:
compiler/generate_dep_d_files.m:
compiler/get_dependencies.m:
compiler/goal_expr_to_goal.m:
compiler/goal_mode.m:
compiler/goal_path.m:
compiler/goal_store.m:
compiler/goal_util.m:
compiler/granularity.m:
compiler/hhf.m:
compiler/higher_order.m:
compiler/hlds_clauses.m:
compiler/hlds_code_util.m:
compiler/hlds_error_util.m:
compiler/hlds_goal.m:
compiler/hlds_llds.m:
compiler/hlds_out_pred.m:
compiler/hlds_rtti.m:
compiler/hlds_statistics.m:
compiler/inlining.m:
compiler/inst_check.m:
compiler/inst_test.m:
compiler/inst_user.m:
compiler/instance_method_clauses.m:
compiler/instmap.m:
compiler/intermod.m:
compiler/intermod_analysis.m:
compiler/interval.m:
compiler/introduce_exists_casts.m:
compiler/introduce_parallelism.m:
compiler/item_util.m:
compiler/lambda.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_util.m:
compiler/lookup_switch.m:
compiler/loop_inv.m:
compiler/make.module_target.m:
compiler/make.util.m:
compiler/make_goal.m:
compiler/make_hlds_separate_items.m:
compiler/make_hlds_types.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/middle_rec.m:
compiler/ml_accurate_gc.m:
compiler/ml_args_util.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_commit_gen.m:
compiler/ml_disj_gen.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_gen_info.m:
compiler/ml_lookup_switch.m:
compiler/ml_proc_gen.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tag_switch.m:
compiler/ml_unify_gen.m:
compiler/ml_unify_gen_construct.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_test.m:
compiler/ml_unify_gen_util.m:
compiler/mlds_to_c_data.m:
compiler/mlds_to_c_func.m:
compiler/mlds_to_c_global.m:
compiler/mlds_to_cs_class.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_data.m:
compiler/mlds_to_java_file.m:
compiler/mlds_to_java_stmt.m:
compiler/mlds_to_java_type.m:
compiler/mmc_analysis.m:
compiler/mode_comparison.m:
compiler/mode_constraints.m:
compiler/mode_debug.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_ordering.m:
compiler/modecheck_call.m:
compiler/modecheck_coerce.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/module_cmds.m:
compiler/old_type_constraints.m:
compiler/opt_debug.m:
compiler/optimize.m:
compiler/options_file.m:
compiler/ordering_mode_constraints.m:
compiler/par_loop_control.m:
compiler/parse_item.m:
compiler/parse_string_format.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_to_term.m:
compiler/parse_util.m:
compiler/pd_debug.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/peephole.m:
compiler/polymorphism.m:
compiler/polymorphism_info.m:
compiler/polymorphism_lambda.m:
compiler/polymorphism_type_class_info.m:
compiler/polymorphism_type_info.m:
compiler/post_typecheck.m:
compiler/pragma_c_gen.m:
compiler/pred_name.m:
compiler/pred_table.m:
compiler/prog_item.m:
compiler/prog_rep.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/push_goals_together.m:
compiler/qual_info.m:
compiler/quantification.m:
compiler/rbmm.execution_path.m:
compiler/rbmm.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.points_to_graph.m:
compiler/rbmm.points_to_info.m:
compiler/rbmm.region_resurrection_renaming.m:
compiler/rbmm.region_transformation.m:
compiler/recompilation.used_file.m:
compiler/recompilation.version.m:
compiler/recompute_instmap_deltas.m:
compiler/resolve_unify_functor.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/set_of_var.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_conj.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_goal_scope.m:
compiler/simplify_goal_switch.m:
compiler/simplify_goal_unify.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/size_prof.m:
compiler/smm_common.m:
compiler/ssdebug.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/stm_expand.m:
compiler/store_alloc.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/superhomogeneous.m:
compiler/switch_detection.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_constr_data.m:
compiler/term_constr_initial.m:
compiler/term_constr_main.m:
compiler/term_constr_main_types.m:
compiler/term_constr_util.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/term_util.m:
compiler/trace_gen.m:
compiler/trailing_analysis.m:
compiler/transform_llds.m:
compiler/try_expand.m:
compiler/tupling.m:
compiler/type_assign.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/typecheck_debug.m:
compiler/typecheck_errors.m:
compiler/typecheck_info.m:
compiler/unify_gen_construct.m:
compiler/unify_gen_deconstruct.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unneeded_code.m:
compiler/untupling.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/var_locn.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
|
||
|
|
3f3045c9e2 |
Get and set varsets/vartypes in proc_infos together.
compiler/hlds_pred.m:
We eventually want to replace the varset and vartypes fields in
each proc_info with a var_table, but it is not practical to do so
at once; it will have to be done gradually, a few modules at most
at a time. During this process, we will need a way either
- to let already converted modules get a var_table out of the proc_info,
and put an updated var_table back into a proc_info, even though
proc_infos still contain varset and vartypes fields, or
- to let not-yet-converted modules get varsets and vartypes out of the
proc_info, and put updated varsets and vartypes back into a proc_info,
even though proc_infos already store a var_table.
The latter cannot be done in two halves (i.e. set the varset half
of the var_table, and then set its vartypes half), and while the former
*can* be done that way, it is more efficient to do them at the same time.
Therefore as a first step, this diff replaces the indiviual getter
and setter predicates of the varset and vartypes fields of proc_info
with a getter that gets both and a setter that sets both.
Put the varset and vartypes next to each other in a structure.
compiler/code_info.m:
Delete a function that duplicates a function in var_table.m.
Conform to the change above.
compiler/det_report.m:
Factor out some common code.
Conform to the change above.
compiler/det_util.m:
Delete a no-longer-needed predicate.
Conform to the change above.
compiler/higher_order.m:
Fix an old oversight: when deleting variables from the vartypes,
delete them from the varset as well.
Conform to the change above.
compiler/liveness.m:
Avoid constructing and traversing a list unnecessarily.
Conform to the change above.
compiler/accumulator.m:
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/arg_info.m:
compiler/build_mode_constraints.m:
compiler/bytecode_gen.m:
compiler/call_gen.m:
compiler/clause_to_proc.m:
compiler/closure_analysis.m:
compiler/code_gen.m:
compiler/code_loc_dep.m:
compiler/complexity.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/ctgc.datastruct.m:
compiler/ctgc.util.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/direct_arg_in_out.m:
compiler/disj_gen.m:
compiler/equiv_type_hlds.m:
compiler/exception_analysis.m:
compiler/float_regs.m:
compiler/follow_code.m:
compiler/goal_mode.m:
compiler/goal_path.m:
compiler/hlds_out_pred.m:
compiler/hlds_rtti.m:
compiler/hlds_statistics.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/intermod_analysis.m:
compiler/introduce_exists_casts.m:
compiler/introduce_parallelism.m:
compiler/lambda.m:
compiler/lco.m:
compiler/live_vars.m:
compiler/loop_inv.m:
compiler/mark_tail_calls.m:
compiler/ml_accurate_gc.m:
compiler/ml_args_util.m:
compiler/ml_closure_gen.m:
compiler/ml_gen_info.m:
compiler/ml_proc_gen.m:
compiler/mode_info.m:
compiler/modecheck_goal.m:
compiler/modes.m:
compiler/par_loop_control.m:
compiler/pd_debug.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/polymorphism_info.m:
compiler/proc_gen.m:
compiler/purity.m:
compiler/push_goals_together.m:
compiler/quantification.m:
compiler/rbmm.add_rbmm_goal_infos.m:
compiler/rbmm.live_variable_analysis.m:
compiler/rbmm.points_to_graph.m:
compiler/rbmm.points_to_info.m:
compiler/rbmm.region_liveness_info.m:
compiler/rbmm.region_transformation.m:
compiler/recompute_instmap_deltas.m:
compiler/saved_vars.m:
compiler/simplify_goal_unify.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/size_prof.m:
compiler/ssdebug.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/stm_expand.m:
compiler/store_alloc.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/switch_detection.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_constr_initial.m:
compiler/term_errors.m:
compiler/term_pass1.m:
compiler/term_pass2.m:
compiler/trace_gen.m:
compiler/trailing_analysis.m:
compiler/try_expand.m:
compiler/tupling.m:
compiler/unneeded_code.m:
compiler/untupling.m:
compiler/unused_args.m:
compiler/unused_imports.m:
Conform to the change above.
|
||
|
|
5cada10369 |
Rename pred_table to pred_id_table.
compiler/pred_table.m:
As above. This addresses half of an old XXX, which is that the two types
defined in this module, predicate_table and pred_table (as it was then)
should have names that (a) say what they do, and (b) are distinct.
Addressing the other half requires a more descriptive but not-too-long
name to replace "predicate_table".
Rename the predicates that operate on the type to follow the name change.
Add a distinguishing prefix to the names of the fields of the
predicate_table type.
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_special_pred.m:
compiler/arg_info.m:
compiler/bytecode_gen.m:
compiler/clause_to_proc.m:
compiler/closure_gen.m:
compiler/cse_detection.m:
compiler/dead_proc_elim.m:
compiler/deep_profiling.m:
compiler/default_func_mode.m:
compiler/det_analysis.m:
compiler/det_util.m:
compiler/direct_arg_in_out.m:
compiler/distance_granularity.m:
compiler/export.m:
compiler/float_regs.m:
compiler/goal_mode.m:
compiler/granularity.m:
compiler/hlds_defns.m:
compiler/hlds_error_util.m:
compiler/hlds_module.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_module.m:
compiler/hlds_out_util.m:
compiler/hlds_pred.m:
compiler/hlds_statistics.m:
compiler/implementation_defined_literals.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/introduce_exists_casts.m:
compiler/introduce_parallelism.m:
compiler/lambda.m:
compiler/lco.m:
compiler/make_hlds_passes.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_llds_back_end.m:
compiler/ml_proc_gen.m:
compiler/mode_info.m:
compiler/modecheck_call.m:
compiler/modes.m:
compiler/oisu_check.m:
compiler/old_type_constraints.m:
compiler/passes_aux.m:
compiler/polymorphism.m:
compiler/polymorphism_post_copy.m:
compiler/post_typecheck.m:
compiler/pre_typecheck.m:
compiler/proc_gen.m:
compiler/proc_requests.m:
compiler/simplify_proc.m:
compiler/stm_expand.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.m:
compiler/structure_sharing.analysis.m:
compiler/switch_detection.m:
compiler/table_gen.m:
compiler/term_constr_build.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_util.m:
compiler/termination.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
compiler/typecheck_info.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to the change in pred_table.m.
Refer to values of the renamed type using a consistent naming scheme.
When the affected code repeats the body of existing helper predicates
for lookup up a pred_info or proc_info, or updating a proc_info
inside a pred_info, or updating a pred_info inside a module_info,
call the helper predicate instead. This makes code shorter and less
cluttered, and the use of the helper predicates for updates automatically
ensures that we don't accidentally update a stale version of the relevant
table. (This has sometimes been a problem in the past.)
In a few places, carve a new predicate for processing one element
of a list out of an existing predicate for processing all list elements.
|
||
|
|
243491523d |
Stop counting errors in module_infos.
Over time, we have almost completely switched over to using error_specs,
using their severity (if not yet printed out) and their effect on the
exit status (if already printed out) to represent the presence of errors,
leaving only a few places that either updated or paid attention to the
num_error field in the module_info. This diff completes that process.
compiler/hlds_module.m:
Delete the num_errors field in the module_info, and the predicates
that operate on it.
compiler/hlds_error_util.m:
Delete module_info arguments whose only purpose was to update the
now-delete field.
compiler/error_util.m:
Delete the old write_error_spec predicates that updated a count of warnings
and a count of errors.
Rename the write_error_spec_ignore predicates, which ignored those counts,
by deleting the "_ignore" from their names. This makes them take the
place of the deleted predicates.
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/compile_target_code.m:
compiler/cse_detection.m:
compiler/find_module.m:
compiler/generate_dep_d_files.m:
compiler/handle_options.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mode_info.m:
compiler/modes.m:
compiler/pd_util.m:
compiler/pred_table.m:
compiler/recompilation.check.m:
compiler/typecheck.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
|
||
|
|
715121485c | Don't import unneeded modules in the interface. | ||
|
|
85eb971b8d |
Specify output streams in some places.
Besides this main purpose, this diff also replaces code that calls
io.write_string several times in a row with code that prints the
thing to be printed in one go with io.format.
compiler/accumulator.m:
compiler/code_gen.m:
compiler/dead_proc_elim.m:
compiler/interval.m:
compiler/ite_gen.m:
compiler/lco.m:
compiler/mode_debug.m:
compiler/mode_info.m:
compiler/modes.m:
compiler/stack_opt.m:
As above.
compiler/Mercury.options:
Specify --warn-implicit-stream-calls for the modules above,
and for some other modules that are already free of such warnings.
|
||
|
|
bd594dded2 |
Impose logical order on mode_info.m and mode_util.m.
compiler/mode_info.m:
compiler/mode_util.m:
Put the predicates in these modules into logical groups, and ensure
that the orders of the declarations and definitions match.
Delete the unused predicate mode_info_set_how_to_check from mode_info.m.
Delete the unused predicates select_output_vars, select_output_things,
and partition_args from mode_util.m.
Rename the unify_modes_to_X predicates to unify_mode_to_X, since each
of these predicates operates on only *one* unify_mode.
Move three predicates that are needed only during mode checking,
and not during later compuiler passes, to modecheck_util.m.
compiler/modecheck_util.m:
Add the predicates moved from mode_util.m.
compiler/Mercury.options:
Require the order of predicates' definitions to match the order of
their declarations in mode_info.m and mode_util.m.
compiler/common.m:
compiler/loop_inv.m:
compiler/modecheck_goal.m:
Conform to the changes in mode_util.m.
|
||
|
|
d2b3fef5cc |
Visually mark debug output from unique_modes.m.
compiler/mode_info.m:
Add a new field to the debug flags we set up when --debug-modes is enabled.
This field specifies whether the debug output is from mode checking,
or from *unique* mode checking. Without this, the two are far too easy
to confuse, as I found out the hard way.
compiler/mode_debug.m:
Use the new field to add visually distinguish mode checkpoints from
the two passes. For example. where mode checking would output
"Enter unify", unique mode checking will output "Enter unique unify".
compiler/unique_modes.m:
Delete a marker on mode checkpoints for conjunctions that also baffled me.
|
||
|
|
6f8154d242 |
Put mode_errors.m's contents into logical order.
compiler/mode_errors.m:
As above.
Delete predicates that (a) do not belong here, but (b) do belong
in some other module.
compiler/mode_info.m:
Move mode_context_init here from mode_errors.m, since the mode_context
type is defined here.
compiler/modes.m:
Move two predicates, maybe_report_error_no_modes and
+report_mode_inference_messages_for_preds here from mode_errors.m,
since their only callers are here.
compiler/post_typecheck.m:
Move +report_indistinguishable_modes_error here from mode_errors.m,
since its only caller is here.
|
||
|
|
c3f39870a1 |
Clean up the representation of mode errors.
compiler/mode_errors.m:
Give the function symbols representing the various kinds of mode errors
more meaningful names. (Some fix misleading implications, such as when
a function symbol name includes "pred", but the error applies to functions
as well.) Do the same for other function symbols in this module.
Where arguments are lists that should never be empty, change their type
to one_or_more to encode this invariant.
In one case (var_multimode_pred_error), the same data items were packaged
in two different ways in two different places. Remove this unnecessary
difference.
In some cases, put arguments in a more logical order.
Improve the comments on most of these function symbols, fixing errors,
fixing omissions, documenting arguments. Add XXXs where warranted.
Put the types used in the various kinds of mode errors below the
mode_error type itself. Put them into meaningful groups.
The current order of the mode_error function symbols is totally
haphazard. Propose a new order for them, but do not implement it yet,
in order to make this diff easier to review.
Make the representation of the error that says "calling an implied mode
for this predicate or function is not implemented" say *why* it is
not implemented. Include this info in the error message we generate.
This error message is not exercised by any existing test case, which is
why there are no changes to test cases in this diff.
Improve the explanation for why you cannot unify two functions or
two predicates. Since this explanation occurs only in verbose output,
no test case is affected by this change either.
Improve variable names.
compiler/mode_info.m:
Conform to the changes in mode_errors.m.
If --debug-modes is specified, print each error message as it is added
to the mode_info. This helped me track down a bug in this change.
compiler/instmap.m:
compiler/modecheck_call.m:
compiler/modecheck_conj.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
Conform to the changes in mode_errors.m and/or mode_info.m.
Add XXXs in some places. One marks one possible cause of Mantis bug #529.
|
||
|
|
3a1ed2efcb |
Replace simple_call_id with pf_sym_name_arity.
compiler/prog_data.m:
Delete the simple_call_id data type, since it is isomorphic
to the pf_sym_name_arity type, which more clearly specifies
what is stored inside it.
compiler/prog_out.m:
Rename (all three versions of) simple_call_id_to_string to
pf_sym_name_orig_arity_to_string, both to conform to the change
in the input data type, and to emphasize that the resulting string
will contain the *original* arity of functions (which does not include
the return value), which is one less than the arity in the
pf_sym_name_arity structure (which, in accordance with the
convention inside the compiler that the arity is the length
of the argument list, *does* include the return value).
Delete the provision inside simple_call_id_to_string, now
pf_sym_name_orig_arity_to_string, for special handling of the names
of the predicates we use to implement promises, because it seems that
*none* of the call sites to any of the three versions of this function
can actually pass to it the identity of such a predicate. These calls
refer to a predicate or mode declaration item (which promise predicates
do not have), to clause or foreign_proc items (which again, promise
predicates cannot have) or calls to the predicate (promise predicates
cannot be called).
Delete the exported predicate simple_call_id_to_sym_name_arity.
It was called from exactly one place, inside prog_out.m itself,
and this diff inlines that call.
Avoid unnecessary forwarding of work from prog_out.m to error_util.m.
Delete (all three versions of) write_simple_call_id. The changes
below replace all their (few) uses with calls to
pf_sym_name_orig_arity_to_string.
compiler/error_util.m:
Replace the simple_call() error piece with qual_pf_sym_name_orig_arity,
and add a new version unqual_pf_sym_name_orig_arity. Their names
explicitly say that they print the original arities of functions,
also say whether they strip away any module qualification on the
sym_name inside the pf_sym_name_arity. We prefer the unqual version
in situations where the module qualifier is implicit, which usually means
that it must be the same as the name of the module being compiled, because
it reduces visual clutter for readers of error messages.
Put {qual,unqual}_pf_sym_name_orig_arity next to their most closely
related function symbols, {qual,unqual}_sym_name_arity, in the
format_component type. (This yields a few inconsequential changes
in the order of error_specs when sorted.)
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/check_libgrades.m:
compiler/check_parse_tree_type_defns.m:
compiler/check_promise.m:
compiler/check_typeclass.m:
compiler/convert_parse_tree.m:
compiler/equiv_type.m:
compiler/goal_expr_to_goal.m:
compiler/hlds_data.m:
compiler/hlds_desc.m:
compiler/hlds_goal.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/hlds_pred.m:
compiler/inst_util.m:
compiler/llds_out_instr.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make_hlds_error.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/ml_unify_gen_construct.m:
compiler/mlds_to_c_stmt.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/modecheck_util.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qualify_items.m:
compiler/parse_item.m:
compiler/parse_module.m:
compiler/parse_type_repn.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/pre_quantification.m:
compiler/pred_table.m:
compiler/prog_item.m:
compiler/recompilation.version.m:
compiler/term_constr_build.m:
compiler/termination.m:
compiler/type_ctor_info.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
compiler/typecheck_info.m:
compiler/unify_gen_construct.m:
compiler/unused_imports.m:
Conform to the changes above. Where I am pretty sure that in an error
message, the module qualifier of a name must be the current module,
use unqual_pf_sym_name_orig_arity instead of qual_pf_sym_name_orig_arity.
Add some sanity checks where they seem appropriate.
Replace sequences of io.write_strings with uses of io.format where this
yields clearer code. (This is why there were no remaining calls to
write_simple_call_id.)
Shorten some too-long lines.
In add_pred.m, make the order of some predicate definitions match
the order of the calls to them.
tests/invalid/ambiguous_method.err_exp:
tests/invalid/ambiguous_method_2.err_exp:
tests/invalid/bad_pred_arity.err_exp:
tests/invalid/bad_sv_unify_msg.err_exp:
tests/invalid/bigtest.err_exp:
tests/invalid/bug113.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/bug278.err_exp:
tests/invalid/bug410.err_exp:
tests/invalid/bug476.err_exp:
tests/invalid/bug487.err_exp:
tests/invalid/complex_constraint_err.err_exp:
tests/invalid/constrained_poly_insts.err_exp:
tests/invalid/errors.err_exp:
tests/invalid/errors1.err_exp:
tests/invalid/errors2.err_exp:
tests/invalid/exported_mode.err_exp:
tests/invalid/field_syntax_error.err_exp:
tests/invalid/foreign_singleton.err_exp:
tests/invalid/funcs_as_preds.err_exp:
tests/invalid/imported_mode.err_exp:
tests/invalid/invalid_binary_literal.err_exp:
tests/invalid/invalid_float_literal.err_exp:
tests/invalid/invalid_hex_literal.err_exp:
tests/invalid/invalid_octal_literal.err_exp:
tests/invalid/make_opt_error.err_exp:
tests/invalid/missing_det_decls.err_exp:
tests/invalid/multimode_syntax.err_exp:
tests/invalid/null_char.err_exp:
tests/invalid/occurs.err_exp:
tests/invalid/record_syntax_errors.err_exp:
tests/invalid/ref_to_implicit_pred.err_exp:
tests/invalid/require_tailrec_1.err_exp:
tests/invalid/require_tailrec_1.err_exp2:
tests/invalid/require_tailrec_2.err_exp:
tests/invalid/require_tailrec_2.err_exp2:
tests/invalid/require_tailrec_3.err_exp:
tests/invalid/require_tailrec_3.err_exp2:
tests/invalid/state_vars_test2.err_exp:
tests/invalid/state_vars_test3.err_exp:
tests/invalid/state_vars_test5.err_exp:
tests/invalid/type_inf_loop.err_exp:
tests/invalid/typeclass_constraint_extra_var.err_exp:
tests/invalid/typeclass_mode_2.err_exp:
tests/invalid/typeclass_test_12.err_exp:
tests/invalid/typeclass_test_2.err_exp:
tests/invalid/typeclass_test_9.err_exp:
tests/invalid/types.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/unbound_type_vars.err_exp:
tests/invalid/with_type.err_exp:
tests/invalid_purity/purity_nonsense.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
tests/warnings/double_underscore.exp:
tests/warnings/pragma_source_file.exp:
tests/warnings/singleton_test.exp:
tests/warnings/singleton_test.exp2:
tests/warnings/singleton_test.exp3:
tests/warnings/singleton_test.exp4:
tests/warnings/singleton_test_state_var.exp:
tests/warnings/warn_return.exp:
tests/warnings/warn_return.exp2:
tests/warnings/warn_return.exp3:
tests/warnings/warn_succ_ind.exp:
tests/warnings/warn_succ_ind.exp2:
tests/warnings/warn_succ_ind.exp3:
tests/warnings/warn_succ_ind.exp4:
Update all these expected output files. Most changes are due to
predicate and function names no longer being module qualified when
the module qualification is obvious. A few changes are due to the
change in the relative ordering of the function symbols of the
format_component type.
For singleton_test, warn_return and warn_succ_ind in warnings,
the changes to the non-C .exp files were done by hand, so they
may have the wrong white space.
|
||
|
|
5722645ce5 |
Separate out type_info args and return values in mode error msgs.
compiler/mode_errors.m:
When printing an error message that says "these args have these modes,
which do not match any declared mode of the callee", avoid confusing
users by not mentioning the extra type_info/typeclass_info args added by
polymorphism, except in the very rare case that they could be the *cause*
of the mode error.
When the callee is a function, list its return value separately from
the other arguments, again in an effort to reduce possible confusion.
compiler/mode_info.m:
To make the above possible, record the actual pred_id of the callee
for plain calls. This should actually be faster than the old code
it replaces, because it avoids the computation of the call_id from
the pred_id for all calls that do not result in error messages.
Fix a misleading predicate name.
compiler/modecheck_goal.m:
compiler/modecheck_util.m:
compiler/unique_modes.m:
Conform to the changes in mode_info.m.
compiler/hlds_pred.m:
Fix a misleading predicate name.
compiler/polymorphism.m:
compiler/pred_table.m:
Conform to the changes in hlds_pred.m.
compiler/add_pred.m:
compiler/add_special_pred.m:
compiler/higher_order.m:
Use variable names that specify which kind of arity they talk about:
the one that counts functions' return values, or the one that doesn't.
tests/invalid/any_passed_as_ground.err_exp:
tests/invalid/ho_default_func_1.err_exp:
tests/invalid/ho_default_func_3.err_exp:
tests/invalid/ho_default_func_4.err_exp:
tests/invalid/ho_type_mode_bug.err_exp:
tests/invalid/state_vars_test1.err_exp:
tests/invalid/try_detism.err_exp:
Update these expected output files to account for the change to
mode_errors.m above.
tests/invalid/any_passed_as_ground.err_exp2:
The old any_passed_as_ground.err_exp could not be matched for a long time
now. The new any_passed_as_ground.err_exp actually updates the old
any_passed_as_ground.err_exp2, since we can't have a .err_exp2 file
without a .err_exp file. Since we now need only one expected output file,
delete the .err_exp2 file.
tests/invalid/ho_default_func_1.err_exp2:
tests/invalid/ho_default_func_3.err_exp2:
Delete these files, since they could not be matched for a long time now.
tests/invalid/try_detism.err_exp2:
The same deal as with the any_passed_as_ground test case.
|
||
|
|
15aa457e12 | Delete $module arg from calls to unexpected. | ||
|
|
414b948fb8 |
Reorder arguments to improve packing.
compiler/globals.m:
compiler/mode_info.m:
As above: put all the sub-word-sized fields in a term next to each other
to allow the compiler to pack them all into a single word.
|
||
|
|
28e9a29fc2 |
Carve hlds_inst_mode.m out of hlds_data.m.
compiler/hlds_class.m:
New module containing the parts of hlds_data.m that deal with
insts and modes.
compiler/hlds_data.m:
Delete the moved code.
compiler/hlds.m:
Include the new module.
compiler/notes/compiler_design.html:
Document the new module.
compiler/*.m:
Conform to the changes above.
|
||
|
|
72fdbec2fd |
Improve diagnostics for currying multi-mode predicates.
The improvements take two forms.
The first is that when the mode checker tries to schedule a unification
of the form X = curried_pred(A1, ... An), but fails, perhaps because
curried_pred has more than one declared mode matching the current insts
of the Ai, we record this fact in the mode_info. Then, if later we find
that X is insufficiently instantiated, we print the message we originally
generated for the X = curried_pred(A1, ... An) unification (but which we
threw away when the scheduling attempt failed) as a possible explanation
of this insufficient instantiation.
The second is that when scheduling X = curried_pred(A1, ... An) but fails,
we record more information about the reason, to print it later in the hope that
it may help the user diagnose the problem.
compiler/mode_errors.m:
Change the representation of the errors resulting for not being able
to schedule rhs_lambda unifications of the form X = curried_pred(Ai).
Merge the previous two separate errors into one, and add a parameter
that that distinguishes the three (not two) possible different causes
of the error. Print better diagnostics for all three, based on a common
template.
Change the representation of the errors that say a variable is not
sufficiently instantiated, to make it possible (but of course not
compulsory) to record what error of the X = curried_pred(Ai) kind
may be responsible for it. Include the error message for this cause
in the error message about the insufficiently instantiated variable.
compiler/mode_info.m:
Add a field to the mode_info that allows a failed attempt to schedule
X = curried_pred(Ai) to record the error it generates as a possible
cause of the later insufficient instantiation of X.
compiler/modecheck_unify.m:
Gather the extra information now needed by the representation of mode
errors for failed attempts to schedule X = curried_pred(Ai).
Record the errors for such attempts in the new mode_info field.
compiler/modecheck_util.m:
When generating "variable is not sufficiently instantiated" errors,
see if the new mode_info field say that the insufficiently instantiated
variable was, in a previous conjunct, involved in a failed
X = curried_pred(Ai) unification, and if yes, record this fact
as a possible cause of the error.
compiler/modecheck_goal.m:
Reset the new field at the start of every branched control structure,
to prevent us from using information about X = curried_pred(Ai)
unifications in one branch in other, parallel branches.
Avoid allocating a context at every goal.
library/term.m:
Add a utility predicate to enable that avoidance.
NEWS:
Mention the new utility predicate.
Fix some no-longer-valid entries.
compiler/modecheck_call.m:
Make some code need less stack space.
Fix some comments.
compiler/modecheck_conj.m:
Clarify some code.
tests/invalid/uint_bitwise_xor_mode.{m,err_exp}:
A new test case for both improvements. It is a version of
tests/hard_coded/uint_bitwise.m cut down to contain just the bug
that previously we generate only a misleading error message for.
tests/invalid/Mmakefile:
Enable the new test.
tests/invalid/multimode_addr_problems.err_exp:
Update this expected output to account for the second improvement.
|
||
|
|
748ac6b62f |
Remove references to power-of-2 allocations by Boehm.
compiler/hlds_goal.m:
compiler/hlds_pred.m:
compiler/simplify_info.m:
As above.
compiler/mode_info.m:
As above, and put two types in the right order.
compiler/typecheck_info.m:
Put two types in the right order.
|
||
|
|
73ef502981 | Delete unneeded imports. | ||
|
|
c6ab550db8 |
Remove the code for automatic initialization of solver vars.
We haven't supported it in years, and keeping it in the compiler
is just a maintenance burden and a performance problem.
mdbcomp/prim_data.m:
Delete the spec_pred_init functor, since we don't support special
"init" predicates anymore.
compiler/prog_data.m:
Delete the slot in solver type details that record the name of the
auto-initialization predicate.
compiler/prog_io_type_defn.m:
Don't allow a type definition to specify an auto-initialization predicate.
compiler/options.m:
compiler/globals.m:
Delete the option that allowed support for auto-initialization to be
turned back on.
compiler/inst_match.m:
compiler/inst_util.m:
Delete comments about auto-initialization.
compiler/mode_info.m:
Delete the record of whether we have variables that can be
auto-initialized (we never do anymore) and the flag that controls whether
auto-initialization is permitted or not.
compiler/modecheck_conj.m:
Simplify the code that modechecks conjunctions, since it no longer
has to figure out where to insert auto-initializations of solver vars.
compiler/modecheck_goal.m:
Delete the code that ensured that if one branch of a branched
control structure auto-initialized a solver variable, then they
all did.
compiler/modecheck_unify.m:
Don't auto-initializate variables before unifications.
compiler/modecheck_util.m:
Delete the code that auto-initialized solver variables at the ends
of procedure bodies if this needed to be done and wasn't done before.
compiler/add_special_pred.m:
compiler/equiv_type.m:
compiler/equiv_type_hlds.m:
compiler/get_dependencies.m:
compiler/hlds_module.m:
compiler/hlds_pred.m:
compiler/modecheck_call.m:
compiler/modes.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out.m:
compiler/post_term_analysis.m:
compiler/smm_common.m:
compiler/special_pred.m:
compiler/term_constr_errors.m:
compiler/term_constr_initial.m:
compiler/term_util.m:
compiler/termination.m:
compiler/trace_params.m:
compiler/type_util.m:
compiler/unify_proc.m:
Delete code that handled stuff related to auto-initialization,
and now always take the path that would normally be taken in the
absence of auto-initialization.
deep_profiler/read_profile.m:
runtime/mercury_layout_util.c:
runtime/mercury_stack_trace.c:
util/mdemangle.c:
Remove code that recognized the compiler-generated name of initialization
predicates.
tests/debugger/solver_test.m:
tests/hard_coded/solver_construction_init_test.m:
tests/hard_coded/solver_disj_inits.m:
tests/hard_coded/solver_ite_inits.m:
tests/invalid/missing_init_pred.m:
tests/invalid/zinc2mer_lib.m:
tests/valid/fz_conf.m:
tests/valid/solver_type_bug_2.m:
tests/valid/solver_type_mutable_bug.m:
These tests tested the handling of auto-initialization, which we
no longer support. Keep them around (and a bit more visible than
inside the git repo) in case we need them again, but add a comment
to each saying that the test is disabled.
tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/Mmakefile:
Disable those tests.
tests/warnings/non_term_user_special.{m,exp}:
Part of this test tested the handling of auto-initialization;
delete that part.
tests/warnings/Mercury.options:
Delete the flag required by the deleted part, since we don't support it
anymore.
|
||
|
|
94535ec121 |
Fix spelling and formatting throughout the system.
configure.ac: browser/*.m: compiler/*.m: deep_profiler/*.m: library/*.m: ssdb/*.m: runtime/mercury_conf.h.in: runtime/*.[ch]: scripts/Mmake.vars.in: trace/*.[ch]: util/*.c: Fix spelling and doubled-up words. Delete trailing whitespace. Convert tabs into spaces (where appropriate). |
||
|
|
2639091f7f |
Fix a performance problem in mode analysis.
When working on the diff to make_hlds_passes.m, the compiler took effectively
forever on an intermediate version; I killed it after about half an hour
of CPU time. Invoking a debug version of the compiler on that version
of make_hlds_passes.m and interrupting it several times while it was
twiddling its thumbs showed that it was spending its time in computing
a set of candidate vars for auto-initialization. Since the predicate
it was analyzing at the time, do_parse_tree_to_hlds, is quite big and has
lots of variables, the sets of candidate variables could be quite big,
and may have to be computed lots of times. However, all those computations
are wasted, since once the set of candidate vars is computed, mode analysis
checks if the variables in those sets have a solver type that has auto
initialization. In most predicates including this one, NO variable has
such a type, so this test will fail.
compiler/modecheck_conj.m:
Test whether ANY variable in the procedure being analyzed has a solver
type with auto initialization. If not, don't bother to compute the
candidate vars.
compiler/mode_info.m:
When initializing the mode_info before starting to analyze a procedure,
record whether any its variables has a solver type with auto
initialization.
There is no test case for this performance bug. First, I don't understand
the algorithm that computes the candidate vars set well enough to hand craft
a small test that nevertheless tickles this worst-case behavior. Second,
trying to minimize the actual problem code would probably yield something
that is still way bigger than one of our usual test cases. And third,
if the test case fails, it would do so by using huge amounts of CPU time
*without* running out of stack, which is a pretty bad failure mode,
and I have no idea how to impose a CPU time limit on a test case
that would also work on Windows. (The code in question is nondet, and
every backtrack to a choice point frees the det stack used up till then.)
However, a hand test on the actual problem code (which is a snapshot
of the offending version of the entire compiler directory) does show
that this diff fixes the problem.
|
||
|
|
c5b64d36ea | Convert (C->T;E) to (if C then T else E). | ||
|
|
62ec97d443 |
Report imports shadowed by other imports.
If a module has two or more import_module or use_module declarations
for the same module, (typically, but not always, one being in its interface
and one in its implementation), generate an informational message about
each redundant declaration if --warn-unused-imports is enabled.
compiler/hlds_module.m:
We used to record the set of imported/used modules, and the set of
modules imported/used in the interface of the current module. However,
these sets
- did not record the distinction between imports and uses;
- did not allow distinction between single and multiple imports/uses;
- did not record the locations of the imports/uses.
The first distinction was needed only by module_qual.m, which *did*
pay attention to it; the other two were not needed at all.
To generate messages for imports/uses shadowing other imports/uses,
we need all three, so change the data structure storing such information
for *direct* imports to one that records all three of the above kinds
of information. (For imports made by read-in interface and optimization
files, the old set of modules approach is fine, and this diff leaves
the set of thus *indirectly* imported module names alone.)
compiler/unused_imports.m:
Use the extra information now available to generate a
severity_informational message about any import or use that is made
redundant by an earlier, more general import or use.
Fix two bugs in the code that generated warnings for just plain unused
modules.
(1) It did not consider that a use of the builtin type char justified
an import of char.m, but without that import, the type is not visible.
(2) It scanned cons_ids in goals in procedure bodies, but did not scan
cons_ids that have been put into the const_struct_db. (I did not update
the code here when I added the const_struct_db.)
Also, add a (hopefully temporary) workaround for a bug in
make_hlds_passes.m, which is noted below.
However, there are at least three problems that prevent us from enabling
--warn-unused-imports by default.
(1) In some places, the import of a module is used only by clauses for
a predicate that also has foreign procs. When compiled in a grade that
selects one of those foreign_procs as the implementation of the predicate,
the clauses are discarded *without* being added to the HLDS at all.
This leads unused_imports.m to generate an uncalled-for warning in such
cases. To fix this, we would need to preserve the Mercury clauses for
*all* predicates, even those with foreign procs, and do all the semantic
checks on them before throwing them away. (I tried to do this once, and
failed, but the task should be easier after the item list change.)
(2) We have two pieces of code to generate import warnings. The one in
unused_imports.m operates on the HLDS after type and mode checking,
while module_qual.m operates on the parse tree before the creation of
the HLDS. The former is more powerful, since it knows e.g. what types and
modes are used in the bodies of predicates, and hence can generate warnings
about an import being unused *anywhere* in a module, as opposed to just
unused in its interface.
If --warn-unused-imports is enabled, we will get two separate set of
reports about an interface import being unused in the interface,
*unless* we get a type or mode error, in which case unused_imports.m
won't be invoked. But in case we do get such errors, we don't want to
throw away the warnings from module_qual.m. We could store them and
throw them away only after we know we won't need them, or just get
the two modules to generate identical error_specs for each warning,
so that the sort_and_remove_dups of the error specs will do the
throwing away for us for free, if we get that far.
(3) The valid/bug100.m test case was added as a regression test for a bug
that was fixed in module_qual.m. However the bug is still present in
unused_imports.m.
compiler/make_hlds_passes.m:
Give hlds_module.m the extra information it now needs for each item_avail.
Add an XXX for a bug that cannot be fixed right now: the setting of
the status of abstract instances to abstract_imported. (The "abstract"
part is correct; the "imported" part may not be.)
compiler/intermod.m:
compiler/try_expand.m:
compiler/xml_documentation.m:
Conform to the change in hlds_module.m.
compiler/module_qual.m:
Update the documentation of the relationship of this module
with unused_imports.m.
compiler/hlds_data.m:
Document a problem with the status of instance definitions.
compiler/hlds_out_module.m:
Update the code that prints out the module_info to conform to the change
to hlds_module.m.
Print status information about instances, which was needed to diagnose
one of the bugs in unused_imports.m. Format the output for instances
nicer.
compiler/prog_item.m:
Add a convenience predicate.
compiler/prog_data.m:
Remove a type synonym that makes things harder to understand, not easier.
compiler/modules.m:
Delete an XXX that asks for the feature this diff implements.
Add another XXX about how that feature could be improved.
compiler/Mercury.options.m:
Add some more modules to the list of modules on which the compiler
should be invoked with --no-warn-unused-imports.
compiler/*.m:
library/*.m:
mdbcomp/*.m:
browser/*.m:
deep_profiler/*.m:
mfilterjavac/*.m:
Delete unneeded imports. Many of these shadow other imports, and some
are just plain unneeded, as shown by --warn-unused-imports. In a few
modules, there were a *lot* of unneeded imports, but most had just
one or two.
In a few cases, removing an import from a module, because it *itself*
does not need it, required adding that same import to those of its
submodules which *do* need it.
In a few cases, conform to other changes above.
tests/invalid/Mercury.options:
Test the generation of messages about import shadowing on the existing
import_in_parent.m test case (although it was also tested very thoroughly
when giving me the information needed for the deletion of all the
unneeded imports above).
tests/*/*.{m,*exp}:
Delete unneeded imports, and update any expected error messages
to expect the now-smaller line numbers.
|
||
|
|
04dec8c205 |
Carve vartypes.m, prog_detism.m and prog_rename.m out of prog_data.m.
Besides defining most of the types representing the smaller parts of
parse trees (parts smaller than items), prog_data.m also has many utility
predicates that operate on values of these types. Carve the three substantial
clusters of predicates out of prog_data.m, and move them into their own
modules, which are each imported by fewer modules than prog_data.m itself.
compiler/vartypes.m:
New module containing the vartypes type and the predicates that operate
on it. The new module has *much* better cohesion than the old prog_data.m.
The vartypes type does not appear in any parse tree; it is used only
in the HLDS. So make vartypes.m part of the hlds.m package, not
parse_tree.m.
Move three predicates that perform renamings and substitutions on vartypes
here from prog_type_subst.m, since the latter is part of the parse_tree.m
package, and thus doesn't have access to hlds.vartypes. Make private
the service predicate that these three moved predicates used to rely on,
since it has no other callers.
compiler/prog_detism.m:
New module containing utility predicates that operate on determinisms
and determinism components.
compiler/prog_rename.m:
New module containing utility predicates that rename variables in
various data structures.
compiler/prog_data.m:
Remove the stuff now in the three new modules.
compiler/prog_type_subst.m:
Remove the three predicates now in vartypes.m.
compiler/mercury_to_mercury.m:
Delete an unneded predicate, which was the only part of this module
that referred to vartypes.
compiler/prog_type.m:
compiler/builtin_lib_types.m:
compiler/type_util.m:
Move some utility predicates that refer to vartypes from prog_type.m
and builtin_lib_types.m (both part of parse_tree.m) to type_util.m
(part of check_hlds.m).
compiler/parse_tree.m:
compiler/hlds.m:
compiler/notes/compiler_design.html:
Mention the new modules.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_heap_ops.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_trail_ops.m:
compiler/arg_info.m:
compiler/bytecode_gen.m:
compiler/call_gen.m:
compiler/clause_to_proc.m:
compiler/closure_analysis.m:
compiler/code_info.m:
compiler/code_loc_dep.m:
compiler/common.m:
compiler/complexity.m:
compiler/const_prop.m:
compiler/constraint.m:
compiler/continuation_info.m:
compiler/coverage_profiling.m:
compiler/cse_detection.m:
compiler/ctgc.datastruct.m:
compiler/ctgc.util.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/det_util.m:
compiler/disj_gen.m:
compiler/equiv_type_hlds.m:
compiler/erl_call_gen.m:
compiler/erl_code_gen.m:
compiler/erl_code_util.m:
compiler/exception_analysis.m:
compiler/float_regs.m:
compiler/follow_code.m:
compiler/follow_vars.m:
compiler/format_call.m:
compiler/goal_expr_to_goal.m:
compiler/goal_path.m:
compiler/goal_store.m:
compiler/goal_util.m:
compiler/headvar_names.m:
compiler/hhf.m:
compiler/higher_order.m:
compiler/hlds_clauses.m:
compiler/hlds_goal.m:
compiler/hlds_llds.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_module.m:
compiler/hlds_out_pred.m:
compiler/hlds_pred.m:
compiler/hlds_rtti.m:
compiler/inlining.m:
compiler/inst_util.m:
compiler/instmap.m:
compiler/intermod.m:
compiler/interval.m:
compiler/lambda.m:
compiler/lco.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/lookup_switch.m:
compiler/make_goal.m:
compiler/mark_tail_calls.m:
compiler/ml_accurate_gc.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/ml_gen_info.m:
compiler/ml_lookup_switch.m:
compiler/ml_proc_gen.m:
compiler/ml_unify_gen.m:
compiler/mode_constraints.m:
compiler/mode_info.m:
compiler/mode_util.m:
compiler/modecheck_call.m:
compiler/modecheck_conj.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/par_loop_control.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/prog_rep.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/qual_info.m:
compiler/quantification.m:
compiler/rbmm.points_to_graph.m:
compiler/rbmm.points_to_info.m:
compiler/rbmm.region_liveness_info.m:
compiler/rbmm.region_transformation.m:
compiler/saved_vars.m:
compiler/set_of_var.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_conj.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_goal_scope.m:
compiler/simplify_goal_switch.m:
compiler/simplify_goal_unify.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/size_prof.m:
compiler/ssdebug.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/stm_expand.m:
compiler/store_alloc.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/switch_detection.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/term_util.m:
compiler/trace_gen.m:
compiler/trailing_analysis.m:
compiler/try_expand.m:
compiler/tupling.m:
compiler/type_assign.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unneeded_code.m:
compiler/untupling.m:
compiler/unused_args.m:
compiler/var_locn.m:
Conform to the above changes, mostly by importing some of the
three new modules as well as, or instead of, prog_data.m.
|
||
|
|
89628ae791 |
More speedups of inst handling code.
On tools/speedtest -l -m, my tests show a speedup of about 2%, but
on Dirk's stress test module, for which the compiler (used to) spend
almost all its time handling insts, the speedup is about 40%.
This diff also contains some small incidental changes I stumbled upon
the "need" for while working on the main change.
compiler/prog_data.m:
The existing inst_test_results type used to be able to hold the results
of four tests about a bound inst. Add two more: the set of inst vars that
may occur in the inst, and whether a type constructor has already been
propagated into the cons_ids of the bound insts.
Put the fields of the the unify_inst and merge_inst inst_names into
a more sensible order.
Define types that hold the information stored in specific kinds of
inst_names, for use by hlds_data.m (see below).
compiler/inst_user.m:
For each user defined bound inst that matches exactly one parameterless
type, propagate its type constructor into it, and record the fact that
it has been done. This avoids having to do it many times later.
Also record the set of inst vars in each inst, again to avoid having
to repeat the test many times later.
compiler/mercury_compile_front_end.m:
Invoke the inst_user module as soon after inst_check.m as we can.
compiler/hlds_data.m:
Make the structure of six subtables of the inst table private, to allow
them to be experimented with (and possibly changed) without code changes
being required in other modules.
The unify_inst_table, the ground_inst_table and the any_inst_table
used to be maps whose keys were inst_names, but they were each only ever
used with one kind of inst_name. Change their keys to the new types
unify_inst_info, ground_inst_info and any_inst_info, which each contain
the information in the unify_inst, ground_inst and any_inst inst_names
respectively. That way, the searches in the maps will perform comparisons
that don't need to switch on what kind of inst_name they are dealing with,
and instead go directly to comparing the arguments.
With the unify_inst_table, also go a step further. The unify_inst_info
has two fields that are equivalent to booleans. Comparing these
at every level of the map is wasteful, so switch the representation
of the unify_inst_table from one map to four maps, one map for each
possible combination of those booleans. This way, the two booleans
in the unify_inst_info key are tested just once, when the applicable map
is selected.
The merge_inst_table used to have a pair of insts as keys. Replace that
with the merge_inst_info type, which also holds a pair of insts,
but on which comparisons should be a bit faster, since it is not
polymorphic, and thus does not need an implicit typeinfo passed along.
Provide a combined search_insert operation on each of the inst_tables,
since their pattern of use is exactly that: search the table, and if
the key is not found, insert a marker that says the entry is being
worked on. This avoid one traversal of a possibly-large tree, with
its associated (possibly very expensive) comparisons.
For each inst table, provide conversion predicates to and from
sorted association lists, for use by equiv_type_hlds.m
compiler/equiv_type_hlds.m:
Expand equivalence types in the new structure of the inst tables.
compiler/inst_util.m:
Use the new search_insert predicates for the various inst_tables.
If one of the two insts being unified is free, then avoid using
the unify_inst_table, since just doing the abstract unification
is faster, and does not pollute the unify_inst_table.
If both insts being merged are bound insts, then avoid using the
merge_inst_table, since (a) the lookup is slower than just doing
the merge, and (b) it can pollute the merge_inst_table to the extent
that *all other lookups* in it become very slow.
compiler/inst_match.m:
Use test result information in bound insts to speed up the corresponding
tests.
compiler/set_of_var.m:
Change the representation of sets of vars back to sparse_bitsets.
I changed them to tree_bitsets several years ago to avoid some bad
worst-case behavior with sparse_bitsets (which occurred when repeatedly
appending to the "ends" of sets), but other algorithmic changes have
since avoiding using set_of_vars in ways that induce that behavior,
and now my benchmarking tells me that the bottleneck operation is
conversion of set_of_vars to lists of vars. This is faster with
sparse_bitsets, since unlike tree_bitsets, they don't have to unravel
a tree structure.
compiler/mode_util.m:
Export a predicate now needed by inst_user.m, and clean up the code a bit,
factoring out repeated code.
compiler/modecheck_util.m:
Modify an equality comparison of two insts to compare the instantiation
states themselves, but NOT the test results about those instantiation
states, since these can differ if the two insts have different histories.
compiler/hlds_code_util.m:
compiler/hlds_out_mode.m:
compiler/hlds_out_module.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/polymorphism.m:
compiler/prog_mode.m:
compiler/recompilation.usage.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to the changes above.
The following changes are mostly incidental.
compiler/hlds_args.m:
Speed up a predicate by avoiding the materialization of a list
that is needed only for a test.
compiler/instmap.m:
Clarify some code.
compiler/liveness.m:
Avoid computing some value when it is not needed.
compiler/mode_errors.m:
Avoid referring to "arguments" (plural) for errors involving *one*
argument.
compiler/mode_info.m:
Move the documentation of some predicates to their declarations.
compiler/modecheck_unify.m:
Compute some data closer to where it is needed, to reduce the number
of stack slots needed.
tests/invalid/constrained_poly_insts2.err_exp:
Expect the updated error message from mode_errors.m (with "argument"
in singular), as well as module qualified insts, since having inst_user.m
push type_ctors into the definitions of named inst module qualifies
the bound_insts inside those definitions.
|
||
|
|
388b1c389a | Use pointer_equal instead of a bespoke predicate. | ||
|
|
3da6a06239 |
Fix problems preventing the system building in non-C grades.
compiler/mode_info.m: Avoid a warning due to he Mercury clause for the predicate old_and_new_may_differ/2 having too tight a determinism. compiler/pickle.m: Fix cut-and-paste errors in Erlang foreign procs. deep_profiler/DEEP_FLAGS.in: Specify the location of the Erlang library headers. |
||
|
|
f0fb4daaec |
Speed up updating mode_infos.
compiler/mode_info.m:
If the new value of a field of mode_info is likely to be bit-identical
to the old value, then test the old and new bits for equality in the
setter, and if they are the same, do not allocate a new mode_info structure
that is guaranteed to be the same as the old one.
By avoiding unnecessary memory turnover, this speeds up the compiler
by about 4%, as measured by tools/speedtest -l.
|
||
|
|
338b5cb98e |
Fix some bugs with constrained polymorphic modes.
1. An inst variable from the head of the clause could be bound in the body. The mode error in the call `P(X)' was not detected because the inst variable I could be bound to ground. :- pred p(pred(T), T). :- mode p(pred(in(I =< ground)) is det, in) is det. p(P, X) :- P(X). 2. In David Overton's thesis, a get_subst function produces an inst substitution from the callee's initial insts to the arguments' initial insts, and the substitution is applied to all insts from the callee. In the implementation we actually build the substitution while matching the arguments' insts with the callee's insts, but we lost some precision by not applying the incremental substitutions built as we match a list of insts. 3. We rename apart the callee's inst variables from our own, but did not keep the merged inst varset. When a renamed inst variable appears in a mode error it would be printed without its original name. (could this avert more serious problems?) 4. inst_merge_3 was missing a case. Some of these bugs may not be apparent due to the hack in inst_matches_final_3 which allows a ground inst to match any bound inst. A similar hack exists in inst_matches_binding_3. compiler/inst_util.m: Handle in inst_merge_3 the case InstA \= constrained_inst_var(_, _), InstB = constrained_inst_var(_, _). Move InstA = not_reached case to inst_merge_2 to maintain inst_merge(not_reached, InstB @ constrained_inst_var(_, _)) = InstB compiler/inst_match.m: Improve precision of inst var substitution computed in handle_inst_var_subs_2, following dmo's thesis. compiler/mode_util.m: compiler/modecheck_call.m: Keep the merged inst varsets after renaming. compiler/mode_info.m: Add "head inst vars" in mode_info structure. compiler/modecheck_util.m: Add get_constrained_inst_vars to extract constrained inst vars from a list of mode. Make modecheck_var_has_inst_list_* fail if the computed substitution would change the constraints of any head inst variables. compiler/modes.m: Initialise mode_info with head inst variables. compiler/pd_info.m: compiler/pd_util.m: Conform to change in mode_info_init (not specifically tested). compiler/prog_mode.m: Export inst_apply_substitution. Make rename_apart_inst_vars return the merged inst varset. Fix comments. tests/invalid/Mmakefile: tests/invalid/constrained_poly_insts2.err_exp: tests/invalid/constrained_poly_insts2.m: tests/valid/Mmakefile: tests/valid/constrained_poly_multi.m: Add test cases. NEWS: Announce fix. |
||
|
|
6d1bc24d0b |
Make vartypes an abstract data type, in preparation for exploring
Estimated hours taken: 4 Branches: main compiler/prog_data.m: Make vartypes an abstract data type, in preparation for exploring better representations for it. compiler/mode_util.m: Provide two different versions of a predicate. The generic version continues to use map lookups. The other version knows it works on prog_vars, so it can use the abstract operations on them provided by prog_data.m. compiler/accumulator.m: compiler/add_class.m: compiler/add_heap_ops.m: compiler/add_pragma.m: compiler/add_pred.m: compiler/add_trail_ops.m: compiler/arg_info.m: compiler/builtin_lib_types.m: compiler/bytecode_gen.m: compiler/call_gen.m: compiler/clause_to_proc.m: compiler/closure_analysis.m: compiler/code_info.m: compiler/common.m: compiler/complexity.m: compiler/const_prop.m: compiler/constraint.m: compiler/continuation_info.m: compiler/cse_detection.m: compiler/ctgc.datastruct.m: compiler/ctgc.util.m: compiler/deep_profiling.m: compiler/deforest.m: compiler/dep_par_conj.m: compiler/det_analysis.m: compiler/det_report.m: compiler/det_util.m: compiler/disj_gen.m: compiler/equiv_type_hlds.m: compiler/erl_call_gen.m: compiler/erl_code_gen.m: compiler/erl_code_util.m: compiler/exception_analysis.m: compiler/float_regs.m: compiler/follow_vars.m: compiler/format_call.m: compiler/goal_path.m: compiler/goal_util.m: compiler/hhf.m: compiler/higher_order.m: compiler/hlds_clauses.m: compiler/hlds_goal.m: compiler/hlds_out_goal.m: compiler/hlds_out_pred.m: compiler/hlds_pred.m: compiler/hlds_rtti.m: compiler/inlining.m: compiler/instmap.m: compiler/intermod.m: compiler/interval.m: compiler/lambda.m: compiler/lco.m: compiler/live_vars.m: compiler/liveness.m: compiler/lookup_switch.m: compiler/mercury_to_mercury.m: compiler/ml_accurate_gc.m: compiler/ml_closure_gen.m: compiler/ml_code_gen.m: compiler/ml_code_util.m: compiler/ml_disj_gen.m: compiler/ml_lookup_switch.m: compiler/ml_proc_gen.m: compiler/ml_unify_gen.m: compiler/mode_info.m: compiler/modecheck_call.m: compiler/modecheck_conj.m: compiler/modecheck_goal.m: compiler/modecheck_unify.m: compiler/modecheck_util.m: compiler/modes.m: compiler/par_loop_control.m: compiler/pd_info.m: compiler/pd_util.m: compiler/polymorphism.m: compiler/post_typecheck.m: compiler/prog_type_subst.m: compiler/prop_mode_constraints.m: compiler/purity.m: compiler/qual_info.m: compiler/rbmm.points_to_info.m: compiler/rbmm.region_liveness_info.m: compiler/rbmm.region_transformation.m: compiler/saved_vars.m: compiler/simplify.m: compiler/size_prof.m: compiler/ssdebug.m: compiler/stack_alloc.m: compiler/stack_opt.m: compiler/store_alloc.m: compiler/structure_reuse.analysis.m: compiler/structure_reuse.direct.choose_reuse.m: compiler/structure_reuse.direct.detect_garbage.m: compiler/structure_reuse.indirect.m: compiler/structure_sharing.analysis.m: compiler/structure_sharing.domain.m: compiler/switch_detection.m: compiler/table_gen.m: compiler/term_constr_build.m: compiler/term_constr_util.m: compiler/term_traversal.m: compiler/term_util.m: compiler/trace_gen.m: compiler/trailing_analysis.m: compiler/try_expand.m: compiler/tupling.m: compiler/type_constraints.m: compiler/type_util.m: compiler/typecheck.m: compiler/typecheck_errors.m: compiler/typecheck_info.m: compiler/unify_gen.m: compiler/unify_proc.m: compiler/unique_modes.m: compiler/untupling.m: compiler/unused_args.m: compiler/var_locn.m: Conform to the above. compiler/prog_type.m: compiler/rbmm.points_to_graph.m: Conform to the above. Move some comments where they belong. compiler/stm_expand.m: Conform to the above. Do not export a predicate that is not used outside this module. Disable some debugging output unless it is asked for. Remove unnecessary prefixes on variable names. library/version_array.m: Instead writing code for field access lookalike functions and defining lookup, set etc in terms of them, write code for lookup, set etc, and define the field access lookalike functions in terms of them. Change argument orders of some internal predicates to be more state variable friendly. Fix typos in comments. tests/hard_coded/version_array_test.exp: Conform to the change to version_array.m. |
||
|
|
585c1d623c |
Fix a problem with from_ground_term scopes.
Estimated hours taken: 20 Branches: main Fix a problem with from_ground_term scopes. When they are built, the scopes are tentantively marked as from_ground_term_construct scopes, and the unifications inside them are in a top down order. Mode analysis therefore expected the unifications inside from_ground_term_construct scopes to have that order. The problem was that mode analysis, when it confirmed that a from_ground_term scope is indeed a from_ground_term_construct scope, itself reversed the order of the unifications, putting them in a bottom up order. When mode analysis is reinvoked, either for unique mode checking, or after cse_detection finds common subexpressions, this meant that mode analysis found the unifications in the "wrong" order, and therefore disregarded the scope, discarding all its performance benefits. This diff separates out the two notions that we previously conflated. The scope kind from_ground_term_construct now refers only to scopes which are definitely known to construct ground terms. We can know that only after mode analysis. Until then, from_ground_term scopes are now marked as from_ground_term_initial. The two kinds have different though overlapping sets of invariants; in particular, they promise different orderings of the unifications in the scope. This diff reduces the time needed to compile mas_objects.data.m from about 221 seconds to about 8. compiler/hlds_goal.m: Add the from_ground_term_initial kind. Document the invariants that each kind of from_ground_term scope promises. compiler/superhomogeneous.m: Mark from_ground_term scopes initially as from_ground_term_initial, not from_ground_term_construct. compiler/post_typecheck.m: Make the predicate that converts function calls that look like unifications (such as X = int.min) into actual function calls say whether it performed such a conversion. compiler/purity.m: Use the new functionality in post_typecheck.m to convert from_ground_term_initial scopes into from_ground_term_other scopes if the conversion of a unification into a call means that we have to break an invariant expected of from_ground_term_initial scopes. compiler/cse_detection.m: compiler/switch_detection.m: Maintain the invariants we now expect of from_ground_term_deconstruct scopes. compiler/modecheck_goal.m: Maintain the invariants we now expect of the different from_ground_term scopes. Avoid traversing such scopes if a previous invocation of mode analysis says we can. Optimize away from_ground_term_construct scopes if the variable being constructed is not needed later. compiler/quantification.m: If the variable named in a from_ground_term_initial or from_ground_term_construct scope is not referred to outside the scope, set the nonlocals set of the scope to empty, which allows later compiler passes to optimize it away. Avoid some unnecessary work by the compiler. compiler/add_trail_ops.m: compiler/closure_analysis.m: compiler/constraint.m: compiler/dead_proc_elim.m: compiler/deep_profile.m: compiler/deforest.m: compiler/delay_construct.m: compiler/delay_partial_inst.m: compiler/dep_par_conj.m: compiler/dependency_graph.m: compiler/exception_analysis.m: compiler/follow_code.m: compiler/follow_vars.m: compiler/goal_form.m: compiler/goal_util.m: compiler/granularity.m: compiler/inlining.m: compiler/interval.m: compiler/lambda.m: compiler/lco.m: compiler/middle_rec.m: compiler/mode_util.m: compiler/parallel_to_plain.m: compiler/simplify.m: compiler/stm_expand.m: compiler/stratify.m: compiler/tabling_analysis.m: compiler/term_pass1.m: compiler/try_expand.m: compiler/tupling.m: compiler/untupling.m: compiler/unused_args.m: Avoid traversing from_ground_term_deconstruct scopes in cases where the invariants that now hold (mainly the absence of anything but deconstruct unifications) make such traversals unnecessary. compiler/live_vars.m: compiler/liveness.m: compiler/structure_reuse.lbu.m: Add comments about exploiting from_ground_term_deconstruct scopes. compiler/det_analysis.m: compiler/hlds_out_goal.m: compiler/polymorphism.m: compiler/saved_vars.m: compiler/unique_modes.m: Handle from_ground_term_initial scopes. compiler/handle_options.m: Add a dump verbosity option that is useful for comparing HLDS dumps created by two different compilers. compiler/type_util.m: Minor speedup. compiler/mode_info.m: compiler/modecheck_conj.m: compiler/prog_data.m: compiler/rbmm.region_transformation.m: compiler/typecheck.m: Improve documentation. |
||
|
|
d00ea69529 |
Switch from using set(prog_var), which is represented using set_ordlist,
Estimated hours taken: 12 Branches: main Switch from using set(prog_var), which is represented using set_ordlist, to set_of_progvar, which is represented using tree_bitset, for most sets of variables in the compiler, including the nonlocals sets in goal_infos. This diff yields about a 5% speedup when compiling the training_cars_full.m stress test, but also about a 1% slowdown on tools/speedtest. Both of these are with the current default state in which tree_bitset is compiled with a whole bunch of sanity checks. If these are disabled, we get roughly a 1% speedup on tools/speedtest. I intend to disable those sanity checks after a shakedown period of a week or two in which the updated version of the compiler is installed on our platforms. compiler/hlds_goal.m: Replace almost all occurrences of set(prog_var) with set_of_progvar. The main exceptions are the types supporting rbmm. compiler/set_of_var.m: Add some more predicates and functions that previous existed on sets but not yet on set_of_vars. compiler/*.m: Conform to the change in hlds_goal.m, and make similar changes in set representations. library/bag.m: Add a predicate and function for creating a bag from a sorted list. We already had them for creating a bag from a set, but a set_of_progvar shouldn't have to be converted to a set. library/robdd.m: Fix deviations from our programming style. |
||
|
|
295415090e |
Convert almost all remaining modules in the compiler to use
Estimated hours taken: 6 Branches: main compiler/*.m: Convert almost all remaining modules in the compiler to use "$module, $pred" instead of "this_file" in error messages. In a few cases, the old error message was misleading, since it contained an incorrect, out-of-date or cut-and-pasted predicate name. tests/invalid/unresolved_overloading.err_exp: Update an expected output containing an updated error message. |
||
|
|
e8d654c5bf |
Remove dependencies on the svbag module.
Branches: main compiler/lco.m: compiler/mode_info.m: Remove dependencies on the svbag module. |
||
|
|
1c3bc03415 |
Make the system compiler with --warn-unused-imports.
Estimated hours taken: 2 Branches: main, release Make the system compiler with --warn-unused-imports. browser/*.m: library/*.m: compiler/*.m: Remove unnecesary imports as flagged by --warn-unused-imports. In some files, do some minor cleanup along the way. |
||
|
|
8a28e40c9b |
Add the predicates sorry, unexpected and expect to library/error.m.
Estimated hours taken: 2 Branches: main Add the predicates sorry, unexpected and expect to library/error.m. compiler/compiler_util.m: library/error.m: Move the predicates sorry, unexpected and expect from compiler_util to error. Put the predicates in error.m into the same order as their declarations. compiler/*.m: Change imports as needed. compiler/lp.m: compiler/lp_rational.m: Change imports as needed, and some minor cleanups. deep_profiler/*.m: Switch to using the new library predicates, instead of calling error directly. Some other minor cleanups. NEWS: Mention the new predicates in the standard library. |
||
|
|
543fc6e342 |
Change the way the typechecker iterates over the predicates of the program.
Estimated hours taken: 12 Branches: main Change the way the typechecker iterates over the predicates of the program. We used to do it by looking up each predicate in the module_info, typechecking it, and putting it back into the module_info. We now do it by converting the predicate table into a list, iterating over the list transforming each pred_info in it, converting the updated list back to a predicate table. The original intention of this change was to allow different predicates to be typechecked in parallel by removing a synchronization bottleneck: the typechecking of a predicate now doesn't have to wait for the typechecking of the previous predicate to generate the updated version of the module_info. However, it turned out that the change is good for sequential execution as well, improving the time on tools/speedtest from 11.33 seconds to 11.08 seconds, a speedup of 2.2%. On tools/speedtest -l, which tests the compilation of more modules, the speedup is even better: 3.1% (from 32.63 to 31.60s). compiler/typecheck.m: Implement the above change. compiler/hlds_module.m: compiler/pred_table.m: Add a new operation, setting the list of valid pred_ids, now needed by typecheck.m, to both modules. Make the names of the predicates for accessing the predicate table more expressive, and make them conform to our naming conventions. compiler/*.m: Trivial changes to conform to the change in hlds_module.m. library/assoc_list.m: Add new predicates used by the new version of typecheck.m (at some time in its development). NEWS: Mention the new predicates. library/list.m: Improve documentation that is now copied to assoc_list.m. tools/speedtest: Make the test command more easily configurable. |
||
|
|
69644fa7c7 |
Fix three bugs with from_ground_term scopes, including Mantis bugs 93 and 94.
Estimated hours taken: 14
Branches: main
Fix three bugs with from_ground_term scopes, including Mantis bugs 93 and 94.
compiler/superhomogenenous.m:
Fix Mantis bug 94. The problem was an overzealous sanity check.
compiler/modes.m:
Fix Mantis bug 93. When analysing a from_ground_term_construct scope,
we set the inst of the var being built to ground, since the shared
nature of static terms requires this. However, some code may require
the term to be unique. We therefore prepare to do mode analysis twice.
On the first pass, we consider terms from from_ground_term to be
ground, as before, but we record the fact that we did so. If
mode analysis of the procedure yields one or more errors, they could
have been due to this decision. So we analyze the procedure a second
time, but this time, after each from_ground_term_construct scope,
we add a call to builtin.copy, which yields a unique term.
Note that this may be overkill. Even if e.g. the procedure has three
from_ground_term_construct scopes, only one of which need to be unique
for mode analysis to succeed, we will call copy after all three.
compiler/mode_info.m:
Provide the infrastructure for the fix in modes.m.
compiler/quantification.m:
Fix the third bug, which is not in Mantis. The bug was that after my
recent optimization of quantification, we never listed the local
variables of from_ground_term_construct scopes in the outputs of the
goal_vars_* family of predicates. However, there is one case where they
are needed, and this is when we want to duplicate the goal, and need to
rename *all* the variables in the copy.
The fix is to add new versions of goal_vars_* and their auxiliary
predicates that collect this information, and use them when expanding
out bi_implications.
This now also expects that bi_implications won't occur in the hLDS
by the time that lambda expansion has been done. Since lambda expansion
is done in the middle pass, and bi_implications are expanded out by the
very first invocation of quantification, even *before* semantic
analysis starts, this is a safe bet.
compiler/hlds_goal.m:
Document where bi_implications are expanded out.
compiler/polymorphism.m:
Minor style improment.
compiler/options.m:
Set the default from_ground_term threshold to what it was before
we discovered these problems.
tests/hard_coded/uo_regression1.{m,exp}:
tests/hard_coded/from_ground_term_bug.{m,exp}:
Slightly modified versions of the Mantis test cases for bugs 93 and 94.
tests/hard_coded/type_qual.{m,exp}:
This test case was the one that shows the third bug. Expand it
to put a from_ground_term_construct scope in the LHS as well as RHS
of a bi-implication.
tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
Enable the two new tests, and enable from_ground_term_construct scopes
on all three tests.
|
||
|
|
5ad9a27793 |
Speed up the compiler's handling of code that constructs large ground terms
Estimated hours taken: 80
Branches: main
Speed up the compiler's handling of code that constructs large ground terms
by specializing the treatment of such code.
This diff reduces the compilation time for training_cars_full.m from 106.9
seconds to 30.3 seconds on alys, my laptop. The time on tools/speedtest
stays pretty much the same.
compiler/hlds_goal.m:
Record the classification of from_ground_term scopes as purely
constructing terms, purely deconstructing them or something other.
Fix an old potential bug: variables inside the construct_how fields
of unifications weren't being renamed along with other variables.
This is a bug if any part of the compiler later looks at those
variables. (I am not sure whether or not this happens.)
compiler/superhomogenous.m:
Provisionally mark newly constructed static terms as being
from_ground_term_construct. Mode checking will either confirm this
or change the scope kind.
compiler/options.m:
compiler/handle_options.m:
Add a new option, from_ground_term_threshold, that allows the user to
set the boundary between ground terms that get scopes and ground terms
do not. I plan to experiment with different settings later.
compiler/modes.m:
Make this classification. For scopes that construct ground terms,
use a specialized algorithm that avoids quadratic behavior.
(It does not access the unify_inst_table, which is where the
factor of N other than the length of the goal list came from.)
The total size of the instmap_deltas, if printed out, still looks like
O(N^2) in size, but due to structure sharing it needs only O(N) memory.
For scopes that construct ground terms, set the determinism information
so that det_analysis.m doesn't have to traverse such scopes.
When handling disjunctions, check whether some nonlocals of the
disjunctions are constructed by from_ground_term_construct scopes.
For any such nonlocals, set their insts to just ground, throwing away
the precise information we have about exactly what function symbols
they and ALL their subterms are bound to. This is HUGE win, since
it allows us avoid spending a lot of time building a huge merge_inst
table, which later passes of the compiler (e.g. equiv_type_hlds) would
then have to spend similarly huge times traversing.
This approach does have a down side. If lots of arms of a disjunction
bind a nonlocal to a large ground term, but a few bind it to a SMALL
ground term, a term below the from_ground_term_threshold, this
optimization won't kick in. That could be one purpose of the new
option. It isn't documented yet; I will seek feedback about its
usefulness first.
compiler/modecheck_unify.m:
Handle the three different kinds of right hand sides separately.
This yields a small speedup, because now we don't test rhs_vars and
rhs_functors (the common right hand sides) for a special case
(goals containing "any" insts) that is applicable only to
rhs_lambda_goals.
compiler/unique_modes.m:
Don't traverse scopes that construct ground terms, since modes.m has
already done everything that needs to be done.
compiler/det_analysis.m:
Don't traverse scopes that construct ground terms, since modes.m has
already done the needed work.
compiler/instmap.m:
Add a new predicate for use by modes.m.
Many predicate names in this module were quite uninformative; give them
informative names.
compiler/polymorphism.m:
If this pass invalidates the from_ground_term_construct invariants,
then mark the relevant scope as from_ground_term_other.
Delete two unused access predicates.
compiler/equiv_type_hlds.m:
Don't traverse scopes that construct ground terms, since modes.m
ensures that their instmap deltas do not contain typed insts, and
thus the scope cannot contain types that need to be expanded.
Convert some predicates to single clauses.
compiler/goal_form.m:
compiler/goal_util.m:
In predicates that test goals for various properties, don't traverse
scopes that construct ground terms when the outcome of the test
is the same for all such scopes.
Convert some predicates to single clauses.
compiler/simplify.m:
Do not look for common structs in from_ground_term_construct scopes,
both because this speeds up the compiler, and because retaining
references to ground terms is in fact a pessimization, not an
optimization. This is because (a) those references need to be stored in
stack slots across calls, and (b) the C code generators ensure that
the cells representing ground terms will be shared as needed.
If all arms of a switch are from_ground_term_construct scopes,
do not merge the instmap_deltas from those arms, since this is
both time-consuming (even after the other changes in this diff)
and extremely unlikely to improve the instmap_delta.
Disable common_struct in from_ground_term_construct scopes,
since for these scopes, it is actually a pessimization.
Do not delete from_ground_term_construct scopes, since many
compiler passes can now use them.
Do some manual deforestation, break up some large predicates,
and give better names to some.
compiler/liveness.m
Special-case the handling from_ground_term_construct scopes. This
allows us to traverse them just once instead of three times, and this
traversal is simpler and faster than any of the three.
In some traversals, we were switching on the goal type twice; once
in e.g. detect_liveness_in_goal_2, and once by calling
goal_expr_has_subgoals. Eliminate the double switching by merging
the relevant predicates. (The double-switching structure was easier
to work with before we had multi-cons-id switches.)
compiler/typecheck.m:
Move a lookup after a test, so we don't have to do it if the test
fails.
Provide a specialized mode for a predicate. This should allow the
compiler to eliminate an argument and a test in the common case.
Note a possible chance for a speedup.
compiler/typecheck_info.m:
Don't apply empty substitutions to the types of a possibly very large
set of variables.
compiler/quantification.m:
Don't quantify from_ground_term_construct scopes. They are created
correctly quantified, and any compiler pass that invalidates that
quantification also removes the from_ground_term_construct mark.
Don't apply empty renamings to a possibly very large set of variables.
Move the code for handling scopes to its own predicate, to avoid
overwhelming the code that handles other kinds of goals. Even from
this, factor out the renaming code, since it is needed only for
some kinds of scopes.
Make some predicate names better reflect what the predicate does.
compiler/pd_cost.m:
For from_ground_term_construct scopes, instead of computing their cost
by adding up the costs of the goals inside, make their cost a constant,
since binding a variable to a static term takes constant time.
compiler/pd_info.m:
Add prefixes on field names to avoid ambiguities.
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/closure_analysis.m:
compiler/constraint.m:
compiler/cse_detection.m:
compiler/dead_proc_elim.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/distance_granularity.m:
compiler/exception_analysis.m:
compiler/follow_code.m:
compiler/follow_vars.m:
compiler/format_call.m:
compiler/granularity.m:
compiler/higher_order.m:
compiler/implicit_parallelism.m:
compiler/inlining.m:
compiler/interval.m:
compiler/lambda.m:
compiler/lco.m:
compiler/live_vars.m:
compiler/loop_inv.m:
compiler/middle_rec.m:
compiler/mode_util.m:
compiler/parallel_to_plain_conj.m:
compiler/saved_vars.m:
compiler/stm_expand.m:
compiler/store_alloc.m:
compiler/stratify.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.lbu.m:
compiler/structure_sharing.analysis.m:
compiler/switch_detection.analysis.m:
compiler/trail_analysis.m:
compiler/term_pass1.m:
compiler/tupling.m:
compiler/unneeded_code.m:
compiler/untupling.m:
compiler/unused_args.m:
These passes have nothing to do in from_ground_term_construct scopes,
so don't traverse them.
In some modules (e.g. dead_proc_elim), some traversals had to be kept.
In loop_inv.m, replace a code structure that updated accumulators
with functions (which prevented the natural use of state variables),
that in lots of places reconstructed the term it had just
deconstructed, and obscured the identical handling of different kinds
of goals, with a structure based on predicates, state variables and
shared code for different goal types where possible.
In store_alloc.m, avoid some double switching on the same value.
In stratify.m, unneeded_code.m and unused_args.m, rename predicates
to avoid ambiguities.
compiler/goal_path.m:
compiler/goal_util.m:
compiler/implementation_defined_literals.m:
compiler/intermode.m:
compiler/mark_static_terms.m:
compiler/ml_code_gen.m:
compiler/mode_ordering.m:
compiler/ordering_mode_constraints.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/rbmm.actual_region_arguments.m:
compiler/rbmm.add_rbmm_goal_infos.m:
compiler/rbmm.condition_renaming.m:
compiler/rbmm.execution_path.m:
compiler/rbmm.region_transformation.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lfu.m:
compiler/structure_reuse.versions.m:
compiler/term_const_build.m:
compiler/term_traversal.m:
compiler/unused_imports.m:
Mark places where we cannot (yet) special case
from_ground_term_construct scopes.
In structure_reuse.lfu.m, turn nested if-then-elses into a switch in.
compiler/size_prof.m:
Turn from_ground_term_construct scopes into from_ground_term_other
scopes, since in term size profiling grades, we need to attach sizes to
terms.
Give predicates better names.
compiler/*.m:
Minor changes to conform to the changes above.
compiler/make_hlds_passes.m:
With -S, print statistics after the third pass over items, since
this is the time-consuming one.
compiler/mercury_compile.m:
Conform to the new names of some predicates.
When declining to output a HLDS dump because it would be identical to
the previous dump, don't confuse the user either by being silent about
the decision, or by leaving an old dump laying around that could be
mistaken for a new one.
tools/binary:
tools/binary_step:
Bring these tools up to date.
compiler/Mmakefile:
Add an int3s target for use by the new code in the tools. The
Mmakefiles in the other directories with Mercury code already have
such a target.
compiler/notes/allocation.html:
Fix an out-of-date reference.
tests/debugger/polymorphic_ground_term.{m,inp,exp}:
New test case to check whether liveness.m handles typeinfo liveness
of ground terms correctly.
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/polymorphic_output.{m,exp}:
Fix tab/space mixup.
|
||
|
|
b000cb322e |
Provide compiler support for Software Transactional Memory through the new
Estimated hours taken: 80 by zs, and lots more by lmika Branches: main Provide compiler support for Software Transactional Memory through the new atomic goal. This work was done by Leon Mika; I merely brought it up to date, resolved conflicts, and cleaned up a few things. There are still several aspects that are as yet incomplete. library/ops.m: Add the operators needed for the syntax of atomic scopes. library/stm_builtin.m: Add the builtin operations needed for the implementation of atomic goals. compiler/hlds_goal.m: Add a new HLDS goal type, which represents an atomic goal and its possible fallbacks (in case an earlier goal throws an exception). Rename the predicate goal_is_atomic as goal_expr_has_subgoals, since now its old name would be misleading. compiler/prog_data.m: compiler/prog_item.m: Add a parse tree representation of the new kind of goal. compiler/prog_io_goal.m: Parse the new kind of goal. compiler/add_clause.m: Translate atomic goals from parse tree form to HLDS. compiler/typecheck.m: compiler/typecheck_errors.m: Do type checking of atomic goals. compiler/modes.m: Do mode checking of atomic goals, and determine whether they are nested or not. compiler/unique_modes.m: Do unique mode checking of atomic goals. compiler/stm_expand.m: New module to expand atomic goals into sequences of simpler goals. library/stm_builtin.m: Add the primitives needed by the transformation. Improve the existing debugging support. mdbcomp/prim_data.m: Add utility functions to allow stm_expand.m to refer to modules in the library. mdbcomp/program_representation.m: Expand the goal_path type to allow the representation of components of atomic goals. compiler/notes/compiler_design.html: Document the new module. compiler/transform_hlds.m: Include the new module in the compiler. compiler/mercury_compile.m: Invoke the STM transformation. compiler/hlds_module.m: Add an auxiliary counter used by the STM transformation. compiler/hlds_pred.m: Add a new predicate origin: the STM transformation. compiler/modules.m: Import the STM builtin module automatically if the module contains any atomic goals. 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/cse_detection.m: compiler/deep_profiling.m: compiler/code_util.m: compiler/delay_construct.m: compiler/delay_partial_inst.m: compiler/dep_par_conj.m: compiler/dependency_graph.m: compiler/det_analysis.m: compiler/det_report.m: compiler/distance_granularity.m: compiler/equiv_type_hlds.m: compiler/erl_code_gen.m: compiler/exception_analysis.m: compiler/follow_code.m: compiler/format_call.m: compiler/goal_form.m: compiler/goal_path.m: compiler/goal_util.m: compiler/granularity.m: compiler/hlds_out.m: compiler/implicit_parallelism.m: compiler/inlining.m: compiler/intermod.m: compiler/lambda.m: compiler/layout_out.m: compiler/lco.m: compiler/lookup_switch.m: compiler/make_hlds_warn.m: compiler/mark_static_terms.m: compiler/mercury_to_mercury.m: compiler/middle_rec.m: compiler/ml_code_gen.m: compiler/mode_constraint_robdd.m: compiler/mode_constraints.m: compiler/mode_errors.m: compiler/mode_info.m: compiler/mode_util.m: compiler/ordering_mode_constraints.m: compiler/pd_cost.m: compiler/pd_util.m: compiler/polymorphism.m: compiler/post_typecheck.m: compiler/prog_rep.m: compiler/prog_type.m: compiler/prop_mode_constraints.m: compiler/rbmm.actual_region_arguments.m: compiler/rbmm.add_rbmm_goal_info.m: compiler/rbmm.condition_renaming.m: compiler/rbmm.execution_path.m: compiler/rbmm.points_to_analysis.m: compiler/rbmm.region_transformation.m: compiler/saved_vars.m: compiler/simplify.m: compiler/size_prog.m: compiler/smm_common.m: compiler/structure_reuse.direct.choose_reuse.m: compiler/structure_reuse.direct.detect_garbage.m: compiler/structure_reuse.indirect.m: compiler/structure_reuse.lbu.m: compiler/structure_reuse.lfu.m: compiler/structure_reuse.versions.m: compiler/structure_sharing.analysis.m: compiler/switch_detection.m: compiler/unused_imports.m: compiler/granularity.m: compiler/granularity.m: Conform to the changes above. Mostly this means handling the new kind of goal. compiler/add_heap_ops.m: compiler/add_trail_ops.m: compiler/build_mode_constraints.m: compiler/closure_analysis.m: compiler/dead_proc_elim.m: compiler/deforest.m: compiler/follow_vars.m: compiler/higher_order.m: compiler/live_vars.m: compiler/liveness.m: compiler/loop_inv.m: compiler/module_qual.m: compiler/prog_util.m: compiler/purity.m: compiler/quantification.m: compiler/store_alloc.m: compiler/stratify.m: compiler/tabling_analysis.m: compiler/term_constr_build.m: compiler/term_pass1.m: compiler/term_traversal.m: compiler/trailing_analysis.m: Conform to the changes above. Mostly this means handling the new kind of goal. Switch syntax from clauses to disj. runtime/mercury_stm.[ch]: Implement the primitives needed by the STM transformation. Add more debugging support to the existing primitives. library/term.m: Generalize get_term_context to work on terms of all kinds. |
||
|
|
f5667464c7 |
Remove support for automatic initialisation of solver types from the language.
Estimated hours taken: 10 Branches: main Remove support for automatic initialisation of solver types from the language. This is being done because: * the current implementation of automatic initialisation means we cannot support polymorphic solver types, e.g. you cannot have the type foo(bar) where: :- solver type foo(T). :- solver type bar. * the current initialisation strategy is fairly ad-hoc anyway; in particular it has a tendency to unnecessarily change the determinism of procedures. * mode error messages are often quite poor because of the interaction between automatic initialisation and impure code. * automatic initialisation is not used in practice. All of the G12 solver libraries that use solver types recommend explicitly initialising solver variables. This change removes support for automatic solver initialisation from the language. The code for supporting it remains in the implementation, but it is now dependent upon the developer-only `--solver-type-auto-init' option. As a transitional measure the compiler will still accept `initialisation is ...' attributes in solver type definitions even when `--no-solver-type-auto-init' is enabled. After this change has bootstrapped, and the relevant updates have been made to the G12 solver libraries, this will be changed so that `initialisation is ...' attributes are considered a syntax error unless `--solver-type-auto-init' is enabled. doc/reference_manual.texi: Document that solver type definitions no longer allow initialisation predicates to be supplied. (The section documenting initialisation predicates has been commented out rather than deleted since the implementation of automatic initialisation still exists.) Remove the section documenting the restrictions on polymorphic solver types. These restrictions no longer apply in the absence of automatic initialisation. compiler/options.m: Add a new developer-only option, `--solver-type-auto-init', that controls whether automatic initialisation of solver variables is allowed (for those solver types that have initialisation predicates specified.) compiler/prog_data.m: Add a type that represents whether a solver type allows automatic initialisation or not. Extend the solver_type_details structure to allow initialisation predicates to be optional. compiler/prog_io.m: Allow initialisation predicates to be optional in solver type definitions. compiler/modes.m: compiler/modecheck_call.m: compiler/modecheck_unify.m: Only insert calls to solver type initialisation predicates if the solver type has an initialisation predicate and the developer-only option `--solver-type-auto-init' is enabled. compiler/unify_proc.m: Handle the situation where a solver type does not have an initialise predicate. compiler/add_special_pred.m: Only add initialisation special predicates for those solver types whose definition provides an initialisation predicate. compiler/mode_info.m: Add a utility predicate that tests whether the support for automatic solver type initialisation is enabled. compiler/type_util.m: Add a predicate that tests whether a type is a solver type that supports automatic initialisation. Add an XXX comment about such types and abstract equivalence types. compiler/mercury_to_mercury.m: Conform to the above changes. compiler/special_pred.m: Fix some typos. samples/solver_types/eqneq.m: Delete the `initialisation is ...' from the definition of the solver type eqneq/1. tests/hard_coded/Mercury.options: Enable `--solver-type-auto-init' for the solver_construction_init_test test. tests/hard_coded/solver_build_call.m: tests/invalid/any_pass_as_ground.m: Don't use automatic solver variable initialisation in these test cases. tests/invalid/partial_implied_mode.err_exp: Conform to the above changes in the mode analyser. tests/valid/Mercury.options: Compile some tests cases with `--solver-type-auto-init' enabled. |
||
|
|
e53a6192d0 |
Improve the performance of the compiler by making sure that the mode_info
Estimated hours taken: 3 Branches: main Improve the performance of the compiler by making sure that the mode_info structure contains only its most frequently updated and/or accessed fields and that these fit into an eight-word memory cell, moving the rest of the fields to the mode_sub_info structure. This improves performance on our standard benchmark from 20.60 seconds to 19.06 seconds, an improvement of 7%. compiler/mode_info.m: Make the change described above. Several fields of mode_sub_info were bools. Replace these with single-purpose types, to make them harder to mix up, especially during initialization. Similarly, replace the type of the field used for checking parallel conjunctions with a specialized type instead of a pair. Rename some predicates for greater consistency with the rest of the compiler. Rename field names to avoid ambiguities. Use the access predicates instead of field access syntax to access the fields of mode_info and mode_sub_info, to make any similar changes easier in the future, and also to make statistics about frequency of field accesses easier to gather. compiler/modecheck_call.m: compiler/modecheck_unify.m: compiler/modes.m: Conform to the changes in mode_info. compiler/modes.m: compiler/unique_modes.m: Do not execute the (save, set to known value, restore) sequence for the "duplicated for switch" feature unless necessary. This avoids a bunch of accesses and updates to the mode_sub_info. In both cases, this required moving some code that would otherwise have had to be duplicated into an inlined predicate. In unique_modes.m, rename a predicate to allow its name to be used for the new inlined predicate. compiler/Mercury.options: Change the inlining limit to allow those predicates to be inlined. |
||
|
|
27aaaf412c |
Fix the failure of the invalid/modes_erroneous test case, whose symptom was
Estimated hours taken: 5 Branches: main Fix the failure of the invalid/modes_erroneous test case, whose symptom was an error message about a "mode error in unification of `X' and `X'". The root cause of the problem was that the renaming of head variables computed by headvar_names.m was being applied too early, during typechecking. The fix is to apply it after the frontend (all the passes that can generate error messages). To avoid slowdowns from larger pred_infos, this diff also moves the least frequently used fields of pred_infos to a subterm. (Proc_infos already had a subterm.) This leads to an almost 3% speedup. compiler/headvar_names.m: Store the renaming instead of applying it. compiler/simplify.m: Apply the renaming in invocations after the front end, since doing so may allow some excess assignments to be eliminated. compiler/hlds_pred.m: Add fields to pred_infos and proc_infos for the renaming. Move the least frequently used fields of pred_infos into a pred_sub_info. Some fields of pred_infos were being accessed using predicates that did not follow our naming conventions, and some were accessed using field access functions that are now inappropriate; fix them all. Require the caller to provide the renaming when creating new pred_infos and proc_infos. This is to force the compiler components that do this to propagate the renaming fields of the original predicates and/or procedures to their modified versions. Convert that some old code that used if-then-elses to use switches instead. compiler/hlds_out.m: Write out the new pred_info and proc_info fields. compiler/*.m: Conform to the changes in hlds_pred.m. compiler/hlds_clauses.m: Avoid ambiguity by giving a prefix to the fields of the clauses_info type. tests/invalid/ho_type_mode_bug.err_exp: tests/invalid/merge_ground_any.err_exp: Don't expect error messages about "X = X" anymore. |
||
|
|
f5345e7b46 |
Add some higher-order operations that work on proc_arg_vectors.
Estimated hour taken: 1.5 Branches: main Add some higher-order operations that work on proc_arg_vectors. These are required by upcoming changes. Remove ambiguities on the function symbol `dead' by renaming type constructors (and in one case by deleting an unused type.) Julien. compiler/hlds_args.m: Add some higher-order operations for proc_arg_vectors. compiler/hlds_pred.m: Delete the type `liveness' since it is unused and its function symbols clash with the function symbols of other types. compiler/prog_data.m: Add prefixes to the function symbols of the type is_live in order to make them unambiguous. compiler/var_locn.m: Do the same for the function symbols for the dead_or_alive type. compiler/inst_match.m: compiler/inst_util.m: compiler/instmap.m: compiler/mercury_to_mercury.m: compiler/mode_info.m: compiler/mode_util.m: compiler/modecheck_call.m: compiler/modecheck_unify.m: compiler/modes.m: compiler/unique_modes.m: Conform to the above changes. compiler_unify_gen.m Switch on the arg_mode type in a few spots. Conform to the above changes. compiler/structure_sharing.domain.m Fix some comments. |