Commit Graph

22765 Commits

Author SHA1 Message Date
Julien Fischer
1b41c69f69 Fix double-up word.
compiler/hlds_class.m:
    As above.
2023-04-05 21:43:13 +10:00
Stefan Muenzel
d95bd0c088 Mark switch as complete in is_foreign_type_body_for_target
Since du_type_layout.is_foreign_type_body_for_target is semidet,
we won't get any compilation error when adding a new target, and
it will fail at runtime. Fix this by marking the switch on Target
as complete.
2023-04-05 00:41:54 +10:00
Julien Fischer
f765494ec9 Fix spelling.
compiler/ml_string_switch.m:
    As above.
2023-04-05 00:38:24 +10:00
Julien Fischer
9627df5a68 Fix typo.
library/eqvclass.m:
    As above.
2023-04-04 21:36:50 +10:00
Julien Fischer
de47db1ab7 Fix a comment.
compiler/switch_util.m:
    As above.
2023-04-04 21:23:39 +10:00
Zoltan Somogyi
bcf16babe2 Avoid a second traversal of an argument list.
Add an XXX about duplicated code.
2023-04-04 11:19:41 +10:00
Zoltan Somogyi
e1fe6f9871 Improve the style of library/eqvclass.m.
Use the same variable (base) name for each field of the eqvclass
structure in all predicates. Make this base name match the name
of that field.

Delete redundant module qualifiers, except in the few cases where
it helps readability.

Add dividers to separate unrelated predicates.

Expand out deeply nested function calls, giving names
to the intermediate results.
2023-04-04 11:19:30 +10:00
Zoltan Somogyi
86c8bbf30e Fix non-doubled-up word. 2023-04-04 08:22:29 +10:00
Julien Fischer
f2c99cc0b2 More spelling fixes, etc.
compiler/cse_detection.m:
compiler/ml_lookup_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_target_util.m:
compiler/switch_util.m:
     As above.
2023-04-03 21:41:32 +10:00
Julien Fischer
7ebf74539a Fix doubled-up words.
compiler/notes/coding_standard.html:
    As above.
2023-04-03 21:18:38 +10:00
Julien Fischer
6faef40e9e Fix spelling.
extras/moose/check.m:
    As above.
2023-04-03 21:09:24 +10:00
Julien Fischer
33ea40c8a3 Fix spelling.
library/uint16.m:
library/uint32.m:
library/uint64.m:
    As above.
2023-04-03 20:22:33 +10:00
Zoltan Somogyi
8e7a1b2a11 Further simplify the management of MLDS switches.
compiler/ml_switch_gen.m:
    The code for deciding how to implement switches on strings was
    a convoluted nest of tests, which tested several different properties
    of the target language. The flexibility this afforded could have been
    useful in the past when the MLDS backend targeted MSIL and gcc asm,
    but with today's three target languages, they are just overkill,
    especially since several parts of the old code were unreachable.
    Replace all that code with a simple switch on the target language.
    Move the switch arm for C into its own predicate in order to reduce
    the required indentation level.

    Assume that all target languages support switches on (smaller-than-64-bit)
    integers, because they all do.

    Use Defns, not Decls, to refer to lists of local var definitions.

    Fix an misleading old comment.

compiler/ml_target_util.m:
    Delete the code testing whether a target language supports switches on
    smaller-than-64-bit integers.
2023-04-03 19:52:58 +10:00
Zoltan Somogyi
13a03cc5e5 Clarify a comment. 2023-04-03 13:28:14 +10:00
Zoltan Somogyi
10a8473cc2 Simplify the management of smart indexing.
compiler/switch_util.m:
    Simplify the interface of the find_switch_category predicate.
    Instead of returning (a) a *smart switch category*, and (b) a flag
    that says whether that category may be used, simply return
    a *switch category*, which includes a non-smart switch category,
    the if-then-else chain.

    Give some data constructors in the switch_category type names that
    clarify the differences between them.

    Move the type_ctor_cat_to_switch_cat function just after its only caller.

