Commit Graph

22765 Commits

Author SHA1 Message Date
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
Julien Fischer
c6d5622bca Update a reference.
README.boostrap:
    As above.
2023-01-23 00:31:21 +11:00
Zoltan Somogyi
61c6c6f761 Announce the clarification of sorted_list_to_set ops. 2023-01-23 00:26:58 +11:00
Zoltan Somogyi
0497e18e7b Clarity the prereqs of sorted_list_to_set for bitsets. 2023-01-23 00:20:48 +11:00
Julien Fischer
f3ec15c1c2 Convert README.{Free,Open}BSD to Markdown.
README.FreeBSD:
README.OpenBSD:
    As above.

    Add .md extension.

README.md:
    Conform to the above change.
2023-01-23 00:11:21 +11:00
Julien Fischer
e922519879 Convert README.HPUX to Markdown.
README.AIX:
    As above.

    Rename this file to README.HPUX.md,

README.md:
    Conform to the above change.
2023-01-23 00:00:59 +11:00
Julien Fischer
9a93f70f8b Convert README.AIX to Markdown.
README.AIX:
    As above.

    Rename this file to README.AIX.md,

README.md:
    Conform to the above change.
2023-01-22 23:56:54 +11:00
Julien Fischer
5d62f7a868 Convert README.MS-Windows to Markdown.
README.MS-Windows:
    As above.

    Rename this file to README.MS-Windows.md.

README.md:
    Conform to the above change.
2023-01-22 23:21:05 +11:00
Zoltan Somogyi
dfab7a6bc9 Improve some comments, and add some new ones. 2023-01-22 19:37:20 +11:00
Julien Fischer
5460b77691 Update some links.
README.MS-VisualC:
README.MS-Windows:
README.MinGW:
     As above.

     Fix spelling.
2023-01-22 19:35:40 +11:00
Zoltan Somogyi
f355497087 Delete include context maps from parse_tree_int[012].
compiler/prog_item.m:
    We used to record information about include declarations
    in parse_tree_int[012] in two forms:

    - as a pair of maps from module names to contexts (one each for
      includes in the interface and implementation sections), and
    - as a single map from module names to an include_module_info, which
      recorded the section of its appearance along with its context.

    The second of these data structures is derived from the first,
    in a process that can result in the generation of diagnostic messages.
    In the absence of any issues reported by these diagnostics, the two forms
    contain the same information.

    Avoid this redundancy by keeping only the second form in the parse trees
    of .int0, .int and .int2 files. (.int3 files cannot contain include_module
    declarations.)

    Since .int2 files may contain include_module declarations only in
    the interface section, change the representation of the second form
    to a type that expresses this invariant: int_include_module_map,
    which is a subtype of the existing type include_module_map.

compiler/comp_unit_interface.m:
compiler/convert_parse_tree.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.collect_mq_info.m:
compiler/parse_tree_out.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
    Conform to the change above.

compiler/item_util.m:
    Add a utility predicate for use by new code above.
2023-01-22 19:01:42 +11:00
Julien Fischer
7ecb8f73cb Update the release notes.
RELEASE_NOTES:
    Delete a left-over reference to the Erlang backend.

    Update the names of the READMES for Java and C#.
2023-01-22 16:32:11 +11:00
Zoltan Somogyi
7234437262 Delete code that has become dead. 2023-01-22 16:27:27 +11:00
Julien Fischer
736f6252d8 Update README.MacOS:
README.MacOS:
    Rename to README.macOS.md.

    Fix markdown in a few spots.

    Add a missing word.

    Describe the OS as "macOS", which is what Apple currently call it.

    Fix up some links.

README.md:
    Conform to the above change.
2023-01-22 16:26:02 +11:00
Zoltan Somogyi
5ae7d25740 Delete import/use context maps from parse_tree_int[012].
compiler/prog_item.m:
    We used to record information about import and use declarations
    in parse_tree_int[012] in two forms:

    - as a quartet of maps from module names to contexts (one each for
      int imports, int uses, imp imports and imp uses), and
    - as a single map from module names to a section_import_and_or_use,
      which recorded the section and kind (import or use) of its appearance
      along with its one context, except for the case of modules that have
      an use_module declaration in the interface section and an import_module
      declaration in the implementation section.

    The second of these data structures is derived from the first,
    in a process that can result in the generation of diagnostic messages.
    In the absence of any issues reported by these diagnostics, the two forms
    contain the same information.

    Avoid this redundancy by keeping only the second form in the parse trees
    of .int0, .int and .int2 files. (For .int3 files, which can contain
    only import_modules, and only in the interface section, this redundancy
    has not been present even before now.)

    Since .int and .int2 files may contain only use_module declarations
    and not import_module declarations, change the representation of the
    second form to a type that expresses this invariant: the new type
    section_use_map, which is a subtype of the existing type
    section_import_and_or_use_map.

    For .int2 files, we could use an even tighter type right now, but
    a fix for Mantis bug #563 would have to undo such a change, so
    don't bother.

compiler/comp_unit_interface.m:
    Delete the code that used to construct the first form above
    for these interface file kinds. Conform to the changes above.

compiler/convert_parse_tree.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.collect_mq_info.m:
compiler/parse_tree_out.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
    Conform to the changes above.

compiler/item_util.m:
    Add new, specialized versions of existing utility predicates
    to make that conformance possible.
