Commit Graph

22588 Commits

Author SHA1 Message Date
Julien Fischer
2c8ada3dcc Delete unused string formatting predicates.
library/string.format.m:
    Delete the old predicates for formatting ints as unsigned values;
    these are now unused.

configure.ac:
    Require the use of a compiler that does not generate references
    to the deleted predicates.

compiler/introduced_call_table.m:
    Delete the above predicates from the introduced call table.
2023-02-09 10:39:58 +11:00
Julien Fischer
500d125f03 Avoid calls to obsolete functions.
extras/lex/regex.m:
    As above.
2023-02-08 22:19:59 +11:00
Zoltan Somogyi
278ebc172a Mark string.*codepoint* as obsolete ...
library/string.m:
    ... in favor of the s/codepoint/code_point/ versions.

NEWS.md:
    Mention that these predicates and functions have been marked obsolete.

    Mention that all the X_to_doc functions in modules other than
    pretty_printer.m have been marked obsolete in favour of the versions
    in pretty_printer.m.

    Standardize on indenting lists of function and predicate names
    by four spaces, not three. (There were more than five times as many
    that were indented by four than by three.)
2023-02-08 19:51:49 +11:00
Zoltan Somogyi
eecf8b6b15 Complain about no clauses for pred/func ...
compiler/typecheck_error_undef.m:
    ... only if that predicate or function was declared by the user.
    If the compiler itself added the pred/func declaration implicitly
    because it saw a clause for that pred/func, but then decided not to
    add that clause to the HLDS after all because it had syntax errors,
    then don't complain about the absence of a clause for a pred/func
    that the user did not declare.

tests/invalid/state_vars_test3.err_exp:
    Expect no complaint about a missing clause in the above situation.
2023-02-08 14:55:40 +11:00
Zoltan Somogyi
bcd520a7d6 Fix typo. 2023-02-03 20:49:47 +11:00
Zoltan Somogyi
3c931d074c Delete old_list_to_set.
library/fat_sparse_bitset.m:
library/sparse_bitset.m:
    As above.

tests/hard_coded/speedtest_bitset.m:
    Delete references to old_list_to_set.
2023-02-03 19:30:53 +11:00
Zoltan Somogyi
d6beab902d Fix comment rot. 2023-02-03 19:06:59 +11:00
Zoltan Somogyi
badadaa761 Fix variable name rot. 2023-02-03 19:06:37 +11:00
Zoltan Somogyi
6cbdc43a45 Delete two unused predicates. 2023-02-03 19:05:46 +11:00
Zoltan Somogyi
86c294a614 Announce fatter_sparse_bitset.m. 2023-02-03 19:04:52 +11:00
Zoltan Somogyi
726da4f03c Prepare to s/codepoint/code_point/ in string.m.
library/string.m:
    For each predicate and function whose name includes "codepoint",

    - create a version in which "codepoint" is replaced by "code_point",
    - make this version the main implementation, making the "codepoint"
      versions forward to the "code_point" versions,
    - add obsolete pragmas for the "codepoint" versions, though these are
      commented out for now. This is so that an installed compiler containing
      this change will already have the recommended alternative available
      when the commenting-out is removed (maybe in a week or so).

NEWS.md:
    Announce the new predicates and functions.

compiler/c_util.m:
compiler/const_prop.m:
compiler/inst_check.m:
compiler/parse_tree_out_term.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/write_error_spec.m:
library/pprint.m:
library/pretty_printer.m:
library/string.format.m:
    Replace all uses of the "codepoint" versions with the "code_point"
    versions.
2023-02-02 19:59:10 +11:00
Peter Wang
7005272a5a Cache module file names when writing dependency files.
When writing out dependency files, the compiler would call
module_name_to_file_name often for the same pairs of module name and
file extension. Caching the results of those calls saves on
constructing temporary strings.

This change reduces the time to make dependencies in the compiler
directory from 2.40 seconds to 2.15 seconds on my machine.

