Commit Graph

977 Commits

Author SHA1 Message Date
Zoltan Somogyi
dadf30718d Add io.write_line_cc/4.
library/io.m:
    Add a version of io.write_line_cc that takes an explicit stream argument.

NEWS:
    Announce the addition.

browser/interactive_query.m:
    Use the new predicate.
2021-03-06 22:09:49 +11:00
Julien Fischer
c2df9af6a8 Document and announce the system RNG module.
library/random.system_rng.m:
    Document what sources of randomness are used by the C backends.

library/MODULES_DOC:
library/MODULES_UNDOC:
    Include random.system_rng module in the library documentation.

NEWS:
    Announce the random.system_rng module.
2021-02-20 10:44:31 +11:00
Julien Fischer
113d0ae9bd Fix markup in NEWS file.
NEWS:
    As above.
2021-01-25 20:21:54 +11:00
Julien Fischer
d03d7fc740 Document Linux AArch64 support.
NEWS:
    As above.

.README.in:
    Add pointer the to the Linux/AArch64 specific README file.

    Delete a left-over reference to the Alpha port.

README.Linux:
    Add pointer the to the Linux/AArch64 specific README file.

README.Linux-aarch64:
    Add a README file specific to the Linux/AArch64 port.
2021-01-25 18:33:24 +11:00
Zoltan Somogyi
9c248726a6 Add uint{64,}_to_lc_hex_string.
library/string.m:
    We long had uint_to_hex_string and uint_to_uc_hex_string. Add
    uint_to_lc_hex_string as well, and make uint_to_hex_string call it.
    This way, users don't have to remember which of the upper and lower
    case versions is defined, and which is missing.

    Do the same for the 64 bit version.

NEWS:
    Announce the new functions.

library/string.format.m:
    Call the new functions.
2021-01-22 17:18:57 +11:00
Zoltan Somogyi
63dabcfcf8 Fix filling in partial terms that use direct_arg tags.
This fix uses the approach discussed on m-dev 2020 nov 16/17 for fixing
github issue #72, whose core problem is a need for information flow
back to a the caller from a callee when the callee fills in the
argument of a function symbol whose representation is a direct_arg tag.
In most cases when the callee fills in the value of an argument,
the caller can see it because the argument is in a word on the heap,
but when the function symbol uses a direct_arg tag, that is not the case.

compiler/direct_arg_in_out.m:
    A new module that implements the transformation proposed on m-dev.
    It creates a fresh clone variable every time an argument of a direct_arg
    tag function symbol is (or may be) updated. This can happen several
    times if a type has more than one function symbol with a direct_arg tag.
    Since the affected variable can be bound to only one function symbol
    at the start, its argument can be filled in only once, but the
    compiler cannot know in advance what function symbol the variable
    contains, and therefore which of the possibly several fill-in sites
    (which fill in the arguments of different function symbols) executed
    in sequence will actually update the variable.

    The transformation ensures that once a variable is cloned, it is
    never referred to again. It also ensures that in a branched control
    structure (if-then-else, disjunction or switch), all branches will use
    the *same* variable to represent the latest version of each cloned
    variable at the end, so that following code has a consistent view
    regardless of through which branch execution has reached it.

    There are three situations that the transformation cannot and does not
    handle.

    1. Situations in which the mode of an argument is either an inst variable,
       or an abstract inst. In either case, the pass cannot know whether
       it should apply its transformation to the argument.

    2. Situations where a procedure that has such an argument is
       exported to C code as a function. In that case, the C signature
       of the function we would generate would be different from what
       the user would normally expect. We could modify the documentation
       of the export pragma, but I don't think there much point due to
       lack of demand. (The problem cannot arise when targeting any language
       other than C, because we use direct_arg tags only with the low level
       data representation, which we only use for C.)

    3. Situations where a procedure that has such an argument is defined
       by foreign_proc. Again, dealing with the problem would require
       nontrivial changes to the documented interface between code in
       foreign_procs and the surrounding Mercury code, and I see no demand
       for code that could benefit from that.

    In these cases, this module generates error messages.

compiler/transform_hlds.m:
    Include the new module in the transform_hlds package.

    Delete unnecessary module qualification on some existing inclusions.
    Put some existing inclusions into a more meaningful order.

compiler/notes/compiler_design.html:
    Document the new pass. Fix some nearby prose.

compiler/lambda.m:
compiler/simplify_proc.m:
    Use a predicate exported by direct_arg_in_out.m to test, for each
    procedure, whether the procedure has any argument positions that are
    subject to the problem that direct_arg_in_out.m addresses.
    simplify_proc.m does this for all procedures it processes;
    lambda.m does this for all the procedures it creates from
    lambda expressions.

    Give a predicate in simplify_proc.m a better name.

    Sort a list of predicate names.

compiler/hlds_module.m:
    Add a field to the module_info that simplify_proc.m and lambda.m
    can use to tell direct_arg_in_out.m what work (if any) it needs to do.

