Estimated hours taken: 4
Branches: main
Add MR_ prefixes to the remaining non-prefixed symbols.
This change will require all workspaces to be updated
The compiler will start generating references to MR_TRUE,
MR_bool, etc., which are not defined in the old runtime
header files.
runtime/mercury_std.h:
Add MR_ prefixes to bool, TRUE, FALSE, max, min,
streq, strdiff, strtest, strntest, strneq, strndiff,
strntest, NO_RETURN.
Delete a commented out definition of `reg'.
runtime/mercury_tags.h:
Add an MR_ prefix to TAGBITS.
configure.in:
runtime/mercury_goto.h:
runtime/machdeps/i386_regs.h/mercury_goto.h:
Add an MR_ prefix to PIC.
runtime/mercury_conf_param.h:
Allow non-prefixed PIC and HIGHTAGS to be defined on
the command line.
runtime/mercury_bootstrap.h:
Add backwards compatibility definitions.
RESERVED_MACRO_NAMES:
Remove the renamed macros.
compiler/export.m:
compiler/ml_code_gen.m:
Use MR_bool rather than MR_Bool (MR_Bool is
meant to be for references to the Mercury type
bool__bool).
runtime/mercury_types.h:
Add a comment the MR_Bool is for references to
bool__bool.
*/*.c:
*/*.h:
*/*.m:
Add MR_ prefixes.
Estimated hours taken: 0.45
Branches: main
library/array.m:
- Don't include the array type name in the error message,
since doing so could inhibit optimization.
- Move the call to throw/1 into the body of out_of_bounds_error/3,
to improve code locality.
- Improve the error message: say explicitly "index ... not in range".
Estimated hours taken: 8
Branches: main
Soon foreign_proc will be impure by default unless given a promise_pure
or promise_semipure attribute. The syntax has been accepted for some
time, we now add the necessary declarations.
browser/dl.m:
compiler/timestamp.m:
library/*.m:
tests/hard_coded/unused_float_box_test.m:
Add promise_pure and promise_semipure declarations for foreign_procs.
Estimated hours taken: 0.3
Branches: main
library/array.m:
Added a new function out_of_bounds_error/3 to construct more
informative index-out-of-bounds error messages. Altered
array__lookup and array__set to use the new function.
Estimated hours taken: 6
Branches: main
Generate exceptions rather than program aborts for domain errors
and out of bounds array accesses.
Improve the handling of the arithmetic functions.
library/float.m:
library/int.m:
compiler/builtin_ops.m:
Handle division by zero with an exception rather than a
program abort.
Add int__unchecked_quotient and float__unchecked_quotient,
which don't check for division by zero.
Remove reverse modes of the arithmetic functions in float.m.
Richard O'Keefe pointed out a while ago that they don't work
because of rounding errors.
Remove the long obsolete `int__builtin_*' and
`float__builtin_float_*' predicates.
library/math.m:
library/array.m:
Generate exceptions rather than program aborts.
The bounds and domain checks are now implemented in
Mercury, so they do not need to be duplicated for each
target language.
library/exception.m:
Remove predicate throw_string/1, which was used to throw
exceptions from array.m across the C interface, which would
not work in LLDS grades.
NEWS:
Document the changes.
tests/general/float_test.m:
tests/general/string_format_test.m:
tests/hard_coded/ho_solns.m:
tests/hard_coded/ho_univ_to_type.m:
tests/hard_coded/qual_strang.m:
tests/hard_coded/qual_strung.m:
Rename occurrences of `builtin_*'.
Estimated hours taken: 0.5
Branches: main
library/array.m:
Use MR_Array for generic Unify and Compare preds.
(but these are still unimplemented).
runtime/mercury_mcpp.h:
Define MR_Array to be System.Array not Object[].
Estimated hours taken: 2
Branches: main
Implement the array operations (in C#).
Add flags for handling compiling C# files in the library directory.
library/Mmakefile:
Add /t:module to the C# compiler flags.
We need this because by default C# creates assemblies, but we
expect the library to be composed of modules.
library/array.m:
Implement most of the functionality of arrays in C#.
We still need to implement
array__make_empty_array/1
array__resize/4
array__shrink/3
array__copy/3
array__make_empty_array requires more RTTI support (to figure
out what type of array to create), and array__copy requires an
implementation of deep_copy.
You need the latest changes to the compiler which map array(T)
to System.Array or T[] for this to compile.
scripts/Mmake.rules:
Add ALL_MS_CSCFLAGS to the C# compiler flags.
scripts/Mmake.vars.in:
Add MS_CSCFLAGS and associated flags.
Estimated hours taken: 80
Branches: main
Major enhancements of the deep profiler. The most important ones are:
- The addition of several new classes of preferences, including: the use of
colour, boxing, sorting, summarizing of higher order call sites, and time
formats.
- Making preferences persistent across different queries, so that once a
preference is set, it "sticks" until the user changes it. Previously,
preferences stuck during query sequences of the same command type.
- Several new command types:
- listing all the modules of the program
- listing all the procedures in a module
- listing all the callers of a procedure,
grouped by calling call site, procedure, module, or clique,
and filtering out certain classes of ancestors
- jumping into the call graph close to the action
- restarting the server (useful when the data file changes)
- New optional columns showing time per call, allocations per call and words
allocated per call.
- Can now display memory consumption in bytes as well as words.
- More robustness in the face of external events, e.g. machine shutdowns.
- Fix a bug reported by Tom in the summaries of procedures that make higher
order calls.
The new functionality required adding some fields to ProcStatic structures;
as a result, compilers and runtime systems that have this change are
incompatible with compilers and runtime systems before this change in deep
profiling grades. (They of course remain compatible in other grades.)
compiler/deep_profiling.m:
compiler/layout.m:
compiler/layout_out.m:
Add two new fields to ProcStatic structures, one giving the line number
of procedure's context and one stating whether the procedure is
exported from its module.
compiler/layout.m:
Be consistent about filename vs file_name in field names.
compiler/*.m:
Minor changes to handle the new fields.
deep_profiler/interface.m:
Define new command types, modify some of the parameters of existing
ones, and delete obsolete ones. Define the types and predicates used
by the new system of preferences, Update the predicates for recognizing
and generating queries accordingly.
Make the order of declarations and definitions more consistent.
deep_profiler/split.m:
Complete rewrite of the only predicate of this module. The old split
predicate deleted any empty substrings resulting from the breakup of
the original string. The new one preserves them, because they are
needed by the new encoding scheme used in interface.m.
deep_profiler/query.m:
New module, containing code dealing with the computational issues of
queries. Some of its code is old (from server.m), much of it is new.
deep_profiler/html_format.m:
New module, containing code dealing with HTML formatting. Some of its
code is old (from server.m), much of it is new.
deep_profiler/top_procs.m:
New module, containing code dealing with issues involving sorting
by various criteria. Some of its code is old (from server.m),
much of it is new.
deep_profiler/exclude.m:
New module to handle contour exclusion. This means that when listing
the callers of a procedure, we display the nearest parent that is *not*
excluded by virtue of being in a given module. The set of modules so
excluded forms a contour drawn through the program.
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_server.m:
deep_profiler/server.m:
Minor changes to adapt to the new system of preferences.
deep_profiler/array_util.m:
Add a mode to foldl2.
deep_profiler/io_combinator.m:
Add predicates for reading in sequences of ten things.
deep_profiler/measurements.m:
Add a function needed by new code.
deep_profiler/timeout.m:
Make the profiler robust in the face of signals.
deep_profiler/canonical.m:
Some more work towards working canonicalization; not there yet.
Move some procedures to profile.m, since other modules also need them
now.
deep_profiler/profile.m:
Add the new fields to ProcStatic structures.
Record the word size.
Record more information about procedures whose activation counters are
ever zeroed, in order to allow query.m to avoid giving misleading
information in cases where a procedure calls itself through a higher
order call site.
Record information about the modules of the program.
Add a bunch of lookup predicates, some moved from canonical.m.
deep_profiler/call_graph.m:
Minor changes to conform to changes in profile.m.
deep_profiler/startup.m:
Fill in the new parts of the profile data structure.
deep_profiler/read_profile.m:
Read the new fields in ProcStatic structures.
Read in the id of the root node as a fixed part of the header,
not as a node.
Read in the word size.
Make it easier to find all the debugging output sites.
Record, for each call site which can call more than one procedure,
whether this causes the caller's ProcStatic structure's activation
count to be zeroed.
runtime/mercury_deep_profiling.h:
Add the new fields to ProcStatic structures.
runtime/mercury_deep_profiling.c:
Write out the new fields to ProcStatic structures.
Write out the id of the root node as a fixed part of the header,
not as a node.
Write out the word size.
Remove incorrect L suffixes on constants.
Record that the artificial procedure "parent of main" is called once,
not zero times, to avoid division by zero when computing per-call
statistics.
runtime/mercury_deep_profiling_hand.h:
Add the new fields to the macros for creating ProcStatic structures.
runtime/mercury_ho_call.c:
library/array.m:
library/builtin.m:
library/exception.m:
library/std_util.m:
Add the new fields to the invocations of those macros.
Estimated hours taken: 1
Fix a bootstrapping problem for the hlc.gc backend.
library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
Provide empty definitions of all the handwritten sys_init functions for
the hlc.gc backend.
Estimated hours taken: 500
Branches: main
Implement deep profiling; merge the changes on the deep2 branch back
onto the trunk.
The main documentation on the general architecture of the deep profiler
is the deep profiling paper.
doc/user_guide.texi:
Document how to use the deep profiler.
deep_profiler:
deep_profiler/Mmakefile:
A new directory holding the deep profiler and its mmakefile.
Mmakefile:
Add targets for the new directory.
Add support for removing inappropriate files from directories.
deep_profiler/interface.m:
The deep profiler consists of two programs: mdprof_cgi.m, which acts
as a CGI "script", and mdprof_server.m, which implements the server
process that the CGI script talks to. Interface.m defines the
interface between them.
script/mdprof.in:
A shell script template. ../configure uses it to generate mdprof,
which is a wrapper around mdprof_cgi that tells it how to find
mdprof_server.
deep_profiler/mdprof_cgi.m:
The CGI "script" program.
deep_profiler/mdprof_server.m:
The top level predicates of the server.
deep_profiler/profile.m:
The main data structures of the server and their operations.
deep_profiler/read_profile.m:
Code for reading in profiling data files.
deep_profiler/startup.m:
Code for post-processing the information in profiling data files,
propagating costs from procedures to their ancestors and performing
various kinds of summaries.
deep_profiler/server.m:
Code for responding to requests from the CGI script.
deep_profiler/cliques.m:
Code to find cliques in graphs.
deep_profiler/array_util.m:
deep_profiler/util.m:
Utility predicates.
deep_profiler/dense_bitset.m:
An implementation of (part of) the set ADT with dense bit vectors.
deep_profiler/measurements.m:
Operations on profiling measurements.
deep_profiler/timeout.m:
An implementation of a timeout facility.
deep_profiler/conf.m:
Functions that depend on autoconfigured settings.
configure.in:
Find out what command to use to find the name of the local host.
Install deep profiling versions of the standard library along with the
other profiling versions.
runtime/mercury_conf.h.in:
Add some macros for deep_profiler/conf.m to use.
library/profiling_builtin.m:
runtime/mercury_deep_call_port_body.h:
runtime/mercury_deep_leave_port_body.h:
runtime/mercury_deep_redo_port_body.h:
A new library module that implements deep profiling primitives.
Some of these primitives have many versions, whose common code is
factor is factored out in three new include files in the runtime.
compiler/deep_profiling.m:
New module to perform the program transformations described in the
paper.
compiler/notes/compiler_design.html:
Document the new compiler module.
compiler/mercury_compiler.m:
Invoke the new module in deep profiling grades. Allow global static
data to be generated by deep_profiling.m.
compiler/options.m:
Add options to turn on deep profiling and (for benchmarking purposes)
control its implementation.
Add an optiooption disable tailcall optimization in the LLDS backend,
to help benchmarking deep profiling.
compiler/jumpopt.m:
compiler/optimize.m:
Obey the option to disable tailcalls.
compiler/handle_options.m:
Handle the implications of deep profiling.
compiler/modules.m:
In deep profiling grades, automatically import profiling_builtin.m.
compiler/prog_util.m:
doc/Makefile:
library/library.m:
Handle the new builtin module.
compiler/export.m:
In deep profiling grades, wrap deep profiling code around exported
procedures to handle the "unscheduled call" aspects of callbacks to
Mercury from the foreign language.
compiler/higher_order.m:
profiler/demangle.m:
util/demangle.c:
When creating a name for a higher-order-specialized predicate, include
the mode number in the name.
compiler/add_trail_ops.m:
compiler/type_util.m:
Move c_pointer_type from add_trail_ops to type_util, so it can also be
used by deep_profiling.m.
compiler/hlds_goal.m:
Add a new goal feature that marks a tail call, for use by
deep_profiling.m.
compiler/hlds_pred.m:
Add a new field to proc_info structures for use by deep_profiling.m.
Add a mechanism for getting proc_ids for procedure clones.
Remove next_proc_id, an obsolete and unused predicate.
compiler/hlds_data.m:
Add a new cons_id to refer to the proc_static structure of a procedure.
compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/dependency_graph.m:
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/ml_unify_gen.m:
compiler/opt_debug.m:
compiler/prog_rep.m:
compiler/rl_exprn.m:
compiler/switch_util.m:
compiler/unify_gen.m:
Trivial changes to handle the new cons_id, goal feature and/or
proc_info argument.
compiler/rtti.m:
Add a utility predicate for extracting pred_id and proc_id from an
rtti_proc_label, for use by hlds_out.m
compiler/layout.m:
compiler/layout_out.m:
compiler/llds.m:
compiler/llds_common.m:
Add support for proc_static and call_site_static structures.
compiler/layout_out.m:
compiler/llds_out.m:
Add code for the output of proc_static structures.
compiler/code_util.m:
Make code_util__make_proc_label_from_rtti a function, and export it.
util/mkinit.c:
compiler/llds_out.m:
compiler/layout.m:
compiler/modules.m:
Add support for a fourth per-module C function, for writing out
proc_static structures (and the call_site_static structures they
contains).
Since proc_static structures can be referred to from LLDS code (and not
just from other static structures and compiler-generated C code),
reorganize the declarations of static structures slightly.
Change the schema for the name of the first per-module C function
slightly, to make it the addition of the fourth function easier.
The scheme now is:
mercury__<modulename>__init
mercury__<modulename>__init_type_tables
mercury__<modulename>__init_debugger
mercury__<modulename>__write_out_proc_statics
Improve formatting of the generated C code.
library/*.m:
runtime/mercury.c:
runtime/mercury_context.c:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_tabling.c:
runtime/mercury_trace_base.c:
runtime/mercury_wrapper.c:
trace/mercrury_trace.[ch]:
trace/mercrury_trace_declarative.c:
trace/mercrury_trace_external.c:
trace/mercrury_trace_internal.c:
Conform to the new scheme for initialization functions for hand-written
modules.
compiler/mercury_compile.m:
library/benchmarking.m:
runtime/mercury_conf_param.h:
runtime/mercury.h:
runtime/mercury_engine.c:
runtime/mercury_goto.c:
runtime/mercury_grade.h:
runtime/mercury_ho_call.c:
runtime/mercury_label.[ch]:
runtime/mercury_prof.[ch]:
Add an MR_MPROF_ prefix in front of the C macros used to control the
old profiler.
compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Make deep profiling completely separate from the old profiling system,
by making the deep profiling grade independent of MR_MPROF_PROFILE_TIME
and the compiler option --profile-time.
library/array.m:
library/builtin.m:
library/std_util.m:
runtime/mercury_hand_unify_body.h:
runtime/mercury_hand_compare_body.h:
In deep profiling grades, wrap the deep profiling call, exit, fail
and redo codes around the bodies of hand-written unification
and comparison procedures.
Make the reporting of array bounds violations switchable between
making them fatal errors, as we currently, and reporting them by
throwing an exception. Throwing an exception makes debugging code
using arrays easier, but since exceptions aren't (yet) propagated
across engine boundaries, we keep the old behaviour as the default;
the new behaviour is for implementors.
runtime/mercury_deep_profiling_hand.h:
New file that defines macros for use in Mercury predicates whose
definition is in hand-written C code.
library/exception.m:
runtime/mercury_exception_catch_body.h:
runtime/mercury_stacks.h:
In deep profiling grades, wrap the deep profiling call, exit, fail
and redo codes around the bodies of the various modes of builtin_catch.
Provide a function that C code can use to throw exceptions.
library/benchmarking.m:
library/exception.m:
library/gc.m:
library/std_util.m:
runtime/mercury_context.[ch]:
runtime/mercury_engine.[ch]:
runtime/mercury_debug.c:
runtime/mercury_deep_copy.c:
runtime/mercury_overflow.h:
runtime/mercury_regs.h:
runtime/mercury_stacks.h:
runtime/mercury_thread.c:
runtime/mercury_wrapper.c:
Add prefixes to the names of the fields in the engine and context
structures, to make code using them easier to understand and modify.
runtime/mercury_deep_profiling.[ch]:
New module containing support functions for deep profiling and
functions for writing out a deep profiling data file at the end of
execution.
runtime/mercury_debug.[ch]:
Add support for debugging deep profiling.
Add support for watching the value at a given address.
Make the buffered/unbuffered nature of debugging output controllable
via the -du option.
Print register contents only if -dr is specified.
runtime/mercury_goto.h:
runtime/mercury_std.h:
Use the macros in mercury_std.h instead of defining local variants.
runtime/mercury_goto.h:
runtime/mercury_stack_layout.h:
runtime/mercury_stack_trace.c:
runtime/mercury_tabling.c:
trace/mercury_trace.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_vars.c:
Standardize some of the macro names with those used in the debugger
paper.
runtime/mercury_heap.h:
Add support for memory profiling with the deep profiler.
runtime/mercury_prof.[ch]:
runtime/mercury_prof_time.[ch]:
Move the functionality that both the old profiler and the deep profiler
need into the new module mercury_prof_time. Leave mercury_prof
containing stuff that is only relevant to the old profiler.
runtime/mercury_prof.[ch]:
runtime/mercury_strerror.[ch]:
Move the definition of strerror from mercury_prof to its own file.
runtime/mercury_wrapper.[ch]:
Add support for deep profiling.
Add suppory for controlling whether debugging output is buffered or
not.
Add support for watching the value at a given address.
runtime/Mmakefile:
Mention all the added files.
scripts/mgnuc.in:
Add an option for turning on deep profiling.
Add options for controlling the details of deep profiling. These
are not documented because they are intended only for benchmarking
the deep profiler itself, for the paper; they are not for general use.
tools/bootcheck:
Compile the deep_profiler directory as well as the other directories
containing Mercury code.
Turn off the creation of deep profiling data files during bootcheck,
since all but one of these in each directory will be overwritten
anyway.
Add support for turning on --keep-objs by default in a workspace.
tools/speedtest:
Preserve any deep profiling data files created by the tests.
trace/mercury_trace.c:
Trap attempts to perform retries in deep profiling grades, since they
would lead to core dumps otherwise.
util/Mmakefile:
Avoid compile-time warnings when compiling getopt.
tests/*/Mmakefile:
tests/*/*/Mmakefile:
In deep profiling grades, switch off the tests that test features
that don't work with deep profiling, either by design or because
the combination hasn't been implemented yet.
Estimated hours taken: 3
Branches: main
Fix bugs with naming changes recently made to the .NET backend.
We are now generating modulename__cpp_code classes instead of
modulename__c_code, but not all parts of the .NET backend and the
runtime/library had been updated.
We are also generating simpler mangling for method names, but some of
the hard-coded references to method names needed to be updated.
compiler/mlds_to_il.m:
compiler/mlds_to_mcpp.m:
Use __cpp_code where required.
Rename generate_method_m_code as generate_method_mcpp_code.
library/Mmakefile:
Copy the runtime DLLs to the current directory, this is required
so that you can install into the global assembly cache using
gacutil.
library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
runtime/mercury_il.il:
Use __cpp_code where required, update to use new mangling
convention.
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.