compiler/write_deps_file.m:
    Add a predicate make_module_file_name that caches calls to
    module_name_to_file_name.

    Thread the cache map through the predicates in this module.
    Replace calls to module_name_to_file_name with calls to
    make_module_file_name when appropriate.
2023-02-02 16:29:06 +11:00
Peter Wang
a07077914c Optimise digraph.compose.
Benchmarking on randomly generated digraphs shows a speedup of 30-40%.
The time to make dependencies in the compiler directory on my machine
is reduced from 3.65 seconds to 2.40 seconds.

library/digraph.m:
    Rewrite digraph.compose more efficiently.
2023-02-02 16:21:54 +11:00
Zoltan Somogyi
fd424de76f s/http/https/, and fix link rot. 2023-02-02 16:00:25 +11:00
Zoltan Somogyi
b843d53a4c Improve actual/expected mismatch diagnostics.
compiler/typecheck_errors.m:
    Improve the diagnostics we generate for mismatches between actual and
    expected types. If the mismatch was between a single actual type and
    a single expected type, we already printed a message whose format
    was specialized for that case, but in every other case, we fell back
    to a more general but less readable error message template. Improve on this
    by splitting the task into two halves, one for the actual type(s) and one
    for the expected type(s), each of which generates simpler text if
    there is only one such type.

    Separate the actual type part of the diagnostic from the expected type part
    using a semicolon instead of a comma, because we now use commas to
    separate multiple actual types from each other, and multiple expected
    types from each other.

    Don't insist on putting a newline after the "type error:" part of the
    diagnostic.

    Do all of the above in just one predicate, factoring out code that
    used to be duplicated.

    Delete a function that has never been used. (I added it around 2008
    for later use by a student working on software transactional memory,
    but that use never happened.) This used to contain a third copy
    of the code that was factored out.

    For functions that used to take both a typecheck_info and a
    type_error_clause_context, delete the latter argument, since the caller
    invariably took it out of the typecheck_info that it also passed.

compiler/typecheck.m:
    Don't pass now-unneeded type_error_clause_contexts.

compiler/typecheck_error_type_assign.m:
    Fix typo in a field name.

tests/invalid/abstract_eqv.err_exp:
tests/invalid/actual_expected.err_exp:
tests/invalid/actual_more_expected.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/ext_type_bug.err_exp:
tests/invalid/fbnf.err_exp:
tests/invalid/foreign_procs_exist_type.err_exp:
tests/invalid/higher_order_mode_mismatch.err_exp:
tests/invalid/integral_constant_no_suffix.err_exp:
tests/invalid/method_impl.err_exp:
tests/invalid/mixed_up_streams.err_exp:
tests/invalid/try_bad_params.err_exp:
tests/invalid/type_diff.err_exp:
tests/invalid/type_error_ambiguous.err_exp:
tests/invalid/types2.err_exp:
tests/invalid_nodepend/errors2.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
tests/invalid_purity/purity_nonsense.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
    Update expected error messages.
2023-02-02 15:44:11 +11:00
Julien Fischer
20dffe1137 Adjust a URL.
compiler/notes/todo.html:
    As above.
2023-02-02 13:51:10 +11:00
Zoltan Somogyi
58a10fa97c Minor style fixes. 2023-02-01 18:57:04 +11:00
Zoltan Somogyi
e53bc5fbfa Make some predicates naturally tail recursive.
Make some predicate names more expressive.
2023-02-01 18:56:02 +11:00
Zoltan Somogyi
4bf17516a4 Optimize contains/insert pair in pre_quantification.m. 2023-02-01 18:54:42 +11:00
Zoltan Somogyi
33ae129d45 Optimize contains/insert pairs in digraph.m ...
... by replacing them with insert_new operations.

Delete redundant module qualifications.
2023-02-01 16:45:05 +11:00
Peter Wang
322efbb62b Optimise get_dependencies_from_graph.
This reduces the time to make dependencies in the compiler directory
from 5.85 seconds to 3.60 seconds on my machine.

compiler/write_deps_file.m:
    Use set.list_to_set instead of calling set.insert in a loop.