2023-01-21 21:31:00 +11:00
Zoltan Somogyi
faf9ebf5e3 Don't provide for implicit imports in .intN parse trees.
compiler/prog_item.m:
    The ptiN_import_use_map fields in the representations of .int0, .int
    and .int2 files had the same type as the ptms_import_use_map field
    in the parse trees of .m files, which is where they were derived from.
    However, while the ptms_import_use_map field needs to be able to represent
    implicit imports, the parse trees of .int0, .int and .int2 files
    should never include any implicit imports, and in fact any implicit
    imports in these fields were already ignored.

    Encode the invariant that interface files never include implicit imports
    in the types of these fields.

compiler/comp_unit_interface.m:
    Discard the implicit part of the source file's import_and_or_use_map
    when computing the contents of .int0, .int and .int2 files.

compiler/item_util.m:
    Provide the facilities used by the updated code in the modules above.

compiler/convert_parse_tree.m:
compiler/grab_modules.m:
compiler/make_hlds_separate_items.m:
    Conform to the changes above.
2023-01-21 06:38:17 +11:00
Julien Fischer
e6f0b6fa36 Update and rewrite README.CSharp.
Convert it to Markdown.

README.CSharp.
    Add a .md extension.

    Update many of the details in this file.

    Add a table-of-contents.

    Break up the FAQ into separate named sections.

README.md:
    Conform to the above change of name.
2023-01-19 20:31:26 +11:00
Zoltan Somogyi
4a14c05ccc Union and intersect up to 8 bitsets at a time. 2023-01-19 15:36:49 +11:00
Zoltan Somogyi
56ed26f650 Improve the remove_{leq,gt} sparse bitset ops.
library/sparse_bitset.m:
library/fat_sparse_bitset.m:
    Speed up the remove_leq and remove_gt operations by moving a
    loop invariant computation, the conversion of the boundary item's index
    into an <offset,bitposn> pair, out of the loop.

    Eliminate some unnecessary differences between the two modules,
    e.g. clear_bit being a predicate rather than a function.

library/test_bitset.m:
    Add facilities to test the remove_leq and remove_gt operations
    of sparse_bitset.m, fat_sparse_bitset.m, and tree_bitset.m
    against the same operations on plain old set_ordlists.

    Bring this module up to date by requiring set elements to be
    members of the uenum typeclass, not the enum typeclass.

    Make the test_bitset type a bespoke type.

library/tree_bitset.m:
    Add predicate versions of the remove_leq and remove_gt operations
    alongside the existing function versions, to allow the new code
    in test_bitset.m to work the same way regardless of which bitset module
    it is testing.

    For uniformity with the other bitset modules, require set elements to be
    members of the uenum typeclass, not the enum typeclass.

    Change the other integers, such as level numbers, to be unsigned
    as well, to avoid the need for casts.

NEWS:
    Announce the new additions and changes.

tests/hard_coded/test_tree_bitset.{m,exp}:
    Use those new facilities to test those operations, and add some
    test sets designed for that purpose.

    Add a comment about the limitations of this testing strategy.

tests/hard_coded/bitset_tester.m:
    Delete this long-unused module. (It was the original basis of
    the test_bitset.m module in the library directory, but it became unused
    when test_tree_bitset.m switched to using that module a long time ago.)
2023-01-19 14:42:34 +11:00
Peter Wang
34af996ae4 Add synonyms for digraph sc, tc, rtc.
library/digraph.m:
    Add non-abbreviated synonyms for digraph.sc, digraph.tc, and
    digraph.rtc.

NEWS:
    Announce additions.
2023-01-19 13:16:22 +11:00
Peter Wang
0fa19819d9 Minor improvement to simple_tc implementation.
library/digraph.m:
    Skip map update when the candidate root for a vertex does not
    need to change.
2023-01-19 13:16:22 +11:00
Peter Wang
b270b6d01c Delete old transitive closure implementation.
library/digraph.m:
    Delete digraph.old_tc, digraph.old_rtc and digraph.slow_rtc.

tests/hard_coded/digraph_tc.m:
tests/hard_coded/digraph_tc.exp:
    Delete comparisons using old_tc, old_rtc and slow_rtc.
2023-01-18 16:50:41 +11:00
Peter Wang
685e632a13 Implement simple_tc algorithm.
Implement transitive closure using the simple_tc algorithm from
Esko Nuutila's doctoral thesis.

On a sample of graphs randomly generated by tests/hard_coded/digraph_tc.m,
ranging from 100 to 3000 vertices, the simple_tc implementation ran
from 2.33 to 93 times as fast as the old implementation on my machine.

library/digraph.m:
    Rename digraph.tc and digraph.rtc to digraph.old_tc and
    digraph.old_rtc. They are kept around for benchmarking,
    and will be deleted soon.

    Use the simple_tc algorithm to implement digraph.tc.

    Use digraph.tc to implement digraph.rtc.

    Let key_set_map_add call sparse_bitset.insert_new instead of
    sparse_bitset.contains followed by sparse_bitset.insert.

tests/hard_coded/digraph_tc.m:
    Add code to benchmark the new and old TC implementations.
2023-01-18 16:50:41 +11:00
Peter Wang
ea08308308 Update expected outputs.
tests/debugger/browse_pretty.exp:
tests/debugger/browser_test.exp3:
    Expect change to list indentation since
    commit 5cbcfaa0ed.
2023-01-18 13:56:08 +11:00