Commit Graph

2410 Commits

Author SHA1 Message Date
Zoltan Somogyi
78720b4537 Improve the user guide.
doc/user_guide.texi:
    Document the recent change that mmc -f *.m is needed if a module's
    file name does not match the fully qualified module name.

    Mention that the discussion of .c and .o files applies only
    to grades targeting C.

    Mention that LLDS details such as MERCURY_OPTIONS governing stack sizes
    apply only in (non-stseg) LLDS grades.

    Mention that mmake does not support Java, C# and Erlang grades,
    but comment out these mentions since I am not sure about exactly
    what we *can* say about this.

    Delete mention of the --assume-gmake option.

    Minor English improvements.

compiler/options.m:
    Delete the --assume-gmake option. It has long been unused.

runtime/mercury_wrapper.c:
    Add a reminder to update user_guide.texi if the default stack sizes
    are changed.
2020-05-30 23:13:42 +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
Zoltan Somogyi
af24cf08db Fix bootcheck in hlc.gc.pregen.
runtime/mercury_label.h:
    Add a #include of mercury_conf.h before the #include of
    mercury_conf_param.h.

    We #include mercury_conf.h anyway, indirectly through mercury_types.h,
    but this happens *after* mercury_conf_param.h. This was not a problem
    in the usual case when a .c file #included mercury_label.h, since
    its inclusion invariable came after inclusion of mercury_imp.h,
    which itself includes mercury_conf.h. It was a problem only in one
    very special case: when, as part of the namespace cleanliness check,
    mercury_label.h was compiled as the only thing #included in
    mercury_label.check.c, *and* the grade is the pregen grade.

    The problem was that MR_LOW_TAG_BITS is *defined* in mercury_conf.h,
    with a simple #define, but in the pregen grade, it is also *redefined*
    in mercury_conf_param.h with a #undef/#define sequence. without
    the fix, the compiler saw the sequence #undef/#define/#define, and
    balked at the double #define. The fix restores the intended
    #define/#undef/#define sequence. And the usual header guard macro
    protects against the double processing of the body of mercury_conf.h.

runtime/mercury_label.c:
    Delete a #include of mercury_conf.h, since it is (and was) redundant.

tests/EXPECT_FAIL_TESTS.hlc.gc.pregen:
    Expect the hard_coded/constant_prop_p1 test case to fail in the pregen
    grade, since one of the things it tests, arithmetic constant propagation,
    is explicitly disabled in this grade.
2020-04-28 10:55:18 +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
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
Julien Fischer
896e504580 Add missing out-of-line definitions for MR_box_{int64,uint64}.
runtime/mercury.c:
     Provide out-of-line definitions for MR_box_{int64,uint64} when using
     boxed 64-bit integers and *not* using GCC.
2020-03-15 17:05:47 +11:00
Julien Fischer
f60caca91c Use trail segments by default in trailing grades.
Until now, we have supported two variants of trailing grades, those that use a
fixed-size trail (.tr) and those that use trail segments (.trseg).  This change
removes support for fixed sized trails, and renames the .trseg grade component
to .tr. The .trseg grade now acts a synonym for .tr; it is deprecated, since we
intend to eventually delete it.  Until then, the behavior of the old .tr grade
component should be available, though to developers only, by compiling the
whole system with EXTRA_CFLAGS = -DMR_USE_FIXED_SIZE_TRAIL.

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

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

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

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

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

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

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

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

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

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

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

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

NEWS:
    Announce this change.
2020-02-18 13:07:24 +11:00
Peter Wang
c38acd1f0b Disable non-local gotos on x86 with GCC 5+ if dynamic linking is enabled.
An old hack allowing non-local gotos to work with PIC on x86
no longer works with GCC 5+; this change is a workaround.
Mantis bug #453.

configure.ac:
    Position the handling of the --enable-dynamic-link option before
    we check if non-local gotos can work.

    Disable non-local gotos on x86 with GCC 5+ if dynamic linking
    is enabled.

runtime/mercury_goto.h:
    Add comment.
2020-01-20 15:24:19 +11:00
Peter Wang
09877885f9 Avoid gcc stringop-truncation error.
Avoid these errors, seen when compiling with a gcc 10 snapshot:
    error: ‘strncpy’ output truncated before terminating nul copying 3 bytes
    from a string of the same length [-Werror=stringop-truncation]

runtime/mercury_trace_term.c:
    Replace use of strncpy with memcpy in a private function.
2020-01-17 17:09:49 +11:00
AlaskanEmily
3f3f2290a0 Use sizeof and (Visual C only) __assume for MR_assert
Using sizeof ensures that the argument to MR_assert is valid code, but does not
actually execute its argument. This is helpful to prevent bitrot.

__assume is a Visual C extension which hints that the argument is impossible.
This gives the compiler hints about unused variables (silencing some warnings),
and can also improve optimization.

runtime/mercury_std.h:
    As above.
2019-12-03 12:38:02 +11:00
Peter Wang
025bee0549 Check for surrogates when converting list of char to string.
library/string.m:
    Make from_char_list, from_rev_char_list, to_char_list throw an
    exception if the list of chars includes a surrogate code point that
    cannot be encoded in a UTF-8 string.

    Make semidet_from_char_list, semidet_from_rev_char_list,
    to_char_list fail if the list of chars includes a surrogate code
    point that cannot be encoded in a UTF-8 string.

runtime/mercury_string.h:
    Document return value of MR_utf8_width.

tests/hard_coded/Mmakefile:
tests/hard_coded/string_from_char_list_ilseq.exp:
tests/hard_coded/string_from_char_list_ilseq.exp2:
tests/hard_coded/string_from_char_list_ilseq.m:
    Add test case.

tests/hard_coded/null_char.exp:
    Expect new message in exceptions thrown by from_char_list,
    from_rev_char_list.