2023-02-01 11:52:30 +11:00
Julien Fischer
38327d65f4 Add a NEWS section for 22.01.6.
NEWS.md:
    As above.
2023-02-01 01:32:31 +11:00
Zoltan Somogyi
ee0f9f73d7 Add library/fatter_sparse_bitset.m.
library/fatter_sparse_bitset.m:
    Add this version of fat_sparse_bitset.m, which stores *two* words
    worth of bits in each cell, not one. This word would otherwise be unused,
    because the Boehm-Demers-Weiser allocator rounds up requests for three
    word cells to four.

library/MODULES_DOC:
library/library.m:
    Add the new module to the list of library modules.

library/fat_sparse_bitset.m:
library/sparse_bitset.m:
library/tree_bitset.m:
    Update the documentation of all these other bitset modules. Copy
    the same basic introduction to all the relevant modules. Add documentation
    of the differences to tree_bitset.m and fatter_sparse_bitset.m, with
    a pointer in fat_sparse_bitset.m to fatter_sparse_bitset.m.

library/test_bitset.m:
    Test the new module as well as the others.

tests/hard_coded/speedtest_bitset.m:
    Extend the benchmarking of list_to_set operations to the new module.
    To allow the benchmarking to be tough enough to be informative, comment
    out the benchmarking of the old_list_to_set operations.
2023-01-31 18:36:16 +11:00
Peter Wang
f90cd7fdb5 Assign mmake .classes variable conditionally.
Evaluating the .classes variable in a Mmakefile can be quite slow.
We can speed up mmake invocations by assigning the variable to an
empty value unless we are targeting Java.

On my machine, a call to mmake in an up-to-date compiler directory
now takes about 0.4 seconds, down from 1.2 seconds.

compiler/write_deps_file.m:
    As above.
2023-01-31 16:03:11 +11:00
Peter Wang
fe50f0c696 Delete touch_files target.
Mmakefile:
    Delete touch_files target. It's probably obsolete.
2023-01-31 15:51:36 +11:00
Peter Wang
3446667416 Fix references to unassigned mmake variables.
compiler/write_deps_file.m:
    Fix reference to used_subdir, should be useds_subdir.

scripts/Mmake.vars.in:
    Assign analysiss_subdir variable.
2023-01-31 15:26:24 +11:00
Peter Wang
bd074ec4c0 Increase parallelism when making standard library .trans_opt files.
Increase parallelism while making .trans_opt files in the library
directory by deleting more edges in the trans-opt dependency graph.
There are no regressions in the generated .trans_opt files.

On my machine, mmake -j32 trans_opts in the library directory
goes from 23 seconds to approximately 11 seconds.

library/mer_std.trans_opt_deps_spec:
    As above.
2023-01-30 17:26:31 +11:00
Peter Wang
7756618737 Allow --trans-opt-deps-spec file to remove more edges.
Let module_allow_deps and module_disallow_deps terms delete an edge
from A to B in the trans-opt dependency graph, even if A and B do not
belong to the same SCC. Previously the edge would only be removed if
A and B imported each other (possibly indirectly), which was
unnecessarily restrictive.

compiler/generate_dep_d_files.m:
    As above.
2023-01-30 16:06:38 +11:00
Zoltan Somogyi
6f6d30b8f2 Improve the speed of fat_sparse_bitset.list_to_set ...
... by using the algorithm now in sparse_bitset.list_to_set.

Keep the old list_to_set algorithm around in both modules for a short while
to allow comparative benchmarking.

library/fat_sparse_bitset.m:
library/sparse_bitset.m:
    As above.

tests/hard_coded/speedtest_bitset.m:
    A benchmark program to compare the old and new list_to_set algorithms,
    both versus each other, and between sparse_bitset and fat_sparse_bitset.
2023-01-29 07:57:44 +11:00
Zoltan Somogyi
80b1d4a7e3 Test all bitset implementation at once.
library/test_bitset.m:
    Instead of comparing just one bitset module (tree_bitset by default)
    against set_ordlist, compare all of them (tree_bitset, sparse_bitset,
    and fat_sparse_bitset) against set_ordlist.

