My commit afe2887882 broke the ability
to run the test suite outside of a bootcheck by executing "mmake runtests"
in the tests directory. This diff fixes that.
tests/Mmake.common:
Don't define "TESTS_DIR = ..". While every single tests/*/Mmakefile
defined it as such, I overlooked the fact that tests/Mmakefile itself
defined it ".", referring to the same directory from a different starting
point. Document this easily-overlooked fact.
Rename the old runtests target, which after afe2887 runs the tests
in a single directory, as runtests_dir, to leave the target name
"runtests" itself free for tests/Mmakefile to use.
tests/Mmakefile:
Define "TESTS_DIR = .", and add a target "runtests" which invokes
"mmake runtests_dir" in each test directory.
tools/bootcheck:
Invoke "mmake runtests_dir" instead of "mmake runtests" in each
test directory.
Initialize a variable just before it is used.
tests/*/Mmakefile:
Add back the definition "TESTS_DIR = .."
A long time ago, test directories such as hard_coded had subdirectories
such as hard_coded/typeclasses. These have since been flattened out
(e.g. hard_coded/typeclasses is now just typeclasses), but there were
still remnants of the old approach. This diff deletes those remnants.
tests/*/Mmakefile:
Delete the TESTS_DIR and the SUBDIRS mmake variables; TESTS_DIR
was always set to "..", and SUBDIRS to the empty string.
Delete any references to the make variable NOT_WORKING, since
it is never used.
tests/Mmake.common:
Document that Mmakefiles in test directories don't have to set
TESTS_DIR and SUBDIRS anymore. Fix the formatting of the documentation
of the make variables they do still have to set.
Delete the targets and actions for handling subdirectories of
test directories, since there aren't any.
tests/Mmakefile:
Simplify some code.
tests/Mmake.common:
Don't invoke any actions in the clean_local and realclean_local
targets, since if using mmc --make, the builtin mmake rules
have actions for those targets as well, and make can't handle
more than one action for a target having actions. Replace those
actions with dependencies on other, unique targets that have
the actions instead.
tests/*/Mmakefile:
Avoid actions in clean_local and realclean_local targets the same way.
Sort the test names in some directories that didn't already do so.
Delete some obsolete comments.
Fix style.
tests/valid/Mmake.valid.common:
As for the Mmakefiles above, and also move the definition of a make
variable before it is needed.
tests/Mmake.common:
Replace the -j1 in the runtests_local target used by all the test
directories with $(MAYBE_J1).
tests/*/Mmakefile:
Define MAYBE_J1 it as the empty string in test directories in which
different tests don't share source files.
Define MAYBE_J1 as -j1 in test directories in which
different tests do share source files.
tests/submodules/sub2_a.m:
Add this copy of sub_a.m to allow tests in the submodules directory
to be done in parallel.
tests/submodules/accessibility2.m:
Import sub2_a.m instead of sub_a.m.
tests/warnings/ambig_types_high_level.m:
Add this copy of ambig_types.m to allow tests in the warnings directory
to be done in parallel.
tests/warnings/ambig_high_level.m:
Import ambig_types_high_level.m instead of ambig_types.m.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
This file-specific setting will override a default setting of expandtabs
in $HOME/.vimrc.
*/Makefile:
*/Mmakefile:
As above.
tests/hard_coded/.gitignore:
Don't ignore the purity subdir. This ignore must have been left over
from when purity.m was a test in hard_coded, not hard_coded/purity,
and it ignored an executable, not a directory.
Branches: main, 11.07
Make the none.gc.memprof grade work with MSVC again.
Avoid more warnings when compiling with MSVC.
compiler/layout_out.m:
Avoid an incomplete type in the declaration of the alloc_sites
array. (Similar changes need to be made for the layout structures
related to debugging and deep profiling - I am in the process of
testing the former, the latter doesn't currently work on Windows
any way.)
browser/listing.m:
Use don't-care variables in some foreign_procs.
This avoids warnings about assignments from uninitialized
variables with MSVC.
*/.cvsignore:
Update cvsignore entries.
Ignore files generated by mprof.
This test checks that trail usage optimisation is correctly removing trail
operations from around semidet conditions in if-the-elses.
It is failing because inlining is simplifying away the if-then-else.
(Differences in the way the HLDS is transformed for the high-level
C backend means that is it working for that.)
tests/trailing/tu_test2.m:
Add a no_inline pragma in order to avoid the above problem.
Estimated hours taken: 0.2
Branches: main
tests/*/Mmakefile:
Sort the lists of tests in each directory. (We usually keep each list
sorted, but then we concatenate several lists, which loses the order.)
This gives you a better idea of how far a bootcheck still has to go.
tools/bootcheck:
Build the interface files before the rest of the files in the library
directory. Again, this gives you a better idea of how far a bootcheck
still has to go.
Make the dependencies for the slice subdirectory of the stage2 at the
same time as the other subdirs; don't let it be caught later.
library/Mmakefile:
Build the interface files in the right order.
Estimated hours taken: 20
Branches: main
Add a mechanism for dynamically growing the trail by adding new segments to it
in a similar fashion to what we do for the stacks with stack segments. The
mechanism is enabled by the trseg (trail segments) grade component. Unlike
stack segments the trail segment mechanism also works with the high-level C
backend.
The mechanism works by adding a test to MR_trail_{value,function} that checks
if we are about to run out of a trail and allocates a new trail segment if
that test succeeds.
Extend mdb's trail_details command to print the current number of trail
segments in trseg grades.
Fix a bug where the MR_trail_ptr was not being reset correctly after
a trail reset.
runtime/mercury_grade.h:
Add the new grade component.
runtime/mercury_conf_param.h:
Document the new grade component, and the option used to debug
trail segments.
runtime/mercury_memory_zones.h:
Shift the definition MR_MemoryZones to this file in order break
a cyclic dependency between header files.
runtime/mercury_context.h:
Add a new field to the context structure to hold a list previous
trail segments.
Delete the definition of the type MR_MemoryZones from here.
runtime/mercury_trail.[ch]:
When adding a new trail entry in trseg grades first check whether we
need to extend the trail and do so if necessary.
Export the definitions of MR_TRAIL_{BASE,ZONE}.
Add a macro, MR_PREV_TRAIL_ZONES, for accessing the list of trail zones
in a grade independent manner.
Fix a typo in a comment.
Add functions for creating and destroying trail segments.
Handle trail segments in the code that handles untrailing and
resets. This also fixes a bug with trail reset where MR_trail_ptr
was not being reset along with the rest of the trail state.
compiler/options.m:
compiler/handle_options.m:
compiler/compile_target_code.m:
scripts/canonical_grade.sh-subr:
scripts/init_grade_option.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
Handle the new grade component.
trace/mercury_trace_cmd_developer.c:
Make the trail_details command print out the number of trail segments
in trseg grades.
tests/trailing/Mmakefile:
tests/trailing/tr_reset_bug.{m,exp}:
Regression test for the bug with trail resets.
Estimated hours taken: 3
Branches: main
Provide a mechanism for resetting the trail. This allows the reuse of
memory that is occupied by any entries on the trail. This can only be done
safely after it is certain that any calls that added the trail entries
cannot be backtracked over. For some programs doing this can prevent trail
exhaustation.
This diff does not provide a way of doing this at the Mercury level, nor
can the compiler currently automatically add calls to reclaim memory used
by trail. Both these things are future work.
XXX the interaction between this and the debugger is a bit unclear since
trailing and debugging don't currently work together properly.
runtime/mercury_trail.h:
runtime/mercury_trail.c:
Add a new function MR_reset_trail(). When called this
function walks back along the trail calling function trail entries
with the MR_gc untrail reason. It then zeros out the trail zone
and resets the ticket counter and ticket high water mark to their
initial values.
Define two macros, MR_TRAIL_ZONE and MR_TRAIL_BASE that expand
to the addresses of the trail zone and the base of the trail
respectively in a grade independent manner.
Redefine MR_num_trail_entries() using the MR_TRAIL_BASE macro.
Document that MR_gc is now used for this.
Fix a typo.
tests/trailing/Mmakefile:
tests/trailing/test_trail_reset.m:
tests/trailing/test_trail_reset.exp:
A test of the trail reset functionality.
Estimated hours taken: 6
Branches: main
In trailing grades, pass flags to the C compiler that force it to align
functions on word boundaries. For some architectures, and for some C compiler
optimisation settings, function addresses are not aligned and this breaks
function trailing when using tagged trail entries.
XXX this diff only fixes the problem for gcc, it's not clear what,
if anything, needs to be done for other C compilers.
configure.in:
s/COMPILER/C_COMPILER_TYPE/. The former is ambiguous as
Mercury uses compilers for several languages.
Instantiate the value of C_COMPILER_TYPE in files generated
by the configure script.
Add an XXX comment about how the type of the C compiler
is determined.
Clean up a few things.
compiler/globals.m:
Define a type, c_compiler_type/0, that represents the type
of C compiler we are using. (This type replaces the old
compiler_type/0 type from compile_target_code.m).
Add a new field to the globals structure that stores the
C compiler type.
Add access and utility procedures for the new field.
Delete some business with unique modes that used to be
required when the I/O globals field was unique.
compiler/options.m:
Simplify the implementation of `--c-compiler-type'.
Most of it is now handled by the globals module.
scripts/Mercury.config.in:
Define a new variable MERCURY_C_COMPILER_TYPE, whose value
is set by the configuration script.
Pass the C compiler type to the Mercury compiler.
compiler/compile_target_code.m:
scripts/mgnuc.in:
When in a trailing grade and using gcc as a C compiler align
functions on word boundaries in order to avoid problems
with function trailing.
Delete the unused type compiler_type/0.
tests/trailing/Mercury.options:
Remove a workaround for the function alignment problem.
Estimated hours taken: 1
Branches: main
Document that values and the addresses of functions that are placed on the
trail must be word aligned.
Fix some failing test cases in the .ll_debug grades.
doc/reference_manual.texi:
Document that the addresses of the C functions used in function trailing
need to be word aligned.
tests/trailing/Mercury.options:
Fix the failure of some trailing test cases in .ll_debug grades by ensuring
that C functions are aligned on 64-bit boundaries. (The set of C
optimisations implied by the .ll_debug grades disable the -falign-functions
optimisation.)
Estimated hours taken: 0.5
Branches: main
tests/trailing/Mmakefile:
Set PROGS variable, otherwise this directory doesn't test properly
when using `mmc --make'.
Estimated hours taken: 10
Branches: main, release
Fix a bug with trail usage optimization that was causing it to break the G12
fd tests. The problem was that the optimization we were applying to model_non
disjunctions was incorrect - instead of considering trail updates along all
forward execution paths from the creation of a choicepoint to the commit, it
was only considering updates along parts of those paths.
The fix (for now) is to remove that particular part of the optimization.
(It will be possible to reinstate part of the optimization but doing so
requires creating trail specialized versions of procedures -
something that we don't currently have support for.)
compiler/trailing_analysis.m:
Treat any goal that creates a choicepoint as potentially modifying
the trail.
compiler/add_trail_ops.m:
Modify the MLDS code generator to conform to the above.
compiler/code_model.m:
compiler/disj_gen.m:
compiler/ite_gen.m:
Do the same for the LLDS code generator.
tests/trailing/tu_test1.{m,exp}:
Test case for the above bug.
tests/trailing/tu_test2.{m,exp}:
Test that trail usage optimization of semidet if-then-else
conditions still works.
tests/trailing/Makefile:
tests/trailing/Mercury.options:
Enable the new test cases.
Estimated hours taken: 0
Branches: main
test/trailing/Mmakefile:
Fix a cut-and-paste error. Only run these tests in trailing
grades, not the other way around.
Estimated hours taken: 1
Branches: main
Move some of the regression tests for trailing from
extras/trailed_update/tests to a new trailing subdirectory in the test suite.
The motivation for doing this is that parts of the trailed_update package are
broken (and likely to remain so until the solver type/purity situation is
sorted out) and the tests are not being run.
extras/trailed_update/tests/Mmakefile:
extras/trailed_update/tests/func_trail_test.{m,exp}:
extras/trailed_update/tests/func_trail_test_2.{m,exp}:
Delete these tests from here.
tests/trailing:
New subdirectory that contains regression tests for trailing.
tests/trailing/Mmakefile:
tests/trailing/Mercury.options:
tests/trailing/func_trail_test.{m,exp}:
tests/trailing/func_trail_test_2.{m,exp}:
Move the test cases from extras/trailed_update/tests to here.
Update the syntax in the test cases and escape some special characters
in the C code correctly.
tests/README:
Update this file to mention the trailing directory.