tests/hard_coded/string_hash.m:
    Don't generate surrogate code points in random strings.
2019-10-30 11:21:02 +11:00
Julien Fischer
ee9aaa8c1b Always use 64-bit offsets with fseek() and ftell().
Most sane systems use 64-bit offsets with those functions; Windows does not.

runtime/mercury_file.h:
   Define macros MR_fseek and MR_ftell that expand to the name of the
   fseek or ftell function that uses 64-bit offsets.

runtime/mercury_deep_profiling.c:
library/io.m:
    Use the new macros and always use 64-bit offsets.
2019-10-08 21:36:11 +11:00
Peter Wang
1a619af68e Add more TODOs relating to ill-formed code unit sequences. 2019-09-13 15:51:02 +10:00
Peter Wang
c08db9e5f7 Make MR_utf8_get return error for more ill-formed sequences.
runtime/mercury_string.c:
    Make MR_utf8_get, MR_utf8_get_mb return an error for code unit
    sequences that encode a surrogate code point, or a code point
    greater than U+10FFFF.

runtime/mercury_string.h:
    Adjust some comments.
2019-09-13 15:51:02 +10:00
Peter Wang
ed1b3fe19c Note some future work for handling ill-formed sequences in strings.
library/io.m:
library/string.m:
    Add warnings that Mercury strings are not limited to valid UTF-8 or
    UTF-16.

library/string.m
library/string.format.m
library/term_io.m
    Note some current behaviours of predicates/functions when passed
    strings containing invalid UTF-8 or UTF-16, and what to do about it.

runtime/mercury_string.h:
    Note behaviour of MR_utf8_encode.
2019-09-09 10:47:48 +10:00
Adrian Wong
a589fd1164 Fix some comments related to hashing.
library/hash_table.m:
library/string.m:
runtime/mercury_string.h:
    As above.
2019-07-29 11:35:53 +10:00
Peter Wang
544f3bf095 Use musl getopt implementation.
LICENSE:
    Mention files derived from musl library.

