Commit Graph

20597 Commits

Author SHA1 Message Date
Zoltan Somogyi
d302810ecf Add some utility predicates, and make some cleanups.
library/list.m:
    Add a predicate version of map_corresponding3.

    Move a predicate next to its only call site.

    Use more meaningful variable names.

library/map.m:
library/tree234.m:
    Add several predicates: foldl4_values, foldl5_values, filter_map_values
    and filter_map_values_only.

library/multi_map.m:
    Embed an implicit assertion in a call.

library/set_ordlist.m:
    Give a predicate a better name.

library/NEWS:
    Announce the new additions.

    Put the list of updated library modules back into alphabetical order.

tests/hard_coded/test_map_filter.{m,exp}:
    Test the one wholly new utility predicate.
2020-02-27 19:23:17 +11:00
Zoltan Somogyi
a39e8adea1 Add a missing foreign_import_module.
library/math.m:
    Since code in math.m uses C macros defined in a foreign_decl in float.m,
    math.m needs a foreign_import_module for float, but it did not have one.
    This caused compilation of math.c to math.o to fail *except* with
    intermodule optimization, which gave math.m the required access to
    float.m's internals anyway. The reason we didn't notice is that
    intermodule optimization is the default.
2020-02-27 18:12:32 +11:00
Julien Fischer
5a1f1581ad Simplify some code.
compiler/modes.m:
compiler/unique_modes.m:
    Use is_dummy_context/1 in some more spots.
2020-02-27 15:42:11 +11:00
Julien Fischer
6ddc27e782 Replace tabs with spaces in the ml script.
scripts/ml.in:
    As above.
2020-02-22 00:53:59 +11:00
Julien Fischer
f60caca91c Use trail segments by default in trailing grades.
Until now, we have supported two variants of trailing grades, those that use a
fixed-size trail (.tr) and those that use trail segments (.trseg).  This change
removes support for fixed sized trails, and renames the .trseg grade component
to .tr. The .trseg grade now acts a synonym for .tr; it is deprecated, since we
intend to eventually delete it.  Until then, the behavior of the old .tr grade
component should be available, though to developers only, by compiling the
whole system with EXTRA_CFLAGS = -DMR_USE_FIXED_SIZE_TRAIL.

runtime/mercury_conf_param.h:
    Delete the MR_TRAIL_SEGMENTS macro. Its effect is now implied by
    MR_USE_TRAIL, unless a new macro, MR_USE_FIXED_SIZE_TRAIL, is defined.
    Developers can use this new macro to disable trail segments, should the
    need for doing that arise.

runtime/mercury_grade.h:
    Add a new macro that defines a binary compatibility version number for
    trailing; use that in the grade part for trailing.

    Use "_trfix" or "_trseg" as the prefix of the trailing part of the
    MR_GRADE_VAR depending on if MR_USE_FIXED_SIZE_TRAIL is defined or
    not.

runtime/mercury_trail.[ch]:
runtime/mercury_context.h:
    Enable trail segments by default, only disabling them if
    MR_USE_FIXED_SIZE_TRAIL is enabled.

runtime/mercury_wrapper.c:
trace/mercury_trace_cmd_developer.c:
    Conform to the above changes.

compiler/compile_target_code.m:
    Do not pass options for trail segments to the C compiler.

compiler/compute_grade.m:
    Treat trseg as a synonym for tr.

compiler/options.m:
    Deprecate --trail-segments.

grade_lib/grade_spec.m:
grade_lib/grade_string.m:
grade_lib/grade_structure.m:
grade_lib/grade_vars.m:
grade_lib/try_all_grade_structs.m:
grade_lib/var_value_names.m:
    Remove the trseg component.

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
    Remove support for the --trail-segments option.

doc/user_guide.texi:
    Update the documentation for the --trail-segments.

    Comment out the documentation of the --trail-size and --trail-size-kwords
    runtime options; they are no longer useful to non-developers.

NEWS:
    Announce this change.
2020-02-18 13:07:24 +11:00
Peter Wang
36e1e26b33 Add test for thread.closeable_channel.
tests/hard_coded/Mmakefile:
tests/hard_coded/closeable_channel_test.exp:
tests/hard_coded/closeable_channel_test.exp2:
tests/hard_coded/closeable_channel_test.m:
    Add new test.
2020-02-18 11:07:34 +11:00
Peter Wang
dae414d920 Add closeable channels to the standard library.
library/thread.closeable_channel.m
    Add the new module. It omits two operations from thread.channel.m:
    - untake, because it is deprecated
    - duplicate, because I'm not sure what it's useful for in practice

