Estimated hours taken: 0.3
Branches: main
Change representation of mutvar(T) for Java back-end in std_util library.
library/std_util.m:
Defined the type mutvar(T) as mercury.std_util.Mutvar, a trivial class
with a single member field to hold the variable.
Modified the implementation of the following procedures in Java:
new_mutvar/2
get_mutvar/2
set_mutvar/2
Estimated hours taken: 5
Branches: main
Implement some library procedures for the Java back end.
library/std_util.m:
Defined the type mutvar(T) as an array of java.lang.Objects (which
will always be size 1)
Implemented the following procedures in Java:
get_registers/3
check_for_floundering/1
discard_trail_ticket/0
swap_heap_and_solutions_heap/0
partial_deep_copy/3
reset_solutions_heap/1
new_mutvar/2
get_mutvar/2
set_mutvar/2
java/runtime/VA_PseudoTypeInfo_Struct0.java:
This new file is a workaround which allows std_util.m to successfully
compile in grade Java.
Estimated hours taken: 2
Branches: main
Begin porting the the library just to use C# as its foreign_proc
language.
library/array.m:
library/char.m:
library/exception.m:
library/float.m:
library/int.m:
library/math.m:
library/private_builtin.m:
library/rtti_implementation.m:
library/std_util.m:
Trivial changes to convert MC++ to C#.
library/table_builtin.m:
Delete some unused MC++ functions.
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: 24
Branches: main
Various fixes to make the Java back-end work better.
compiler/ml_code_gen.m:
Make sure that no module in the generated MLDS
tries to import itself.
Also, add some XXX comments about the handling of
model_semi foreign_procs for Java and IL.
compiler/ml_code_util.m:
Fix a bug with the handling of `top_unused' modes with `--det-copy-out'.
compiler/mlds_to_java.m:
Add an XXX comment about the problem with type names clashing
with constructor names.
Add an XXX comment about ignoring `pragma foreign_import'
and `pragma export' for Java.
Fix the code so that we handle `foreign_decl' and `foreign_code'
for Java properly -- previously, we were generating code for
`foreign_decl' in the wrong place, and `foreign_code' was just
ignored.
Handle procedures defined as `external' by calling `extern_Foo',
rather than generating a declaration with no body, because
Java syntax doesn't allow that.
Fix a bug where some names weren't getting mangled properly.
Fix some bugs where it was not generating correct package
names or module qualifiers for modules in the Mercury
standard library.
library/Mmakefile:
Add support for the `java' grade.
This involved adding new targets `javas' and `classes',
and making the main `library' target depend on these if
the grade is `java'.
library/builtin.m:
Add (stub) Java implementations of various builtins:
- the type_ctor_infos for the builtin types int, string, character
- builtin.unify/2 and builtin.compare/3
library/private_builtin.m:
Add (stub) Java implementations of various builtins:
- the type_ctor_info for private_builtin.type_info/1
- builtin_compare_int/3, builtin_compare_string/3,
builtin_strcmp/3
library/math.m:
- Fix a couple of bugs in the Mercury code for "log" and "log2".
library/std_util.m:
Provide a Java implementation for cc_multi_equal/2.
Avoid a compiler warning for the Mercury implementation
of semidet_succeed and semidet_fail.
library/store.m:
Rename the constructor for the `store/1' type,
to work around a bug in the Java back-end.
library/string.m:
Fix bugs in the Mercury implementation of string__contains_char
and string__split.
Provide a Java implementation of string__length.
library/type_desc.m:
Provide Java implementations of type_of/1 and has_type/2.
Provide (stub) implementations of the builtin types type_desc/0
and type_ctor_desc/0.
Estimated hours taken: 4
Branches: main
Ensure that the global heap and solutions heap are not used
in accurate GC grades.
runtime/mercury_conf_param.h:
Define new parameters MR_RECLAIM_HP_ON_FAILURE
and MR_MIGHT_RECLAIM_HP_ON_FAILURE. These will
not be defined for accurate GC grades.
runtime/mercury_engine.h:
runtime/mercury_engine.c:
Only allocate the solutions heap and the global heap
if MR_MIGHT_RECLAIM_HP_ON_FAILURE is set.
library/std_util.m:
Don't define MR_RECLAIM_HP_ON_FAILURE, since it is now
defined in runtime/mercury_conf_param.h.
library/exception.m:
When an exception is throw, reset the heap iff
MR_RECLAIM_HP_ON_FAILURE is set, rather than iff
MR_CONSERVATIVE_GC is not set.
runtime/mercury_deep_copy.h:
runtime/mercury_deep_copy.c:
Change MR_make_permanent() and MR_make_long_lived() so that they
copy data to the global heap iff MR_MIGHT_RECLAIM_HP_ON_FAILURE
is set, rather than iff MR_CONSERVATIVE_GC is not set.
Estimated hours taken: 1.5
Branches: main
library/builtin.m:
library/io.m:
library/library.m:
library/private_builtin.m:
library/string.m:
library/std_util.m:
library/table_builtin.m:
library/type_desc.m:
runtime/mercury_mcpp.cpp:
Use .NET string literals rather than using C string literals and
having them be then implicitly converted to .NET strings.
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: 4
Branches: main
Implement deep_copy for reference types.
This is needed for accurate GC.
library/private_builtin.m:
compiler/mlds_to_gcc.m:
runtime/mercury_builtin_types.h:
runtime/mercury_construct.c:
runtime/mercury_hlc_types.h:
runtime/mercury_mcpp.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.h:
runtime/mercury_type_info.h:
runtime/mercury_unify_compare_body.h:
Add a new built-in type `private_builtin.ref(T)' and a
corresponding new type_ctor_rep `TYPE_CTOR_REP_REFERENCE'.
library/std_util.m:
library/store.m:
library/benchmarking.m:
Use private_builtin.ref/1 instead of c_pointer.
Estimated hours taken: 9
Branches: main
Finish off Peter Ross's partially-completed set of changes to
use `cc_multi' instead of `cc_nondet' for various predicates in
deconstruct.m and std_util.m. Also, fix a bug in his changes that
broke `deconstruct.arg_cc' in the asm_fast.gc.par grade.
library/std_util.m:
Changed named_argument_cc from `cc_nondet' to `cc_multi'.
library/deconstruct.m:
Delete the cc_nondet mode of `named_arg',
and replace it with a new cc_multi predicate `named_arg_cc'.
Also, fix a bug where univ_arg_idcc was declared
`will_not_call_mercury' but was nevertheless calling Mercury code.
NEWS:
Document the interface changes mentioned above.
Also, reorganize the description of all the changes relating
to incorrect use of `cc_nondet' into a single section.
Estimated hours taken: 80
Branches: main
A first implementation of the inter-module analysis framwork.
Currently only unused argument analysis is supported.
The current inter-module analysis scheme using `.trans_opt' files
has some major limitations. The compilation dependencies introduced
by `.trans_opt' files are too complicated for Mmake without major
limitations on which modules can use the contents of which `.trans_opt'
files. Also, the `.trans_opt' file system only computes greatest fixpoints,
which is often too weak to find opportunities for optimization.
A better solution is to provide a library which manually handles
the dependencies introduced by inter-module analysis, and can deal with
the complications introduced by cyclic module dependencies.
TODO:
- support other analyses, e.g. termination, type specialization
- dependency tracking and invalidation after source modifications
- garbage collection of unused versions
- least fixpoint analyses
analysis/Mmakefile:
analysis/mer_analysis.m:
analysis/analysis.m:
analysis/analysis.file.m:
The analysis library.
analysis/README:
Description and design documentation.
Mmake.workspace:
Mmakefile:
compiler/Mmakefile:
tools/bootcheck:
Link the analysis library into mercury_compile.
compiler/hlds_module.m:
Store analysis information in the module_info.
compiler/options.m:
doc/user_guide.texi:
Add an option `--intermodule-analysis'.
compiler/mercury_compile.m:
Call the analysis library to write the gathered
information at the end of a compilation.
compiler/unused_args.m:
Call the analysis library to retrieve information
about imported procedures. This replaces code which
used the `.opt' files.
Change the names created for unused arguments procedures
to include the arguments removed, rather than a sequence
number. I think Zoltan is working on a change to name
mangling, so I haven't updated the demangler.
compiler/prog_util.m:
Generate the new predicate names for unused_args.m.
library/std_util.m:
Add a polymorphic version of unit, which is useful
for binding type variables.
compiler/modules.m:
scripts/Mmake.vars.in:
Clean up files created by the analysis framework
in `mmake realclean'.
util/mdemangle.c:
profiler/demangle.m:
Document the change in the name mangling of procedures with
unused arguments.
configure.in:
Check for state variables and fixes for some typeclass bugs.
tests/warnings/Mmakefile:
tests/warnings/unused_args_analysis.{m,exp}:
Test case.
Estimated hours taken: 1
Branches: main
Fix some incorrect behaviour when attempting to use the
include_details_cc mode of various predicates.
library/deconstruct.m:
Constrain arg and limited_construct so that they are only called for
the do_not_allow and canonicalize cases, so that users get an error
message when attempting to use the include_details_cc mode.
Rewrite det_arg so that it work for the include_details_cc case.
library/std_util.m:
Rewrite argument_cc to use arg_cc.
Estimated hours taken: 0.25
Branches: main
Avoid ambiguous overloading problems with two types in std_util having
a no data constructor.
library/std_util.m:
Rename the no data constructor in maybe_arg to no_arg.
library/deconstruct.m:
Use the new data constructor name.
Estimated hours taken: 2
Branches: main
Implemented limited_deconstruct_cc in Mercury.
library/deconstruct.m:
Implement limited_deconstruct_idcc as a cc_multi predicate
with the success of the predicate encoded into a maybe type,
as it is impossible to implement it as cc_nondet.
Change the C code version of limited_deconstruct_idcc to match
the Mercurys version behaviour.
Delete the bogus modes of limited_deconstruct/5 and implement
them as limited_deconstruct_cc/3 instead.
library/std_util.m:
Change limited_deconstruct_cc to have the correct determinism
and type signature.
runtime/mercury_ml_deconstruct_body.h:
Add a new #define which controls whether we save a success
indicator into SUCCESS_INDICATOR.
NEWS:
Document the changes to interfaces of limited_deconstruct and
limited_deconstruct_cc.
tests/hard_coded/deconstruct_arg.m:
Update the test case to test this new functionality.
Estimated hours taken: 6
Branches: main
Implement arg_cc in Mercury using rtti_implementation.
library/deconstruct.m:
Implement univ_arg_idcc as a cc_multi predicate with the
success of the predicate encoded into a maybe type, as it is
impossible to implement is as cc_nondet.
Change the C code version of univ_arg_idcc to match the
Mercury versions behaviour.
Delete the bogus modes of arg/4 and implement them as arg_cc/3
instead.
library/std_util.m:
Introduce a new type maybe_arg which is returned by arg_cc to
return its result.
Change arg_cc to have the correct determinism and type
signature.
Add utility predicates which allow us to construct values of
the maybe type from a foreign language.
runtime/mercury_ml_arg_body.h:
Add a new #define which controls whether or not success is
saved into SUCCESS_INDICATOR.
NEWS:
Document the changes to interface of arg and arg_cc.
tests/hard_coded/deconstruct_arg.m:
Update the test case to test this new functionality.
Estimated hours taken: 20
Branches: main
Fix several occurrences of a bug that prevented the compiler from passing
all the tests in deep profiling grades. We now pass all the tests in deep
profiling grades.
Some additional changes were useful in tracking this bug down. Using C types
to represent deep profiling data structures allowed us to delete a bunch of
casts and thus eliminate them as potential bug locations. Another was to fix
some bugs in low level debugging support.
In light of the fragility of the deep profiling invariants, always check them
when writing out deep profiling data files. Since mdprof depends on these
invariants, they have to be checked somewhere, and we already have code for the
checks in the runtime.
Reenable tail recursion support in deep profiling grades, since it now works.
(The bug this change fixes used to occur most in tail recursive procedures,
which is why previously I turned it off.)
compiler/options.m:
Reenable tail recursion support in deep profiling grades.
runtime/mercury_unify_compare_body.h:
Fix the bug that prevented us from passing all the tests with
invariants checked and tail recursion support enabled. The bug was
that in several cases, the code in mercury_unify_compare_body.h
did not invoke the appropriate deep profiling routines and thus
did not fill in the deep profiling data structure they were supposed to
fill in, breaking an invariant.
There were several instances of this bug: unify, compare and
compare_representation on tuples, and compare_representation on
functions, predicates and user-defined types.
These oversights were possible because the actions of returning an
answer and filling in the deep profiling data structures (in deep
profiling grades) were separate. If one omitted the latter, tests could
still work in all grades except deep profiling grades.
The fix therefore uses one macro (return_compare_answer or return
unify_answer, depending on the the operation) to fill in the deep
profiling data structure (in deep profiling grades) and return the
answer, making it impossible to forget to do the former.
The new approach treats compare_representation the same as compare,
and gathers the same information for it.
runtime/mercury_ho_call.c:
Factor out some commonalities in the definitions of the MR_ProcStatic
data structures used by the code in mercury_unify_compare_body.h.
Change a macro name to support the changes in
mercury_unify_compare_body.h.
Change the module name of compare_representation/3 from std_util to
builtin, to match unify/2 and compare/3.
compiler/deep_profiling.m:
Treat compare_representation/3 the same way as we treat compare/3.
library/builtin.m
library/std_util.m
Move the declaration of compare_representation/3 from std_util to
builtin, to make it easier to handle it the same way as compare/3.
Since it is just a variant of compare/3 and is at least as built
into the implementation, it belongs there anyway.
library/profiling_builtin.m:
Use C types to represent deep profiling data structures.
Delete the casts that are redundant after this change.
Fix formatting of foreign_procs.
runtime/mercury_deep_profiling.c:
As mentioned above, always check the invariants of the deep profiling
data structures when writing them out.
runtime/mercury_deep_profiling.h:
Avoid a warning about nested declarations of variable "i".
runtime/mercury_deep_rec_depth_body.h:
Delete a bunch of casts we don't need anymore.
runtime/mercury_wrapper.[ch]:
Initialize a couple of predicate names in the low level debug support
to "" instead of NULL. The code that accesses these variables passes
them to strcmp directly, which lead to core dumps. We could change the
accessing code to test for NULL, but since that code is executed on
every call when low level debugging is enabled, that would lead to
even greater slowdowns, which we can do without.
To avoid a warning about casting away const, make the variables
involved "const char *" instead of plain "char *"; we don't want
to update the pointed-to strings anyway.
tools/bootcheck:
In profiling grades, write out profiling data files by default, and
require the use of an option to turn them off. This is needed to make
sure that the deep profiling invariants are checked by default.
tests/hard_coded/compare_rep_usereq.m:
tests/hard_coded/compare_representation.m:
Avoid hard-coding the name of the module defining
compare_representation/3.
Estimated hours taken: 40
Branches: main
Output Managed C++ code using the same mechanisms as we do for C#
code, rather than using pragma_c_gen to generate MC++ code. This
fixes the problem that functions couldn't be defined in MC++, and also
should make the code more maintainable in the future as MC++ is much
more similar to C# than to C.
compiler/mlds.m:
Add a new field to outline_foreign_proc. This field has
information which links the mlds variables with the variable
names used in the foreign code.
compiler/ml_code_gen.m:
Generate a foreign proc for MC++ the same way we generate a
foreign proc for C#.
Generate the data for the new field in outline_foreign_proc.
Use the context of the string which contains the pragma foreign
proc body for the context of the foreign proc. This ensures that
error messages refer to the correct line number.
compiler/mlds_to_il.m:
Add to the list of foreign languages defined in the module to
include those which don't have a foreign_proc defined in them.
Move the relevant code from atomic_statement_to_il to
generate_method so that we handle external procedures correctly.
compiler/mlds_to_ilasm.m:
Call mlds_to_managed.
compiler/ml_backend.m:
Add the new module and remove mlds_to_mcpp and mlds_to_csharp.
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
Minor changes to handling the new field in outline_foreign_proc.
compiler/mlds_to_csharp.m:
compiler/mlds_to_mcpp.m:
Removed files whose functionality has been subsumed by
mlds_to_managed.
library/construct.m:
library/float.m:
library/io.m:
library/std_util.m:
library/type_desc.m:
Changes required to get the library to be able compile in the
ilc grade.
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: 4
Branches: main
Some more improvements for accurate GC.
library/std_util.m:
Don't do heap reclamation on failure in builtin_aggregate
and builtin_do_while if accurate GC is enabled, since
accurate GC currently doesn't support heap reclamation
on failure (for reasons explained in the comments in
compiler/ml_elim_nested.m).
Also, define the `heap_pointer' type here as equivalent to
the one in private_builtin, rather than using c_pointer,
so that it gets the correct RTTI for a heap pointer.
runtime/mercury_deep_copy_body.h:
Don't complain about saved heap pointers unless they actually
point into the Mercury heap. This is needed to handle the
null values used for saved heap pointers in std_util.m when GC
is enabled.
Estimated hours taken: 16
Branches: main
Three changes related to accurate GC:
(1) Fix the handling of forwarding pointers.
(2) Change the interface to MR_(agc_)deep_copy() so that the first argument is
a value, not a pointer; the only reason that it was made a pointer was
because of the previous, broken, code for handling forwarding pointers.
(3) Delete the code for handling saved heap pointers, since it doesn't work
properly, and because the code conflicted with change (2).
The method this code used is not the right one to use, anyway, so the
effort of maintaining it would be a waste.
It doesn't work properly for two reasons:
(i) For heap reclamation on failure to work at all,
we also need at least some degree of liveness-accuracy.
Otherwise a local variable may get initialized to point
to the heap, then the heap is reset, then the memory
is overwritten with new allocations, and then a collection
occurs, at which point the local variable now points to
a value of the wrong type.
(ii) The method of handling saved heap pointers during GC
means that we lose heap reclamation on failure after a
GC occurs. A better method would be to just allocate a
word of heap space at each choice point.
runtime/mercury_deep_copy_body.h:
runtime/mercury_deep_copy.h:
runtime/mercury_deep_copy.c:
Rewrite the code handling forwarding pointers:
store forwarding pointers in the object being copied,
not in the pointer to it, and use a bitmap to distinguish
which objects contain forwarding pointers.
Change the interface to MR_(agc_)deep_copy() so that the first
argument is a value, not a pointer.
runtime/mercury_accurate_gc.c:
Add code to MR_garbage_collect() to initialize the forwarding
pointer bitmap.
runtime/mercury_accurate_gc.c:
library/builtin.m:
library/private_builtin.m:
library/exception.m:
library/std_util.m:
Update calls to MR_(agc_)deep_copy() to reflect the new interface.
runtime/mercury_accurate_gc.h:
runtime/mercury_accurate_gc.c:
Delete the code for handling saved heap pointers.
runtime/mercury_type_info.c:
compiler/mlds_to_c.m:
When allocating type_infos or typeclass_infos on the Mercury heap,
allocate an extra word at the start, for use as a forwarding
pointer. With most objects, we can just overwrite the fields
of the old copy of the object (in the "from-space"), but we
can't do that for type_infos or typeclass_infos, since they need
to remain valid during garbage collection, because the GC's
tracing code uses them.
Estimated hours taken: 5.5
Branches: main
Implement compare_representation/3, which is like compare except that it
is cc_multi, and it doesn't abort on non-canonical types. The implementation
only works for the LLDS backend; in other cases, the runtime aborts with
a "sorry" message. For this reason, it is not officially part of the
standard library yet.
library/std_util.m:
Add the new predicate, which is implemented via "external".
runtime/mercury_ho_call.c:
Implement compare_representation/3, and also a C version.
runtime/mercury_unify_compare_body.h:
Implement the body of compare_representation/3. When the macro
include_compare_rep_code is defined comparison of preds and
funcs doesn't abort, the code that is used for MR_COMPARE_BY_RTTI
is enabled, and usereq types are treated as normal types.
runtime/mercury_conf_param.h:
Document the fact that calls to compare_representation are
counted as calls to compare for the purposes of MR_TYPE_CTOR_STATS.
runtime/Mmakefile:
Bug fix: add missing pic_o versions of the explicit dependencies.
Use variables for the suffixes in these dependencies.
runtime/mercury.c:
runtime/mercury.h:
Supply a HIGHLEVEL_CODE version of the new predicate. This just
gives a "Sorry, not implemented" message and aborts.
tests/hard_coded/Mmakefile:
tests/hard_coded/compare_rep_usereq.exp:
tests/hard_coded/compare_rep_usereq.m:
tests/hard_coded/compare_representation.exp:
tests/hard_coded/compare_representation.m:
Test cases.
tests/hard_coded/compare_rep_array.m:
A test case which doesn't work yet.
Estimated hours taken: 40
Branches: main
Allow declarations of the form
:- pred p `with_type` higher_order_type `with_inst` higher_order_inst.
XXX We should allow `with_inst` annotations on higher-order terms.
compiler/prog_data.m:
Add fields to `pred_or_func' and `pred_or_func_mode'
items to hold the `with_type` and `with_inst` annotations.
compiler/prog_io.m:
compiler/prog_io_typeclass.m:
Parse the annotations.
compiler/module_qual.m:
Module qualify the annotations.
compiler/equiv_type.m:
Expand away `with_type` and `with_inst`. Report errors.
Strip items containing errors from the item list.
Record smart recompilation dependencies on the types and
modes expanded. Also record a dependency on the arity of
predicate and function declarations before expansion.
Use error_util for error messages.
compiler/mercury_to_mercury.m:
Write `with_type` and `with_inst` annotations to interface files.
compiler/make_hlds.m:
Ignore `with_type` and `with_inst` fields in predicate and
function declarations.
compiler/recompilation.m:
Changes to allow equiv_type.m to record dependencies on
arbitrary items, not just types.
compiler/recompilation_usage.m:
compiler/recompilation_check.m:
Allow searches in the sets of used predicates and functions using
name, not name and arity, as the key. This is needed because
the actual arity of a predicate defined using `with_type` is
not known when writing the interface files.
compiler/recompilation_version.m:
Handle `with_inst` and `with_type`.
Pragmas now need to be recorded in the version_numbers even
if there is no matching `:- pred' or `:- func' declaration --
the pragma may apply to a predicate or function declared using
`with_type`.
compiler/mode_util.m:
Export inst_subsitute_arg_list for use by equiv_type.m.
compiler/error_util.m:
Add predicate `pred_or_func_to_string'.
library/std_util.m:
Add std_util__map_foldl_maybe and std_util__map_foldl2_maybe,
which are like list__map_foldl and list__map_foldl2, but
apply to the item stored in a value of type std_util__maybe.
NEWS:
doc/reference_manual.texi:
Document the new syntax and library predicates.
tests/invalid/Mmakefile:
tests/invalid/with_type.m:
tests/invalid/with_type.err_exp:
tests/invalid/constrained_poly_insts.err_exp:
tests/recompilation/TESTS:
tests/recompilation/unchanged_with_type_nr*:
tests/recompilation/with_type_re*:
Test cases.
tests/invalid/errors1.err_exp:
tests/invalid/type_loop.err_exp:
tests/invalid/vars_in_wrong_places.err_exp:
Update expected output.
Estimated hours taken: 2
Branches: main
Get the debugger's interactive query mechanism to print out details of
non-canonical types (e.g. higher-order types).
browser/interactive_query.m:
Use `io__write_cc' rather than `io__write', and hence declare the
argument passed to `builtin_aggregate' as `cc_multi' rather than `det'.
library/std_util.m:
Add modes to `builtin_aggregate' and `do_while' in which the
collector predicate has determinism `cc_multi'.
library/builtin.m:
Add impure variants of `promise_only_solution' and
`promise_only_solution_io', for use by std_util.m.
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: 2.5
Branches: main
Add MR_ prefixes to uses of configuration macros.
Bootcheck now succeeds with MR_NO_CONF_BACKWARDS_COMPAT.
Mmake.common.in:
Define MR_NO_CONF_BACKWARDS_COMPAT when checking
for namespace cleanliness.
RESERVED_MACRO_NAMES:
Remove the configuration macros.
runtime/mercury_conf_bootstrap.h:
Remove a duplicate definition of BOXED_FLOAT.
configure.in:
*/*.c:
*/*.h:
*/*.m:
Add MR_ prefixes.
Estimated hours taken: 12
Branches: main
Reorganize deconstruct.m so that each predicate that deconstructs terms has
three variants:
- One that aborts when attempting to deconstruct non-canonical terms.
- One that succeeds when attempting to deconstruct a term of a non-canonical
type, but returns a constant such as "<<noncanonical>>" for such
deconstructions. It still aborts when deconstructing a noncanonical term
of an ordinarily canonical type, which can happen with HAL if the term
is currently a variable.
- One that succeeds when attempting to deconstruct non-canonical terms of both
kinds, but whose determinism requires its caller to be in a committed choice
context.
Each of the predicates function, arg, named_arg, deconstruct and
limited_deconstruct now has an extra argument that selects one of the three
variants above. Each of these predicates now has three modes, one for each
value of this argument. The separate predicates with _cc at the ends of their
names are now superseded by one of these modes.
At the same time, I also eliminated the distinction between arg and argument.
Arg used to check if the returned argument was of the expected type, and fail
if it wasn't, while argument used to return a univ. The new arg now returns
a value of an existential type, which the caller can now typecheck or put
into a univ as it pleases.
The descriptions of the changes:
library/deconstruct.m:
Implement the changes discussed above. Work around a bug by making
the foreign_procs return a univ from which we later extract the value;
this inefficiency should be fixed later, when the typechecker has been
fixed to allow different clauses to return existentially typed values.
library/std_util.m:
Reimplement the forwarding predicates that call deconstruct.m in terms
of its new interface.
library/io.m:
Make use of the new functionality in deconstruct.m to offer versions
of io__print and io__write that allow the user to choose how to print
noncanonical terms.
library/private_builtin.m:
Export the `sorry' predicate for use in deconstruct.m and elsewhere.
runtime/mercury_deconstruct.[ch]:
runtime/mercury_ml_expand_body.h:
runtime/mercury_ml_arg_body.h:
runtime/mercury_ml_deconstruct_body.h:
runtime/mercury_ml_functor_body.h:
Implement the new functionality.
library/store.m:
extras/trailed_update/tr_store.m:
Conform to the new interfaces of some functions in the updated files
in the runtime.
tests/debugger/polymorphic_output.exp*:
Update for an updated error message.
tests/hard_coded/deconstruct_arg.{m,exp*}:
Update the test case to test the committed choice versions of the
deconstruction predicates as well as the usual versions. (The aborting
versions cannot all be tested in a single test case.)
Estimated hours taken: 8
Branches: main
Move the RTTI-related parts of std_util.m to three new modules in the standard
library, and (in the case of embedded C code) to new modules in the runtime.
The main reason for this is to allow a reorganization of some of the
RTTi-related functionality without breaking backward compatibility. However,
the new arrangement should also be easier to maintain.
Use a separate type_ctor_rep for functions, to distinguish them from predicates
for RTTI code. (At one point, I thought this could avoid the need for the
change to the initialization files mentioned below. It can't, but it is a good
idea in any case.)
library/std_util.m:
Remove the functionality moved to the new modules, and replace them
with type equivalences and forwarding code. There are no changes in
the meanings of the user-visible predicates, with two exceptions.
- First, the true, equivalence-expanded names of what used to be
std_util:type_desc and std_util:type_ctor_desc are now
type_desc:type_desc and type_desc: type_ctor_desc.
- Second, deconstructing a function term now yields
"<<function>>" instead of "<<predicate>>".
The intention is that the RTTI predicates in std_util.m will continue
to work in a backwards-compatible manner for the near future, i.e. as
the new modules are updated, the code in std_util will be updated to
maintain the same functionality, modulo improvements such as avoiding
unwanted exceptions. When the RTTI functionality in the other modules
has stabilised, the RTTI predicates in std_util.m should be marked
obsolete.
The exported but non-documented functionality of std_util has been
moved to one of the new modules without forwarding code, with one
of the moved predicates being turned into the function it should have
been in the first place.
library/construct.m:
library/deconstruct.m:
library/type_desc.m:
Three new modules for the code moved from std_util.m.
library/library.m:
compiler/modules.m:
Record the names of the three new library modules.
runtime/mercury.[ch]:
compiler/mlds_to_il.m:
Record that type_desc is now in type_desc.m, not std_util.m.
compiler/static_term.m:
Import the deconstruct module, since we are using its undocumented
facilities.
runtime/Mmakefile:
Mention the two new modules.
runtime/mercury_construct.[ch]:
runtime/mercury_type_desc.[ch]:
Two new modules holding the C functions that used to be in foreign_code
in std_util, now using MR_ instead of ML_ prefixes, and being more
consistent about indentation.
runtime/mercury_type_info.h:
Add a new type_ctor_rep for functions, separate from predicates.
(It reuses the EQUIV_VAR type_ctor_rep, which hasn't been used
in ages.)
Use type_ctor_reps to distinguish between the type_ctor_infos of
pred/0 and func/0. However, to create higher order typeinfos, we
still need to know the addresses of the type_ctor_infos for
pred/0 and func/0, and we still need to know the address of the
type_ctor_info for tuples to create typeinfos for tuples. Since
these three type_ctor_infos are defined in the library,
we cannot access them directly from the runtime. We therefore need
to access them indirectly in the usual manner, via address_of
variables initialized by mkinit-generated code.
library/builtin.m:
library/private_builtin.m:
library/rtti_implementation.m:
runtime/mercury.c:
runtime/mercury_mcpp.{h,cpp}:
java/TypeCtorRep.java:
Updates to accommondate the new function type_ctor_rep.
runtime/mercury_type_info.[ch]:
Add some functions from foreign_code in std_util that fit in best here.
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.h:
runtime/mercury_unify_compare_body.h:
Delete the code for handling EQUIV_VAR, and add code for handling
functions.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
Add three variables holding the address of the type_ctor_infos
representing functions, predicates and tuples.
util/mkinit.c:
Fill in these three variables.
tests/general/accumulator/construct.{m,exp}:
tests/general/accumulator/deconstruct.{m,exp}:
tests/hard_coded/construct.{m,exp}:
Rename these tests by adding a _test at the ends of their names,
in order to avoid collisions with the names of the new standard library
modules. The test cases have not changed, with the exception of the :-
module declaration of course.
tests/general/accumulator/Mmakefile:
tests/general/accumulator/INTRODUCED:
tests/hard_coded/Mmakefile:
Record the name changes.
tests/hard_coded/existential_float.exp:
Updated the expected output to reflect that deconstructions now print
"<<function>>" instead of "<<predicate>>" when appropriate.
tests/hard_coded/higher_order_type_manip.exp:
Updated the expected output to reflect the new name of what used to be
std_util:type_desc.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
#include type_desc.h instead of std_util.h, since the C functions
we want to call are now defined there.
trace/mercury_trace_vars.c:
Update to account for the movement of type_desc from std_util to
type_desc, and ensure that we don't refer to any type_ctor_infos
in MLDS grades.
Estimated hours taken: 12
Branches: main
Fix a bug by distinguishing the type_ctor_reps of type_infos and
type_ctor_infos. The type_ctor_infos of types with nonzero arity
cannot be printed, copied etc like type_infos; any attempt to do so
causes a core dump.
For similar reasons, add a separate type_ctor_rep for
base_typeclass_infos separate from typeclass_infos.
runtime/mercury_type_info.h:
runtime/mercury_mcpp.h:
compiler/mlds_to_gcc.m:
library/rtti_implementation.m:
java/TypeCtorRep.java:
Add new type_ctor_reps for type_ctor_infos and base_typeclass_infos.
library/private_builtin.m:
runtime/mercury.c:
Use the new type_ctor_reps in the type_ctor_infos of the builtin types
type_ctor_info and base_typeclass_info.
runtime/mercury_type_info.[ch]:
Add a function for comparing type_ctor_infos.
Move some interface documentation from the source file to the header
file.
runtime/mercury_deep_copy_body.h:
Add code to handle the new type_ctor_reps.
Simplify some code.
Make the whole file use 4-space indentation.
library/std_util.m:
runtime/mercury_ml_expand_body.h:
runtime/mercury_unify_compare_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_tabling.c:
Add code to handle the new type_ctor_reps.
Estimated hours taken: 12
Branches: main
This is the first half of a change that removes redundant fields from
type_ctor_info structures.
configure.in:
Do not require an exact match on the RTTI version number.
runtime/mercury_type_info.h:
Update the RTTI version number.
Add the new definition of type_ctor_infos.
Add prefixes to the fields in type_ctor_infos that did not already have
them.
Provide macros to access the fields in the changed part of
type_ctor_infos in a way that works with both the old and new
type_ctor_info structures.
Move some stuff so that macros that logically belong together are next
to each other.
runtime/mercury_mcpp.h:
Update the RTTI version number and the macros for defining
type_ctor_infos.
library/rtti_implementation.m:
Update the mechanism for access to type_ctor_info fields.
Add prefixes to field names and use RTTI-version-independent macros
as necessary.
compiler/hlds_module.m:
compiler/rtti.m:
Delete obsolete fields from the terms from which type_ctor_info
structures are derived.
compiler/dead_proc_elim.m:
Minor changes to conform to this change in data structure.
compiler/type_ctor_info.m:
Minor changes to conform to this change in data structure.
Update the RTTI version number.
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
Output the new type_ctor_info structure.
compiler/llds_out.m:
compiler/mlds_to_c.m:
Emit a #define to select the new type_ctor_info structure.
library/std_util.m:
runtime/mercury.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
runtime/mercury_type_tables.c:
runtime/mercury_unify_compare_body.h:
tests/hard_coded/type_tables.m:
trace/mercury_trace.c:
Add prefixes to field names and use RTTI-version-independent macros
as necessary.
Estimated hours taken: 1
Branches: main
library/std_util.m:
Mark the relevant routines as thread_safe. Make the appearance of
foreign_proc clauses much more uniform, to make it easier to make
similar changes in the future.
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: 1
Branches: main
library/std_util.m:
Add Mercury mode specific definitions for the functor_cc,
deconstruct_cc and limited_deconstruct_cc which just throw an error.
Estimated hours taken: 12
Branches: main
Add committed choice versions of the functions and predicates that deconstruct
terms. These versions succeed even if the the term being deconstructed is of a
non-canonical type.
NEWS:
Mention the new procedures.
library/std_util.m:
Add the following procedures: functor_cc, argument_cc, det_argument_cc,
named_argument_cc, det_named_argument_cc, deconstruct_cc and
limited_deconstruct_cc.
To avoid code duplication, factor out the code common to several
procedures and put it into three new files in the runtime directory,
mercury_ml_{fuctor,arg,deconstruct__body.h.
Add arguments to the various expansion functions to control what they
should do for non-canonical types. Move them to mercury_deconstruct.c
in the runtime directory to make it easier to access them from other
places.
Fix some bugs in the code for det_arg and family in the computation
of abort messages.
library/store.m:
extras/trailed_update/tr_store.m:
trace/mercury_trace_vars.c:
Adjust the references to the expansion functions.
runtime/mercury_deconstruct.[ch]:
A new module to contain the expansion functions.
runtime/mercury_ml_arg_body.h:
runtime/mercury_ml_deconstruct_body.h:
runtime/mercury_ml_functor_body.h:
New files to contain the bodies of the std_util procedures for
deconstructing terms.
runtime/mercury_deconstruct_macros.h:
A new header file for macros used in several places.
library/Mmakefile:
runtime/Mmakefile:
Add the new files to the required lists.
Estimated hours taken: 20
Branches: main
This is the first half of a change that reduces the size of type_ctor_info
structures, and moves the version number to the start (immediately after the
arity) to make future changes easier.
The second half can be committed only when the first half has been installed
on all our machines.
Note that when this change is installed on a machine, you will need to do a cvs
update in every workspace that uses that machine's installed compiler before
being able to continue working with that workspace. This is because the
compiler will generate the new MR_TypeCtorInfo structure, and you will get C
compiler errors if your runtime still contains a declaration only for the old
one.
Doing a cvs update after this change is checked but before it is installed
should be OK.
runtime/mercury_type_info.h:
Define the new version of the type_ctor_info structure while keeping
the old one temporarily; the presence of a macro definition, which
is emitted only by new compiler versions, selects the new version.
Increment the maximum supported rtti version number.
Remove some obsolete stuff, and move some macro definitions to their
proper place in the file.
Define a macro to allow access to the type_ctor_rep field regardless
of version.
Define a macros to allow the declaration of type_ctor_info structures
regardless of version.
runtime/mercury_ho_call.h:
With the new type_ctor_info structures, take the address of the
unify procedure from the new unify field, since the old one has
been reused for other purposes.
compiler/type_ctor_info.m:
Increment the rtti version number.
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
Generate the new type_info structure.
compiler/llds_out.m:
compiler/mlds_to_c.m:
Generate a macro definition that selects the new type_ctor_info
for use, since that is what we are generating.
library/rtti_implementation.m:
library/std_util.m:
runtime/mercury.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
runtime/mercury_unify_compare_body.h:
runtime/mercury_wrapper.c:
Use the version-independent macro to access the type_ctor_rep field.
library/table_builtin.m:
Use the version-independent macro to declare type_ctor_infos.
Estimated hours taken: 8
Branches: main
Allow the browser to refer to fields by name.
browser/browser_info.m:
Generalize the data structure for recording paths within terms to allow
navigation by field names.
browser/browse.m:
browser/program_representation.m:
Update the algorithms for navigation in terms accordingly.
browser/parse.m:
Update the algorithm for reading in navigation terms.
Allow digits as well as letters and underscores in "names", since
field names may contain digits as well. This should not impact
other uses of names by the other parts of the debugger.
library/std_util.m:
Add new predicates named_argument and det_named_argument. They are
implemented using ML_named_arg, a new C function which is the same
as ML_arg except that it specifies the selected argument by name.
NEWS:
Mention the new predicates.
runtime/mercury_ml_expand_body.h:
Add a new alternative, EXPAND_NAMED_ARG, for use in implementing
ML_named_arg.
tests/debugger/field_names.{m,inp,exp,exp2}:
Expand this test case to exercise the browser.
Estimated hours taken: 0.2
Branches: main
library/std_util.m:
Replace calls to var/1 in type_to_univ with mode-specific clauses.
Since var/1 is impure, it was not being optimized away, and neither
was the disjunction around it.
Estimated hours taken: 0.5
library/std_util.m:
Add `const' to avoid a gcc warning / lcc error caused
by my earlier addition of `const' in runtime/mercury_type_info.h.
Also delete an unused local variable.
Estimated hours taken: 18
Branches: main
Add RTTI support for the new reserved address data representations.
runtime/mercury_type_info.h:
runtime/mercury_mcpp.h:
runtime/mercury.h:
library/private_builtin.m:
library/rtti_implementation.m:
Add MR_TYPECTOR_REP_RESERVED_ADDR (with and without _USEREQ) to
the MR_TypeCtorRep enum, for discriminated union types containing
one or more functors represented using reserved addresses,
and add new RTTI structs to hold information about how such
types are represented.
compiler/type_ctor_info.m:
compiler/mlds_to_gcc.m:
compiler/opt_debug.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
Add appropriate code to generate these new RTTI structs.
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_unify_compare_body.h:
runtime/mercury_tabling.c:
library/std_util.m:
Add code to handle the MR_TYPECTOR_REP_RESERVED_ADDR alternative,
using the information in the new RTTI structs.
Estimated hours taken: 1
Branches: main, dotnet-foreign
Fix some bugs introduced by the recent change to represent
mlds__native_bool_type as bool.
library/builtin.m:
library/std_util.m:
Change the return type from int to bool for semidet predicates
implemented as MC++ code.
Estimated hours taken: 10
Branches: main
Fix semidet C# code to use SUCCESS_INDICATOR.
Represent mlds__native_bool_type as bool, not int32.
In the library, fix incorrect uses of MC++ to implement functions -- these
weren't being caught because they returned int32, and we assumed
this was a semidet return value, not an actual integer.
These incorrect uses were all buggy -- functions don't work in MC++.
The compiler is now catches cases where functions returning int are
implemented in MC++ -- but it won't catch cases where
IL's bool type is returned, but that should not be a such a problem.
compiler/ilasm.m:
Handle the output of boolean integer constants.
compiler/ml_code_gen.m:
Add SUCCESS_INDICATOR to the locals of the MLDS for semidet C# code,
copy SUCCESS_INDICATOR into succeeded after the execution of the
user's code.
compiler/mlds_to_csharp.m:
Implement assignments (so we can copy SUCCESS_INDICATOR to
succeeded).
compiler/mlds_to_il.m:
Copy return values into SUCCESS_INDICATOR for forwarded
predicates (it will then be copied into succeeded).
This all gets optimized away in the generated IL anyway.
Represent native_bool_type as bool, not int32.
Check for MC++ functions returning bool (not int32).
Output true and false as boolean constants for 1 and 0.
compiler/mlds_to_mcpp.m:
Map bool to MR_Bool, not MR_Integer.
library/int.m:
Implement much of the code in Mercury rather than C# or MC++.
The more efficient C bindings remain, but for other backends we
fall back on the Mercury bindings.
library/io.m:
Implement io__get_stream_id as a pred in MC++.
It is easier to keep this as MC++ at the moment as that is what
the rest of the io.m code is implemented in (including the
Mercury stream data structure).
library/std_util.m:
Add some missing assignments to SUCCESS_INDICATOR.
Estimated hours taken: 0.5
Branches: main
Fix the library so it compiles in grade ilc.
library/std_util.m:
Implement null and get_functor_2 in C#/MC++.
Estimated hours taken: 3
Branches: main
Change the list constructor from `./2' to `[|]/2'. `./2' will
eventually become the module qualification operator.
library/parser.m:
library/io.m:
library/sparse_bitset.m:
library/std_util.m:
library/term_io.m:
compiler/mercury_to_mercury.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
browser/interactive_query.m:
extras/moose/grammar.m:
extras/moose/moose.m:
extras/morphine/source/generate_call_site_cov.m:
extras/xml/xml.encoding.m:
samples/muz/higher_order.m:
tests/debugger/declarative/app.m:
tests/dppd/transpose_impl.m:
tests/hard_coded/ground_dd.m:
tests/hard_coded/split_c_files.m:
Change all references to `./2' to use `[|]/2' instead.
compiler/typecheck.m:
Handle `./2' as a special case in `report_error_undef_cons'.
Warn about module list not being imported if `[|]/2' is undefined.
compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
Add name conversions for `[|]' (f_cons) and `[]' (f_nil).
NEWS:
doc/reference_manual.texi:
w3/tutorial/lists-n-things.m4:
Document the changes.
tests/debugger/{,declarative}/*.exp*:
Update test case results. For some tests the output changed
because they output lists in the non-pretty format. For others,
the output changed because the alphabetical ordering of the
constructors of type `list/1' changed, so the numbering of
the switch branches in the goal paths changed.
Estimated hours taken: 50
Branches: main
Implement most of the RTTI required for io__write to work in the .NET
backend. With this code most of tests/hard_coded/write.m work (up until
the point where we try to write a univ).
We don't yet handle higher-order terms or existentially quantified type
variables.
library/io.m:
Prepend an "_" to some unused variables.
Move unsafe_cast from io.m into rtti_implementation.m -- it is
useful in rtti_implementation (and possibly elsewhere), and it's
better to have io depend on rtti_implementation than vice-versa.
library/rtti_implementation.m:
Implement type_ctor_name_and_arity for commonly occuring data
representations.
Add type_ctor_is_variable_arity to simplfy this test.
Rename index as type_info_index to make it clear what we are
indexing into.
library/std_util.m:
Improve some of the error messages to make it easier to track
down unimplemented code.
Call into rtti_implementation for type_ctor_and_args.
Use pragma export to generate ML_call_rtti_compare_type_infos
(it wasn't available before so we jumped through a few more
hoops to call into rtti_implementation).