mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-17 23:05:21 +00:00
db5d688c435b7abae731e1faa83bac3c8a96d51a
164 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
46a67b0b48 |
When the typechecker finds highly ambiguous overloading, print what symbols
Estimated hours taken: 16
Branches: main
When the typechecker finds highly ambiguous overloading, print what symbols
were overloaded, and where they occurred. Without this information, it is
very hard to fix the error if the predicate body is at all large.
Fix some software engineering problems encountered during this process.
Modify some predicates in error_util in order to simplify their typical usage.
Change the type_ctor type to be not simply a sym_name - int pair but a type
with its own identifying type constructor. Change several other types that
were also sym_name - int pairs (mode_id, inst_id, item_name, module_qual.id
and the related simple_call_id) to have their own function symbols too.
compiler/typecheck_info.m:
Add a field to the typecheck_info structure that records the overloaded
symbols encountered.
compiler/typecheck.m:
When processing ambiguous predicate and function symbols, record this
fact in the typecheck_info.
Add a field to the cons_type_info structure to make this possible.
compiler/typecheck_errors.m:
When printing the message about highly ambiguous overloading,
what the overloaded symbols were and where they occurred.
compiler/error_util.m:
Make error_msg_specs usable with plain in and out modes by separating
out the capability requiring special modes (storing a higher order
value in a function symbol) into its own, rarely used type.
Make component_list_to_line_pieces a bit more flexible.
compiler/prog_data.m:
compiler/module_qual.m:
compiler/recompilation.m:
Change the types listed above from being equivalence types (pairs)
to being proper discriminated union types.
compiler/*.m:
Conform to the changes above.
In some cases, simplify the code's use of error_util.
tests/warnings/ambiguous_overloading.{m,exp}:
Greatly extend this test case to test the new functionality.
tests/recompilation/*.err_exp.2
Reflect the fact that the expected messages now use the standard
error_util way of quoting sym_name/arity pairs.
|
||
|
|
459847a064 |
Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18 Branches: main Move the univ, maybe, pair and unit types from std_util into their own modules. std_util still contains the general purpose higher-order programming constructs. library/std_util.m: Move univ, maybe, pair and unit (plus any other related types and procedures) into their own modules. library/maybe.m: New module. This contains the maybe and maybe_error types and the associated procedures. library/pair.m: New module. This contains the pair type and associated procedures. library/unit.m: New module. This contains the types unit/0 and unit/1. library/univ.m: New module. This contains the univ type and associated procedures. library/library.m: Add the new modules. library/private_builtin.m: Update the declaration of the type_ctor_info struct for univ. runtime/mercury.h: Update the declaration for the type_ctor_info struct for univ. runtime/mercury_mcpp.h: runtime/mercury_hlc_types.h: Update the definition of MR_Univ. runtime/mercury_init.h: Fix a comment: ML_type_name is now exported from type_desc.m. compiler/mlds_to_il.m: Update the the name of the module that defines univs (which are handled specially by the il code generator.) library/*.m: compiler/*.m: browser/*.m: mdbcomp/*.m: profiler/*.m: deep_profiler/*.m: Conform to the above changes. Import the new modules where they are needed; don't import std_util where it isn't needed. Fix formatting in lots of modules. Delete duplicate module imports. tests/*: Update the test suite to confrom to the above changes. |
||
|
|
be5b71861b |
Convert almost all the compiler modules to use . instead of __ as
Estimated hours taken: 6 Branches: main compiler/*.m: Convert almost all the compiler modules to use . instead of __ as the module qualifier. In some cases, change the names of predicates and types to make them meaningful without the module qualifier. In particular, most of the types that used to be referred to with an "mlds__" prefix have been changed to have a "mlds_" prefix instead of changing the prefix to "mlds.". There are no algorithmic changes. |
||
|
|
5f589e98fb |
Various cleanups for the modules in the compiler directory.
Estimated hours taken: 4 Branches: main Various cleanups for the modules in the compiler directory. The are no changes to algorithms except the replacement of some if-then-elses that would naturally be switches with switches and the replacement of most of the calls to error/1. compiler/*.m: Convert calls to error/1 to calls to unexpected/2 or sorry/2 as appropriate throughout most or the compiler. Fix inaccurate assertion failure messages, e.g. identifying the assertion failure as taking place in the wrong module. Add :- end_module declarations. Fix formatting problems and bring the positioning of comments into line with our current coding standards. Fix some overlong lines. Convert some more modules to 4-space indentation. Fix some spots where previous conversions to 4-space indentation have stuffed the formatting of the code up. Fix a bunch of typos in comments. Use state variables in more places; use library predicates from the sv* modules where appropriate. Delete unnecessary and duplicate module imports. Misc. other small cleanups. |
||
|
|
21685c9e22 |
Improve the error messages generated for determinism errors involving committed
Estimated hours taken: 6
Branches: main
Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.
The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.
compiler/det_analysis.m:
Keep track of goals to the right of the current goal that could fail,
and include them in the error representation if required.
compiler/det_report.m:
Include the list of failing goals to the right in the representations
of determinism errors involving committed committed choice goals.
Convert the last part of this module that wasn't using error_util
to use error_util. Make most parts of this module just construct
error message specifications; print those specifications (using
error_util) in only a few places.
compiler/hlds_out.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
compiler/compiler_util.m:
Error_util is still changing reasonably often, and yet it is
included in lots of modules, most of which need only a few simple
non-parse-tree-related predicates from it (e.g. unexpected).
Move those predicates to a new module, compiler_util.m. This also
eliminates some undesirable dependencies from libs to parse_tree.
compiler/libs.m:
Include compiler_util.m.
compiler/notes/compiler_design.html:
Document compiler_util.m, and fix the documentation of some other
modules.
compiler/*.m:
Import compiler_util instead of or in addition to error_util.
To make this easier, consistently use . instead of __ for module
qualifying module names.
tests/invalid/det_errors_cc.{m,err_exp}:
Add this new test case to test the error messages for cc contexts.
tests/invalid/det_errors_deet.{m,err_exp}:
Add this new test case to test the error messages for unifications
inside function symbols.
tests/invalid/Mmakefile:
Add the new test cases.
tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
Change the expected output to conform to the change in det_report.m,
which is now more consistent.
|
||
|
|
f9fe8dcf61 |
Improve the error messages generated for determinism errors involving committed
Estimated hours taken: 8
Branches: main
Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.
The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.
compiler/det_analysis.m:
Keep track of goals to the right of the current goal that could fail,
and include them in the error representation if required.
compiler/det_report.m:
Include the list of failing goals to the right in the representations
of determinism errors involving committed committed choice goals.
Convert the last part of this module that wasn't using error_util
to use error_util. Make most parts of this module just construct
error message specifications; print those specifications (using
error_util) in only a few places.
compiler/hlds_out.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
compiler/compiler_util.m:
Error_util is still changing reasonably often, and yet it is
included in lots of modules, most of which need only a few simple
non-parse-tree-related predicates from it (e.g. unexpected).
Move those predicates to a new module, compiler_util.m. This also
eliminates some undesirable dependencies from libs to parse_tree.
compiler/libs.m:
Include compiler_util.m.
compiler/notes/compiler_design.html:
Document compiler_util.m, and fix the documentation of some other
modules.
compiler/*.m:
Import compiler_util instead of or in addition to error_util.
To make this easier, consistently use . instead of __ for module
qualifying module names.
tests/invalid/det_errors_cc.{m,err_exp}:
Add this new test case to test the error messages for cc contexts.
tests/invalid/det_errors_deet.{m,err_exp}:
Add this new test case to test the error messages for unifications
inside function symbols.
tests/invalid/Mmakefile:
Add the new test cases.
tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
Change the expected output to conform to the change in det_report.m,
which is now more consistent.
|
||
|
|
b2012c0c0e |
Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst'
Estimated hours taken: 8 Branches: main compiler/*.m: Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst' and 'mer_mode'. This is to avoid the need to parenthesize these type names in some contexts, and to prepare for the possibility of a parser that considers those words to be reserved words. Rename some other uses of those names (e.g. as item types in recompilation.m). Delete some redundant synonyms (prog_type, mercury_type) for mer_type. Change some type names (e.g. mlds__type) and predicate names (e.g. deforest__goal) to make them unique even without module qualification. Rename the function symbols (e.g. pure, &) that need to be renamed to avoid the need to parenthesize them. Make their replacement names more expressive. Convert some more modules to four space indentation. Avoid excessively long lines, such as those resulting from the automatic substitution of 'mer_type' for 'type'. |
||
|
|
d609181cb9 |
Consider types of the form
Estimated hours taken: 30
Branches: main
Consider types of the form
:- type x ---> f.
to be dummy types, since they contain no information. Optimize them the same
way we currently optimize io.state and store.store.
runtime/mercury_type_info.h:
Add a new type_ctor_rep for dummy types.
runtime/mercury_tabling.h:
Add a representation for "tabled" dummy types, which don't actually
have a level in the trie, so that the runtime system can handle that
fact.
runtime/mercury_ml_expand_body.h:
When deconstructing a value of a dummy type, ignore the actual value
(since it will contain garbage) and instead return the only possible
value of the type.
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.c:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
library/rtti_implementation.m:
Handle the type_ctor_rep of dummy types.
runtime/mercury_builtin_types.c:
Provide a place to record profiling information about unifications and
comparisons for dummy types.
runtime/mercury_mcpp.h:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
Add a new type_ctor_rep for dummy types, and fix some previous
discrepancies in type_ctor_reps.
mdbcomp/prim_data.m:
Move a bunch of predicates for manipulating special_pred_ids here from
the browser and compiler directories.
Rename the function symbols of the special_pred_id type to avoid the
need to parenthesize the old `initialise' function symbol.
Convert to four-space indentation.
mdbcomp/rtti_access.m:
Don't hardcode the names of special preds: use the predicates in
prim_data.m.
Convert to four-space indentation.
browser/declarative_execution.m:
Delete some predicates whose functionality is now in
mdbcomp/prim_data.m.
compiler/hlds_data.m:
Replace the part of du type that says whether a type an enum, which
used to be a bool, with something that also says whether the type is a
dummy type.
Convert to four-space indentation.
compiler/make_tags.m:
Compute the value for the new field of du type definitions.
compiler/hlds_out.m:
Write out the new field of du type definitions.
compiler/rtti.m:
Modify the data structures we use to create type_ctor_infos to allow
for dummy types.
Convert to four-space indentation.
compiler/type_ctor_info.m:
Modify the code that generates type_ctor_infos to handle dummy types.
compiler/type_util.m:
Provide predicates for recognizing dummy types.
Convert to four-space indentation.
compiler/unify_proc.m:
Generate the unify and compare predicates of dummy types using a new
code scheme that avoids referencing arguments that contain garbage.
When generating code for unifying or comparing other types, ignore
any arguments of function symbols that are dummy types.
Don't use DCG style access predicates.
compiler/higher_order.m:
Specialize the unification and comparison of values of dummy types.
Break up an excessively large predicate, and factor out common code
from the conditions of a chain of if-then-elses.
compiler/llds.m:
For each input and output of a foreign_proc, include a field saying
whether the value is of a dummy type.
compiler/pragma_c_gen.m:
Fill in the new fields in foreign_proc arguments.
compiler/hlds_goal.m:
Rename some predicates for constructing unifications to avoid
unnecessary ad-hoc overloading. Clarify their documentation.
Rename a predicate to make clear the restriction on its use,
and document the restriction.
Add a predicate for creating simple tests.
Add a utility predicate for setting the context of a goal directly.
compiler/modules.m:
Include dummy types interface files, even if they are private to the
module. This is necessary because with the MLDS backend, the generated
code inside the module and outside the module must agree whether a
function returning a value of the type returns a real value or a void
value, and this requires them to agree on whether the type is dummy
or not.
The impact on interface files is minimal, since very few types are
dummy types, and changing a type from a dummy type to a non-dummy type
or vice versa is an ever rarer change.
compiler/hlds_pred.m:
Provide a representation in the compiler of the trie step for dummy
types.
compiler/layout_out.m:
Print the trie step for dummy types.
compiler/table_gen.m:
Don't table values of dummy types, and record the fact that we don't
by including a dummy trie step in the list of trie steps.
compiler/add_pragma.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/aditi_builtin_ops.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/det_report.m:
compiler/exception_analysis.m:
compiler/inst_match.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/opt_util.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/qual_info.m:
compiler/rl.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/rtti_out.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_norm.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_gen.m:
Conform to the changes above.
compiler/export.m:
compiler/exprn_aux.m:
compiler/foreign.m:
compiler/polymorphism.m:
compiler/proc_label.m:
compiler/rtti_to_mlds.m:
compiler/special_pred.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/state_var.m:
compiler/switch_util.m:
compiler/trace_params.m:
Conform to the changes above.
Convert to four-space indentation.
compiler/mlds_to_java.m:
compiler/var_locn.m:
Conform to the changes above, which requires threading the module_info
through the module.
Convert to four-space indentation.
compiler/mercury_compile.m:
Pass the module_info to mlds_to_java.m.
compiler/ml_util.m:
compiler/polymorphism.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
Delete some previously missed references to the temporary types used
to bootstrap the change to the type_info type's arity.
compiler/polymorphism.m:
Turn back on an optimization that avoids passing parameters (such as
type_infos) to foreign_procs if they are not actually referred to.
compiler/prog_data.m:
Convert to four-space indentation.
library/svvarset.m:
Add a missing predicate.
trace/mercury_trace.c:
Delete the unused function that used to check for dummy types.
tests/debugger/field_names.{m,inp,exp}:
Add to this test case a test of the handling of dummy types. Check that
their values can be printed out during normal execution, and that the
debugger doesn't consider them live nondummy variables, just as it
doesn't consider I/O states live nondummy variables.
|
||
|
|
b54ab42d70 |
A simple tool for performing substitutions on the source files of the
Estimated hours taken: 0.5 Branches: main tools/subst: A simple tool for performing substitutions on the source files of the compiler. compiler/*.m: Change the names of the get predicates operating on module_infos to include "get" in the name, for uniformity. This was done mostly by the following sed script, with some manual cleanup afterwards to reduce excessive line lengths. s/module_info_types/module_info_get_type_table/ s/module_info_set_types/module_info_set_type_table/ s/module_info_insts/module_info_get_inst_table/ s/module_info_set_insts/module_info_set_inst_table/ s/module_info_modes/module_info_get_mode_table/ s/module_info_set_modes/module_info_set_mode_table/ s/module_info_ctors/module_info_get_cons_table/ s/module_info_set_ctors/module_info_set_cons_table/ s/module_info_classes/module_info_get_class_table/ s/module_info_set_classes/module_info_set_class_table/ s/module_info_instances/module_info_get_instance_table/ s/module_info_set_instances/module_info_set_instance_table/ s/module_info_superclasses/module_info_get_superclass_table/ s/module_info_set_superclasses/module_info_set_superclass_table/ s/module_info_assertion_table/module_info_get_assertion_table/ s/module_info_exclusive_table/module_info_get_exclusive_table/ s/module_info_ctor_field_table/module_info_get_ctor_field_table/ s/module_info_name/module_info_get_name/ s/module_info_globals/module_info_get_globals/ s/module_info_contains_foreign_types/module_info_get_contains_foreign_types/ s/module_info_num_errors/module_info_get_num_errors/ s/module_info_type_ctor_gen_infos/module_info_get_type_ctor_gen_infos/ s/module_info_stratified_preds/module_info_get_stratified_preds/ s/module_info_unused_arg_info/module_info_get_unused_arg_info/ s/module_info_exception_info/module_info_get_exception_info/ s/module_info_type_spec_info/module_info_get_type_spec_info/ s/module_info_no_tag_types/module_info_get_no_tag_types/ s/module_info_analysis_info/module_info_get_analysis_info/ s/module_info_aditi_top_down_procs/module_info_get_aditi_top_down_procs/ |
||
|
|
477d041397 |
This is step 2 of eliminating the arguments of the type_ctor_info, type_info,
Estimated hours taken: 8 Branches: main This is step 2 of eliminating the arguments of the type_ctor_info, type_info, base_typeclass_info and typeclass_info type constructors. This step changes the arity of those type constructors from 1 to 0, and starts generating references to them again. Due to bootstrapping issues, we can't delete the zero_type_ctor_info, zero_type_info, zero_base_typeclass_info and zero_typeclass_info types yet; that will be step 3. library/private_builtin.m: Change the arity of those type constructors. runtime/mercury_builtin_types.m: Update the unify and compare predicates of the old type constructors for their new arity. compiler/polymorphism.m: compiler/size_prof.m: compiler/type_util.m: Generate references to the newly arity-0 old type constructions. compiler/type_ctor_info.m: compiler/type_util.m: trace/mercury_trace_vars.c: Update references to the old types to reflect their new arities. compiler/type_ctor_info.m: There are no more fake arities. library/io.m: library/rtti_implementation.m: library/string.m: library/table_builtin.m: Update references to the old types for their new arities. |
||
|
|
99293279e6 |
This is step 1 of eliminating the arguments of the type_ctor_info, type_info,
Estimated hours taken: 8 Branches: main This is step 1 of eliminating the arguments of the type_ctor_info, type_info, base_typeclass_info and typeclass_info type constructors. This step doesn't delete those arity-1 type constructors yet; that will be done in step 2. This delay due to bootstrapping issues: installed compilers still generate references to those type constructors. However, after this change, compilers will instead generate references to arity-0 versions of those types named zero_type_ctor_info, zero_type_info, zero_base_typeclass_info and zero_typeclass_info. library/private_builtin.m: Add the new type constructors. For each predicate that operates on the old arity-1 type constructors, add a version that operates on the new type arity-0 onstructors, and whose implementation is identical. runtime/mercury_builtin_types.m: Add the unify and compare predicates of the new type constructors. runtime/mercury_wrapper.[ch]: runtime/mercury_init.h: util/mkinit.c: Change the C type of the variable that holds the types of type_infos and pseudo_type_infos, since their representation is now simpler (no dummy argument). trace/mercury_trace_vars.c: Modify data structures that recognize the four old types to recognize their new variants as well. compiler/higher_order.m: compiler/polymorphism.m: Generate references to the new versions of predicates that manipulate type_infos and typeclass_infos. compiler/hlds_pred.m: compiler/ml_code_util.m: compiler/type_ctor_info.m: Modify predicates that recognize the four old types to recognize their new variants as well. compiler/type_util.m: Modify the predicates that construct the types of type_infos to create references to the new arity-0 type constructors. Modify predicates that recognize the four old types to recognize their new variants as well. Delete the predicate whose job was to replace the dummy arguments of the arity-1 type constructors with the void type, since it is not needed anymore. Delete the unused predicate cell_type_name. compiler/stack_layout.m: Fix comment. compiler/size_prof.m: Conform to the changes in type_util. compiler/pseudo_type_info.m: Conform to the changes in type_util. Convert to four-space indentation. |
||
|
|
3fc6b3f128 |
Change the representation of types in the compiler.
Estimated hours taken: 30 Branches: main Change the representation of types in the compiler. We also add some support for handling kinds, which will be used later when we have a kind system. There are a number of places where kinds are not yet handled correctly -- we assume that all kinds will be `star'. Each of these locations is flagged with a comment that contains "XXX kind inference:". compiler/prog_data.m: Implement the new version of type (type). Change the definition of type_param to be a variable instead of a term, since all parameters must be variables anyway. Implement versions of varset.merge_* which work with tvarsets and produce renamings instead of substitutions. Renamings are more convenient than substitutions because we don't need to know the kinds of type variables in order to build the renaming, and in any case the substitutions shouldn't have anything other than variables in the range so renamings will be more efficient and safe. Define the type of kinds, and provide a couple of utility predicates to operate on them. compiler/prog_io.m: Parse type definition heads as a sym_name and list of type_params, rather than a functor. Handle this change in other predicates. Allow parse errors to be returned by get_with_type/3, and handle these errors. Remove parse_type/2. This predicate didn't do any processing, it just forwarded handling to convert_type/2. compiler/prog_io_typeclass.m: Change type_is_functor_and_vars to handle the new representation of types. In doing so, we retain the old behaviour that pure predicates pass this test, but no other pred or func types. This behaviour is arguably incorrect, but there is little point changing the behaviour at the moment. Instead we should remove these kind of restrictions entirely, but that should be done later. compiler/prog_io_util.m: Provide predicates to both parse and unparse types. We need to unparse types before printing them out, since we do a lot of special case handling when printing out terms and we don't want to duplicate this functionality for types. compiler/module_qual.m: Remove report_invalid_type. We now report ill-formed types during parsing. compiler/superhomogeneous.m: Handle errors from the parsing of type expressions. compiler/prog_out.m: Provide a predicate to convert builtin_types to their string names, and vice-versa. compiler/prog_type.m: Add a bunch of simple tests to use on types which may have kind annotations present. In such cases, types do not have a canonical representation so the simple handling of these tests is not what we want. (Note that these are only required in early phases. The kind annotations -- when they are implemented -- will be removed before type checking.) Consistently handle the application of renamings, substitutions and recursive substitutions to various data structures. compiler/mercury_to_mercury.m: Implement mercury_output_type, mercury_format_type and mercury_type_to_string. These convert the type to a term before formatting -- the reason for this is so that appropriate parentheses are used when formatting operators. This results in some slight changes to error messages, which are reflected in changes to the expected output files in the tests. Remove the old version of mercury_type_to_string. Change the argument ordering of mercury_format_var to be consistent with mercury_format_type. (Other predicates in this module should probably be changed in a similar way, since this argument ordering is more amenable to higher-order programming. But that can be left for another change.) compiler/type_util.m: Implement type unification. The behaviour is much the same as the previous behaviour, except that we now handle apply/N types properly, and we also allow for kind annotations. Implement an occurs check for types. Remove the example definition of replace_eqv_type. It isn't used and would no longer work anyway even if it would have worked before. Add a tvar_kind_map field to ctor_defn. The functions type_info_type and type_ctor_info_type now return types with `void' as their argument, rather than the type that the type_info or type_ctor_info was for. Remove type_util.real_vars/2, since it no longer does anything different from prog_type.vars/2. Remove the commented out implementation of type_to_ctor_and_args/3. Its implementation is in prog_type.m, and has changed significantly in any case. compiler/add_clause.m: Move parse_purity_annotation/3 to prog_io_util.m. compiler/check_typeclass.m: Remove apply_substitution_to_var_list/3, since we now have predicates in prog_type.m to handle such things. compiler/continuation_info.m: compiler/trace.m: Use prog_type.vars/2 instead of type_util.real_vars/2. The two predicates have the same meaning now since type_infos don't contain any type variables. compiler/hlds_data.m: Add tvar_kind_map fields to hlds_type_defn and hlds_class_defn. compiler/hlds_pred.m: Add a tvar_kind_map field to pred_info. compiler/polymorphism.m: Add a tvar_kind_map field to poly_info. Remove unify_corresponding_types, which is no longer used. compiler/hlds_out.m: Use mercury_output_type/5 instead of term_io__write_term/4 and mercury_output_term/5. compiler/post_typecheck.m: Build the void substitution directly rather than building intermediate lists. compiler/recompilation.version.m: Use term__list_subsumes instead of type_list_subsumes, which now operates only on types. This follows up on what was suggested in an XXX comment. compiler/typecheck_errors.m: Use unparse_type/2 to format error messages. compiler/typecheck_info.m: Don't export write_type_with_bindings/5. It is no longer used outside of this module. compiler/*.m: Conform to the above changes. library/rtti_implementation.m: Fix a syntax error that went undetected in our previous implementation, and amazingly enough was compiled correctly anyway. library/term.m: Move the versions of term__unify, term__unify_list and term__list_subsumes that were implemented specifically for types to here. The version of term_unify that takes a list of bound variables (i.e., variables that should not be bound any further) is used by the subsumption check, which in turn is used by recompilation.version.m. tests/invalid/kind.err_exp: tests/invalid/tc_err1.err_exp: tests/invalid/tc_err2.err_exp: tests/misc_tests/pretty_print_test.exp: Update the expected output of these tests to match what we now do. |
||
|
|
10536c5ee0 |
Divide make_hlds.m into submodules of manageable size.
Estimated hours taken: 12 Branches: main Divide make_hlds.m into submodules of manageable size. compiler/make_hlds.m: Distribute all the code that was previously here to new submodules. Include those submodules. Keep the existing interface of this module by defining predicates that do nothing except call the actual implementation in one of those submodules. The only changes visible from outside are the renaming of a predicate and the creation of a second name, make_hlds_qual_info, for qual_info. Both changes are designed to avoid ambiguity in the presence of intermodule optimization. compiler/add_aditi.m: Submodule for dealing with aditi-specific issues. compiler/add_class.m: Submodule for handling typeclasses. compiler/add_clause.m: Submodule for handling the general processing of clauses. compiler/add_pred.m: Submodule for handling new predicates. compiler/add_special_pred.m: Submodule for handling special (unify/compare/index/init) predicates. compiler/add_type.m: Submodule for handling new types. compiler/add_mode.m: Submodule for handling new insts and modes. compiler/add_solver.m: Submodule for handling new solver types. compiler/add_pragma.m: Submodule for handling new pragmas. compiler/state_var.m: Submodule for handling the state variable transformation. compiler/superhomogeneous.m: Submodule for converting clauses to superhomogeneous form. compiler/field_access.m: Submodule for field access syntax. compiler/make_hlds_passes.m: Submodule containing the code that performs passes on the item list, adding things to the HLDS, calling the other submodules as necessary. compiler/make_hlds_warn.m: Submodule that looks for constructs that merit warnings. compiler/make_hlds_error.m: Submodule containing error messages used by more than one submodule. compiler/hlds_pred.m: Since this module defines the clauses_info and proc_id types, move the predicates that initialize values of that type here as well from make_hlds.m (deleting an unnecessary parameter from one). compiler/hlds_pred.m: compiler/prog_data.m: Move the type tvar_name_map from from hlds_pred.m to prog_data.m, since that is where similar maps are. compiler/check_typeclass.m: compiler/mercury_compile.m: Conform to the change to make_hlds_qual_info. compiler/hlds_out.m: compiler/prog_out.m: Replace two identical predicates for printing out lists of strings in hlds_out.m and make_hlds.m with just one in prog_out.m, since that is where it belongs in the compiler. compiler/prog_util.m: Move some utility predicates for substitutions and term recognition here from make_hlds.m, since they are needed by more than one submodule. Make this module conform to our coding guidelines, and convert it to four-space indentation to eliminate bad line breaks. compiler/clause_to_proc.m: compiler/hlds_code_util.m: compiler/make_tags.m: compiler/prog_mode.m: compiler/quantification.m: compiler/type_util.m: Trivial formatting changes. compiler/notes/compiler_design.html: Describe the new modules. |
||
|
|
38d9ef3479 |
Package the type_info_varmap and typeclass_info_varmap types into an ADT
Estimated hours taken: 25 Branches: main Package the type_info_varmap and typeclass_info_varmap types into an ADT called rtti_varmaps. There are two main purposes for this: - We wish to extend this set of maps with new maps. Doing this will be a lot easier and less error prone if all of the maps are packaged in a single data structure. - Any new maps that we add may contain redundant information that just makes searching the maps more efficient. Therefore they must be kept consistent with the existing maps. Having all the maps inside an ADT makes it easier to ensure this. This change also includes two extensions to the maps. First, the typeclass_info_map is made reversible so that it is possible to efficiently look up the constraint for a given typeclass_info variable. Second, a new map from prog_vars to types makes it possible to efficiently look up the type that a given type_info variable is for. These two changes mean that it is no longer necessary to consult the argument of type_info/1 or typeclass_info/1 to find this information. (We still do put that information there, though; changing the RTTI is left for a separate change.) compiler/hlds_pred.m: Move items relating to type_infos and typeclass_infos into a section of their own. Add a type `rtti_var_info' to hold information about the contents of a type_info or typeclass_info variable. Define the rtti_varmaps abstract data type. This data structure consists of the type_info_varmap and the typeclass_info_varmap. Add a new map, type_info_type_map, which is like the inverse to the type_info_varmap. The difference is that the latter can point to locations that are inside a typeclass_info variable, whereas the former only refers to type_info variables. Note that the combined maps do not form a bijection, or even an injection, since it is possible for two different type variables to point to the same location (that is, if they are aliased). Make the typeclass_info_varmap reversible, by using the new module injection.m. Unlike the type_info_varmap, this map is always injective since the same typeclass_info cannot be used for two different constraints. The predicates rtti_det_insert_type_info_locn and set_type_info_locn, which update the type_info_varmap, contain sanity checks to ensure that only type variables that have already been registered with the type_info_type_map are used, and that the information in both maps is consistent. Use the rtti_varmaps structure in proc_info and clauses_info, in place of type_info_varmap and typeclass_info_varmap. compiler/polymorphism.m: Remove polymorphism__type_info_or_ctor_type/2 and polymorphism__typeclass_info_class_constraint/2, to ensure that nobody tries to use the information in the type argument. Replace them with two similar predicates that test if a type is type_info or typeclass_info, but that don't return the argument. Ensure that the new type_info_type_map in the rtti_varmaps is kept up to date by threading the rtti_varmaps through a few more places. Some of these places are exported, so this part of the change affects other modules as well. Fix a comment that referred to a non-existent predicate. compiler/type_util.m: Remove the predicates apply_substitutions_to_var_map/5 and apply_substitutions_to_typeclass_var_map/5. The functionality is now provided by the new ADT. compiler/cse_detection.m: Rewrite update_existential_data_structures/4 to use the interface provided by rtti_varmaps. The algorithm for doing this has changed in the following ways: - The first pass, which builds a map from changed locations in the first branch to the tvars concerned, is modified slightly to traverse over the keys instead of over key-value pairs. - The second pass, which previously calculated the induced type substitution and reconstructed the type_info_varmap now only does the former. - Applying the prog_var transformation and the induced type substitution is done at the end, using the interface to rtti_varmaps. compiler/goal_util.m: Rewrite goal_util__extra_nonlocal_typeinfos/6 to avoid the need for using map__member/3 on the typeclass_info_varmap (about which the existing comments say "this is probably not very efficient..."), and to be more efficient in general. Previously, we nondeterministically generated non-local type vars and then tested each constraint to see if it had the type var in it. Now, we go through each constraint one at a time and check if any of the type variables in it are non-local. This is more efficient because we only need to find one non-local type in order to include the typeclass_info in the non-locals -- the remaining (duplicate) solutions are pruned away. compiler/higher_order.m: Use the new maps instead of looking at the arguments of type_info/1 and typeclass_info/1 types. We plan to remove this information from type_info and typeclass_info types in future. Previously, this module used the type argument in order to update the varmaps when the curried arguments of a higher order call are added as arguments to the procedure in which the call occurs. We now look up this information at the point where the curried arg variables are known, and store this information in higher_order_arg alongside the types where it used to be stored. This structure is threaded through to the place where the information is needed. Fix a cut and paste bug in higher_order_arg_depth/1. It was previously calling higher_order_args_size/1 in the recursive call, instead of calling higher_order_args_depth/1. compiler/inlining.m: In inlining__do_inline_call, apply the substitutions to the entire rtti_varmaps structure, not just to the type_info_varmap. (XXX Is there a good reason why the substitution should _not_ be applied to the typeclass_info varmap?) compiler/magic_util.m: Avoid using polymorphism__type_info_or_ctor_type/2 and polymorphism__typeclass_info_class_constraint/2, as these are no longer supported. compiler/*.m: Straightforward changes to use the new ADT. library/injection.m: New library module. This provides an `injection' type which is similar to the existing `bimap' type in that it implements back-to-back maps, but doesn't have such stringent invariants imposed. In particular, the reverse map is not required to be injective. This type is used to model the relationship between prog_constraints and program variables that hold typeclass_infos for them. Namely, the typeclass_info for a constraint can be held in two different variables, but one variable can never hold the typeclass_info for two distinct constraints. library/library.m: Add the new library module. library/list.m: Add list__foldl_corresponding and list__foldl2_corresponding, which traverse two lists in parallel, which one or two accumulators, and abort if there is a length mismatch. NEWS: Mention the changes to the standard library. |
||
|
|
d075d35702 |
Implement functional dependencies for the typeclass system.
Estimated hours taken: 240 Branches: main Implement functional dependencies for the typeclass system. The implementation has two major parts. First, some of the basic checks of constraints are relaxed. These used to occur in make_hlds but that functionality has now been moved to check_typeclass. We also add a range of new tests to ensure that the FDs are used correctly. Second, an "improvement" pass to context reduction is added. This looks for constraints which match certain rules, and when it finds them updates the current bindings. The general rule is that type variables become more instantiated, but only in a way which provably does not affect the satisfiability of the constraints. XXX The plan for this change is to put the context reduction into a new module check_hlds.typeclasses.m, but I have left the code in typecheck.m for the moment because the diff will be easier to review that way. Moving to the new module will also remove the problem of one particular function being implemented in both typecheck and hlds_data, which is flagged by an XXX in the code. XXX the check for consistency of instances is not yet complete. We check all visible instances, but not instances that are only present at link time. We could check these in a similar way to the check for overlapping instances (that is, by defining a symbol that will conflict and cause a link error if there are overlapping instances), but in the long run a better solution will be required. Producing this is left for a later change. compiler/check_typeclass.m: Check for ambiguities in typeclass constraints here, rather than make_hlds. We check by calculating the closure of the bound type variables under the induced functional dependencies. This pass is merged in with the already existing pass that checks the quantifiers on constrained type variables. Check instances for range-restrictedness and for consistency. When checking for cycles in the typeclass hierarchy, build up the set of ancestors of a class which have FDs on them. This set is used when searching for opportunities to apply improvement rules during type checking. compiler/hlds_data.m: Define hlds_class_fundeps and add it to to hlds_class_defn. Add a field to hlds_class_defn to store the ancestors which have functional dependencies. Define the type 'instance_id', which is just an integer. This is what is used in proofs to identify instances. In hlds_constraints and in constraint_ids, use the terms 'assumed' and 'unproven' rather than 'existential' and 'universal'. The latter are confusing to use since the treatment of constraints differs depending on whether the constraint is on the head or the body of a clause. Add a field to the hlds_constraints for redundant constraints. These are constraints that have either already been reduced or don't need to be reduced, which may contribute to improvement of types. Define some new predicates for initialising and updating the hlds_constraints. compiler/type_util.m: Accommodate the change to hlds_constraints. compiler/hlds_out.m: Output the functional dependencies. compiler/intermod.m: Reconstruct a functional dependency from the HLDS, for outputting. compiler/make_hlds.m: Convert functional dependencies from parse tree form and add them to the HLDS. Check that functional dependencies are identical in subsequent definitions of the same typeclass. Don't check for ambiguity here. That is now done in check_typeclass. compiler/mercury_to_mercury.m: Output functional dependencies in typeclass declarations. compiler/prog_data.m: Define prog_fundeps and add them to the parse tree. compiler/prog_io_typeclass.m: Parse functional dependencies on typeclass declarations. compiler/typecheck.m: Require the class_table to be passed to reduce_context_by_rule_application, since the functional dependencies are stored here. Also thread the bindings argument through, since the bindings may be improved by context reduction. Save the resulting bindings in the type_assign. Instead of passing a list of assumed constraints and threading the unproven constraints through context reduction, thread through a hlds_constraints structure. This contains more information about redundant constraints than just the two lists. Extend context reduction with two new passes. The first applies the "class" FD rule, which tries to find two constraints which are identical on the domain of some FD, and then unifies the range arguments. The pair of constraints are either both redundant constraints, or one redundant constraint and one assumed constraint. The second applies the "instance" FD rule, which for each constraint tries to find an instance which is more general on the domain arguments. It then binds the instance arguments and unifies the range arguments of the instance with those of the constraint. When calculating the head_type_params for a predicate, include all variables that occur in universal constraints, since these may not necessarily occur in the arguments. Rename some variables: use variable prefixes "Pred" and "Parent" for types that are from the callee or that have been renamed apart respectively. This follows the same naming scheme used in polymorphism. Remove the headtypes/0 type, and use head_type_params/0 throughout. Add a new kind of cons_error for using "new" on a constructor that is not existentially typed. We check for this situation in convert_cons_defn, and report it in report_cons_error. Pass a value to convert_cons_defn indicating whether the constraints should be flipped or not, and whether the context is a constructor that uses 'new'. We flip the constraints here rather than after the fact, since creating the constraints now requires some extra processing to be done, and we don't want to have to redo that processing. Add a constant function that specifies whether variable numbers should be displayed as part of the debugging output. This is currently set to 'yes' but the previous behaviour can be achieved by changing the value to 'no'. doc/reference_manual.texi: Document the new feature. NEWS: Announce the new feature. tests/*: New test cases. compler/*.m: Minor changes related to the above. compiler/error_util.m: Fix comment grammar. compiler/prog_type.m: Fix an incorrect comment. |
||
|
|
4427723508 |
Remove the assumption made by polymorphism.m that all type variables
Estimated hours taken: 240
Branches: main
Remove the assumption made by polymorphism.m that all type variables
appearing in class constraints also appear in the type being constrained.
This is a first step towards adding functional dependencies, since in the
presence of functional dependencies (or "improvement" in general) this
assumption no longer holds.
The assumption made by polymorphism manifests itself in the fact that
constraints on atomic goals are reconstructed by unifying the types of
formal parameters with the types of actual arguments, and then applying
the resulting substitution to the constraints. Any type variables in
constraints that don't appear in the formal parameters will therefore
remain unbound.
This change overcomes the assumption by building up a map from constraint
identifiers to constraints during typechecking, and then looking up this
map in order to reconstruct the constraint during the polymorphism
transformation.
To support this, the type 'class_constraint' has been removed and replaced
by two distinct types, 'prog_constraint' and 'hlds_constraint'. The former
is part of the parse tree and holds the same information as the old
class_constraint. The latter is part of the HLDS, and is used during
typechecking; in addition to the information in prog_constraints, it also
stores a set of identifiers that represent where the constraint came from.
These identifiers are used as the keys in the aforementioned map.
At this stage the constraint identifiers are only used by typechecking to
build the constraint map. Other passes use either prog_constraints or
hlds_constraints with an empty set of identifiers.
compiler/hlds_data.m:
Define the constraint_id type, which is used to uniquely identify
class constraints. A better scheme than this one has been suggested,
but that will be left to a later change. An XXX comment to that
effect has been added.
Define the hlds_constraint type, which is like prog_constraint but
it also includes a set of constraint_ids. Define a set of predicates
to initialise and manipulate these.
Define the constraint_map type here. Move the definition of
constraint_proof_map to here, where it more sensibly belongs.
Update the comments in hlds_instance_defn slightly, with information
that I found I needed to know when making this change.
compiler/hlds_pred.m:
Add a field to the pred_info to store the constraint_map.
Move the definition of constraint_proof_map from here.
compiler/hlds_out.m:
Print out a representation of the constraint map if it isn't empty.
compiler/type_util.m:
Change the predicates that used to operate on class_constraints so
that they now operate on hlds_constraints. The old versions of these
predicates have now moved to prog_util.
Add some utility predicates to manipulate constraint_maps.
Add a predicate to apply a variable renaming to constraint_proof_maps.
compiler/prog_data.m:
Rename class_constraint(s) to prog_constraint(s).
compiler/prog_util.m:
Provide a set of predicates for manipulating prog_constraints.
compiler/typecheck.m:
Ensure that goal_paths are filled in before the first iteration
of typechecking.
Pass the hlds_goal_info down through typecheck_goal_2 so that the
goal_path can be retrieved when needed to assign identifiers to
constraints. Thread the goal_path through to wherever it is needed.
Store hlds_constraints in the args_type_assign rather than
prog_constraints, so that the required information is available
when creating the new set of type_assigns. Do likewise for the
cons_type_info type. Don't pass the module_info through
make_pred_cons_info*, since it isn't used. Do pass the goal_path,
though, so that constraints in cons_type_infos can be given the
correct identifier.
Add a constraint_map field to the typecheck_info, initialised to empty.
When retrieving the final information from a typecheck_info, return
the resulting constraint_map, after applying any type bindings.
Ensure that any constraints that may not have been entered into the
constraint_map are put there now. Call the new predicate in type_util
to rename the constraint_proof_map, rather than doing it longhand
here.
Make the following changes to context reduction:
- Thread the constraint_map through, so that it can be updated
as constraints are eliminated.
- Instead of simply calling sort_and_remove_dups on the
set of constraints remaining after one iteration, merge the
constraints in such a way that the complete set of
constraint_ids is retained.
- Disregard the constraint_ids when deleting newly introduced
constraints that are equivalent to constraints that have
already been seen.
- Simplify the code of find_matching_instance_rule_2 by
moving the deterministic code out of the condition of the
if-then-else.
Move find_first_map into the library.
compiler/polymorphism.m:
Ensure that the goal_path is set when constructing lambda goals.
In process_call, look up the constraints in the constraint_map
using the goal_path as part of the key, rather than calculating
the constraints by applying the ParentToActual type substitution.
Rearrange this code so that it is divided into easier to understand
blocks.
Add a field to the poly_info to store the constraint_map, and
initialise it from the pred_info.
compiler/goal_path.m:
Fill slots in lambda_goals, since constraints inside these will
otherwise not be identified properly. The goal_paths inside here
do not entirely make sense, since there is no goal_path_step for
the lambda_goal itself. However, there is enough information
retained to distinguish these goal_paths from any other possible
goal_path, which is all that we require to identify constraints.
Add a warning not to fill in the goal slots between the typechecking
and polymorphism passes, since doing so could potentially render the
constraint_maps incorrect.
compiler/make_hlds.m:
Initialise the constraint_map to empty in pred_infos.
Move the code for updating the superclass_table into a separate
predicate. Initially this change was made because, in an earlier
version of the change, the superclass_table had some extra
information that needed to be filled in. That part of the change
is not needed in this diff, but the new predicate simplifies the
code a bit so I've left it there.
compiler/check_typeclass.m:
Convert the prog_constraints into hlds_constraints before passing
them to typecheck.reduce_context_by_rule_application. They are
assigned no identifiers, since these constraints are not required
to be put into the constraint map.
Change the name of the function get_constraint_id to
get_constraint_class_id, since it would now be ambiguous otherwise.
compiler/cse_detection.m:
Import parse_tree__prog_util, since that is where renamings of
prog_constraints are now defined.
compiler/higher_order.m:
Initialise pred_infos here with an empty constraint_map.
compiler/post_typecheck.m:
When binding type vars to void, apply the void substitution to the
constraint_map.
compiler/table_gen.m:
Pass the constraint_map when creating a new pred_info.
compiler/unused_args.m:
Create the pred_info with an empty constraint_map. The constraint_map
won't be used by this stage anyway.
compiler/*.m:
Update to use the new type names. Also update to use the existing
type synonyms typeclass_info_varmap and constraint_proof_map.
Change names of predicates and functions to use prog_constraint
instead of class_constraint, where applicable.
library/list.m:
Add find_first_map from typecheck. Also add find_first_map{2,3},
since at one stage during development I needed find_first_map3, and,
although it's not used in the current diff, there is little point
removing it now.
|
||
|
|
3c60c0e485 |
Change a bunch of modules to import only one module per line, even
Estimated hours taken: 4 Branches: main compiler/*.m: Change a bunch of modules to import only one module per line, even from the library. compiler/mlds_to_il.m: compiler/mlds_to_managed.m: Convert these modules to our current coding style. Use state variables where appropriate. Use predmode declarations where possible. |
||
|
|
a3352a6e5d |
Do not include :- import_module' and :- use_module' declarations
Estimated hours taken: 22 Branches: main Do not include `:- import_module' and `:- use_module' declarations in the implementation section of .int and .int2 files unless the types that they export are required by the definition of an equivalence type. This should help prevent unnecessary recompilations when new imports are made in the implementation of modules. Break up check_hlds.type_util so that predicates that do not require access to the HLDS are placed in a new module, parse_tree.prog_type. The above change requires some of these predicates. This also removes one of the dependencies between the parse_tree package on modules of the check_hlds package. Remove the remaining such dependency by moving inst_constrains_unconstrained_var/1 from check_hlds.inst_util to parse_tree.prog_mode. None of the modules in parse_tree now depend upon modules in check_hlds. Modify the parser so that import_module declarations that specify more than one module are replaced by multiple import_module declarations, with one module per declaration. This makes the above change easier to implement and is in any case required by the upcoming diff for canonicalizing module interfaces. We also do the same for use_module and include_module declarations. compiler/modules.m: Don't import modules in the implementation section of interface files unless they are required by the definition of equivalence types. compiler/prog_type.m: New module. Move procedures from type_util that do not depend on the HLDS to here so that we can use them when generating interface files. XXX There are probably others that could be moved as well - I only moved those that were immediately useful. compiler/type_util.m: Delete the procedures that have been moved to the new prog_type module. compiler/prog_io.m: Remove the dependency on check_hlds.inst_util. compiler/prog_io_typeclass.m: compiler/equiv_type.m: Remove dependencies on check_hlds.type_util. compiler/prog_util.m: Add a predicate sym_name_get_module_name/2 that is similar to sym_name_get_module_name/3 except that it fails if the input is an unqualified sym_name. compiler/inst_util.m: Delete inst_contains_unconstrained_var/1 from this module and copy it to prog_mode.m. compiler/parse_tree.m: Include the new module. Do not import the check_hlds package as all dependencies on this package have been removed. compiler/*.m: Minor changes to conform to the above. compiler/notes/compiler_design.html: Mention the new module. |
||
|
|
59d2d4a573 |
This adds a module mdbcomp__trace_counts that reads in the
Estimated hours taken: 17 Branches: main This adds a module mdbcomp__trace_counts that reads in the .mercury_trace_counts files produced by the compiler's trace mechanism. The format of said files was slightly changed. As the new module is to be used by the compiler and the debugger, it is placed in the mdbcomp module. This required bringing some types from the compiler into a new module within mdbcomp. browser/trace_counts.m: New module for reading execution trace summaries. browser/prim_data.m: New module holding types and predicates moved in from the compiler. Types: pred_or_func, sym_name, module_name, proc_label, special_pred_id, trace_port Predicates: string_to_sym_name, insert_module_qualifier The mode field of proc_label is now an int instead of a proc_id to avoid pulling proc_id into mdbcomp. browser/mdbcomp.m: Add trace_counts and prim_data to the mdbcomp module. browser/declarative_execution.m: Renamed mdb's definition of module_name to flat_module_name to avoid conflicts with the definition in mdbcomp__prim_data. runtime/mercury_trace_base.c: In the format of .mercury_trace_counts, write module and predicate names now use quoted atom syntax so that names with spaces and non-printable characters can be machine-parsed. browser/: compiler/: Many changes to account for movement of types, and the change to proc_label. |
||
|
|
1067d612d2 |
Extend the solver types implementation to handle abstract equivalence solver
Estimated hours taken: 180 Branches: main Extend the solver types implementation to handle abstract equivalence solver types. Fix the automatic initialisation of variables with solver types in atomic goals not in conjunctions. Fix the automatic initialisation of variables with solver types with type parameters (previously we were not inserting the necessary type_info arguments.) Add the modes ia and oa for in(any) and out(any) as built-ins. Correct the solver types documentation to reflect the fact that any \= ground for non-solver types. doc/reference_manual.texi: Previously the documentation stated that inst any was equivalent to inst ground for non-solver types. This is not correct: an (ordinary) list of inst any solver type values, for example, may not be semantically ground and therefore must have any as (some component of) its inst. Document the addition of built-in modes ia and oa. library/builtin.m: Added modes ia and oa as synonyms for in(any) and out(any), respectively. compiler/goal_util.m: Add a version of goal_util__generate_unsafe_cast with two extra inst parameters (needed because solver types typically have inst any rather than ground). compiler/make_hlds.m: Fix a bug whereby the declarations for the initialisation special preds for imported types were being module qualified using the name of the *importing* module. This turns out to be correct for unification and comparison predicates because they are duplicated in every module that needs them, but not for solver type initialisation predicates. compiler/modes.m: Export modes__construct_initialisation_call which is now also called from unify_proc.m. Fix a misleading compiler error message. Rearrange some comments for accuracy. Scheduling of conjunctions now handles the mode_info flag may_initialise_solver_vars slightly differently to support the initialisation of free solver vars in atomic goals not appearing in conjunctions. construct_initialisation_call(s) and prepend_initialisation_call now change the mode_info (and thus does not need the module_info). construct_initialisation_call and build_call are now much more careful about setting up goal_infos, vartypes and instmap_deltas correctly. compiler/modecheck_call.m: Ensure that modecheck_end_of_call properly restores the mode_info may_initialise_solver_vars flag before returning. compiler/modecheck_unify.m: Arrange for one of the solver vars to be initialised in free/free unifications if mode_info_may_initialise_solver_vars is set. XXX Var/functor unification still needs fixing. compiler/mode_info.m: Added mode_info_get_may_initialise_solver_vars. mode_infos are now initialised to have the may_initialise_solver_vars flag set to yes in order to allow the initialisation of solver type goals not appearing in conjunctions. Conjunctions temporarily set this flag to no to try scheduling without inserting initialisation calls. compiler/polymorphism.m: Add new exported pred, process_new_call. This predicate takes the details about a call to be inserted somewhere after the usual polymorphism pass has been run and extends the call with the goals and extra arguments to construct and pass any required type_infos. XXX This predicate does not yet handle calls whose arguments include existentially quantified types or type class constraints. compiler/type_util.m: A type that is equivalent to a solver type is now also considered a solver type. compiler/unify_proc.m: The compiler generated initialisation predicate for an abstract equivalence solver type first calls the initialisation predicate for the RHS of the type equivalence, then casts the result back into the type on the LHS of the type equivalence. |
||
|
|
980afa90c5 |
Add an analysis that tries to identify those procedures
Estimated hours taken: 70 Branches: main Add an analysis that tries to identify those procedures in a module that will not throw an exception. (I guess it may be more accurate to call it a non-exception analysis). For those procedures that might throw exceptions the analysis further tries to distinguish between those that throw an exception as a result of a call to throw and those that throw an exception as a result of a call to a unification/comparison predicate that may involve calls to user-defined equality/comparison predicates that throw exceptions. This sort of thing used to be done by the termination analysis, where being able to prove termination was equated with not throwing an exception. This no longer works now that the termination analyser considers exception.throw/1 to be terminating - and in fact it never quite worked anyway because the termination analyser was not handling things like foreign code and user-defined equality and comparison predicates correctly. There are currently a few limitations, the main ones being: * we currently use transitive-intermodule optimization rather than the intermodule-analysis framework. This may causes problems when their are cycles in the module dependency graph. * we currently assume that all calls to higher-order predicates may result in an exception being thrown. * we currently assume that all foreign procs that make calls back to Mercury may throw exceptions. * we currently assume that all solver types and existentially quantified types might result in an exception being thrown. It should be possible to remove these limitations in later versions. This diff also modifies the cannot_loop_or_throw family of predicates in goal_form.m. There are now two versions of each predicate; one that can make use of information from the termination and exception analyses and one that cannot. compiler/exception_analysis.m: The new analysis. compiler/prog_data.m: compiler/prog_io_pragma.m: Handle `:- pragma exceptions(...' in .opt and .trans_opt files. compiler/hlds_module.m: Attach information to each module about whether each procedure in the module may throw an exception. compiler/goal_form.m: Rewrite the predicates in this module so that they can optionally use information from the exception analysis. compiler/constraint.m: compiler/goal_util.m: compiler/rl.m: compiler/simplify.m: Use information from exception and termination analyses when performing various optimizations. compiler/type_util.m: Add a new predicate type_util.type_is_existq/2 that tests whether a type is existentially quantified or not. compiler/mercury_compile.m: compiler/mercury_to_mercury.m: compiler/modules.m: compiler/options.m: compiler/module_qual.m: compiler/make_hlds.m: compiler/recompilation.version.m: compiler/trans_opt.m: compiler/transform_hlds.m: Minor changes needed by the above. NEWS: compiler/notes/compiler_design.html: doc/user_guide.texi: Mention the new analysis. tests/README: Include a description of the term directory. tests/term/Mercury.options: tests/term/Mmakefile: tests/term/exception_analysis_test.m: tests/term/exception_analysis_test.trans_opt_exp: Add a test for the new analysis. |
||
|
|
f8312974e4 |
Bugfixes (mostly) related to the recent solver types changes.
Estimated hours taken: 3 Branches: main Bugfixes (mostly) related to the recent solver types changes. compiler/type_util.m: Having the compiler assume that type variables denote solver types causes the compiler to throw an exception when it tries to compile the initialisation forwarding predicate for exported abstract type foo(T) defined as foo(T) == T. The right solution at some point is to introduce a solver type class. type_util__is_solver_type no longer assumes that type variables denote solver types. compiler/prog_io.m: Fixed a bug in make_maybe_where_details where a solver type without user defined equality or comparison would get a `yes(unify_compare(no, no))' result rather than just `no'. tests/invalid/partial_implied_mode.err_exp2: Copy of partial_implied_mode.err_exp, but with different temporary variable names in the expected compiler errors. tests/invalid/any_mode.m: tests/invalid/any_mode.err_exp: tests/invalid/any_should_not_match_bound.m: tests/invalid/any_should_not_match_bound.err_exp: Updated code and expected error. tests/misc_tests/pretty_print_test.exp: Corrected expected error. |
||
|
|
bf2e37d199 |
Implemented the solver types design.
Estimated hours taken: 100s Branches: main Implemented the solver types design. Solver types provide the means for adding constrained types to Mercury programs. A variable of a constrained type may have constraints placed on it, limiting the values it may be bound to, *before* the variable is actually bound to a particular value (cf. CLP(Z), CLP(R), CLP(FD) etc.) Improve the scheduling of solver type goals by preferring deconstructions over constructions followed by unifications. This is arranged by allowing solver type initialisation calls to be inserted only when all else fails. (XXX This implementation is O(n^2). I will fix things if this becomes an issue in practice.) I have also made some small, opportunistic cosmetic changes. This implementation has evolved through several design changes, during which some functionality was added then later removed - I elected to preserve any cleaned-up replacement code if removing the no-longer-needed-by-the- solver-types-design functionality was easy to do. doc/reference_manual.texi: Document solver types. compiler/hlds_data.m: Changed the du_type and foreign_type constructors appropriately and added a new solver_type constructor. compiler/hlds_out.m: Improved the code to write out the `where ...' part of a type definition and moved it to mercury_output.m. compiler/inst_match.m: Added the pred inst_is_any/1. compiler/inst_util.m: Added the pred inst_contains_unconstrained_var/1. compiler/make_hlds.m: Added processing for solver types, in particular adding the compiler generated declarations and implementations of the conversion functions. compiler/mercury_to_mercury.m: Added predicate mercury_output_where_attributes. compiler/mode_info.m: Added a new field to mode_info to indicate whether solver type initialisation calls can be inserted by modecheck_conj_list_2. compiler/mode_errors.m: compiler/modecheck_call.m: compiler/modecheck_unify.m: compiler/modes.m: The compiler now inserts calls to initialisation preds, where necessary, before calls and at the end of procedures. It does not yet do this at the end of disjuncts and its scheduling policy is naive (i.e. it performs terribly.) Added modecheck_conj_list_3 which allows modecheck_conj_list_2 to insert initialisation calls for a single goal, then repeats if this succeeded in scheduling some delayed goals. compiler/modules.m: XXX Reviewers: please look at the `rafe: XXX' comments and advise! compiler/prog_data.m: Added the solver_type constructor and the special_type_details and solver_type_details types. compiler/prog_io.m: compiler/prog_io_pragma.m: Parse the new syntax. Replaced get_maybe_equality_compare_preds with parse_type_decl_where_part_if_present. compiler/prog_mode.m: Added funcs in_mode/1, out_mode/1, in_any_mode/0, out_any_mode/0, and any_inst/0. compiler/special_pred.m: Added `initialise' constructor to special_pred_id. Changed special_pred_name to include the type name and arity with `__Unify__', `__Inex__' etc. compiler/type_util.m: Added some more utility funcs/preds. compiler/unify_proc.m: Generate the forwarding predicates for initialisation preds. compiler/equiv_type.m: compiler/equiv_type_hlds.m: compiler/foreign.m: compiler/hlds_module.m: compiler/intermod.m: compiler/magic_util.m: compiler/ml_code_gen.m: compiler/ml_type_gen.m: compiler/ml_unify_gen.m: compiler/mlds.m: compiler/module_qual.m: compiler/post_typecheck.m: compiler/pragma_c_gen.m: compiler/prog_util.m: compiler/purity.m: compiler/recompilation.check.m: compiler/recompilation.usage.m: compiler/recompilation.version.m: compiler/rl_key.m: compiler/table_gen.m: compiler/term_norm.m: compiler/termination.m: compiler/type_ctor_info.m: compiler/typecheck.m: Propagate the changes to hlds_goal_expr. |
||
|
|
b816836f02 |
Optimize away stack slots storing dummy values; values of the io__state and
Estimated hours taken: 8
Branches: main
Optimize away stack slots storing dummy values; values of the io__state and
store__store types.
compiler/stack_alloc.m:
Allocate distinct negative stack slot numbers to values of dummy types.
We need
compiler/hlds_pred.m:
Add a predicate for testing whether a value is of a dummy type.
compiler/code_into.m:
When constructing the list of live locations after a call, do not
include the negative stack slots containing dummy values. The list
of live locations is used by the (future) native collector, which
should ignore dummy types, and by the debugger. The debugger can't
do anything with these dummy values on the stack except tell the
user about their existence, which doesn't do the debugger user any
good.
We still keep liveness information about dummy values in registers
at calls and returns, since both the procedural and declarative
debuggers need to know procedures' full argument lists.
With respect to the list of live locations before the call, which
was used only by the (now extinct) value numbering optimization,
filter out all dummy types, since their values need not be preserved.
compiler/trace.m:
Do not ask the code generator to preserve values of dummy types,
since doing so would require referring to negative stack slots.
compiler/unify_gen.m:
compiler/var_locn.m:
Fix a couple of situations in which we could refer to the negative
stack slots we now allocate to dummy values.
compiler/call_gen.m:
Reorder some code to make the source match what happens at runtime.
compiler/llds_out.m:
Fix the formatting of the sanity check for negative stack slots.
compiler/handle_options.m:
Since the --debug-opt-pred-id option is useless without --debug-opt,
make --debug-opt-pred-id option imply --debug-opt. This was useful
in debugging this diff.
trace/mercury_trace.c:
Adapt the test for whether a retry is across I/O. We used to base the
test on whether the retried predicate has any I/O state arguments,
and if so, whether the original I/O state variable is still around
on the stack. After this change, the answer to the second half of
that question would always be "no", so we now use only the first half:
whether the retried predicate has any I/O state arguments. This
requires us to consider more retries to be retries across I/O, but
from the point of view of a user who may not remember whether the I/O
predicate has done any I/O so far or not, is arguably more consistent
than our previous policy.
Allow retries even if a value of type store.store is missing, since
store.store is a dummy type just as io.state is.
trace/mercury_trace.c:
compiler/type_util.m:
Document the fact that you need to update both these files if you
want to modify the set of dummy types.
tests/debugger/retry.{inp,exp,exp2}:
Due to the change in mercury_trace.c, one retry in this test case
changes to being retry over I/O. Update the test input to force this
retry over I/O, and expect the expanded input to be echoed in the
output.
tests/debugger/nondet_stack.{exp,exp2}:
Update these expected outputs to account for the fact that we now need
fewer stack slots to hold old I/O states when debugging is enabled.
|
||
|
|
90cdc14ef9 |
Optimize away instructions that move around dummy values; values of the
Estimated hours taken: 3 Branches: main Optimize away instructions that move around dummy values; values of the io__state and store__store types. (We still reserve stack slots for them; getting rid of that is future work.) compiler/var_locn.m: When moving values around, do not emit assignments that move around dummy values. Delete an unused predicate. compiler/code_info.m: Pass to var_locn.m the extra information it now needs. compiler/llds_out.m: Do not emit assignments for dummy arguments of foreign_procs. compiler/type_util.m: Make the code for checking whether a type is a dummy type use the existing predicate for finding the type constructor of a type. |
||
|
|
885fd4a387 |
Remove almost all dependencies by the modules of parse_tree.m on the modules
Estimated hours taken: 12 Branches: main Remove almost all dependencies by the modules of parse_tree.m on the modules of hlds.m. The only such dependencies remaining now are on type_util.m. compiler/hlds_data.m: compiler/prog_data.m: Move the cons_id type from hlds_data to prog_data, since several parts of the parse tree data structure depend on it (particularly insts). Remove the need to import HLDS modules in prog_data.m by making the cons_ids that refer to procedure ids refer to them via a new type that contains shrouded pred_ids and proc_ids. Since pred_ids and proc_ids are abstract types in hlds_data, add predicates to hlds_data to shroud and unshroud them. Also move some other types, e.g. mode_id and class_id, from hlds_data to prog_data. compiler/hlds_data.m: compiler/prog_util.m: Move predicates for manipulating cons_ids from hlds_data to prog_util. compiler/inst.m: compiler/prog_data.m: Move the contents of inst.m to prog_data.m, since that is where it belongs, and since doing so eliminates a circular dependency. The separation doesn't serve any purpose any more, since we don't need to import hlds_data.m anymore to get access to the cons_id type. compiler/mode_util.m: compiler/prog_mode.m: compiler/parse_tree.m: Move the predicates in mode_util that don't depend on the HLDS to a new module prog_mode, which is part of parse_tree.m. compiler/notes/compiler_design.m: Mention prog_mode.m, and delete the mention of inst.m. compiler/mercury_to_mercury.m: compiler/hlds_out.m: Move the predicates that depend on HLDS out of mercury_to_mercury.m to hlds_out.m. Export from mercury_to_mercury.m the predicates needed by the moved predicates. compiler/hlds_out.m: compiler/prog_out.m: Move predicates for printing parts of the parse tree out of hlds_out.m to prog_out.m, since mercury_to_mercury.m needs to use them. compiler/purity.m: compiler/prog_out.m: Move predicates for printing purities from purity.m, which is part of check_hlds.m, to prog_out.m, since mercury_to_mercury.m needs to use them. compiler/passes_aux.m: compiler/prog_out.m: Move some utility predicates (e.g. for printing progress messages) from passes_aux.m to prog_out.m, since some predicates in submodules of parse_tree.m need to use them. compiler/foreign.m: compiler/prog_data.m: Move some types from foreign.m to prog_data.m to allow the elimination of some dependencies on foreign.m from submodules of parse_tree.m. compiler/*.m: Conform to the changes above, mostly by updating lists of imported modules and module qualifications. In some cases, also do some local cleanups such as converting predicate declarations to predmode syntax and fixing white space. |
||
|
|
ff60134ee9 |
Bring these modules up to our current coding standards.
Estimated hours taken: 8 Branches: main analysis/analysis.m: browser/browse.m: compiler/accumulator.m: compiler/assertion.m: compiler/atsort.m: compiler/c_util.m: compiler/check_typeclass.m: compiler/clause_to_proc.m: compiler/code_gen.m: compiler/code_model.m: compiler/const_prop.m: compiler/constraint.m: compiler/dead_proc_elim.m: compiler/delay_construct.m: compiler/dependency_graph.m: compiler/det_analysis.m: compiler/det_report.m: compiler/export.m: compiler/fact_table.m: compiler/follow_code.m: compiler/graph_colour.m: compiler/hlds_module.m: compiler/inlining.m: compiler/llds.m: compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/ml_tailcall.m: compiler/ml_unify_gen.m: compiler/mmc_analysis.m: compiler/mode_errors.m: compiler/passes_aux.m: compiler/post_typecheck.m: compiler/size_prof.m: compiler/switch_util.m: compiler/table_gen.m: compiler/term_errors.m: compiler/transform_llds.m: compiler/type_util.m: compiler/unify_gen.m: compiler/unneeded_code.m: compiler/unused_args.m: Bring these modules up to our current coding standards. Use predmode declarations and state variable syntax where relevant. Reorder arguments where this is needed for the use state variables. Make the orders of predicate definitions correspond to the order of their declarations. Replace some overly large lambda expressions with named predicates. Convert some predicates to functions where this makes their use more convenient. Use field access notation where convenient. Fix any inconsistent indentation. Remove module prefixes on predicate names where this is necessary to allow sane indentation. In several places, use predicates from error_util.m to print error messages. Apart from this, there are no changes in algorithms. In some places, conform to the changes below. compiler/error_util.m: compiler/hlds_error_util.m: Add new variants of existing predicates for use in some of the changed modules above. compiler/hlds_out.m: Add some functions to convert values of some HLDS types as strings, for use in preparing the arguments of the new calls to predicates in error_util.m. Change the implementations of the predicates that print values of those types to call those functions instead of allowing code duplication. compiler/llds.m: Add some field names to allow use of field updates where relevant. tests/invalid/assert_in_interface.err_exp: tests/invalid/multisoln_func.err_exp: tests/invalid/tricky_assert1.err_exp: Update the expected outputs of these test cases to allow for them being generated by error_util.m, and hence being better formatted than before. |
||
|
|
5d6fd3bd6f |
Reduce the dependence of earlier parts of the compiler on the later ones.
Estimated hours taken: 4 Branches: main Reduce the dependence of earlier parts of the compiler on the later ones. Unnecessary import_module declarations in top level modules such as hlds.m cause unnecessary recompilations when adding new types in later modules, such as submodules of ll_backend.m. This change reduces the number of such unnecessary imports. There are no changes in algorithms, only functionality being moved around. compiler/code_model.m: Change this module from being a submodule of backend_libs.m to being a submodule of hlds.m, since nothing in it is dependent on any backend. compiler/arg_info.m: compiler/code_util.m: Change arg_info.m from being a submodule of ll_backend.m to being a submodule of hlds.m, since most of it is applicable to all current and foreseeable backends. Move the one exported predicate that is ll_backend dependent, and its support predicates, to code_util.m. compiler/backend_libs.m: compiler/ll_backend.m: compiler/hlds.m: Update include_module declarations in accordance with the above. compiler/prog_data.m: compiler/term_util.m: Instead of defining two separate types for holding argument size and termination information, one including HLDS-specific information (in term_util.m) and one not (in prog_data.m), use a polymorphic type defined in prog_data.m and two monomorphic instances. compiler/termination.m: compiler/mercury_to_mercury.m: Change the predicates for writing out argument size and termination information to handle the polymorphic type (we don't need special handling of the monomorphic versions), and move them from termination.m to mercury_to_mercury.m, since this allows us to avoid some undesirable dependencies. compiler/base_typeclass_info.m: compiler/hlds_code_util.m: Move the predicate make_instance_string from base_typeclass_info.m to hlds_code_util.m, again because it allows us to remove some undesirable dependencies. compiler/top_level.m: compiler/backend_libs.m: compiler/check_hlds.m: compiler/hlds.m: compiler/ll_backend.m: compiler/parse_tree.m: compiler/transform_hlds.m: Delete some import_module declarations of other top level modules in these top level modules. Some imports were totally unnecessary. Some imports were useful in only a small minority of submodules; those submodules now import the necessary top level modules directly. Move remaining import_module declarations to the implementation section where this is feasible. Where we still need to import modules we ideally shouldn't, note why. compiler/*.m: Update imports of code_util and arg_info. In some cases, import top level modules no longer imported by the parent module. In some cases, delete unnecessary imports. |
||
|
|
2a1f091157 |
Bring a part of this module I previously missed into line with our
Estimated hours taken: 0.2 Branches: main compiler/type_util.m: Bring a part of this module I previously missed into line with our current coding standards. Use predmode declarations and state variable syntax when appropriate. |
||
|
|
fa9ca36d03 |
This diff makes several files easier to read and to maintain (as well as
Estimated hours taken: 5 Branches: main This diff makes several files easier to read and to maintain (as well as more than 400 lines shorter), but contains no changes in algorithms whatsoever. compiler/deep_profiling.m: compiler/foreign.m: compiler/hlds_module.m: compiler/hlds_data.m: compiler/make_hlds.m: compiler/post_typecheck.m: compiler/prog_data.m: compiler/purity.m: compiler/type_util.m: Bring these modules into line with our current coding standards. Use predmode declarations and state variable syntax when appropriate. Reorder arguments of predicates where necessary for the use of state variable syntax, and where this improves readability. Replace predicates with functions where appropriate. Standardize indentation. compiler/*.m: Conform to the changes above. |
||
|
|
82c6cdb55e |
Make definitions of abstract types available when generating
Estimated hours taken: 100
Branches: main
Make definitions of abstract types available when generating
code for importing modules. This is necessary for the .NET
back-end, and for `:- pragma export' on the C back-end.
compiler/prog_data.m:
compiler/modules.m:
compiler/make.dependencies.m:
compiler/recompilation.version.m:
Handle implementation sections in interface files.
There is a new pseudo-declaration `abstract_imported'
which is applied to items from the implementation
section of an interface file. `abstract_imported'
items may not be used in the error checking passes
for the curent module.
compiler/equiv_type_hlds.m:
compiler/notes/compiler_design.html:
New file.
Go over the HLDS expanding all types fully after
semantic checking has been run.
compiler/mercury_compile.m:
Add the new pass.
Don't write the `.opt' file if there are any errors.
compiler/instmap.m:
Add a predicate instmap_delta_map_foldl to apply
a procedure to all insts in an instmap.
compiler/equiv_type.m:
Export predicates for use by equiv_type_hlds.m
Reorder arguments so state variables and higher-order
programming can be used.
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
Handle `:- pragma foreign_type' as a form of type
declaration rather than a pragma.
compiler/hlds_data.m:
compiler/*.m:
Add a field to the type_info_cell_constructor cons_id
to identify the type_ctor, which is needed by
equiv_type_hlds.m.
compiler/module_qual.m:
Donn't allow items from the implementation section of
interface files to match items in the current module.
compiler/*.m:
tests/*/*.m:
Add missing imports which only became apparent with
the bug fixes above.
Remove unnecessary imports which only became apparent with
the bug fixes above.
tests/hard_coded/Mmakefile:
tests/hard_coded/export_test2.{m,exp}:
Test case.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import2.{m,err_exp}:
Test case.
|
||
|
|
cea3c7294e |
Fix a bug where the type_ctor_info for type_info/1 and
Estimated hours taken: 2 Branches: main Fix a bug where the type_ctor_info for type_info/1 and type_ctor_info/1 weren't being generated. compiler/type_ctor_info.m: Also have to generate a type_ctor_info for those types which have hand defined rtti due to having a fake type body. compiler/type_util.m: Rename builtin_type_ctors_with_no_type_defn as builtin_type_ctors_with_no_hlds_type_defn as the former name was misleading, and remove an incorrect comment about which type_ctors this function returns. compiler/make_hlds.m: compiler/typecheck.m: Changes due to the renaming of builtin_type_ctors_with_no_hlds_type_defn. |
||
|
|
368eaf2d11 |
Address review comments of fjh about my change to generate type_ctor and
Estimated hours taken: 1.5 Branches: main Address review comments of fjh about my change to generate type_ctor and special preds for the builtin types which don't have an abstract type declaration. compiler/make_hlds.m: Change parse_tree_to_hlds to use the state variable syntax. compiler/type_util.m: s/builtin_type_ctors/builtin_type_ctors_with_no_type_defn/ which better reflects which type ctors this function returns. compiler/type_ctor_info.m: Improve the documentation of how the code determines whether or not a type_ctor_info needs to be generated. compiler/typecheck.m: Use builtin_type_ctors_with_no_type_defn and make the documentation more explicit. |
||
|
|
22e4692ac5 |
Rather than declare the builtin types as abstract types in builtin.m
Estimated hours taken: 4 Branches: main Rather than declare the builtin types as abstract types in builtin.m special case their handling in the compiler to ensure that the special preds and the type_ctor_infos are generated when needed. compiler/type_util.m: Add a utility predicate which returns the list of type_ctors which represent types which are special builtins (ie they have no type declaration, even an abstract one). compiler/make_hlds.m: Add the special preds for the special builtins if we are generating the rtti for the builtins. compiler/type_ctor_info.m: Add type_ctor_infos for the special builtins if we are generating the rtti for the builtins. compiler/typecheck.m: The special predicates for the special builtins don't require typechecking. library/builtin.m: Remove the special builtins as they are no longer needed for generating the type_ctor_infos for a type. |
||
|
|
a2bf36e49a |
This diff contains no changes in algorithms whatsoever.
Estimated hours taken: 4 Branches: main This diff contains no changes in algorithms whatsoever. browser/*.m: compiler/*.m: library/*.m: Replace old-style lambdas with new-style lambdas or with named procedures. |
||
|
|
03cbbf4fc0 |
Improve the clarity of polymorphism.m further.
Estimated hours taken: 2 Branches: main Improve the clarity of polymorphism.m further. compiler/polymorphism.m: When a data structure involving type variables has several versions which differ in which tvarset those type variables come from (the raw tvarset of a called predicate's pred_info, the renamed-apart version in which those type variables have been lifted into the caller's newly expanded tvarset, and the version in which the type variables in the types of the formal parameters been replaced with the actual (possibly polymorphic) types from the actual arguments), use a mnemonic prefix to distinguish them, not a numerical suffix of the kind we use for other kinds of transformations. Put the code handling foreign_procs into its own predicate, to make debugging easier. compiler/prog_data.m: Add field names to the class_constraints type, for use in polymorphism.m. compiler/type_util.m: Add a utility predicate, factoring out repeated code from polymorphism.m. library/varset.m: Clarify the documentation of varset__merge_subst. |
||
|
|
8693e293a2 |
This diff makes hlds_pred.m and many callers of its predicates easier to read
Estimated hours taken: 4 Branches: main This diff makes hlds_pred.m and many callers of its predicates easier to read and to maintain, but contains no changes in algorithms whatsoever. compiler/hlds_pred.m: Bring this module into line with our current coding standards. Use predmode declarations, functions, and state variable syntax when appropriate. Reorder arguments of predicates where necessary for the use of state variable syntax, and where this improves readability. Replace old-style lambdas with new-style lambdas or with partially applied named procedures. Standardize indentation. compiler/*.m: Conform to the changes in hlds_pred.m. This mostly means using the new argument orders of predicates exported by hlds_pred.m. Where this is now conveniently possible, change predicates to use state variable notation. In some modules, using state variable notation required changing the orders of arguments in the module's top predicate. compiler/passes_aux.m: Change the order of arguments in the calls this module makes to allow the callees to use state variable notation. Convert this module to state variable notation too. |
||
|
|
f007b45df8 |
Implement the infrastructure for term size profiling.
Estimated hours taken: 400
Branches: main
Implement the infrastructure for term size profiling. This means adding two
new grade components, tsw and tsc, and implementing them in the LLDS code
generator. In grades including tsw (term size words), each term is augmented
with an extra word giving the number of heap words it contains; in grades
including tsc (term size cells), each term is augmented with an extra word
giving the number of heap cells it contains. The extra word is at the start,
at offset -1, to leave almost all of the machinery for accessing the heap
unchanged.
For now, the only way to access term sizes is with a new mdb command,
"term_size <varspec>". Later, we will use term sizes in conjunction with
deep profiling to do experimental complexity analysis, but that requires
a lot more research. This diff is a necessary first step.
The implementation of term size profiling consists of three main parts:
- a source-to-source transform that computes the size of each heap cell
when it is constructed (and increments it in the rare cases when a free
argument of an existing heap cell is bound),
- a relatively small change to the code generator that reserves the extra
slot in new heap cells, and
- extensions to the facilities for creating cells from C code to record
the extra information we now need.
The diff overhauls polymorphism.m to make the source-to-source transform
possible. This overhaul includes separating type_ctor_infos and type_infos
as strictly as possible from each other, converting type_ctor_infos into
type_infos only as necessary. It also includes separating type_ctor_infos,
type_infos, base_typeclass_infos and typeclass_infos (as well as voids,
for clarity) from plain user-defined type constructors in type categorizations.
This change needs this separation because values of those four types do not
have size slots, but they ought to be treated specially in other situations
as well (e.g. by tabling).
The diff adds a new mdb command, term_size. It also replaces the proc_body
mdb command with new ways of using the existing print and browse commands
("print proc_body" and "browse proc_body") in order to make looking at
procedure bodies more controllable. This was useful in debugging the effect
of term size profiling on some test case outputs. It is not strictly tied
to term size profiling, but turns out to be difficult to disentangle.
compiler/size_prof.m:
A new module implementing the source-to-source transform.
compiler/notes/compiler_design.html:
Mention the new module.
compiler/transform_hlds.m:
Include size_prof as a submodule of transform_hlds.
compiler/mercury_compile.m:
If term size profiling is enabled, invoke its source-to-source
transform.
compiler/hlds_goal.m:
Extend construction unifications with an optional slot for recording
the size of the term if the size is a constant, or the identity of the
variable holding the size, if the size is not constant. This is
needed by the source-to-source transform.
compiler/quantification.m:
Treat the variable reference that may be in this slot as a nonlocal
variable of construction unifications, since the code generator needs
this.
compiler/compile_target_code.m:
Handle the new grade components.
compiler/options.m:
Implement the options that control term size profiling.
doc/user_guide.texi:
Document the options and grade components that control term size
profiling, and the term_size mdb command. The documentation is
commented out for now.
Modify the wording of the 'u' HLDS dump flag to include other details
of unifications (e.g. term size info) rather than just unification
categories.
Document the new alternatives of the print and browse commands. Since
they are for developers only, the documentation is commented out.
compiler/handle_options.m:
Handle the implications of term size profiling grades.
Add a -D flag value to print HLDS components relevant to HLDS
transformations.
compiler/modules.m:
Import the new builtin library module that implements the operations
needed by term size profiling automatically in term size profiling
grades.
Switch the predicate involved to use state var syntax.
compiler/prog_util.m:
Add predicates and functions that return the sym_names of the modules
needed by term size profiling.
compiler/code_info.m:
compiler/unify_gen.m:
compiler/var_locn.m:
Reserve an extra slot in heap cells and fill them in in unifications
marked by size_prof.
compiler/builtin_ops.m:
Add term_size_prof_builtin.term_size_plus as a builtin, with the same
implementation as int.+.
compiler/make_hlds.m:
Disable warnings about clauses for builtins while the change to
builtin_ops is bootstrapped.
compiler/polymorphism.m:
Export predicates that generate goals to create type_infos and
type_ctor_infos to add_to_construct.m. Rewrite their documentation
to make it more detailed.
Make orders of arguments amenable to the use of state variable syntax.
Consolidate knowledge of which type categories have builtin unify and
compare predicates in one place.
Add code to leave the types of type_ctor_infos alone: instead of
changing their types to type_info when used as arguments of other
type_infos, create a new variable of type type_info instead, and
use an unsafe_cast. This would make the HLDS closer to being type
correct, but this new code is currently commented out, for two
reasons. First, common.m is currently not smart enough to figure out
that if X and Y are equal, then similar unsafe_casts of X and Y
are also equal, and this causes the compiler do not detect some
duplicate calls it used to detect. Second, the code generators
are also not smart enough to know that if Z is an unsafe_cast of X,
then X and Z do not need separate stack slots, but can use the same
slot.
compiler/type_util.m:
Add utility predicates for returning the types of type_infos and
type_ctor_infos, for use by new code in polymorphism.m.
Move some utility predicates here from other modules, since they
are now used by more than one module.
Rename the type `builtin_type' as `type_category', to better reflect
what it does. Extend it to put the type_info, type_ctor_info,
typeclass_info, base_typeclass_info and void types into categories
of their own: treating these types as if they were a user-defined
type (which is how they used to be classified) is not always correct.
Rename the functor polymorphic_type to variable_type, since types
such as list(T) are polymorphic, but they fall into the user-defined
category. Rename user_type as user_ctor_type, since list(int) is not
wholly user-defined but falls into this category. Rename pred_type
as higher_order_type, since it also encompasses functions.
Replace code that used to check for a few of the alternatives
of this type with code that does a full switch on the type,
to ensure that they are updated if the type definition ever
changes again.
compiler/pseudo_type_info.m:
Delete a predicate whose updated implementation is now in type_util.m.
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Still treat type_infos, type_ctor_infos, typeclass_infos and
base_typeclass_infos as user-defined types, but prepare for when
they won't be.
compiler/hlds_pred.m:
Require interface typeinfo liveness when term size profiling is
enabled.
Add term_size_profiling_builtin.increase_size as a
no_type_info_builtin.
compiler/hlds_out.m:
Print the size annotations on unifications if HLDS dump flags call
for unification details. (The flag test is in the caller of the
modified predicate.)
compiler/llds.m:
Extend incr_hp instructions and data_addr_consts with optional fields
that allow the code generator to refer to N words past the start of
a static or dynamic cell. Term size profiling uses this with N=1.
compiler/llds_out.m:
When allocating memory on the heap, use the macro variants that
specify an optional offset, and specify the offset when required.
compiler/bytecode_gen.m:
compiler/dense_switch.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/goal_form.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/inst_match.m:
compiler/intermod.m:
compiler/jumpopt.m:
compiler/lambda.m:
compiler/livemap.m:
compiler/ll_pseudo_type_info.m:
compiler/lookup_switch.m:
compiler/magic_util.m:
compiler/middle_rec.m:
compiler/ml_code_util.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modecheck_unify.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/post_typecheck.m:
compiler/reassign.m:
compiler/rl.m:
compiler/rl_key.m:
compiler/special_pred.m:
compiler/stack_layout.m:
compiler/static_term.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
Minor updates to conform to the changes above.
library/term_size_prof_builtin.m:
New module containing helper predicates for term size profiling.
size_prof.m generates call to these predicates.
library/library.m:
Include the new module in the library.
doc/Mmakefile:
Do not include the term_size_prof_builtin module in the library
documentation.
library/array.m:
library/benchmarking.m:
library/construct.m:
library/deconstruct.m:
library/io.m:
library/sparse_bitset.m:
library/store.m:
library/string.m:
Replace all uses of MR_incr_hp with MR_offset_incr_hp, to ensure
that we haven't overlooked any places where offsets may need to be
specified.
Fix formatting of foreign_procs.
Use new macros defined by the runtime system when constructing
terms (which all happen to be lists) in C code. These new macros
specify the types of the cell arguments, allowing the implementation
to figure out the size of the new cell based on the sizes of its
fields.
library/private_builtin.m:
Define some constant type_info structures for use by these macros.
They cannot be defined in the runtime, since they refer to types
defined in the library (list.list and std_util.univ).
util/mkinit.c:
Make the addresses of these type_info structures available to the
runtime.
runtime/mercury_init.h:
Declare these type_info structures, for use in mkinit-generated
*_init.c files.
runtime/mercury_wrapper.[ch]:
Declare and define the variables that hold these addresses, for use
in the new macros for constructing typed lists.
Since term size profiling can refer to a memory cell by a pointer
that is offset by one word, register the extra offsets with the Boehm
collector if is being used.
Document the incompatibility of MR_HIGHTAGS and the Boehm collector.
runtime/mercury_tags.h:
Define new macros for constructing typed lists.
Provide macros for preserving the old interface presented by this file
to the extent possible. Uses of the old MR_list_cons macro will
continue to work in grades without term size profiling. In term
size profiling grades, their use will get a C compiler error.
Fix a bug caused by a missing backslash.
runtime/mercury_heap.h:
Change the basic macros for allocating new heap cells to take
an optional offset argument. If this is nonzero, the macros
increment the returned address by the given number of words.
Term size profiling specifies offset=1, reserving the extra
word at the start (which is ignored by all components of the
system except term size profiling) for holding the size of the term.
Provide macros for preserving the old interface presented by this file
to the extent possible. Since the old MR_create[123] and MR_list_cons
macros did not specify type information, they had to be changed
to take additional arguments. This affects only hand-written C code.
Call new diagnostic macros that can help debug heap allocations.
Document why the macros in this files must expand to expressions
instead of statements, evn though the latter would be preferable
(e.g. by allowing them to declare and use local variables without
depending on gcc extensions).
runtime/mercury_debug.[ch]:
Add diagnostic macros to debug heap allocations, and the functions
behind them if MR_DEBUG_HEAP_ALLOC is defined.
Update the debugging routines for hand-allocated cells to print the
values of the term size slot as well as the other slots in the relevant
grades.
runtime/mercury_string.h:
Provide some needed variants of the macro for copying strings.
runtime/mercury_deconstruct_macros.h:
runtime/mercury_type_info.c:
Supply type information when constructing terms.
runtime/mercury_deep_copy_body.h:
Preserve the term size slot when copying terms.
runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
Reduce code duplication by using a now standard macro for copying
strings.
runtime/mercury_grade.h:
Handle the two new grade components.
runtime/mercury_conf_param.h:
Document the C macros used to control the two new grade components,
as well as MR_DEBUG_HEAP_ALLOC.
Detect incompatibilities between high level code and profiling.
runtime/mercury_term_size.[ch]:
A new module to house a function to find and return term sizes
stored in heap cells.
runtime/mercury_proc_id.h:
runtime/mercury_univ.h:
New header files. mercury_proc_id.h contains the (unchanged)
definition of MR_Proc_Id, while mercury_univ.h contains the
definitions of the macros for manipulating univs that used to be
in mercury_type_info.h, updated to use the new macros for allocating
memory.
In the absence of these header files, the following circularity
would ensue:
mercury_deep_profiling.h includes mercury_stack_layout.h
- needs definition of MR_Proc_Id
mercury_stack_layout.h needs mercury_type_info.h
- needs definition of MR_PseudoTypeInfo
mercury_type_info.h needs mercury_heap.h
- needs heap allocation macros for MR_new_univ_on_hp
mercury_heap.h includes mercury_deep_profiling.h
- needs MR_current_call_site_dynamic for recording allocations
Breaking the circular dependency in two places, not just one, is to
minimize similar problems in the future.
runtime/mercury_stack_layout.h:
Delete the definition of MR_Proc_Id, which is now in mercury_proc_id.h.
runtime/mercury_type_info.h:
Delete the macros for manipulating univs, which are now in
mercury_univ.h.
runtime/Mmakefile:
Mention the new files.
runtime/mercury_imp.h:
runtime/mercury.h:
runtime/mercury_construct.c:
runtime/mercury_deep_profiling.h:
Include the new files at appropriate points.
runtime/mercury.c:
Change the names of the functions that create heap cells for
hand-written code, since the interface to hand-written code has
changed to include type information.
runtime/mercury_tabling.h:
Delete some unused macros.
runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
Use the new macros supplying type information when constructing lists.
scripts/canonical_grade_options.sh-subr:
Fix an undefined sh variable bug that could cause error messages
to come out without identifying the program they were from.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade_options.sh-subr:
scripts/mgnuc.in:
Handle the new grade components and the options controlling them.
trace/mercury_trace_internal.c:
Implement the mdb command "term_size <varspec>", which is like
"print <varspec>", but prints the size of a term instead of its value.
In non-term-size-profiling grades, it prints an error message.
Replace the "proc_body" command with optional arguments to the "print"
and "browse" commands.
doc/user_guide.tex:
Add documentation of the term_size mdb command. Since the command is
for implementors only, and works only in grades that are not yet ready
for public consumption, the documentation is commented out.
Add documentation of the new arguments of the print and browse mdb
commands. Since they are for implementors only, the documentation
is commented out.
trace/mercury_trace_vars.[ch]:
Add the functions needed to implement the term_size command, and
factor out the code common to the "size" and "print"/"browse" commands.
Decide whether to print the name of a variable before invoking the
supplied print or browse predicate on it based on a flag design for
this purpose, instead of overloading the meaning of the output FILE *
variable. This arrangement is much clearer.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
Supply type information when constructing terms.
browser/program_representation.m:
Since the new library module term_size_prof_builtin never generates
any events, mark it as such, so that the declarative debugger doesn't
expect it to generate any.
Do the same for the deep profiling builtin module.
tests/debugger/term_size_words.{m,inp,exp}:
tests/debugger/term_size_cells.{m,inp,exp}:
Two new test cases, each testing one of the new grades.
tests/debugger/Mmakefile:
Enable the two new test cases in their grades.
Disable the tests sensitive to stack frame sizes in term size profiling
grades.
tests/debugger/completion.exp:
Add the new "term_size" mdb command to the list of command completions,
and delete "proc_body".
tests/debugger/declarative/dependency.{inp,exp}:
Use "print proc_body" instead of "proc_body".
tests/hard_coded/nondet_c.m:
tests/hard_coded/pragma_inline.m:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
tests/valid/Mmakefile:
Disable the IL tests in term size profiling grades, since the term size
profiling primitives haven't been (and probably won't be) implemented
for the MLDS backends, and handle_options causes a compiler abort
for grades that combine term size profiling and any one of IL, Java
and high level C.
|
||
|
|
5fa9a4b111 |
Remove the unimplemented aditi_filter and aditi_modify
Estimated hours taken: 0.5 Branches: main compiler/*.m: Remove the unimplemented aditi_filter and aditi_modify goals -- they will never be implemented. Remove the `aditi_top_down' lambda_eval_method, which was only used for those update goals. Even if those update goals were to be implemented, a special type of lambda expression shouldn't actually be needed. Use clearer names for the updates in the constructors of the aditi_builtin type. |
||
|
|
ea33d1945c |
The Aditi API has been re-implemented. This change updates
Estimated hours taken: 40
Branches: main
The Aditi API has been re-implemented. This change updates
the Mercury->Aditi interface to work with the new API.
compiler/aditi_builtin_ops.m:
Pass aditi__states to the builtin predicates implementing
calls to Aditi procedures.
compiler/mode_util.m:
Add a function aditi_ui_mode.
compiler/type_util.m:
Add a function aditi_state_type.
runtime/mercury_wrapper.{c,h}:
util/mkinit.c:
Pass the connection and a transaction in which to
store the Aditi-RL modules.
extras/aditi/aditi.m:
extras/aditi/aditi_private_builtin.m:
util/mkinit.c:
Use the new API.
|
||
|
|
a8ce49c7a8 |
Fix a bug reported by Fergus, which caused an abort when a
Estimated hours taken: 5
Branches: main
Fix a bug reported by Fergus, which caused an abort when a
user-defined unification or comparison predicate was ill-typed.
compiler/intermod.m:
Don't attempt to module qualify the unification
and comparison routines for type declarations that
won't be used on the current back-end -- they won't
have been typechecked. They will be ignored when read
back in, but we put them in the `.opt' file because
it is sometimes useful to test compiling a module
against a workspace using a grade different to that
used to build the workspace.
compiler/type_util.m:
Choose the correct unification/comparison predicates for
the current back-end where there are both Mercury and
foreign definitions for a type.
compiler/make_hlds.m:
compiler/foreign.m:
Move have_foreign_type_for_backend to foreign.m, for
use by intermod.m.
doc/reference_manual.texi:
Clarify the documentation about user-defined unification and
comparison predicates for foreign types.
tests/invalid/Mmakefile:
tests/invalid/illtyped_compare.{m,err_exp}:
Add a test case.
tests/invalid/make_opt_error.{m,err_exp}:
This change caused the error in this test case to not
be reported any more (it occurred in code not used
on the back-end being compiled for). Fix the test
so an error is reported.
|
||
|
|
2ad2f0a28e |
Allow types to be declared as "solver" types using the syntax
Estimated hours taken: 120
Branches: main
Allow types to be declared as "solver" types using the syntax
`:- solver type ...'.
For a non-solver type t (i.e. any type declared without using the
`solver' keyword), the inst `any' should be considered to be equivalent
to a bound inst i where i contains all the functors of the type t and
each argument has inst `any'. For solver types, `any' retains its
previous meaning.
This is required to allow us to represent HAL's `old' inst using `any'.
In HAL, `old' is like `any' if the type is an instance of a particular
type class (`solver/1'). However, for types that are not instances of
`solver/1', `old' needs to be treated as though it is `bound'.
library/ops.m:
Add `solver' as a unary prefix operator.
compiler/prog_data.m:
Add a field to the type `type_defn' to record whether or not the
type is a solver type.
compiler/hlds_data.m:
Add an equivalent field to the type `hlds_type_body'.
compiler/prog_io.m:
compiler/make_hlds.m:
compiler/modules.m:
compiler/mercury_to_mercury.m:
compiler/hlds_out.m:
Handle the new ":- solver type ..." syntax.
compiler/det_report.m:
compiler/equiv_type.m:
compiler/foreign.m:
compiler/hlds_code_util.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/magic_util.m:
compiler/ml_code_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/module_qual.m:
compiler/post_typecheck.m:
compiler/pragma_c_gen.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/special_pred.m:
compiler/stack_opt.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
Handle the changes to `type_defn' and `hlds_type_body'.
compiler/type_util.m:
Add predicates `type_util__is_solver_type' and
`type_body_is_solver_type'.
compiler/inst_match.m:
compiler/inst_util.m:
In inst_matches_{initial,final,binding} and
abstractly_unify_inst_functor, when we are comparing `any' insts, check
whether or not the type is a solver type and treat it appropriately.
compiler/instmap.m:
compiler/modecheck_unify.m:
Pass type information to abstractly_unify_inst_functor.
compiler/mode_util.m:
Add a predicate `constructors_to_bound_any_insts' which is the same as
`constructors_to_bound_insts' except that it makes the arguments of the
bound inst `any' instead of `ground'.
tests/invalid/any_mode.m:
tests/invalid/any_mode.err_exp:
tests/hard_coded/any_free_unify.m:
Modify these test cases to use a "solver" type instead of `int'.
tests/valid/any_matches_bound.m:
tests/valid/Mmakefile:
tests/invalid/Mmakefile:
tests/invalid/any_should_not_match_bound.m:
tests/invalid/any_should_not_match_bound.err_exp:
Add new test cases.
extras/trailed_update/var.m:
clpr/cfloat.m:
Modify to use the new `:- solver type' syntax.
|
||
|
|
127fe0f85f |
Fixes to allow testing of ground' matches bound'.
Estimated hours taken: 10 Branches: main Fixes to allow testing of `ground' matches `bound'. compiler/modules.m: When writing discriminated union types to the .int2 file, write out the full type definition rather than an abstract type declaration. This is necessary because a module which transitively imports the .int2 file may need to know the constructors to allow `ground' to be compared with `bound' insts. See the new test case `transitive_inst_type' for an example. If the type has user-defined equality and/or comparison predicates then we write "... where type_is_abstract_noncanonical" to the .int2 file instead of giving the predicate names. compiler/make_hlds.m: If a discriminated union type is imported from a .int2 file, mark it as `abstract_imported'. compiler/typecheck.m: When type checking var-functor unifications, do not allow functors whose types are `abstract_imported', unless we are type checking an `opt_imported' predicate. compiler/prog_data.m: Add a new alternative `abstract_noncanonical_type' to the type `unify_compare' to represent "where type_is_abstract_noncanonical" annotations read from .int2 files. compiler/prog_io.m: Parse "where type_is_abstract_noncanonical" annotations on discriminated union types. compiler/special_pred.m: compiler/unify_proc.m: Avoid creating unification and comparison predicates for types with `type_is_abstract_noncanonical' annotations. compiler/intermod.m: Handle the change to the `unify_compare' type. compiler/type_util.m: Do not remove module qualifiers from constructors before looking them up in the cons table. Some cons ids only have the qualified version in the table. tests/hard_coded/Mmakefile: tests/hard_coded/Mercury.options: tests/hard_coded/transitive_inst_type.exp: tests/hard_coded/transitive_inst_type.m: tests/hard_coded/transitive_inst_type2.m: tests/hard_coded/transitive_inst_type3.m: tests/hard_coded/trans_intermod_user_equality.exp: tests/hard_coded/trans_intermod_user_equality.m: tests/hard_coded/trans_intermod_user_equality2.m: tests/hard_coded/trans_intermod_user_equality3.m: Add some test cases. |
||
|
|
a25b2c0507 |
Prepare to make type_info and typeclass_info foreign types by allowing
Estimated hours taken: 2 Branches: main Prepare to make type_info and typeclass_info foreign types by allowing the compiler to generate type_ctor_infos for them, and allow them to be passed to foreign code without warnings. compiler/type_util.m: Make the predicate type_ctor_has_hand_defined_rtti return true only if the relevant type is not declared as a foreign type. This is needed to allow the compiler to bootstrap across the change that makes type_info and typeclass_info foreign types. This required passing the type definition to the predicate. compiler/special_pred.m: compiler/unify_proc.m: Pass the extra argument to type_ctor_has_hand_defined_rtti. compiler/type_ctor_info.m: Pass the extra argument to type_ctor_has_hand_defined_rtti. Set the required flags on any compiler-generated type_ctor_info structures for the builtin types with fake arities. compiler/llds_out.m: Fix an old bug: ensure that the second argument of the MR_MAYBE_UNBOX_FOREIGN_TYPE macro is of type MR_Word, because the macro insists on this. If applied to e.g. type_ctor_info constants, the old code would have generated C compiler warnings, because their type is not MR_Word. Special case the most frequently passed foreign types to avoid the memcpy overhead in MR_MAYBE_UNBOX_FOREIGN_TYPE. compiler/export.m: Add a utility predicate to help llds_out.m. In the future, the MLDS C backend may want to use it too. |
||
|
|
d6f05747a2 |
Prepare to make type_info and typeclass_info foreign types by eliminating the
Estimated hours taken: 4 Branches: main Prepare to make type_info and typeclass_info foreign types by eliminating the compiler's dependence on their function symbols. At the moment, the compiler generates type_intos and typeclass_infos by using the function symbols of these types as cons_ids. However, the function symbols have fake arities, which demanded special treatment in many places. This change makes the compiler use the cons_ids type_into_cell_constructor and typeclass_into_cell_constructor instead, except in insts, which need to know the arity of the constructor. compiler/hlds_data.m: Add the two new cons_ids. compiler/polymorphism.m: Use the two new cons_ids instead of the function symbols of the type_info and typeclass_info types, since those function symbols will soon be deleted. compiler/type_util.m: Add a type and some predicates to control the representation of type_info and typeclass_info cells in one place. Since we no longer depend on the representations of the function symbols of the type_info and typeclass_info types, do not special case their representation. compiler/hlds_code_util.m: Implement the representation of the two new function symbols. compiler/bytecode.m: Add two new cons_ids to parallel the ones in hlds_data.m. compiler/higher_order.m: Look for the two new cons_ids, instead of the old ones. Make the code more maintainable. compiler/*.m: Minor changes to conform to the changes above. library/private_builtin.m: Delete the statement that the compiler depends on the functors of the type_info and type_ctor_info types. bytecode/mb_bytecode.h: Document that some bytecodes generated by the compiler are not yet implemented by the bytecode interpreter. |
||
|
|
aa478cb237 |
Take a piece of code in modecheck_unify and make it a predicate in
Estimated hours taken: 0.2 Branches: main compiler/type_util.m: compiler/modecheck_unify.m: Take a piece of code in modecheck_unify and make it a predicate in type_util, without any logic changes. In an upcoming diff, another module will need the same code. |
||
|
|
4f42c8e2b1 |
Improve the documentation of predicates checking for user-defined
Estimated hours taken: 0.2 Branches: main compiler/type_util.m: compiler/det_analysis.m: Improve the documentation of predicates checking for user-defined equality. |
||
|
|
6554ef7daa |
Replace "is" with "=".
Estimated hours taken: 2 Branches: main Replace "is" with "=". Add field names where relevant. Replace integers with counters where relevant. |
||
|
|
9551640f55 |
Import only one compiler module per line. Sort the blocks of imports.
Estimated hours taken: 2 Branches: main compiler/*.m: Import only one compiler module per line. Sort the blocks of imports. This makes it easier to merge in changes. In a couple of places, remove unnecessary imports. |
||
|
|
482105e074 |
Allow user-defined comparison functions using the syntax
Estimated hours taken: 10
Branches: main
Allow user-defined comparison functions using the syntax
:- type t ---> t where equality is t_equal, comparison is t_compare.
.
Allow user-defined equality and comparison for foreign types using the syntax
:- pragma foreign_type(c, t, "c_t") where
equality is t_equal, comparison is t_compare.
compiler/prog_data.m:
compiler/mercury_to_mercury.m:
compiler/hlds_out.m:
compiler/*.m:
Allow comparison predicates in `type' and `pragma foreign_type'
declarations
compiler/hlds_data.m:
compiler/*.m:
Allow equality and comparison predicates to be attached
to foreign types.
compiler/prog_io.m:
compiler/prog_io_pragma.m:
Parse the new syntax.
compiler/make_hlds.m:
Don't add the types to the HLDS or do typechecking if
there are errors in the type declarations.
Test case: tests/invalid/foreign_type_visibility.m.
compiler/foreign.m:
compiler/special_pred.m:
compiler/type_util.m:
Check whether foreign types have user-defined equality.
compiler/unify_proc.m:
Generate clauses for user-defined comparison,
and clauses for unification for foreign types.
compiler/intermod.m:
Resolve overloading before writing the `.opt' files.
library/builtin.m:
Add `uo' modes for promise_only_solution, for use in
user-defined comparison predicates.
Add types and insts to allow declaration of user-defined
comparison predicates using `with_type` and `with_inst`.
We already have types and insts `builtin__comparison_pred',
but they have a different argument ordering to `compare/3'.
NEWS:
doc/reference_manual.texi:
Document the change.
tests/hard_coded/Mmakefile:
tests/hard_coded/user_compare.{m,exp}:
Test case.
tests/invalid/Mmakefile:
tests/invalid/typeclass_test_{9,10}.{m,err_exp}:
tests/invalid/purity/purity_nonsense{,2}.{m,err_exp}:
The change to error-checking in make_hlds.m meant that
the compilation stopped before some errors in
typeclass_test_9.m were detected. The code which
tests for those errors is now in typeclass_test_10.m.
|