Estimated hours taken: 400
Branches: main
Implement the infrastructure for term size profiling. This means adding two
new grade components, tsw and tsc, and implementing them in the LLDS code
generator. In grades including tsw (term size words), each term is augmented
with an extra word giving the number of heap words it contains; in grades
including tsc (term size cells), each term is augmented with an extra word
giving the number of heap cells it contains. The extra word is at the start,
at offset -1, to leave almost all of the machinery for accessing the heap
unchanged.
For now, the only way to access term sizes is with a new mdb command,
"term_size <varspec>". Later, we will use term sizes in conjunction with
deep profiling to do experimental complexity analysis, but that requires
a lot more research. This diff is a necessary first step.
The implementation of term size profiling consists of three main parts:
- a source-to-source transform that computes the size of each heap cell
when it is constructed (and increments it in the rare cases when a free
argument of an existing heap cell is bound),
- a relatively small change to the code generator that reserves the extra
slot in new heap cells, and
- extensions to the facilities for creating cells from C code to record
the extra information we now need.
The diff overhauls polymorphism.m to make the source-to-source transform
possible. This overhaul includes separating type_ctor_infos and type_infos
as strictly as possible from each other, converting type_ctor_infos into
type_infos only as necessary. It also includes separating type_ctor_infos,
type_infos, base_typeclass_infos and typeclass_infos (as well as voids,
for clarity) from plain user-defined type constructors in type categorizations.
This change needs this separation because values of those four types do not
have size slots, but they ought to be treated specially in other situations
as well (e.g. by tabling).
The diff adds a new mdb command, term_size. It also replaces the proc_body
mdb command with new ways of using the existing print and browse commands
("print proc_body" and "browse proc_body") in order to make looking at
procedure bodies more controllable. This was useful in debugging the effect
of term size profiling on some test case outputs. It is not strictly tied
to term size profiling, but turns out to be difficult to disentangle.
compiler/size_prof.m:
A new module implementing the source-to-source transform.
compiler/notes/compiler_design.html:
Mention the new module.
compiler/transform_hlds.m:
Include size_prof as a submodule of transform_hlds.
compiler/mercury_compile.m:
If term size profiling is enabled, invoke its source-to-source
transform.
compiler/hlds_goal.m:
Extend construction unifications with an optional slot for recording
the size of the term if the size is a constant, or the identity of the
variable holding the size, if the size is not constant. This is
needed by the source-to-source transform.
compiler/quantification.m:
Treat the variable reference that may be in this slot as a nonlocal
variable of construction unifications, since the code generator needs
this.
compiler/compile_target_code.m:
Handle the new grade components.
compiler/options.m:
Implement the options that control term size profiling.
doc/user_guide.texi:
Document the options and grade components that control term size
profiling, and the term_size mdb command. The documentation is
commented out for now.
Modify the wording of the 'u' HLDS dump flag to include other details
of unifications (e.g. term size info) rather than just unification
categories.
Document the new alternatives of the print and browse commands. Since
they are for developers only, the documentation is commented out.
compiler/handle_options.m:
Handle the implications of term size profiling grades.
Add a -D flag value to print HLDS components relevant to HLDS
transformations.
compiler/modules.m:
Import the new builtin library module that implements the operations
needed by term size profiling automatically in term size profiling
grades.
Switch the predicate involved to use state var syntax.
compiler/prog_util.m:
Add predicates and functions that return the sym_names of the modules
needed by term size profiling.
compiler/code_info.m:
compiler/unify_gen.m:
compiler/var_locn.m:
Reserve an extra slot in heap cells and fill them in in unifications
marked by size_prof.
compiler/builtin_ops.m:
Add term_size_prof_builtin.term_size_plus as a builtin, with the same
implementation as int.+.
compiler/make_hlds.m:
Disable warnings about clauses for builtins while the change to
builtin_ops is bootstrapped.
compiler/polymorphism.m:
Export predicates that generate goals to create type_infos and
type_ctor_infos to add_to_construct.m. Rewrite their documentation
to make it more detailed.
Make orders of arguments amenable to the use of state variable syntax.
Consolidate knowledge of which type categories have builtin unify and
compare predicates in one place.
Add code to leave the types of type_ctor_infos alone: instead of
changing their types to type_info when used as arguments of other
type_infos, create a new variable of type type_info instead, and
use an unsafe_cast. This would make the HLDS closer to being type
correct, but this new code is currently commented out, for two
reasons. First, common.m is currently not smart enough to figure out
that if X and Y are equal, then similar unsafe_casts of X and Y
are also equal, and this causes the compiler do not detect some
duplicate calls it used to detect. Second, the code generators
are also not smart enough to know that if Z is an unsafe_cast of X,
then X and Z do not need separate stack slots, but can use the same
slot.
compiler/type_util.m:
Add utility predicates for returning the types of type_infos and
type_ctor_infos, for use by new code in polymorphism.m.
Move some utility predicates here from other modules, since they
are now used by more than one module.
Rename the type `builtin_type' as `type_category', to better reflect
what it does. Extend it to put the type_info, type_ctor_info,
typeclass_info, base_typeclass_info and void types into categories
of their own: treating these types as if they were a user-defined
type (which is how they used to be classified) is not always correct.
Rename the functor polymorphic_type to variable_type, since types
such as list(T) are polymorphic, but they fall into the user-defined
category. Rename user_type as user_ctor_type, since list(int) is not
wholly user-defined but falls into this category. Rename pred_type
as higher_order_type, since it also encompasses functions.
Replace code that used to check for a few of the alternatives
of this type with code that does a full switch on the type,
to ensure that they are updated if the type definition ever
changes again.
compiler/pseudo_type_info.m:
Delete a predicate whose updated implementation is now in type_util.m.
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Still treat type_infos, type_ctor_infos, typeclass_infos and
base_typeclass_infos as user-defined types, but prepare for when
they won't be.
compiler/hlds_pred.m:
Require interface typeinfo liveness when term size profiling is
enabled.
Add term_size_profiling_builtin.increase_size as a
no_type_info_builtin.
compiler/hlds_out.m:
Print the size annotations on unifications if HLDS dump flags call
for unification details. (The flag test is in the caller of the
modified predicate.)
compiler/llds.m:
Extend incr_hp instructions and data_addr_consts with optional fields
that allow the code generator to refer to N words past the start of
a static or dynamic cell. Term size profiling uses this with N=1.
compiler/llds_out.m:
When allocating memory on the heap, use the macro variants that
specify an optional offset, and specify the offset when required.
compiler/bytecode_gen.m:
compiler/dense_switch.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/goal_form.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/inst_match.m:
compiler/intermod.m:
compiler/jumpopt.m:
compiler/lambda.m:
compiler/livemap.m:
compiler/ll_pseudo_type_info.m:
compiler/lookup_switch.m:
compiler/magic_util.m:
compiler/middle_rec.m:
compiler/ml_code_util.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modecheck_unify.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/post_typecheck.m:
compiler/reassign.m:
compiler/rl.m:
compiler/rl_key.m:
compiler/special_pred.m:
compiler/stack_layout.m:
compiler/static_term.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
Minor updates to conform to the changes above.
library/term_size_prof_builtin.m:
New module containing helper predicates for term size profiling.
size_prof.m generates call to these predicates.
library/library.m:
Include the new module in the library.
doc/Mmakefile:
Do not include the term_size_prof_builtin module in the library
documentation.
library/array.m:
library/benchmarking.m:
library/construct.m:
library/deconstruct.m:
library/io.m:
library/sparse_bitset.m:
library/store.m:
library/string.m:
Replace all uses of MR_incr_hp with MR_offset_incr_hp, to ensure
that we haven't overlooked any places where offsets may need to be
specified.
Fix formatting of foreign_procs.
Use new macros defined by the runtime system when constructing
terms (which all happen to be lists) in C code. These new macros
specify the types of the cell arguments, allowing the implementation
to figure out the size of the new cell based on the sizes of its
fields.
library/private_builtin.m:
Define some constant type_info structures for use by these macros.
They cannot be defined in the runtime, since they refer to types
defined in the library (list.list and std_util.univ).
util/mkinit.c:
Make the addresses of these type_info structures available to the
runtime.
runtime/mercury_init.h:
Declare these type_info structures, for use in mkinit-generated
*_init.c files.
runtime/mercury_wrapper.[ch]:
Declare and define the variables that hold these addresses, for use
in the new macros for constructing typed lists.
Since term size profiling can refer to a memory cell by a pointer
that is offset by one word, register the extra offsets with the Boehm
collector if is being used.
Document the incompatibility of MR_HIGHTAGS and the Boehm collector.
runtime/mercury_tags.h:
Define new macros for constructing typed lists.
Provide macros for preserving the old interface presented by this file
to the extent possible. Uses of the old MR_list_cons macro will
continue to work in grades without term size profiling. In term
size profiling grades, their use will get a C compiler error.
Fix a bug caused by a missing backslash.
runtime/mercury_heap.h:
Change the basic macros for allocating new heap cells to take
an optional offset argument. If this is nonzero, the macros
increment the returned address by the given number of words.
Term size profiling specifies offset=1, reserving the extra
word at the start (which is ignored by all components of the
system except term size profiling) for holding the size of the term.
Provide macros for preserving the old interface presented by this file
to the extent possible. Since the old MR_create[123] and MR_list_cons
macros did not specify type information, they had to be changed
to take additional arguments. This affects only hand-written C code.
Call new diagnostic macros that can help debug heap allocations.
Document why the macros in this files must expand to expressions
instead of statements, evn though the latter would be preferable
(e.g. by allowing them to declare and use local variables without
depending on gcc extensions).
runtime/mercury_debug.[ch]:
Add diagnostic macros to debug heap allocations, and the functions
behind them if MR_DEBUG_HEAP_ALLOC is defined.
Update the debugging routines for hand-allocated cells to print the
values of the term size slot as well as the other slots in the relevant
grades.
runtime/mercury_string.h:
Provide some needed variants of the macro for copying strings.
runtime/mercury_deconstruct_macros.h:
runtime/mercury_type_info.c:
Supply type information when constructing terms.
runtime/mercury_deep_copy_body.h:
Preserve the term size slot when copying terms.
runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
Reduce code duplication by using a now standard macro for copying
strings.
runtime/mercury_grade.h:
Handle the two new grade components.
runtime/mercury_conf_param.h:
Document the C macros used to control the two new grade components,
as well as MR_DEBUG_HEAP_ALLOC.
Detect incompatibilities between high level code and profiling.
runtime/mercury_term_size.[ch]:
A new module to house a function to find and return term sizes
stored in heap cells.
runtime/mercury_proc_id.h:
runtime/mercury_univ.h:
New header files. mercury_proc_id.h contains the (unchanged)
definition of MR_Proc_Id, while mercury_univ.h contains the
definitions of the macros for manipulating univs that used to be
in mercury_type_info.h, updated to use the new macros for allocating
memory.
In the absence of these header files, the following circularity
would ensue:
mercury_deep_profiling.h includes mercury_stack_layout.h
- needs definition of MR_Proc_Id
mercury_stack_layout.h needs mercury_type_info.h
- needs definition of MR_PseudoTypeInfo
mercury_type_info.h needs mercury_heap.h
- needs heap allocation macros for MR_new_univ_on_hp
mercury_heap.h includes mercury_deep_profiling.h
- needs MR_current_call_site_dynamic for recording allocations
Breaking the circular dependency in two places, not just one, is to
minimize similar problems in the future.
runtime/mercury_stack_layout.h:
Delete the definition of MR_Proc_Id, which is now in mercury_proc_id.h.
runtime/mercury_type_info.h:
Delete the macros for manipulating univs, which are now in
mercury_univ.h.
runtime/Mmakefile:
Mention the new files.
runtime/mercury_imp.h:
runtime/mercury.h:
runtime/mercury_construct.c:
runtime/mercury_deep_profiling.h:
Include the new files at appropriate points.
runtime/mercury.c:
Change the names of the functions that create heap cells for
hand-written code, since the interface to hand-written code has
changed to include type information.
runtime/mercury_tabling.h:
Delete some unused macros.
runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
Use the new macros supplying type information when constructing lists.
scripts/canonical_grade_options.sh-subr:
Fix an undefined sh variable bug that could cause error messages
to come out without identifying the program they were from.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade_options.sh-subr:
scripts/mgnuc.in:
Handle the new grade components and the options controlling them.
trace/mercury_trace_internal.c:
Implement the mdb command "term_size <varspec>", which is like
"print <varspec>", but prints the size of a term instead of its value.
In non-term-size-profiling grades, it prints an error message.
Replace the "proc_body" command with optional arguments to the "print"
and "browse" commands.
doc/user_guide.tex:
Add documentation of the term_size mdb command. Since the command is
for implementors only, and works only in grades that are not yet ready
for public consumption, the documentation is commented out.
Add documentation of the new arguments of the print and browse mdb
commands. Since they are for implementors only, the documentation
is commented out.
trace/mercury_trace_vars.[ch]:
Add the functions needed to implement the term_size command, and
factor out the code common to the "size" and "print"/"browse" commands.
Decide whether to print the name of a variable before invoking the
supplied print or browse predicate on it based on a flag design for
this purpose, instead of overloading the meaning of the output FILE *
variable. This arrangement is much clearer.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
Supply type information when constructing terms.
browser/program_representation.m:
Since the new library module term_size_prof_builtin never generates
any events, mark it as such, so that the declarative debugger doesn't
expect it to generate any.
Do the same for the deep profiling builtin module.
tests/debugger/term_size_words.{m,inp,exp}:
tests/debugger/term_size_cells.{m,inp,exp}:
Two new test cases, each testing one of the new grades.
tests/debugger/Mmakefile:
Enable the two new test cases in their grades.
Disable the tests sensitive to stack frame sizes in term size profiling
grades.
tests/debugger/completion.exp:
Add the new "term_size" mdb command to the list of command completions,
and delete "proc_body".
tests/debugger/declarative/dependency.{inp,exp}:
Use "print proc_body" instead of "proc_body".
tests/hard_coded/nondet_c.m:
tests/hard_coded/pragma_inline.m:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
tests/valid/Mmakefile:
Disable the IL tests in term size profiling grades, since the term size
profiling primitives haven't been (and probably won't be) implemented
for the MLDS backends, and handle_options causes a compiler abort
for grades that combine term size profiling and any one of IL, Java
and high level C.
Estimated hours taken: 0.5
library/array.m:
Improve completeness guarantees by using if-then-else's to ensure that
operations that can throw an exception are really conditional on bounds
checks.
This also allows us to call the `unsafe' (unchecked) versions directly.
Estimated hours taken: 3
Branches: main
Have the compiler define the RTTI of the array type, instead of having
it be handwritten.
library/array.m:
Add a type definition for the array type, making it a foreign type
(MR_ArrayPtr) with the existing predicates array_equal and
array_compare as its unify and compare preds.
Change array_compare to return the result as uo, not out,
to make this possible.
Delete all the hand-written code and data structures needed by
RTTI, since they are now compiler-generated.
Delete the old casts from MR_Word to MR_ArrayType *, since
they are now not needed (MR_ArrayPtr is defined as MR_ArrayType *).
Add a macro to centralize the LVALUE_CAST we now need when calling
MR_incr_hp_msg (which assumes that it assigning to an MR_Word).
compiler/mlds_to_c.m:
Generate MR_ArrayPtr instead of MR_Array for array/1.
compiler/mlds.m:
Back out my earlier change to mlds.m, since it isn't needed for
bootstrapping anymore.
runtime/mercury_library_types.h:
runtime/mercury_types.h:
Move the definitions of MR_ArrayType, MR_ArrayPtr and MR_ConstArrayPtr
from mercury_library_types to mercury_types, since they can now be
referred to from any compiler-generated C file in high level C grades.
Estimated hours taken: 4
Branches: main
Get the mercury compiler working with ROTOR, the MS shared source CLI
implementation.
compiler/mlds_to_il.m:
ROTOR doesn't allow calli calls to be made tail calls, so
don't make them tail calls.
compiler/options.m:
Add the option --support-rotor-clr which avoids generating
code which can cause problems for the ROTOR CLR.
library/array.m:
Fix some function signatures which were incorrectly declared
as returning int rather than MR_bool, which the MS CLR accepts
but ROTOR doesn't.
runtime/Mmakefile:
Add a commented out rule for compiling mercury_il.il for
ROTOR.
runtime/mercury_il.il:
Add a `// REMOVE FOR ROTOR comment' to all the tail. prefixes
associatied with calli instructions.
doc/user_guide.texi:
Document --support-rotor-clr.
Estimated hours taken: 4
Branches: main
library/*.m:
Delete Mercury clauses that just call sorry/1.
I applied this change to all files except the following:
rtti_implementation.m (because in that case, there is no C
implementation) and profiling_builtin.m and table_builtin.m
(because new back-ends needn't support profiling or tabling;
the warnings with `--warn-stubs' for those would be just noise.)
library/array.m:
Provide C# code for the (in, array_uo) mode of array__copy/2,
by copying the code for the (array_ui, array_uo) mode.
library/math.m:
Provide Mercury implementations of some of the math functions.
Estimated hours taken: 0.25
Branches: main
library/array.m:
Document why we have chosen to represent arrays of size 0 as
the null pointer on the .NET backend.
Estimated hours taken: 1
Branches: main
Implement array__make_empty_array on the IL backend.
library/array.m:
Use the null pointer to signify an empty array in
array__make_empty_array. Check for this null pointer before
manipulating an array object in all the relevant places.
Estimated hours taken: 6
Branches: main
Enforce namespace cleanliness in the library and browser directories
as well as in the runtime and trace directories.
Mmake.common.in:
Move the rules check_namespace here (they used to be in the Mmakefiles
of the runtime and trace directories), together with the variables they
need. Generalize them to also handle the needs of the browser, library
and bytecode directories. The former two in particular need the
ability to check automatically generated .mh files.
Make all the rules used by check_namespace conditional on a macro
that is defined by the Makefiles in all the directories that are
checked for namespace cleanliness.
trace/Mmakefile:
runtime/Mmakefile:
Replace the old rules for check_namespace, which are now in
../Mmake.common.in, with the macros needed to control their behavior.
bytecode/Mmakefile:
Add the macros needed to control the behavior of the rules for
check_namespace.
Move the lists of files to the start, before the include of
../Mmake.common.
browser/Mmakefile:
library/Mmakefile:
Add the macros needed to control the behavior of the rules for
check_namespace.
runtime/RESERVED_MACRO_NAMES:
Update comments, and delete obsolete exceptions.
browser/RESERVED_MACRO_NAMES:
library/RESERVED_MACRO_NAMES:
New files to contain the exceptions from the naming scheme.
tools/bootcheck:
Invoke "mmake check_namespace" in the library and browser directories
as well as the runtime and the trace directories. Perform the
invocation before we delete the object files we are checking for
cleanliness.
Clean up object files in all stage2 directories, not just the library,
as soon as we can.
library/array.m:
library/builtin.m:
library/io.m:
library/time.m:
Fix namespace violations.
Estimated hours taken: 3
Branches: main
Remove the assumption on user supplied comparison predicates that
C(X, Y, =) implies X = Y (similarly for comparison functions). Our code
shouldn't need to assume this, and sometimes more general orderings are
useful (for example, when you only want to compare the key of a key-value
pair). The existing assumptions were not documented anywhere, so we now
document the remaining assumptions in builtin.m.
With this assumption gone the issue of the stability of library sorting
predicates that allow a user supplied ordering arises, since elements may
be equivalent according to the ordering even though they are not equal.
Therefore modify the documentation of standard library predicates to make
clear what we do with equivalent elements, and make minor modifications to
the code to ensure that it does as we claim.
Although the builtin comparison predicates are guaranteed to satisfy the
assumption, we nevertheless remove it from the implementation of predicates
in list.m that use builtin comparison. The rationale for this is that we
don't need the assumption, and it may not be robust if in future we ever
decide to allow user defined comparison.
NEWS:
Mention the changed assumptions about user supplied comparison
predicates and functions.
Mention the new predicate exported from list.m.
library/builtin.m:
Add types comparison_pred/1 and comparison_func/1, and corresponding
insts. Document the assumptions we make about comparison predicates
and functions.
library/list.m:
Modify sort/3, sort_and_remove_dups/3, merge/4 and
merge_and_remove_dups/4, as well as any functional versions, to use
the new types. Document the stability of sorting, and modify the
code to ensure that we conform to this.
Add remove_adjacent_dups/3, which takes a user supplied comparison
predicate and determines whether elements are duplicates based on
this, rather than the usual equality.
Modify the implementation of some predicates that use compare, to
avoid the unnecessary assumption.
Fix some spelling and grammatical errors.
library/array.m:
library/bt_array.m:
Modify the interface of {,bt_}array__bsearch to use the new types
and insts. Update the documentation.
tests/hard_coded/Mmakefile:
tests/hard_coded/stable_sort.exp:
tests/hard_coded/stable_sort.m:
A test case that checks the stability of list__sort.
Estimated hours taken: 20
Branches: main
Add support for interfacing Mercury with the MPS garbage collector.
This change is broken into three parts:
1. Import version 1.100.1 of the MPS kit into the Mercury
CVS repository, in the directory `mps_gc'.
2. Make some changes to the MPS kit for Mercury,
to support fully-conservative collection and tagged pointers,
and to wrap it in an interface that is similar to that of
the Boehm collector.
3. Modify the rest of the Mercury implementation
to support linking with the MPS kit instead
of the Boehm collector. This involved defining
`mps' as a new GC method and a new grade component.
This is part 3 of 3.
Mmake.workspace:
Include the MPS directories in the header file and library search
paths.
tools/bootcheck:
Link the mps_gc directory into the stage2 and stage3 directories.
Mmake.workspace:
runtime/Mmakefile:
scripts/ml.in:
For *.mps grades, link in mps.a.
(XXX ml.in is linking in libmps.a, which is wrong.)
runtime/Mmakefile:
trace/Mmakefile:
In the rule for `check_headers', which checks macro namespace
cleanliness, allow names to start with `MPS_' or `mps_'.
runtime/RESERVED_MACRO_NAMES:
Add `mercury_mps_h', which is used by mps_gc/code/mercury_mps.h
for its header guard. (Normally it would be better to use
uppercase for header guard macro names, but that would be
inconsistent with the coding style used in mps_gc/code.)
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade.sh-subr:
Handle the new `mps' GC method and grade component.
compiler/globals.m:
compiler/options.m:
doc/user_guide.texi:
Replace gc_method `conservative' with two alternatives
`boehm' and `mps'. ("--gc conservative" is still allowed,
and treated as equivalent to "--gc boehm".)
Add new function `gc_is_conservative' to globals.m.
compiler/mercury_compile.m:
compiler/handle_options.m:
Use `gc_is_conservative' rather than `= conservative'.
compiler/handle_options.m:
Handle the "mps" grade component.
(XXX need to document this in options.m and user_guide.texi)
compiler/compile_target_code.m:
Pass the appropriate C defines for the new GC methods.
compiler/mercury_compile.m:
Wrap the work-around for a Boehm GC bug inside `#ifndef MR_MPS_GC'.
library/array.m:
Use GC_FREE() rather than GC_free().
This is needed for two reasons:
- so that it works with MPS, which only defines GC_FREE
- so that it works with then Boehm collector when
GC debugging is enabled
library/benchmarking.m:
Output GC statistics for the MPS collector.
runtime/mercury.h:
runtime/mercury_heap.h:
runtime/mercury_init.h:
runtime/mercury_memory.h:
If MR_MPS_GC is defined, use mercury_mps.h rather than gc.h.
runtime/mercury_conf_param.h:
Add configuration macros MR_BOEHM_GC and MR_MPS_GC.
Set MR_CONSERVATIVE_GC if either of these is set.
Default to MR_BOEHM_GC if only MR_CONSERVATIVE_GC is set.
runtime/mercury_context.h:
runtime/mercury_deep_copy.h:
runtime/mercury_engine.h:
runtime/mercury_float.h:
runtime/mercury_heap.h:
Explictly #include "mercury_conf.h", so that
MR_CONSERVATIVE_GC will be set properly before it is tested.
runtime/mercury_grade.h:
Handle the .mps grade component.
runtime/mercury_memory.c:
runtime/mercury_wrapper.c:
runtime/mercury_memory_handlers.c:
Move the call to MR_setup_signals() earlier in the
initialization sequence, so that the MPS signal handlers
get installed after our signal handlers. This is needed
because our signal handlers assume that any signals that
they can't handle are fatal errors, which interfere's
with MPS's use of signal handlers for memory barriers.
runtime/mercury_wrapper.c:
Add code to initialize the MPS collector.
Put code which is specific to the Boehm collector inside
#ifdef MR_BOEHM_GC rather than #ifdef MR_CONSERVATIVE_GC.
runtime/mercury_wrapper.h:
Update a comment.
Estimated hours taken: 36
Branches: main
Harmonize the treatment of the builtin types by the runtime system across
the MLDS and LLDS C backends. (Their treatment by the .NET and Java backends
is unchanged, at least for now.)
Previously, the RTTI data structures and unify and compare predicates for the
builtin types were defined in runtime/mercury.c for the MLDS backend but in
library/{builtin,private_builtin,type_desc}.m for the LLDS backend. This
make several kinds of maintenance difficult, and more likely to be forgotten.
The two backends also had their generic unify/compare code in different modules
(mercury.c and mercuy_ho_call.c) and used distinct macros for defining RTTI
data structures. This change fixes those problems by defining a consistent
set of macros (with backend-specific implementations but backend-independent
semantics), concentrating the definitions of all the RTTI structures and of all
the unify and compare predicates for builtin types in a new module in the
runtime, mercury_builtin_types.[ch], and concentrating all the generic
unify/compare predicates in mercury_ho_call.[ch].
This change also makes the runtime use consistently module qualified names
for the RTTI data structures for the builtin types. Since they are not module
qualified by the Mercury compiler, we module qualify them by macros that map
the mmc-generated names to the ones expected by the runtime system. This makes
it easier to use the same macros in LLDS and MLDS grades.
runtime/mercury_builtin_types.[ch]:
New module to contain all the C code for the implementation of
unify and compare predicates for the builtin types. Its contents
comes from mercury.c in the runtime (for the MLDS C backend) and
builtin.m, private_builtin.m and type_desc.m in the library (for the
LLDS C backend).
The unify/compare predicates for tuples now report errors. This is
necessary because the tuple is a variable arity constructor. Their
previous implementations for the MLDS backend relied on only being
called from the generic unify/compare routines with a nonstandard
interface, being passed a typeinfo for the tuple type, rather than
the typeinfos for the arguments of the type constructor. This worked
because we don't currently specialize unifies/compares of tuple types,
but was a potential problem if we ever started to do such
specialization. The fix is to handle tuples in the generic
unify/compare routines, just as in the LLDS backend.
runtime/mercury_ho_call.c:
Move the generic unify/compare routines for the MLDS backend here
from mercury.c.
Conform to the coding standard wrt indentation.
runtime/mercury_ho_call.h:
Declare the generic unify/compare routines for both backends.
Delete a typedef that now needs to be in mercury_types.h to avoid
circular dependencies.
runtime/mercury_type_info.h:
Use the same macros for defining type_ctor_info structures for the MLDS
and LLDS backends.
This required moving the definitions of MR_UnifyFunc_N and
MR_CompareFunc_N here from mercury.c.
runtime/mercury_hlc_types.h:
A new file containing definitions of types needed by the MLDS C
backend. These definitions used to be in mercury.h, but now they are
needed in mercury_type_info.h, a header file that doesn't and shouldn't
include mercury.h. They can't easily be put in mercury_types.h because
they depend on mercury_std.h, and we are not allowed to include
mercury_std.h in mercury_types.h.
runtime/mercury.h:
Delete the definitions of the C types representing type_info and
pseudo_type_infos, since these are now in mercury_type_info.h.
#include mercury_type_info.h.
Delete the definitions now in mercury_hlc_types.h.
runtime/mercury.c:
Delete the definitions of the C types representing unify and compare
predicates, since these are now in mercury_type_info.h.
runtime/mercury_bootstrap.h:
Module qualify the RTTI data structures of the builtin types, since
it makes it easier to use the same macros to define RTTI structures
in the LLDS and MLDS backend. (Previously, mercury_bootstrap.h had
macros to delete such module qualification for the variable arity
types.)
runtime/mercury_types.h:
Move some type definitions from mercury_ho_call.h and
mercury_deep_profiling.h to mercury_types.h to prevent problems
with circular dependencies between header files.
runtime/mercury_debug.h:
Delete a #include to prevent a circular dependency.
runtime/mercury_profiling_builtin.[ch]:
A new module containing the {call,exit,redo,fail} port predicates
for deep profiling, moved here from library/profiling_builtin.m.
They are referred to by the implementations of the unify and compare
predicates of builtin types, and thus they need to be in the runtime
directory to avoid references from the runtime to the library.
runtime/Mmakefile:
Add the new files.
tools/make_port_code:
A script to generate runtime/mercury_profiling_builtin.[ch] fully
automatically.
library/array.m:
Use the new backend-independent macros to reduce the amount of code
that was duplicated for the two backends.
library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
Delete RTTI structures and unify and compare predicates
that are now in runtime/mercury_builtin_types.c.
library/profiling_builtin.m:
Replace the definitions of the predicates implementing the
{call,exit,redo,fail} port predicates with external declarations.
trace/mercury_trace_vars.c:
Use a now backend-independent macro to refer to a type_ctor_info.
trace/Mmakefile:
Do not define MERCURY_BOOTSTRAP_H, since mercury_bootstrap.h now
contains some definitions needed by code in the trace directory.
Replace it with MR_NO_BACKWARDS_COMPAT.
util/mkinit.c:
Module qualify the references to the RTTI structures of builtin types,
since the generated _init.c files don't include mercury_bootstrap.h.
Note that after this change has bootstrapped, we should be able to
delete those references, since they were only needed to give the
runtime access to the addresses of RTTI structures that used to be
defined in the library, but are now defined in the runtime.
Estimated hours taken: 120
Branches: main
Allow the library to compile in the grade il (high level data).
compiler/ml_util.m:
Add more types which need to be represented using the low level
representation because of how they are handled in the library.
compiler/mlds_to_il.m:
Remove an XXX which is no longer necessary.
Add the heap_pointer type to the list of types whose RTTI is defined
by hand.
library/exception.m:
Move the definition of Exception from the runtime to the local module.
This is needed for when univ/0 is no longer represented as a low level
type.
runtime/mercury_mcpp.cpp:
Remove the implementation of Exception that is now in exception.m.
library/Mmakefile:
The lowlevel Exception type is now defined in the library not the
runtime, so add rules to ensure that the foreign code is built in
the correct order.
library/io.m:
Reimplement io__stream as a foreign_type. This makes the code more
type safe and avoids problems with the different representation of
the io__stream type when using high and low level data.
Change io__command_line_arguments so that it throws an exception
when we use high level data, as I am yet to work out how to access
high level lists.
library/rtti_implementation.m:
Add a comment that get_subterm doesn't work with high level data.
Fix some bugs with the default versions of type_ctor_compare_pred and
type_ctor_unify_pred.
library/sparse_bitset.m:
Remove the foreign_proc implementation of make_bitset_elem as it
will not work with both data representations and their is a Mercury
implementation.
library/string.m:
Remove the foreign_proc implementation of all the predicates which
manipulate lists as they all have a Mercury implementation, as I am yet
to work out how to access high level lists.
Add a Mercury implementation for string__join_list.
runtime/mercury_mcpp.h:
library/array.m:
library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
Define and use typedefs where appropiate for type_info/0, type_info/1,
comparison_result/0 and univ/0, as there representation may change in
the future between using high level and low level data.
Estimated hours taken: 20
Branches: main
The tag bootstrap_20020613_intermod can be used to get a compiler which
compiles this change.
configure.in:
Test that the option --bug-intermod-2002-06-13 exists. This signifies
that the a bug in intermodule optimization for predicates which are
defined as both mercury and foreign code clauses.
library/array.m:
library/benchmarking.m:
library/builtin.m:
library/char.m:
library/construct.m:
library/deconstruct.m:
library/float.m:
library/gc.m:
library/int.m:
library/io.m:
library/library.m:
library/math.m:
library/private_builtin.m:
library/profiling_builtin.m:
library/rtti_implementation.m:
library/sparse_bitset.m:
library/std_util.m:
library/store.m:
library/table_builtin.m:
library/time.m:
library/type_desc.m:
Define a mercury version of every pragma foreign_proc.
Remove any foreign_procs which are not implemented yet.
Estimated hours taken: 0.2
Branches: main
library/*.m
Back out Pete's unreviewed change from yesterday.
It doesn't compile without a recent bug fix, but no
CVS tag was added.
Estimated hours taken: 16
Branches: main
Define a mercury version of every pragma foreign_proc, and remove any
foreign_procs which just throw an exception that the code is not implemented.
library/array.m:
library/benchmarking.m:
library/builtin.m:
library/char.m:
library/construct.m:
library/deconstruct.m:
library/exception.m:
library/float.m:
library/gc.m:
library/int.m:
library/io.m:
library/library.m:
library/math.m:
library/private_builtin.m:
library/profiling_builtin.m:
library/rtti_implementation.m:
library/sparse_bitset.m:
library/std_util.m:
library/store.m:
library/string.m:
library/table_builtin.m:
library/time.m:
library/type_desc.m:
Define a mercury version of every pragma foreign_proc, and remove any
foreign_procs which just throw an exception that the code is not
implemented.
Estimated hours taken: 8
Branches: main
library/array.m:
extras/trailed_update/tr_array.m:
runtime/mercury_deep_copy_body.h:
runtime/mercury_library_types.h:
Allocate arrays on the Mercury heap, using MR_incr_hp_msg(),
rather than using MR_GC_malloc(). This is needed for accurate
GC, to ensure that the objects pointed to by the array elements
will get traced by the collector.
Estimated hours taken: 0.25
Branches: main, release
library/array.m:
Fix an undetected unique mode error -- the input array
to 'elem :=' should have mode `array_di', not `array_ui'.
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.