compiler/ml_switch_gen.m:
compiler/switch_gen.m:
    Flatten the switches on the return values of find_switch_category.

    Merge arms of these switches that handle dumb switches and switches
    on floats, because they are both implemented as if-then-else chains.

    In ml_switch_gen.m, inline the ml_gen_smart_int64_switch predicate,
    which made only one decision, at its only call site.

    Add XXXs that point out opportunities for further simplification.

compiler/ml_lookup_switch.m:
    Rename a predicate to conform to the new names of switch categories.
2023-04-03 10:02:39 +10:00
Zoltan Somogyi
d3425a4f6f Improve some comments. 2023-03-30 21:49:47 +11:00
Zoltan Somogyi
9b6390b17e Bring the programming style of extras up to date.
extras/curs/curs.m:
extras/curs/curs.panel.m:
    Make panel a separate submodule of curs, not a nested submodule.

extras/base64/base64.m:
extras/curses/mcurses.basics.m:
extras/curses/mcurses.m:
extras/curses/mcurses.misc.m:
extras/curses/mcurses.user.m:
extras/gator/evolve.m:
extras/gator/genotype.m:
extras/gator/phenotype.m:
extras/gator/tausworthe3.m:
extras/monte/dots.m:
extras/monte/geom.m:
extras/monte/hg.m:
extras/monte/monte.m:
extras/monte/rnd.m:
extras/moose/grammar.m:
extras/moose/moose.m:
extras/mopenssl/mopenssl.m:
extras/net/echo.m:
extras/net/errno.m:
extras/net/getaddrinfo.m:
extras/net/net.m:
extras/net/netdb.m:
extras/net/sockets.m:
extras/net/streams.m:
extras/net/tcp.m:
extras/net/test_lookups.m:
extras/net/types.m:
extras/odbc/odbc.m:
extras/odbc/odbc_test.m:
extras/references/README:
extras/references/reference.m:
extras/references/scoped_update.m:
extras/solver_types/library/any.m:
extras/solver_types/library/any_array.m:
extras/solver_types/library/any_assoc_list.m:
extras/solver_types/library/any_list.m:
extras/solver_types/library/any_map.m:
extras/solver_types/library/any_tree234.m:
extras/solver_types/library/any_util.m:
extras/trail/trail.m:
extras/trailed_update/samples/interpreter.m:
extras/trailed_update/samples/vqueens.m:
extras/trailed_update/tests/var_test.m:
extras/trailed_update/tr_array.m:
extras/trailed_update/tr_store.m:
extras/trailed_update/trailed_update.m:
extras/trailed_update/unsafe.m:
extras/trailed_update/var.m:
    Bring programming style up to date.
2023-03-30 21:48:10 +11:00
Julien Fischer
69569b1bbf Secure temporary file and directory creation for Java.
In the Java grade, the implementation of predicates used to create unique
temporary files and directories was not secure, due to the underlying Java API
methods not setting permissions correctly. Alternative methods were added in
Java 7, but we currently use the older insecure methods. This change switches
the Java implementations of temporary file and directory creation over to the
newer methods.

We have long provided a Mercury wrapper for secure temporary file / directory
creation in the extras/java_extra_libs. That will be redundant after this change
and I will remove it in a separate change.

library/io.file.m:
     Use the secure temporary file and directory creation methods introduced
     in Java 7.

     Mention that for make_temp_directory/6, the Java implementation will now
     ignore the Suffix argument.

     Delete some that was used to generated temp file names; its use of
     java.util.Random probably wasn't particularly secure either.