compiler/mercury_compile_middle_passes.m:
    Invoke direct_arg_in_out.m if the new field in the HLDS indicates
    that it has some work to do. (In the vast majority of compiler invocations,
    it won't have any.)

compiler/hlds_pred.m:
    The new code in direct_arg_in_out.m creates a clone of each procedure
    affected by the problem, before deleting the originals (to make sure that
    no references to the unfixed versions of now-fixed procedures remain.)
    Make it possible to create exact clones of both predicates and procedures
    by adding two pairs of predicates, {pred,proc}_prepare_to_clone and
    {pred,proc}_create.

    Add the direct_arg_in_out transformation as a possible source
    of transformed predicates.

library/private_builtin.m:
    Add a new builtin operation, partial_inst_copy, that the new module
    generates calls to.

configure.ac:
    Require the installed compiler to recognize partial_inst_copy
    as a no_type_info builtin.

compiler/builtin_ops.m:
    Recognize the new builtin. (This was committed before the rest; the diff
    to private_builtin.m can be done only once the change to builtin_ops.m
    is part of the installed compiler.)

compiler/options.m:
    Add a way to test whether the builtin_ops.m in the installed compiler
    recognizes the new builtin.

compiler/dead_proc_elim.m:
    Do not delete the new primitive before direct_arg_in_out.m has had
    a chance to generate calls to it.

    Add an XXX.

compiler/error_util.m:
    Recognize the new module as a source of error messages.

compiler/pred_table.m:
    Add a pair of utility predicates to be used when looking up
    builtin predicates, for which the compiler writer knows that
    there should be exactly one match. These are used in direct_arg_in_out.m.

compiler/simplify_goal_call.m:
    Replace some existing code with calls to the new predicates
    in pred_table.m.

compiler/hlds_goal.m:
    Add modes to rename_vars_in_goal_expr that express the fact
    that when an atomic goal_expr has some variables renamed inside it,
    it does not suddenly become some *other* kind of goal_expr.
    New code in direct_arg_in_out.m relies on this.

compiler/hlds_out_goal.m:
    When the HLDS we are dumping out is malformed because it contains
    calls to predicates that have been deleted, the compiler used to abort
    at such calls. (I ran into this while debugging direct_arg_in_out.m.)

    Fix this. When such calls are encountered, we now print out as much
    information we can about the call, and prefix the call with an
    unmistakable prefix to draw attention to the problem.

compiler/inst_util.m:
    Fix a bug that prevented direct_arg_in_out.m from even being invoked
    on some test code for it.

    The bug was in code that we use to unify a headvar's initial inst
    with its final inst. When the initial inst was a non-ground bound_inst
    such as the ones used in tests/hard_coded/gh72.m, and the final inst
    was simply "ground", this code quite properly returned a bound_inst
    (which, unlike ground, can show the exact set of function symbols
    that the headvar could be bound to). The problem was that it
    reused the original bound_inst's test results, including the one
    that said the final inst is NOT ground, which of course is wrong
    for any inst unified with ground. Fix two instances of this bug.

compiler/modes.m:
    Make some of the code I had to traverse to find the bug in inst_util.m
    easier to read and understand.

    Replace some uses of booleans with bespoke enum types.

    Change the argument lists of some predicates to put related arguments
    next to each other.

    Give some variables more descriptive names.

compiler/layout_out.m:
    Conform to the change in hlds_pred.m.

compiler/var_locn.m:
    Fix a code generation bug. When filling-in the value of the argument
    of a function symbol represented by a direct_arg tag, the code we
    generated for it worked only if the direct_arg tag used 0
    as its ptag value. In the test cases we initially used for
    github issue 72, that was the case, but the new tests/hard_coded/gh72.m
    has direct_tag args that use other ptag values as well.

    Document the reason why the updated code works.

compiler/term_constr_initial.m:
    Add the new primitive predicate added to private_builtin.m,
    partial_inst_copy, to a table of builtins that do not take type_infos,
    even though their signatures contain type variables.

    Fix a bunch of old bugs: most other such primitives were not listed
    either.

mdbcomp/program_representation.m:
    Add partial_inst_copy to the master list of builtins that do not take
    type_infos even though their signatures contain type variables. (Done
    by an earlier commit.)

    Document the fact that any updates here require updates to
    term_constr_initial.m.

library/multi_map.m:
    We have long had multi_map.add and multi_map.set as synonyms,
    but we only had multi_map.reverse_set. Add multi_map.reverse_add
    as a synonym for it.

    Define the "set" versions in terms of the "add" versions,
    instead of vice versa.

NEWS:
    Document the new predicates in multi_map.m.

tests/hard_coded/gh72a.m:
    Fix typo.

tests/hard_coded/gh72.{m,exp}:
    A new, much more comprehensive test case than gh72a.m.
    This one tries to tickle github issue 72 in as many forms of code
    as I can think of.

tests/invalid/gh72_errors.{m,err_exp}:
    A test case for testing the generation of error messages for
    two out of the three kinds of situations that direct_arg_in_out.m
    cannot handle. (Proposals for how to test the third category welcome.)

tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
    Enable the two new test cases, as well as two old ones, gh72[ab].m,
    that previously we didn't pass.

tests/invalid/Mercury.option:
    Do not compile gh72_error.m with --errorcheck-only, since its errors
    are reported by a pass that --errorcheck-only does not invoke.
2021-01-13 05:35:40 +11:00
Julien Fischer
587ec47536 Lift restriction on formatting 64-bit integers.
Zoltan's recent addition of support for formatting fixed size integer types
using string.format and friends works by casting the fixed size integer value
to an int or uint value and then re-using the existing code we already have for
formatting those. This works in all cases except when formatting 64-bit integer
types on systems where int / uint is a 32-bit quantity (notably, both the C#
and Java backends). This diff lifts that restrictions.

library/string.format.m:
    Add support for formatting 64-bit integers without having to cast them
    to an int or uint.

    Export new format predicates for use by the code generated by
    compiler/format_call.m.

compiler/format_call.m:
    Generate calls to the 64-bit versions of the format_*_component predicates
    where necessary.

compiler/simplify_proc.m:
    Update the list of predicates that may be introduced by the compiler.

NEWS:
    Delete the mention of the restriction.

tests/hard_coded/opt_format.{m,exp}:
    Extend this test to cover 64-bit integers.
2021-01-07 12:19:22 +11:00
Julien Fischer
52b31f5089 Add uint64 to string conversion for bases 8 and 16.
library/string.m:
     Add functions for converting uint64s to strings of base 8 or base 16
     digits. For most integer types we can cast to a uint and then use the
     uint versions of these operations but for 64-bit types we cannot since
     on some of our supported platforms uints are 32-bit.

NEWS:
     Announce the additions.

tests/hard_coded/Mmakefile:
tests/hard_coded/uint64_string_conv.{m,exp}:
     Add a test of the new functions.
2020-12-15 22:45:31 +11:00
Julien Fischer
f8e65add3a Format uints directly.
Currently, the Mercury implementation of string formatting handles uints by
casting them to ints and then using the code for formatting signed integers as
unsigned values.  Add an implementation that works directly on uints and make
the code that formats signed integers as unsigned integers use that instead.
The new implementation is simpler and avoids unnecessary conversions to
arbitrary precision integers.

Add new functions for converting uint values directly to octal and hexadecimal
strings that use functionality provided by the underlying platforms; replace
the Mercury code that previously did that with calls to these new functions.

library/string.m:
    Add the functions uint_to_hex_string/1, uint_to_uc_hex_string/1 and
    uint_to_octal_string/1.

library/string.format.m:
    Make format_uint/6 operate directly on uints instead of casting the value
    to a signed int and calling format_unsigned_int/6.

    Make format_unsigned_int/6 cast the int value to a uint and then call
    format_uint/6.

    Delete predicates and functions used to convert ints to octal and
    hexadecimal strings.  We now just use the functions exported by
    the string module.

NEWS:
    Announce the additions to the string module.

tests/hard_coded/Mmakefile:
tests/hard_coded/uint_string_conv.{m,exp*}:
     Add a test of uint string conversion.
2020-11-20 23:07:52 +11:00
Julien Fischer
c242c4b981 Adjust markup in NEWS file.
NEWS:
   As above.
2020-11-14 14:29:49 +11:00
Zoltan Somogyi
9730abbb8b Announce the new poly_types. 2020-11-10 11:10:04 +11:00
Zoltan Somogyi
685dbea53e Delete obsolete preds/funcs in term.m.
library/term.m:
    As above.

NEWS:
    Announce the changes.
2020-10-30 19:04:26 +11:00
Peter Wang
fc4c747386 Delete references to Erlang backend in documentation.
.INSTALL.in:
.nocopyright:
BUGS:
README.Erlang:
README.MS-VisualC:
README.MacOS:
README.MinGW:
README.md:
doc/reference_manual.texi:
doc/user_guide.texi:
    As above.

NEWS:
    Announce removal of Erlang backend.
2020-10-27 10:56:10 +11:00
Julien Fischer
0721d90373 Drop support for versions of macOS prior to 10.9.
This means that the following are no longer supported:

- the powerpc*apple*darwin* configuration.
- versions of XCode prior to about 6 or so

NEWS:
    Announce the above.

README.MacOS:
    Delete text describing things that are no longer supported.

configure.ac:
    Do not check if gcc is really llvm-gcc.  llvm-gcc was replaced
    by clang years ago.

compiler/compile_target_code.m:
scripts/mgnuc.in:
    Delete a workaround for an issue on powerpc based Macs.
2020-10-26 12:54:14 +11:00
Zoltan Somogyi
0b9b4b862b Mention deletion of _se predicate variants. 2020-10-22 17:58:44 +11:00
Zoltan Somogyi
4ec34ffcbb Delete default names from clauses in .opt files.
library/varset.m:
    Provide a capability to delete the names of variables,
    either individually, or en masse.

    Unrelated change: replace two clauses with a switch.

NEWS:
    Document the new functionality in varset.m.

compiler/convert_parse_tree.m:
    Use the new functionality to delete the name of every variable
    that has a default name in a clause in a .opt file. Document why
    we do this.
2020-10-22 17:41:43 +11:00
Zoltan Somogyi
5ca61d187f Document recent changes to getopt/getopt_io. 2020-10-22 17:31:32 +11:00
Zoltan Somogyi
a36eed702d Add add_suffix to the standard library.
compiler/write_deps_file.m:
library/string.m:
    Move a generally-useful function to the library.

NEWS:
    Announce the addition.
2020-10-19 15:52:47 +11:00
Julien Fischer
ff39b3463b Remove legacy support for the Alpha architecture.
README.Linux-Alpha:
runtime/machdeps/ALPHA_REGS:
runtime/machdeps/alpha_regs.h:
runtime/machdeps/alpha_regtest:
    Delete these files.

configure.ac:
runtime/Mmakefile:
runtime/mercury_goto.h:
runtime/mercury_regs.h:
README.md:
README.Linux:
README.Linux-PPC:
    Delete or update references to the Alpha architecture.

NEWS:
    Announce the above.

scripts/mgnuc.in:
    Unrelated: update a comment.
2020-10-18 16:35:52 +11:00
Julien Fischer
7dca0964cb Fix more markup in NEWS file.
NEWS:
   As above.
2020-10-14 23:38:15 +11:00
Julien Fischer
5c1af017ac Fix markup in NEWS file.
NEWS:
   As above.
2020-10-14 23:36:44 +11:00
Peter Wang
89e59e7cc8 Delete support for browsing terms as XML.
The 'browse --xml' command has not worked with current versions of
xsltproc for quite some time, but we have not received any bug reports,
nor has anyone tried to fix it. We have a method for interactively
exploring a term in 'browse --web' so IMHO there is no need to keep
support for 'browse --xml'.

browser/browse.m:
browser/browser_info.m:
browser/declarative_user.m:
trace/mercury_trace_browse.c:
trace/mercury_trace_browse.h:
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_cmd_parameter.c:
trace/mercury_trace_cmd_parameter.h:
trace/mercury_trace_internal.c:
    Delete code.

doc/mdb_categories:
doc/user_guide.texi:
    Delete documentation.

configure.ac:
    Don't search for a XUL browser and xsltproc.

scripts/mdbrc.in:
    Delete 'xml_browser_cmd' and 'xml_tmp_filename' lines.

scripts/xul_tree.xsl:
    Delete now unused file.

scripts/Mmakefile:
    Conform to deletions.

tests/debugger/Mmakefile:
tests/debugger/browser_test.exp:
tests/debugger/browser_test.exp3:
tests/debugger/browser_test.inp:
tests/debugger/mdb_command_test.inp:
tests/debugger/save.exp2:
tests/declarative_debugger/browse_arg.exp:
tests/declarative_debugger/browse_arg.inp:
    Don't test 'browse --xml' any longer.

extras/xml_stylesheets/README:
    Delete reference to 'browse --xml' command.

NEWS:
    Announce change.
2020-10-14 17:41:54 +11:00
Zoltan Somogyi
f8c67929de Modernize library/array2d.m.
library/array2d.m:
    Add lookup and unsafe_lookup, in both function and predicate forms,
    as alternatives to rafe's ^elem notation.

    Use meaningful variable names in both code and documentation.
    For example, use NumRows and NumColumns instead of M and N.

    Replace the implementation of the function that converts a 2d array
    back to lists. The new implementation has one loop over rows and one
    loop over columns, while the old one had a single loop that did
    both jobs. The new one returns [] (meaning no rows) for a 0x0 array,
    while the old returned [[]] (meaning one row with no columns).

NEWS:
    Announce the changes.

tests/hard_coded/test_array2d.m:
    Use a lookup instead of ^elem.

tests/hard_coded/test_array2d.exp:
    Expect the updated output from lists. Expect any exceptions to come
    from lookup functions, not ^elem functions (since the latter now
    just call the former).
2020-10-05 00:06:37 +11:00
Julien Fischer
0dd6c2b0cc Update NEWS for 20.06.1.
NEWS:
    As above.
2020-10-04 03:32:04 +11:00
Julien Fischer
2c727afc05 Adjust markup in NEWS file.
NEWS:
    As above.

    Put debugger changes in a debugger section.
2020-10-03 23:12:46 +10:00
Peter Wang
a22e973025 Let mdb run an external command for 'list'.
browser/listing.m
    Add list_file_with_command which calls an external command to print
    source listings instead of doing it internally. The implementation
    is incomplete in that the external command's standard output and
    standard error streams are not redirected into OutStrm and ErrStrm.

    Rename mercury_stream_to_c_FILE_star to
    mercury_stream_to_c_file_ptr.

    Consolidate some output calls with string.format.

trace/mercury_trace_cmd_parameter.c:
trace/mercury_trace_cmd_parameter.h:
trace/mercury_trace_internal.c:
    Add a 'list_cmd' command which sets or prints the current
    external listing command.

trace/mercury_trace_cmd_browsing.c:
    Make 'list' command call list_file_with_command if an external
    listing command was set.

doc/user_guide.texi:
    Document 'list_cmd' command.

tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
    Update for new command.

NEWS:
    Announce changes.
2020-10-02 19:01:45 +10:00
Zoltan Somogyi
181ada0dbf Avoid -O<n> resetting previously set options.
This implements Mantis feature request #495.

NEWS:
    Announce the change.

compiler/optimization_options.m:
    A new module for managing optimization options.

    It defines a separate bespoke type for every boolean optimization option
    to make it harder to confuse them. It defines a tuple type (opt_tuple)
    for accessing optimization options quickly. It implements the turning on
    (but NOT turning off) of optimizations when a given optimization level
    is selected.

tools/make_optimization_options_middle:
tools/make_optimization_options_db:
    The script that generates the meat of optimization_options.m,
    and the database of option names, kinds and initial values
    that it uses as its input. The script also generates some code
    for the special_handler predicate in compiler/options.m.

tools/make_optimization_options_start:
tools/make_optimization_options_end:
    The handwritten initial and final parts of optimization_options.m.

tools/make_optimization_options:
    The script that pulls these parts together to form optimization_options.m.

compiler/options.m:
    Make every optimization option a special option, to be handled by
    the special_handler predicate. That handling consists of simply
    adding a representation of the option to the end of a cord of
    optimization options, to be processed later by optimization_options.m.
    That processing will record the values of these options in the opt_tuple,
    which is where every other part of the compiler should get them from.

    Change the interface of special_handler to make the above possible.

    Add an "optopt_" (optimization option) prefix to the name of
    every optimization option, to make them inaccessible to the rest
    of the compiler under their old name, and thus help enforce the switch
    to using the opt_tuple. Any access to these options to look up
    their values would fail anyway, since the option data would no longer be
    e.g. bool(yes), but bool_special, but the name change makes this failure
    happen at compile time, not runtime.

    Reclassify a few options to make the above make sense. Some options
    (unneeded_code_debug, unneeded_code_debug_pred_name, and
    common_struct_preds) were classified as oc_opt even though they
    control only the *debugging* of optimizations, while some options
    (c_optimize and inline_alloc) were not classified as oc_opt
    even though we do set them automatically at some optimization levels.

    Delete the opt_level_number option, since it was not used anywhere.

    Delete the code for handling -ON and --opt-space, since that is now
    done in optimization_options.m.

    Add some XXXs.

compiler/handle_options.m:
    Switch to using getopt_io.process_options_userdata_se, as required
    by the new interface of the special_handler in options.m.
    In the absence of errors, invoke optimization_options.m to initialize
    the opt_tuple. Then update the opt_tuple incrementally when processing
    option implications that affect optimization options.

compiler/globals.m:
    Put the opt_tuple into a new field of the globals structure.

compiler/accumulator.m:
compiler/add_pragma_type_spec.m:
compiler/add_trail_ops.m:
compiler/code_info.m:
compiler/code_loc_dep.m:
compiler/compile_target_code.m:
compiler/const_struct.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/disj_gen.m:
compiler/erl_code_gen.m:
compiler/format_call.m:
compiler/global_data.m:
compiler/grab_modules.m:
compiler/higher_order.m:
compiler/hlds_pred.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/ite_gen.m:
compiler/jumpopt.m:
compiler/libs.m:
compiler/llds_out_code_addr.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_instr.m:
compiler/llds_out_util.m:
compiler/matching.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/ml_disj_gen.m:
compiler/ml_gen_info.m:
compiler/ml_lookup_switch.m:
compiler/ml_optimize.m:
compiler/ml_proc_gen.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen_construct.m:
compiler/optimize.m:
compiler/pd_util.m:
compiler/peephole.m:
compiler/polymorphism.m:
compiler/proc_gen.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_scope.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/simplify_tasks.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/tag_switch.m:
compiler/tupling.m:
compiler/unify_gen_construct.m:
compiler/unneeded_code.m:
compiler/unused_args.m:
    Conform to the changes above, mostly by looking up optimization options
    in the opt_tuple. In some places, replace bools containing optimization
    options with the bespoke type of that specific optimization option.

library/getopt_template:
    Fix a bug that screwed up an error message.

    The bug happened when processing a --file option. If one of the
    options in the file was a special option whose special handler failed,
    the code handling that failing option returned both an error indication,
    and the rest of the argument list read in from the file. The code
    handling the --file option then *ignored* the error indication from
    the failed special option, and returned an error message of its own
    complaining about the unconsumed remaining arguments in the file,
    believing them to be non-option arguments, even though these arguments
    were never looked it to see if they were options.

    The fix is for the code handling --flag options to check whether
    the code processing the file contents found any errors, and if so,
    return that error *without* looking at the list of remaining arguments.

    In an unrelated change, factor out a duplicate call.
2020-09-28 18:16:13 +10:00
Zoltan Somogyi
d0d6d1ab2b Remove "is" as a synonym for "=", step 2.
configure.ac:
    Require step 1 to be installed.

library/prolog.m:
    Add back here the definition of "is" that was deleted from int.m.

compiler/parse_goal.m:
    Don't accept "is" as a synomym for "=".

NEWS:
    Announce the change.
2020-08-26 14:57:18 +10:00
Julien Fischer
735473fe48 Fix minor errors in recent NEWS entries.
NEWS:
    Fix minor errors in entries about deleted library predicates.

    Adjust the markup of the same.
2020-08-19 21:51:05 +10:00
Zoltan Somogyi
75b88b03c7 Implement memo attribute disable_warning_if_ignored.
NEWS:
doc/reference_manual.texi:
    Document the new attribute, which, if specified on a pragma memo,
    shuts up the warning that the compiler would otherwise generate
    about that pragma if it had to ignore it because the targeted backend
    does not support memoing.

compiler/prog_data_pragma.m:
    Add the new attributes to the set of tabling attributes.

    Add the new attribute to the eval_memo eval_method as an argument
    in order to preserve it until table_gen.m can act on it. (The other
    tabling attributes are implemented way before that, so the attribute
    structure itself doesn't survive to reach table_gen.m.)

compiler/parse_pragma.m:
    Parse the new pragma, and copy it to the eval method.

compiler/table_gen.m:
    Generate a warning about ignoring a pragma memo only if the new attribute
    does not disable that warning.

compiler/options.m:
    Provide a simple way for the configure script to test whether
    the installed compiler contains this diff.

compiler/hlds_out_module.m:
compiler/hlds_out_pred.m:
compiler/hlds_pred.m:
compiler/item_util.m:
compiler/layout_out.m:
compiler/parse_tree_out_pragma.m:
compiler/prog_out.m:
compiler/tabling_analysis.m:
    Conform to the changes above.
2020-08-19 06:14:58 +10:00
Zoltan Somogyi
58ea6ffff2 Delete old obsolete predicates and functions.
library/*.m:
    Specifically, delete any predicates and functions whose `pragma obsolete'
    dates from 2018 or before. Keep the ones that were obsoleted
    only this year or last year.

NEWS:
    Announce the changes.

tests/debugger/io_tab_goto.m:
tests/debugger/tabled_read.m:
tests/declarative_debugger/io_stream_test.m:
tests/declarative_debugger/tabled_read_decl.m:
tests/declarative_debugger/tabled_read_decl_goto.m:
tests/general/array_test.m:
tests/hard_coded/mutable_init_impure.m:
tests/hard_coded/remove_file.m:
tests/tabling/mercury_java_parser_dead_proc_elim_bug.m:
tests/tabling/mercury_java_parser_dead_proc_elim_bug2.m:
tests/valid/mercury_java_parser_follow_code_bug.m:
    Replace references to predicates and functions that this diff deletes
    with their suggested replacements.

    In several test cases, bring the programming style up to date.

tests/hard_coded/shift_test.{m,exp}:
    Most of this test case tested the now-deleted legacy shift operations.
    Replace these with tests of their non-legacy versions, including
    testing for the expected exceptions.

tests/hard_coded/shift_test.{m,exp}:
    Don't pass --no-warn-obsolete when compiling shift_test.m anymore.
2020-08-18 11:57:47 +10:00
Julien Fischer
6a8ce2d6d5 Add a section for 20.06.1 NEWS
NEWS:
    As above.
2020-07-30 00:03:17 +10:00
Peter Wang
ca8384de08 Revert "Enable munmap support in Boehm GC by default."
This reverts commit 4ef3fdad30.

Unfortunately, when calling GC_gcollect_and_unmap() repeatedly
the program would sometimes abort with the message:

    mmap(PROT_NONE) failed

This is on Linux 5.7.7 x86-64.
2020-07-23 17:29:51 +10:00
Peter Wang
4ef3fdad30 Enable munmap support in Boehm GC by default.
Memory unmapping support is useful for long running programs to return
unused memory pages back to the OS, e.g. a server process can reduce the
amount of physical memory it occupies during idle periods.

Previously the user building the Mercury system needed to enable munmap
support at configure time. In 2008 I wrote:

    Allow the use of munmap() in Boehm GC, in order to return unused
    memory pages back to the OS. This has an adverse effect on run times
    so we want to be able to enable it on a per-application basis.

Bdwgc upstream has more recently enabled munmap support by default on
the master branch (albeit, not the v7.6.x branch we currently use).

Some testing on my machine suggests that we can try enabling munmap
support by default:

  - in asm_fast.gc grade, there was no discernable difference to the
    compiler's performance, with or without munmap support

  - in the hlc.gc grade, the compiler ran 1-2% faster
    WITH munmap support enabled

Tested on Linux/x86-64, time to compile the 10 largest modules in the
arena directory.

configure:
    Change default value of enable_gc_mmap and enable_gc_munmap to yes.

    Invert sense of --enable-gc-mmap and --enable-gc-munmap options in
    the help text.

NEWS:
    Announce change.
2020-07-22 17:17:33 +10:00
Julien Fischer
fb643a2ca7 Support 'mercury' as a synonym for 'mmc' on all platforms.
On Windows the name 'mmc' is also used for the executable for Microsoft
Management Console.  For the MSVC port on the Windows command line we have long
provided a batch file named 'mercury' as an alternative to `mmc' in order to
avoid this clash.  (Re-arranging your PATH to avoid the clash is not always an
option.)

Provide a shell script named 'mercury' that serves the same purpose elsewhere.
Its main use is to avoid the name clash on MinGW/MSYS, Cygwin etc., but
making the name available everywhere should avoid unnecessary changes in build
scripts and alike.

Document the issue with the name clash in the appropriate chapter of the user's
guide and also in the top-level Windows README file.

scripts/mercury.in:
     Add a template for the 'mercury' script.

configure.ac:
     Create the 'mercury' wrapper script.

scripts/Mmakefile:
     Add 'mercury' to the list of scripts.

doc/user_guide.texi:
     Add a paragraph describing the 'mmc' name clash on Windows and what
     to do about it.

     Unrelated change: ':' is no longer a module qualifier.

README.MS-Windows:
     Point users to the relevant chapter of the user's guide for ways
     to deal with the `mmc' name clash.

NEWS:
     Announce the addition.
2020-06-16 16:33:22 +10:00
Julien Fischer
9f23ac15b8 20.06 release preparations.
NEWS:
HISTORY:
    Shift 20.01.X NEWS into the HISTORY file.

RELEASE_NOTES:
    Bump version.
2020-06-02 16:23:22 +10:00
Julien Fischer
eae9222ca7 Put NEWS entries back in order.
NEWS:
   As above.
2020-05-26 23:12:39 +10:00
Julien Fischer
20c4912cc4 Fix a typo.
NEWS:
   As above.
2020-05-26 23:09:52 +10:00
Julien Fischer
61bd9a4e45 Use integer constant functions in string formatting.
library/string.format.m:
    Use the constant functions exported by the integer module
    for small integers where possible; this avoids having to
    construct those integers at runtime.

library/integer.m:
    Add constant functions returning 8 and 16 as arbitrary
    precision integers.

NEWS:
    Announce the above additions.
2020-05-26 18:35:12 +10:00
Julien Fischer
9528f326d2 Formatting of uints using string.format etc.
Extend the operations that perform formatted conversion, such as
string.format/2, to be able to handle values of type uint directly. We have
always supported formatting values of type int as unsigned values, but
currently the only way to format uint values is by explicitly casting them to
an int. This addresses Mantis issue #502.

library/string.m:
    Add a new alternative to the poly_type/0 type that wraps uint
    values.

    Update the documentation for string.format. uint values may
    now be formatted using the u, x, X, o or p  conversion specifiers.

library/string.format.m:
   Add the necessary machinery for handling formatting of uint values.

library/string.parse_runtime.m:
library/string.parse_util.m:
   Handle uint poly_types.

library/io.m:a
   Handle uint values in the write_many predicates.

library/pprint.m:
   Handle uint values in the poly/1 function.

compiler/format_call.m:
compiler/parse_string_format.m:
    Conform to the above changes.

compiler/options.m:
    Add a way to detect if a compiler supports this change.

NEWS:
    Announce the above changes.

tests/hard_coded/stream_format.{m,exp}:
    Extend this test to cover uints.

tests/invalid/string_format_bad.m:
tests/invalid/string_format_unknown.m:
    Conform to the above changes.

tests/string_format/Mmakefile:
tests/string_format/string_format_uint_o.{m,exp,exp2}:
tests/string_format/string_format_uint_u.{m,exp,exp2}:
tests/string_format/string_format_uint_x.{m,exp,exp2}:
   Add tests of string.format with uints.
2020-05-23 14:01:01 +10:00
Zoltan Somogyi
5f47e4b742 Add new option --show-definition-extents.
When specified, the compiler will generate an overview of the sequence
of predicates and functions in the module being compiled, and put it
in a file with the suffix ".defn_extents". For tests/benchmarks/nrev,
this file looks like this:

    main/2              26 to     26
    main1/1             28 to     30
    main3/3             35 to     37
    data/1              42 to     42
    nreverse/2          48 to     50
    concatenate/3       55 to     57
    print_list/3        62 to     64
    print_list_2/3      76 to     80

This overview can help spot situations in which related predicates
and functions are not grouped together.

compiler/options.m:
    Add the new option.

compiler/mercury_compile_main.m:
    If the new option is specified, invoke hlds_defns.m to do the task
    that it asks for.

compiler/hlds_defns.m:
    Implement the new option, mostly by slightly generalizing the old code
    that implements the related option --show-definition-line-counts,
    and wrapping it up in a small amount of new code.

doc/user_guide.texi:
NEWS:
    Document and announce the new option.
2020-05-06 16:25:02 +10:00
Zoltan Somogyi
85f20002c5 Move the domain_error type to exception.m.
library/math.m:
library/exception.m:
    Move the domain_error type from math.m to exception.m.

NEWS:
    Announce the change as a potentially breaking change.

deep_profiler/query.m:
library/float.m:
library/int.m:
library/int16.m:
library/int32.m:
library/int64.m:
library/int8.m:
library/integer.m:
library/uint.m:
library/uint16.m:
library/uint32.m:
library/uint64.m:
library/uint8.m:
    Replace all references to math.domain_error with just domain_error.
    Delete imports of math.m where this was the only reason for the import.
2020-05-01 18:57:43 +10:00
Zoltan Somogyi
ada627928c Stop supporting --tags none for C.
The effect of --tags none is to tell the compiler not to use any primary
tag bits. The option is not needed when targeting Java, C# or Erlang,
since with these languages we can't use primary tags. It was effective
only in C grades. However, since using primary tags is always faster,
the only use case for --tags none was to measure *how much* faster.
This was useful in Mercury's early development, but has become obsolete
ages ago.

compiler/options.m:
doc/user_guide.texi:
    Delete the --tags option. For non-C targets, it was never needed,
    and with the deletion of first --tags high and now --tags none,
    --tags low is the only supported value for C.

    Change the documentation of the --num-ptag-bits option to emphasize
    that name, not its older but less specific synonym, --num-tag-bits.
    Document that the only reason to use this option is cross-compilation.

    In user_guide.texi, also delete some references to long-deleted
    options for reserved addresses and objects, and some duplicate lines
    in comments.

NEWS:
    Document the option removal.

compiler/globals.m:
    Delete the tags_method field of the globals, since it is not
    needed anymore.

compiler/handle_options.m:
    Delete the code that converts the value of the --tags option to the
    value of the tags_method field of the globals.

    Ensure that the value of the num_ptag_bits option is (a) zero when
    not targeting C, and (b) either 2 or 3 when targeting C.

compiler/du_type_layout.m:
    Check that we are using 2 or 3 ptag bits when targeting C.

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

runtime/mercury_grade.h:
    Generate an error if MR_TAGBITS is zero (which could happen
    only with --tags none).

runtime/mercury_tags.h:
    Delete the definitions of the list access macros for the MR_TAGBITS == 0
    case.
2020-04-28 13:36:58 +10:00
Julien Fischer
551464acf6 Fix some markup in the NEWS file.
NEWS:
    As above.
2020-04-20 22:51:13 +10:00
Julien Fischer
3cc811155f Minor fix for the NEWS file.
NEWS:
    Make some headings consistent.
2020-04-20 22:47:59 +10:00
Julien Fischer
09bafce455 Adjust the NEWS file.
NEWS:
    Shift the fix for bug #461 into the 20.01.2 section.
2020-04-20 17:53:25 +10:00
Julien Fischer
ba5fe38ee7 Add unboxed_readers to the stream module.
library/stream.m:
    Add a new type of reader, unboxed_reader.  These provide a 'get'
    operation that does not need to box its output in the non-error case.

library/io.m:
    Add an unboxed_reader instance for text_input_streams and chars.

NEWS:
   Announce the addition.
2020-04-20 17:49:06 +10:00
Peter Wang
a4b26739ba Reset es_action field when idle ws engine receives a notification.
In MR_do_idle_worksteal, reset the engine's es_action field to
MR_ENGINE_ACTION_NONE before performing the notified action.
This mirrors the behaviour in MR_do_sleep.

Fixes the assertion failure in Mantis bug #461: when an engine is
shut down, MR_verify_final_engine_sleep_sync checks that the engine's
es_action field is MR_ENGINE_ACTION_NONE.

runtime/mercury_context.c:
    As above.

NEWS:
    Announce change.
2020-04-20 12:41:45 +10:00
Peter Wang
7267bad6ea Document actual behaviour of mvar.try_take and mvar.try_read.
library/thread.mvar.m:
    Document actual behaviour of mvar.try_take and mvar.try_read:
    both may return `no' even if the mvar was not empty.

    Clarify behaviour of mvar.read.

NEWS:
    Announce change.
2020-04-20 11:33:25 +10:00
Zoltan Somogyi
3e894a7a9d Remove the hl grade component.
As we discussed, it has fallen into disuse. Its main purpose was to
pave the way for the .net backend and later for the java and csharp grades.
Now that the .net backend is ancient history and the java and csharp grades
are established, that purpose is gone, and for every other purpose,
hlc is better because it is simpler and faster.

compiler/options.m:
    Delete the --high-level-data option. It is no longer needed,
    bacause the data representation scheme is now a direct function
    of the target language.

doc/user_guide.texi:
    Delete references to the --high-level-data option.

NEWS:
    Mention that --high-level-data is no longer supported.

compiler/compute_grade.m:
    Delete references to the hl grade component, and conform
    to the deletion of the --high-level-data option.

compiler/compile_target_code.m:
    Give some predicates more meaningful names, and conform to the
    deletion of the --high-level-data option.

compiler/const_struct.m:
compiler/du_type_layout.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/lco.m:
compiler/mercury_compile_main.m:
compiler/ml_gen_info.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen_construct.m:
compiler/mlds_to_c_data.m:
compiler/mlds_to_c_func.m:
compiler/mlds_to_c_type.m:
compiler/mlds_to_c_util.m:
    Conform to the deletion of the --high-level-data option.

grade_lib/grade_spec.m:
grade_lib/grade_vars.m:
    Delete the datarep solver variable, since the data representation
    is now a direct function of the target language.

    Delete the requirements involving the deleted solver variable.

grade_lib/grade_structure.m:
    Delete the datarep component of the representation of MLDS C grades,
    since its value would now be fixed.

grade_lib/grade_solver.m:
grade_lib/grade_string.m:
grade_lib/try_all_grade_structs.m:
grade_lib/var_value_names.m:
    Conform to the changes above.

grade_lib/Mmakefile:
    Link the grade library's test programs statically, like we do
    the executables in the other directories.

library/io.m:
library/robdd.m:
library/rtti_implementation.m:
runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
runtime/mercury_hlc_types.h:
    Remove references to MR_HIGHLEVEL_DATA, as well as any code
    that was guarded by #ifdef MR_HIGHLEVEL_DATA.

scripts/Mmake.vars.in:
scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
scripts/mmake.in:
scripts/mmc.in:
scripts/mtc:
scripts/parse_grade_options.sh-subr:
scripts/parse_ml_options.sh-subr.in:
    Remove references to --high-level-data options.

    In canonical_grade.sh-subr, compute the base grade more directly.

    Remove a few left-over references to the assembler backend.

    Add or fix vim modelines where relevant.

    Fix inconsistent indentation.

    Add missing ;;s in case statements.

    Switch to using ${var} references instead of just $var.

tests/invalid/Mercury.options:
    Make the test_feature_set test case run in grade java instead of hl.gc.

tests/invalid/test_feature_set.err_exp:
    Update the expected out for the grade change.
2020-04-11 19:30:58 +10:00