tests/hard_coded/test_bitsets.{m,exp}:
    Rename this test case from test_tree_bitset to test_bitsets, since
    (through library/test_bitset.m) we now test ALL bitset implementations,
    not just tree_bitset.

tests/hard_coded/Mmakefile:
    Refer to the test by its new name.
2023-01-29 04:04:24 +11:00
Zoltan Somogyi
e05f2befcb Encode arity kind in the type. 2023-01-28 02:29:24 +11:00
Zoltan Somogyi
b6c1f1b3e4 Switch on int/uint size just once. 2023-01-28 02:29:15 +11:00
Julien Fischer
4da0cad1c8 Update format_call documentation.
compiler/format_call.m:
    Update the descriptions of part of the tansformations implemented by this
    module; fix some minor errors.
2023-01-27 18:07:17 +11:00
Julien Fischer
bbff6f8609 Fix a bug in string.format.
The current implementation of the unsigned conversion specifiers (i.e. %x, %X,
%o, %u) for fixed-size 8-, 16- and 32-bit signed integers works by casting
theses values into (word-sized) ints and then using the existing code for
formatting ints as unsigned values. This does not work for negative values as
they are being sign extended when converted to ints. For example,

      io.format("%x", [i8(min_int8)], !IO)

prints:

      ffffffffffffff80 (on a 64-bit machine)

rather than just:

      80

Fix the above problem by casting ints, int8s, int16s etc. that are being
formatted as unsigned values to uints and using the uint formatting code.

NOTE: the formatting code for 64-bit integers follows a different code path
and is not affected by any of this.

library/string.format.m:
    Implement unsigned conversion specifiers for non-64-bit signed
    integers by casting to uint and using the uint formatting code.

    Add predicates for converting signed integers into uints.

    The format_unsigned_int_* predicates can be deleted after this change
    is installed.

compiler/format_call.m:
    Implement unsigned conversion specifiers for non-64-bit signed
    integers by casting to uint and using the uint formatting code.

compiler/introduced_call_table.m:
    Update the table of introduced predicates.

compiler/options.m:
    Add an option that can be used to test whether this fix is
    installed.

tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
tests/hard_coded/opt_format_sign_extend.{m,exp}:
    Test that formatting code introduced by the compiler does not
    accidentally sign-extend negative values.

tests/string_format/string_format_{o,x,u}.{m,exp,exp2}:
    Make these tests much more comprehensive then they previously
    were.
2023-01-27 17:16:54 +11:00
Peter Wang
b0ae10248b Use --trans-opt-deps-spec option.
Use the recently added --trans-opt-deps-spec option to break cycles in
the trans-opt dependency graph for the standard library. This enables
more parallelism when making the .trans_opt files; it now takes about
half as long as before.

Ordering modules sensibly, so that .trans_opt files are created in a
logical order, also improves analysis results for many predicates and
functions. The only results which show a regression with this change are
for deprecated forwarding predicates/functions.

In future, we will probably be able to trim more dependencies to further
improve parallelism, without impacting analysis results.

configure.ac:
    Check that the bootstrap compiler supports --trans-opt-deps-spec.

library/mer_std.trans_opt_deps_spec:
    Add the spec file that adjusts dependencies in the trans-opt
    dependency graph.

library/INTER_FLAGS:
    Use the --trans-opt-deps-spec option when building with mmake.

scripts/prepare_install_dir.in:
tools/binary:
tools/bootcheck:
tools/unary:
    Copy mer_std.trans_opt_deps_spec when preparing a copy of the
    library directory.
2023-01-25 16:48:45 +11:00
Peter Wang
9fa20d1e71 Delete unused transitive closure implementations.
library/digraph.m:
    Delete simple_tc and stack_tc.

    Reorder some code.

tests/hard_coded/digraph_tc.m:
    Delete code for testing simple_tc and stack_tc.