library/MODULES_DOC:
library/library.m
library/thread.m:
NEWS:
    Mention the new module.
2020-02-17 14:36:31 +11:00
Peter Wang
5a825d0363 Deprecate thread.channel.untake/4
A call to channel.untake will deadlock if a call to channel.take is
blocked on the same channel.
unGetChan was removed from GHC for the same reason:
https://gitlab.haskell.org/ghc/ghc/issues/4154

library/thread.channel.m:
    Deprecate channel.untake/4.

NEWS:
    Announce the change.
2020-02-17 11:27:57 +11:00
Zoltan Somogyi
bb8e42ad44 Improve the style of hash_table.m.
library/hash_table.m:
    Switch to using kv_lists to represent items in overflowing buckets.
    This is both cleaner and more efficient.

    Give many types, function symbols, predicates, functions and variables
    more meaningful names.

    Add XXXs to mark some significant potential problems.

    When an operation has both function and predicate forms, make the
    function form forward to the predicate form, as we do in the rest
    of the standard library.

    Make equality testing between a key in a hash bucket and a search key
    explicit in all cases.

library/kv_list.m:
    Add some functionality that hash_table.m now needs from kv_lists.

library/assoc_list.m:
    Add some functionality that kv_list.m now has, to maintain parity
    between the two modules.

NEWS:
    Announce the changes to assoc_list.m. (The changes to kv_list are moot,
    since it is a new module.)

tests/hard_coded/hash_table_test.{m,exp}:
    Make the progress messages output by this test more meaningful,
    and update its programming style.
2020-02-16 15:45:28 +11:00
Julien Fischer
373635b89e Adjust the markup of a NEWS entry.
NEWS:
    As above.
2020-02-13 17:49:00 +11:00
Zoltan Somogyi
09e81967b7 Add a new module, kv_list, to the standard library.
library/kv_list.m:
    This new module is a version of assoc_list.m in which the list of
    key-value pairs is represented not by a list of pairs (which has
    two two-word cells per key-value pair) but by a bespoke, flattened
    data structure (which has one three-word cell per key-value pair).
    This should improve performance by reducing the number of memory
    allocations and traffic to and from the data cache. (The *amount*
    of memory allocated will not be affected, since Boehm rounds up
    three words to four. And since cache block sizes are also powers
    of two, traffic to and from memory should stay roughly the same.)

    The new module has one operation for every operation in assoc_list.m,
    plus two functions for converting between assoc_lists and kv_lists
    (one for each direction).

library/assoc_list.m:
    Improve comments on some exported predicates and/or functions.

    Add a lookup operation on assoc lists as a predicate. This operation
    already existed as a field access function; not having it available
    using normal syntax was a bit strange.

library/library.m:
library/MODULES_DOC:
NEWS:
    Mention the new module.
2020-02-13 13:42:31 +11:00
Julien Fischer
d33647299a Rationalise hash functions across the standard library.
Currently, the hash functions for (some of) the primitive types are defined in
three places:

   1. The hash_table module.
   2. The version_hash_table module (duplicates of the above).
   3. Some (but not all) of the library modules for the primitive types.

This change makes the library module for a primitive type provide the hash
function for that type and deprecates the versions in the hash table modules.

Additionally, deprecate the "generic" has functions in the hash table modules.

library/hash_table.m:
library/version_hash_table.m:
    As above.

library/char.m:
library/int.m:
library/uint.m:
    Add hash/1 and hash/2.

library/float.m:
    Add hash/2.

library/robdd.m:
    Replace a call to the deprecated function.

NEWS:
    Announce the above additions and deprecations.

tests/hard_coded/hash_table_delete.m:
tests/hard_coded/hash_table_test.m:
tests/hard_coded/version_hash_table_delete.m:
tests/hard_coded/version_hash_table_test.m:
    Conform to the above change.
2020-02-11 14:22:42 +11:00
Peter Wang
5350d703cb Add combined higher-order types and insts to NEWS.
NEWS:
    Add combined higher-order types and insts as new to the 20.01
    release.
2020-02-11 12:27:15 +11:00
Peter Wang
3eb1333ec2 Uncomment help text for --warn-suspicious-recursion.
compiler/options.m:
    Uncomment help text for --warn-suspicious-recursion.
    (It was already documented in the user guide.)

NEWS:
    Add --warn-suspicious-recursion as new to the 20.01 release.
