Estimated hours taken: 2
Branches: main
Merge the changes from the dotnet-foreign branch which deal with
namespaces.
compiler/ilasm.m:
compiler/ilds.m:
compiler/mlds_to_il.m:
compiler/mlds_to_mcpp.m:
For the module foo.m, place all the code in a type called
mercury_code in the namespace foo rather than in the type foo and no
namespace. This helps avoid problems where you have a type and a
namespace at the top level with the same name.
Only output a namespace declarations if the namespace has a name.
library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
runtime/mercury_il.il:
Change to using the new convention for namespaces.
Estimated hours taken: 5
Branches: main
Updates to the runtime and library for .NET backend.
These changes mean the runtime and library will no longer work for Beta 1.
If you want to use Beta 1, you will have to use mercury 0.10.x.
library/.cvsignore:
Add .cpp .dll and .il files.
runtime/.cvsignore:
Add .dll files.
library/Mmakefile:
Add an assembly search patch to the MS_CLFLAGS
Work around bugs in the assembly cache installer by generating one
big .il file for the library.
Generate a strong name file and use it.
library/array.m:
Update the code to work correctly -- the MC++ compiler is now a bit
stricter about type casts.
library/exception.m:
Stop using an enum and use #defines -- the enum has stopped working.
(I don't have time to figure out why just now).
library/float.m:
library/math.m:
Some of the mathematical functions have changed names.
library/io.m:
Use an ascii encoder to generate ASCII output by default.
Without this we get Unicode UTF output, and it seems to like to
insert a BOM (byte-order-mark) which means Hello World doesn't work
anymore.
Add a stream reader and writer to the MercuryFileStruct.
library/library_strong_name.sn:
The strong name for this library.
runtime/mercury_il.il:
Insert .publickeytoken to identify the mercury assembly and mscorlib.
Add ['mscorlib'] assembly refs to System.Object and ['mercury'] for
mercury code.
Use box and unbox instructions instead of our hand-hacked boxing
classes. Remove the old conversion classes.
Add a missing return to mercury.Init::init_runtime()
runtime/mercury_mcpp.cpp:
Minor fix: s/Exception/System.Exception/
runtime/mercury_mcpp.h:
Fix the definition of MR_Array.
Use array syntax for macros that manipulate arrays.
Estimated hours taken: 2
Branches: main release
configure.in:
Check for foreign_proc, as we require it to work if we wish to
bootstrap.
library/*.m:
Turn foreign_code/3+ into foreign_proc by applying the
following subsitutions:
First turn all foreign_code into foreign_proc:
s/foreign_code\(/foreign_proc\(/g
Then turn back any foreign_proc with a string as its second
argument.
s/foreign_proc(\("[A-Za-z0-9+]*",[ \t\n]*")/foreign_code$1/g
Estimated hours taken: 0.5
library/array.m:
Sorted out minor confusion between output and temporary arrays
in samsort_up/8 that was causing the test cases to fail.
Estimated hours taken: 4
Various fixes for the GCC back-end.
library/array.m:
library/private_builtin.m:
library/sparse_bitset.m:
library/string.m:
library/table_builtin.m:
library/time.m:
Add #includes for header files needed by these modules.
compiler/modules.m:
Add the extra object files needed for the GCC back-end
(and for fact tables) to the .pic_os list as well as to
the .os list.
compiler/gcc.m:
Delete the second copy of a duplicated paragraph in the comments.
compiler/mlds_to_gcc.m:
Fix a bug that showed up after my recent change which added
an MLDS->MLDS optimization that converted assignments into
initializers. The bug was that the code here didn't handle
the case when an initializer for a local variable refers to
another local variable declared earlier in the same block.
Estimated hours taken: 3
library/array.m:
Removed mergesort in favour of samsort which has much better
performance on mostly sorted data and is within a hair as
good on random data.
Estimated hours taken: 4
Added sorting, fold and permutation functions/predicates to array.m.
library/array.m:
Added funcs sort/1, foldl/3, foldr/3.
Added pred permutation/4.
NEWS:
Recorded above in changes to library section.
Estimated hours taken: 2.5
Fix a bug that broke profiling in MLDS grades.
(Note that profiling is still broken in MLDS grades,
due to some other bug(s) that still remain.)
library/array.m:
library/builtin.m:
runtime/mercury.c:
Delete some unnecessary and harmful calls to MR_init_entry()
for procedures for which we were already automatically
generating calls to MR_init_entry(). The duplicate calls
broke profiling, since the profiler aborts if it detects
duplicate entries in the Prof.Decl file.
library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
library/exception.m:
runtime/mercury.c:
Document empty initialization functions better.
Estimated hours taken: 5
Avoid a dependency where the runtime depends on the library.
library/array.m:
runtime/mercury.c:
runtime/mercury.h:
runtime/mercury_type_info.h:
Move code for doing array comparisons and unifications into the std
library.
Estimated hours taken: 200
First implementation of the standard library in managed C++.
configure.in:
Autodetect the .NET SDK, and set MS_DOTNET_SDK_DIR based on it.
Find the IL assembler, and set ILASM.
compiler/inlining.m:
Turn off inlining of pragma_foreign_code with the IL backend.
compiler/mlds_to_c.m:
Add a comment questioning the foreign language interfacing still to be
done in this backend, and remove the "inline target code" from
this list (since it has been completed).
compiler/mlds_to_il.m:
Generate code for :- external. We generate a forwarding
function to the expected implementation in
<modulename>__c_code.cpp
Rename all the classes to use MixedCase, and to put them in the
mercury.runtime namespace.
compiler/mlds_to_ilasm.m:
Don't use the System or mercury namespaces by default.
Change the names of the runtime cpp files to mercury_mcpp.dll
and mercury_il.dll.
Use c_util to output unops and binops.
doc/user_guide.texi:
Document MS_CL_NOASM, MS_CLFLAGS and EXTRA_MS_CLFLAGS.
library/*.m:
Rename pragma c_code as pragma foreign_code("C", ...).
Add pragma foreign_code for MC++.
Only a fraction of the predicates are implemented, everything
else simply throws and exception when called.
Implementations of predicates marked with :- external are
provided as pragma foreign_code, but are commented out.
library/Mmakefile:
runtime/Mmakefile:
Add targets for building the dlls for the library.
runtime/mercury_mcpp.cpp:
runtime/mercury_mcpp.h:
Implementation of the runtime.
runtime/mercury_il.il:
This file mainly implements things that can't be written in
managed C++ (e.g. function pointers).
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Add rules for generating .dlls and .exes from .ils and .cpps.
Estimated hours taken: 5
Allow field access functions to take extra arguments.
Change the field update function names from `'field:='/2' to `'field :='/2'.
compiler/make_hlds.m:
Handle field names with arguments.
compiler/hlds_pred.m:
Add " :=" as the suffix for a field update function,
rather than ":=".
compiler/typecheck.m:
Update instances of `field:='/2 in comments.
compiler/det_util.m:
compiler/simplify.m:
`det_info_vartypes' was defined using the `field:=' syntax.
Change it into a normal predicate for bootstrapping.
library/array.m:
library/bt_array.m:
library/map.m:
Add field access functions `elem/2' and `'elem :='/3'.
For maps, the `elem' function calls `map__search',
so add field access functions `det_elem' and `det_elem :='
to call `map__lookup' and `map__det_update'.
NEWS:
doc/reference_manual.tex:
Document the changes.
Improve readability by changing occurrences
of `X^field' to `X ^ field'.
tests/hard_coded/typeclasses/record_syntax.{m,exp}:
Test field names with arguments.
tests/invalid/record_syntax_errors.err_exp:
Update the expected output.
Estimated hours taken: 16
Add support for using a different C calling convention for the
C functions generated by the MLDS back-end, if you're on x86
and you define MR_USE_REGPARM. The code do to this uses GNU C's
function attributes extension; it will only work if you have
the latest snapshot versions of gcc. So MR_USE_REGPARM is
not enabled by default.
compiler/ml_call_gen.m:
For higher-order calls and class method calls, assign the
function pointer to a local variable. This is needed for
current versions of gcc, since gcc doesn't support function
attributes on function types in function pointer type casts.
compiler/mlds_to_c.m:
Output "MR_CALL" in function declarations.
Also output a reference to MR_GRADE_VAR, like we do for the
LLDS back-end.
runtime/mercury_std.h:
Define MR_CALL. This is a macro that can expand to some
implementation-specific C extension to specify the
calling convention used for the MLDS back-end.
E.g. for gcc, on x86, if MR_USE_REGPARM is defined it
expands to `__attribute__((__regparm__(3), __stdcall__))'.
runtime/mercury_conf_param.h:
Document MR_USE_REGPARM.
runtime/mercury_grade.h:
Encode the setting of MR_USE_REGPARM in the mangled grade name.
runtime/mercury_types.h:
runtime/mercury.h:
runtime/mercury.c:
runtime/mercury_wrapper.h:
runtime/mercury_wrapper.c:
util/mkinit.c:
library/array.m:
library/builtin.m:
library/exception.m:
Use MR_CALL for functions that should have the
Mercury calling convention.
runtime/mercury_types.h:
runtime/mercury.h:
Move the definition of MR_Cont and MR_NestedCont from
mercury_types.h to mercury.h. This was needed to avoid a
cyclic header dependency problem and is also a good idea
anyway, since MR_Cont and MR_NestedCont are specific to the
MLDS back-end.
Estimated hours taken: 10
Make everything in the runtime use MR_ prefixes, and make the compiler
bootstrap with -DMR_NO_BACKWARDS_COMPAT.
runtime/mercury_*.[ch]
Add MR_ prefixes to all functions, global variables and almost all
macros that could pollute the namespace. The (intentional) exceptions
are
1. some function, variable, type and label names that already start
with MR_, mercury_, Mercury or _entry;
2. some standard C macros in mercury_std.h;
3. the macros used in autoconfiguration (since they are used in scripts
as well as the runtime, the MR_ prefix may not be appropriate for
those).
In some cases, I deleted things instead of adding prefixes
if the "things" were obsolete and not user visible.
runtime/mercury_bootstrap.h:
Provide MR_-less forms of the macros for bootstrapping and for
backward compatibility for user code.
runtime/mercury_debug.[ch]:
Add a FILE * parameter to a function that needs it.
compiler/code_info.m:
compiler/export.m:
compiler/fact_table.m:
compiler/llds.m:
compiler/llds_out.m:
compiler/pragma_c_gen.m:
compiler/trace.m:
Add MR_ prefixes to the C code generated by the compiler.
library/*.m:
Add MR_ prefixes to handwritten code.
trace/mercury_trace_*.c:
util/mkinit.c:
Add MR_ prefixes as necessary.
extras/concurrency/semaphore.m:
Add MR_ prefixes as necessary.
Estimated hours taken: 4
This is part 2 of a change that provides a register of all the types defined
in the program.
util/mkinit.c:
After part 1 of this change, each compiler-generated module has three
initialization functions: the old one (to register label addresses
etc), one to register type_ctor_infos, and one to register module
layouts for the debugger. However, only the first was invoked from
the mkinit generated <mainmodule>_init.c file.
This change invokes the other two as well. One complication is that
hand-written "modules" do not have the two new kinds of initialization
functions, so only their first initialization function should be
called. We do this by requiring those "modules" to have one of two
specific forms: an initial prefix of either sys_init or
mercury_sys_init.
scripts/c2init.in:
Rerrange the mechanism we use to allow the overriding of the locations
of the init files to be passed to mkinit. The previous mechanism used
a single environment variable, MERCURY_MOD_LIB_MODS, to hold the names
of these init files. While the default setting of this variable was
conditional on whether the --trace option was given to c2init
(including the init file for the browser only with --trace),
there was no way to override the default value in a similarly
conditional manner. This is now a problem, because including the
browser init file in the list of init files passed to mkinit will
cause mkinit to emit code that causes the browser's modules to be
linked in, without also linking in the libraries (e.g. -ldl) on which
the browser depends. The reason why this hasn't bitten us earlier
is that the code that drags in the browser was #ifdef'ed out
in the first initialization function; the reason why it would
bite us now is that it is *not* #ifdef'ed out in the second
initialization function (the one that register type_ctor_infos).
The new mechanism uses two environment variables, MERCURY_MOD_LIB_MODS
and MERCURY_TRACE_LIB_MODS, with the first normally containing
the filenames of the init files of the runtime and library directories
and the second the filename of the init file of the browser directory.
The value of the second environment variable is passed to mkinit
only if c2init is invoked with the --trace flag.
There is also a new environment variable MERCURY_TRACE_LIB_DIR,
which has a role parallel to MERCURY_MOD_LIB_DIR.
compiler/Mmakefile:
profiler/Mmakefile:
tools/bootcheck:
Specify the filename of the browser init file in
MERCURY_TRACE_LIB_MODS.
library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
Add code to initialization functions to register the type_ctor_infos
of hand-defined types.
Note that this code is in the usual initialization function, the one
called by do_init_modules(). Putting this code in a separate
initialization function that is called by do_init_modules_type_tables()
would require complicating mkinit.c considerably.
runtime/mercury_wrapper.c:
Make do_init_modules_type_tables() call do_init_modules(), so that
calling do_init_modules_type_tables() guarantees the registration
of all the type_ctor_infos in the program, including the hand-defined
ones.
runtime/mercury_context.c:
Make the name of the handwritten module follow the convention now
required by mkinit.
Estimated hours taken: 2
Get the compiler to bootstrap with -DMR_NO_BACKWARDS_COMPAT.
compiler/c_util.m:
compiler/rtti_out.m:
Add MR_ prefixes to various type names in generated code.
compiler/*.m:
browser/*.m:
library/*.m:
Add MR_prefixes to various type and function names in pragma C code.
runtime/*.[ch]:
trace/*.[ch]:
Add MR_prefixes to various type and function names in
hand-written code.
Estimated hours taken: 24
Bootstrap in the grade hlc.gc.memprof.
To analyse the generated Prof.* files you need to supply the option
--no-demangle to the profiler.
compiler/ml_code_gen.m:
Define MR_PROC_LABEL in pragma c_code.
compiler/mlds.m:
Add a new alternative to the type target_code_component which
records a mlds_entity_name. This information is needed when
outputing the MR_PROC_LABEL #define.
compiler/ml_elim_nested.m:
Changes due to the change to the type target_code_component.
compiler/mlds_to_c.m:
Define a new predicate mlds_maybe_output_init_fn which outputs an
initialisation function, if necessary. This body of the
initialisation function consists of calls to init_entry for each
function in the src module.
If profiling is turned on at each function call: call
MR_prof_call_profile(callee, caller) to record the arc in the call
graph.
If profiling is turned on each heap allocation call
MR_maybe_record_allocation().
Changes due to the change to the type target_code_component.
library/array.m:
library/builtin.m:
library/exception.m:
library/private_builtin.m:
library/std_util.m:
As c2init doesn't understand preprocessor directives we need to
define some empty initialisation functions.
trace/mercury_trace_vars.c:
Avoid a linking problem with MR_trace_ignored_type_ctors.
Add a dummy member to MR_trace_ignored_type_ctors so that the array
is never empty.
runtime/mercury.c:
Call MR_init_entry for each hand defined procedure.
runtime/mercury.h:
If profiling is turned on include the relevant header files.
runtime/mercury_goto.h:
Define MR_init_entry.
runtime/mercury_prof.c:
runtime/mercury_prof.h:
Make decl_fptr an extern global pointer so that mercury_wrapper.c
can call fclose on it.
runtime/mercury_wrapper.c:
Call fclose on decl_fptr.
Estimated hours taken: 3
[Mainly down to getting reaquainted with remote CVS]
Miscellaneous small library improvements.
library/array.m
Added `in' mode versions of array.m functions with `array_ui' modes.
This is handy for immutable arrays.
library/std_util.m
Added pred `isnt/2' to invert sense of semidet preds for higher
order programming. For example, where one might write
Odds = list__filter(odd, Xs)
one could now also write
Evens = list__filter(isnt(odd), Xs)
Added func `id/1' that computes the identity function.
Estimated hours taken: 5
Remove the need for and the definition of the general index predicate.
Instead, always call the type-specific index predicate from the type-specific
compare predicate.
The declaration of the general index predicate, and the declarations and
implementations of the index predicates on builtin types such as ints
will be deleted once the changes to the compiler have been bootstrapped
on all platforms.
compiler/unify_proc.m:
Always call the type-specific index predicate from the type-specific
compare predicate.
Do not generate bodies for type-specific index predicates for
equivalence types, since the compare predicate for such a type
does not call the index predicate.
compiler/make_hlds.m:
Do not generate type-specific index predicates for equivalence types,
since the compare predicate for such a type does not call the index
predicate.
compiler/hlds_module.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/dead_proc_elim.m:
Do not record the identity of type-specific index predicates, since
type_ctor_infos no longer need to know about these predicates.
compiler/type_ctor_info.m:
For the time being, fill the index_pred slot in type_ctor_infos
with a redundant reference to the unify predicate. The unify predicate
slot will later move this slot, to allow us to put the version number
as close to the start of the type_ctor_info as possible and to avoid
wasting full words on fields that need only small numbers of bits
(version number, type_ctor_rep, number of ptags used).
compiler/higher_order.m:
Update a comment.
runtime/mercury_type_info.h:
Rename the index_pred slot.
Update the definitions of the macros for filling in the special pred
slots to not take the entry label of the index pred as an argument,
since it is no longer needed.
runtime/mercury_ho_call.c:
Remove the code for the generic index predicate. At the default
optimization level, the compiler specializes away all references to
this predicate in the library, compiler etc, so this is safe to do,
and we can't keep the old implementation, since it depends on a slot
in the type_ctor_info that is no longer there.
library/array.m:
library/builtin.m:
library/private_builtin.m:
When invoking the macros for creating type_ctor_infos for builtin
and special types, do not pass the entry label of the index pred.
Estimated hours taken: 4
Some modifications to the standard library code to
get it to compile with `--high-level-code'.
(For a couple of files, namely std_util.m and
store.m, `-O0' is also needed.)
library/array.m:
library/benchmarking.m:
library/io.m:
library/private_builtin.m:
library/std_util.m:
library/store.m:
Add `#include' declarations that are needed when compiling
with --high-level-code.
Wrap `#ifndef MR_HIGHLEVEL_CODE' around definitions
of low-level C code that doesn't compile with --high-level-code.
library/exception.m:
library/std_util.m:
Add multiple inclusion guards to all the typedefs defined
inside `pragma c_header_code'.
This is necessary since each `pragma c_header_code' fragment
can be included in several automatically-generated header
files which all get included by a single C file.
library/builtin.m:
Implement copy/2 for --high-level-code.
Estimated hours taken: 8, plus about 12 hours by Tyson.
Remove type_ctor_layouts and type_ctor_functors where not needed.
Simplify type_ctor_layouts by removing code that generates (and
documentations for) particularly representations that are no longer used
now that we use type_ctor_reps.
Several files also had miscellaneous cleanups and documentation fixes,
the most important being the move of the type_ctor_info structures
for preds/funcs from runtime/mercury_type_info.c to library/builtin.m.
compiler/base_type_layout.m:
Simplify documentation.
Remove references to representations in type_ctor_layouts that
are no longer used.compiler/base_type_layout.m:
compiler/base_type_info.m:
Keep base_type_info__type_ctor_rep_to_int in sync with
MR_TypeCtorRepresentation.
runtime/mercury_grade.h:
runtime/mercury_cpp.h:
Move the definitions of MR_STRINGIFY and MR_PASTEn to the new file
mercury_cpp.h. Add MR_PASTEn for several new values of n, for use by
mercury_type_info.h.
runtime/mercury_type_info.h:
Define macros for creating type_ctor_info structures for builtin types.
These have NULL layout and functor fields.
Remove several obsolete macros.
runtime/mercury_layout_util.c:
Use the new macros for defining a dummy type_ctor_info.
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
Modify the implementation of some RTTI functions to use the layout
and functors structures only if they are defined.
runtime/mercury_type_info.c:
Modify MR_collapse_equivalences to use the type_ctor_rep, not the
functors indicator, to check for equivalence, since the latter is
not guaranteed to be present.
Move the type_ctor_info structure for preds/funcs to builtin.m.
library/array.m:
Use these macros to define the type_ctor_info structure for array.
library/builtin.m:
Use these macros to define the type_ctor_info structure for int,
float, character, string, saved succip etc values, and for preds
and funcs.
library/private_builtin.m:
Use these macros to define the type_ctor_info structure for type_infos,
type_ctor_infos, typeclass_infos and base_typeclass_infos.
Move a c_header_code to the section that needs it.
library/std_util.m:
Use the new macros to define the type_ctor_info structure for univ
and for std_util's own type_info type.
Modify the implementations of some RTTI predicates to use the
layout and functors structures only if they are defined.
Estimated hours taken: 24
Ensure that the none.gc and none grades compile using a compiler
other than gcc. This is not completely tested as lcc on linux can't
generate code for boehm_gc, and 'cc -std1' on the alpha runs out of
memory while trying to link the compiler. However the compiler does
bootstrap using just gcc and also with lcc with boehm_gc compiled by
gcc.
configure.in:
-Wl,opt1,opt2 syntax is not supported by lcc instead use -Wlopt1
-Wopt2.
compiler/export.m:
Only output a label declaration if that label is exported, as the
static label declarations are not legal C.
library/io.m:
compiler/stack_layout.m:
Replace escape sequence \x with \\x in pragma c code.
library/array.m:
library/std_util.m:
Define what the struct is before using it, so the correct size for the
struct can be calculated.
library/private_builtin.m:
Replace escape sequence \x with \\x in pragma c code.
Ensure that there is at least one local variable so that the
structure definition for holding the local vars contains something.
runtime/mercury_faultaddr.h:
Remove an unnecessary cast.
runtime/mercury_reg_workarounds.h:
#include sys/time.h for FD_ZERO().
runtime/mercury_stack_trace.h:
Remove an extraneous ',' which was causing warnings.
Estimated hours taken: 0.2
library/*.m:
Put MR_ prefixes on uses of string_const(), make_aligned_string()
variants, and COMPARE_EQUAL and friends, in order to allow bootstrap
with -DMR_NO_BACKWARDS_COMPAT.
Estimated hours taken: 1.5
Add version information to type_ctor_infos. This way bootstrapping is
easier and binary compatibility can be broken more slowly.
RTTI code can check version numbers before performing operations on
data structures that have recently changed their representation.
At the least they can abort cleanly and let you know that it's time
to re-compile, at best they can handle both forms of the data structure.
It is a bootstrapping problem that currently there is no version number
information in the appropriate slot in pre-built systems.
The version numbers start at 2 simply because 2 "occurs naturally"
much less often than 1 or 0. And 42 was becoming trite.
compiler/base_type_info.m:
Generate RTTI version numbers in compiler-generated
type_ctor_infos.
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
runtime/mercury_bootstrap.c:
runtime/mercury_type_info.c:
Add RTTI version numbers for handwritten type_ctor_infos.
runtime/mercury_type_info.h:
Add MR_RTTI_VERSION to define the current version of the RTTI
info and the first version: MR_RTTI_VERSION_INITIAL which
happens to have the value of 2.
Estimated hours taken: 8
Reorganize the routines for allocating and deallocating memory:
runtime/mercury_std.h:
runtime/mercury_misc.c:
runtime/mercury_memory.h:
runtime/mercury_memory.c:
- Put the routines in the proper place.
Previously the declarations and definitions of the memory
allocation/deallocation routines were spread amoungst
all four of these files; I moved the ones in mercury_std.h
and mercury_misc.c so that they are now all defined
in mercury_memory.{h,c}
- Avoid unnecessary duplication
The following routines did exactly the same thing,
modulo bugs(!):
allocate_bytes() and newmem()
deallocate_bytes() and oldmem()
make() and allocate_object()
make_many() and allocate_array()
- Use appropriate names.
I added `MR_' prefixes, and ensured that macros that are not
function-like macros use all uppercase. I also used a more
consistent naming scheme.
Previously the names used were
(1) checked_malloc, checked_realloc
(2a) allocate_bytes, deallocate_bytes, reallocate_bytes,
allocate_object, allocate_array, resize_array
(2b) newmem, oldmem, resizemem,
make, make_many, resize_many
The new names are
(1) MR_malloc, MR_free, MR_realloc,
MR_NEW, MR_NEW_ARRAY, MR_RESIZE_ARRAY
(2) MR_GC_malloc, MR_GC_free, MR_GC_realloc,
MR_GC_NEW, MR_GC_NEW_ARRAY, MR_GC_RESIZE_ARRAY
runtime/*.[ch]:
trace/*.[ch]:
library/array.m:
library/benchmarking.m:
library/io.m:
library/std_util.m:
extras/odbc/odbc.m:
extras/aditi/aditi.m:
Use the new names.
Estimated hours taken: 0.1
library/array.m:
Change the documentation to suggest using CFLAGS rather than
MGNUCFLAGS for `-DML_OMIT_ARRAY_BOUNDS_CHECKS'.
Estimated hours taken: 3
Fix problems that broke the `jump' and `fast' grades.
library/builtin.m:
library/private_builtin.m:
library/array.m:
library/std_util.m:
Use MR_MAYBE_STATIC_CODE() in initializers for type_ctor_infos,
to avoid a compilation error when code addresses are not valid
initializers. Call MR_INIT_TYPE_CTOR_INFO() to ensure that the
type_ctor_infos for c_pointer, type_info, type_ctor_info,
typeclass_info, base_typeclass_info, array, and univ are
initialized at runtime if they can't be initialized statically.
Estimated hours taken: 16
Changed all type_ctor_info structures to use the MR_TypeCtorInfo type. This
is primarily to reduce the number of conflicts when merging independent
changes to the type_ctor_info structures. As part of this, changed the type
of `string_const' to be `String' rather than `Word *', to avoid type errors
in the initialisers for compiler-generated type_ctor_infos.
compiler/llds_out.m:
Don't emit definitions for type_ctor_info structs; instead use
`MR_TypeCtorInfo_struct'.
Removed a couple of casts of `string_const's to type `String', since
they are no longer necessary.
compiler/llds.m:
Changed the entries for `string_const' and `multi_string_const' in
llds__const_type/2 to be `string' rather than `data_ptr'.
library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
runtime/mercury_bootstrap.c:
runtime/mercury_type_info.c:
Changed all the hand-defined type_ctor_info structures to just use
`MR_TypeCtorInfo_struct', and added appropriate casts to the
initialisers. This included removing what appears to have been the
last vestiges of `USE_TYPE_LAYOUT' conditionals since their use was
so broken that it would probably be easier to re-implement the same
functionality from scratch than to debug and rebuild on what was left.
runtime/mercury_type_info.h:
Introduced `struct MR_TypeCtorInfo_struct' as the name of the
(previously anonymous) struct which `MR_TypeCtorInfo' was a pointer
to.
Introduced `MR_DECLARE_TYPE_CTOR_INFO_STRUCT' for declaring
type_ctor_info structures, since `MR_DECLARE_STRUCT' generates
old-style names for type_ctor_infos.
runtime/mercury_deep_copy.c:
runtime/mercury_tabling.c:
library/std_util.m:
extras/exceptions/exception.m:
Changed some uses of `MR_DECLARE_STRUCT' to use
`MR_DECLARE_TYPE_CTOR_INFO_STRUCT' instead.
runtime/mercury_bootstrap.h:
Added some `#define's of some old type_ctor_info type names to be
`MR_TypeCtorInfo_struct', so that during bootstrapping the type
names generated by the old version of the compiler work with the new
scheme used in the manual definitions.
runtime/mercury_string.h:
Changed the type of the macro `string_const/2'. It used to cast to
`Word *', now it casts to `String'.
Estimated hours taken: 5
[This change was by Ralph Becket.
I'm just the person who reviewed it and committed it. -fjh.]
Add functions for the single output det predicates in a number
of modules in the standard library. Basically, for each
:- pred f(in, ..., in, out) is det.
I have added the declaration
:- func f(in, ..., in) = out.
and definition
f(X1, ..., Xn) = Y :-
f(X1, ..., Xn, Y).
library/char.m:
library/dir.m:
library/map.m:
library/string.m:
library/list.m:
library/set.m:
Make the changes described above.
library/array.m:
As above, except array input modes are all array_ui or
array_di as appropriate and array output modes are array_uo.
library/int.m:
Added forward versions of +/2, */2 and -/2 as plus/2, times/2
and minus/2 respectively, to make it easier to pass these
as arguments to higher-order predicates.
Also added func constants for max_int, min_int and bits_per_int.
library/integer.m:
Replaced local functions for list head, tail and length with
calls to equivalent functions now defined in list.m.
library/io.m:
Added func for error_message/2.
library/list.m:
Add functions det_head/1 and det_tail/1 which abort on null lists.
library/set.m:
Add functions map/2, filter_map/2 and fold/3.
library/std_util.m:
Added utility function to construct a pair object from its
arguments and general purpose higher order functions for
partial functions and for function composition, exponentiation
and exchanging the arguments of a binary function.
Estimated hours taken: 30 (including debugging)
Add MR_TYPECTOR_REP_* to the type_ctor_info to describe the
representation of this type.
We want to do this because it allows us to check quickly to see
what kind of data representation is being used. Previously this
information was spread throughout the type_ctor_layout and
type_ctor_functors data structures. It was complex to interpret
and contained a lot of unnecessary duplication.
We can now omit data structures such as the type_ctor_layout in many
cases (it is only necessary for discriminated unions). Because we rule
out some of the possible alternatives, the encodings used in the
type_ctor_layout can be simplified. Also, the functors indicator in
type_ctor_functors can be removed, as it subsumed by this data
structure.
Use this representation in code that uses RTTI.
compiler/base_type_info.m:
Add a missing alternative to the type_ctor_rep (this was a
bug).
library/array.m:
library/builtin.m:
library/private_builtin.m:
runtime/mercury_bootstrap.c:
Use MR_TYPECTOR_REP_* in the type_ctor_infos for builtin types.
library/std_util.m:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
Use MR_TYPECTOR_REP_* and MR_DISCUNION_TAG_* to dispatch on
data representations.
Also, fix a bug in deep_copy when copying floating point values.
I'm not sure when this stopped working, or if this is exactly
the right fix, but it is more correct than the previous code.
runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
Update code to use MR_TYPECTOR_REP_*.
Use a struct for type_ctor_info.
tests/hard_coded/Mmakefile:
tests/hard_coded/deep_copy.m:
tests/hard_coded/deep_copy.exp:
Add a test case for deep_copy.
Estimated hours taken: 0.5
Move the type_ctor_infos for array and univ into their proper places.
This change has bootstrapped on most of our platforms, but actually
causes trouble linking small programs (because it creates runtime ->
library dependencies). So we should move it as soon as possible.
library/array.m:
library/std_util.m:
Add type_ctor_info for array and univ.
runtime/mercury_bootstrap.c:
Remove type_ctor_info for array and univ.
Estimated hours taken: 4.5
Remove support for --args simple. We don't use it, we won't use it even for
experiments, and it is unnecessary complication.
If anybody were using --args simple, this would need bootstrapping, but
since nobody does, there is no need, and this can be committed as an
ordinary change.
compiler/options.m:
doc/user_guide.texi:
scripts/*.in:
scripts/*.sh-subr:
Remove the --args option.
compiler/globals.m:
Remove the args_method global and its access predicates.
compiler/handle_options.m:
Don't set the args_method global from the option.
compiler/arg_info.m:
Remove support for --args simple. This allows us to remove a now
redundant argument from an exported predicate.
compiler/mercury_compile.m:
Remove the code for passing -DCOMPACT_ARGS to the C compiler.
compiler/bytecode_gen.m:
compiler/fact_table.m:
compiler/follow_vars.m:
compiler/live_vars.m:
compiler/call_gen.m:
Don't pass the unnecessary argument to arg_info.
compiler/call_gen.m:
compiler/unify_gen.m:
Remove now unnecessary assertions.
compiler/hlds_pred.m:
Don't include an args_method in proc_infos; instead, include
a slot that says whether the procedure's address is taken or not.
(In most cases, this determined whether the args_method was
simple or compact.) We will need this bool in the near future
(when we generate layout structures for procedures whose address
is taken).
Modify the signatures of exported predicates to accommodate
this change to the data structure.
compiler/hlds_out.m:
Print the new slot, not the args_method.
compiler/lambda.m:
When creating procedures from lambdas, set the address-taken slot
to address_is_taken instead of setting up its args_method.
compiler/make_hlds.m:
Minor changes to conform to the changes in the signatures of
the predicates exported from hlds_pred.m.
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/dnf.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/modecheck_call.m:
compiler/pd_info.m:
compiler/post_typecheck.m:
compiler/unify_gen.m:
Minor changes to conform to the changes in the signatures of
the predicates exported from hlds_pred.m and make_hlds.m.
runtime/mercury_type_info.h:
Remove the conditional definition of the macros that provided
an argument-method-independent way of referring to the registers
holding the inputs and outputs of e.g. unification procedures.
We don't need the independence anymore, and using registers instead
of macros in the code ensures that maintainers are aware of register
reuse issues (e.g. they copy an input from r1 before overwriting it
with an output).
runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
Remove support for the args method component of the grade.
runtime/mercury_ho_call.c:
runtime/mercury_tabling.c:
library/*.m:
Conform to the changes in runtime/mercury_type_info.h by effectively
applying the #defines appropriate to compact args by hand.
Remove code and data structures only needed for simple args.
Remove comments needed only in the presence of uncertainty about
the args method.
Estimated hours taken: 0.4
Add a new predicate to array.m: array__map.
NEWS:
mention the new predicate.
library/array.m:
add the new predicate array__map/3.
Estimated hours taken: 8
During the writing of the RTTI paper, we decided that type_ctor_info
was a much better name than base_type_info.
Rename base_type* as type_ctor*, except we don't rename the modules
base_type_info and base_type_layout just yet.
Most of these changes were made using the following sed patterns:
s/base_type_info/type_ctor_info/g
s/base_type_layout/type_ctor_layout/g
s/base_type_functors/type_ctor_functors/g
s/BASETYPE_INFO/TYPE_CTOR_INFO/g
s/TYPEFUNCTORS/TYPE_CTOR_FUNCTORS/g
s/TYPELAYOUT/TYPE_CTOR_LAYOUT/g
s/BASE_TYPEINFO/TYPE_CTOR_INFO/g
s/BASE_TYPE_INFO/TYPE_CTOR_INFO/g
s/BaseTypeInfo/TypeCtorInfo/g
s/BaseTypeLayout/TypeCtorLayout/g
s/base_type(/type_ctor(/g
s/:- module type_ctor_info/:- module base_type_info/g
s/:- module type_ctor_layout/:- module base_type_layout/g
s/type_ctor_info__/base_type_info__/g
s/type_ctor_layout__/base_type_layout__/g
/import_module/s/type_ctor_info/base_type_info/g
/import_module/s/type_ctor_layout/base_type_layout/g
compiler/*.m:
library/*.m:
runtime/*.{c,h}:
profiler/demangle.m:
util/mdemangle.c:
Applied the above sed commands.
runtime/mercury_bootstrap.h:
Add bootstrapping #defines so the type_ctor_* substitutions in
the library don't cause link problems.
Delete some redundant bootstrapping definitions.
Estimated hours taken: 18
Make it possible to compile a module (e.g. std_util) without debugging,
while still allowing debuggable code called from that module via higher-order
predicates (e.g. solutions) to have a proper stack trace.
compiler/options.m:
Add the new option --stack-trace-higher-order.
compiler/mercury_compile.m:
Always invoke continuation_info and stack_layout, since it is no
longer the case that either all procedures or none get layout
structures generated for them, and the other modules are in a better
position to make that decision.
compiler/continuation_info.m:
Handle the extra tests required by the change to mercury_compile.m.
When we gather info about a procedure, remember whether that
procedure must have a procedure layout that includes the procedure id
section.
compiler/stack_layout.m:
Use the flag remembered by continuation_info to help decide
whether we need procedure layout structures.
Fix an old space wastage: after generating marker saying that
the second and later groups of fields of a procedure layout are
not present, do not generate another marker saying that the
third group of fields is not present. Since it was in the wrong
position, it did not have the right meaning; it only worked because,
due to the presence of the first marker, it was never looked at anyway.
compiler/code_gen.m:
Use the new capability of continuation_info.m to require
procedure layouts including procedure id sections for any predicate
that has higher-order arguments, if --stack-trace-higher-order is set.
compiler/globals.m:
Rename want_return_layouts as want_return_var_layouts, since this
is a more accurate representation of what the predicate does.
compiler/call_gen.m:
compiler/code_info.m:
Conform to the change in globals.m.
compiler/llds_out.m:
Separate the c_modules containing compiler-generated code into two
groups, those that define labels that have stack layouts and those
that don't. In most cases one or the other category will be empty,
but with --stack-trace-higher-order, the c_modules containing
higher-order procedures will have stack layouts, while others will
not.
Reorganize the way the way the initialization functions are generated,
by putting c_modules falling into different categories into different
bunches. c_module falling into the first category always have their
initialization code included, while those in the second category
have it included only if the old flag MR_MAY_NEED_INITIALIZATION
is set.
Delete the obsolete #define of MR_STACK_TRACE_THIS_MODULE.
Improve some predicate names, in an effort to prevent confusion
about what a "file" is (since the code uses more than one meaning,
given the presence of --split-c-files).
compiler/pragma_c_gen.m:
Fix an old bug: s/NONDET_FIXED_SIZE/MR_NONDET_FIXED_SIZE/.
Required for the change to library/string.m.
doc/user_guide.texi:
Document the new option.
runtime/mercury_goto.c:
Simplify the conditions under which labels get added to the label
table with:
- The macros init_{entry,label,local}_ai always add
the label to the label table without a layout structure.
- The macros init_{entry,label,local}_sl always add it with a layout
structure.
- Whether the macros init_{entry,label,local} with no suffix
add the label to the label table depends on the values of other
configuration parameters, but they will never include a layout
structure.
The intended use is that any label that has a layout structure should
be initialized with a _sl macro. Any other label that should always
be in the label table if the label table is needed at all (labels
such as do_fail) should be initialized with _ai. Everything else
should be initialized with a suffixless macro.
runtime/mercury_conf_params.c:
Remove MR_USE_STACK_LAYOUTS and MR_STACK_TRACE_THIS_MODULE, since
due to the simplification of mercury_goto.h, they are not used anymore.
runtime/mercury_stack_layout.h:
Remove the old macros for creating layout structures with bogus
contents, and replace them with new macros for creating layout
structures with meaningful contents.
runtime/mercury_engine.c:
runtime/mercury_wrapper.c:
Remove bogus layout structures. Ensure the labels defined here
always get into the label table.
runtime/mercury_ho_call.c:
Remove bogus layout structures. Add proper ones where necessary.
runtime/mercury_bootstrap.c:
runtime/mercury_type_info.c:
Remove bogus layout structures.
runtime/mercury_boostrap.h:
Add this new file for bootstrapping purposes.
Temporarily #define NONDET_FIXED_SIZE as MR_NONDET_FIXED_SIZE, since
pragma_c_gen.m refers to the former until the update to it gets
installed.
runtime/Mmakefile:
Add a reference to mercury_boostrap.h.
library/builtin.m:
Remove bogus layout structures.
library/array.m:
library/benchmarking.m:
library/private_builtin.m:
Remove bogus layout structures. Add proper ones.
library/std_util.m:
Remove bogus layout structures. Add proper ones.
Replace references to framevar(n) with references to MR_framevar(n+1).
Fix an old bug in code under #ifndef COMPACT_ARGS: in the
implementation of mercury____Compare___std_util__univ_0_0_i1, the
succip register was not being saved across the call to
mercury__compare_3_0.
library/string.m:
Remove the need for bogus layout structures, by converting the
implementation of string__append(out, out, in) from hand-written
C module into nondet pragma C code.
Estimated hours taken: 0.5
Another fix to my change to ensure that the declarations and definitions
for data constants specify the same linkage (extern or static).
This one is needed to make it work with --split-c-files.
runtime/mercury_goto.h:
Add an `MR_' prefix to the MODULE_STATIC_OR_EXTERN.
library/array.m:
library/builtin.m:
library/std_util.m:
extras/clpr/cfloat.m:
Use MR_MODULE_STATIC_OR_EXTERN instead of `static' on the hand-coded
definitions of the base_type_functors and base_type_layouts for
builtin types.
Estimated hours taken: 3
Ensure that the declarations and definitions for data constants
specify the same linkage (extern or static), because the C standard
says that if the linkage is different, then the behaviour is undefined.
This bug resulted in undefined symbol link errors for the RS/6000 AIX port.
compiler/llds_out.m:
When printing out declarations for data constants,
compute the linkage from the data_name, rather than
always assuming `extern'. When printing out definitions,
add a sanity check to ensure that the linkage that would be
computed from the data_name is the same as the linkage used
for the definition.
compiler/base_type_info.m:
Make base_type_infos always exported from the module, never local.
This is necessary to ensure that the linkage can be
computed from the data_name.
compiler/base_type_layout.m:
Make base_type_functors and base_type_info structures
always local to the module, rather than exported.
This is necessary to ensure that the linkage can be
computed from the data_name.
library/array.m:
library/builtin.m:
library/std_util.m:
Add `static' to the hand-coded definitions of the base_type_functors
and base_type_layouts for builtin types.
compiler/base_typeclass_info.m:
compiler/llds.m:
compiler/stack_layout.m:
Add comments pointing to the new predicate linkage/2 in
llds_out.m, to ensure that future maintenance doesn't break
the assumptions it makes.
Estimated hours taken: 1.5
Improve the multi-threaded execution support.
runtime/mercury_context.{c,h}:
Move the code for runnext from the .h file to the .c file -
it is reasonably large (in the thread_safe grades) so avoiding
the duplication is handy. It also makes debugging much easier!
Also, make scheduling a context as runnable append it to the
end of the runqueue, rather than consing it to the front. This
yeilds more useful behaviour for concurrent code that wants to
yeild in favour of any other runnable context.
library/math.m:
library/string.m:
library/io.m:
Add thread_safe to the flags for a whole bunch of predicates and
functions that are thread-safe.
Estimated hours taken: 0.5
library/*.m:
Convert
:- pragma(c_code, ...
to
:- pragma c_code(...
and introduce will_not_call_mercury in places where it is implicit
(this is in preparation for changing the default to may_call_mercury).
Estimated hours taken: 0.5
NEWS:
mention the changes to map and tree234.
library/map.m:
added map__foldl/4 and map__map_values/3 which forward to the
corresponding predicates in tree234.
library/tree234.m:
implement tree234__foldl and tree234__map_values.
Estimated hours taken: 0.2
library/array.m:
Fix comments about bounds checking - the "maximum" performance
recommendation can be improved by compiling the entire
module with bounds checking off, not just the bits that
get intermodule-optimized.
Estimated hours taken: 0.5
library/*.m:
compiler/*.m:
Undo Zoltan's bogus update of all the copyright dates.
The dates in the copyright header should reflect the years
in which the file was modified (and no, changes to the
copyright header itself don't count as modifications).