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.
Estimated hours taken: 0.1
Branches: main
compiler/hlds_clauses.m:
compiler/hlds_pred.m:
Rename all the get access predicates in these modules that don't
already have put "get" in their name. (The names of the set access
predicates were OK already.)
compiler/*.m:
Conform to the above.
All this was done by this sed script:
s/clauses_info_varset/clauses_info_get_varset/
s/clauses_info_explicit_vartypes/clauses_info_get_explicit_vartypes/
s/clauses_info_vartypes/clauses_info_get_vartypes/
s/clauses_info_headvars/clauses_info_get_headvars/
s/clauses_info_clauses_rep/clauses_info_get_clauses_rep/
s/clauses_info_rtti_varmaps/clauses_info_get_rtti_varmaps/
s/pred_info_import_status/pred_info_get_import_status/
s/pred_info_arg_types/pred_info_get_arg_types/
s/pred_info_typevarset/pred_info_get_typevarset/
s/pred_info_tvar_kinds/pred_info_get_tvar_kinds/
s/pred_info_procedures/pred_info_get_procedures/
s/proc_info_context/proc_info_get_context/
s/proc_info_varset/proc_info_get_varset/
s/proc_info_vartypes/proc_info_get_vartypes/
s/proc_info_headvars/proc_info_get_headvars/
s/proc_info_inst_varset/proc_info_get_inst_varset/
s/proc_info_maybe_declared_argmodes/proc_info_get_maybe_declared_argmodes/
s/proc_info_argmodes/proc_info_get_argmodes/
s/proc_info_maybe_arglives/proc_info_get_maybe_arglives/
s/proc_info_declared_determinism/proc_info_get_declared_determinism/
s/proc_info_inferred_determinism/proc_info_get_inferred_determinism/
s/proc_info_goal/proc_info_get_goal/
s/proc_info_can_process/proc_info_get_can_process/
s/proc_info_rtti_varmaps/proc_info_get_rtti_varmaps/
s/proc_info_eval_method/proc_info_get_eval_method/
s/proc_info_is_address_taken/proc_info_get_is_address_taken/
s/proc_info_stack_slots/proc_info_get_stack_slots/
s/proc_info_liveness_info/proc_info_get_liveness_info/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
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.
Estimated hours taken: 2
Branches: main
Remove support for the Aditi backend. It is a pain to have to update it every
time a data structure changes when we don't see any benefit from it, and its
presence makes compilation of the compiler directory take about 10% longer
(since the Aditi backend modules are roughly 10% of the code in the compiler
directory). Deleting the Aditi-specific data structures from the HLDS should
also speed up compilation a little bit.
I have spoken to Rao and he is fine with this step.
Aditi users, if there are any, can continue to use the Aditi support in
release 0.12.*. I also tagged the last version on the trunk to support aditi
with the name "last_aditi". The need for modifications in this Aditi support
is likely to be very rare to nonexistent, if the recent past is any guide:
the Aditi backend hasn't seen a nontrivial modification in a year or more.
This diff removes a net 31492 lines.
compiler/add_aditi.m:
compiler/aditi_backend.pp:
compiler/aditi_builtin_ops.m:
compiler/context.m:
compiler/dnf.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/rl.m:
compiler/rl_analyse.m:
compiler/rl_block.m:
compiler/rl_block_opt.m:
compiler/rl_code.m:
compiler/rl_dump.m:
compiler/rl_exprn.m:
compiler/rl_file.pp:
compiler/rl_gen.m:
compiler/rl_info.m:
compiler/rl_key.m:
compiler/rl_liveness.m:
compiler/rl_loop.m:
compiler/rl_opt.m:
compiler/rl_out.pp:
compiler/rl_relops.m:
compiler/rl_sort.m:
compiler/rl_stream.m:
Remove these compiler modules, since they existed only to support the
Aditi backend.
compiler/hlds_goal.m:
Delete the Aditi-specific components of goals (e.g. the aditi-builtin
kind of generic calls and Aditi-evaluated lambdas).
compiler/hlds_pred.m:
Delete the Aditi-specific components of pred_infos.
compiler/prog_data.m:
Delete the Aditi-specific items.
compiler/passes_aux.m:
Don't worry about processing all procedures or just all non-Aditi
procedures.
compiler/add_clause.m:
Add a predicate from a deleted module that is now used only here.
compiler/*.m:
Conform to the data structure changes above.
compiler/notes/*.html:
Remove references to the Aditi backend.
tests/invalid/aditi.m:
tests/invalid/aditi_errors.err_exp:
tests/invalid/aditi_errors.m:
tests/invalid/aditi_private_builtin.m:
tests/invalid/aditi_state_errors.err_exp:
tests/invalid/aditi_state_errors.m:
tests/invalid/aditi_update_derived_relation.err_exp:
tests/invalid/aditi_update_derived_relation.m:
tests/invalid/aditi_update_errors.err_exp:
tests/invalid/aditi_update_errors.m:
tests/invalid/aditi_update_mode_errors.err_exp:
tests/invalid/aditi_update_mode_errors.m:
tests/valid/aditi.m:
tests/valid/aditi_calls_mercury.m:
tests/valid/aditi_error_bug.m:
tests/valid/aditi_error_bug2.m:
tests/valid/aditi_error_bug3.m:
tests/valid/aditi_private_builtin.m:
tests/valid/aditi_query.m:
tests/valid/aditi_update.m:
tests/valid/base_relation.m:
tests/valid/base_relation2.m:
tests/valid/ite_to_disj.m:
Remove these Aditi-specific tests.
tests/*/Mmakefile:
Remove the references to these Aditi-specific tests.
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.
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'.
Estimated hours taken: 18
Branches: main
Implement --optimize-constructor-last-call for hlc grades.
compiler/lco.m:
Include the types of pointed-to fields in the types of the address-of
variables generated by the transformation, since the HLC backend needs
it.
library/private_builtin.m:
Add a new type, store_at_ref_type, for use by the new version of the
transformation in lco.m.
compiler/ml_call_gen.m:
Handle the form of builtin used by store_at_ref.
compiler/ml_unify_gen.m:
Handle construction unifications that take the addresses of some
fields.
compiler/ml_closure_gen.m:
Conform to the change in ml_unify_gen.m.
compiler/handle_options.m:
Do not disable --optimize-constructor-last-call in hlc grades.
compiler/add_pred.m:
When creating the implementation of the store_at_ref builtin,
don't make the body of the predicate be an invocation of the builtin
itself, since the generated HLC code is not type-correct C. Instead,
make it "true". Since the predicate itself (as distinct from the
builtin operation) is never used, this is OK.
Minor cleanups.
compiler/mlds_to_c.m:
Make the generated C code somewhat easier to read.
Convert to four-space indentation.
compiler/options.m:
Add an option, opt_level_number, which records the selected
optimization level numerically. The idea is that optimizations such
as --optimize-constructor-last-call, which produce speedups only
at some but not all optimization levels, can be enabled only when
they help. This capability is not yet used; that will require further
experimentation.
Convert to four-space indentation.
compiler/mlds.m:
Translate store_at_ref Mercury types into a pointer MLDS type.
Minor cleanups.
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
Minor cleanups.
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.
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/
Estimated hours taken: 2
Branches: main
compiler/ml_*.m:
Convert these modules to four space indentation, and clean up
departures from our coding standards.
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.
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.
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.
Estimated hours taken: 24
Branches: main
Some work towards getting the "browser" directory to build in grade java.
In particular, this is a step towards fixing a problem in the Java
back-end with sub-modules. When compiling code that uses sub-modules,
we run up against a Java restriction that a class which is in a package
is not allowed to have the same name as the package. The work-around
is to use names starting with an uppercase letter for Java class names,
and names starting with a lower-case letter for Java package names.
XXX This diff is a partial step: it uses names starting with an
uppercase letter for Java class names that correspond to Mercury types.
It does not yet use an uppercase letter for Java classes that correspond
to Mercury modules.
XXX With this diff, we just flip the case of the initial letter,
which just works around the problem by avoiding the clashing cases,
rather than eliminating them. We should use a more complicated mangling
that eliminates the problem completely, e.g. map lowercase Mercury names
to uppercase, map uppercase Mercury names to "U_" followed by the name.
compiler/mlds_to_java.m:
Output type names with an initial uppercase letter.
compiler/mlds.m:
Add a new enumeration type qual_kind, with values type_qual
and module_qual.
Add a qual_kind field to the fully_qualified_type type.
Add a qual_kind argument to the append_class_qualifier function,
and if the qual_kind is module_qual, adjust the case of the
qualifier appropriately for the back-end.
compiler/ml*.m:
compiler/rtti_to_mlds.m:
Fill in the new qual_kind field, and pass qual_kind to
append_class_qualifier.
library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
library/io.m:
library/rtti_implementation.m:
Use type names with an initial uppercase letter.
browser/Mmakefile:
Work around problems where Java compilers don't like the file names
generated by mmc for code using sub-modules.
For IL and Java, build with --allow-stubs --no-warn-stubs.
browser/declarative_execution.m:
Give a Java definition for the "proc_layout" type.
This is needed to avoid compilation errors in grade java.
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.
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.
Estimated hours taken: 8
Branches: main
compiler/modules.m:
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/bytecode_data.m:
compiler/prog_io_util.m:
Bring these modules up to date with our current coding style. Use
predmode declarations and state variable syntax where appropriate.
Fix inconsistent indentation. Print more error messages using
error_util.m for printing error messages.
compiler/trace_param.m:
Add a new predicate for use by the updated code in handle_options.m.
compiler/error_util.m:
compiler/hlds_error_util.m:
Make error_util.m to be a submodule of parse_tree.m, not hlds.m.
Most of its predicates are not dependent on HLDS data structures.
Move the ones that are into a new module, hlds_error_util, that
is a submodule of hlds.m. Overall, this reduces the dependence
of submodules of parse_tree.m, including modules.m, on submodules
of hlds.m.
compiler/notes/compiler_design.html:
Update the documentation of compiler modes to account for
hlds_error_util.m.
compiler/hlds.m:
compiler/parse_tree.m:
Update the list of included submodules.
compiler/*.m:
Update module imports and module qualifications as needed for the
change above.
tests/invalid/*.{exp,exp2}:
Update the expected outputs of a bunch of test cases to reflect the new
format of some warning messages due to the user error_util; they now
observe line length limits, and print contexts in some cases where they
were previously missing.
Estimated hours taken: 8
Branches: main
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_simplify_switch.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tag_switch.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
Bring the modules in the language-independent part of the MLDS backend
up to date with our current coding standards.
Use predmode declarations where appropriate.
Use state variable syntax where appropriate. Reorder arguments where
required to make this possible. For predicates that only read the
ml_gen_info and aren't likely to write it in the future, delete the
output ml_gen_info argument.
Change large lambda expressions into named predicates where this
improves readability, and in one case factor out duplicated code
in lambda expressions.
Standardize indentation. Shorten some variable names (e.g. by removing
MLDS prefixes) where the new names are unambiguous, to make some goals
fit on fewer lines.
Estimated hours taken: 8
Branches: main
Augment the descriptors of du functors with information about the type class
constraints on their existentially typed arguments (if any). This is not yet
used, but will be needed to perform type class membership tests (as we
discussed on wednesday). We will need to bump the binary compatibility version
number when we start relying on the newly generated data.
Turn on the generation of the new type class descriptor data structures, since
we now need them to describe functors with type class constraints.
This in turn required making the generation of those data structures work
for the MLDS backends as well as the LLDS backend. (The original diff that
added those data structures updated only the LLDS backend.)
compiler/mercury_compile.m:
Always generate descriptors for type class declarations in both LLDS
and MLDS backends. Generate descriptors for type class instances
(which are not referred to from functor descriptors) only if
--new-type-class-rtti is given.
compiler/rtti.m:
Instead of recording just the number of constraints on existentially
typed arguments of functors, record the constraints themselves.
Add new rtti_ids to describe (arrays of) constraints in DuExistInfos.
Add predicates to look up the types of not just the data structures
denoted by rtti_ids, but also their element types if they are arrays.
This is needed because functor desciptors may now contain arrays of
MR_TypeClassConstraints, even though we generate no data structure
of that type; we generate structures of type MR_TypeClassConstraintN
for various values of N, and cast them to MR_TypeClassConstraint.
Factor out some common code.
compiler/rtti_out.m:
Implement the new field of DuExistInfos, and comment out the code
needed to generate type class instances' method descriptors.
Comment out the code for generating method addresses. (See the comment
on mercury_typeclass_info.h below.)
Fix a misleading variable name.
compiler/rtti_to_mlds.m:
Replace "not yet implemented" aborts when translating the new style
type class decl and instance structures with actual translation code.
Implement the new field of DuExistInfos.
Factor out common code for making arrays of pseudo-typeinfos.
compiler/mlds_to_gcc.m:
Factor out the code for turning the type of an rtti data structure
into the type of an array of them, to allow the latter step not to be
done if we are want the type of the array elements.
Add code for defining the types of type class declaration and instance
descriptors.
Implement the new field of DuExistInfos.
compiler/type_ctor_info.m:
Instead of recording just the number of constraints on existentially
typed arguments of functors, record the constraints themselves.
compiler/type_class_info.m:
Generate instance descriptors only if requested.
Export a function now needed by type_ctor_info.m.
compiler/mlds.m:
Allow mlds__rtti_type to refer to the types of elements of the arrays
we generate, even if there is no rtti_id that has that type.
compiler/mlds_to_c.m:
Module qualify type class declaration and instance descriptors, at
least for now; it is only base_typeclass_infos for which we need to
detect duplicate definitions in different modules.
Modify the types of du functor descriptors to include type class
constraint information.
compiler/ml_closure_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
Trivial changes to conform to the changes above.
runtime/mercury_type_info.h:
Add a field giving a list of type class constraints to MR_DuExistInfo.
Move the definitions of the types describing type class constraints
here from mercury_typeclass_info.h, since MR_DuExistInfo now refers
to it. mercury_type_info.h cannot include mercury_typeclass_info.h
without causing a circularity problem.
runtime/mercury_types.h:
Move a bunch of typedefs of structs here from mercury_typeclass_info.h,
again to avoid circularity problems.
runtime/mercury_typeclass_info.h:
Remove the stuff moved to mercury_type_info.h and mercury_types.h.
For now, do not include the code addresses of the procedure's
representing an instance's methods in the instance structure,
since the MLDS backend doesn't really have a notion of a generic code
address, and even if it did it doesn't have an equivalent of the LLDS
backend's code address to proc layout structure mapping, so the code
addresses by themselves would be useless. (The code addresses needed
for method calls are stored in the base_typeclass_info, not the
instance structure.)
When we want to start using information about instance methods
in ways beyond what is afforded by the dictionary in the
base_typeclass_info, we will need to revisit this decision, and will
probably have to include the necessary information about the instance
methods in the instance's data structure directly instead of via a
pointer to the instance method implementations themselves.
runtime/mercury_type_info.h:
runtime/mercury_tags.h:
Move a macro used to define enum constants that compiler generated code
can refer to from mercury_type_info.h to mercury_tags.h (which already
contains a similar macro whose definition is also dependent on
--reserve-tag), since it is now also needed in mercury_proc_id.h.
runtime/mercury_proc_id.h:
Use that macro define MR_PREDICATE and MR_FUNCTION, since the compiler
now generates references to them.
Estimated hours taken: 8
Branches: main
The comparison and unification function pointers stored in the
type_ctor_info must be pointers to functions where all the arguments
are boxed. This wasn't occuring on the IL backend for types which
are value types.
il_compiler/compiler/rtti_to_mlds.m:
Call ml_gen_closure_wrapper to construct a version of the
comparison and unification functions where the arguments are
boxed. The wrapper function simply unboxes the arguments and
calls the actual special pred.
il_compiler/compiler/ml_closure_gen.m:
Adapt ml_gen_closure_wrapper so that it can generate a wrapper
function for special preds.
tests/hard_coded/Mmakefile:
tests/hard_coded/equality_pred_which_requires_boxing.exp:
tests/hard_coded/equality_pred_which_requires_boxing.m:
Add a test case for this bug.
Estimated hours taken: 2
Branches: main
Fix a bug that broke bootstrapping in grade hlc.agc.
compiler/ml_closure_gen.m:
Ensure that we generatine GC tracing code for the closure_arg
parameter. This is needed because it gets referenced by the
GC tracing code for other local variables in this function.
Without this, if two GCs occur between when a closure is
called and when it returns, then the first GC will collect
the closure, and then the second GC will try to dereference
the closure_arg parameter.
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.
Estimated hours taken: 24
Branches: main
Implement accurate GC for type class methods.
Accurate GC now supports the whole Mercury language.
compiler/ml_closure_gen.m:
Generate GC tracing code for the type class method instance
wrapper functions whose addresses get stored in typeclass_infos.
This code generates a closure layout for the method instance
procedure, and then calls MR_materialize_closure_params(),
passing it the typeclass_info and the closure layout.
runtime/mercury_layout_util.h:
runtime/mercury_layout_util.c:
Add new routine MR_materialize_typeclass_info_params(), for use
by the code generated by ml_closure_gen.m.
This is similar to MR_materialize_closure_params() except that
it works on a typeclass_info rather than an MR_Closure.
compiler/ml_code_util.m:
Change ml_bump_function_labels so that it also bumps the constant
sequence number, and rename it as ml_bump_counters. This is needed
to avoid clashes between different local closure_layout constants
after they get hoisted to the top level by ml_elim_nested.m.
compiler/rtti_to_mlds.m:
Update to reflect the changed interface to ml_gen_closure_wrapper
and ml_code_util.m.
compiler/ml_elim_nested.m:
Update the accurate GC TODO list.
compiler/options.m:
doc/user_guide.texi:
Document that accurate GC is now supported.
NEWS:
Mention that we now support accurate GC.
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.
Estimated hours taken: 6
Branches: main
Fix two related anomalies. One was that base_typeclass_infos were being
created using the fcailities of rtti.m, but they were being referred to
using data_addr, not rtti_addr, in the LLDS backend, and they had similar
special treatment in the MLDS backend. The second is the special treatment of
base_typeclass_infos within rtti.m, rtti_out.m and rtti_to_mlds.m, due
to the fact that unlike the other data structures defined in rtti.m,
their id does not include an rtti_type_ctor. When we move over to the
proposed data structures for representing type class and instance
information, base_typeclass_infos won't be alone in not including
an rtti_type_ctor in their id.
compiler/rtti.m:
Introduce the notion of an rtti_id, which includes an rtti_type_ctor
only for references to data structures for which that is appropriate.
compiler/llds.m:
compiler/mlds.m:
Delete the redundant data_name base_typeclass_info.
Use rtti_ids where appropriate.
compiler/llds_out.m:
Delete the code handling the deleted data_name base_typeclass_info.
Conform to the changes to rtti.m and llds.m.
compiler/ll_pseudo_type_info.m:
compiler/ml_closure_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/stack_layout.m:
compiler/unify_gen.m:
Conform to the changes above, which in several cases allows us to
eliminate the special handling of base_typeclass_infos.
compiler/base_typeclass_info.m:
Follow up on an old XXX, and make a predicate tail recursive.
Estimated hours taken: 3
Branches: main
Reduce inappropriate dependencies on ll_backend modules. Except for
simplification of unnecessarily complicated logic in dependency_graph.m,
this change only moves functionality around.
compiler/llds_out.m:
compiler/c_util.m:
compiler/name_mangle.m:
Move predicates that are used by multiple backends from
ll_backend__llds_out to backend_libs__c_util and to a new module
backend_libs__name_mangle. Make the relevant ones functions,
and give some of them more meaningful names.
compiler/trace.m:
compiler/hlds_goal.m:
Move a backend-independent predicate from ll_backend__trace
to hlds__hlds_goal.
compiler/llds.m:
compiler/trace_params.m:
Move the definition of the trace_port type from ll_backend__llds
to libs__trace_params to avoid having libs__trace_params depend on
ll_backend.
compiler/exprn_aux.m:
compiler/globals.m:
Move the definition of the imported_is_constant from
ll_backend__exprn_aux to libs__globals to avoid having libs__globals
depend on ll_backend.
compiler/*.m:
Conform to the above changes. This removes many inappropriate
dependencies on the LLDS backend.
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.
Estimated hours taken: 24
Branches: main
Support impurity declarations for higher-order code.
In particular, allow `impure' and `semipure' annotations on
higher-order types, higher-order calls, and lambda expresions.
NEWS:
doc/reference_manual.texi:
Document the new language feature.
compiler/hlds_goal.m:
compiler/hlds_pred.m:
Add `purity' field to
- the `higher_order' alternative of the hlds_goal.generic_call type
- the `higher_order' alternative of the hlds_pred.generic_call_id type
- the `lambda_goal' alternative of the hlds_goal.unify_rhs type
compiler/type_util.m:
Add a new `purity' argument to the procedures dealing with
higher-order types. Add code for parsing impure/semipure
higher-order types.
compiler/lambda.m:
compiler/make_hlds.m:
compiler/typecheck.m:
compiler/post_typecheck.m:
compiler/purity.m:
compiler/polymorphism.m:
Various minor changes to support impure/semipure higher-order lambda
expressions.
compiler/polymorphism.m:
compiler/pseudo_type_info.m:
XXX ought to change these to include purity in the RTTI for
higher-order function types.
compiler/simplify.m:
Don't try to optimize semipure/impure higher-order calls.
compiler/assertion.m:
compiler/bytecode_gen.m:
compiler/call_gen.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/dead_proc_elim.m:
compiler/deep_profiling.m:
compiler/det_analysis.m:
compiler/det_util.m:
compiler/equiv_type.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/mode_util.m:
compiler/modecheck_call.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/pd_util.m:
compiler/prog_rep.m:
compiler/pseudo_type_info.m:
compiler/quantification.m:
compiler/recompilation.usage.m:
compiler/rl_gen.m:
compiler/stratify.m:
compiler/switch_detection.m:
compiler/term_traversal.m:
compiler/term_util.m:
compiler/unify_gen.m:
compiler/unique_modes.m:
Trivial changes to handle the new purity fields and/or arguments.
tests/hard_coded/purity/Mmakefile:
tests/hard_coded/purity/impure_func_t5_fixed2.m:
tests/hard_coded/purity/impure_func_t5_fixed2.exp:
tests/hard_coded/purity/impure_func_t5_fixed2.exp2:
tests/hard_coded/purity/impure_pred_t1_fixed3.m:
tests/hard_coded/purity/impure_pred_t1_fixed3.exp:
tests/invalid/purity/Mmakefile:
tests/invalid/purity/impure_func_t5_fixed.m:
tests/invalid/purity/impure_func_t5_fixed.err_exp:
tests/invalid/purity/impure_pred_t1_fixed.m:
tests/invalid/purity/impure_pred_t1_fixed.err_exp:
Add new test cases to test the new feature.
tests/invalid/purity/impure_func_t5.err_exp:
tests/invalid/purity/impure_pred_t1.err_exp:
tests/invalid/purity/impure_pred_t2.err_exp:
tests/invalid/purity/purity.err_exp:
tests/invalid/purity/purity_nonsense.err_exp:
Update the expected error messages for existing test cases.
tests/invalid/purity/.cvsignore:
New file, copied from tests/invalid/.cvsignore.
Estimated hours taken: 0.1
Branches: main
compiler/ml_closure_gen.m:
Delete an XXX comment about a problem with accurate GC,
because the problem it mentions has been fixed already.
Estimated hours taken: 2
Branches: main
compiler/ml_closure_gen.m:
Fix a bug: the `closure_arg' variable in closure wrappers
does need to be traced by the GC, even though it is not
referenced by the mutator, since it is referenced by the
collector.
Estimated hours taken: 20
Branches: main
Implement the last remaining bits needed to do accurate GC for
closure wrappers.
compiler/ml_call_gen.m:
Add an extra boolean argument to ml_gen_call and
ml_gen_box_or_unbox_lval specifying whether or not
the calling procedure is a closure wrapper.
If it is, declare any local variables allocated
to hold temporaries needed for boxing/unboxing
using ml_gen_local_for_output_arg from ml_closure_gen.m,
so that the GC tracing code gets handled right.
Also add an extra int argument to ml_gen_box_or_unbox_lval,
specifying the argument number, since this is needed by
ml_gen_local_for_output_arg.
compiler/ml_closure_gen.m:
Pass `yes' for the new boolean argument to ml_gen_call.
Fix a bug where the `allocated_memory_cells' list was not being
initialized.
Export ml_gen_local_for_output_arg, for use by ml_call_gen.m.
Fix an off-by-one bug in ml_gen_local_for_output_arg.
compiler/ml_code_gen.m:
Pass `no' for the new boolean argument to ml_gen_call
and ml_gen_box_or_unbox_lval.
Estimated hours taken: 40
Branches: main
A step towards RTTI in Mercury.
This step redefines the representation of pseudo-typeinfos inside the compiler
to be identical to the representation we will need for efficient interpretation
of RTTI data structures in Mercury. Later steps will do likewise for
typectorinfos. In the end, we will have two implementations of RTTI:
the current low-level, very efficient one written in C, which will be used
by the C backends (both LLDS and MLDS), and a new, higher-level one
which will use Mercury data structures and Mercury predicates for
interpretation (along the lines of library/rtti_implementation.m)
for the Java and IL backends.
A large part of this change concerns the fact that pseudo-typeinfos can now
contain typeinfos as well as other pseudo-typeinfos, and they do in the
frequent case that the type of an argument is ground. Given that typeinfos
are just special cases of pseudo-typeinfos, the code for handling the two
types is usually similar, with common code factored out when relevant.
In the process of redesigning the data structures concerning (pseudo-)
typeinfos, I also fixed an old naming scheme that has become misleading.
The representation of a (pseudo-) typeinfo depends on whether the principal
type constructor is fixed arity or not. We used to denote this distinction
with the phrases first-order vs higher-order, since at first the only variable
arity type constructors were pred and func. However, this hasn't been true
since we added tuples. I have changed the naming scheme to be fixed-arity vs
variable-arity.
compiler/rtti.m:
Add new, purely Mercury data structures for representing typeinfos
and pseudo-typeinfos, designed both for efficient interpretation
and as a source for the generation of static data structures in C.
compiler/pseudo_type_info.m:
Delete the type definitions here, since they are superseded by the new
definitions in rtti.m.
Add predicates for constructing typeinfos as well as pseudo-typeinfos,
since now we need those too.
Conform to the changed data structures for (pseudo-) typeinfos.
compiler/ll_pseudo_type_info.m:
compiler/ml_closure_gen.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/opt_debug.m:
compiler/type_ctor_info.m:
Conform to the changed data structures for (pseudo-) typeinfos.
compiler/mlds.m:
Since the MLDS now refers to type_infos, add their type
(mlds__type_info_type) to the list of types the MLDS knows about.
compiler/ml_code_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Handle mlds__type_info_type.
compiler/mlds_to_gcc.m:
Conform to the changed data structures for (pseudo-) typeinfos,
and handle mlds__type_info_type.
runtime/mercury_bootstrap.h:
Override the compiler-generated names of the type_ctor_infos of the
variable arity type constructors. The MLDS backend requires these
to be module qualified; the LLDS backend requires them to be
unqualified. This is a problem because the same code now generates
the compiler's internal representation of pseudo-typeinfos for both
backends.
The temporary solution is to have the compiler generate these names
module qualified, and have these macros convert them to the unqualified
form. (The long term solution should be to always module qualify
everything, but doing that is for another change.)
runtime/mercury_type_info.h:
Change the naming scheme from first order vs higher order to fixed
arity vs variable arity.
library/construct.m:
library/deconstruct.m:
runtime/mercury.c:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_desc.c:
runtime/mercury_type_info.c:
runtime/mercury_unify_compare_body.h:
Conform to the new naming scheme.
runtime/mercury.h:
Conform to the new naming scheme.
Declare fixed and variable arity types for typeinfos as well as
pseudo-typeinfos, since pseudo-typeinfos can now refer to typeinfos.
Estimated hours taken: 2
Branches: main
Fix a bug with closure layouts and the GCC back-end.
compiler/mlds_to_gcc.m:
Handle boxing of array constants.
compiler/ml_closure_gen.m:
Ensure that the closure layout argument of the closure is boxed,
so that its type matches the closure array element type.
Estimated hours taken: 24
Branches: main
Some more steps towards accurate GC for the MLDS->C back-end.
compiler/ml_closure_gen.m:
Generate GC tracing code for some (XXX but still not yet all)
of the local variables declared in closure wrapper functions.
compiler/ml_code_util.m:
Add a new procedure ml_gen_maybe_gc_trace_code_with_typeinfo,
for use by ml_closure_gen.m.
compiler/ml_elim_nested.m:
Update the comments about accurate GC.
runtime/mercury.h:
Include "mercury_layout_util.h", because the code that we
generate for tracing variables in closure wrapper functions
uses MR_materialize_closure_type_params().
Estimated hours taken: 0.75
Branches: main
compiler/ml_closure_gen.m:
Fix a bug that broke `hlc_nest' grades: eliminate any duplicate
constant definitions produced by ml_gen_closure_layout.
Estimated hours taken: 0.25
Branches: main
compiler/ml_closure_gen.m:
Back out my previous bug work-around, i.e. enable generation of
closure layouts on all back-ends, since the bug with generating
closure layouts on .NET has been fixed already.
The main aim of this change is to make the overall, high-level structure
of the compiler clearer, and to encourage better encapsulation of the
major components.
compiler/libs.m:
compiler/backend_libs.m:
compiler/parse_tree.m:
compiler/hlds.m:
compiler/check_hlds.m:
compiler/transform_hlds.m:
compiler/bytecode_backend.m:
compiler/aditi_backend.m:
compiler/ml_backend.m:
compiler/ll_backend.m:
compiler/top_level.m:
New files. One module for each of the major components of the
Mercury compiler. These modules contain (as separate sub-modules)
all the other modules in the Mercury compiler, except gcc.m and
mlds_to_gcc.m.
Mmakefile:
compiler/Mmakefile:
Handle the fact that the top-level module is now `top_level',
not `mercury_compile' (since `mercury_compile' is a sub-module
of `top_level').
compiler/Mmakefile:
Update settings of *FLAGS-<modulename> to use the appropriate
nested module names.
compiler/recompilation_check.m:
compiler/recompilation_version.m:
compiler/recompilation_usage.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/recompilation.version.m:
Convert the `recompilation_*' modules into sub-modules of the
`recompilation' module.
compiler/*.m:
compiler/*.pp:
Module-qualify the module names in `:- module', `:- import_module',
and `:- use_module' declarations.
compiler/base_type_info.m:
compiler/base_type_layout.m:
Deleted these unused empty modules.
compiler/prog_data.m:
compiler/globals.m:
Move the `foreign_language' type from prog_data to globals.
compiler/mlds.m:
compiler/ml_util.m:
compiler/mlds_to_il.m:
Import `globals', for `foreign_language'.
Mmake.common.in:
trace/Mmakefile:
runtime/Mmakefile:
Rename the %.check.c targets as %.check_hdr.c,
to avoid conflicts with compiler/recompilation.check.c.
Estimated hours taken: 4
Branches: main
compiler/ml_closure_gen.m:
A tvar_vector is an array of ints, not a pointer to an int, so use
that for the type of vector. Without this change closure layouts do
not compile on the IL back-end as a pointer to an int is not the
same thing as an array of ints, as it is on the C back-end.
Estimated hours taken: 0.5
Branches: main
compiler/ml_closure_gen.m:
Disable generation of closure layouts for non-C targets, since
apparently this causes some problems with the IL back-end.
Estimated hours taken: 1
Branches: main
Move the code for constructing closures from ml_unify_gen.m
into a new module ml_closure_gen.m.
compiler/ml_unify_gen.m:
compiler/ml_code_util.m:
Move ml_make_boxed_types and fixup_builtin_module from
ml_unify_gen.m to ml_code_util.m, for use by ml_closure_gen.m.
compiler/ml_unify_gen.m:
Export ml_gen_new_object, for use by ml_closure_gen.m.
compiler/rtti_to_mlds.m:
Import ml_closure_gen.m, for ml_gen_closure_wrapper.
compiler/ml_unify_gen.m:
compiler/ml_closure_gen.m:
Move the code for constructing closures from ml_unify_gen.m
into a new module ml_closure_gen.m.
compiler/notes/compiler_design.html:
Mention the new module.