2020-02-11 12:27:15 +11:00
Julien Fischer
64830a4615 Announce the fix for bug #496.
NEWS:
    Add a news section for 20.01.1.

    Announce the fix.

    Add a better illustration of the problem that the fix
    addresses.
2020-02-09 20:54:49 +11:00
Zoltan Somogyi
036b97ff7d Emit a reminder about a limitation of cse_detection when needed.
Common subexpression elimination (cse) declines to do its job of transforming

    (
        X = f(A1, ..., An),
        goal A
    ;
        X = f(B1, ..., Bn),
        goal B
    )

into

    X = f(X1, ..., Xn),
    (
        A1 = X1, ..., An = Xn,
        goal A
    ;
        B1 = X1, ..., Bn = Xn,
        goal B
    )

when the insts of some of X's arguments are at least partially unique,
because mode analysis cannot track uniqueness through the extra unifications
that this transformation introduces. When this happens, and the procedure
this code is in does not match its declared determinism, generate a message
that gives this fact as a possible reason for that determinism mismatch.

This fixes Mantis bug #496 to the extent that we *can* fix it
without rewriting the whole of mode analysis.

compiler/hlds_pred.m:
    Provide a slot in the proc_info for recording whether cse has declined
    to pull a common unification out of a branched control structure because
    of this concern, and if so, at what locations in the source code.

    An unrelated change: move a slot used only by constraint-based mode
    analysis, which is never enabled, from the proc_info to the proc_sub_info.
    This should improve both speed and memory consumption, though very
    slightly.

compiler/cse_detection.m:
    Record each such location in this slot.

    Doing this requires a change in approach. Previously, we did not try
    to pull a unification out of any branch of a branched control structure
    if it involved (partially or wholly) unique arguments. However, doing
    this in just one branch cannot possibly affect the output of cse detection,
    since it pulls a unification out of a branch only if can pull the same
    unification out of all the other branches as well.

    Our new approach is to transform branched control structures regardless
    of uniqueness, and then *undo* the transformation (simply by discarding
    its result) if it involves unique arguments. It is such undoing that we
    record in the proc_info.

compiler/switch_detection.m:
    Conform to the new approach.

compiler/hlds_out_pred.m:
    Print the contents of the new slot in HLDS dumps.

compiler/det_report.m:
    If the actual determinism of a procedure, as computed by determinism
    analysis, does not match its declared determinism, *and* if the proc_info's
    new slot says that cse declined to pull some common unifications
    out of a branched control structure, then mention that fact, and
    the usual fix, as a possible explanation of the determinism problem.

tests/invalid/bug496.{m,err_exp}:
    The Mantis test case.

tests/invalid/Mmakefile:
    Enable the new test case.
2020-02-07 11:56:54 +11:00
Julien Fischer
eed0f86519 Delete some obsolete procedures.
Delete some procedures that have been marked as obsolete since before the 14.01
release.

library/hash_table.m:
library/version_array.m:
    As above.

NEWS:
    Announce the deletions.

tests/hard_coded/hash_table_delete.m:
    Replace a call to one of the deleted functions.
2020-02-02 02:31:35 +11:00
Zoltan Somogyi
e47586fc24 Add map.keys_as_set.
library/map.m:
    As above.

NEWS:
    Announce the addition.
2020-01-31 11:24:57 +11:00
Julien Fischer
671471a0e9 Add a post 20.01 section to the NEWS file.
NEWS:
    As above.

    Announce the addition of keys_as_set/[12].
2020-01-31 11:19:56 +11:00
Zoltan Somogyi
1e2188331e Put the contents of map.m into a logical order. 2020-01-31 10:38:00 +11:00
Peter Wang
c89a0b1276 Don't link to libmer_eventspec redundantly.
This avoid a link error when using clang's ThinLTO mode:
    error: Failed to link module
    ../trace/libmer_eventspec.a.llvm.18688.mercury_event_parser.c:
    Expected at most one ThinLTO module per bitcode file

compiler/Mmakefile:
    Remove libmer_eventspec.a from MLOBJS.
    Mmake.workspace already causes the library to be linked in.
2020-01-28 17:15:41 +11:00
Peter Wang
68a77f4a09 Make link-time optimisation with clang work.
configure.ac:
    Add -flto to LINK_SHARED_OBJ and LINK_SHARED_OBJ_SH commands
    when LTO is enabled with clang.

    Search for and use LTO-aware llvm-ar, llvm-ranlib and llvm-nm
    programs in place of the normal tools.
