mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-20 08:19:28 +00:00
6d9448c6542ee17b5cbf11418fdb756dde4d213e
70 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6d9448c654 |
Implement a new option `--warn-non-tail-recursion'.
Estimated hours taken: 1 Branches: main Implement a new option `--warn-non-tail-recursion'. compiler/ml_tailcall.m: Add a pass to warn about directly recursive calls that are not tail calls. compiler/options.m: doc/user_guide.texi: Add a new option to enable the new pass. compiler/mercury_compile.m: Add code to invoke the new pass. compiler/handle_options.m: If --warn-non-tail-recursion is set, then report an error if either --high-level-code or --optimize-tailcalls is not, or if --error-check-only is set. compiler/notes/compiler_design.html: Mention the new functionality in ml_tailcall.m. |
||
|
|
f08b29edc9 |
Some more bug fixes for accurate GC with the MLDS->C back-end.
Estimated hours taken: 2 Branches: main Some more bug fixes for accurate GC with the MLDS->C back-end. With these changes, and a few hacks (see http://www.cs.mu.oz.au/research/ mercury/mailing-lists/mercury-reviews/mercury-reviews.0201/0188.html), I was able to build all of the programs in tests/benchmarks in grade hlc.agc, with `EXTRA_MCFLAGS = -O5 --no-deforestation --no-reclaim-heap-on-failure'. compiler/ml_elim_nested.m: - Use an assignment rather than an initializer when saving the stack chain; this is needed because the hoist_nested_funcs pass (which gets run next) assumes that the MLDS doesn't have any initializers for local variables. - Include a counter in the ml_elim_info, and use it to ensure that all the saved stack chain variables get named differently; this is needed because the hoist_nested_funcs pass doesn't handle variables with overlapping scopes. - Move the code for generating the code to save/restore the stack chain into a separate function. compiler/notes/compiler_design.html: Mention the accurate GC pass in ml_elim_nested.m. |
||
|
|
d6fa030ee9 |
Fix an omission.
Estimated hours taken: 0.1 Branches: main compiler/notes/compiler_desigm.html: Fix an omission. |
||
|
|
95acb0d8a2 |
Implement heap reclamation on failure for the MLDS back-end.
Branches: main Estimated hours taken: 8 Implement heap reclamation on failure for the MLDS back-end. library/private_builtin.m: Add impure procedures for saving and restoring the heap pointer. compiler/add_heap_ops.m: New file, similar to add_trail_ops.m. An HLDS->HLDS transformation to add heap reclamation operations. compiler/mercury_compile.m: Call the new pass. compiler/notes/compiler_design.html: Mention the new pass. compiler/add_trail_ops.m: compiler/table_gen.m: compiler/goal_util.m: Abstract out the common code from `generate_call' in table_gen.m, add_trail_ops.m, and add_heap_ops.m, and put it in a new procedure `generate_simple_goal' in goal_util.m. compiler/add_heap_ops.m: compiler/add_trail_ops.m: Apply a review suggestion from Peter Ross: when putting code in places that should not be reachable, insert code that calls private_builtin__unused (which calls error/1) rather than just inserting `true'. |
||
|
|
311d0af1e5 |
Constraint propagation.
Estimated hours taken: 90
Constraint propagation.
compiler/constraint.m:
Push constraints left and inwards as much as possible
within a goal. This module has been completely rewritten.
compiler/deforest.m:
Push constraints within a goal before processing it.
Make specialized versions for calls with constrained outputs.
Rerun determinism inference on specialized versions
when constraint propagation has been run, because the
determinism can change from nondet to semidet.
compiler/pd_util.m:
Add pd_util__propagate_constraints, which uses constraint.m
to push constraints within a goal.
Add some documentation for the exported predicates.
compiler/pd_term.m:
Add support for checking termination of the optimization process
for constraint propagation, which differs from deforestation
in that the conjunctions selected for optimization don't
necessarily have a call at both ends.
compiler/pd_debug.m:
Print some extra information when `--debug-pd' is enabled.
compiler/mercury_compile.m:
Check whether constraint propagation should be performed when
working out whether to run the deforestation pass.
compiler/make_hlds.m:
Add `no_inline' markers to the "recursive" procedures
introduced for builtins to stop constraint propagation
attempting to specialize such procedures.
compiler/hlds_pred.m:
Don't fill in the declared determinism field of the predicates
introduced by `hlds_pred__define_new_pred', so that rerunning
determinism inference will compute a more accurate determinism.
compiler/inlining.m:
Requantify before recomputing instmap_deltas, not after.
compiler/det_report.m:
Add predicates to disable warnings when rerunning
determinism analysis after constraint propagation.
compiler/options.m:
Add documentation for `--constraint-propagation'.
Add option `--local-constraint-propagation', which makes
deforestation call constraint.m to move constraints within
a goal, but does not create specialized versions of procedures
for which there are calls with constrained outputs.
compiler/handle_options.m:
`--constraint-propagation' implies `--local-constraint-propagation'.
compiler/notes/compiler_design.html:
Change the documentation to show that constraint.m is now part
of the deforestation pass.
NEWS:
Announce the new transformation.
doc/user_guide.texi:
Document the new options.
tests/hard_coded/Mmakefile:
tests/hard_coded/constraint.{m,exp}:
tests/hard_coded/constraint_order.{m,exp}:
Test cases.
|
||
|
|
9dd11b2fc6 |
Smart recompilation. Record version numbers for each item
Estimated hours taken: 400
Smart recompilation. Record version numbers for each item
in interface files. Record which items are used in each compilation.
Only recompile a module if the output file does not exist or
nothing has changed.
There is still some work to do on this:
- it doesn't work with inter-module optimization.
- it doesn't work when the module name doesn't match the file name.
(this problem will go away when mmake functionality is moved into
the compiler.
I'll hold off documenting this change in the NEWS file and
on the web page for a month or so, until I've had a bit more
experience using it.
compiler/options.m:
compiler/handle_options.m:
doc/user_guide.texi:
Add an option `--smart-recompilation', currently off by default.
Add an internal option `--generate-version-numbers' to control
whether version numbers are written to the interface files. If
`--smart-recompilation' is disabled because the module
is being compiled with `--intermodule-optimization' (e.g. in the
standard library), we still want to write the version numbers
to the interface files.
Add an option `--verbose-recompilation' (default off)
to write messages describing why recompilation is needed.
Add an option `--warn-smart-recompilation' (default on)
to control warnings relating to the smart recompilation
system. Warn if smart recompilation will not work with
the output and inter-module optimization options given.
compiler/recompilation.m:
Type declarations for smart recompilation.
Predicates to record program items used by compilation.
compiler/recompilation_version.m:
Compute version numbers for program items in interface files.
compiler/recompilation_usage.m:
Find all items used by a compilation.
compiler/recompilation_check.m:
Check whether recompilation is necessary.
compiler/timestamp.m:
Timestamp ADT for smart recompilation.
compiler/mercury_compile.m:
Invoke the smart recompilation passes.
compiler/modules.m:
compiler/prog_io.m:
Return timestamps for modules read.
When reading a module make sure the current input stream
is reset to its old value, not stdin.
Handle version number items in interface files.
compiler/module_qual.m:
compiler/unify_proc.m:
compiler/make_hlds.m:
Record all items used by local items.
compiler/make_hlds.m:
Process `:- pragma type_spec' declarations in
add_item_list_clauses. The qual_info is needed
when processing `:- pragma type_spec' declarations
so that any equivalence types used by the declaration
can be recorded as used by the predicate or function to
which the `:- pragma type_spec' applies.
compiler/equiv_type.m:
For each imported item, record which equivalence types
are used by that item.
compiler/hlds_module.m:
Add a field to the module_info to store information about
items used during compilation of a module.
compiler/check_typeclass.m:
Make sure any items used in clauses for typeclass method
implementations are recorded in the `.used' file.
compiler/prog_data.m:
compiler/*.m:
Factor out some duplicated code by combining the
pred and func, and pred_mode and func_mode items.
Make it easier to extract the name of a type, inst or mode
from its declaration.
Add an item type to hold the version numbers for an interface file.
Allow warnings to be reported for `nothing' items (used for
reporting when version numbers are written using an
obsolete format).
compiler/prog_io.m:
compiler/prog_io_util.m:
compiler/typecheck.m:
compiler/type_util.m:
compiler/*.m:
Strip contexts from all types, not just those in class constraints.
This makes it possible to use ordinary unification to check
whether items have changed (with the exception of clauses).
Remove code to create types with contexts in typechecking.
Remove code scattered through the compiler to remove contexts
from types in class constraints.
compiler/hlds_pred.m:
compiler/prog_util.m:
Move hlds_pred__adjust_func_arity to prog_util, so that it
can be used by the pre-hlds passes.
compiler/typecheck.m:
compiler/hlds_module.m:
Move typecheck__visible_modules to hlds_module.m, so it can
be used by recompilation_usage.m.
compiler/typecheck.m:
Add a comment telling where updates may be required if the
code to typecheck a var-functor unification changes.
compiler/error_util.m:
Allow writing messages without contexts (used for the verbose
recompilation messages).
Add functions to format sym_name and sym_name_and_arity,
and to add punctuation to the end of an error message
without unwanted line breaks before the punctuation.
scripts/Mmake.rules:
compiler/modules.m:
Don't remove the output file before running the compiler. We need
to leave the old output file intact if smart recompilation detects
that recompilation is not needed.
compiler/notes/compiler_design.html:
Document the new modules.
library/io.m:
NEWS:
Add predicates to find the modification time of files
and input_streams.
library/set.m:
NEWS:
Add a predicate version of set__fold
Don't sort the output of set__filter, it's already sorted.
library/std_util.m:
NEWS:
Add a predicate `std_util__map_maybe/3' and a function
`std_util__map_maybe/2' to apply a predicate or a function to
a value stored in a term of type `std_util__maybe'.
configure.in:
runtime/mercury_conf.h.in:
runtime/RESERVED_MACRO_NAMES:
When checking whether the compiler is recent enough, check for
the --warn-smart-recompilation option.
Check for stat().
library/Mmakefile:
Disable warnings about smart recompilation not working with
`--intermodule-optimization'.
browser/Mmakefile:
Disable warnings about smart recompilation not working when
the module name doesn't match the file name.
runtime/mercury_string.h:
Add a macro MR_make_string_const() which automates computation
of the length of string argument to MR_string_const().
tests/recompilation/Mmakefile:
tests/recompilation/runtests:
tests/recompilation/test_functions:
tests/recompilation/TESTS:
tests/recompilation/README:
A framework for testing smart recompilation.
The option currently only works for the recompilation directory.
tests/recompilation/TEST.m.{1,2}:
tests/recompilation/TEST_2.m.{1,2}:
tests/recompilation/TEST.exp.{1,2}:
tests/recompilation/TEST.err_exp.2:
Test cases, where TEST is one of add_constructor_r, add_instance_r,
add_instance_2_r, add_type_nr, change_class_r, change_instance_r,
change_mode_r, field_r, func_overloading_nr, func_overloading_r,
lambda_mode_r, nested_module_r, no_version_numbers_r,
pragma_type_spec_r, pred_ctor_ambiguity_r, pred_overloading_r,
add_type_re, remove_type_re, type_qual_re.
tests/handle_options:
Add an option `-e' to generate any missing expected output files.
|
||
|
|
04e614485d |
Implement deep profiling; merge the changes on the deep2 branch back
Estimated hours taken: 500 Branches: main Implement deep profiling; merge the changes on the deep2 branch back onto the trunk. The main documentation on the general architecture of the deep profiler is the deep profiling paper. doc/user_guide.texi: Document how to use the deep profiler. deep_profiler: deep_profiler/Mmakefile: A new directory holding the deep profiler and its mmakefile. Mmakefile: Add targets for the new directory. Add support for removing inappropriate files from directories. deep_profiler/interface.m: The deep profiler consists of two programs: mdprof_cgi.m, which acts as a CGI "script", and mdprof_server.m, which implements the server process that the CGI script talks to. Interface.m defines the interface between them. script/mdprof.in: A shell script template. ../configure uses it to generate mdprof, which is a wrapper around mdprof_cgi that tells it how to find mdprof_server. deep_profiler/mdprof_cgi.m: The CGI "script" program. deep_profiler/mdprof_server.m: The top level predicates of the server. deep_profiler/profile.m: The main data structures of the server and their operations. deep_profiler/read_profile.m: Code for reading in profiling data files. deep_profiler/startup.m: Code for post-processing the information in profiling data files, propagating costs from procedures to their ancestors and performing various kinds of summaries. deep_profiler/server.m: Code for responding to requests from the CGI script. deep_profiler/cliques.m: Code to find cliques in graphs. deep_profiler/array_util.m: deep_profiler/util.m: Utility predicates. deep_profiler/dense_bitset.m: An implementation of (part of) the set ADT with dense bit vectors. deep_profiler/measurements.m: Operations on profiling measurements. deep_profiler/timeout.m: An implementation of a timeout facility. deep_profiler/conf.m: Functions that depend on autoconfigured settings. configure.in: Find out what command to use to find the name of the local host. Install deep profiling versions of the standard library along with the other profiling versions. runtime/mercury_conf.h.in: Add some macros for deep_profiler/conf.m to use. library/profiling_builtin.m: runtime/mercury_deep_call_port_body.h: runtime/mercury_deep_leave_port_body.h: runtime/mercury_deep_redo_port_body.h: A new library module that implements deep profiling primitives. Some of these primitives have many versions, whose common code is factor is factored out in three new include files in the runtime. compiler/deep_profiling.m: New module to perform the program transformations described in the paper. compiler/notes/compiler_design.html: Document the new compiler module. compiler/mercury_compiler.m: Invoke the new module in deep profiling grades. Allow global static data to be generated by deep_profiling.m. compiler/options.m: Add options to turn on deep profiling and (for benchmarking purposes) control its implementation. Add an optiooption disable tailcall optimization in the LLDS backend, to help benchmarking deep profiling. compiler/jumpopt.m: compiler/optimize.m: Obey the option to disable tailcalls. compiler/handle_options.m: Handle the implications of deep profiling. compiler/modules.m: In deep profiling grades, automatically import profiling_builtin.m. compiler/prog_util.m: doc/Makefile: library/library.m: Handle the new builtin module. compiler/export.m: In deep profiling grades, wrap deep profiling code around exported procedures to handle the "unscheduled call" aspects of callbacks to Mercury from the foreign language. compiler/higher_order.m: profiler/demangle.m: util/demangle.c: When creating a name for a higher-order-specialized predicate, include the mode number in the name. compiler/add_trail_ops.m: compiler/type_util.m: Move c_pointer_type from add_trail_ops to type_util, so it can also be used by deep_profiling.m. compiler/hlds_goal.m: Add a new goal feature that marks a tail call, for use by deep_profiling.m. compiler/hlds_pred.m: Add a new field to proc_info structures for use by deep_profiling.m. Add a mechanism for getting proc_ids for procedure clones. Remove next_proc_id, an obsolete and unused predicate. compiler/hlds_data.m: Add a new cons_id to refer to the proc_static structure of a procedure. compiler/bytecode_gen.m: compiler/code_util.m: compiler/dependency_graph.m: compiler/hlds_out.m: compiler/mercury_to_mercury.m: compiler/ml_unify_gen.m: compiler/opt_debug.m: compiler/prog_rep.m: compiler/rl_exprn.m: compiler/switch_util.m: compiler/unify_gen.m: Trivial changes to handle the new cons_id, goal feature and/or proc_info argument. compiler/rtti.m: Add a utility predicate for extracting pred_id and proc_id from an rtti_proc_label, for use by hlds_out.m compiler/layout.m: compiler/layout_out.m: compiler/llds.m: compiler/llds_common.m: Add support for proc_static and call_site_static structures. compiler/layout_out.m: compiler/llds_out.m: Add code for the output of proc_static structures. compiler/code_util.m: Make code_util__make_proc_label_from_rtti a function, and export it. util/mkinit.c: compiler/llds_out.m: compiler/layout.m: compiler/modules.m: Add support for a fourth per-module C function, for writing out proc_static structures (and the call_site_static structures they contains). Since proc_static structures can be referred to from LLDS code (and not just from other static structures and compiler-generated C code), reorganize the declarations of static structures slightly. Change the schema for the name of the first per-module C function slightly, to make it the addition of the fourth function easier. The scheme now is: mercury__<modulename>__init mercury__<modulename>__init_type_tables mercury__<modulename>__init_debugger mercury__<modulename>__write_out_proc_statics Improve formatting of the generated C code. library/*.m: runtime/mercury.c: runtime/mercury_context.c: runtime/mercury_engine.c: runtime/mercury_ho_call.c: runtime/mercury_tabling.c: runtime/mercury_trace_base.c: runtime/mercury_wrapper.c: trace/mercrury_trace.[ch]: trace/mercrury_trace_declarative.c: trace/mercrury_trace_external.c: trace/mercrury_trace_internal.c: Conform to the new scheme for initialization functions for hand-written modules. compiler/mercury_compile.m: library/benchmarking.m: runtime/mercury_conf_param.h: runtime/mercury.h: runtime/mercury_engine.c: runtime/mercury_goto.c: runtime/mercury_grade.h: runtime/mercury_ho_call.c: runtime/mercury_label.[ch]: runtime/mercury_prof.[ch]: Add an MR_MPROF_ prefix in front of the C macros used to control the old profiler. compiler/handle_options.m: runtime/mercury_grade.h: scripts/canonical_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: Make deep profiling completely separate from the old profiling system, by making the deep profiling grade independent of MR_MPROF_PROFILE_TIME and the compiler option --profile-time. library/array.m: library/builtin.m: library/std_util.m: runtime/mercury_hand_unify_body.h: runtime/mercury_hand_compare_body.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of hand-written unification and comparison procedures. Make the reporting of array bounds violations switchable between making them fatal errors, as we currently, and reporting them by throwing an exception. Throwing an exception makes debugging code using arrays easier, but since exceptions aren't (yet) propagated across engine boundaries, we keep the old behaviour as the default; the new behaviour is for implementors. runtime/mercury_deep_profiling_hand.h: New file that defines macros for use in Mercury predicates whose definition is in hand-written C code. library/exception.m: runtime/mercury_exception_catch_body.h: runtime/mercury_stacks.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of the various modes of builtin_catch. Provide a function that C code can use to throw exceptions. library/benchmarking.m: library/exception.m: library/gc.m: library/std_util.m: runtime/mercury_context.[ch]: runtime/mercury_engine.[ch]: runtime/mercury_debug.c: runtime/mercury_deep_copy.c: runtime/mercury_overflow.h: runtime/mercury_regs.h: runtime/mercury_stacks.h: runtime/mercury_thread.c: runtime/mercury_wrapper.c: Add prefixes to the names of the fields in the engine and context structures, to make code using them easier to understand and modify. runtime/mercury_deep_profiling.[ch]: New module containing support functions for deep profiling and functions for writing out a deep profiling data file at the end of execution. runtime/mercury_debug.[ch]: Add support for debugging deep profiling. Add support for watching the value at a given address. Make the buffered/unbuffered nature of debugging output controllable via the -du option. Print register contents only if -dr is specified. runtime/mercury_goto.h: runtime/mercury_std.h: Use the macros in mercury_std.h instead of defining local variants. runtime/mercury_goto.h: runtime/mercury_stack_layout.h: runtime/mercury_stack_trace.c: runtime/mercury_tabling.c: trace/mercury_trace.c: trace/mercury_trace_declarative.c: trace/mercury_trace_external.c: trace/mercury_trace_vars.c: Standardize some of the macro names with those used in the debugger paper. runtime/mercury_heap.h: Add support for memory profiling with the deep profiler. runtime/mercury_prof.[ch]: runtime/mercury_prof_time.[ch]: Move the functionality that both the old profiler and the deep profiler need into the new module mercury_prof_time. Leave mercury_prof containing stuff that is only relevant to the old profiler. runtime/mercury_prof.[ch]: runtime/mercury_strerror.[ch]: Move the definition of strerror from mercury_prof to its own file. runtime/mercury_wrapper.[ch]: Add support for deep profiling. Add suppory for controlling whether debugging output is buffered or not. Add support for watching the value at a given address. runtime/Mmakefile: Mention all the added files. scripts/mgnuc.in: Add an option for turning on deep profiling. Add options for controlling the details of deep profiling. These are not documented because they are intended only for benchmarking the deep profiler itself, for the paper; they are not for general use. tools/bootcheck: Compile the deep_profiler directory as well as the other directories containing Mercury code. Turn off the creation of deep profiling data files during bootcheck, since all but one of these in each directory will be overwritten anyway. Add support for turning on --keep-objs by default in a workspace. tools/speedtest: Preserve any deep profiling data files created by the tests. trace/mercury_trace.c: Trap attempts to perform retries in deep profiling grades, since they would lead to core dumps otherwise. util/Mmakefile: Avoid compile-time warnings when compiling getopt. tests/*/Mmakefile: tests/*/*/Mmakefile: In deep profiling grades, switch off the tests that test features that don't work with deep profiling, either by design or because the combination hasn't been implemented yet. |
||
|
|
cddde72b73 |
Remove the `--convert-to-goedel' option. It doesn't really work
Estimated hours taken: 0.5 Remove the `--convert-to-goedel' option. It doesn't really work and it's a hassle to maintain. Remove the `--generate-prolog' and `--prolog-dialect' options. They aren't implemented, and now that we have a proper debugger they probably never will be. compiler/mercury_to_goedel.m: Removed. compiler/notes/compiler_design.html: Remove mercury_to_goedel.m. compiler/globals.m: compiler/handle_options.m: Remove code dealing with Prolog dialects. compiler/options.m: doc/user_guide.texi: Remove the options. compiler/prog_io.m: Delete a comment referring to Mercury-to-Goedel converters. compiler/mercury_compile.m: Don't call convert_to_goedel. NEWS: Document the removal of the `--convert-to-goedel' option. WORK_IN_PROGRESS: Remove a reference to the `--generate-prolog' option. |
||
|
|
028211a6b5 |
Remove compiler/excess.m. Its functionality has been included in
Estimated hours taken: 0.2 Remove compiler/excess.m. Its functionality has been included in simplify.m. The rationale for leaving it lying around was that it may have been necessary to provide a version which maintains superhomogeneous form. Experience has shown that when a compiler pass requires strict superhomogeneous form (e.g. magic.m) it's simpler to add back the extra assignments where needed. compiler/excess.m: Removed. compiler/dnf.m: Remove the last import of excess.m. compiler/notes/compiler_design.html Remove description of excess.m. |
||
|
|
b973fb0b9d |
Add support for using different clauses for different modes of a
Estimated hours taken: 8 Branches: main Add support for using different clauses for different modes of a predicate or function, using mode annotations on the clauses. compiler/make_hlds.m: Add support for mode annotations on clauses. compiler/module_qual.m: Add new routine qualify_clause_mode_list, for use by make_hlds.m. compiler/mode_errors.m: Export output_mode_decl, for use by make_hlds.m compiler/purity.m: Treat procedures with different clauses for different modes as impure, unless promised pure. compiler/notes/compiler_design.html: Specify when module qualification of modes in clause mode annotations is done (in make_hlds.m). NEWS: doc/reference_manual.texi: Document the new feature. |
||
|
|
7add5e0b0d |
Disable value numbering, now that it is no longer needed.
Estimated hours taken: 0.5 Branches: main Disable value numbering, now that it is no longer needed. The value numbering source files are not deleted from the CVS repository, since that would make their restoration (in the unlikely event that this is needed) inconvenient, but they will no longer be compiled or included in compiler executables. doc/user_guide.texi: compiler/options.m: Delete the options dealing with value numbering. compiler/optimize.m: Do not invoke value numbering. compiler/handle_options.m: Delete code that handles implications involving value numbering. compiler/opt_debug.m: Delete code for debugging value numbering, since leaving it in would require importing value numbering modules and would thus drag them into the compiler executable. compiler/value_number.m: compiler/vn_block.m: compiler/vn_cost.m: compiler/vn_debug.m: compiler/vn_filter.m: compiler/vn_flush.m: compiler/vn_order.m: compiler/vn_table.m: compiler/vn_temploc.m: compiler/vn_type.m: compiler/vn_util.m: compiler/vn_verify.m: Delete these now obsolete modules. compiler/notes/compiler_design.html: Delete mentions of value numbering and its modules. tests/general/accumulator/Mmakefile: tests/hard_coded/Mmakefile: Remove references to options removed by this change. |
||
|
|
9c58f97e3b |
Add a new optimization, --use-local-vars, to the LLDS backend.
Estimated hours taken: 20 Branches: main Add a new optimization, --use-local-vars, to the LLDS backend. This optimization is intended to replace references to fake registers and stack slots with references to temporary variables in C code, since accessing these should be cheaper. With this optimization and one for delaying construction unifications, the eager code generator should generate code at least good as that produced by the old value numbering pass. This should make it possible to get rid of value numbering, which is much harder to maintain. compiler/use_local_vars.m: New module containing the optimization. compiler/notes/compiler_design.html: Mention the new module. compiler/exprn_aux.m: Add new utility predicates for use by use_local_vars. If --debug-opt is specified, do not dump instruction sequences to standard output. Instead, put them in separate files, where they can be compared more easily. compiler/options.m: Add the --use-local-vars option to control whether the use_local_vars pass gets run. compiler/llds.m: Add liveness information to the c_code and pragma_foreign_code LLDS instructions, in order to allow use_local_vars to work in the presence of automatically-generated C code (e.g. by debugging). compiler/livemap.m: Use the new liveness information to generate useful livemap information even in the presence of automatically generated C code. compiler/code_gen.m: compiler/code_info.m: compiler/dupelim.m: compiler/frameopt.m: compiler/llds_common.m: compiler/llds_out.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/pragma_c_gen.m: compiler/trace.m: compiler/vn_block.m: compiler/vn_cost.m: compiler/vn_filter.m: compiler/vn_verify.m: Provide and/or ignore this additional liveness information. compiler/wrap_block.m: The post_value_number pass wraps LLDS instruction sequences using temporaries in a block instruction which actually declares those temporaries. It used to be used only by value numbering; it is now also used by use_local_vars. It has therefore been renamed and put in its own file. compiler/optimize.m: Invoke use_local_vars if required, and call wrap_blocks instead of post_value_number. compiler/value_number.m: Since the value numbering pass still cannot handle automatically generated C code, check for it explicitly now that livemap carries out only a weaker check. compiler/basic_block.m: Add a module qualification. library/set.m: library/set_bbbtree.m: library/set_ordlist.m: library/set_unordlist.m: Add a new predicate, union_list, to each implementation of sets, for use by some of the new code above. tests/general/array_test.m: Print out the result of each operation as soon as it is done, so that if you get a seg fault, you know which operations have completed and which haven't. |
||
|
|
afd6568f4e |
A new module for delaying construction unifications past builtins in
Estimated hours taken: 8 Branches: main compiler/delay_construct.m: A new module for delaying construction unifications past builtins in conjunctions that can fail. The idea is to incur the cost of memory allocation only if those tests succeed. This can speed up code (e.g. tests/benchmarks/query) by integer factors. compiler/notes/compiler_design.m: Mention the new module. compiler/options.m: doc/user_guide.texi: Add a new option, --delay-construct, that switches on the new optimization. compiler/mercury_compile.m: Invoke the new optimization if the option calls for it. |
||
|
|
8b98304a37 |
Add back a line I deleted by accident.
Estimated hours taken: 0.1 compiler/notes/compiler_design.html: Add back a line I deleted by accident. |
||
|
|
ccf4e35bb5 |
Document unneeded_code.m.
Estimated hours taken: 0.1 compiler/notes/compiler_design.html: Document unneeded_code.m. |
||
|
|
e07e1cd1da |
Implement trailing for the MLDS back-end.
Estimated hours taken: 16 Implement trailing for the MLDS back-end. library/private_builtin.m: Define impure Mercury procedures corresponding to the trailing operations in runtime/mercury_trail.h. compiler/add_trail_ops.m: A new HLDS->HLDS pass. This implements trailing by inserting calls to the trailing primitives declared in library/private_builtin.m. compiler/notes/compiler_design.html: Document the new pass. compiler/mercury_compile.m: Change the code for mercury_compile__mlds_backend so that if trailing is enabled, it invokes the new add_trail_ops pass. runtime/mercury_wrapper.c: For high-level C grades, call MR_init_memory() (which sets up the redzone signal handlers, etc.) and if trailing is enabled, initialize the trail. library/benchmarking.m: Change the code in report_stats for printing out the size of the trail so that it gets the trail zone from MR_trail_zone rather than via the MercuryEngine, so that it works in high-level C grades (which don't have any MercuryEngine). extras/trailed_update/tr_array.m: extras/trailed_update/var.m: Add missing `#includes' to make these files work with the MLDS back-end. |
||
|
|
ebe9f9a3ec |
Add tabling of I/O actions for the debugger.
Estimated hours taken: 80
Add tabling of I/O actions for the debugger.
compiler/options.m:
Add a new option, --trace-table-io, that enables the tabling of I/O
actions, and another, --trace-table-io-states, that governs whether the
tabling includes the I/O state variables themselves. (You want to table
these variables iff they contain meaningful information that is not
stored in global variables.) These options are for developers only
for now.
compiler/modules.m:
Implicitly import table_builtin if --trace-table-io is specified.
compiler/prog_data.m:
Add eval_table_io as a new eval method.
compiler/hlds_pred.m:
Add a mechanism for checking whether a predicate has an input/output
pair of io__state args.
Extend the tables indexed by eval_method to handle eval_table_io.
compiler/hlds_out.m:
Print the eval method in HLDS dumps.
compiler/table_gen.m:
If a procedure has a pair of I/O state args and is defined using pragma
C code that has the tabled_for_io marker, and --trace-table-io is
specified, then perform I/O tabling on it and mark it as tabled.
compiler/notes/compiler_design.m:
Document that table_gen.m can now change the evaluation methods of
procedures (to eval_table_io).
compiler/stack_layout.m:
runtime/mercury_stack_layout.h:
Add an extra field to proc layouts. If debugging is enabled and a
procedure has I/O state arguments, this field gives the number of the
stack slot which will be filled with the I/O action counter at the
time of the call, so that on retry the debugger can reset the I/O
action counter to this value.
compiler/trace.m:
Add code to reserve and fill this stack slot.
Make the order of fields in the trace_slots structure match the order
in proc layouts.
compiler/code_info.m:
compiler/live_vars.m:
Pass a module_info to trace__setup and trace__reserved_slots.
library/io.m:
Mark the I/O primitives (i.e. procedures that are defined by pragma C
code and do I/O) with the tabled_for_io feature. (See the discussion
of I/O primitives in compiler/table_gen.m.)
Standardize the formatting of predicates defined by pragma C codes.
library/table_builtin.m:
Define the predicates that perform I/O tabling, to which calls are
inserted in I/O tabled predicates. These depend on knowing what the
maximum MR_Unsigned value is.
library/table_builtin.m:
runtime/mercury_tabling_macros.h:
Table nodes implementing a simple kind of trie, which can also be
viewed as a hash table with the hash function hash(n) = hash - start
were already supported by mercury_tabling.c. They are used to
implement I/O tabling, since I/O the tabled action numbers form a
contiguous sequence. Now allow that functionality to be accessed
from the library through macros.
runtime/mercury_trace_base.[ch]:
Add the global variables required by I/O tabling.
trace/mercury_trace.c:
Implement retry across I/O by resetting the I/O counter to the value
it had on entry to the retried call. However, since this is not safe
in general, ask the user for permission first.
trace/mercury_trace.h:
Add two extra arguments to MR_trace_retry to specify the input and
output streams on which to ask permission.
trace/mercury_trace_internal.c:
Add commands to start and stop I/O tabling. For now, they are for use
by developers only and are undocumented; I expect they will change
significantly before being let loose on users.
trace/mercury_trace_external.c:
trace/mercury_trace_declarative.c:
Pass extra arguments to MR_trace_retry to indicate that these modules
are not interested (at least for now) in retry across I/O, since they
do not (yet) have mechanisms for asking the user for permission.
tests/debugger/tabled_read.{m,inp,exp,data}:
A new test case to check retry across tabled and non-tabled I/O.
tests/debugger/Mmakefile:
Enable the new test case.
|
||
|
|
d9c0475e4a |
Reorganize the code for handling switches in the MLDS and
Estimated hours taken: 2 Reorganize the code for handling switches in the MLDS and LLDS back-ends to reduce code duplication. compiler/switch_util.m: New file. Contains stuff for switches that is shared between the MLDS and LLDS back-ends. compiler/ml_switch_gen.m: compiler/ml_string_switch.m: compiler/ml_tag_switch.m: compiler/switch_gen.m: compiler/string_switch.m: compiler/tag_switch.m: Move code that was duplicated in the LLDS and MLDS back-ends into string_util.m. Change some names and import_module declarations to match the new organization. compiler/notes/compiler_design.html: Document the new module switch_util.m. Also mention ml_tag_switch.m. |
||
|
|
612865de05 |
Get the MLDS back-end to generate better code for string switches.
Estimated hours taken: 8 Get the MLDS back-end to generate better code for string switches. compiler/ml_code_util.m: compiler/ml_unify_gen.m: Move the routines for generating static constants from ml_unify_gen.m to ml_code_util.m, for use by ml_string_switch.m. compiler/ml_string_switch.m: New file, adapted from string_switch.m. This handles generation of string switches for the MLDS back-end. It generates string switches using string hashing and either computed gotos or int switches. compiler/ml_switch_gen.m: Add support for string switches. Export the target_supports_* predicates, for use in ml_string_switch.m. (Perhaps these predicates should be moved into a different module?) Add `target_supports_goto'. compiler/notes/compiler_design.html: Mention the new module. Also mention other MLDS modules that have been recently added and not yet documented here. |
||
|
|
169db1b8fd |
The .NET MSIL (Microsoft Intermediate Language) backend.
Estimated hours taken: 220 The .NET MSIL (Microsoft Intermediate Language) backend. While not complete, this backend implements enough of Mercury to run programs such as eliza (with an appropriate runtime, which is not part of this change). The IL backend TODO list is in mlds_to_il.m. We generate IL "assembler" from MLDS. The IL assembler (ILASM) then turns this into bytecode in a .DLL or .EXE file. Pragma C code is put into a separate .cpp file and compiled using the managed C++ compiler. compiler/il_peephole.m: Peephole optimize the IL. compiler/ilasm.m: Generate IL assembler from IL. Also a representation of the entities in the IL assembler syntax. compiler/ilds.m: The IL instruction set. compiler/mercury_compile.m: Generate IL if --target il is set. Define mercury_compile__mlds_has_main/1. Assemble the IL if --target-code-only is not set. Use "target_debug" option instead of "c_debug". compiler/ml_code_gen.m: If the target is IL and we are generating MLDS for foreign code that calls continuations (that is, model_non pragma C code), create a nested function (not implemented in foreign code) to call the continuation. This is because in managed C++ it isn't possible to call a continuation, but it's fine to call a method written in IL that calls the continuation instead. compiler/ml_code_util.m: Add unexpected/1 as another error message handler. Add code for generating indirect calls to success continutation (via a nested function). compiler/ml_elim_nested.m: Generate slightly different code for IL environments. We don't use the address of the environment variable (like in the C backend) but use the environment variable directly. We also have to initialize the environment as a new object. This is because we use a class to represent the environment, whereas the C backend uses a struct. Also, if there is no environment required for nested functions (that is, the nested functions don't use any of the local variables of the parent), don't generate an environment. This is important for the nested functions generated in mangaged C++ -- otherwise have to be able to handle defining and initializing environments in managed C++ just to do the continuation calls for model non pragma C code. Add field names to elim_info. compiler/mlds_to_il.m: The IL code generator. Also contains the mapping from MLDS type to IL types (which is useful when generating forieng language stubs to interface with IL). compiler/options.m: Add a debugging option for IL assember -- it prints out each line of assembler before it executes. This is very much a developer only option. Make a "target_debug" option -- the old "c_debug" option is just an alias for this option. If the target it IL, "target_debug" can also turn on debugging for IL, allowing the IL debugger to display IL instructions as it traces execution. |
||
|
|
3ce3b14c84 |
Make procedure bodies available to the declarative debugger.
Estimated hours taken: 20 Make procedure bodies available to the declarative debugger. browser/program_representation.m: Add _rep suffixes to the function symbols, to make iit easier to distinguish HLDS goals and goal representations. compiler/static_layout.m: If --trace-decl is specified, include a representation of the procedure body in the procedure's layout structure. compiler/prog_rep.m: A new module, containing the code that converts goals from HLDS to a term in the format we want to put in the layout structure. compiler/static_term.m: A new module, containing the code that converts Mercury terms to the LLDS rval we need to give to llds_out.m. compiler/code_gen.m: compiler/continuation_info.m: Preserve the information needed by prog_rep compiler/Mmakefile: Extend the search path to the browser directory, since the new file prog_rep.m imports one of the submodules of mdb.m stored there. compiler/notes/compiler_desigm.html: Document the new modules. library/std_util.m: Add a mechanism for static_term.m to use in converting terms into rvals. This mechanism uses RTTI information to deconstruct terms, and return not only their arguments, but also information about how the term can be constructed from its arguments. runtime/mercury_type_info.h: Add a couple of macros to make construction and deconstruction of univs easier, for use in std_util.m. trace/mercury_trace_internal.c: Add a new command, "proc_body", that prints out the representation of the body of the current procedure. This is meant only for developers to use to check that the procedure body representation is OK; it is deliberately not documented. Also fix a bug: make sure that we do not pass a NULL pointer to fputs when echoing a line of input that isn't there (because we got EOF). |
||
|
|
76b98ac506 |
Add some more documentation to compiler/notes.
Estimated hours taken: 2 Add some more documentation to compiler/notes. compiler/notes/overall_design.html: New file. Contains a list of the major sub-systems in the compiler, and a description of how we handle some of the dependency issues that arise. compiler/notes/compiler_design.html: Add a link to overall_design.html. |
||
|
|
99e86ef46d |
Mention the new ml_type_gen.m module.
Estimated hours taken: 0.1 compiler/notes/compiler_design.html: Mention the new ml_type_gen.m module. |
||
|
|
79d7e7aa02 |
Document the mark_static_terms module.
Estimated hours taken: 0.25 compiler/notes/compiler_design.html: Document the mark_static_terms module. |
||
|
|
4bb527330e |
Implement typeclasses for the MLDS back-end.
Estimated hours taken: 15 Implement typeclasses for the MLDS back-end. compiler/rtti.m: Add base_typeclass_info as a new alternative in the rtti_name and rtti_data types. compiler/base_typeclass_info.m: Change it to define base_typeclass_infos as rtti_data rather than comp_gen_c_data. compiler/mercury_compile.m: Modify to reflect the changes to base_typeclass_info.m's interface. Also change the order in which we run the MLDS passes: make sure to generate all the MLDS, including that generated by rtti_to_mlds.m, before running the MLDS transformation passes ml_tailcall.m and ml_elim_nested.m, since the wrapper functions that rtti_to_mlds.m generates for typeclass methods can contain code which those two MLDS transformation passes need to transform. compiler/rtti_out.m: compiler/rtti_to_mlds.m: compiler/mlds_to_c.m: compiler/opt_debug.m: Handle base_typeclass_infos. compiler/mlds_to_c.m: Fix a bug where it was not properly mangling variable names. Note that polymorphism.m can introduce variable names that contain operators, e.g. `TypeClassInfo_for_+'. This bug broke tests/hard_coded/operator_classname.m. I also changed it to mangle label names. compiler/rtti_to_mlds.m: Pass down the module_info, so that ml_gen_init_method can use it when generate wrapper functions for type class methods. compiler/ml_unify_gen.m: Export the ml_gen_closure_wrapper procedure, for use by rtti_to_mlds for type class methods. compiler/ml_code_util.m: Add a new predicate `ml_gen_info_bump_func_label', for use by rtti_to_mlds.m when generating wrapper Add some functions defining magic numbers related to the representation of type_infos, base_typeclass_infos, and closures. compiler/ml_call_gen.m: Handle type class method calls. compiler/llds_out.m: Split the code for outputting a base_typeclass_info name into a separate subroutine, and export that subroutine, for use by rtti_out.m. compiler/llds_out.m: compiler/rtti_out.m: Change llds_out.m so that it calls a new predicate output_base_typeclass_info_storage_type_name, defined in rtti_out.m, when outputting base_typeclass_info declarations. This is needed because base_typeclass_infos are now defined as RTTI constants with type `Code * []', and so need to be handled as such by rtti_out.m rather than being assumed to be structs like the other LLDS data_names. Also move the code for handling dynamic initialization of method pointers from llds_out.m to rtti_out.m, at the same time changing it to handle their new definitions as rtti_data rather than comp_gen_c_data. compiler/mlds.m: Delete the type `base_data', since it is no longer needed. compiler/notes/type_class_transformation.html: Fix a documentation bug: the second field of base_typeclass_infos is the number of instance constraints, not the number of unconstrained type variables. compiler/notes/compiler_design.html: Document the use of the rtti modules in the MLDS back-end, and improve the documentation of their use in the LLDS back-end. runtime/mercury.h: Add a typedef for `MR_BaseTypeclassInfo', for use by the code generated by rtti_to_mlds.m and mlds_to_c.m for base_typeclass_infos. Also add another work-around declaration of an MR_TypeCtorInfo; with this, the browser directory now compiles. |
||
|
|
4ccc3b32ac |
Cleanup of the type_ctor_infos and their components, to achieve two goals.
Estimated hours taken: 65
Cleanup of the type_ctor_infos and their components, to achieve two goals.
First, the new data structure is defined in strongly typed C, with only
two unions, whereas the old data structure was defined by a bunch of macros
that used casts all over the place. The new design should therefore make it
significantly easier to debug code that uses RTTI, and to get it right in
the first place. Second, the new data structures are logically organized,
whereas the old ones had several bad features (such as fixed fields coming
after variable-length arrays in "structures") required by backward
compatibility.
For the time being, the runtime system will be able to handle type_ctor_infos
using both the old and the new data structures, which are distinguished by
the type_ctor_info's version number.
To minimize the disruption caused by such bootstrapping, this change also
incorporates an improvement in the RTTI: for most pseudo_type_infos included
in the RTTI, it records information that allows the runtime system to tell
whether the pseudo_type_info is ground or not; if it is, then the runtime
need not scan the pseudo_type_info looking for type parameters to expand.
Based on statistics I have gathered, this will eliminate between half and two
thirds of all such scans when we do unification and comparison by RTTI.
This change does not impact the structures of typeinfos, base_typeclass_infos
or typeclass_infos.
runtime/mercury_type_info.h:
Define the C types for the new type_ctor_info components.
Update the C type for type_ctor_infos themselves, and the macros
that act on it.
Centralize the list of files that depend on type info representation
here.
Make the names of the two macros that give the number of (all kinds of)
type info vars and the number of existential type info vars consistent.
runtime/mercury_std.h:
Change a comment to refer to one of these renamed macros by its new
name.
compiler/rtti.m:
compiler/rtti_out.m:
New files: rtti.m defines new types that allow us to construct
Mercury representations of the C structures we want to emit,
and rtti_out.m converts those representations to C definitions.
These files are intended to be independent of whether the backend
is LLDS or MLDS. At the moment, there are several vestiges that
tie them to LLDS, mostly due to (a) the lack of a shared common
infrastructure between llds_out.m and mlds_to_c.m, and (b)
the continued use of the old representation of (pseudo-) typeinfos
as rvals. These concerns will be addressed in a future change.
compiler/llds.m:
Update the definition of the comp_gen_c_data and data_addr types
to account for the new RTTI structures.
compiler/llds_out.m:
Update the code to output comp_gen_c_data and data_addr values
to account for the new RTTI structures.
Make some parts of the code more modular, so that rtti_out.m
can use what used to be selected parts of predicates.
Export several predicates for use by rtti_out.m. Some of these
should later be moved to a file for infrastructure shared by
llds_out.m and mlds_to_*.m. Others should be made internal again
when the representation of typeinfos is made independent of the LLDS.
Rename some predicates to better reflect their purpose.
compiler/base_type_layout.m:
compiler/base_type_info.m:
These files are obsoleted by this change. They remain in CVS, but
are no longer used. All of base_type_info.m has been moved into
type_ctor_info.m, and so have the parts of base_type_layout.m
that create the functors and layout structures inside type_ctor_infos;
the remaining part of base_type_layout.m is now in pseudo_type_info.m.
compiler/pseudo_type_info.m:
New file containing the code to create pseudo_type_infos from
base_type_layout.m, slightly updated for the new compiler structure.
compiler/type_ctor_info.m:
New module: almost total rewrite of the base_type_info.m and the
relevant part of base_type_layout.m for the new data structure.
Do not invoke base_typeclass_info.m, since the structures it creates
are not parts of the type_ctor_infos.
compiler/ml_base_type_info.m:
Comment out obsolete unfinished code. It should be replaced by
calls to type_ctor_info, once type_ctor_info's dependence on LLDS
has been eliminated.
compiler/hlds_module.m:
Rename the data structure from which type_ctor_infos are generated.
Delete the data structure from which type_ctor_layouts were generated,
since it is redundant.
Switch to using field names.
compiler/make_tags.m:
compiler/hlds_data.m:
make_tags.m had code that duplicated much of the the functionality
of an existing predicate in hlds_data.m. This change moves that
predicate to hlds_data where it belongs, and gives it an appropriate
name.
compiler/mercury_compile.m:
Do not invoke the predicates that used to be in base_type_layouts
directly; let type_ctor_info do it for the types for which it is
appropriate.
Do invoke base_typeclass_info directly.
compiler/dead_proc_elim.m:
compiler/llds_common.m:
compiler/opt_debug.m:
compiler/stack_layout.m:
compiler/unify_gen.m:
Trivial changes to conform to the changes in the representation of
compiler-generated C data.
compiler/notes/compiler_design.html:
Updates to reflect the new files.
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
Provide alternate implementations of functionality that used the
old functors and layout structures, to use the new ones instead
if the relevant type_ctor_info's version number calls for it.
In many cases, doing this cleanly required reducing the scopes of
variables.
runtime/mercury_tabling.[ch]:
Note where additional work on tabling of typeclass infos is needed,
but do not do the work yet, since it would conflict with DJ's coming
change.
library/std_util.m:
Provide alternate implementations of functionality that used the
old functors and layout structures, to use the new ones instead
if the relevant type_ctor_info's version number calls for it.
In many cases, doing this cleanly required reducing the scopes of
variables.
The predicates get_functor and construct take an integer argument
that identifies a functor of a du type. The integer used to be
the functor's ordinal number in the type definition, but this
was not documented. It is now the functor's position in the list
of the type's functors sorted first on name and then on arity.
This functionality is potentially more useful, since io__read
could do binary instead of linear search when looking for a given
functor. This is an incompatibility, but a very minor one.
Add a new predicate, get_functor_ordinal, to provide a way
to convert lexicographic position into ordinal position.
This is not used yet.
Rename the two different kinds of variables named "info" so that
one can tell them apart.
tests/hard_coded/construct.exp:
Update the expected output of this test based on the new definition
of the meaning of functor numbers in the get_functor and construct
predicates in std_util.
tests/hard_coded/deep_copy.{m,exp}:
Add some code to test the "type contains var" bit vector in du
functor descriptions.
tests/hard_coded/existential_rtti.{m,exp}:
Make the test case print out results as it goes along, to make it
easier which subtask a core dump is coming from. Update the expected
output accordingly.
|
||
|
|
d79cc30587 |
Recognise associativity assertions, and use them to introduce
Estimated hours taken: 35
Recognise associativity assertions, and use them to introduce
accumulators.
mercury/compiler/assertion.m:
Add assertion__is_associativity_assertion, which for an assert_id
determines whether the assertion is associative.
mercury/compiler/accumulator.m:
Call assertion__is_associativity_assertion to determine whether a
call is associative.
Rather than failing if a call is associative and nothing is known
about the effect of rearranging the argument order, report a
suppressible warning.
Fix a bug where the mode of the introduced pred wasn't correct.
mercury/compiler/mercury_compile.m:
Move accumulator introduction before inlining and unused_args, as
inlining can inline an associative call making it unrecognisable and
unused_args eliminates arguments which make it difficult to relate
the assertion with the actual call.
mercury/compiler/notes/compiler_design.html:
Document the constraints on when the module accumulator.m can be
called for it to be effective.
mercury/compiler/options.m:
Add the new option "--inhibit-accumulator-warnings".
mercury/doc/user_guide.texi:
Document "--inhibit-accumulator-warnings".
mercury/library/list.m:
Declare list__append to be associative.
tests/general/accumulator/runtests:
Turn the tests back on, they *should* work under different
optimization levels now.
tests/warnings/Mmakefile:
tests/warnings/arg_order_rearrangment.exp:
tests/warnings/arg_order_rearrangment.m:
Test that a warning is output when accumulator introduction reorders
the arguments to a call without knowing the performance
implications.
|
||
|
|
0cb9cf89fd |
Document stratify.m and trans_opt.m.
Estimated hours taken: 0.25 compiler/notes/compiler_design.html: Document stratify.m and trans_opt.m. |
||
|
|
28f0898dda |
Implement the generation of base_type_info structures
Estimated hours taken: 3
Implement the generation of base_type_info structures
for the MLDS back-end. (Generation of base_type_functors
and base_type_layouts is still not yet implemented, though.)
compiler/ml_base_type_info.m:
New file. This generates the base_type_info structures.
It is similar to base_type_info.m, but for the MLDS back-end.
compiler/ml_code_gen.m:
Change ml_gen_types to call ml_base_type_info__generate_mlds.
Export ml_gen_pred_label, for use by ml_base_type_info.m.
compiler/mlds.m:
Add a new MLDS type `mlds__base_type_info_type',
for base_type_infos.
compiler/mlds_to_c.m:
Add code to handle `mlds__base_type_info_type'.
Handle complex initializers.
Generate proper module qualifiers for data names.
compiler/base_type_info.m:
Delete an obsolete comment.
Add a comment warning that any changes here may also require
changes to ml_base_type_info.m.
compiler/notes/compiler_design.html:
Mention the new module.
|
||
|
|
8079645f11 |
Modify the MLDS back-end to support the `--no-gcc-nested-functions' option.
Estimated hours taken: 30 Modify the MLDS back-end to support the `--no-gcc-nested-functions' option. compiler/ml_elim_nested.m: New module. Contains an MLDS->MLDS transformation pass to eliminated nested functions. compiler/mercury_compile.m: Call the new pass. compiler/notes/compiler_design.html: Mention the new module. compiler/ml_code_gen.m: If --no-gcc-nested-functions is specified, then pass environment pointers to the nested continuation functions. Note that most of the work of converting nested functions into non-nested functions is deferred to the ml_elim_nested pass. But the passing of environment pointers affects the calling convention, and so it really needs to be done here -- it can't be done in any semantics-preserving MLDS transformation later one. Also it is easier to do it in this pass anyway. Also fix a bug where it was miscalculating the set of variables to declare. compiler/mlds.m: - Add a new alternative `mlds__generic_env_ptr_type', used for environment pointers. - Add a new alternative `mlds__class_type' to the `mlds__type' discriminated union, so that types can include user-defined types. This is needed so that we can define struct types for the nested function enviroments. As part of that change, rename `mlds__class' as `mlds__class_defn'. - Change the argument type for the `do_commit' and `try_commit' instructions from `var' to `rval'/`lval'. This is needed so that these instructions can refer to references defined in the containing function via the environment pointer. compiler/mlds_to_c.m: - Changed to reflect the renaming of `mlds__class' as `mlds__class_defn'. - Changed to reflect the change to the `do_commit' and `try_commit' argument types. - For the `mlds__cont_type' type, output it as either `MR_NestedCont' or `MR_Cont', depending on whether the `--gcc-nested-functions' option is enabled. - Fix a bug where it would incorrectly parenthesizing the left-hand operand of `->'. - Insert some additional blank lines in the output, for readability. runtime/mercury_types.h: - Rename the old `Cont' type as `MR_NestedCont', and add a new `MR_Cont' type. |
||
|
|
d551dd1dc9 |
Handle quantification analysis of bi-implication (`<=>') goals correctly.
Estimated hours taken: 10
Handle quantification analysis of bi-implication (`<=>') goals correctly.
Previously we used to expand bi-implications before doing quantification
analysis, which stuffed up the results of quantification analysis for
those goals. We need to do quantification analysis first, and only
then can we expand bi-implications. In addition, elimination of double
negation needs to come after expansion of bi-implication, so I moved
that from make_hlds.m to purity.m.
compiler/hlds_goal.m:
Add a new alternative to the HLDS goal type for bi-implications.
Also add a new predicate negate_goal, for use by purity.m.
compiler/make_hlds.m:
Don't expand bi-implication here, instead just use the new
bi_implication/2 HLDS goal type.
Don't eliminated double negation here.
compiler/quantification.m:
Handle quantification for bi-implications.
Expand bi-implications.
compiler/purity.m:
Eliminate double negation.
compiler/hlds_out.m:
Add code to print out bi-implication goals.
compiler/*.m:
Trivial changes to handle the new bi_implication/2
alternative in the HLDS goal type.
compiler/notes/compiler_design.html:
Document the above changes.
tests/hard_coded/Mmakefile:
tests/hard_coded/quantifier2.m:
tests/hard_coded/quantifier2.exp:
A regression test for the above change.
|
||
|
|
86cfbfc660 |
Add some documentation in the compiler notes.
Estimated hours taken: 0.25 Add some documentation in the compiler notes. compiler/notes/compiler_design.html: Mention lp.m in the termination analysis section. Mention par_conj.m in the parallel conjunction section. |
||
|
|
68ed70f61a |
Mention the name of the module that computes goal paths (goal_path.m).
Estimated hours taken: 0.1 compiler/notes/compiler_design.html: Mention the name of the module that computes goal paths (goal_path.m). |
||
|
|
d8e05866da |
Extend the assertion system by
Estimated hours taken: 56
Extend the assertion system by
* handling assertions in the interface of a module differently to
those in the implementation.
* testing an assertion for the commutivity property.
compiler/polymorphism.m:
Remove the resolving of function calls and data constructors, do it
in post_typecheck instead so that assertions are fully resolved.
compiler/post_typecheck.m:
Add the resolving of function calls and data constructors.
Also call assertion__in_interface_check, if an assertion is in the
interface.
compiler/purity.m:
post_typecheck__finish_assertion can now print error messages so
pass the io__states.
compiler/hlds_data.m:
Add assertion_table_pred_ids, so that intermod knows which pred_ids
are assertions.
compiler/hlds_out.m:
Add predicate hlds_out__write_assertion, which is used by intermod
to write assertions to .opt files.
Change the behaviour of outputing a call, so that if the call is a
function it gets written out in functional syntax. This is
necessary because the resolving of function symbols now occurs in
post_typecheck (pre writing .opt files) rather than in polymorphism
(post writing .opt files).
compiler/intermod.m:
Change intermod so that it writes out any assertion in the
interface to the .opt file.
compiler/modules.m:
Ensure that assertions in the interface are not written to the
.int files. Assertions should only appear in .opt files.
compiler/dead_proc_elim.m:
When intermodule optimization is turned on dead_proc_elim gets run
before typechecking and the assertion predicates are removed. This
change makes dead_proc_elim keep assertions.
compiler/make_hlds.m:
The head variables for an assertion are already known, so initialise
the clause_info structure to those variables rather then creating
Arity fresh variables.
Also don't insert unifications with the head of the assertion, since
we already know that only variables are in the head.
compiler/goal_util.m:
Add mode `goal_calls_pred_id(in, out) is nondet' for use by
assertion__record_preds_used_in.
compiler/assertion.m:
Add a predicate assertion__is_comutativity_assertion, which given
an assertion_id determines whether or not that assertion declares
the commutivity of a pred/func.
Add a predicate assertion__in_interface_check, which checks that an
assertion doesn't refer to any constructors, functions and
predicates defined in the implementation of that module (note
doesn't handle modules imported in the implementation section
correctly).
Rewrite assertion__record_preds_used_in to use the nondet mode of
goal_calls_pred_id.
compiler/accumulator.m:
Remove the facts which declare '+' and '*' to be commutative, and
instead use the new assertion__is_commutivity_assertion predicate.
Also remove the bool from assoc_fact which is the commutivity of the
predicate, since only associative predicates reside in the table
now.
library/int.m:
Add commutivity declarations for '+' and '*', now that they have
been removed from the assoc_fact table. This allows me to test that
all of these changes actually work!
compiler/hlds_goal.m:
Clear up the documentation (I hope) for the type call_unify_context,
so that it is clear that the unification may also have been a
function application.
doc/reference_manual.texi:
doc/transition_guide.texi:
Document assertions.
|
||
|
|
3f5de0a821 |
A very very rough prototype of the MLDS code generator.
Estimated hours taken: 40 A very very rough prototype of the MLDS code generator. compiler/ml_code_gen.m: New module. This converts HLDS to MLDS. Still quite incomplete. compiler/mlds.m: A few minor changes to make things easier for ml_code_gen.m: - add the type `mlds__statements == list(mlds__statement).' - for special_preds, only store the declaring module name if it is different from the defining module name. - a couple of small bugs (one occurrence of class_id should have been hlds_data__class_id, and the definition of the function abstractness_mask was wrong). compiler/mlds_to_c.m: - Implement code for outputting code_addrs. - Minor changes to make the output look better. compiler/mercury_to_c.m: Delete this module, since it is now obsolete -- it has been replaced by the MLDS back-end. compiler/mercury_compile.m: Add code for invoking the MLDS back-end. When the --high-level-C option is specified, invoke the MLDS back-end rather than mercury_to_c.m. compiler/notes/compiler_design.html: Delete the stuff about mercury_to_c.m. Delete the "not yet committed" comment about ml_code_gen.m. |
||
|
|
de27cd9bbb |
A batch of changes related to the development of the new MLDS back-end.
Estimated hours taken: 30 A batch of changes related to the development of the new MLDS back-end. compiler/notes/compiler_design.html: Reorganize the documentation to reflect the multi-target / multiple back-end nature of the compiler. Document mlds.m and the new modules c_util.m and mlds_to_c.m. compiler/mlds_to_c.m: New module. This converts MLDS to C/C++ code. This version compiles, but it is still quite incomplete; there's lots of parts which are still not yet implemented. compiler/llds_out.m: compiler/c_util.m: Move some procedures from llds_out.m into a new module c_util.m, so that they can also be used by mlds_to_c.m. compiler/mlds.m: - Add new functions for use by mlds_to_c.m: * get_prog_context/1, for getting the prog_context from an mlds__context * get_module_name/1, for getting the module name from the mlds * module_name_to_sym_name/1, for converting an mlds_module_name to a sym_name - Change the mlds__func_signature type to * allow multiple return values, for consistency with the MLDS `return' statement; * include the names of the parameters. - Undo the premature over-optimization of making the `constness' and `finality' flags share the same flag bit. |
||
|
|
5069b6adb8 |
Fix some documentation bugs: conversion of unifications
Estimated hours taken: 0.25 compiler/post_typecheck.m: compiler/purity.m: compiler/notes/compiler_design.html: Fix some documentation bugs: conversion of unifications into function calls is now done in polymorphism.m, not modecheck_unify.m. compiler/purity.m: Delete imports of modules modecheck_unify and modecheck_call, since they weren't needed. |
||
|
|
fd5c0b0587 |
Document the trace, goal_path and commit_gen modules.
Estimated hours taken: 0.2 compiler/notes/compiler_design.html: Document the trace, goal_path and commit_gen modules. |
||
|
|
4fdc8b46c5 |
Record in which predicate an assertion is used.
Estimated hours taken: 8
Record in which predicate an assertion is used.
compiler/accumulator.m:
compiler/lambda.m:
compiler/magic.m:
Initialise the assertions field in the new pred_info.
compiler/assertion.m:
An abstract interface to the assertion table (hopefully).
compiler/hlds_data.m:
Modify assertion_table_add_assertion to return the assert_id of the
inserted assertion.
compiler/hlds_pred.m:
Record in the pred_info the set of assertions that mention the pred.
compiler/post_typecheck.m:
Now record which predicates are used in assertions.
compiler/notes/compiler_design.html:
Document assertion.m
|
||
|
|
ea96a2b910 |
Document fact_table.m.
Estimated hours taken: 0.25 compiler/notes/compiler_design.html: Document fact_table.m. |
||
|
|
8d456a1396 |
Document the transform_llds module.
Estimated hours taken: 0.25
compiler/notes/compiler_design.html:
Document the transform_llds module.
|
||
|
|
786ee0f64d |
Document bytecode_data.m, rl_opt.m and rl_relops.m.
Estimated hours taken: 0.2 compiler/notes/compiler_design.html: Document bytecode_data.m, rl_opt.m and rl_relops.m. |
||
|
|
773bd702cc |
Some more changes to minimize the complexity of the intermodule dependencies.
Estimated hours taken: 2.5 Some more changes to minimize the complexity of the intermodule dependencies. In particular, ensure that bytecode.m does not need to import llds.m. compiler/llds.m: compiler/builtin_ops.m: Move the definitions of the unary_op and binary_op types into a new module `builtin_ops'. These types are used by three of the different back-ends (bytecode, llds, and mlds) and therefore deserve to be in their own module. compiler/bytecode.m: Define a type `byte_reg_type' and use that instead of llds__reg_type. Delete the import of module llds. compiler/notes/compiler_design.html: Document the new module builtin_ops. compiler/rl_exprn.m: Add a comment explaining why we need to import llds (and builtin_ops). compiler/base_type_layout.m: compiler/bytecode.m: compiler/code_util.m: compiler/dense_switch.m: compiler/ite_gen.m: compiler/jumpopt.m: compiler/llds_out.m: compiler/lookup_switch.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/rl_exprn.m: compiler/string_switch.m: compiler/tag_switch.m: compiler/transform_llds.m: compiler/unify_gen.m: compiler/value_number.m: compiler/vn_block.m: compiler/vn_cost.m: compiler/vn_flush.m: compiler/vn_type.m: compiler/vn_util.m: compiler/vn_verify.m: Add imports of module builtin_ops to lots of modules that imported llds. |
||
|
|
41be69cb26 |
Add the infrastructure for assertions into the compiler.
Estimated hours taken: 0.25
Add the infrastructure for assertions into the compiler.
compiler/notes/compiler_design.html:
Update documentation about exactly where quantification is done.
compiler/notes/glossary.html:
Define what an assertion is.
|
||
|
|
ec86c88404 |
Merge in the changes from the existential_types_2 branch.
Estimated hours taken: 4 Merge in the changes from the existential_types_2 branch. This change adds support for mode re-ordering of code involving existential types. The change required modifying the order of the compiler passes so that polymorphism comes before mode analysis, so that mode analysis can check the modes of the `type_info' or `typeclass_info' variables that polymorphism introduces, so that it can thus re-order the code accordingly. This change also includes some more steps towards making existential data types work. In particular, you should be able to declare existentially typed data types, the compiler will generate appropriate unification and compare/3 routines for them, and deconstruction unifications for them should work OK. However, currently there's no way to construct them except via `pragam c_code', and we don't generate correct RTTI for them, so you can't use `io__write' etc. on them. library/private_builtin.m: compiler/accumulator.m: compiler/bytecode_gen.m: compiler/check_typeclass.m: compiler/clause_to_proc.m: compiler/code_util.m: compiler/common.m: compiler/dead_proc_elim.m: compiler/dependency_graph.m: compiler/det_analysis.m: compiler/det_report.m: compiler/follow_code.m: compiler/follow_vars.m: compiler/goal_util.m: compiler/higher_order.m: compiler/hlds_goal.m: compiler/hlds_out.m: compiler/hlds_pred.m: compiler/intermod.m: compiler/lambda.m: compiler/live_vars.m: compiler/magic.m: compiler/make_hlds.m: compiler/mercury_compile.m: compiler/mercury_to_c.m: compiler/mode_errors.m: compiler/mode_info.m: compiler/mode_util.m: compiler/modecheck_call.m: compiler/modecheck_unify.m: compiler/modes.m: compiler/pd_cost.m: compiler/polymorphism.m: compiler/post_typecheck.m: compiler/purity.m: compiler/quantification.m: compiler/rl_exprn.m: compiler/rl_key.m: compiler/simplify.m: compiler/table_gen.m: compiler/term_traversal.m: compiler/type_util.m: compiler/typecheck.m: compiler/unify_gen.m: compiler/unify_proc.m: compiler/unique_modes.m: compiler/unused_args.m: compiler/notes/compiler_design.html: doc/reference_manual.texi: tests/hard_coded/typeclasses/Mmakefile: tests/hard_coded/typeclasses/existential_data_types.m: tests/hard_coded/typeclasses/existential_data_types.exp: tests/warnings/simple_code.exp: tests/hard_coded/Mmakefile: tests/term/arit_exp.trans_opt_exp: tests/term/associative.trans_opt_exp: tests/term/pl5_2_2.trans_opt_exp: tests/term/vangelder.trans_opt_exp: tests/term/arit_exp.trans_opt_exp: tests/term/associative.trans_opt_exp: tests/term/pl5_2_2.trans_opt_exp: tests/term/vangelder.trans_opt_exp: tests/invalid/errors2.err_exp2: tests/invalid/prog_io_erroneous.err_exp2: tests/invalid/type_inf_loop.err_exp2: tests/invalid/types.err_exp2: tests/invalid/polymorphic_unification.err_exp: tests/invalid/Mmakefile: tests/warnings/simple_code.exp: tests/debugger/queens.exp: tests/hard_coded/Mmakefile: tests/hard_coded/existential_reordering.m: tests/hard_coded/existential_reordering.exp: Merge in the changes from the existential_types_2 branch. |
||
|
|
8ab130a3b0 |
Add a new pass to the compiler, that attempts to introduce accumulators
Estimated hours taken: 500
Add a new pass to the compiler, that attempts to introduce accumulators
into a procedure so as to make that procedure tail recursive.
WORK_IN_PROGRESS:
Document that the transformation now exists.
compiler/goal_util.m:
Create goal_util__can_reorder_goals, which is a version of
pd_util__can_reorder_goals that will work on the alias branch.
compiler/instmap.m:
Add instmap__changed_vars. This predicate is meant to provide the
same functionality as instmap_delta_changed_vars, but work on the
alias branch.
Also add comment to instmap_delta_changed_vars about using
instmap_changed_vars
compiler/accumulator.m:
The transformation.
compiler/mercury_compile.m:
Call the transformation.
compiler/options.m:
Add the option to turn the transformation on.
doc/user_guide.texi:
Document the option.
profiler/demangle.m:
util/mdemangle.c:
Demangle the accumulator version of the procedure labels.
compiler/notes/compiler_design.html:
Add the new pass to the documentation.
|
||
|
|
fabfb2c7bc |
Update the description of the check_typeclass phase to indicate
Estimated hours taken: 0.25
compiler/notes/compiler_design.html:
Update the description of the check_typeclass phase to indicate
that it:
- comes before type checking
- performs a source-to-source transformation
to defer most
of the checking to later passes.
Also delete mention of qualifying pred and func names in
check_typeclass.m; all that work gets done by the later passes now.
|
||
|
|
31373e6d96 |
Improve the documentation of Aditi code generation by
Estimated hours taken: 0.25 compiler/notes/compiler_design.html: Improve the documentation of Aditi code generation by splitting out the section describing the modules involved in the output from those involved in code generation. |
||
|
|
18430aaef1 |
Aditi compilation.
Estimated hours taken: 1200
Aditi compilation.
compiler/options.m:
The documentation for these is commented out because the Aditi
system is not currently useful to the general public.
--aditi: enable Aditi compilation.
--dump-rl: write the intermediate RL to `<module>.rl_dump'.
--dump-rl-bytecode: write a text version of the bytecodes
to `<module>.rla'
--aditi-only: don't produce a `.c' file.
--filenames-from-stdin: accept a list of filenames to compile
from stdin. This is used by the query shell.
--optimize-rl, --optimize-rl-cse, --optimize-rl-invariants,
--optimize-rl-index, --detect-rl-streams:
Options to control RL optimization passes.
--aditi-user:
Default owner of any Aditi procedures,
defaults to $USER or "guest".
--generate-schemas:
write schemas for base relations to `<module>'.base_schema
and schemas for derived relations to `<module>'.derived_schema.
This is used by the query shell.
compiler/handle_options.m:
Handle the default for --aditi-user.
compiler/hlds_pred.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
Add some Aditi pragma declarations - `aditi', `supp_magic', `context',
`naive', `psn' (predicate semi-naive), `aditi_memo', `aditi_no_memo',
`base_relation', `owner' and `index'.
Separate out code to parse a predicate name and arity.
compiler/hlds_pred.m:
Add predicates to identify Aditi procedures.
Added markers `generate_inline' and `aditi_interface', which
are used internally for Aditi code generation.
Add an `owner' field to pred_infos, which is used for database
security checks.
Add a field to pred_infos to hold the list of indexes for a base
relation.
compiler/make_hlds.m:
Some pragmas must be exported if the corresponding predicates
are exported, check this.
Make sure stratification of Aditi procedures is checked.
Predicates with a mode declaration but no type declaration
are no longer assumed to be local.
Set the `do_aditi_compilation' field of the module_info if there
are any local Aditi procedures or base relations.
Check that `--aditi' is set if Aditi compilation is required.
compiler/post_typecheck.m:
Check that every Aditi predicate has an `aditi__state' argument,
which is used to ensure sequencing of updates and that Aditi
procedures are only called within transactions.
compiler/dnf.m:
Changed the definition of disjunctive normal form slightly
so that a call followed by some atomic goals not including
any database calls is considered atomic. magic.m can handle
this kind of goal, and it results in more efficient RL code.
compiler/hlds_module.m:
compiler/dependency_graph.m:
Added dependency_graph__get_scc_entry_points which finds
the procedures in an SCC which could be called from outside.
Added a new field to the dependency_info, the
aditi_dependency_ordering. This contains all Aditi SCCs of
the original program, with multiple SCCs merged where
possible to improve the effectiveness of differential evaluation
and the low level RL optimizations.
compiler/hlds_module.m:
Add a field to record whether there are any local Aditi procedures
in the current module.
Added versions of module_info_pred_proc_info and
module_info_set_pred_proc_info which take a pred_proc_id,
not a separate pred_id and proc_id.
compiler/polymorphism.m:
compiler/lambda.m:
Make sure that predicates created for closures in Aditi procedures
have the correct markers.
compiler/goal_util.m:
Added goal_util__switch_to_disjunction,
goal_util__case_to_disjunct (factored out from simplify.m)
and goal_util__if_then_else_to_disjunction. These are
require because supplementary magic sets can't handle
if-then-elses or switches.
compiler/type_util.m:
Added type_is_aditi_state/1.
compiler/mode_util.m:
Added partition_args/5 which partitions a list of arguments
into inputs and others.
compiler/inlining.m:
Don't inline memoed procedures.
Don't inline Aditi procedures into non-Aditi procedures.
compiler/intermod.m:
Handle Aditi markers.
Clean up handling of markers which should not appear in `.opt' files.
compiler/simplify.m:
Export a slightly different interface for use by magic.m.
Remove explicit quantifications where possible.
Merge multiple nested quantifications.
Don't report infinite recursion warnings for Aditi procedures.
compiler/prog_out.m:
Generalised the code to output a module list to write any list.
compiler/code_gen.m:
compiler/arg_info.m:
Don't process Aditi procedures.
compiler/mercury_compile.m:
Call magic.m and rl_gen.m.
Don't perform the low-level annotation passes on Aditi procedures.
Remove calls to constraint.m - sometime soon a rewritten version
will be called directly from deforestation.
compiler/passes_aux.m:
Add predicates to process only non-Aditi procedures.
compiler/llds.m:
compiler/llds_out.m:
Added new `code_addr' enum members, do_{det,semidet,nondet}_aditi_call,
which are defined in extras/aditi/aditi.m.
compiler/call_gen.m:
Handle generation of do_*_aditi_call.
compiler/llds_out.m:
Write the RL code for the module as a constant char array
in the `.c' file.
compiler/term_errors.m:
compiler/error_util.m:
Move code to describe predicates into error_util.m
Allow the caller to explicitly add line breaks.
Added error_util:list_to_pieces to format a list of
strings.
Reordered some arguments for currying.
compiler/hlds_out.m:
Don't try to print clauses if there are none.
runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
Added a function `mercury__load_aditi_rl_code()' to the generated
`<module>_init.c' file which throws all the RL code for the program
at the database. This should be called at connection time by
`aditi__connect'.
Added an option `--aditi' which controls the output
`mercury__load_aditi_rl_code()'.
compiler/notes/compiler_design.html:
Document the new files.
Mmakefile:
bindist/Mmakefile:
Don't distribute extras/aditi yet.
New files:
compiler/magic.m:
compiler/magic_util.m:
Supplementary magic sets transformation. Report errors
for constructs that Aditi can't handle.
compiler/context.m:
Supplementary context transformation.
compiler/rl_gen.m:
compiler/rl_relops.m:
Aditi code generation.
compiler/rl_info.m:
Code generator state.
compiler/rl.m:
Intermediate RL representation.
compiler/rl_util:
Predicates to collect information about RL instructions.
compiler/rl_dump.m:
Print out the representation in rl.m.
compiler/rl_opt.m:
Control low-level RL optimizations.
compiler/rl_block.m:
Break a procedure into basic blocks.
compiler/rl_analyse.m:
Generic dataflow analysis for RL procedures.
compiler/rl_liveness.m:
Make sure all relations are initialised before used, clear
references to relations that are no longer required.
compiler/rl_loop.m:
Loop invariant removal.
compiler/rl_block_opt.m:
CSE and instruction merging on basic blocks.
compiler/rl_key.m:
Detect upper/lower bounds for which a goal could succeed.
compiler/rl_sort.m:
Use indexing for joins and projections.
Optimize away unnecessary sorting and indexing.
compiler/rl_stream.m:
Detect relations which don't need to be materialised.
compiler/rl_code.m:
RL bytecode definitions. Automatically generated from the Aditi
header files.
compiler/rl_out.m:
compiler/rl_file.m:
Output the RL bytecodes in binary to <module>.rlo (for use by Aditi)
and in text to <module>.rla (for use by the RL interpreter).
Also output the schema information if --generate-schemas is set.
compiler/rl_exprn.m:
Generate bytecodes for join conditions.
extras/aditi/Mmakefile:
extras/aditi/aditi.m:
Definitions of some Aditi library predicates and the
interfacing and transaction processing code.
|
||
|
|
3e244090d7 |
Rework the handling of types in higher_order.m.
Estimated hours taken: 50 Rework the handling of types in higher_order.m. - Fix bugs in higher_order.m that stopped it working with --typeinfo-liveness. - Perform type and typeclass specialisation. compiler/polymorphism.m: Previously the type of typeclass_infos variables did not contain any information about the constraint about which the variable contains information. Now the type of a typeclass_info is `private_builtin:typeclass_info( private_builtin:constraint([ClassName, ConstrainedTypes]))'. This allows predicates such as type_list_subsumes to check that the class constraints match. Note that `private_builtin:constraint' has no declaration, so a lookup in the type definition map will fail. That's OK, because type_to_type_id will fail on it, so it will be treated as a type variable by any code which doesn't manipulate types directly. Added polymorphism__typeclass_info_class_constraint to get the class_constraint from a typeclass_info's type. This isn't used yet. Also, fix a bug in extract_type_info: an entry in the typeinfo_var_map was being overwritten using an entry from a dummy typevarset. Actually the optimization to overwrite the location of the type_info after extracting it from a typeclass_info was wrong because the type_info won't be in that location in other branches. compiler/higher_order.m: Rework the handling of type substitutions. Now the types of the called procedure are `inlined' into the calling procedure, rather than building up the types of the specialised version using the higher-order arguments. The advantage of this is that the code is a bit simpler and handles extra type_infos properly. The disadvantage is that the argument types for specialised versions may be more specific than they need to be, so in some cases more specialised versions will be created than before. Also, don't actually rebuild the higher-order terms in the specialised versions - just pass the terms through in case they are needed. Handle the extra typeinfos required for --typeinfo-liveness. Specialize calls to unify/2, index/2 and compare/3. Specialize class_method_calls. Specialize calls to the predicates in private_builtin.m which manipulate typeclass_infos. compiler/type_util.m: type_to_type_id now fails on the dummy `constraint' type. Remove typeinfos for non-variable types from the typeinfo_varmap after inlining and higher-order specialisation. compiler/inlining.m: Factor out some common code to handle type substitutions for use by higher_order.m. compiler/hlds_pred.m: Return the list of extra type_info variables added to the argument list. compiler/goal_util.m: Take a set of non-locals as an argument to goal_util__extra_nonlocal_typeinfos rather than extracting them from a goal. compiler/special_pred.m: Handle unmangled unify/compare/index in special_pred_get_type. compiler/base_type_layout.m: Don't generate references to the typeinfo for `private_builtin:constraint' - it doesn't exist. compiler/unused_args.m: Don't barf on specialised unification predicate names. compiler/options.m: Added options: `--type-specialization' (default off). `--higher-order-size-limit' - restrict the size of specialized versions produced by higher_order.m. `--disable-opt-for-trace' (default on) - where possible don't change the options to make the trace match the source code. compiler/handle_options.m: Don't disable higher_order.m when --typeinfo-liveness is set. Handle `--disable-opt-for-trace'. compiler/hlds_data.m: compiler/*.m: Add the instance number to `base_typeclass_info_const' cons_ids, so that higher_order.m can easily index into the list of instances for a class to find the methods. compiler/hlds_out.m: Use the correct varset when printing out the constraint proofs. Write the typeclass_info_varmap for each procedure. compiler/mercury_to_mercury.m: Print type variables with variable numbers. library/private_builtin.m: Add the argument to the typeclass_info type to hold the representation of the constraint. runtime/mercury_ho_call.c: Semidet and nondet class_method_calls where (0 < num_arg_typeclass_infos < 4) were aborting at runtime because arguments were being placed starting at r1 rather than at r(1 + num_arg_typeclass_infos). doc/user_guide.texi Document the new options. compiler/notes/compiler_design.html: Update the role of higher_order.m. tests/hard_coded/typeclasses/extra_typeinfo.m: Test case for the mercury_ho_call.c bug and the polymorphism.m extract_typeinfo bug and for updating the typeclass_info_varmap for specialised versions. |