2023-03-28 21:46:00 +11:00
Zoltan Somogyi
66ecca99ab Add a note on a failed experiment. 2023-03-28 05:42:24 +11:00
Zoltan Somogyi
de4678f8d5 Minor cleanup of compiler/notes/*.html.
compiler/notes/coding_standards.html:
    Document our usual initial comment block.

    Document vim modelines a bit more extensively.

    Document short %---% lines.

    Fix bad formatting results caused by tabs in the HTML code.

    Fix documentation rot.

compiler/notes/compiler_design.html:
    Explain the terms HLDS, LLDS and MLDS just after their first occurrences.

    Fix incorrect references to "passes".

    Describe the components of the LLDS and MLDS backends the same way
    where possible.

    Fix documentation rot.

    Fix bugs in English expression.

compiler/notes/developer_intro.html:
    Fix documentation rot.

compiler/notes/glossary.html:
    Explain that functions also have pred_infos.

compiler/notes/overall_design.html:
    Fix bugs in English expression.

compiler/notes/reviews.html:
    Fix documentation rot.

    Fix bugs in English expression.

compiler/notes/work_in_progress.html:
    Use a more accurate name for this page.
2023-03-28 02:53:13 +11:00
Zoltan Somogyi
14e4342364 Use predmode syntax. 2023-03-28 02:36:34 +11:00
Zoltan Somogyi
81c1ef0749 Delete stray line. 2023-03-28 02:36:15 +11:00
Zoltan Somogyi
aaca428172 Add some comments. 2023-03-27 22:12:06 +11:00
Julien Fischer
97d1065993 Fix my previous commit.
profiler/demangle.m:
   Fix an incomplete change that was accidently committed.
2023-03-25 22:12:54 +11:00
Julien Fischer
a23d353a7f Use stdlib procedures in some spots.
profiler/demangle.m:
     As above.
2023-03-25 21:28:29 +11:00
Julien Fischer
94f8e73bdb Fix wording.
compiler/term_constr_build.m:
     As above.
2023-03-25 16:48:31 +11:00
Mark Brown
81ce3a3459 Tweak a comment.
library/list.m:
	Make the same change as was suggested elsewhere, where the
	comment was being quoted.
2023-03-25 01:06:56 +11:00
Julien Fischer
a5a9d7364f Announce the fix for Githbub issue #116.
NEWS.md:
    As above.
2023-03-22 19:02:38 +11:00
Julien Fischer
ab9b87f610 Fix Github issue #116.
Building programs with --intermodule-optimization fails when using a library
containing submodules that was *not* installed with --intermodule-optimization
enabled. This is because the compiler is trying to find the .int0 files for the
library, but these are only installed when the library is built with
--intermodule-optimization enabled. The fix is to always install any .int0
files for a library.

compiler/make.program_target.m:
compiler/write_deps_file.m:
    Always install the .int0 files for libraries.
2023-03-22 02:04:02 +11:00
Julien Fischer
c047985f81 Fixes description of profiling files.
doc/user_guide.texi:
    s/Prof.Decls/Prof.Decl/ in a couple of spots.

    Fix wording.
2023-03-20 21:33:01 +11:00
Zoltan Somogyi
1ca63c2867 Run string_format_{bad,unknown} in profdeep grades.
tests/invalid/Mmakefile:
    These tests have not needed to catch exceptions in a long time,
    so there is no need to avoid running them in profdeep grades.
2023-03-19 14:10:29 +11:00
Peter Wang
1e7b2f6fbd Fix syntax error. 2023-03-19 13:11:01 +11:00
Zoltan Somogyi
2c866fb4d2 Avoid "overriding recipe" messages in tests/invalid.
tests/invalid/Mmakefile:
    Some tests cases in this directory have target-specific make rules
    if (and only if) the test flags include --intermod-opt. We used to include
    these tests in the lists of tests that do not have target-specific rules,
    which lead to messages about "overriding recipe for <target>" from make.
    Fix this by including test cases in the list of tests that do not have
    target-specific rules only if they belong there.

    Delete inappropriate entries from  REDIRECT_OPT_ERROR_MODULES, the list
    of tests cases that have target-specific make rules if (and only if)
    the test flags include --intermod-opt. Some of the modules that used
    to be in this list have since been moved to the invalid_make_int directory,
    where they don't need special handling (because what is special here
    is standard there). Some other modules in this list either never existed
    or have been deleted from the test suite as a whole. Delete both of these
    kinds of test case names from that list.

    Move the rules that figure out whether to enable a category of tests
    (e.g. the trailed tests) just after the definition of the list of tests
    in that category.

    Delete an obsolete comment, whose up-to-date form has been nearby
    for a while now.

    Add an XXX.

tests/invalid_make_int/Mmakefile:
    Note which test cases that have been moved here were included in
    REDIRECT_OPT_ERROR_MODULES, in case that does turn out to be useful later.
2023-03-19 02:49:22 +11:00
Zoltan Somogyi
af70cb4f84 Use . as the module qualifier.
We stopped using : as the module qualifier decades ago.
2023-03-19 00:26:21 +11:00
Zoltan Somogyi
40ff19acbb Standardize mode names in argument lists.
compiler/hlds_error_util.m:
    When converting lists of arguments mode to strings for error messages,
    replace from/to pairs of insts that stand for standard modes with the
    names of those standard modes.

compiler/prog_mode.m:
    Add a utility function for doing that standardization.

tests/invalid/io_in_ite_cond.err_exp:
tests/invalid_manual/gh118.err_exp:
    Expect the standard forms of modes.

tests/invalid_manual/Mmakefile:
    Specify the grade for the test independently of the grade of the
    workspace or of the last bootcheck. Make the Mercury compiler flags
    specific to the test.
2023-03-19 00:24:25 +11:00
Zoltan Somogyi
2315f1660e Replace /* */ comments with // comments in util.
util/mdemangle.c:
util/mfiltercc.c:
util/mkinit_common.c:
util/pad_backslash.c:
    As above. The other .c files in util already used // comments.