2020-01-28 10:52:47 +11:00
Peter Wang
9d81b80221 Make link-time optimisation with gcc work.
configure.ac:
    Add -flto to LINK_SHARED_OBJ and LINK_SHARED_OBJ_SH commands
    when LTO is enabled with gcc.

    Search for and use LTO-aware gcc-ar, gcc-ranlib and gcc-nm
    programs in place of the normal tools.
2020-01-28 10:47:31 +11:00
Julien Fischer
cbdc597523 Document a known issue in the NEWS file.
NEWS:
   As above.
2020-01-27 20:02:14 +11:00
Julien Fischer
6e32d80a5e Improve support for MSYS2 builds.
MSYS2 provides a POSIX like environment and package manager for Windows.
It packages up the MinGW-w64 port of GCC.  (MSYS2 is separate from the
original MSYS.)

Make it possible to build Mercury under MSYS2 with the MinGW-w64 GCC
without having to resort to cross compilation.

configure.ac:
    Recognise the x86_64-pc-mingw* architecture returned by config.guess
    under MSYS2.

    If we are building the MSVC port under MSYS2, set up the flags for
    threads appropriately.

scripts/ml.in:
    Pass libraries to the linker correctly for static linking on all the
    different MinGW configurations.

README.MinGW:
    Update documentation for MinGW ports.
2020-01-24 17:40:22 +11:00
Zoltan Somogyi
e9ad852183 Improve mode error messages a bit more.
compiler/mode_errors.m:
    Simplify the wording of the new error message component added yesterday.

    Mention a possible reason for inst mismatches when the inst contains
    a higher order component. Put this in the parentheses, because it is
    *not* guaranteed to be the actual reason.

compiler/inst_util.m:
    Add a utility predicate for the new code in mode_errors.m.

tests/invalid/any_passed_as_ground.err_exp:
tests/invalid/constrained_poly_insts2.err_exp:
tests/invalid/ho_type_mode_bug.err_exp:
tests/invalid/try_detism.err_exp:
    Expect the updated error messages.
2020-01-24 16:26:24 +11:00
Zoltan Somogyi
b831562958 Improve error messages for some mode errors.
compiler/mode_errors.m:
    There are two improvements.

    The first and much the more important is that when a call does not match
    any of the declared modes of the called predicate or function, we now
    print the names and insts of any arguments whose insts, by themselves,
    do not match any of the callee's modes. Instead of reporting "here are
    all the arguments, here are all their insts, find out for yourself
    which one is wrong", the compiler now tells the programmer explicitly
    which one is wrong in almost all cases. (Not all. If e.g. two args <A, B>
    have insts <free, free>, but the callee has two modes, <in, out> and
    <out, in>, then the compiler won't report either arg, since neither arg
    is wrong by itself.)

    The second improvement is that when the verbosity settings ask us
    to print all possible reasons why we can't schedule a conjunction,
    instead of our default approach of printing the only the first,
    we now put a blank line between the different reasons, for visual
    separation.

compiler/modecheck_call.m:
    Preserve the extra information now needed by mode_errors.m.

compiler/modecheck_util.m:
    Conform to the changes above.

tests/invalid/any_passed_as_ground.err_exp:
tests/invalid/anys_in_negated_contexts.err_exp:
tests/invalid/constrained_poly_insts2.err_exp:
tests/invalid/ho_default_func_1.err_exp:
tests/invalid/ho_default_func_3.err_exp:
tests/invalid/ho_type_mode_bug.err_exp:
tests/invalid/modes_erroneous.err_exp:
tests/invalid/try_detism.err_exp:
    Expect the updated error messages for these tests.
2020-01-24 14:19:30 +11:00
Julien Fischer
5a5ea709b9 Force the use of static linkage with MSVC in the ml script.
This fixes a problem that made it impossible to use mmake with MSVC.

scripts/ml.in:
     Force the use of static linkage with MSVC.
2020-01-23 20:31:31 +11:00
Julien Fischer
ca58b4c2a4 Updates for the ml script.
scripts/ml.in:
    Shared libraries are now the default on FreeBSD systems.

    Handle 64-bit Cygwin systems the same as 32-bit ones.

    Update references to the configure script source.
2020-01-23 20:15:49 +11:00
Julien Fischer
1f3812e898 Replace an old hack in the ml script.
Instead of trying to determine the type of the C compiler in the ml script
based on the name of the C compiler executable, use the C compiler type
determined by the configure script.

scripts/ml.in:
    As above.
2020-01-23 20:03:39 +11:00
Julien Fischer
0d218e34c6 Address review comments.
configure.ac:
    As above.