2023-01-25 16:14:11 +11:00
Peter Wang
0eb4281a90 Implement two more transitive closure algorithms.
Implement two transitive closure algorithms in the digraph module:

  - Basic_TC by Yannis Ioannidis et al.

  - STACK_TC by Esko Nuutila, a refinement of the SIMPLE_TC algorithm
    previously implemented

On 450 graphs randomly generated by tests/hard_coded/digraph_tc.m,
ranging from 100 to 3000 vertices:

  - basic_tc ran from 0.79 to 1.66 times as fast as simple_tc
    (mean 1.139, stdev 0.136)

  - basic_tc ran from 0.83 to 1.81 times as fast as stack_tc
    (mean 1.131, stdev 0.160)

Therefore, after this commit, I will delete the simple_tc and stack_tc
implementations, but they will be available in the version history.

library/digraph.m:
    Implement Basic_TC and STACK_TC.

    Use map.transform_value in key_set_map_union to replace a search
    followed by update.

tests/hard_coded/digraph_tc.m:
    Test and benchmark the new algorithms.

    Also compare inverse graphs to check that predecessor maps are
    maintained properly.
2023-01-25 12:28:45 +11:00
Zoltan Somogyi
9c9a44be00 Improve the worst case of list_to_set on sparse bitsets.
library/sparse_bitset.m:
    Replace the old algorithm, which had O(N^2) worst-case behavior,
    with a modified form of natural merge sort, whose worst-case complexity
    is O(NlogN).
2023-01-24 04:05:26 +11:00
Peter Wang
cf2aafae5c Fix typo. 2023-01-23 17:11:45 +11:00
Julien Fischer
b5fff1c3b4 Fix markup.
NEWS.md:
    As above.
2023-01-23 13:09:02 +11:00
Julien Fischer
06d83c7ca9 Rename NEWS -> NEWS.md.
NEWS:
    As above.

README.md:
RELEASE_NOTES:
bindist/Mmakefile:
compiler/notes/coding_standards.html:
compiler/notes/developer_intro.html:
    Conform to the above change.
2023-01-23 13:09:02 +11:00
Julien Fischer
d3059f5e0f Use https links in more spots.
README.Docker:
README.bootstrap:
README.cross.md:
README.md:
RELEASE_NOTES:
     As above.
2023-01-23 04:11:07 +11:00
Julien Fischer
680e2b3079 Convert README.ssdebug to Markdown.
README.ssdebug:
    As above.

    Add a .md extension.

README.CSharp.md:
README.Java.md:
    Conform to the above change.
2023-01-23 03:37:12 +11:00
Julien Fischer
c27f120d54 Update link to x86_64 ABI documentation.
runtime/machdeps/x86_64_regs.h:
    As above.
2023-01-23 02:29:13 +11:00
Julien Fischer
f7d4858c5c Fix a typo.
README.HPUX.md:
    As above.
2023-01-23 02:13:54 +11:00
Julien Fischer
c79966ea17 Convert README.clang to Markdown.
README.clang:
    As above.

    Add a .md extension.

README.md:
RELEASE_NOTES:
    Conform to the above change.
2023-01-23 02:09:44 +11:00
Julien Fischer
6dffe00611 Update some references.
README.Cygwin:
README.MS-Windows.md:
RELEASE_NOTES:
    Refer to README.MS-VisualC.md.
2023-01-23 01:42:50 +11:00
Julien Fischer
344db9162e Convert README.MS-VisualC to Markdown
README.MS-VisualC:
    As above.

README.md:
    Conform to the above change.
2023-01-23 01:37:57 +11:00
Julien Fischer
8cda709b9c Convert README.Linux-aarch64 to Markdown.
README.Linux-aarch64:
    As above.

README.md:
    Link the above file from here.
2023-01-23 00:44:25 +11:00
Julien Fischer
35f461a952 Convert README.Solaris to Markdown.
README.Solaris:
    As above.

README.md:
    Conform to the above change.
2023-01-23 00:35:04 +11:00