--no-ansi (mgnuc) and --no-ansi-c (mmc) have not actually done anything for
many years now. Deprecate these options and remove their "use" throughout most
of the Mercury system. (The remaining uses are in the Makefiles for the Boehm
GC, which need to be updated separately.)
Also deprecate the internal compiler option --cflags-for-ansi.
compiler/options.m:
Document that --no-ansi-c is now deprecated.
Document that the internal option --cflags-for-ansi is now
deprecated.
compiler/compile_target_code.m:
Do not pass the ANSI options to the C compiler.
scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
Deprecate the --no-ansi option; delete code that no longer does
anything useful.
configure.ac:
Delete the configuration variable CFLAGS_FOR_ANSI; it is only ever
set to be empty. (The comment talks about --no-ansi doing other things
in the mgnuc script. It used to also cause some preprocessor macros
to be defined for compatibility with the system headers on some
platforms -- that has not been the case since 2013.)
doc/user_guide.texi:
Document that --no-ansi-c is deprecated.
bytecode/Mmakefile:
compiler/Mercury.options:
library/Mercury.options:
extras/odbc/odbc.m:
runtime/Mmakefile:
scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
tests/hard_coded/Mercury.options:
tests/valid/Mercury.options:
trace/Mmakefile:
util/Mmakefile:
Conform to the above change.
NEWS.md:
Announce the above.
This allows the compiler to eliminate the construction of typeinfo
arguments for calls to version_array.lookup and version_array.set,
when compiling with intermodule optimisation and --optimize-unused-args.
In particular, version_hash_table would previously dynamically construct
typeinfos in order lookup or update hash table buckets.
This change improves the run time of a do-nothing build of Prince using
mmc --make on my machine from 1.6 s to 1.43 s.
library/version_array.m:
Add pragma inlines for version_array.lookup and version_array.set.
library/Mercury.options:
Always compile version_hash_table with --optimize-unused-args.
configure.ac:
Require the installed compiler to support disable_warning scopes
for unknown_format_calls.
compiler/Mercury.options:
library/Mercury.options:
Do not disable unknown_format_call warnings in whole files.
compiler/parse_tree_out_info.m:
compiler/pd_debug.m:
library/io.m:
library/stream.string_writer.m:
library/string.m:
Disable unknown_format_call warnings for just the format calls
that need it.
library/ra_list.m:
As above.
Rename ra_list_lookup to ra_list_search, since it fails if the item
to be accessed does not exist. Add a version, ra_list_lookup, which
aborts in that case.
Add predicates to append two ra_lists, and to convert ra_lists
to just plain lists.
Change the argument order of some predicates to be more
state variable friendly.
Add some documentation.
library/bt_array.m:
Delete the moved code, and update the references to the changed predicates.
library/Mercury.options:
Now that the ra_list predicates have been moved to their own module,
stop giving bt_array.m a free pass on inconsistent predicate order.
library/MODULES_DOC:
library/library.m:
Add ra_list.m as a documented module of the Mercury standard library.
library/array.m:
Delete a predicate that served as a test for an ancient bug fix.
NEWS:
Announce both the new ra_list module, and the deletion of the predicate
from array.m.
tests/hard_coded/array_sort.m:
Don't call the predicate deleted from array.m.
tests/hard_coded/ra_list_test.{m,exp}:
A new test case to test operations on ra_lists.
tests/hard_coded/Mmakefile:
Enable the new test case.
library/robdd.m:
Put related predicates (as best as I can tell) next to each other,
and put the groups of related predicates into a meaningful order.
library/Mercury.options:
Enable the warning about inconsistent predicate order for robdd.m.
library/array.m:
library/bt_array.m:
library/pprint.m:
In each of these modules,
- put related predicates next to each other,
- put the groups of related predicates into a meaningful order, and
- improve the documentation of some predicates, and
- improve some variable names in the implementation, including giving
explicit names to some function results.
library/Mercury.options:
Enable the warning about inconsistent predicate order for two of those
modules, but not bt_array.m, pending a decision about making its
informal "submodule" an actual separate module.
... move the implementation of flush_*output to io.stream_ops.m.
In both cases, improve the predicate names a bit.
Add a distinguishing prefix to the names of the function symbols of a type,
to reduce the number of times the function symbol names ok, error and eof
are overloaded from ridiculous to slighly less ridiculous :-(
Move related predicate arguments next to each other.
library/io.text_read.m:
New submodule containing the code that implement the predicates
that read values of non-primitive types, all but one of which are text.
library/io.stream_ops.m:
Move the implementation of flushing output here from io.m.
library/io.m:
Delete the code moved to the above modules.
library/MODULES_UNDOC:
library/library.m:
List the new submodule as undocumented.
library/Mercury.options:
Allow io.text_read.m, instead of io.m, to define an inst for a type
that has a definition in a foreign language as well as Mercury.
This diff moves this inst definition to io.text_read.m.
... and obsolete the globals structure in the I/O state.
library/io.m:
Move the implementations of the predicates that read and write bitmaps
to bitmap.m. Leave forward predicates in io.m, but mark them obsolete.
Mark the predicates that get, set and update the globals structure
stored in the I/O state as obsolete.
Export some functionality used by the moved code. The exports are
in the second, undocumented interface section.
Improve the names of some internal predicates.
Add some module qualifiers to reduce type ambiguities.
library/Mercury.options:
Disable obsolete warnings for io.m, to allow the initialization
of the I/O state to initialize the globals as well; the globals
are now marked obsolete, but they do still exist.
library/bitmap.m:
Move the predicates for reading and writing bitmaps here from io.m.
Add a "_range" suffix to the names of the predicates that read and write
a range in a bitmap. Without this, both read_bitmap and write_bitmap
existed with *four* arities. Now each of these predicates has only
two arities: one with an explicit stream, and one without.
Document a spot that may need double maintance.
Move the hash functions before the predicates that do I/O.
NEWS:
Announce the changes.
library/bit_buffer.read.m:
Document a spot that may need double maintance.
Fix some comments, and indentation.
profiler/globals.m:
Use a mutable to replace the system's only remaining use of
the globals structure in the I/O state.
Stop exporting a predicate used only locally.
Delete unneeded module qualifiers on predicate declarations and
clause heads.
library/*.m:
Delete Erlang foreign code and foreign types.
Delete documentation specific to Erlang targets.
library/deconstruct.m:
Add pragma no_determinism_warning to allow functor_number_cc/3
to compile for now.
library/Mercury.options:
Delete workaround only needed when targetting Erlang.
browser/listing.m:
mdbcomp/rtti_access.m:
Delete Erlang foreign code and foreign types.
library/getopt_io.m:
As above.
library/getopt.m:
library/getopt_io.m:
Minor changes to things like variable names to remove unneeded
differences between these two files.
The only differences now remaining are those that relate to:
- the name of the module, e.g. in error messages,
- the presence of an I/O state pair in getopt_io.m, and
- the file_special option kind, which is why getopt_io.m needs
the I/O states.
library/Mercury.options:
Enforce the match between definition order and declaration order
for getopt.m as well.
library/getopt_io.m:
Improve the documentation.
Make the definition order of predicates match the declaration order.
Improve some predicate names and variable names.
library/Mercury.options:
Enforce the match between definition order and declaration order.
library/io.m:
Put the contents of the implementation section of io.m into
the same order as the interface section, after some minor reordering
in the interface section.
library/Mercury.options:
Don't specify --no-warn-inconsistent-pred-order-clauses for io.m
anymore.
library/set.m:
Organize the predicates of this modules a lot better, clustering
related predicates into named groups, and imposing a meaningful order
both within and among groups.
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
Put the predicates of these modules into the same order as set.m
as far as possible given that some of these modules define predicates
that set.m doesn't, and vice versa.
Delete any redundant module qualifications in clause heads and predicate
and function declarations. In calls to error, use $pred to specify the
location.
library/Mercury.options:
Require the order of definitions in these modules to match the order
of declarations.
library/LIB_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
Specify --warn-inconsistent-pred-order-clauses as a default flag
in these directories as well.
library/string.m:
Reorder code to make this module compile cleanly with
--warn-inconsistent-pred-order-clauses.
Don't export base_string_to_int_underscore to lexer.m, since
lexer.m does not use it anymore, and neither does anything else.
(The export was not publicly documented.)
library/benchmarking.m:
library/bitmap.m:
library/builtin.m:
library/map.m:
library/profiling_builtin.m:
library/rbtree.m:
library/table_builtin.m:
library/uint.m:
profiler/globals.m:
profiler/options.m:
profiler/prof_info.m:
slice/mdice.m:
slice/mslice.m:
slice/mtc_diff.m:
slice/mtc_union.m:
ssdb/ssdb.m:
Reorder code to make these modules compile cleanly with
--warn-inconsistent-pred-order-clauses.
library/Mercury.options:
Specify --no-warn-inconsistent-pred-order-clauses for the modules
that would still get warnings without this option.
library/exception.m:
library/io.m:
For each predicate, put all its clauses and foreign_procs next to each
other.
library/Mercury.options:
Do not pass --no-warn-non-contiguous-clauses and
--no-warn-non-contiguous-foreign-procs to the Mercury compiler
when compiling exception.m and io.m, since they do not need this
anymore.
Do not pass --no-halt-at-warn to the Mercury compiler
when compiling io.m, since this should not have been needed
since 2009.
configure.ac:
Require the installed compiler to have the recent bug fix to
contiguity warnings, since without that bug fix, we get warnings
for code that is actually perfectly ok.
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
Specify both --warn-non-contiguous-clauses and
--warn-non-contiguous-foreign-procs as the default in each directory.
library/Mercury.options:
Disable the warnings for exception.m and io.m, which are have not
been cleaned up yet wrt these warnings.
library/int8.m:
library/int16.m:
library/int32.m:
library/int64.m:
library/uint8.m:
library/uint16.m:
library/uint32.m:
library/uint64.m:
Impose the same structure on all these modules to pretty much
the maximum extent possible. The obvious differences include things
such as the modules for the unsigned variants not containing predicates
for computing absolute values, for returning their minimum value,
or for unary minus (or plus), nor having any differences between
flooring and truncating division. There are also differences
in whether conversion predicates to or from the int type may fail.
library/Mercury.options:
Require these modules to have the same order of definitions as
declarations.
library/int16.m:
library/int32.m:
library/int64.m:
Replace the implementations of some operations with calls to
their unsigned counterparts.
library/uint16.m
Implement reverse_bits/1 in Mercury. (For the Java backend,
we still call the version in the Java library.)
library/Mercury.options:
Do not warn about unused imports in the int32 module.
Replace placeholder types with int64 and uint64 as appropriate throughout the
system.
Enable support for 64-bit integer literals in the compiler.
Add initial library support for 64-bit integers.
configure.ac:
Check that the bootstrap compiler recognises int64 and uint64 as
builtins.
library/int64.m:
library/uint64.m:
Populate these two modules to the extent that we can now run
basic tests of 64-bit integer support.
Note that since the bootstrap compiler will not recognise
64-bit integer literals, any such literals are current written
as conversions from ints; this will be replaced once this change
has bootstrapped.
library/private_builtin.m:
Replace the placeholder definitions for builtin unification and
comparison of 64-bit integers with their actual definitions.
library/integer.m:
Add procedures for converting integers to- and from int64 and uint64.
library/string.m:
Add functions for converting 64-bit integers into strings.
library/io.m:
Add predicates for writing 64-bit integers to text streams.
(Support for 64-bit integers with binary streams will be done
separately.)
library/stream.string_writer.m:
Add put_int64/4 and put_uint/64.
Extend the implementations of print and write to cover int64 and
uint64.
library/pprint.m:
Make int64 and uint64 instances of the doc/1 type class.
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
Handle int64 and uint64 properly in deconstruct.
library/term.m:
Add functions for converting 64-bit integers into terms.
library/term_conversion.m:
Support int64 and uint64 in univ -> term conversion.
library/Mercury.options:
Avoid a warning about the import of the require being
unused in the int64 and uint64 modules. It *is* used,
but only in the definitions used by the Erlang backend.
compiler/superhomogeneous.m:
Accept 64-bit integer literals.
compiler/c_util.m:
In C, write out the value of the min_int64 as the symbolic
constant INT64_MIN. This expands in such a way as to avoid
generating warnings from the C compiler.
compiler/builtin_ops.m:
compiler/bytecode.m:
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/hlds_data.m:
compiler/hlds_out_util.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/lookup_switch.m:
compiler/mercury_to_mercury.m:
compiler/mlds.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_to_term.m:
compiler/prog_data.m:
compiler/prog_out.m:
compiler/prog_rep.m:
Replace the use of int as a placeholder with int64 or uint64 as
appropriate.
tests/hard_coded/Mmakefile:
tests/hard_coded/arith_int64.{m,exp}:
tests/hard_coded/arith_uint64.{m,exp}:
tests/hard_coded/bitwise_int64.{m,exp}:
tests/hard_coded/bitwise_uint64.{m,exp}:
tests/hard_coded/cmp_int64.{m,exp}:
tests/hard_coded/cmp_uint64.{m,exp}:
tests/hard_coded/integer_int64_conv.{m,exp}:
tests/hard_coded/integer_uint64_conv.{m,exp}:
Add tests of basic operations on 64-bit integers.
tests/hard_coded/construct_test.{m,exp}:
Extend this test to cover 64-bit integers.
On tools/speedtest -l, my three tests shows speedups between 7% and 12%
for this diff. For Dirk's stress test module, for which the compiler
spends almost all its time handling insts, the speedup was bigger:
the compilation time went from 3.6 to 2.3 seconds.
compiler/inst_user.m:
A new module that pretests user defined bound insts, and records
the results in the insts themselves, so that those tests won't
have to be done repeatedly, each time the compiler needs their results.
compiler/check_hlds.m:
compiler/notes/compiler_design.html:
Include the new module.
compiler/mercury_compile_front_end.m:
Invoke the new module.
compiler/inst_check.m:
Rewrite this module to record, for each user defined bound inst, the type
constructor(s) that the top-level bound insts match. This should allow a
later diff to make inst_user.m more effective by pre-pushing the one
matching type constructor into the inst, for insts that *do* have exactly
*one* matching type constructor.
The information needed for this also allows us to generate more precise
error messages, fulfilling an earlier TODO.
compiler/hlds_data.m:
Add a field to inst definitions to allow this recording.
Don't hide the representation of the table of user insts. It just makes
code working with it harder, and provides no benefit, since any useful
structure imposed on top of the current simple map would require the
lookups to be done *inside* the abstraction barrier, which the current
design does not allow.
compiler/prog_data.m:
Add a redundant field to the representation of data constructors (function
symbols) in type definitions. This field holds the number of arguments
of the function symbols, computed just once when the representation is
created, rather than many times later on in many parts of the compiler.
compiler/prog_io_type_defn.m:
Fill in the new redundant field when the constructor representations
are created.
compiler/mode_util.m:
Avoid the use of higher order code in a predicate that happens to be
performance critical when compiling Dirk's stress test module.
compiler/add_mode.m:
compiler/add_type.m:
compiler/check_typeclass.m:
compiler/du_type_layout.m:
compiler/equiv_type.m:
compiler/export.m:
compiler/hhf.m:
compiler/hlds_module.m:
compiler/hlds_out_module.m:
compiler/inst_check.m:
compiler/intermod.m:
compiler/make_tags.m:
compiler/mercury_to_mercury.m:
compiler/ml_type_gen.m:
compiler/module_qual.m:
compiler/post_typecheck.m:
compiler/prog_type.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/special_pred.m:
compiler/term_constr_build.m:
compiler/term_norm.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the changes above.
library/Mercury.options:
Disable the trace flag that calls for the runtime testing of the invariants
of the tree_bitset.m module. We have tested it far more than necessary,
and it has been just overhead for a long time now. This helps speed up
quantification, which takes nontrivial time on Dirk's module.
library/multi_map.m:
Add a utility predicate needed above. It is a reverse set, i.e. a set
with a value, key argument order.
Put the code for the function versions of predicates next to the code
for the predicate versions.
tests/warnings/inst_with_no_type.m:
tests/valid/inst_perf_bug_1.m:
Fix indentation.
tests/warnings/inst_with_no_type.exp:
Update this file to expect the new and improved error messages now
generated by inst_check.m.
*/*_FLAGS.in:
Specify that by default, the compiler should generate warnings
for unknown format strings and bad known format strings.
*/Mercury.options:
Override this default setting for a few modules that have legitimate
reasons for calling e.g. string.format with unknown format strings.
compiler/fact_table.m:
deep_profiler/html_format.m:
Minor changes to avoid calling string.format with unknown format strings.
Estimated hours taken: 0.5
Branches: main
library/tree_bitset.m:
Put all the assertions into trace goals that can be switched on or off
at will.
If the assertions are disabled, we get a speedup of more than 7%
on tools/speedtest.
library/Mercury.options:
Given the recently discovered bugs in the tree_bitset module,
enable the assertions for now.
Branches: main
Mark procedures whose names use the suffix "_det" to indicate that the procedure
is a det version of a semidet procedure of the same name (modulo the suffix) as
obsolete. The versions that use "det_" as a prefix should be used instead.
(The latter naming scheme is the one in general use throughout the standard
library.)
library/dir.m:
library/list.m:
library/stack.m:
As above.
Add versions with the "det_" suffix where they were not already
present.
Group function definitions together with the corresponding
predicate definition.
library/cord.m:
library/erlang_rtti_implementation.m:
library/io.m:
library/string.m:
compiler/*.m:
browser/declarative_execution.m:
browser/declarative_tree.m:
ssdb/ssdb.m:
Conform to the above changes.
library/Mercury.options:
Delete a setting for a deleted module.
NEWS:
Announce this change.
Estimated hours taken: 2
deep_profiler/autopar_calc_overlap.m:
New module for calculating the overlap between the conjuncts of a
parallelised conjunction. Its contents are taken from the old
autopar_search_callgraph.m.
deep_profiler/autopar_costs.m:
New module for calculating the costs of goals. Its contents
are taken from the old autopar_search_callgraph.m.
deep_profiler/autopar_reports.m:
New module for creating reports. Its contents are taken from
the old autopar_search_callgraph.m.
deep_profiler/autopar_search_goals.m:
New module for searching goals for parallelizable conjunctions.
Its contents are taken from the old autopar_search_callgraph.m.
deep_profiler/autopar_search_callgraph.m:
Remove the code moved to other modules.
deep_profiler/mdprof_fb.automatic_parallelism.m:
Add the new modules.
deep_profiler/*.m:
Remove unnecessary imports.
Fix copyright years on the new modules.
browser/*.m:
compiler/*.m:
mdbcomp/*.m:
Remove unnecessary imports.
library/Mercury.options:
Make it possible to compile a whole workspace with
--warn-unused-imports by turning that option off for type_desc.m
(which has a necessary import that --warn-unused-imports thinks
is unused).
extras/lazy_evaluation/README:
Note that lazy.m is now in the standard library.
extras/lazy_evaluation/lazy.m:
library/Mercury.options:
NEWS:
Implemented review comments from my previous change.
This patch fixes various problems, the most significant is the calculation of
variable use information. The parallelisation analysis uses deep profiling
data. In other words, profiling data that is attached to context information
referring to not just the procedure but the chain of calls leading to that
invocation of that procedure (modulo recursion). The variable use analysis did
not use deep profiling data, therefore comparing the time that a variable is
produced with a call to the time in total of that call was not sound, and
sometimes resulted in information that is not possible, such as a variable
being produced or consumed after the call that produces or consumes it has
exited.
This change-set updates the variable use analysis to use deep profiling data to
avoid these problems. At the same time it provides more accurate information
to the automatic parallelisation pass. This is possible because of an earlier
change that allowed the coverage data to use deep profiling data.
In its current state, the parallelisation analysis now finishes without errors
and computes meaningful results when analysing a profile of the mercury
compiler's execution.
deep_profiler/report.m:
The proc var use report is now a call site dynamic var use report.
1) It now uses deep profiling data.
2) It makes more sense from the callers perspective so it's now based
around a call site rather than a proc.
Add inst subtypes to the recursion_type type.
deep_profiler/query.m:
The proc var use query is now a call site dynamic var use query, see
report.m.
deep_profiler/var_use_analysis.m:
Fix a bug here and in mdprof_fb.automatic_parallelism.m: If a
variable is consumed by a call and appears in it's argument list more than
once, take the earliest consumption time rather than the one for the
earliest argument.
Variable use analysis now uses recursion_patterns.m to correctly compute
the cost of recursive calls. It also uses 'deep' profiler data.
Only measure variable use relative to the entry into a procedure, rather
than either relative to the entry or exit. This allows us to simplify a
lot of code.
deep_profiler/create_report.m:
The proc var use info report is now a call site dynamic var use info
report.
Move some utility code from here to the new analysis_utils.m module.
deep_profiler/display_report.m:
Conform to changes in report.m.
Improve the information displayed for variable first-use time
reports.
deep_profiler/mdprof_fb.automatic_parallelism.m:
Conform to changes in report.m
Refactored the walk down the clique tree. This no-longer uses the
clique reports from the deep profiling tool.
We now explore the same static procedure more than once. It may be best to
parallelise it in some contexts rather than others but for now we assume
that the benefits in some context are worth the costs without benefit in
the other contexts. This is better than reaching a context where it is
undesirable first and never visiting a case where parallelisation is
desirable.
Fix a bug in the calculation of how much parallelisation is used by
parallelisations in a clique's parents. This used to trigger an
assertion.
Don't try to parallelize anything in the "exception" module.
There's probably other builtin code we should skip over here.
Removed an overzealous assertion that was too easily triggered by the
inaccuracies of IEEE-754 arithmetic.
Compute variable use information lazily for each variable in each call. I
believe that this has made our implementation much faster as it no-longer
computes information that is never used.
Refactor and move build_recursive_call_site_cost_map to the new
module analysis_utils.m where it can be used by other analyses.
Call site cost maps now use the cs_cost_csq type to store costs,
code in this module now conforms to this change.
Conform to changes in messages.m
deep_profiler/recursion_patterns.m:
Export a new predicate, recursion_type_get_maybe_avg_max_depth/2. This
retrieves the average maximum recursion depth from recursion types that know
this information.
Move code that builds a call site cost map for a procedure to
analysis_utils.m where it can be used by other analyses.
deep_profiler/analysis_utils.m:
Added a new module containing various utility predicates for profile
analysis.
deep_profiler/coverage.m:
Added an extra utility predicate get_coverage_after/2.
deep_profiler/message.m:
Each message has a location that it refers to, a new location type has
been added: call_site_dynamic.
Added a new warning that can be used to describe when a call site's
argument's use time cannot be computed.
Added new predicates for printing out messages whose level is below a
certain threshold. These predicates can be called from io trace goals.
Message levels start at 0 and currently go to 4, more critical messages
have lower levels. The desired verbosity level is stored in a module local
mutable.
deep_profiler/mdprof_feedback.m:
Move the message printing code from here to message.m.
deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
Conform to changes in query.m.
mdbcomp/feedback.automatic_parallelism.m:
Added a new function for computing the 'cpu time' of a parallel
computation.
library/lazy.m:
Moved lazy.m from extras to the standard library.
library/list.m:
Add a new predicate member_index0/3. Like member/2 except it also gives
the zero-based index of the current element within the list.
library/maybe.m:
Add two new insts.
maybe_yes(I) for the maybe type's yes/1 constructor.
maybe_error_ok(I) for the maybe_error type's ok/1 constructor.
library/Mercury.options:
Add a work around for compiling lazy.m with intermodule optimisations.
NEWS:
Update news file for the addition of lazy.m and the member_index0 predicate
in list.m
deep_profiler/.cvsignore:
Ignore feedback.automatic_parallelism.m which is copied by Mmakefile from
the mdbcomp/ directory.
with --profile-for-implicit-parallelism enabled. (The nightly
builds on taura do this.) This is bug #98 in Mantis.
library/Mercury.options:
Workaround the bug.
Estimated hours taken: 0.2
Branches: main
library/LIB_FLAGS.in:
library/Mercury.options:
Compile all modules in the library, not just a few, with
--optimize-constructor-last-call. I tried this last year, when
it yielded a slight slowdown on tools/speedtest; but now, it yields
a speedup of about 3.5%. The downside is not that important: a 2.8%
increase in the size of the archive file holding the Mercury standard
library.
Branches: main
library/dir.m:
library/io.m:
Update these modules using `:- pragma foreign_export' in Java grades
to fix undefined reference errors.
library/Mercury.options:
Set `--no-halt-at-warn' on io.m for now as compilers more than a week
old will warn about the foreign_exports, even though they work.
Estimated hours taken: 0.5
Branches: main
Avoid running out of stack space when parsing big terms.
library/Mercury.options:
Enable last-call-modulo-cons optimisation to make
`lexer.get_token_list_2' tail recursive.
library/parser.m:
Make `check_for_bad_token' tail recursive. Change the behaviour to
what should be the intended behaviour in the first place.
Write out a switch in full.
Branches: main
Implement more standard library predicates for Erlang.
configure.in:
library/Mercury.options:
library/erlang_conf.m.in:
Add a module erlang_conf.m which is generated from erlang_conf.m.in to
contain the VERSION and FULLARCH constants.
library/library.m:
Include erlang_conf.m and implement library.version.
library/dir.m:
Implement dir.make_directory, dir.make_single_directory.
library/io.m:
Implement io.file_modification_time and io.file_type.
Turn mercury_current_{text,binary}_{input,output} functions into
macros to avoid an intermodule function call each time we want to get
a current stream.
Fix io.call_system in the case that the called command produced no
output.
Delete an XXX from the Erlang implementation of io.rename_file,
which behaves properly (it was an misunderstanding).
library/time.m:
Fix time.c_time and time.c_difftime to work with {Date,Time} tuples
instead of just the Time part.
Estimated hours taken: 6
Branches: main
Add more documentation for the Erlang backend.
Make it possible to configure and install the Erlang backend without too
much manual tweaking.
NEWS:
Mention the Erlang backend.
README.Erlang:
Add installation and other notes for Erlang.
doc/reference_manual.texi:
doc/user_guide.texi:
Add documentation for Erlang.
aclocal.m4:
configure.in:
Check that the bootstrap compiler knows about the
builtin_compound_{eq,lt} builtins, and understands
--erlang-native-code.
Make configure check for Erlang tools.
Add configure --enable-erlang-grade option. Erlang support
is disabled by default.
scripts/Mercury.config.in:
Add `--erlang-compiler <erl>' and `--erlang-interpreter <erlc>'
options to be set by configure.
analysis/ANALYSIS_FLAGS.in:
compiler/COMP_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
Add `--erlang-include-directory <dir>/Mercury/hrls' options so that
the compiler can find Erlang header files from other subdirectories.
compiler/Mercury.options:
library/Mercury.options:
Work around bugs in the HiPE compiler when compiling two modules.
Delete the workaround that was necessary while bootstrapping
builtin_compound_{eq,lt}.
compiler/options.m:
Add notes that two options to check that the compiler is recent enough
won't be recognised because they begin "no-" prefixes, and we have
to use "--no-no-" instead.
compiler/options_file.m:
Support ERLANG_FLAGS, EXTRA_ERLANG_FLAGS variables in options files to
be the same as passing --erlang-flags.
browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
slice/Mmakefile:
trace/Mmakefile:
Make the build system do the same things in the Erlang grade as for
the IL and Java grades.
scripts/final_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Make these scripts know about the erlang grade so that parts of the
build system won't abort on seeing it.
Estimated hours taken: 25
Branches: main
Use Erlang comparison operators to compare compound (non-atomic) data values
when possible, which is a lot more efficient than using the comparison
predicates generated by Mercury. However, we can only do this if we know at
the call site that the values being compared don't have user-defined
equality/comparison predicates.
Also, we have to accept that Erlang won't order functors according to the order
they appear in the type definition. The comparison predicates we generate must
match the order which would be given by Erlang. (This was already a bug
before this change.)
In the implementation, we introduce two builtin predicates in private_builtin:
builtin_compound_eq and builtin_compound_lt. During simplifcation, we replace
applicable unifications by calls to builtin_compound_eq, and applicable calls
to builtin.compare by if-then-elses using builtin_compound_eq and
builtin_compound_lt. The calls to builtin_compound_eq and builtin_compound_lt
are translated into builtin operators compound_eq and compound_lt, which
eventually become =:= and < in the Erlang output.
With this change the Mercury compiler is ~35% faster when running as Erlang
bytecode (but still ~200x slower than asm_fast.gc).
library/private_builtin.m:
Add declarations for builtin_compound_eq and builtin_compound_lt.
library/Mercury.options:
Set --allow-stubs and --no-halt-at-warn for private_builtin.m until the
addition of the new builtins bootstraps.
mdbcomp/program_representation.m:
Mark builtin_compound_eq and builtin_compare_lt as polymorphic
predicates which don't take type_info arguments.
compiler/add_pred.m:
Don't add the following clauses when compiling private_builtin.m.
The bodies would be expanded out to use the compound_eq and compound_lt
builtins, but only the Erlang backend can support those.
builtin_compound_eq(X, Y) :- builtin_compound_eq(X, Y).
builtin_compound_lt(X, Y) :- builtin_compound_lt(X, Y).
compiler/builtin_ops.m:
Add the builtins compound_eq and compound_lt and their translations.
compiler/bytecode.m:
compiler/llds.m:
compiler/llds_to_x86_64.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
Conform to additions of compound_eq, compound_lt.
compiler/erl_call_gen.m:
Translate compound_eq, compound_lt to =:= and < respectively in Erlang.
compiler/options.m:
Add internal options --can-compare-compound-values and
--lexically-order-constructors.
compiler/handle_options.m:
Make --target erlang imply --can-compare-compound-values and
--lexically-order-constructors.
compiler/simplify.m:
If --can-compare-compound-values is set, transform applicable
unifications and comparisons using builtin_compound_eq and
builtin_compound_lt, as above.
Move a check for simplify_do_const_prop deeper in, otherwise
simplify_library_call would only be called if
--optimise-constant-propagation is set. simplify_library_call is where
we transform builtin.compare calls to use builtin_compound_{eq,lt}.
Add builtin_compound_eq and builtin_compound_lt as predicates which
simplify may introduce calls to, to prevent them being removed by dead
proc elimination.
compiler/unify_proc.m:
If --lexically-order-constructors is enabled, sort data constructors in
the same order as Erlang before generating comparison predicates.
Otherwise comparisons using the Erlang builtins and comparisons using
the generated comparison predicates would give different results.
compiler/type_util.m:
Add a predicate type_definitely_has_no_user_defined_equality_pred which
succeeds iff the given type has no user-defined equality or comparison
predicates.
Conform to change in foreign.m.
compiler/foreign.m:
Change the semidet function
`foreign_type_body_has_user_defined_eq_comp_pred' to a predicate.
compiler/post_term_analysis.m:
Conform to change in foreign.m.
compiler/prog_type.m:
Fix a comment.
Estimated hours taken: 15
Branches: main
Add support for mutables in the Erlang backend.
compiler/make_hlds_passes.m:
Refactor code that inserts mutable-related items for C backend.
Insert items for mutable-related predicates for Erlang.
compiler/prog_item.m:
Add item_mutable inst.
compiler/prog_mutable.m:
Document the mutable transformation for Erlang.
library/Mercury.options:
library/erlang_builtin.m:
New module. This contains a server process that will run in the
background to handle messages relating to mutables in Erlang. In
future it may hold other things for the Erlang backend.
library/library.m:
Add `erlang' module to the standard library.
compiler/elds_to_erlang.m:
Make the Erlang main wrapper start and stop the Erlang global server.
doc/reference_manual.texi:
Add a (commented out) reminder that that mutables are supported
in Erlang as well.
tests/hard_coded/Mmakefile:
tests/hard_coded/float_gv.m:
tests/hard_coded/sub-modules/non_word_mutable.m:
Make these test cases work in Erlang.
Estimated hours taken: 90
Branches: main
NEWS:
library/bit_buffer.m:
library/bit_buffer.read.m:
library/bit_buffer.write.m:
Add bit_buffers to the standard library. A bit_buffer
provides a bit-oriented interface to byte streams.
These will be used as a base for write_binary and read_binary.
library/stream.m:
Add class which supports reading multiple items at once into
a store.
Clarify the blocking behaviour of `put' and `get'.
Document the behaviour of subsequent calls to `get'
after a call returns eof or an error.
library/bitmap.m:
Add a shorthand for `new(N, no)'.
Add `shrink_without_copying' to destructively shrink a bitmap
without copying the data.
Add a function `append_list' to condense a list of bitmaps.
Improve bounds error messages.
Clean up the handling of zero-length bit ranges.
Add type `bitmap.slice' to represent a segment of a bitmap,
and functions to create slices.
library/io.m:
Change the interface of io.read_bitmap to conform to
the stream.bulk_reader interface, by not returning the
bitmap inside the return code. The bitmap is still
valid (although maybe not completely filled) no matter
what result is returned.
Add io.read_binary_file_as_bitmap/N.
library/library.m:
Add recent additions to the list of library modules.
library/Mercury.options:
Use "+=" rather than "=" when setting target-specific
options to allow them to be added to be Mmake.params.
tests/hard_coded/Mmakefile:
tests/hard_coded/bit_buffer_test.m:
tests/hard_coded/bit_buffer_test.exp:
Test case.
tests/hard_coded/bitmap_test.m:
tests/hard_coded/bitmap_simple.m:
tests/hard_coded/bitmap_test.exp:
Update for change to io.read_bitmap.
Test bounds error messages.
Estimated hours taken: 80
Branches: main
Improvements for bitmap.m, to make it useable as a general container
for binary data.
library/bitmap.m:
runtime/mercury_bitmap.c:
runtime/mercury_bitmap.h:
Specialize the representation of bitmaps to an array of unsigned
bytes defined as a foreign type.
This is better than building on top of array(int) because it:
- is better for interfacing with foreign code
- has a more sensible machine-independent comparison order
(same as array(bool))
- avoids storing the size twice
- has more efficient copying, unification, comparison and tabling
(although we should probably specialize the handling of array(int)
and isomorphic types as well)
- uses GC_MALLOC_ATOMIC to avoid problems with bit patterns that look
like pointers (although we should do that for array(int) as well)
XXX The code for the Java and IL backends is untested.
Building the library in grade Java with Sun JDK 1.6 failed (but
at least passed error checking), and I don't have access to a
copy of MSVS.NET. The foreign code that needs to be tested is
trivial.
Add fields `bit', `bits' and `byte' to get/set a single bit,
multiple bits (from an int) or an 8 bit byte.
Add functions for converting bitmaps to hex strings and back,
for use by stream.string_writer.write and deconstruct.functor/4.
bitmap.intersect was buggy in the case where the input bitmaps
had a different size. Given that bitmaps are implemented with
a fixed domain (lookups out of range throw an exception), it
makes more sense to throw an exception in that case anyway,
so all of the set operations do that now.
The difference operation actually performed xor. Fix it and
add an xor function.
library/version_bitmap.m:
This hasn't been fully updated to be the same as bitmap.m.
The payoff would be much less because foreign code can't
really do anything with version_bitmaps.
Add a `bit' field.
Deprecate the `get/2' function in favour of the `bit' field.
Fix the union, difference, intersection and xor functions
as for bitmap.m.
Fix comparison of version_arrays so that it uses the same
method as array.m: compare size then elements in order.
The old code found version_arrays to be equal if one was
a suffix of the other.
library/char.m:
Add predicates for converting between hex digits and integers.
library/io.m:
library/stream.string_writer.m:
library/term.m:
Read and write bitmaps.
runtime/mercury_type_info.h:
runtime/mercury_deep_copy_body.h:
runtime/mercury_mcpp.h:
runtime/mercury_table_type_body.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_unify_compare_body.h:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_term_size.c:
runtime/mercury_string.h:
library/construct.m:
library/deconstruct.m
compiler/prog_type.m:
compiler/mlds_to_gcc.m:
compiler/rtti.m:
Add a MR_TypeCtorRep for bitmaps, and handle it in the library
and runtinme.
library/Mercury.options:
Compile bitmap.m with `--no-warn-insts-without-matching-type'.
runtime/mercury_type_info.h:
Bump MR_RTTI_VERSION.
NEWS:
Document the changes.
tests/hard_coded/Mmakefile:
tests/hard_coded/bitmap_test.m:
tests/hard_coded/bitmap_simple.m:
tests/hard_coded/bitmap_tester.m:
tests/hard_coded/bitmap_test.exp:
tests/tabling/Mmakefile:
tests/tabling/expand_bitmap.m:
tests/tabling/expand_bitmap.exp:
tests/hard_coded/version_array_test.m:
tests/hard_coded/version_array_test.exp:
Test cases.
Branches: main
Move more of the concurrency related modules from extras into the standard
library.
library/Mercury.options:
library/library.m:
library/thread.m:
library/thread.channel.m:
library/thread.mvar.m:
library/thread.semaphore.m:
Move the concurrency-related modules `channel', `mvar' and
`semaphore' from extras/concurrency into the standard library.
Make thread.mvar use the standard library module mutvar instead of
providing its own implementation of the same thing.
Replace "ME_" prefixes by "ML_".
library/mutvar.m:
Add predicate `new_mutvar0' which is like `new_mutvar' but does not
require an initial value for the mutvar. This is needed for
thread.mvar.
Define `new_mutvar' in terms of `new_mutvar0' and `set_mutvar'.
runtime/mercury_thread.h:
Make the MR_WAIT macro expand to "(0)" when MR_THREAD_SAFE is not
defined, so it can be used in an expression context. Zero is the
success code for pthread_cond_wait.
extras/concurrency/channel.m:
extras/concurrency/mvar.m:
extras/concurrency/semaphore.m:
Remove these modules.
extras/concurrency/Mercury.options:
extras/concurrency/concurrency.m:
Delete lines pertaining to removed modules.
extras/concurrency/philo.m:
extras/concurrency/philo2.m:
extras/concurrency/philo3.m:
Update to use the standard library modules.
NEWS:
Announce the change.
(This patch is due to Jon Morgan).
Estimated hours taken: 0.2
Branches: main
Fix problems with a few Mercury clauses in the standard library that have C
foreign procedure declarations, and will not build with the default Mercury
clause.
library/rtti_implementation.m:
Alter num_functors to fail rather than returning -1 for types
without functors, to conform to the recent change in construct.
library/term_size_prof_builtin.m:
Import require, so that error can be used to indicate that the
function is unsupported for any backends that do not implement this
module's functionality.
library/Mercury.options:
Disable `--warn-unused-imports' when compiling the above module
since the results from it will not be reliable. (See XXX comment
at head of compiler/unused_imports.m for details.)
Estimated hours taken: 2
Branches: main
Shift extras/concurrency/spawn.m into a new standard library module
named `thread'.
library/thread.m:
New module. This contains modified versions of the spawn/3
and yield/2 predicates that previously lived in
extras/concurrency/spawn.m. The main modifications are:
- we now allow this module to compile in non .par hl* grades.
(Attempting to actually spawn a new thread in these grades will
cause a runtime abort.)
- s/ME_/ML_/
library/library.m:
Add the new module.
library/exception.m:
Improve a comment.
library/Mercury.options:
Compile the thread module with --no-local-thread-engine-base since
the handwritten C code in that module makes compiling with that
optimization enabled difficult.
extras/concurrency/spawn.m:
Redefine the old versions of spawn/3 and yield/2 in terms
of the versions in the standard library.
Mark them as obsolete and add a pointer to the new versions.
NEWS:
Announce the change.
Estimated hours taken: 1
Branches: main
library/Mercury.options:
Compile sparse_bitset.m and tree_bitset.m with
--optimize-constant-propagation, which enables the optimizations
in simplify.m for operations involving bits_per_int, which were
designed for this purpose.
Compile them also with --use-atomic-cells, to enables to use plain
Mercury code instead of foreign procs to allocate nodes containing
bitsets.
These changes lead to a speedup of about 1.5% in compiling
training_cars_full.m, from 97.3 seconds to 95.8 seconds.
library/sparse_bitset.m:
library/tree_bitset.m:
Use Mercury code instead of foreign_procs to allocate nodes containing
bitsets.
I tried commenting out the sanity checks still left in tree_bitset.m,
but this lead to a speedup of only 0.1%, so I left them in.
Estimated hours taken: 6
Branches: main
Optimize the functions involving int.bits_per_int, since doing this can speed
up sparse_bitset.m.
compiler/options.m:
Add an option that says whether we are cross-compiling, since our
optimizations work only int.bits_per_int returns the same in the
running program as in the compiler that generates its code.
compiler/simplify.m:
If we are not cross compiling, replace calls to the functions
involving bits_per_int whose other arguments have unknown values
with simpler, faster operations, one of whose operands is the
compiler's value for bits_per_int.
Shift some work from const_prop to simplify, since the code to do the
above needs it also.
compiler/const_prop.m:
If we are not cross compiling, evaluate calls to the functions
involving bits_per_int whose other arguments have known values.
compiler/add_pragma.m:
Just as we report errors for attempts to define builtins via clauses,
report errors for attempts to define builtins via foreign_procs.
compiler/hlds_module.m:
Factor out some common code.
compiler/Mercury.options:
Turn on the new optimizations for sparse_bitset.m.
mdbcomp/prim_data.m:
Provide a utility predicate for recognizing standard library modules,
for use in simplify.m.
Estimated hours taken: 3
Branches: main
Clean up in unused module imports in the Mercury system detected
by --warn-unused-imports.
analysis/*.m:
browser/*.m:
deep_profiler/*.m:
compiler/*.m:
library/*.m:
mdbcomp/*.m:
profiler/*.m:
slice/*.m:
Remove unused module imports.
Fix some minor departures from our coding standards.
analysis/Mercury.options:
browser/Mercury.options:
deep_profiler/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
profiler/Mercury.options:
slice/Mercury.options:
Set --no-warn-unused-imports for those modules that are used as
packages or otherwise break --warn-unused-imports, e.g. because they
contain predicates with both foreign and Mercury clauses and some of
the imports only depend on the latter.
Estimated hours taken: 2
Branches: main
Add some new utility predicates for use with streams.
library/stream.m:
Add the predicate stream.format/5, an analogue of io.format,
that writes formatted output using an arbitrary string writer.
Add a predicate stream.ignore_whitespace/4 that can be used
to skip past whitespace in a putback char reader stream.
library/Mercury.options:
Don't warn about unknown format calls in the stream module.
Unrelated change: remove a workaround that was put in place
before the addition of the `--no-warn-obsolete' option.
compiler/format_call.m:
Also analyse calls to stream.format/5.
tests/hard_coded/Mmakefile:
tests/hard_coded/stream_format.{m,exp}:
tests/hard_coded/stream_ignore_ws.{m,exp,data}:
Test stream.format/5 and stream.ignore_whitespace/3.
tests/invalid/string_format_bad.{m,exp}:
tests/invalid/string_format_unknown.{m,exp}:
Check that we emit messages for bad/unknown calls to stream.format/5.
Estimated hours taken: 0.1
Branches: main
library/Mercury.options:
Turn on --optimize-constructor-last-call for list.m and tree234.m.
In the following, version 1 is with the original parameters, version 2
is with --optimize-constructor-last-call for list.m only, version 3
is with --optimize-constructor-last-call for both modules.
mercury_compile.01 average of 12 with ignore=1 20.44
mercury_compile.02 average of 12 with ignore=1 19.99
mercury_compile.03 average of 12 with ignore=1 19.83
Estimated hours taken: 0.3
Branches: main
Enable --warn-insts-without-matching-type by default.
configure.in:
Check for this option when checking whether the bootstrap compiler
is new enough.
compiler/options.m:
Turn the warning on by default.
library/Mercury.options:
Disable the warning for io.m and array.m. These modules contain
insts with symbols in their bound lists that don't belong to any
Mercury types, since the corresponding types are foreign types.
Estimated hours taken: 0.5
Branches: main
Add obsolete pragmas to the interface of bintree_set.
library/bintree_set.m:
Add obsolete pragmas to the procedures in the interface of this
module; the documentation has said they are obsolete for a very long
time.
library/Mercury.options:
Avoid warnings about calls to obsolete pragmas within bintree_set.
compiler/llds_out.m:
Replace usage of bintree_set with set_tree234, since the former is
obsolete.