2020-01-23 16:21:47 +11:00
Julien Fischer
135db3d482 Do not allow the use of x86_64-pc-msys.
configure.ac:
    Stop and report an error if this script is run on the x86_64-pc-msys
    architecture; that will go badly wrong as the configure script currently does
    not handle it correctly.
2020-01-23 13:59:46 +11:00
Julien Fischer
906f73fb92 Add a note about building the MSVC port on MSYS2.
README.MS-VisualC:
    When using MSVC as the C compiler and building on MSYS2, the
    configuration type must not be "*-pc-msys".  (That configuration
    type is used for building programs for use with MSYS itself, not
    native executables.)
2020-01-23 13:43:23 +11:00
Julien Fischer
f820adc40e Fix a typo.
NEWS:
   As above.
2020-01-22 23:54:22 +11:00
Zoltan Somogyi
18e222656f Stop common_struct from interfering with mark_static_terms.
This fixes Mantis bug #493.

compiler/common.m:
    Don't apply the common_struct optimization if doing so could possibly
    invalidate the annotations generated by mark_static_terms.m, which the
    MLDS code generator relies on.

    Move the tests for the applicability of the common_struct optimization
    for both construction and deconstruction unifications next to each other.

    Add XXXs about possible problems this code may have when applied to code
    that does region based memory allocation.

tests/valid/bug493.m:
    A simplified version of the Mantis test case.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
    Enable the new test case, and specify the options that originally caused
    the bug to manifest itself.
2020-01-22 22:10:43 +11:00
Zoltan Somogyi
97fd7f5336 Replace nondet code with det code. 2020-01-22 22:10:43 +11:00
Julien Fischer
8504add3ea Re-enable asm_fast grades on i*86 Windows with GCC 5+.
configure.ac:
    As above, there's no particular reason to disallow them other
    than a little messiness in the configure script.
2020-01-22 17:35:55 +11:00
Julien Fischer
7a681a97e5 Announce back-end deletions and deprecations.
NEWS:
   As above.

Julien.
2020-01-22 15:09:14 +11:00
Julien Fischer
bb6093033b Announce grades we no longer support.
NEWS:
   As above.
2020-01-22 13:34:57 +11:00
Peter Wang
df9c251890 Update readmes.
.README.in:
BUGS:
    Reduce verbosity.

    Mention GitHub issue tracker.

README.HPUX:
    Delete redundant contact information.

README.Linux:
    Delete information about long-obsolete a.out executables.
2020-01-22 13:13:18 +11:00
Peter Wang
9ef7f4319b Add notes about untested platforms.
README.Erlang:
README.Linux-PPC:
README.Solaris:
    As above.
2020-01-22 12:58:36 +11:00
Peter Wang
b89a789a19 Add changes to vim syntax files to NEWS.
NEWS:
    As above.
2020-01-22 12:52:58 +11:00
Peter Wang
6a8b3841bc Update list of tested platforms.
RELEASE_NOTES:
    As above.
2020-01-22 12:52:58 +11:00
Julien Fischer
9461f8daca Fix the wording of a NEWS entry.
NEWS:
   As above.
2020-01-22 00:46:32 +11:00
Julien Fischer
d591aef0b4 Another update for the release notes.
RELEASE_NOTES:
   Mention the versions of Windows we have tested on.

   Mention that Mercury ran on Windows XP in the past.
2020-01-21 20:21:59 +11:00
Julien Fischer
ed7a834325 Adjust the release notes.
RELEASE_NOTES:
    Adjust the list of systems we have tested on.

README.MacOS:
    Be clear that this document covers all version of macOS.
2020-01-21 20:10:04 +11:00
Julien Fischer
b5c9a66837 Update some installation documentation.
.INSTALL.in:
   The configure option --disable-dynamic-link does not do what this
   file says it does; the new --disable-shared-libs option does, so
   mention that instead.
2020-01-21 19:48:28 +11:00
Peter Wang
ff0c363ea4 Define int to string conversions more precisely.
library/string.m:
    As above.
2020-01-21 16:19:27 +11:00
Julien Fischer
44dc77fca1 Add new configuration option for disabling shared libraries.
configure.ac:
   Add the option --disable-shared-libs, which turns off shared libraries
   even on systems that support them.

   Make the workaround for bug #453 look at the value of the new option,
   rather than that of --disable-dynamic-link.
2020-01-21 11:44:40 +11:00
Peter Wang
ead0b56ea1 Add note about PIC and dynamic linking.
configure.ac:
    Mention that dynamic linking does not necessarily imply PIC.
2020-01-20 18:53:25 +11:00