2023-03-19 00:16:22 +11:00
Zoltan Somogyi
d9046a19d2 Add a test case for github issue #118.
tests/invalid_manual/gh118.err_exp:
tests/invalid_manual/gh118.gh118_helper.m:
tests/invalid_manual/gh118.m:
    As above. The invalid_manual directory is a new test directory.
    Its tests are not executed by tools/bootcheck.

tests/invalid_manual/Mmakefile:
    Add a make rule for executing the test.

tests/invalid_manual/Mercury.options:
    Add this options file (currently empty).

compiler/det_report.m:
    Redirect comments to the actual location of the test case.
2023-03-18 21:33:54 +11:00
Zoltan Somogyi
1144163bd5 Fix indentation. 2023-03-18 21:20:44 +11:00
Zoltan Somogyi
3e9b16dd74 Don't operate on one proc using all-module code.
compiler/det_analysis.m:
    Implement determinism_check_proc using code that processes one procedure,
    instead of code intended to process an entire module.

    To make the above possible without code duplication, rearrange the code
    around det_infer_proc. Instead of printing (if --debug-det is enabled)
    the result of det_infer_proc in its caller, print it in a predicate that
    det_infer_proc calls.

    Fix argument order in a predicate.

compiler/det_report.m:
    To make the above possible, export a predicate.

compiler/modes.m:
compiler/try_expand.m:
    Conform to the new argument order in det_analysis.m.
2023-03-16 19:07:31 +11:00
Zoltan Somogyi
8758df5518 Fix compiler abort on non-model_det procedures.
Github issue #118 reports a compiler abort that happens when
table_gen.m attempts to perform that transformation that implements
the tabling of I/O actions for declarative debugging, and a sanity check
finds that the procedure's determinism is not model_det.

We could change table_gen.m to not transform the affected predicate
in such cases. This change could fix *this specific* compiler abort,
but it is better to fix the root cause, which is that our semantic analysis
passes have not detected and reported a violation of our semantic rules,
and have allowed the affected predicate to flow through to the middle end
to be processed.

compiler/det_analysis.m:
compiler/det_report.m:
    We used to check whether predicates with I/O state arguments have
    one of the permitted model_det determinisms as part of det_infer_proc.
    Github issue #118 arose because det_infer_proc processes only
    predicates defined in the current module. It was also strange that
    some properties of mode declarations were checked by det_infer_proc
    in det_analysis.m (which can be invoked on a procedure more than once
    during mode inference), while others were checked by
    check_determinism_of_procs in det_report.m (which is only ever invoked
    on a procedure once, at the end of determinism analysis).

    Move the checks on mode declarations all to det_report.m. Partly
    this is to fix the above code smell, but mainly so that we can add
    check_determinism_of_imported_procs, which performs the part of
    the job of check_determinism_of_procs that is appropriate for
    imported procedures.

    Make the error message for invalid mode declarations more specific
    by listing the given invalid determinism as well as the possible
    valid determinisms.

    To make the above possible without doing unnecessary checks on
    compiler-constructed procedures that are "born correct", separate out
    imported procedures from born-correct procedures. Previously, they
    were lumped together as "no inference needed" procedures.

