Rename mmc and mgnuc options that set this grade component to --c-debug-grade.
Let the options named --c-debug of both mmc and mgnuc enable C level debugging
of only the module being compiled.
runtime/mercury_grade.h:
Rename the .ll_debug grade component to .c_debug. Also rename the C macro
that controls the presence or absence of this grade component
from MR_LL_DEBUG to MR_C_DEBUG_GRADE.
runtime/mercury_conf_param.h:
runtime/mercury_debug.c:
runtime/mercury_debug.h:
runtime/mercury_engine.c:
runtime/mercury_label.c:
runtime/mercury_memory_zones.c:
runtime/mercury_memory_zones.h:
runtime/mercury_overflow.c:
runtime/mercury_std.h:
runtime/mercury_wrapper.c:
Rename the MR_LOWLEVEL_DEBUG macro to MR_DEBUG_THE_RUNTIME.
Previously, the name of this macro wrongly implied that it had
something to do with the old .ll_debug grade component, even though
- the MR_LOWLEVEL_DEBUG macro was designed to debug LLDS grades,
since only these existed when it was created, while
- the .ll_debug grade component (now .c_debug) is useful only for
MLDS grades targeting C.
compiler/options.m:
Rename the old confusingly named low_level_debug option to c_debug_grade.
Move it to the list of grade options, and fix its documentation, which
was completely wrong:
- code in compile_target_code.m treated it as being a synonym of
the .ll_debug (now .c_debug) grade component, while
- its (commented out) documentation here in options.m said it called for
the enabling of what is now MR_DEBUG_THE_RUNTIME.
compiler/compile_target_code.m:
Conform to the rename just above.
Define MR_C_DEBUG_GRADE instead of MR_LL_DEBUG if c_debug_grade is enabled.
Pass -g to the C compiler if either c_debug_grade or target_debug
is enabled.
Add an XXX about a missing safety check for an obsolete experimental
feature.
compiler/compute_grade.m:
When given a grade with a .c_debug grade component, set only the
c_debug_grade option; don't set the target_debug option, which is NOT
a grade option. The change to compile_target_code.m above handles the
only situation in which this implication was formerly required.
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Look for and process the .c_debug grade component instead of .ll_debug.
Use a sh variable named c_debug_grade to record its absence/presence.
Look for and process the --c-debug-grade grade-component option,
setting the same sh variable, c_debug_grade. (All grade components
can be set piecemeal using sh options to the scripts using these
subroutines.) This replaces the old, confusingly named option
--low-level-debug.
scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
Consistently use the sh variable c_debug to record the presence of
the (non-grade) --c-debug option to mgnuc, and the sh variable
c_debug_grade to record the presence of the .c_debug grade component.
Stop looking for and handling the --low-level-debug option, which
mgnuc used to document, even though this duplicated the same documentation
in init_grade_options.sh-subr, which mgnuc includes. The difference was
that init_grade_options.sh-subr meant it to represent the old .ll_debug
MLDS grade component, while mgnuc treated it as specifying what is now
MR_DEBUG_THE_RUNTIME for LLDS grades. It didn't help that two sh variables
with quite different semantics had names that differed only in an
underscore: LLDEBUG_OPTS vs LL_DEBUG_OPTS.
scripts/Mmakefile:
Add a missing dependency to force the rebuild of mgnuc after each update
of its sh subroutine mgnuc_file_ops.sh-subr.
doc/user_guide.texi:
Document the --c-debug-grade option of mmc. This option was not publicly
documented under its original misleading name (--low-level-debug), but
its documentation is now possible without contorted dancing around the
name.
Clarify the documentation of mgnuc's --c-debug option.
README.sanitizers:
configure.ac:
Conform to the rename of the grade component.
grade_lib/grade_spec.m:
grade_lib/grade_string.m:
grade_lib/grade_structure.m:
grade_lib/try_all_grade_structs.m:
Conform to the rename of the grade component .ll_debug to .c_debug.
Don't allow the .c_debug grade component in LLDS grades.
In grade_string.m, add some obvious implications of some grade components.
grade_lib/choose_grade.m:
grade_lib/grade_lib.m:
grade_lib/test_grades.m:
grade_lib/var_value_names.m:
Fix white space.
scripts/ml.in:
tools/lmc.in:
tools/test_mercury:
Conform to the change in compile_target_code.m to the naming of
Boehm gc library variants.
All the strings returned by MR_win32_error_name include a common prefix
"ERROR_". Since there are many (1749) such strings, we can reduce the
size of the data by about 10 KB by returning only the part following the
prefix.
tools/generate_windows_error_name:
runtime/mercury_windows_error_name.c:
Make MR_win32_error_name return strings without the "ERROR_" prefix.
library/io.m:
Update caller system_error_win32_error_name to add the "ERROR_"
prefix.
Fix compilation with older versions of MinGW(-w64) and any other
compilers which don't have as many ERROR_ constants defined.
tools/generate_windows_error_name:
Reduce the list of ERROR_ constants.
runtime/mercury_windows_error_name.c:
Regenerate.
Implement the error handling proposals from February 2022 on the
mercury-users list, and August 2022 on the mercury-reviews list.
We add io.system_error to the public interface of io.m
and document what its foreign representation is for each backend.
We allow io.error to optionally contain an io.system_error value,
and provide predicates to retrieve the io.system_error from an io.error.
The user may then inspect the system error via foreign code.
We also provide a predicate that takes an io.error and returns a name
for the system error it contains (if any). This makes it relatively easy
for Mercury programs to check for specific error conditions.
By returning platform-specific (actually, implementation-dependent)
error names, we are pushing the responsibility of mapping strings to
error conditions onto the application programmer. On the other hand, it
is not practical for us to map all possible system-specific error codes
to some common set of values. We could do it for a small set of common
error codes/exceptions, perhaps.
The standard library will construct io.error values containing
io.system_errors. However, we do not yet provide a facility for user
code to do the same.
library/io.m:
Move io.system_error to the public interface.
Change the internal representation of io.error to support containing
a io.system_error. An io.system_error may originate from an errno
value or a Windows system error code; the constructor distinguishes
those cases.
Add predicates to retrieve a system_error from io.error.
Add predicate to return the name of the system error in an io.error.
Replace make_err_msg with make_io_error_from_system_error.
Replace make_maybe_win32_err_msg with
make_io_error_from_maybe_win32_error.
Delete ML_make_err_msg and ML_make_win32_err_msg macros.
browser/listing.m:
library/bitmap.m:
library/dir.m:
library/io.call_system.m:
library/io.environment.m:
library/io.file.m:
library/io.text_read.m:
mdbcomp/program_representation.m:
Conform to changes.
Leave comments for followup work.
tools/generate_errno_name:
tools/generate_windows_error_name:
Add scripts to generate mercury_errno_name.c and
mercury_windows_error_name.c.
runtime/Mmakefile:
runtime/mercury_errno_name.c:
runtime/mercury_errno_name.h:
runtime/mercury_windows_error_name.c:
runtime/mercury_windows_error_name.h:
Add MR_errno_name() and MR_win32_error_name() functions,
used by io.m to convert error codes to string names.
tests/hard_coded/null_char.exp:
Update expected output.
trace/mercury_trace_cmd_developer.c:
trace/mercury_trace_tables.[ch]:
Add two options to the mdb command "ambiguity".
Print ambiguities between function and predicate forms of the same
operation, such as list.length, only if the new option -b, or
--both-pred-and-func, is given.
Print ambiguities involving procedures that were created by type
specialization only if the new option -s, or --typespec is given.
(The -t option name was already taken.)
These changes remove from the ambiguity command's output
(some of) the parts that are not useful when one wants to eliminate
ambiguities by renaming.
Clarify a heading.
doc/user_guide.texi:
Document the above changes.
runtime/mercury_proc_id.h:
Fix a field name that has become misleading.
MR_UserProcId_Structs have a field named MR_user_arity.
In this name, the "MR_user_" part is a prefix shared by the other
fields in that structure, to indicate that they are part of the id
of a user-defined procedure, as opposed to a compiler-created
unify, compare or index procedure. However, the arity it contains
is what the compiler now calls a pred_form_arity: it does not count
type_info and typeclass_info arguments added by polymorphism, but
it *does* count function return values for functions. This is now
misleading, because in the compiler, a user_arity does *not* count
function return values for functions.
Replace this field name with MR_user_pred_form_arity, which tells
readers that this arity is a pred_form_arity. The presence of the
"user" part of the name may still cause some confusion, but at least
that confusion should motivate readers to look up the field name,
whose comment should clarify things.
mdbcomp/rtti_access.m:
runtime/mercury_debug.c:
runtime/mercury_deep_profiling.c:
runtime/mercury_ho_call.c:
runtime/mercury_layout_util.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.c:
trace/mercury_trace.c:
trace/mercury_trace_external.c:
trace/mercury_trace_util.c:
Conform to the change in mercury_proc_id.h.
tests/debugger/ambiguity.{m,inp,exp}:
tests/debugger/ambiguity_helper.m:
Expand this test case to test the new functionality.
The type specialized predicates are in a new helper module,
because this is the simplest way to avoid dead procedure elimination
deleting any of the predicates whose names we want to test for ambiguities.
There is an issue on Linux/aarch64 with older versions of gcc where a
commit performed on a thread using the gcc __builtin_longjmp function
causes an assertion failure in pthread_create() if the Mercury runtime
is dynamically linked:
pthread_create.c:430: start_thread: Assertion `freesize < pd->stackblock_size' failed.
or a crash if the Mercury runtime is statically linked:
*** Mercury runtime: caught segmentation violation ***
cause: address not mapped to object
The gcc versions tested are:
BAD - gcc version 6.3.0 20170516 (Debian 6.3.0-18) from Debian 9
BAD - gcc version 8.3.0 (Debian 8.3.0-2) from Debian 10
OK - gcc version 10.2.1 20210110 (Debian 10.2.1-6) from Debian 11
on Debian with glibc.
runtime/mercury.h:
Define MR_USE_GCC_BUILTIN_SETJMP_LONGJMP if we decide to use gcc's
__builtin_setjmp and __builtin_longjmp functions instead of the
standard functions.
Use standard setjmp/longjmp on aarch64 if gcc version is < 10.
Update the comment for MR_builtin_jmp_buf to refer to the GCC manual
instead of the GCC source code. Use an array of 'intptr_t's instead
of 'void *'s, to match the manual.
tests/hard_coded/Mmakefile
tests/hard_coded/thread_commit.m:
tests/hard_coded/thread_commit.exp:
tests/hard_coded/thread_commit.exp2:
Add test case.
We have two main notions of trace levels. The first is the global trace level,
which is set by compiler options, and the second is the effective trace level
for a given procedure. The two are different not just in that the effective
trace level for a procedure may differ from the global trace level, but also
in that there exist effective trace levels that cannot be specified using
compiler options.
compiler/trace_params.m:
Add the new type eff_trace_level for representing effective trace levels.
(Old code has long used "Eff" as an abbreviation for "effective".)
Use it where relevant.
Delete functions that (a) first compute the effective trace level
for a procedure, and (b) then test that effective trace level,
and replace each of them with a function that does only (b).
There was already a function that did only (a); rename it to avoid
an ambiguity.
compiler/code_info.m:
Store the effective trace level of the procedure being translated
in the code_info, to save it from having to be recomputed many times.
compiler/code_loc_dep.m:
Get the effective trace level for the procedure being compiled
from code_info.
compiler/hlds_out_pred.m:
Write out each procedure's effective trace level.
compiler/llds.m:
Include the effective trace level in generated c_procs, for use by
continuation_info.m.
compiler/continuation_info.m:
Rename a predicate to avoid a name clash.
Conform to the changes above.
compiler/handle_options.m:
Note a non-problem.
compiler/globals.m:
compiler/layout.m:
compiler/layout_out.m:
compiler/liveness.m:
compiler/optimize.m:
compiler/proc_gen.m:
compiler/simplify_goal_conj.m:
compiler/simplify_goal_scope.m:
compiler/simplify_info.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/store_alloc.m:
compiler/trace_gen.m:
compiler/transform_llds.m:
Conform to the changes above.
compiler/mercury_compile_front_end.m:
Fix a misleading predicate name.
compiler/hlds_out_module.m:
Simplify some code.
runtime/mercury_goto.h:
Fix misplaced/wrong casts and stray backslashes in macros that are usually
only used when debugging the debugger.
On some operating systems, e.g. Linux, it is possible to enter main()
with argv[0] == NULL if the parent process calls execve() with
argv[0] == NULL, or equivalently, passing NULL for the argv parameter.
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
Do not assume argc > 0 and argv[0] != NULL in MR_process_args.
If argv[0] is NULL then set MR_progname to the empty string
so users of MR_progname can assume it points to a valid string.
Add a new global variable MR_progname_is_known to indicate if
argv[0] was NULL or not.
library/io.m:
Make io.progname return the default program name if argv[0] was
NULL.
util/mkinit.c:
Set MR_progname to a valid string if argv[0] is NULL.
This is not actually necessary, since, in that case, the subsequent
call to parse_options() would immediately exit the program
as no file names will be found in argv.
This reduces the size of the output of tools/bootcheck by 3700+ lines,
or about 25%.
Mmake.common.in:
Don't print the actions implementing namespace cleanliness checks.
To allow the attribution of any violations of the namespace rules,
print the name of the C module before any list of detected
nonallowed symbols.
To avoid mmake printing the actions for creating the .o files
that some of the check_namespace actions later check, rename
the affected object files .pseudo_o files, so that we can specify
a rule for them that is a copy of the rule for .o files, differing
only in not printing the compilation command.
Mark the files involved in check_namespace actions as dependencies
of .SECONDARY, which means that mmake does not automatically delete them
after building them as intermediate files. The reason for this is that
there is no way to tell make to delete intermediate files *silently*,
i.e. without writing out the rm command that deletes them.
To make up for this, tools/bootcheck now cleans up each directory
immediately after "mmake check_namespace" with "mmake clean_check",
which invokes mmake rules that do not print the rm commands.
This change does have the effect that these intermediate files *will*
hang around if the check_namespace target is every invoked manually.
However,
- we just about never run check_namespace in a directory manually, and
- when we do, a simple "mmake clean_check" will do the required cleanup.
scripts/Mmake.rules:
Move the vim tag line to its usual place at the top.
Replace old-school rules such as .m.err with their modern equivalents
(such as %.err: %.m).
scripts/Mmakefile:
Instead of printing the rules that make test_mdbrc, print only a
"making test_mdbrc" message.
runtime/Mmakefile:
Conform to the change of the name of a make variable in Mmake.common.in.
ssdb/Mmakefile:
Fix an old bug that something else in this diff tickled: make the
.depend target of each main module depend on SSDB_FLAGS, *not* just
the phony general "depend" target. This was a bug because tools/bootcheck
- copied across to stage 2 ONLY SSDB_FLAGS.in, and NOT SSDB_FLAGS,
- did NOT explicitly make SSDB_FLAGS from SSDB_FLAGS.in, even though
pretty much invocations of the Mercury compiler in this directory
have "--flags SSDB_FLAGS" as an implicit argument, and then
- built dependencies in the ssdb directory by invoking the top
Mmakefile's dep_ssdb target, which (indirectly) invokes
$(SSDB_LIB_NAME).depend.
Due to all the above, I don't actually know how tools/bootcheck
could ever build stage2/ssdb until now :-(
tools/bootcheck:
Invoke "mmake clean_check" after each "mmake check_namespace".
Change the code that explicitly builds the directory-specific
X_FLAGS file in each directory (which is invoked only when using
mmc --make) to actually build all such files, when previously
it built only a subset.
tests/invalid/Mmakefile:
tests/invalid_nodepend/Mmakefile:
tests/invalid_onlydepend/Mmakefile:
tests/invalid_options_file/Mmakefile:
tests/invalid_purity/Mmakefile:
tests/invalid_submodules/Mmakefile:
tests/stm/Mmakefile:
Fix an unintended consequence of replacing the .m.err rule in
scripts/Mmake.rules with %.err: %.m, which is that the %.err: %.m
rules in these mmakefiles became ineffective, because they appear
in the makefile we construct *after* the rule in scripts/Mmake.rules,
which specify a different action (the rules here return a nonzero
status in the *absence* of failure, which would be ridiculous
for the rule in scripts/Mmake.rules). Apparently, the %.err: %.m rules
overrode the rule in scripts/Mmake.rules while it had the old form,
but do not do so now it has the new form.
The fix is to make replace all the "%.err: %.m" rules in these Mmakefiles
with "$(PROGS:%=%.err): %.err: %.m" rules, which specify that they
override the generic rule for the .err files of the test cases
in each directory.
In invalid_purity/Mmakefile, fix a bug: -nodepend suffixes make sense
in only in the name of a *test*, not the name of a *program*, so
move such a suffix from a program name to a test name. Without this,
the program's .err file would be included in the list of .err files
to which the ".err: .m" rule applies under the wrong name.
In invalid_submodules/Mmakefile, fix the misleading names of some
make variables, and fix a misspelt directory name.
Standardize on "$(PROGS:%=%.err)" notation, replacing earlier instances
of "$(addsuffix .err,$(PROGS))". The reason for this is that when I tried
using "$addsuffix .int_err,$(PROGS))" in tests/invalid/invalid_make_int,
it did not work. (A google search on "gnu make addsuffix" did not yield
any clues as to why. Maybe you can only add suffixes that do not contain
underscores?)
.gitmodules:
boehm_gc:
Update boehm_gc submodule to release-8.0-mercury-20201129.
runtime/mercury_report_stats.c:
runtime/mercury_wrapper.c:
Use total full-collection time API added in Boehm GC v8.0.0.
NEWS:
Announce change.
runtime/mercury_string.h:
As above. Valid code points in the ranges [1D800, 1DFFF] and
[10D800, 10DFFF] were treated like invalid surrogates because the
high bits were masked away.
tests/hard_coded/Mmakefile:
tests/hard_coded/char_not_surrogate.exp:
tests/hard_coded/char_not_surrogate.m:
tests/hard_coded/string_not_surrogate.exp:
tests/hard_coded/string_not_surrogate.m:
Add test cases.
compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/final_grade_options.sh-subr:
Generate an error message for grades that mix parallel execution
and minimal model tabling.
compiler/compute_grade.m:
Improve two comments.
runtime/mercury_bitmap.c:
Delete the function MR_hex_char_to_int(). It has been unused since 2011.
(Actually, it was unused before then since its only caller was also
unused.)
configure.ac:
Run the C compiler to check if it actually targets x86-64.
Previously we assumed if $host is x86_64 then the C compiler will be
targeting x86-64, but that is not true if gcc -m32 or gcc -mx32 is
used.
Then, as before, if the C compiler targets x86 and dynamic linking
is enabled (except on Windows) and GCC is version 5+ then disable
selection of any grades that use gcc labels.
runtime/mercury_goto.h:
Report an error if the user tries to use non-local gotos with PIC
on x86 with GCC 5+.
README.x86:
Document the issue.
README.md:
Add reference to README.x86.
runtime/mercury_atomic_ops.h:
clang provides the GCC builtin function __sync_synchronize(); use that
as a fallback memory barrier.
Avoid unreadable #error directive output from clang.
Add an XXX about C11 atomic ops.
runtime/mercury_atomic_ops.h:
As above; on aarch64-apple-darwin we were *not* getting the error about
memory fence operations not being defined when using clang as the C
compiler; compilation was instead aborting later due to MR_SFENCE
not being defined.
runtime/mercury_term_size.c:
Use MR_index_or_search_ptag_layout to search du type layouts by
primary tag and MR_index_or_search_sectag_functor to search
sectag_alternatives by secondary tag, as required for subtypes.
Delete cases for MR_TYPECTOR_REP_RESERVED_ADDR*
which have since been deleted.
MR_SECTAG_REMOTE_WORD was previously renamed to
MR_SECTAG_REMOTE_FULL_WORD.
(Note that even with these changes, MR_RECORD_TERM_SIZES
is not in a working state.)
runtime/mercury_ho_call.c:
Include mercury_deconstruct_macros.h for macros used in the
following.
runtime/mercury_unify_compare_body.h:
Use MR_index_or_search_ptag_layout to search du type layouts by
primary tag and MR_index_or_search_sectag_functor to search
sectag_alternatives by secondary tag, as required for subtypes.
runtime/mercury_deconstruct.c:
Use MR_index_or_search_ptag_layout to search du type layouts by
primary tag and MR_index_or_search_sectag_functor to search
sectag_alternatives by secondary tag, as required for subtypes.
(MR_named_arg_num is used by the debugger.)
runtime/mercury_deep_copy.c:
Include mercury_deconstruct_macros.h for
MR_index_or_search_ptag_layout and
MR_index_or_search_sectag_functor.
runtime/mercury_deep_copy_body.h:
Use the macros to search a du type layout by primary tag or a
sectag_alternatives array by secondary tag, which is necessary
for subtypes.
runtime/mercury_deconstruct.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_term_size.c:
runtime/mercury_unify_compare_body.h:
Add comments where we can and can't directly index a du type layout
or sectag alternatives array.
tests/hard_coded/subtype_rtti.m:
tests/hard_coded/subtype_rtti.exp:
tests/hard_coded/subtype_rtti.exp2:
Test deep copying of subtype terms.
compiler/table_gen.m:
Find the maximum value used by an enum type to determine the size of
a trie node required for its step. Previously the code counted the
number of alternatives in the enum type, which does not work for
subtypes.
compiler/hlds_pred.m:
Update comment.
runtime/mercury_ml_expand_body.h:
runtime/mercury_deconstruct_macros.h:
Move some macros from mercury_ml_expand_body.h to
mercury_deconstruct_macros.h, and add MR_ prefixes.
runtime/mercury_construct.c:
Update comment.
runtime/mercury_table_type_body.h:
Use macros to search the ptag layout array or secondary tag array
if it is not possible to directly index them (which is the case for
subtypes).
tests/tabling/Mmakefile:
tests/tabling/table_subtype_du.m:
tests/tabling/table_subtype_du.exp:
tests/tabling/table_subtype_enum.m:
tests/tabling/table_subtype_enum.exp:
Add test cases.
In the high-level data representation, make a subtype term be
represented using the class corresponding to the base type constructor
instead of its own class. This is necessary to be able to downcast
a term from a type to a subtype in Java and C#.
compiler/du_type_layout.m:
Move get_base_type_ctor predicate to type_util.m.
Abort in a couple of places that should not occur.
compiler/type_util.m:
Add get_base_type_ctor predicate.
compiler/globals.m:
Add compilation_target_high_level_data predicate.
compiler/lco.m:
Use compilation_target_high_level_data predicate.
compiler/ml_type_gen.m:
When using the high-level data representation,
don't generate a MLDS type definition (class) for a subtype.
compiler/mlds.m:
When using the high-level data representation,
replace a Mercury subtype with its base type in an mlds_type.
Move foreign_type_to_mlds_type.
compiler/ml_unify_gen_util.m:
To access a field when using the high-level data representation,
use field names from the base type constructor of a subtype.
compiler/unify_proc.m:
When using the high-level data representation,
generate unify/compare procs for subtypes that just call the
unify/compare proc for the base type constructor.
compiler/options.m:
Delete references to --high-level and --high-level-data.
---------------
runtime/mercury_type_info.h:
Document a new field MR_type_ctor_base in MR_TypeCtorInfo_Struct.
The field is unnecessary and does not exist in the
MR_TypeCtorInfo_Struct for C.
runtime/mercury_dotnet.cs.in:
Add type_ctor_base member to MR_TypeCtorInfo_Struct for C#.
java/runtime/TypeCtorInfo_Struct.java
Add type_ctor_base member to MR_TypeCtorInfo_Struct for Java.
compiler/rtti.m:
compiler/type_ctor_info.m:
Add field corresponding to MR_type_ctor_base in type_ctor_details
for enum, notag and general du types.
compiler/rtti_to_mlds.m:
Initialize the MR_type_ctor_base field in type_ctor_infos
for high-level data grades.
compiler/rtti_out.m:
Don't write out the MR_type_ctor_base field when using
the low-level data representation.
library/rtti_implementation.m:
In Java and C# grades (high-level data grades), use the
MR_type_ctor_base field to get the type_ctor_info of the base type
ctor when constructing or deconstructing terms of a subtype.
It is necessary to perform reflection using class and field names
from the base type constructor since there are no classes
corresponding to subtypes.
Clean up some code.
---------------
tests/hard_coded/Mmakefile:
tests/hard_coded/subtype_abstract.m:
tests/hard_coded/subtype_abstract_2.m:
tests/hard_coded/subtype_abstract.exp:
Add a test case.
tests/hard_coded/subtype_rtti.m:
tests/hard_coded/subtype_rtti.exp2:
Enable a test that was previously skipped in Java and C# grades.
Make subtypes share data representation with base type when using
low-level data. High-level data grades are unchanged, so subtypes
are still represented with distinct classes from their base types.
----------------
compiler/prog_data.m:
Add abstract_subtype option for type_details_abstract.
Correct XXX comment.
compiler/prog_item.m:
Add type item_type_repn_info_subtype.
Add tcrepn_is_subtype_of option for type_ctor_repn_info.
compiler/equiv_type.m:
Replace equivalences in tcrepn_is_subtype_of.
compiler/module_qual.qualify_items.m:
Module qualify in tcrepn_is_subtype_of.
compiler/prog_type.m:
Rename some predicates that can only work on non-subtype du types.
Update comments.
compiler/check_parse_tree_type_defns.m:
Classify subtype type definitions as std_mer_type_du_subtype
instead of std_mer_type_du_all_plain_constants or
std_mer_type_du_not_all_plain_constants.
Update some comments.
compiler/du_type_layout.m:
Add two sub-passes to handle subtypes.
compiler/comp_unit_interface.m:
Extend this module to handle subtype type definitions,
analogous to the way equivalence type definitions are handled.
Rename some predicates to clarify that they must not be used
to test subtypes.
Record an abstract version of a subtype type definition using
the abstract_subtype option in type_details_abstract.
This allows the super type ctor of the subtype to be known,
and hence the base type ctor, when a subtype is abstract exported.
Update comments.
compiler/decide_type_repn.m:
Extend this module to handle subtype type definitions.
Generate type_representation items for subtype type definitions
which include the super type ctor of the subtype.
compiler/parse_tree_out.m:
Write out abstract_subtype as
"where type_is_abstract_subtype(Name/Arity)" on type definitions.
compiler/parse_type_defn.m:
Parse "type_is_abstract_subtype(Name/Arity)" declarations.
compiler/parse_tree_out_type_repn.m:
Write type_representation items with "is_subtype_of(TypeCtor/Arity)".
compiler/parse_type_repn.m:
Parse "is_subtype_of(TypeCtor/Arity)" in type_representation items.
compiler/add_type.m:
compiler/convert_parse_tree.m:
compiler/opt_debug.m:
compiler/type_util.m:
Conform to changes.
Update comments.
compiler/direct_arg_in_out.m:
Delete XXX, nothing to do.
compiler/parse_util.m:
Rename overly specific variable.
----------------
runtime/mercury_type_info.h:
Add a flag in MR_TypeCtorInfo to indicate if the enum/du layout
array may be indexed by an enum value or du ptag value.
Subtypes break the invariant that the layout array contains entries
for every enum/ptag value from 0 up to the maximum value.
The presence of the flag MR_TYPE_CTOR_FLAG_LAYOUT_INDEXABLE tells
the runtime that it can directly index the layout array instead of
searching through it (which is the common case, for non-subtypes).
Add a field MR_du_ptag to MR_DuPtagLayout. This is necessary to find
an entry for a given primary tag value in a MR_DuPtagLayout array.
Add a field MR_du_ptag_flags to MR_DuPtagLayout, currently with one
possible flag MR_DU_PTAG_FLAG_SECTAG_ALTERNATIVES_INDEXABLE.
As with primary tags, subtypes break the invariant that the
sectag_alternatives array contains entries for every secondary tag
value from 0 up to the maximum value. The presence of the flag tells
the runtime that it can directly index the sectag_alternatives array
(which is the common case, for non-subtypes).
The two fields added to MR_DuPtagLayout occupy space that was
previously padding, so the size of MR_DuPtagLayout is unchanged.
In MR_EnumFunctorDesc, replace the MR_enum_functor_ordinal field by
MR_enum_functor_value, i.e. the integer value representing the
functor in memory. Storing *both* the functor ordinal and enum value
would increase the size of the MR_EnumFunctorDesc struct, and would
be redundant in the common case of non-subtype enums (both fields
would contain equal values). We forgo having the functor ordinal
directly available, at the cost of needing to search through an
MR_EnumFunctorDesc array when a functor ordinal is required for a
subtype enum, which should be rare.
compiler/rtti.m:
Swap enum "functor ordinal" and "value" in places.
Use a type 'enum_value' to try to ensure we do not mix up enum
functor ordinals and enum values.
Add code to encode the MR_TYPE_CTOR_FLAG_LAYOUT_INDEXABLE flag.
Add code to encode the MR_DU_PTAG_FLAG_SECTAG_ALTERNATIVES_INDEXABLE
flag.
compiler/rtti_out.m:
Write out "enum_ordinal_ordered_tables" ordered by functor ordinals
instead of "enum_value_ordered_tables" ordered by enum values.
Output the enum value for MR_EnumFunctorDesc instead of functor
ordinal.
Output the MR_du_ptag and MR_du_ptag_flags fields for
MR_DuPtagLayout.
Relax sanity check on primary tags. A subtype may not necessarily
use ptag 0, and may skip ptag values.
compiler/rtti_to_mlds.m:
Generate "enum_ordinal_ordered_tables" instead of
"enum_value_ordered_tables".
Fill in the enum value for a MR_EnumFunctorDesc instead of
the functor ordinal.
compiler/type_ctor_info.m:
Add predicate to generate the MR_du_ptag_flags field.
Add the MR_TYPE_CTOR_FLAG_LAYOUT_INDEXABLE flag to type_ctor_infos
when appropriate.
Bump the type_ctor_info_rtti_version.
----------------
runtime/mercury_ml_expand_body.h:
Search through an enum layout array to find the matching enum value,
unless the array can be indexed.
Search through a ptag layout array to find the matching ptag value,
unless the array can be indexed.
Search through a sectag_alternatives array to find the matching
secondary tag value, unless the array can be indexed.
Factor out the code to search through a foreign enum layout array
into a separate macro.
runtime/mercury_construct.c:
runtime/mercury_construct.h:
Add a functor_ordinal field to the MR_Construct_Info_Struct.
This will hold the functor ordinal now that it is not available in
MR_EnumFunctorDesc.
Make MR_get_functors_check_range take an argument to indicate if the
functor_ordinal field needs to be filled in properly. Most callers
do not need the field.
library/construct.m:
Conform to changes to MR_get_functors_check_range and
MR_EnumFunctorDesc.
-------------------
runtime/mercury_dotnet.cs.in:
Modify RTTI classes for C# backend, analogous to the changes for the
C runtime.
Add methods to index/search through enum layout arrays, ptag layout
arrays, and sectag_alternatives arrays.
java/runtime/DuPtagLayout.java:
java/runtime/EnumFunctorDesc.java:
java/runtime/TypeCtorInfo_Struct.java:
Modify RTTI classes for Java backend, analogous to the changes for the
C runtime.
Add methods to index/search through enum layout arrays, ptag layout
arrays, and sectag_alternatives arrays.
library/rtti_implementation.m:
Conform to MR_EnumFunctorDesc field change.
Index or search through the enum layout array or ptag layout array
based on the MR_TYPE_CTOR_FLAG_LAYOUT_INDEXABLE flag.
Index or search through the sectag_alternatives array depending on
the MR_DU_PTAG_FLAG_SECTAG_ALTERNATIVES_INDEXABLE flag.
Add separator lines.
Slightly reorder some code.
----------------
tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
tests/hard_coded/subtype_pack.m:
tests/hard_coded/subtype_pack_2.m:
tests/hard_coded/subtype_pack.exp:
tests/hard_coded/subtype_rtti.m:
tests/hard_coded/subtype_rtti.exp:
tests/hard_coded/subtype_rtti.exp2:
Add test cases.
Detect I/O errors that occur when reporting statistics and handle them them by
throwing io.error exceptions.
runtime/mercury_report_stats.[ch]:
Make MR_report_{standard,full_memory}_stats return zero on success
or errno if an I/O error occurs.
library/io.m:
Return a system_error indication from the report statistics predicates
and throw an io.error exception on an error.
library/benchmarking.m:
Implement report_stats/0 and report_full_memory_stats/0 by calling the
report statistics predicates from the io module rather then by using
foreign_procs. This ensures we get identical error handling behaviour
between the two modules.
Simplify the C# and Java statistics reporting methods.
Stream line number counters were not being consistently updated by the
predicates used to report statistics. This change fixes the places where these
line number counters are not being updated.
runtime/mercury_report_stats.{h,c}:
Pass the stream line number counter to the functions used to write statistics.
Update stream line number counts as statistics are printed.
library/io.m:
library/benchmarking.m:
Pass the stream line number counters to the C versions of the statistics
reporting functions. (The C# and Java versions already update the counter
correctly.)
Until now, all the predicates that reported statistics wrote their output
to stderr; users could not choose another stream. This diff adds ways
to report those same statistics to a stream chosen by the user, though
for now, only when targeting C.
The code for reporting statistics used to be in benchmarking.m, in the
form of a foreign_decl/foreign_code pair that declared and defined the
needed data structures and functions, and foreign_procs that called them.
All this code had stderr hard-coded as the destination stream.
As long as the output is done by C code (as opposed to the C code
constructing a big string containing all the stuff to be output),
directing the output to a user-supplied io.text_output_stream requires
converting that text_output_stream to a value of the C "FILE *" type.
This requires access to the actual definition of the io.text_output_stream
type, which is private to io.m. We could export it to benchmarking.m,
but that is undesirable. Instead, this diff moves the code that used
to be in benchmarking.m's foreign_decl/foreign_code pair to a new
module in the runtime, mercury_report_stats.[ch], which allows
foreign_procs in both benchmarking.m and io.m to use it.
We used to have
impure report_stats/0 in benchmarking.m
report_stats/2 in io.m
report_stats/3 in io.m
The difference between the two versions in io.m is a "selector" argument
that specifies which kind of stats to print. Adding a text_output_stream
argument to report_stats/2 would create report_stats/3, which clashes
with this existing name/arity pair. This diff therefore renames
io.report_stats/2 as io.report_standard_stats.
library/benchmarking.m:
Delete the code moved to mercury_report_stats.[ch]. Call
ML_report_full_memory_stats even if MR_MPROF_PROFILE_MEMORY is not defined
(see next entry).
runtime/mercury_report_stats.[ch]:
New module containing the code moved from benchmarking.m, with
ML_report_stats renamed to ML_report_standard_stats, and then
all ML_ prefixes replaced with MR_ prefixes.
There is one substantive change. In benchmarking.m, the
ML_report_full_memory_stats function was always declared, but it was
defined, and used, only inside "#ifdef MR_MPROF_PROFILE_MEMORY".
Change this so that it is always defined and used, but prints
a message about memory profiling not being available if
MR_MPROF_PROFILE_MEMORY is not defined. This is preferable to the empty
output that calls to report_full_memory_stats used to generate in such
situations.
runtime/Mmakefile:
Add the new header and source files to the lists of header and source
files respectively.
library/io.m:
Make the changes described above.
Provide specific predicates for the full_memory and tabling stats,
as well as for the standard stats. For now, these are implemented
only for C.
Fix inconsistent indentation.
NEWS:
Announce the rename of io.report_stats/2 to io.report_standard_stats/2,
but do not announce the other new predicates in io.m yet. That should
happen when they work for C# and Java as well.
compiler/file_util.m:
Conform to the change from report_stats to report_standard_stats.
runtime/.r1
On Windows we implement the system RNG by calling the CRT's rand_s() function.
library/random.system_rng.m:
Implement the system RNG on Windows using rand_s().
runtime/mercury_std.h:
On Windows define the macro _CRT_RAND_S before the initial
inclusion of stdlib.h -- we must do this otherwise the declaration
of rand_s() will not be visible.
runtime/machdeps/aarch64_regs.h:
runtime/mercury_regs.h:
Define global registers for aarch64.
configure.ac:
Compile with -fomit-frame-pointer on aarch64. (Doing so frees
up register x29.)
Compile with -fPIC instead of -fpic on aarch64-*-linux* systems
in order to avoid size limits on the global offset table.
configure.ac:
compiler/notes/overall_design.html:
deep_profiler/conf.m:
runtime/mercury_context.h:
runtime/mercury_goto.h:
runtime/mercury_grade.h:
runtime/mercury_regs.h:
As above -- the configure template has been named configure.ac
for a long time now.
configure.ac:
Deduplicate checks for how to access the program counter from a
signal handler context.
Check REG_RIP for x86-64 and REG_EIP for i386.
Define _GNU_SOURCE for the register constants (REG_RIP, etc.)
Drop support for accessing the PC on Alpha as it doesn't fit easily
into the "uc_mcontext.gregs[$reg]" pattern.
configure.ac:
Delete check for sa_sigaction field. If a call to sigaction()
has the SA_SIGINFO flag set then the handler must be specified in
the sa_sigaction field, not the sa_handler field.
runtime/mercury_conf.h.in:
Delete MR_SIGACTION_FIELD macro.
runtime/mercury_signal.c:
Don't use MR_SIGACTION_FIELD macro.
Don't define dummy value for SA_SIGINFO.
tools/configure_mingw_cross:
Don't set now-unused variable.
The configure checks for sigcontext (aka sigcontext_struct) have failed
for a long time without anyone noticing. The MR_GET_FAULT_ADDR macro
that is also needed for the sigcontext code paths was only ever defined
for __i386__ and __mc68000__.
According to the sigaction(2) man page, the struct sigcontext
argument was obsoleted by the introduction of the SA_SIGINFO flag
(which we also have code for, though also not working either).
configure.ac:
Delete checks related to struct sigcontext.
Delete check for asm/sigcontext.h
runtime/mercury_conf.h.in:
Delete macros that are no longer defined.
runtime/mercury_memory_handlers.c:
runtime/mercury_signal.c:
runtime/mercury_signal.h:
Delete code for using signal handlers that take a sigcontext argument.
Add XXX where native GC casts a context parameter to
struct sigcontext * when it should be a ucontext_t *.
Possibly never tested.
runtime/mercury_faultaddr.h:
Delete this file containing only the MR_GET_FAULT_ADDR macro which is
no longer used.
runtime/RESERVED_MACRO_NAMES:
ssdb/RESERVED_MACRO_NAMES:
trace/RESERVED_MACRO_NAMES:
Delete macros that are no longer defined.
tools/configure_mingw_cross:
Don't need to set variables mercury_cv_sigcontext_struct_2arg and
mercury_cv_sigcontext_struct_3arg any more.
This should fix Mantis bug #514.
runtime/mercury_builtin_types_proc_layouts.h:
Fix the first problem: refer to four type constructors defined
in private_builtin.m by their correct arities, so that the proc layout
structures we generate for their unify and compare predicates
get generated with the correct names and contents.
The arities were probably correct when the code was written;
we changed them from 1 to 0 at some point, and simply forgot
to update all the affected places.
runtime/mercury_stack_layout.h:
Fix the second problem: add "extern" to the declarations of those
proc layout structures. Without the "extern", compilers defaulting
the -fcommon will place these structures into common storage,
which can be used as *definitions*. With the "extern", compilers
should do the right thing whether or not they default to -fcommon.
runtime/mercury_unify_compare_body.h:
Conform to the change in mercury_builtin_types_proc_layouts.h:
refer to the affected four types using the correct arities.
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.