runtime/process_getopt:
    Process files from ../getopt/*.[ch] to produce
    mercury_getopt.h, mercury_getopt.c, mercury_getopt_long.c.

runtime/mercury_getopt.h:
runtime/mercury_getopt.c:
runtime/mercury_getopt_long.c:
    Add files generated by process_getopt.

runtime/Mmakefile:
    Update list of source files.

util/Mmakefile:
    Use musl getopt if the system C library does not have getopt().

tests/debugger/browser_test.exp:
tests/debugger/browser_test.exp2:
tests/debugger/browser_test.exp3:
tests/hard_coded/runtime_opt.exp:
    Update expected error messages to match new getopt() output.

changed exp output
2019-06-10 13:30:49 +10:00
Peter Wang
3162997f14 Delete GNU getopt implementation.
runtime/GETOPT/getopt.c:
runtime/GETOPT/getopt.h:
runtime/GETOPT/getopt1.c:
runtime/mercury_getopt.c:
runtime/mercury_getopt.h:
runtime/mercury_getopt1.c:
    Delete files.

runtime/RESERVED_MACRO_NAMES:
    Delete __GNU_LIBRARY__ macro.
2019-06-10 13:30:43 +10:00
Peter Wang
2e9b41d8a2 Store less-than-word-sized values in LSBs of box.
runtime/mercury_heap.h:
    Store less-than-word-sized values in least significant bits of a
    box. This makes no difference on little endian machines.
    On big endian machines, it affects the value printed out
    when the box is printed generically.
2019-06-08 16:40:24 +10:00
Peter Wang
dfab1619c2 Disambiguate references to editline.
There are multiple libraries named "editline" on the net.
The one that Mercury supports is (a port of) the NetBSD editline
library, sometimes also referred to as "libedit". Make it easier
for the user to install the correct library.

.INSTALL.in:
configure.ac:
m4/mercury.m4:
runtime/mercury_conf.h.in:
    Mention NetBSD and libedit in a few more places.
2019-06-08 14:06:53 +10:00
Zoltan Somogyi
02bf90da93 Fix a type-size-mismatch bug in RTTI.
runtime/mercury_stack_layout.h:
    Make the count of type params the same size as the descriptions
    of the locations of those type params, since they are filled in
    by values from the same compiler-generated array. The mismatch caused
    hard_coded/copy_pred_2.m to fail on a 64-bit big endian machine
    (AIX/PowerPC).
2019-06-05 17:33:10 +02:00
AlaskanEmily
2330a2f294 Fix comment ending a macro
runtime/mercury_goto.h:
    Switching one of the comments only seen in Sparc code cut off the end of a macro.
    Only block comments can be placed inside macros anyway, not single-lines.
2019-03-13 16:51:08 +11:00
AlaskanEmily
117eba02f1 Avoid using HZ to scale clock values on Linux.
HZ is no longer an accurate scaling factor, and is hardcoded to 100.

runtime/mercury_timing.h:
    As above.
2018-11-29 06:01:42 +00:00
Peter Wang
5f7d3e6bb2 Use consistent integer types for some RTTI fields.
runtime/mercury_type_info.h:
    Use unsigned integer types for a few RTTI structure fields that
    are known to hold non-negative values.

    Add comments for other field types that could be changed later.

compiler/rtti.m:
    Use fixed size integer types for fields matching the size
    and signedness of the corresponding C RTTI structure fields.

    Encode type ctor flags in a uint16 instead of int.

    Make type_ctor_details_num_ptags and type_ctor_details_num_functors
    return a maybe value, instead of a negative value to represent no
    primary tags or no function symbols, respectively.

compiler/type_ctor_info.m:
    Conform to type changes.

    Use uint16 to represent the "contains var" bit vector.

compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
    Conform to type changes.

    Add comments to make it easier to find the code that writes out
    each particular RTTI structure field.

compiler/ml_util.m:
    Add helper functions.

compiler/add_special_pred.m:
compiler/du_type_layout.m:
compiler/erl_rtti.m:
compiler/erlang_rtti.m:
compiler/hlds_data.m:
compiler/llds_out_data.m:
compiler/ml_unify_gen_construct.m:
compiler/opt_debug.m:
compiler/pseudo_type_info.m:
compiler/stack_layout.m:
compiler/unify_gen_construct.m:
    Conform to type changes.

compiler/parse_type_defn.m:
compiler/prog_data.m:
    Use uint32 for functor ordinal numbers.

library/rtti_implementation.m:
    Use fixed size integer types for RTTI field accessor functions,
    and update callers.

java/runtime/DuArgLocn.java:
java/runtime/DuExistInfo.java:
java/runtime/DuExistLocn.java:
java/runtime/DuFunctorDesc.java:
java/runtime/TypeCtorInfo_Struct.java:
    Use integer types in RTTI structure definitions for Java that match
    the types in the C versions of the same structures.

runtime/mercury_dotnet.cs.in:
    Use integer types in RTTI structure definitions for C# that match
    the types in the C versions of the same structures.
2018-11-19 12:37:36 +11:00
Julien Fischer
f8d188fda8 Fix minor documentation problems.
deep_profiler/display_report.m:
deep_profiler/message.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analsis.m:
java/runtime/UnreachableDefault.java:
runtime/mercury_engine.c:
runtime/mercury_minimal_model.c:
runtime/mercury_signal.h:
runtime/mercury_stack_layout.h:
runtime/mercury_wrapper.c:
runtime/mercury_threadscope.c:
trace/mercury_trace_external.c:
HISTORY:
    As above.
2018-10-09 05:27:36 +00:00
Zoltan Somogyi
8303b503b6 Unify and compare packed args in bulk when possible.
compiler/unify_proc.m:
    Try to optimize the code we generate for unification and comparison
    predicates when a function symbol's arguments include sub-word-sized
    arguments packed together into a word.

    For unify predicates, generate code to test whether the two words
    at the same offset in the terms being unified are equal. This works
    regardless of whether the arguments are signed or unsigned.

    For compare predicates, generate code to compare the two words
    at the same offset in the terms being compared *if* all the arguments
    in the terms being compared are unsigned. This works because we put
    the earlier arguments in the more significant bit positions. But if
    some of the arguments are signed, then divide the argument word
    in sequences of zero or more unsigned arguments separated by signed
    arguments. We then generate code that compares any contiguous sequences
    of unsigned arguments in bulk, while comparing each signed field
    separately.

    Do the bulk unification and comparison via foreign_proc goals generated
    inline. This works only when we are generating C, but this is ok because
    we pack sub-word-sized arguments into a word only when generating C.

    We do the comparison of signed sub-word-sized fields (int8, int16 or int32)
    via foreign_proc goals generated inline as well. Doing them using unify
    goals would work as well, but would be less efficient in general. This is
    because having N such arguments in a function symbols requires storing
    only one value across calls for each term being compared (the term itself)
    when generating foreign_procs, but would require storing N values across
    calls (the values of the sub-word-sized signed arguments) when generating
    unifications. Generating inline foreign_procs is effectively a manual
    application of the optimization implemented by saved_vars.m.

library/private_builtin.m:
    Add the builtin predicates that unify_proc.m now generates calls to.

    We should never need their bodies, but the compiler does need to know
    the declarations of all predicates mentioned in inline foreign_procs.

configure.ac:
runtime/mercury_conf.h.in:
    Define either MR_MERCURY_IS_32_BITS or MR_MERCURY_IS_64_BITS depending
    on the word size. Make the configured value of MR_BITS_PER_WORD available
    to C code.

mdbcomp/program_representation.m:
    Register the new builtin predicates as no_typeinfo_builtins, i.e.
    builtins whose arguments' types contain type variables, that nevertheless
    should *not* be passed the typeinfos of the actual types bound to those
    type variables.

compiler/hlds_clauses.m:
    Bulk unification of arguments works only when all the arguments involved
    are initially ground. The optimized unification clauses we can now generate
    are thus appropriate only for <in,in> unifications. (Technically, they
    *would* work for unifications for which the function symbol arguments
    involved in bulk unify operations are ground even if some other arguments
    are initially free, but that distinction is too hard to make, compared
    to the extremely small performance gain that would be available
    if we *could* make that distinction.)

    Provide a way for unify_proc.m to mark a clause as being for use either
    in the <in,in> modes of unifications (for the optimized version using bulk
    unifications), or as in all other modes of unifications (for a version in
    which that optimization has been disabled).

    Replace two boolean fields in clauses_infos with bespoke types, for
    greater readability and reliability. These are a remnant of a different
    way to differentiate <in,in> vs non-<in,in> clauses that I ultimately
    decided against. These bespoke types are independent of the main change
    in this diff, but there is no reason to undo their use.

compiler/clause_to_proc.m:
    When copying clauses to procedure bodies inside type-specific unify
    predicates, pay attention to the markers that unify_proc.m put on
    those clauses about which are for <in,in> modes and which are for
    non-<in,in> modes.

    To make this possible, make our callers pass us extra information.

compiler/options.m:
    Add a bootstrapping option that governs whether unify_proc.m should
    try to apply the new optimization.

    Give an option that governs comparisons of function symbols for Erlang
    a name that reflects that fact.

compiler/hlds_pred.m:
    Fix a misleading predicate name.

compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/dead_proc_elim.m:
compiler/det_report.m:
compiler/erl_code_gen.m:
compiler/handle_options.m:
compiler/higher_order.m:
compiler/hlds_out_module.m:
compiler/hlds_out_pred.m:
compiler/hlds_statistics.m:
compiler/intermod.m:
compiler/mercury_compile_front_end.m:
compiler/ml_proc_gen.m:
compiler/modecheck_unify.m:
compiler/proc_gen.m:
compiler/proc_requests.m:
compiler/purity.m:
compiler/resolve_unify_functor.m:
compiler/structure_reuse.indirect.m:
compiler/structure_sharing.analysis.m:
compiler/tabling_analysis.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/unused_args.m:
    Conform to the changes above.
2018-10-03 08:32:29 +10:00
Peter Wang
bb35de8b3d Fix references to undeclared MR_ALLOC_ID in low-level C memprof grades.
runtime/mercury_ml_expand_body.h:
    Delete references to MR_ALLOC_ID in code that builds lists of univs.
2018-09-16 16:23:16 +10:00
Peter Wang
e40d54f89c Include <sys/select.h> for select() if available.
According to the man page, <sys/select.h> is the header to include
on POSIX systems for select() and associated APIs.
Fixes compilation with some versions of Cygwin (Github issue #49).

configure.ac:
runtime/mercury_conf.h.in
    Define MR_HAVE_SYS_SELECT_H if <sys/select.h> is available.

runtime/mercury_reg_workarounds.c
runtime/mercury_reg_workarounds.h
    Include <sys/select.h> if MR_HAVE_SYS_SELECT_H is defined.
2018-09-11 10:55:30 +10:00
Peter Wang
aef7167203 Avoid gcc misleading indentation warning.
runtime/mercury_deconstruct_macros.h:
    Reformat an else if in MR_get_arg_value() to prevent a warning from
    gcc 8 about misleading indentation when -ftrack-macro-expansion=0
    is used (which we pass to make error messages easier to filter).
2018-09-09 12:33:26 +10:00
Zoltan Somogyi
d1ec3e3f55 Pack characters as sub-word-sized arguments.
compiler/options.m:
    Add new options --allow-packing-chars and --allow-packing-mini-types,
    for use by developers only.

compiler/du_type_layout.m:
    If the new --allow-packing-chars option is set, then allow characters
    to be packed as sub-word-sized arguments.

    Record the value of the --allow-packing-mini-types in the parameters
    as well, without using it as yet. (That is for a future change.)

    Fix the test for what counts as suboptimal packing. Given an argument
    list such as <sub-word-sized args, word-sized arg, sub-word-sized args>
    where the two lots of sub-word-sized args could fit into a single word,
    the old code did NOT emit a "this is suboptimal" message for it. This
    was because it did not consider a reduction from 2n words to 2n-1 words
    to be significant, as boehm_gc would always round up the number of words
    to (at least) the next multiple of 2. The problem was that the code
    used to apply this test ONLY to the number of words occupied by
    sub-word-sized args. In this case, better packing would make that number
    go from 2 to 1, so it did emit the message, even though the *total*
    number of words in the memory cell would go from 3 to 2.

    We could fix this by applying the round-up-to-even the test to the total
    number of words, but it is simpler to eliminate round-up-to-even entirely.
    This is desirable anyway, since we *should* prefer compresssing e.g.
    a 4 word cell down to 3 if possible, since this would reduce traffic
    to and from (some levels of) cache, even if it would not reduce
    the size of the memory allocation.

    Fix some too-long lines.

compiler/prog_data.m:
    Add fill_char21 as a new kind of fill for sub-word-sized arguments.
    (The 21 is a reminder of the 21 bit size of Unicode chars.)

runtime/mercury_type_info.h:
    Document that fill_char21 arguments are treated the same way as enum args
    in the RTTI.

compiler/hlds_out_module.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_util.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/unify_gen_util.m:
    Conform to the changes above.
2018-08-30 23:26:56 +10:00
Zoltan Somogyi
86f563a94d Pack subword-sized arguments next to a remote sectag.
compiler/du_type_layout.m:
    If the --allow-packing-remote-sectag option is set, then try to pack
    an initial subsequence of subword-sized arguments next to remote sectags.

    To allow the polymorphism transformation to put the type_infos and/or
    typeclass_infos it adds to a function symbol's argument list at the
    *front* of that argument list, pack arguments next to remote sectags
    only in function symbols that won't have any such extra arguments
    added to them.

    Do not write all new code for the new optimization; instead, generalize
    the code that already does a very similar job for packing args next to
    local sectags.

    Delete the code we used to have that picked the packed representation
    over the base unpacked representation only if it reduced the
    "rounded-to-even" number of words. A case could be made for its usefulness,
    but in the presence of the new optimization the extra code complexity
    it requires is not worth it (in my opinion).

    Extend the code that informs users about possible argument order
    rearrangements that yield better packing to take packing next to sectags
    into account.

compiler/hlds_data.m:
    Provide a representation for cons_tags that use the new optimization.
    Instead of adding a new cons_tag, we do this by replacing several old
    cons_tags that all represent pointers to memory cells with a single
    cons_tag named remote_args_tag with an argument that selects among
    the old cons_tags being replaced, and adding a new alternative inside
    this new type. The new alternative is remote_args_shared with a
    remote_sectag whose size is rsectag_subword(...).

    Instead of representing the value of the "data" field in classes
    on the Java and C# backends as a strange kind of secondary tag
    that is added to a memory cell by a class constructor instead of
    having to be explicitly added to the front of the argument vector
    by the code of a unification, represent it more directly as separate
    kind of remote_args_tag. Continuing to treat it as a sectag would have
    been very confusing to readers of the code of ml_unify_gen_*.m in the
    presence of the new optimization.

    Replacing several cons_tags that were usually treated similarly with
    one cons_tag simplifies many switches. Instead of an switch with that
    branches to the same switch arm for single_functor_tag, unshared_tag
    and shared_remote_tag, and then switches on these three tags again
    to get e.g. the primary tag of each, the new code of the switch arm
    is executed for just cons_tag value (remote_args_tag), and switches
    on the various kinds of remote args tags only when it needs to.
    In is also more natural to pass around the argument of remote_args_tag
    than to pass around a variable of type cons_tag that can be bound to only
    single_functor_tag, unshared_tag or shared_remote_tag.

    Add an XXX about possible further steps along these lines, such as
    making a new cons_tag named something like "user_const_tag" represent
    all user-visible constants.

compiler/unify_gen_construct.m:
compiler/unify_gen_deconstruct.m:
compiler/unify_gen_test.m:
compiler/unify_gen_util.m:
compiler/ml_unify_gen_construct.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_test.m:
compiler/ml_unify_gen_util.m:
    Implement X = f(Yi) unifications where f uses the new representation,
    i.e. some of its arguments are stored next to a remote sectag.

    Some of the Yi are stored in a tagword (a word that also contains a tag,
    in this case the remote secondary tag), while some are stored in other
    words in a memory cell. This means that such unifications have similarities
    both to unifications involving arguments being packed next to local
    sectags, and to unifications involving ordinary arguments in memory cells.
    Therefore wherever possible, their implemenation uses suitably generalized
    versions of existing code that did those two jobs for two separate kinds of
    cons_tags.

    Making such generalizations possible in some cases required shifting the
    boundary between predicates, moving work from a caller to a callee
    or vice versa.

    In unify_gen_deconstruct.m, stop using uni_vals to represent *either* a var
    *or* a word in a memory cell. While this enabled us to factor out some
    common code, the predicate boundaries it lead to are unsuitable for the
    generalizations we now need.

    Consistently use unsigned ints to represent both the whole and the parts
    of words containing packed arguments (and maybe sectags), except when
    comparing ptag constants with the result of applying the "tag" unop
    to a word, (since that unop returns an int, at least for now).

    In a few cases, avoid the recomputation of some information that we
    already know. The motivation is not efficiency, since the recomputation
    we avoid is usually cheap, but the simplification of the code's correctness
    argument.

    Use more consistent terminology in things such as variable names.

    Note the possibility of further future improvements in several places.

compiler/ml_foreign_proc_gen.m:
    Delete a long unused predicate.

compiler/mlds.m:
    Add an XXX documenting a possible improvement.

compiler/rtti.m:
    Update the compiler's internal representation of RTTI data structures
    to make them able to describe secondary tags that are smaller than
    a full word.

compiler/rtti_out.m:
    Conform to the changes above, and delete a long-unused predicate.

compiler/type_ctor_info.m:
    Use the RTTI's du_hl_rep to represent cons_tags that distinguish
    between function symbols using a field in a class.

compiler/ml_type_gen.m:
    Provide a specialized form of a function for code in ml_unify_gen_*.m.
    Conform to the changes above.

compiler/add_special_pred.m:
compiler/bytecode_gen.m:
compiler/export.m:
compiler/hlds_code_util.m:
compiler/lco.m:
compiler/ml_closure_gen.m:
compiler/ml_switch_gen.m:
compiler/ml_tag_switch.m:
compiler/rtti_to_mlds.m:
compiler/switch_util.m:
compiler/tag_switch.m:
    Conform to the changes above.

runtime/mercury_type_info.h:
    Update the runtime's representation of RTTI data structures to make them
    able to describe remote secondary tags that are smaller than a full word.

runtime/mercury_deconstruct.[ch]:
runtime/mercury_deconstruct.h:
runtime/mercury_deconstruct_macros.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_ml_arg_body.h:
runtime/mercury_ml_deconstruct_body.h:
runtime/mercury_ml_functor_body.h:
    These modules collectively implement the predicates in deconstruct.m
    in the library, and provide access to its functionality to other C code,
    e.g. in the debugger. Update these to be able to handle terms with the
    new data representation optimization.

    This update requires a significant change in the distribution of work
    between these files for the predicates deconstruct.deconstruct and
    deconstruct.limited_deconstruct. We used to have mercury_ml_expand_body.h
    fill in the fields of their expand_info structures (whose types are
    defined in mercury_deconstruct.h) with pointers to three vectors:
    (a) a vector of arg_locns with one element per argument, with a NULL
    pointer being equivalent to a vector with a given element in every slot;
    (b) a vector of type_infos with one element per argument, constructed
    dynamically (and later freed) if necessary; and (c) a vector of argument
    words. Once upon a time, before double-word and sub-word arguments,
    vector (c) also had one word per argument, but that hasn't been true
    for a while; we added vector (a) help the consumers of the expand_info
    decode the difference. The consumers of this info  always used these
    vectors to build up a Mercury term containing a list of univs,
    with one univ for each argument.

    This structure could be stretched to handle function symbols that store
    *all* their arguments in a tagword next to a local sectag, but I found
    that stretching it to cover function symbols that have *some* of their
    arguments packed next to a remote sectag and *some other* of their
    arguments in a memory cell as usual would have required a well-nigh
    incomprehensibly complex, and therefore almost undebuggable, interface
    between mercury_ml_expand_body.h and the other files above. This diff
    therefore changes the interface to have mercury_ml_expand_body.h
    build the list of univs directly. This make its code relatively simple
    and self-contained, and it should be somewhat faster then the old code
    as well, since it never needs to allocate, fill in and then free
    vectors of type_infos (each such typeinfo now gets put into a univ
    as soon as it is constructed). The downside is that if we ever wanted
    to get all the arguments at once for a purpose other than constructing
    a list of univs from them, it would nevertheless require constructing
    that list of univs anyway as an intermediate data structure. I don't see
    this downside is significant, because (a) I don't think such a use case
    is very likely, and (b) even if one arises, debuggable but a bit slow
    is probably preferable to faster but very hard to debug.

    Reduce the level of indentation of some of these files to make the code
    easier to edit. Do this by

    - not adding an indent level from switch statements to their cases; and
    - not adding an indent level when a case in a switch has a local block.

    Move the break or return ending a case inside that case's block,
    if it has one.

runtime/mercury_deep_copy_body.h:
runtime/mercury_table_type_body.h:
    Update these to enable the copying or tabling of terms whose
    representations uses the new optimization.

    Use the techniques listed above to reduce the level of indentation
    make the code easier to edit.

runtime/mercury_tabling.c:
runtime/mercury_term_size.c:
    Conform to the changes above.

runtime/mercury_unify_compare_body.h:
    Make this code compile after the changes above. It does need to work
    correctly, since we only ever used this code to compare the speed
    of unify-by-rtti with the speed of unify-by-compiler-generated-code,
    and in real life, we always use the latter. (It hasn't been updated
    to work right with previous arg packing changes either.)

library/construct.m:
    Update to enable the code to construct terms whose representations
    uses the new optimization.

    Add some sanity checks.

library/private_builtin.m:
runtime/mercury_dotnet.cs.in:
java/runtime/Sectag_Locn.java:
    Update the list of possible sectag kinds.

library/store.m:
    Conform to the changes above.

trace/mercury_trace_vars.c:
    Conform to the changes above.

tests/hard_coded/deconstruct_arg.{m,exp,exp2}:
    Extend this test to test the deconstruction of terms whose
    representations uses the new optimization.

    Modify some of the existing terms being tested to make them more diverse,
    in order to make the output easier to navigate.

tests/hard_coded/construct_packed.{m,exp}:
    A new test case to test the construction of terms whose
    representations uses the new optimization.

tests/debugger/browse_packed.{m,exp}:
    A new test case to test access to the fields of terms whose
    representations uses the new optimization.

tests/tabling/test_packed.{m,exp}:
    A new test case to test the tabling of terms whose
    representations uses the new optimization.

tests/debugger/Mmakefile:
tests/hard_coded/Mmakefile:
tests/tabling/Mmakefile:
    Enable the new test cases.
2018-08-30 05:14:38 +10:00
Peter Wang
72f174b4e2 Don't print value of errno in MR_fatal_error.
The majority of calls to MR_fatal_error do not follow an operation that
sets errno, so printing out an error message unrelated to the reason for
the fatal error will lead to confusion. It can also cause test failures
if errno happens to be set to non-zero some time prior to an expected
call to MR_fatal_error. Fixes bug #464.

runtime/mercury_misc.c:
    Don't print value of errno in MR_fatal_error.

runtime/mercury_context.c:
runtime/mercury_thread.c:
    Pass strerror strings to MR_fatal_error where appropriate.

runtime/mercury_memory_zones.c:
runtime/mercury_memory_zones.h:
    Pass strerror strings to MR_fatal_error following failures of
    MR_protect_pages. Document that this assumes MR_protect_pages sets
    errno on error.

    Skip unnecessary call to sprintf before MR_fatal_error.

runtime/mercury_deep_profiling.c:
    Skip unnecessary call to sprintf before MR_fatal_error.

    Reduce size of some buffers.

runtime/mercury_overflow.c:
runtime/mercury_stack_trace.c:
    Pass a fixed format string to MR_fatal_error just in case
    the message string may contain percentage signs.

runtime/mercury_tabling.c:
    Skip unnecessary call to sprintf before MR_fatal_error.

deep_profiler/timeout.m:
library/thread.m:
mdbcomp/shared_utilities.m:
    Pass strerror strings to MR_fatal_error where appropriate.

trace/mercury_trace.c:
    Skip unnecessary call to sprintf before MR_fatal_error.

trace/mercury_trace_external.c:
    Pass a fixed format string to MR_fatal_error just in case.
2018-08-19 12:19:19 +10:00
Peter Wang
58345256f8 Fix compilation with musl.
musl warns if <sys/signal.h> is included, which now breaks the build due
to --halt-at-warn-if-possible. The comments state that the inclusion was
to work around a problem on FreeBSD, but it is no longer necessary for
FreeBSD 11.

runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
    Don't include <sys/signal.h>
2018-08-11 11:50:15 +10:00
Peter Wang
6e407d0fca Change types in memory attribution profile structures.
runtime/mercury_heap_profile.c:
    Use MR_Unsigned for fields that count the number of cells or words
    allocated. Since they do not represent object sizes, the use of
    size_t was not appropriate. More importantly, to print size_t values
    we should use the 'z' length modifier to fprintf, but that may not
    be supported on all platforms we need to work on.

    Print unsigned values with 'u' format specifier.

    For the MR_vsc_size field, which does represent an object size, cast
    the value to MR_Unsigned and print it with the 'u' format specifier.
2018-08-10 14:47:20 +10:00
Peter Wang
2ed8154b9f Fix compilation of memprof grades on 32-bit.
runtime/mercury_heap_profile.c:
    Use MR_INTEGER_LENGTH_MODIFIER to get the right format specifier
    when printing size_t fields.
2018-08-09 22:57:00 +10:00
Zoltan Somogyi
2bfe4d402c Compile everything with --halt-at-warn-if-possible. 2018-08-02 14:45:42 +10:00
Julien Fischer
92802b9ad7 Fix a typo in MR_escape_string_quote.
runtime/mercury_string.c:
    s/b/v/ in a spot.

tests/hard_coded/deconstruct_arg.exp:
tests/hard_coded/deconstruct_arg.exp2:
    Conform to the above change.
2018-07-29 12:42:30 +00:00
Peter Wang
e5e37562a5 Fix variable name. 2018-07-26 19:12:59 +10:00
Zoltan Somogyi
9b9493e293 Use separate variables for separate concepts. 2018-07-26 15:15:21 +10:00
Peter Wang
e272470974 Add comment about use of select().
runtime/mercury_context.c:
    Add comment in MR_check_pending_contexts.
2018-07-25 15:02:14 +10:00
Peter Wang
2be2e7468c Do not use _snprintf functions directly in place of snprintf functions.
The Windows _snprintf family of functions do not guarantee null
termination when the output is truncated so cannot be used as direct
replacements for the snprintf functions. Also, the _snprintf functions
have different return values from the C99 snprintf functions when output
is truncated (like some older snprintf implementations).

Furthermore, on Windows snprintf/vsnprintf may be synonyms for
_snprintf/_vsnprintf so cannot be relied upon to terminate their outputs
either, even if the functions exist.

runtime/mercury_string.c:
runtime/mercury_string.h:
    Define MR_snprintf and MR_vsnprintf as macro synonyms for
    snprintf/vsnprintf ONLY if _snprintf/_vsnprintf do not exist.

    Otherwise, implement MR_snprintf and MR_vsnprintf functions
    that behave like the C99 functions, in terms of _vsnprintf.

    Require that either snprintf/vsnprintf or _snprintf/_vsnprintf
    are available. This should be true on all systems still in use.

runtime/mercury_debug.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_runtime_util.c:
runtime/mercury_stack_layout.c:
runtime/mercury_stack_trace.c:
runtime/mercury_stacks.c:
runtime/mercury_tabling.c:
runtime/mercury_threadscope.c:
runtime/mercury_trace_base.c:
runtime/mercury_wrapper.c:
trace/mercury_trace_completion.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_spy.c:
trace/mercury_trace_vars.c:
bytecode/mb_disasm.c:
    Use MR_snprintf instead of snprintf/_snprintf
    and MR_vsnprintf instead of vsnprintf/_vsnprintf.

    Drop code paths using sprintf as a fallback.
2018-07-23 10:26:29 +10:00
Peter Wang
18777b51b1 Fix problems parsing environment options.
runtime/mercury_wrapper.c:
    Fix wrong size argument in calls to snprintf.

    Fix use-after-free if there is an error while parsing environment
    options.
2018-07-23 10:22:17 +10:00
Zoltan Somogyi
4e218920d9 Fix a gcc warning. 2018-07-19 02:17:14 +02:00
Julien Fischer
4455d3601e Escape characters in strings returned by deconstruct.functor/4.
runtime/mercury_string.[ch]:
    Add a function that returns a copy of a string inside double
    quotes and with escapes for any control characters inserted.

    Add macro that tests if a character is a control character.

runtime/mercury_ml_expand_body.h:
    Use the above function to escape characters in the representation
    of string functors.

library/rtti_implementation.m:
    Do the same for the C# and Java backends.

library/term_io.m:
    Update a comment.

NEWS:
    Announce the above change to deconstruct.functor/4, as well
    the earlier change to its handling of characters.

tests/hard_coded/deconstruct_arg.m:
tests/hard_coded/deconstruct_arg.exp:
    Extend this test case to cover strings.
2018-07-11 01:42:33 +10:00
Zoltan Somogyi
8e45a89895 Use spaces, not tabs, in the Java and C# runtimes.
Add modelines to keep it that way.

Fix formatting, and english in comments.
2018-07-10 13:52:11 +02:00
Julien Fischer
d8fb7d15a8 Update C# RTTI code.
runtime/mercury_dotnet.cs.in:
    Update the other constructor for the DuPtagLayout class.
2018-07-10 17:03:56 +10:00
Zoltan Somogyi
d23cbe32bd Update the C# and Java runtimes ...
... after my recent changes.

java/runtime/DuFunctorDesc.java:
java/runtime/DuPtagLayout.java:
    Add the new field to the Java equivalents of the two C structures
    affected by the recent change to support packing arguments next to
    local secondary tags.

runtime/mercury_dotnet.cs.in:
    Add the new field to the C# equivalent of one of two C structures
    affected by the recent change to support packing arguments next to
    local secondary tags; the other was done earlier.

runtime/mercury_type_info.h:
    Include java/runtime/* among the files that may need to be updated
    after a change in this file.
2018-07-10 03:07:17 +02:00
Zoltan Somogyi
624aaa01f1 Pack subword-sized arguments next to a local sectag.
compiler/du_type_layout.m:
    If a new option is set, then try to represent function symbols with
    only subword-sized arguments by packing those arguments into the same word
    as the primary tag and (if it is needed) a secondary tag.

    If there are too many such function symbols for the available number of
    bits, pick the ones that need the least number of bits, in order to
    allow us to use this representation for as many such function symbols
    as possible.

    This diff implements this packing only for types that have more than one
    argument, because implementing it for types that have only one argument
    has two extra complications. One is the need for another new cons_id
    (see below), which would make this diff bigger and harder to review.
    The other is the need to consider interactions with the direct_arg
    optimization.

    Don't invoke the code for deciding the representation of arguments
    if either (a) the function symbol has no arguments, or (b) its cons_id
    alone dictates how we will treat its argument (in such cases, there is
    always exactly one).

    Fix a bug in computing the number of bits needed to distinguish N things.

    Store the value of the "experiment" option in the params for now,
    since it has helped track down bugs in this change, and may do the same
    for my next change. It costs next to nothing.

compiler/options.m:
    Add an option that controls whether we allow du_type_layout to pack
    arguments next to local secondary tags. The default value is "no",
    since "yes" may break binary compatibility.

    Add an option that controls whether we allow du_type_layout to pack
    arguments next to remote secondary tags. This option is not yet used.

compiler/hlds_data.m:
    Add a new cons_id, shared_local_tag_with_args, to represent function
    symbols in which the arguments are packed next to a local secondary tag.
    Rename the existing shared_local_tag cons_id as shared_local_tag_no_args,
    to clarify the distinction.

    Redesign the representation of secondary tags a bit, to meet the
    requirements I discovered while implementing the new data representation.

compiler/prog_data.m:
    Document the now-expanded uses of the arg_pos_width type.

compiler/ml_unify_gen.m:
compiler/unify_gen.m:
    Implement unifications involving the new cons_id.

compiler/var_locn.m:
    Implement deconstruction unifications involving both right-to-left data
    flow and the new cons_id for the LLDS backend requires var_locn.m
    to implement a new kind of assignment to a variable: one that updates
    its old value. Add a predicate for this. (Previously, deconstructions
    with right-to-left flow could update the old value of a word in a
    memory cell, whose state var_locn.m does *not* track.)

compiler/code_loc_dep.m:
    Provide the interface between unify_gen. and var_locn.m.

compiler/code_info.m:
    Store the number of primary tag bits in the code_info, to save it looking
    up in the globals structure, since with its new code, unify_gen.m needs it
    more often now.

compiler/hlds_out_module.m:
doc/user_guide.texi:
    Implement the capability of restricting the dump of the type table
    to only the types defined in the module being compiled. Without this,
    the type table is cluttered with information about types in other
    modules, including the automatically-included builtin modules.

compiler/handle_options.m:
    Add a new value of the -D option. The new value, du, asks for the
    dumping out of the representations of only the locally defined types.

compiler/ml_gen_info.m:
    Store the number of primary tag bits as a uint8, not as int.

compiler/ml_tag_switch.m:
compiler/switch_util.m:
compiler/tag_switch.m:
    Update the code that generates switches on du types to handle
    local secondary tags that must be masked off before use.

compiler/rtti.m:
    Update the compiler's representation of RTTI information to account for
    the new data representation.

compiler/type_ctor_info.m:
    Construct the updated RTTI representation.

compiler/bytecode_gen.m:
compiler/export.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/modecheck_goal.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
    Conform for the changes above.

runtime/mercury_type_info.h:
    Extend the representation of du functors in the RTTI to account for
    the new data representation scheme. The extensions add only to the
    *ends* of structures, or to lists of enum values, with the extensions
    only being used if the representation is actually used, which should
    allow the updated runtime to also work with .c files that were compiled
    with a compiler that does *not* have this diff. For the same reason,
    make the old enum value MR_SECTAG_LOCAL a synonym for the new
    MR_SECTAG_LOCAL_REST_OF_WORD, which expresses a distinction that
    did not previously exist.

    Delete a reference to a file that no longer exists.

runtime/mercury_dotnet.cs.in:
library/rtti_implementation.m:
    Update the C# and Mercury mirrors of the types updated in
    mercury_type_info.h.

runtime/mercury_deconstruct.c:
runtime/mercury_deconstruct_macros.h:
runtime/mercury_ml_expand_body.h:
    Implement the deconstruction of terms using the new data representation.

runtime/mercury_deep_copy_body.h:
    Implement the copying of terms using the new data representation.

runtime/mercury_table_type_body.h:
    Implement the tabling of terms using the new data representation.

runtime/mercury_term_size.c:
    Implement computing the size of terms using the new data representation.

runtime/mercury_unify_compare_body.h:
    Implement RTTI-based unifications of terms using the new data
    representation. (Or at least make a first attempt at this implementation.
    We never use RTTI-based unification, so this code has not been tested,
    but it is not clear that it *needs* to be tested.)

library/construct.m:
    Implement the construction of terms using the new data representation.

library/private_builtin.m:
    List MR_SECTAG_LOCAL_REST_OF_WORD as a synonym of MR_SECTAG_LOCAL for Java,
    since rtti_to_mlds.m will now emit the new version.

    Note that the new data representation is not applicable to Java (or C#),
    so it should never see the other kind of sectag (MR_SECTAG_LOCAL_BITS).

tests/hard_coded/sectag_bits.{m,exp}:
tests/hard_coded/sectag_bits_test_data:
    A new test case to test the reading in and writing out (and therefore
    the construction and deconstruction) of terms containing arguments
    packed with a local sectag.

tests/hard_coded/Mmakefile:
    Enable the new test case.
2018-07-08 17:54:11 +02:00
Julien Fischer
a00e86be35 Escape all control characters in io.write, deconstruct.functor etc.
The above predicates currently escape all of the C0 control characters (+
Delete).  This change modifies them to escape all of the characters in the
Unicode category `Other,control' using backslash escapes when they exist and
octal escapes otherwise.

library/term_io.m:
    Do not treat C1 control characters as Mercury source characters.

    Re-order the list of Mercury punctuation characters by codepoint
    order; it is difficult to check for completion otherwise.

    Put a list of special characters escapes in order.

runtime/mercury_ml_expand_body.h:
library/rtti_implementation.m:
   Update the implementations of functor/4 to escape all control
   characters when returning the functor of a character.

library/deconstruct.m:
    Specify that functor/4 should escape all control characters in
    the value returned for characters and strings.  (XXX TODO: it
    currently doesn't implement the new behaviour for strings; I'll
    add that separately.)

library/io.m:
library/stream.string_writer.m:
    Similar to the above but for io.write etc.

tests/hard_coded/write.{m,exp}:
tests/hard_coded/deconstruct_arg.{m,exp,exp2}:
   Extend these tests to cover the block of C1 control characters
   and the boundaries around it.
2018-06-19 17:08:20 +10:00
Julien Fischer
a0be50798a Update handling --force-readline.
runtime/mercury_wrapper.c:
    As above.
2018-06-18 23:34:13 -04:00