Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
Branches: main, 11.07
Make compilation of extras/references more reliable.
extras/references/Makefile:
extras/references/Mmakefile:
extras/references/Mercury.options:
Use mmc --make to build and install this library (as we do with
some of the other extras packages) instead of mmake. This allows
us to sue the grade filtering mechanism in mmc --make to ensure
that we only install the library in grades that support trailing.
Fix a number of problems that prevent this library installing cleanly:
+ don't require the presence of asm_fast grades; build the library in
the default grade with the trail segment component added.
+ use trail segment grades instead of fixed sized trail grades (the latter
are not installed anymore unless specifically requested by the user).
+ install the C header file that is part of this library.
+ delete ancient workarounds for supporting shared libraries on Linux.
extras/references/tests/Mmakefile:
extras/references/samples/Mmakefile:
Conform to the above changes.
Don't assume that the extension for static libraries is .a; it's
not on some systems.
extras/references/global.m:
Add a feature set pragma specifying that trailing is required.
extras/references/nb_reference.m:
s/__/./
extras/lex/lex.m:
Unrelated change: avoid using an obsolete function.
Branches: main
Estimated hours taken: 1
extras/references/nb_reference.m:
Use private_builtin.ref(T) rather than c_pointer for the
nb_reference type, so that nb_references can be copied using
copy/1 or stored in `pragma memo' tables.
Estimated hours taken: 3
Branches: main
extras/references/nb_reference.m:
extras/references/reference.m:
extras/references/tests/glob_test.m:
extras/references/tests/ref_test.m:
Fix places where the code previously assumed that `nb_reference(T)' and
`reference(T)' had the same representation as `c_pointer'.
This is not the case in some grades, e.g. the `--reserve-tag' grades.
Estimated hours taken: 2.5
Branches: main
Add MR_ prefixes to uses of configuration macros.
Bootcheck now succeeds with MR_NO_CONF_BACKWARDS_COMPAT.
Mmake.common.in:
Define MR_NO_CONF_BACKWARDS_COMPAT when checking
for namespace cleanliness.
RESERVED_MACRO_NAMES:
Remove the configuration macros.
runtime/mercury_conf_bootstrap.h:
Remove a duplicate definition of BOXED_FLOAT.
configure.in:
*/*.c:
*/*.h:
*/*.m:
Add MR_ prefixes.
Estimated hours taken: 0.5
Branches: main
extras/references/c_reference.h:
extras/references/nb_reference.m:
extras/references/reference.m:
extras/references/scoped_update.m:
Add "MR_" prefixes to a number of identifiers which were missing them.
Estimated hours taken: 2
Clean up some typeinfo handling code that is only enabled in non-gc grades.
runtime/mercury_deep_copy.[ch]:
Make the typeinfo arg of MR_make_long_lived MR_TypeInfo, not Word.
runtime/mercury_tabling_macros.h:
Treat the typeinfo arg of MR_make_permanent, a macro that calls
MR_make_long_lived, a MR_TypeInfo, not Word.
extras/reference/nb_reference.m:
Treat the typeinfo arg of MR_make_long_lived a MR_TypeInfo, not Word.
library/exception.m:
library/std_util.m:
Treat the typeinfo arg of deep_copy as MR_TypeInfo, not Word.
Also fix some other warnings in std_util.m.
library/private_builtin.m:
Pass the addresses of type_ctor_infos (which function as type_infos)
to MR_TABLE_SAVE_ANSWER.
Expect that argument to be a typeinfo, not the name of a type_ctor_info
to take the address of.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
Treat the typeinfo arg of deep_copy as MR_TypeInfo, not Word.
Estimated hours taken: 12 (this figure a wild guess, because most of this
stuff was done about 6 months ago and left to rot).
This change basically exposes the C types used for implementing the
`reference' and `nb_reference' types in extras/references, so that if the
user wishes to allocate these types somewhere other than on the heap, they
can. This is needed by HAL in order to implement global variables.
extras/references/c_reference.h:
New file, intended to expose the C types used by the `reference'
and `nb_reference' modules, so that the user can allocate them
somewhere other than on the heap if they need to.
extras/references/nb_reference.m:
Added a new predicate `init/2' for initialising a user-allocated
`nb_reference'.
extras/references/reference.m:
Moved the `ME_Reference' type to c_reference.h, and added a new
predicate `init/2' for initialising a user-allocated `reference'.
extras/references/README:
Added entries for the new `c_reference.h' and `tests/glob_test.m'
files, as well as correcting the name of `tests/ref_test.m'.
extras/references/tests/Mmakefile:
Added `glob_test' to the list of programs to build.
extras/references/tests/glob_test.m:
Test case for statically-allocated reference types, implementing
global variables. Adapted from output from the HAL compiler.
extras/references/tests/glob_test.exp:
Expected output from `glob_test'.
Estimated hours taken: 70 (plus whatever pets spent when he wrote the
original version of this)
This change adds a new extras directory, "references". This directory
contains two impure reference type modules and a module that allows scoped
non-backtrackable update, along with examples of using them and tests.
These modules are intended to be useful when HAL is retargetted to Mercury,
for implementing global variables (backtracking and non-backtracking), and
may also be useful for the debugger.
In order to implement these features, a new memory zone "global heap" was
added to the runtime system, for a heap which is not reclaimed on failure,
along with a pair of functions for copying terms to this heap.
runtime/mercury_deep_copy.c:
runtime/mercury_deep_copy.h:
Added two functions, MR_make_permanent() and
MR_make_partially_permanent(), which essentially do a deep copy of a
term to the global heap.
(In conservative GC grades, these functions actually do nothing).
runtime/mercury_engine.c:
runtime/mercury_engine.h:
Added fields global_heap_zone and e_global_hp (for the global heap
and its heap pointer) to the MR_mercury_engine_struct, along with
appropriate initialisation, etc.
Defined MR_heap_zone, MR_solutions_heap_zone, and
MR_global_heap_zone for convenient access to the corresponding field
of the relevant Mercury engine.
runtime/mercury_memory.c:
Added code for handling the size and zone size of the global heap.
runtime/mercury_regorder.h:
runtime/mercury_regs.h:
Defined MR_global_hp (the global heap pointer for general use),
along with corresponding other changes.
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
Added declarations and initialisation of the size and zone_size of
the global_heap.
Added an entry for MR_GLOBAL_HP_RN to print_register_usage_counts()
(plus missing entries for MR_SOL_HP_RN, MR_MIN_HP_REC and
MR_MIN_SOL_HP_REC).
New files:
extras/references/Mmakefile:
Mmakefile for building and testing these modules.
extras/references/README:
Description of contents of this directory.
extras/references/global.m:
A wrapper module for building a library containing the nb_reference,
reference and scoped_update modules.
extras/references/nb_reference.m:
Implements references which are not backtracked on failure.
extras/references/reference.m:
Implements references which *are* backtracked on failure.
extras/references/scoped_update.m:
Allows nested scoping of non-backtracking references.
extras/references/samples/Mmakefile:
extras/references/samples/max_of.m:
extras/references/samples/max_test.exp:
extras/references/samples/max_test.m:
An example of using a non-backtracking reference (to find the
maximum of the solutions generated by a predicate), with tests.
extras/references/tests/Mmakefile:
extras/references/tests/ref_test.exp:
extras/references/tests/ref_test.m:
Some tests of references (backtracking and non-backtracking) and
scoping.