The crash that this diff fixes occurred when giving a command such as
"print Var^1" to mdb, where the first argument of Var is a direct arg.
runtime/mercury_ml_expand_body.h:
When deconstructing a term with a direct arg, return NULL
as the value of expand_info->chosen_arg_word_sized_ptr.
The crash occurred when we returned a non-null pointer,
which violated the expectations of trace/mercury_trace_vars.c
and its callers. (Not surprising, since those that function and
its callers were written long before the direct_arg optimization
was added to the system.)
runtime/mercury_deconstruct.h:
Document the rationale behind the above changes. (The contents of
mercury_ml_expand_body.h are #included in mercury_deconstruct.c.)
trace/mercury_trace_vars.c:
Add the debugging code I used to track down this issue, in disabled form.
Fix missing copyright year.
trace/mercury_trace_browse.c:
Delete obsolete comment.
Fix missing copyright years.
tests/debugger/direct_arg_test.{m,inp,exp}:
A test case for this bug.
tests/debugger/Mmakefile:
Enable the new test case.
compiler/hlds_out_type_table.m:
When dumping out the data constructors in the type table,
if a constructor has names for some of its fields,
put the name and the type of each field on different lines.
In the original test case for this bug, of which direct_arg_test.m
is an extreme simplification, pretty much every line overflows
without this.
Also, factor out some duplicated code, and replace bools with values
of a bespoke type.
trace/mercury_trace_cmd_browsing.c:
Change the dump command to allow the name of the variable
whose value is to be dumped to be followed by a path,
specifying the *part* of the variable's value to be printed.
trace/mercury_trace_vars.[ch]:
To make that possible, provide a version of an existing function
that returns an extra value that the new code in
mercury_trace_cmd_browsing.c needs, and another extra value
that conceptually belongs with it.
Mark strange code with an XXX.
NEWS.md:
Announce both this new capability and a just-now contributes predicate.
library/pqueue.m:
Make the just-now contributed code more readable.
tests/debugger/browser_test.{m,inp,exp3}:
Extend this test case to test the new functionality.
trace/mercury_trace_internal.c:
Whe printing the "there is no such variable" message at
conditional break points, print the name of the variable.
The original message can be misread to mean that there
is nothing at *the selected path*; the new one cannot.
trace/mercury_trace_spy.c:
trace/mercury_trace_spy.h:
Add a mechanism to enable the above change.
tests/debugger/cond.exp:
Expect the updated error message.
trace/mercury_trace_internal.c:
Make the diagnostic more easily readable.
trace/mercury_trace_vars.c:
Add disabled-but-could-be-enabled-again debugging code.
LICENSE:
compiler/handle_options.m:
doc/*.texi:
profiler/mercury_profile.m:
slice/mtc_diff.m:
slice/mtc_union.m:
trace/mercury_trace_internal.c:
As above.
slice/mcov.m:
slice/mslice.m:
slice/mdice.m:
Adjust years printed copyright notice to cover the
entire program, not just the top-level module.
Put .mh files into a Mercury/mhs subdirectory when --use-subdirs
or --use-grade-subdirs is used.
compiler/file_names.m:
Replace ext_cur_mh with ext_cur_ngs_max_cur_mh, in the new category
ext_cur_ngs_max_cur. The new category is similar to that for .mih
files, except that .mh files are never placed in grade-specific
subdirectories.
compiler/handle_options.m:
Add Mercury/mhs subdirs to list of C include directories
when --use-subdirs or --use-grade-subdirs is in effect.
compiler/write_deps_file.m:
Add $(mhs_subdir) prefix before %.mh patterns.
Create a Mercury/mhs -> .. symlink when installing.
This is required by mmc --make and mmake --use-subdirs.
Conform to the changes above.
compiler/export.m:
compiler/make.file_names.m:
compiler/make.program_target.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mlds_to_c_file.m:
Conform to the changes above.
scripts/Mmake.vars.in:
Define the variable mhs_subdir.
scripts/Mmake.rules:
Add -I option to find .mh files when --use-subdirs is used.
browser/.mgnuc_copts:
browser/MDB_FLAGS.in:
compiler/.mgnuc_copts:
compiler/COMP_FLAGS.in:
deep_profiler/.mgnuc_copts:
deep_profiler/DEEP_FLAGS.in:
extras/EXTRAS_FLAGS.in:
grade_lib/.mgnuc_copts:
grade_lib/GRADE_LIB_FLAGS.in:
library/.mgnuc_copts:
mdbcomp/.mgnuc_copts:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/.mgnuc_copts:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/.mgnuc_copts:
profiler/PROF_FLAGS.in:
slice/.mgnuc_copts:
slice/SLICE_FLAGS.in:
ssdb/.mgnuc_copts:
ssdb/SSDB_FLAGS.in:
tests/.mgnuc_copts.ws:
tests/WS_FLAGS.ws:
trace/.mgnuc_copts:
tools/lmc.in:
Add -I options to find .mh files when the workspace is built
with mmake --use-subdirs.
samples/c_interface/standalone_c/Makefile:
Add option to let the C compiler find the .mh file.
NEWS.md:
Announce change.
Delete trailing whitespace.
Each of the new modules, and the updated browse.m, have significantly more
cohesion than the original browse.m.
browser/print_term.m:
A new module containing the parts of the old browse.m that dealt with
printing out terms or their components.
This module exports its services to the updated browse.m and
to trace/mercury_trace_vars.c.
browser/save_term.m:
A new module containing the parts of the old browse.m that dealt with
dumping terms to files.
This module exports its services to trace/mercury_trace_browse.c.
browser/term_paths.m:
A new module containing the parts of the old browse.m that dealt with
operations on paths in terms.
This module exports its services to the updated browse.m,
declarative_user.m, and print_term.m.
browser/browse.m:
Delete the code moved to the new modules.
browser/mdb.m:
Include the three new modules.
browser/term_to_html.m:
Add module qualifiers to some calls to reduce ambiguity.
browser/declarative_user.m:
ssdb/ssdb.m:
trace/mercury_trace_browse.c:
trace/mercury_trace_vars.c:
Conform to the changes above.
--no-ansi (mgnuc) and --no-ansi-c (mmc) have not actually done anything for
many years now. Deprecate these options and remove their "use" throughout most
of the Mercury system. (The remaining uses are in the Makefiles for the Boehm
GC, which need to be updated separately.)
Also deprecate the internal compiler option --cflags-for-ansi.
compiler/options.m:
Document that --no-ansi-c is now deprecated.
Document that the internal option --cflags-for-ansi is now
deprecated.
compiler/compile_target_code.m:
Do not pass the ANSI options to the C compiler.
scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
Deprecate the --no-ansi option; delete code that no longer does
anything useful.
configure.ac:
Delete the configuration variable CFLAGS_FOR_ANSI; it is only ever
set to be empty. (The comment talks about --no-ansi doing other things
in the mgnuc script. It used to also cause some preprocessor macros
to be defined for compatibility with the system headers on some
platforms -- that has not been the case since 2013.)
doc/user_guide.texi:
Document that --no-ansi-c is deprecated.
bytecode/Mmakefile:
compiler/Mercury.options:
library/Mercury.options:
extras/odbc/odbc.m:
runtime/Mmakefile:
scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
tests/hard_coded/Mercury.options:
tests/valid/Mercury.options:
trace/Mmakefile:
util/Mmakefile:
Conform to the above change.
NEWS.md:
Announce the above.
The usual mdb "dump" command puts every function symbol on its own line.
This guarantees that we generate any line that is too long to be displayed
on terminals, but it also generates output that is too stretched out
vertically for its structure to be readily apparent. Dumping the term
as a doc allows pretty_printer.m to put as many function symbols on a line
as would fit, without exceeding the maximum line length.
browser/browse.m:
Add save_term_to_file_doc, a way to save a (possibly synthetic)
browser term in a file, using an interface that works the same way
the predicate that saves browser terms as XML.
Inline a predicate at its only call site. Improve variable names.
trace/mercury_trace_browse.[ch]:
Add MR_trace_save_term_as_doc, as an interface function between
save_term_to_file_doc and the code of mercury_trace_cmd_browsing.c.
trace/mercury_trace_cmd_browsing.c:
Add support for a new -p/--prettyprint flag to the mdb "dump" command,
which asks for the given term to be dumped as a pretty_printer doc.
doc/user_guide.texi:
NEWS:
Document the new option.
library/pretty_printer.m:
NEWS:
Rename write_as_doc to write_doc_formatted, and fix its argument type.
tests/debugger/browser_test.inp:
Dump a term that we already dumped with "dump" with "dump -x" and
"dump -p" as well.
tests/debugger/browser_test.m:
Put the code to remove the files we are going to dump to
and then later to print the files we have dumped to into separate
predicates. This keeps most (but not all) line numbers unchanged
even though we now dump to more files.
tests/debugger/browser_test.exp3:
Update this file to account both for the extra output from the just-added
dump commands, and for the changes in line numbers.
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.
browser/browse.m:
browser/browser_info.m:
browser/collect_lib.m:
browser/declarative_debugger.m:
browser/declarative_oracle.m:
browser/declarative_user.m:
browser/diff.m:
browser/help.m:
browser/interactive_query.m:
browser/parse.m:
browser/util.m:
Replace implicit streams with explicit streams.
Shorten lines longer than 79 chars.
In some places, simplify some code, often using constructs such as
string.format that either did not exist or were too expensive to use
when the original code was written.
In some places, change predicate names that were not meaningful
without module qualification by *including* the module qualification
in the name (e.g. init -> browser_info_init).
In some places, add XXXs.
In browser_info.m, make the output stream *part* of the debugger type,
because without this, having the debugger type belong to the stream
typeclass does NOT make sense. (The typeclass instance for debugger
used to always write to the current output stream, which this diff
is replacing with the use of explicitly specified streams.)
In browse.m, consistently put stream arguments before other arguments.
In browse.m, when exporting Mercury predicates to C, export them
under names with the standard ML_BROWSE_ prefix, NOT under the name
of a *different* predicate with that prefix.
In diff.m, eliminate an unnecessary difference between what we print
when the difference between two terms is at the root, vs what we print
when the difference between two terms is lower down.
In interactive_query.m, when trying to write a program out to a file,
do NOT write the program to the current output stream if we cannot open
the file, since that would accomplish nothing useful.
Also in interactive_query.m, cleanup .dylib instead of .so on MacOS.
In util.m, delete some unused predicates.
In collect_lib.m, document why some code is not worth updating.
In declarative_oracle.m, rename predicates with previously-ambiguous
names.
browser/MDBFLAGS.in:
Specify --warn-implicit-stream-calls for all Mercury modules
in the browser directory from now.
trace/mercury_trace_browse.c:
trace/mercury_trace_cmd_browsing.c:
ssdb/ssdb.m:
Conform to the changes in browser/*.m.
tests/debugger/queens.{exp,exp2}:
Expect the extra output from browser/diff.m.
The 'browse --xml' command has not worked with current versions of
xsltproc for quite some time, but we have not received any bug reports,
nor has anyone tried to fix it. We have a method for interactively
exploring a term in 'browse --web' so IMHO there is no need to keep
support for 'browse --xml'.
browser/browse.m:
browser/browser_info.m:
browser/declarative_user.m:
trace/mercury_trace_browse.c:
trace/mercury_trace_browse.h:
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_cmd_parameter.c:
trace/mercury_trace_cmd_parameter.h:
trace/mercury_trace_internal.c:
Delete code.
doc/mdb_categories:
doc/user_guide.texi:
Delete documentation.
configure.ac:
Don't search for a XUL browser and xsltproc.
scripts/mdbrc.in:
Delete 'xml_browser_cmd' and 'xml_tmp_filename' lines.
scripts/xul_tree.xsl:
Delete now unused file.
scripts/Mmakefile:
Conform to deletions.
tests/debugger/Mmakefile:
tests/debugger/browser_test.exp:
tests/debugger/browser_test.exp3:
tests/debugger/browser_test.inp:
tests/debugger/mdb_command_test.inp:
tests/debugger/save.exp2:
tests/declarative_debugger/browse_arg.exp:
tests/declarative_debugger/browse_arg.inp:
Don't test 'browse --xml' any longer.
extras/xml_stylesheets/README:
Delete reference to 'browse --xml' command.
NEWS:
Announce change.
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.
browser/listing.m:
Use posix_spawnp() to call the external 'list' command instead of
io.call_system. This avoids characters in the command or arguments
being interpreted as shell meta characters by the system shell.
On platforms that do not support posix_spawn, print an error
message.
Redirect the standard output and standard error of the child process
to OutStrm and ErrStrm so that the external listing command outputs
to the mdb window when using 'mdb -w' or 'mdb --program-in-window'.
trace/mercury_trace_cmd_browsing.c:
Ensure the 'list' command does not pass a negative first line number
to the external listing command.
browser/listing.m
Add list_file_with_command which calls an external command to print
source listings instead of doing it internally. The implementation
is incomplete in that the external command's standard output and
standard error streams are not redirected into OutStrm and ErrStrm.
Rename mercury_stream_to_c_FILE_star to
mercury_stream_to_c_file_ptr.
Consolidate some output calls with string.format.
trace/mercury_trace_cmd_parameter.c:
trace/mercury_trace_cmd_parameter.h:
trace/mercury_trace_internal.c:
Add a 'list_cmd' command which sets or prints the current
external listing command.
trace/mercury_trace_cmd_browsing.c:
Make 'list' command call list_file_with_command if an external
listing command was set.
doc/user_guide.texi:
Document 'list_cmd' command.
tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
Update for new command.
NEWS:
Announce changes.
trace/mercury_trace_cmd_browsing.c:
The "level" command was documented to reset the current ancestor level
to the level of the current event (ancestor level 0) when invoked
without arguments, but when invoked that way, it reported an error
instead. Fix this.
tests/debugger/queens_rep.inp:
tests/debugger/queens_rep.exp:
Add a test for the fix in this existing test case.
browser/help.m:
Simplify the data types representing the nested structure
of help information. Simplify the code of the predicates
that work on that structure.
Simplify some of the predicates, e.g. by having a search predicate
do *just* search.
Give types and predicates more meaningful names. Make argument order
more suitable for state-variables. Move a predicate next to its
only call site.
browser/declarative_user.m:
Conform to the change in help.m.
Replace two bools with values of bespoke types.
browser/declarative_debugger.m:
browser/declarative_oracle.m:
Conform to the changes in help.m and declarative_user.m.
doc/generate_mdb_doc:
Fix the vim modeline.
trace/mercury_trace_declarative.c:
trace/mercury_trace_help.c:
Conform to the changes in the browser directory.
util/info_to_mdb.c:
Switch from /**/ to // for comments.
Give a macro a meaningful name.
Fix indentation.
trace/mercury_trace_spy.c:
When the user wants to put a breakpoint on a line in a file,
but there is no event exactly on the given line number,
mdb used to tell the user just that fact. This diff makes
mdb more helpful, by printing the nearest line numbers before
and after the given line number that *do* have events on which
breakpoints can be put.
The mismatch can come for several reasons, with the most common
probably being that textually, a switch arm for e.g X being f
starts with the X = f unification goal, but switch detection
*deletes* that unification from the switch arm, so the event
for entry into that arm is actually on the line for the *next* goal.
trace/mercury_trace_tables.[ch]:
Provide the info needed by mercury_trace_spy.c.
Change the interface of MR_process_file_line_layouts to make it
self-contained, i.e. returning counts of matches, instead of
merely *adding* to preexisting counts. This is simpler, since
the only caller of that function needs no running tally.
tests/debugger/breakpoints.inp:
Extend this test to test the possible error messages we now generate.
tests/debugger/breakpoints.exp:
tests/debugger/breakpoints.exp2:
Update the expected outputs in both debug and non-debug grades.
The main objective of this change is to get bootchecks in the csharp
and java grades to actually build the slice, profiler, deep_profiler
and mfilterjavac directories, which (due to the bug this diff fixes)
they weren't doing before.
However, since one side effect of this change is to eliminate
one source of annoying warnings from mmake about references to undefined
variables, a subsidiary objective is to eliminate other sources of such
warnings as well, which mostly come from the rules for making tags files.
browser/Mmakefile:
deep_profiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
When creating stage 3, the bootcheck builds, in each directory,
only the files that it wants to compare against their stage 2 versions.
This means that it wants to build all the .c, .cs or .java files,
which it does via the cs, css and javas mmake targets.
The correct definitions of the rules of these targets depends on
whether mmc --make is being used or not, so we need at least two
sets of definitions: one for mmc --make, and for no mmc --make,
and conditionally selecting the appropriate one. The latter definition
has the problem that it refers to mmake variables that are intended
to be defined in .dv files created by mmc --generate-dependencies,
but until that has been run, those mmake variables are undefined.
Until now, the only directories that had both the mmc --make
and the no mmc --make definitions were the ones needed to build
the compiler. Bootchecks in the csharp and java grades, which
always use --make make, got errors when they tried to build
the directories that bootcheck builds after the compiler:
the slice, profiler, deep_prof and mfilterjavac directories.
This diff ensures that all directories we build in bootcheck
get all both versions of the os, cs, css, and javas targets.
In fact, they get two subversions of the no mmc --make version:
one for use in the presence of .dv files, and one for use in their
absence. The latter just builds the .dv files and invokes mmake
again. This avoids one source of warnings about undefined mmake
variables.
To avoid another source, make the rules for tags files and their
proxies depends on *.m instead of mmake variables such as $(mcov.ms),
since this makes sense even before making dependencies. The only price
is that any untracked Mercury source files in the directory have to
either be given some other suffix, or moved somewhere else.
Where relevant, make the mtags invocation prefer the master versions
of files that are copied from the mdbcomp directory to other directories,
since this is the only writeable version.
Make the os and cs rules consistently NOT build the _init.[co] files.
The way we use those files in bootcheck, we never need them;
when we need them, the right target to give is the executable anyway.
In the slice directory, don't put mcov between mtc_union and mtc_diff.
Eliminate unnecessary duplication, e.g. of sources in rules.
Eliminate double negatives in conditionals.
Fix formatting.
Mmake.common.in:
bindist/Mmakefile:
bytecode/Mmakefile:
compiler/Mmakefile:
doc/Mmakefile:
grade_lib/Mmakefile:
robdd/Mmakefile:
samples/Mmakefile:
scripts/Mmakefile:
tools/Mmakefile:
trace/Mmakefile:
util/Mmakefile:
Add "ft=make" to vim modelines. This is redundant for the files whose
names is Mmakefile, but it is needed for Mmake.common.
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.
trace/Mmakefile
Fix incorrect makefile rule with multiple targets.
A rule with multiple targets is equivalent to writing many rules,
each with one target, so the bison rule would (in parallel make)
run bison once for the .c target and once for the .h target.
The solution is to use a pattern rule, which GNU make recognises
as a single recipe generating multiple outputs.
Write separate rules for mercury_event_scanner.c and
mercury_event_scanner.h.
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.
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.
trace/mercury_trace_cmd_browsing.c:
Avoid errors about the conversion specifier not matching the
type of the corresponding argument in a call to fprintf.
trace/mercury_trace_cmd_browsing.c:
Lift the hard-wired limit on printing a maximum of 20 I/O actions at once
by adding the option "-m max" to the "print io" command. Keep the default
at 20 for its "print io" form, which prints the next batch of I/O actions,
but move it up to 500 for the "print io *" form, which is intended
to print *all* I/O actions.
Use separate functions for processing the options of the "print" and
"browse" mdb commands. The new -m option applies only to the print command,
while the existing -w and -x options apply only to the browse command.
Make "print io N" print the same out-of-range error message as
"print io N-M". This inconsistency was an oversight.
doc/user_guide.texi:
Document the changes above. Document some previously existing aspects
of the "print io" command that should have been documented but weren't.
Change some other documentation to refer to "I/O actions" instead of
just "io actions".
tests/debugger/tabled_read_decl.exp:
Expect the updated error message for an out-of-range "print io N".
tests/debugger/tabled_typeclass.{inp,exp,exp2}:
Print the I/O actions we want using a single "print -m 100 io *" command.
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.
trace/mercury_trace_completion.c:
Use rl_filename_completion_function rather than
filename_completion_function; the latter name is deprecated (and, in fact,
is not present on some systems).
Support the use of the editline library as an alternative to GNU readline for
the debugger command-line prompt. The former has a more permissive license
than the latter. If licensing is not an issue then GNU readline is the
preferable choice (e.g. feature wise); as such it is the default option.
NOTE: there are (apparently) two editline libraries, one derived from NetBSD
and one from Minix -- this diff adds support for the former. (Using the latter
should just be a matter of using a different header file and supplying a
different library name to link against, but I haven't tried that yet.)
m4/mercury.m4:
Add a configuration check for editline.
configure.ac:
Check the presence of editline.
runtime/mercury_conf.h.in:
Replace the macro MR_NO_USE_READLINE with MR_USE_READLINE which
is defined if GNU readline is available and the user has not
forbidden its use.
Add a new macro MR_USE_EDITLINE which does the same for editline.
Add a new macro that is defined if the header editline/readline.h
is present.
trace/mercury_trace_completion.c:
trace/mercury_trace_readline.c:
Use editline in place of readline if appropriate.