tests/invalid/ho_unique_error.err_exp:
tests/invalid/mostly_uniq1.err_exp:
tests/invalid/mostly_uniq2.err_exp:
    Expect the extra detail in error messages.

tests/invalid/io_in_ite_cond.err_exp:
tests/invalid/magicbox.err_exp:
tests/invalid/try_detism.err_exp:
    Expect an error message about the invalid determinism of a procedure
    with I/O state args. Previously, we did not generate an error message
    for these issues.
2023-03-16 16:27:03 +11:00
Zoltan Somogyi
0d9f714844 Break up a large predicate. 2023-03-16 11:14:13 +11:00
Zoltan Somogyi
7c0851304c Fix misleading predicate name. 2023-03-16 10:59:48 +11:00
Zoltan Somogyi
1e9eb51c8b Break det_infer_proc into smaller pieces.
compiler/det_analysis.m:
    Carve three separate predicates out of det_infer_proc. Besides improving
    readability, one of the new predicates should be useful in the fix for
    github issue #118.

    Factor out the common initial and final parts of two related but
    different long error messages.

    Improve the wording of some error messages.

    Replace two separate traversals of the list of pragma exported procedures
    with one.

tests/invalid/ho_unique_error.err_exp:
tests/invalid/mostly_uniq1.err_exp:
tests/invalid/mostly_uniq2.err_exp:
tests/invalid/one_member.err_exp:
    Expect the updated wording in error messages.
2023-03-16 09:46:04 +11:00
Zoltan Somogyi
0715d500bd Make the module comment more readable. 2023-03-16 03:01:44 +08:00
Zoltan Somogyi
dace807074 Document the purpose of ml_rename_classes.m. 2023-03-16 03:01:20 +08:00
Zoltan Somogyi
e4c75b250b Improve programming style. 2023-03-12 16:23:21 +08:00
Julien Fischer
b955ef9024 Fix spelling.
extras/lex/regex.m:
    As above.
2023-03-12 14:44:02 +11:00
Julien Fischer
93dba486ec Update programming style in extras/lex.
extras/lex/lex.buf.m:
extras/lex/lex.lexeme.m:
extras/lex/lex.convert_NFA_to_DFA.m:
    As above.
2023-03-12 14:36:49 +11:00
Zoltan Somogyi
da3e2e80d3 Make invoked_by_mmc_make part of the op_mode.
compiler/op_mode.m:
    Add a field that specifies whether the compiler was invoked by
    "mmc --make" to the opm_top_args top-level op_mode. This is the
    class of op_modes for which we need that info.

    Fill in this new field from the value of the --invoked-by-mmc-make
    option.

compiler/options.m:
    Add an "only_opmode_" prefix to the internal name of the
    --invoked-by-mmc-make option. Move this option next to the --make option.

    Improve the wording of some options' usage messages.

doc/user_guide.texi:
    Make the same changes in wording here as well.

compiler/add_pragma.m:
compiler/add_type.m:
compiler/exception_analysis.m:
compiler/handle_options.m:
compiler/headvar_names.m:
compiler/hlds_module.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mode_errors.m:
compiler/op_mode.m:
compiler/options.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.analysis.m:
compiler/tabling_analysis.m:
compiler/term_util.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
    Conform to the changes above, either by finding out whether
    the compiler was invoked by mmc --make using the op_mode instead
    of the option, or by ignoring that info where not needed.
2023-03-11 16:55:06 +08:00
Julien Fischer
d7f28528b4 Announce the fix for Github issue #117.
NEWS.md:
    As above.
2023-03-11 19:43:10 +11:00