Estimated hours taken: 5
[This change was by Ralph Becket.
I'm just the person who reviewed it and committed it. -fjh.]
Add functions for the single output det predicates in a number
of modules in the standard library. Basically, for each
:- pred f(in, ..., in, out) is det.
I have added the declaration
:- func f(in, ..., in) = out.
and definition
f(X1, ..., Xn) = Y :-
f(X1, ..., Xn, Y).
library/char.m:
library/dir.m:
library/map.m:
library/string.m:
library/list.m:
library/set.m:
Make the changes described above.
library/array.m:
As above, except array input modes are all array_ui or
array_di as appropriate and array output modes are array_uo.
library/int.m:
Added forward versions of +/2, */2 and -/2 as plus/2, times/2
and minus/2 respectively, to make it easier to pass these
as arguments to higher-order predicates.
Also added func constants for max_int, min_int and bits_per_int.
library/integer.m:
Replaced local functions for list head, tail and length with
calls to equivalent functions now defined in list.m.
library/io.m:
Added func for error_message/2.
library/list.m:
Add functions det_head/1 and det_tail/1 which abort on null lists.
library/set.m:
Add functions map/2, filter_map/2 and fold/3.
library/std_util.m:
Added utility function to construct a pair object from its
arguments and general purpose higher order functions for
partial functions and for function composition, exponentiation
and exchanging the arguments of a binary function.
Estimated hours taken: 30 (including debugging)
Add MR_TYPECTOR_REP_* to the type_ctor_info to describe the
representation of this type.
We want to do this because it allows us to check quickly to see
what kind of data representation is being used. Previously this
information was spread throughout the type_ctor_layout and
type_ctor_functors data structures. It was complex to interpret
and contained a lot of unnecessary duplication.
We can now omit data structures such as the type_ctor_layout in many
cases (it is only necessary for discriminated unions). Because we rule
out some of the possible alternatives, the encodings used in the
type_ctor_layout can be simplified. Also, the functors indicator in
type_ctor_functors can be removed, as it subsumed by this data
structure.
Use this representation in code that uses RTTI.
compiler/base_type_info.m:
Add a missing alternative to the type_ctor_rep (this was a
bug).
library/array.m:
library/builtin.m:
library/private_builtin.m:
runtime/mercury_bootstrap.c:
Use MR_TYPECTOR_REP_* in the type_ctor_infos for builtin types.
library/std_util.m:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
Use MR_TYPECTOR_REP_* and MR_DISCUNION_TAG_* to dispatch on
data representations.
Also, fix a bug in deep_copy when copying floating point values.
I'm not sure when this stopped working, or if this is exactly
the right fix, but it is more correct than the previous code.
runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
Update code to use MR_TYPECTOR_REP_*.
Use a struct for type_ctor_info.
tests/hard_coded/Mmakefile:
tests/hard_coded/deep_copy.m:
tests/hard_coded/deep_copy.exp:
Add a test case for deep_copy.
Estimated hours taken: 0.5
Move the type_ctor_infos for array and univ into their proper places.
This change has bootstrapped on most of our platforms, but actually
causes trouble linking small programs (because it creates runtime ->
library dependencies). So we should move it as soon as possible.
library/array.m:
library/std_util.m:
Add type_ctor_info for array and univ.
runtime/mercury_bootstrap.c:
Remove type_ctor_info for array and univ.
Estimated hours taken: 4.5
Remove support for --args simple. We don't use it, we won't use it even for
experiments, and it is unnecessary complication.
If anybody were using --args simple, this would need bootstrapping, but
since nobody does, there is no need, and this can be committed as an
ordinary change.
compiler/options.m:
doc/user_guide.texi:
scripts/*.in:
scripts/*.sh-subr:
Remove the --args option.
compiler/globals.m:
Remove the args_method global and its access predicates.
compiler/handle_options.m:
Don't set the args_method global from the option.
compiler/arg_info.m:
Remove support for --args simple. This allows us to remove a now
redundant argument from an exported predicate.
compiler/mercury_compile.m:
Remove the code for passing -DCOMPACT_ARGS to the C compiler.
compiler/bytecode_gen.m:
compiler/fact_table.m:
compiler/follow_vars.m:
compiler/live_vars.m:
compiler/call_gen.m:
Don't pass the unnecessary argument to arg_info.
compiler/call_gen.m:
compiler/unify_gen.m:
Remove now unnecessary assertions.
compiler/hlds_pred.m:
Don't include an args_method in proc_infos; instead, include
a slot that says whether the procedure's address is taken or not.
(In most cases, this determined whether the args_method was
simple or compact.) We will need this bool in the near future
(when we generate layout structures for procedures whose address
is taken).
Modify the signatures of exported predicates to accommodate
this change to the data structure.
compiler/hlds_out.m:
Print the new slot, not the args_method.
compiler/lambda.m:
When creating procedures from lambdas, set the address-taken slot
to address_is_taken instead of setting up its args_method.
compiler/make_hlds.m:
Minor changes to conform to the changes in the signatures of
the predicates exported from hlds_pred.m.
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/dnf.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/modecheck_call.m:
compiler/pd_info.m:
compiler/post_typecheck.m:
compiler/unify_gen.m:
Minor changes to conform to the changes in the signatures of
the predicates exported from hlds_pred.m and make_hlds.m.
runtime/mercury_type_info.h:
Remove the conditional definition of the macros that provided
an argument-method-independent way of referring to the registers
holding the inputs and outputs of e.g. unification procedures.
We don't need the independence anymore, and using registers instead
of macros in the code ensures that maintainers are aware of register
reuse issues (e.g. they copy an input from r1 before overwriting it
with an output).
runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
Remove support for the args method component of the grade.
runtime/mercury_ho_call.c:
runtime/mercury_tabling.c:
library/*.m:
Conform to the changes in runtime/mercury_type_info.h by effectively
applying the #defines appropriate to compact args by hand.
Remove code and data structures only needed for simple args.
Remove comments needed only in the presence of uncertainty about
the args method.
Estimated hours taken: 16
Allow the compiler to handle create rvals whose arguments have a size
which is different from the size of a word. Use this capability to reduce
the size of RTTI information, in two ways.
The first way is by rearranging the way in which we represent information
about the live values at a label. Instead of an array with an entry for
each live value, the entry being a pair of Words containing a shape
representation and a location description respectively, use an array
of shape representations (still Words), followed by an array of 32-bit ints
(which may be smaller than Word) describing locations whose descriptions
don't fit into 8 bits, followed by an array of 8-bit ints describing
locations whose descriptions do fit into 8 bits.
The second way is by reducing the sizes of some fields in the C structs
used for RTTI. Several of these had to be bigger than necessary in the
past because their fields were represented by the args of a create rval.
On cyclone, this reduces the size of the object file for queens.m by 2.8%.
IMPORTANT
Until this change is reflected in the installed compiler, you will not be
able to use any modules compiled with debugging in your workspaces if the
workspace has been updated to include this change. This is because the RTTI
data structures generated by the old installed compiler will not be compatible
with the new structure definitions.
The workaround is simple: if your workspace contains modules compiled with
debugging, don't do a cvs update until this change has been installed.
configure.in:
Check whether <stdint.h> is present. If not, autoconfigure
types that are at least 16 and 32 bits in size.
runtime/mercury_conf.h.in:
Mention the macros used by the configure script, MR_INT_LEAST32_TYPE
and MR_INT_LEAST16_TYPE.
runtime/mercury_conf_param.h:
Document the macros used by the configure script, MR_INT_LEAST32_TYPE
and MR_INT_LEAST16_TYPE.
runtime/mercury_types.h:
If <stdint.h> is available, get the basic integer types (intptr_t,
int_least8_t, etc) from there. Otherwise, get them from the
autoconfigure script. Define types such as Word in terms of these
(eventually) standard types.
runtime/mercury_stack_layout.h:
Add macros for manipulating short location descriptions, update the
types and macros for manipulating long location descriptions.
Modify the way the variable count is represented (since it now must
count locations with long and short descriptions separately),
and move it to the structure containing the arrays it describes.
Reduce the size of the some fields in structs. This required some
reordering of fields to avoid the insertion of padding by the compiler,
and changes to the definitions of some types (e.g. MR_determinism).
runtime/mercury_layout_util.[ch]:
runtime/mercury_stack_trace.c:
runtime/mercury_accurate_gc.c:
trace/mercury_trace.c:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
Update the code to conform to the changes to stack_layout.h.
compiler/llds.m:
Modify the create rval in two ways. First, add an extra argument to
represent the types of the arguments, which used to always be implicit
always a word in size, but may now be explicit and possibly smaller
(e.g. uint_least8). Second, since the code generator would do the wrong
thing with creates with smaller than wordsize arguments, replace
the old must-be-unique vs may-be-nonunique bool with a three-valued
marker, must_be_dynamic vs must_be_static vs can_be_either.
Add uint_least8, uint_least16, uint_least32 (and their signed variants)
and string as llds_types.
Add a couple of utility predicates for checking whether an llds_type
denotes a type whose size is the same as word.
compiler/llds_out.m:
Use explicitly given argument types when declaring and initializing
the arguments of a cell, if they are given.
compiler/llds_common.m:
Don't conflate creates with identical argument values but different
C-level argument types. The probability of a match is minuscule anyway.
compiler/stack_layout.m:
Use the new representation of creates to generate the new versions of
RTTI data structures.
compiler/code_exprn.m:
If a create is marked must_be_static, don't inspect the arguments
to decide whether it can be static or not. If it can't, we'll get
an abort later on in llds_out or during C compilation anyway.
compiler/base_type_layout.m:
When creating pseudo typeinfos, return the llds_type of the resulting
rval.
Minor changes required by the change in create.
compiler/base_type_info.m:
compiler/base_typeclass_info.m.m:
compiler/code_util.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/lookup_switch.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/string_switch.m:
compiler/unify_gen.m:
compiler/vn_cost.m:
compiler/vn_filter.m:
compiler/vn_flush.m:
compiler/vn_order.m:
compiler/vn_type.m:
compiler/vn_util.m:
compiler/vn_verify.m:
Minor changes required by the change in create.
library/benchmarking.m:
library/std_util.m:
Use the new macros in hand-constructing proc layout structures.
library/Mmakefile:
Add explicit dependencies for benchmarking.o and std_util.o
on ../runtime/mercury_stack_layout.h. Although this is only a subset
of the truth (in reality, all library objects depend on most of the
runtime headers), it is a good tradeoff between safety and efficiency.
The other runtime header files tend not to change in incompatible ways.
trace/Mmakefile:
Add explicit dependencies for all the object files on
../runtime/mercury_stack_layout.h, for similar reasons.
Estimated hours taken: 3
Prefix everything defined in runtime/mercury_{stacks,tags}.h MR_.
In the process, get rid of the grade component MR_DEBUG_NONDET_STACK,
since this makes the update to mercury_stacks.h simpler and its use is
long obsolete.
runtime/mercury_tags.h:
Put MR_ prefixes in front of everything defined here.
runtime/mercury_stacks.h:
Put MR_ prefixes in front of everything defined here.
Remove support for MR_DEBUG_NONDET_STACK. Replace most of the
lost functionality by calling an updated mkframe_msg.
Remove the definitions of push() and pop(). Their use conflicts with
the idea that everything on the det stack is part of a frame, which
the RTTI stuff depends on.
runtime/mercury_bootstrap.h:
Add backward compatibility macros for the old names in the above two
files.
Remove some old entries in this file which are no longer needed.
runtime/mercury_wrapper.c:
Remove the only uses of push() and pop().
Put MR_ in front of some things that need them.
runtime/mercury_engine.c:
Put MR_ in front of some things that need them.
runtime/mercury_misc.[ch]:
Make mkframe_msg get the name of the procedure that owns the stack
frame from an explicitly passed argument, rather than the prednm slot
(which no longer exists). This actually improves low-level debugging
support without MR_DEBUG_NONDET_STACK.
Remove unnecessary return statements.
runtime/mercury_debug.h:
Pass on the new arg of mkframe_msg.
Fix long lines.
runtime/mercury_conf_param.h:
Remove the documentation of MR_DEBUG_NONDET_STACK.
runtime/mercury_grade.h:
Remove the grade component of MR_DEBUG_NONDET_STACK.
doc/reference_manual.texi:
Document the MR_ prefixed versions of list_empty, list_cons etc.
library/io.m:
library/std_util.m:
library/string.m:
Add prefixes to some references to the runtime.
Estimated hours taken: 5
This change does some renaming to match the new nomenclature introduced
in the RTTI paper.
Rename simple tags as unshared tags, complicated tags as shared
remote tags and complicated constant tags as shared local.
Also rename "simple vector" as "functor descriptor",
"functors vector" as "enum vector".
compiler/base_type_layout.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/hlds_data.m:
compiler/make_tags.m:
compiler/switch_gen.m:
compiler/tag_switch.m:
compiler/unify_gen.m:
Perform these renamings in the compiler, renaming a few
functors and data structures.
library/std_util.m:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
Perform these renamings in the library and runtime, renaming
macros and variables.
Estimated hours taken: 36
Switch to a closure representation that includes runtime type and procedure id
information, so that closures can be copied, garbage collected, printed, etc.
This RTTI information is not yet used. Adding code to use it would be futile
until Tyson finishes his changes to the other RTTI data structures.
Note also that this change provides the information required for solving the
problem of trying to deep copy closures only for grades that include
--typeinfo-liveness. Providing this info for other grades is future work.
configure.in:
Find out what the right way to refer to a variable-sized array
at the end of a struct is.
runtime/mercury_ho_call.h:
New file to define the structure of closures and macros for accessing
closures.
runtime/Mmakefile:
Add the new header file.
runtime/mercury_ho_call.c:
Add an entry point to handle calls to new-style closures. The code
to handle old-style closures, which was unnecessarily duplicated for
each code model, stays until all the installed compilers use the new
closure representation.
Until that time, the new entry point will contain code to detect
the use of old-style closures and invoke the old code instead.
This allows stage1s compiled with old compilers to use the old style
and stage2 to use the new style without any special tricks anywhere
else.
Add a new entry point to handle method calls of all code models.
The old entry points, which had the same code, will also be deleted
after this change has been bootstrapped.
runtime/mercury_calls.h:
Remove the macros that call closures. Their interface sucked, they
were not used, and their implementation is now out of date.
runtime/mercury_stack_layout.h:
Add a new type, MR_Type_Param_Locns, for use by the C type
representing closures. Since MR_Stack_Layout_Vars has a field,
MR_slvs_tvars, which references a data structure identical
in every way to MR_Type_Param_Locns, change the type of that field
to this new type, instead of the previous cheat.
runtime/mercury_layout_util.h:
Minor update to conform to the new type of the MR_slvs_tvars field.
(This is the only use of that field in the system.)
runtime/mercury_type_info.h:
Add new types MR_TypeInfo and MR_PseudoTypeInfo. For now, they
are just Word, but later we can make them more accurate.
In the meantime, we can refer to them instead of to Word,
making code clearer. One such reference is now in mercury_ho_call.h.
compiler/notes/release_checklist.html:
Add a reminder to remove the redundant code from mercury_ho_call.c
after bootstrapping.
compiler/llds.m:
Replace three code addresses for calling closures and another three
for calling methods with one each.
compiler/call_gen.m:
compiler/dupelim.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/llds_out.m:
Trivial updates in accordance with the change to llds.m
compiler/code_info.m:
Move the code to handle layouts to continuation_info.m,
since that's where it belongs. Leave only the code for picking
up parameters from code_infos and for putting results back in there.
Remove the redundant arguments of code_info__init, and extract
them from ProcInfo, to make clear that they are related.
compiler/code_gen.m:
Since we pass ProcInfo to code_info__init, don't pass its components.
compiler/continuation_info.m:
Add the code moved from code_info.m, in a form which takes explicit
arguments for things that used be hidden in the code_info.
Add new code, closely related to the moved code, that creates
layout info from a procedure's argument info, rather than from a
(part of) the current code generator state. This way, it can be
invoked from places that don't have a code_info for the procedure
for which they want to generate layouts. This is the case when
we generate layouts for closures.
compiler/par_conj_gen.m:
compiler/trace.m:
Minor changes required by the move of stuff from code_info to
continuation_info.
compiler/stack_layout.m:
Export some predicates for use by unify_gen.
compiler/unify_gen.m:
Switch to creating new style closures, complete with layout info.
Optimize the code for extending closures a bit. By copying the
fixed words of the closure outside the loop, we avoid incurring
the loop overhead twice.
compiler/code_util.m:
Add a couple of utility predicates for continuation_info.m and
unify_gen.m
library/benchmarking.m:
library/std_util.m:
Refer to the new entry point for handling closures.
browser/dl.m:
Use the new closure representation.
Note that extras/dynamic_linking/dl.m, which is supposed to be
the same as browser/dl.m but is not, should also be updated, but
this will be handled later by Fergus.
tests/hard_coded/closure_extension.{m,exp}:
A new test case to exercise the code for extending closures.
tests/hard_coded/Mmakefile:
Enable the new test case.
Estimated hours taken: 8
During the writing of the RTTI paper, we decided that type_ctor_info
was a much better name than base_type_info.
Rename base_type* as type_ctor*, except we don't rename the modules
base_type_info and base_type_layout just yet.
Most of these changes were made using the following sed patterns:
s/base_type_info/type_ctor_info/g
s/base_type_layout/type_ctor_layout/g
s/base_type_functors/type_ctor_functors/g
s/BASETYPE_INFO/TYPE_CTOR_INFO/g
s/TYPEFUNCTORS/TYPE_CTOR_FUNCTORS/g
s/TYPELAYOUT/TYPE_CTOR_LAYOUT/g
s/BASE_TYPEINFO/TYPE_CTOR_INFO/g
s/BASE_TYPE_INFO/TYPE_CTOR_INFO/g
s/BaseTypeInfo/TypeCtorInfo/g
s/BaseTypeLayout/TypeCtorLayout/g
s/base_type(/type_ctor(/g
s/:- module type_ctor_info/:- module base_type_info/g
s/:- module type_ctor_layout/:- module base_type_layout/g
s/type_ctor_info__/base_type_info__/g
s/type_ctor_layout__/base_type_layout__/g
/import_module/s/type_ctor_info/base_type_info/g
/import_module/s/type_ctor_layout/base_type_layout/g
compiler/*.m:
library/*.m:
runtime/*.{c,h}:
profiler/demangle.m:
util/mdemangle.c:
Applied the above sed commands.
runtime/mercury_bootstrap.h:
Add bootstrapping #defines so the type_ctor_* substitutions in
the library don't cause link problems.
Delete some redundant bootstrapping definitions.
Estimated hours taken: 0.1
library/std_util.m:
Add two new types:
:- type maybe_error ---> ok ; error(string).
:- type maybe_error(T) ---> ok(T) ; error(string).
We should think about replacing several types in
io.m with instances of these.
Estimated hours taken: 0.1
library/std_util.m:
Add parentheses to use of `some' in type declaration for has_type/2,
to avoid syntax error for SICStus Prolog.
Estimated hours taken: 6
Fix a memory allocation bug reported by
Warwick Harvey <wharvey@cs.monash.edu.au>.
library/std_util.m:
runtime/mercury_type_info.c:
Use `newmem()' rather than `malloc()' when allocating memory
that will contain Mercury terms or types. This is needed
because the Boehm collector does not trace memory allocated
with malloc().
Estimated hours taken: 0.1
library/std_util.m:
Add parentheses to use of `some' in type declaration for univ_value/1,
to avoid syntax error for SICStus Prolog.
Estimated hours taken: 20
Improvements to coroutining support. These changes allow us to do
provide io primatives that cause the Mercury context to suspend rather
than causing the engine to block.
configure.in:
Test to see if we can handle contexts that block on IO
using select().
compiler/pragma_c_gen.m:
Include the predicate name in the calls to MR_OBTAIN_GLOBAL_C_LOCK
and MR_RELEASE_GLOBAL_C_LOCK for improved debugging.
Fix a bug where the global lock was not being released when
semidet pragma c code failed.
runtime/mercury_thread.h:
Change the global lock macros to include the message generated
by the changes to pragma_c_gen.
library/char.m:
library/std_util.m:
include `thread_safe' in the flags for a couple of pragma c
definitions that seem to have missed out.
runtime/mercury_context.{c,h}:
Add a list of "pending" contexts that are blocked on a
file descriptor. When the runqueue becomes empty, we call
select on all the pending contexts.
Move schedule from the header file to the c file (changing
it from a macro to a function) for easier debugging at a
slight performance cost.
TODO: add a nonblocking call to select so that we can poll
for io from time to time rather than waiting till there is
nothing else to do.
runtime/mercury_reg_workarounds.{c,h}:
Make functions that forward to the FD_* macros, which on Linux
attempt to use registers that we've already grabbed. Aarrggh!
runtime/mercury_thread.c:
Tidy up some of the conditional compilation.
runtime/mercury_types.h:
Remove the definition of SpinLock since we're not using them
and are not likely to any time soon.
Estimated hours taken: 4
Change the standard library to use existential types.
library/std_util.m:
Add new existentially typed procedures univ_value/1 and has_type/2.
library/term.m:
library/io.m:
Use existential types rather than unsafe casts and other hacks.
Estimated hours taken: 2
Add an mdb command to invoke the term browser.
trace/mercury_trace_internal.c:
Add code to implement a new command `browse', which invokes
the interactive term browser in browser/browse.m.
doc/mdb_categories:
doc/user_guide.texi:
Document the new `browse' mdb command.
Also simplify the documentation on the `print' command.
browser/browse.m:
Change browse/3 so that it takes an argument of type `T' rather
than `univ'.
library/std_util.m:
Modify ML_expand() so that it does not abort for values of type
c_pointer, type_info, or array(T). This is to prevent the
browser from aborting when trying to display values of those types.
Estimated hours taken: 16
Make stack layout structures work in grades that do not have static code
addresses. (Although it seems that those grades do not work in the absence
of layout structures.)
compiler/llds_out.m:
If an entry label has a layout structure, then during its
initialization, output a macro that will, if necessary,
initialize the code address inside its layout structure.
Do not output a const before a layout structure if the macro
will actually initialize a code address inside it.
compiler/llds.m:
Separate out proc_layouts from internal_layouts in the type
data_name, since only proc_layouts have code addresses in them.
Clarify the existing documentation of the label type's alternatives.
This should help prevent the recurrence of bugs like the one in
mercury_goto.h.
compiler/stack_layout.m:
Replace code addresses inside proc layout structures with a dummy
value if code addresses are not static.
runtime/mercury_goto.h:
Fix a long-standing bug: init_local should treat its argument
as a procedure entry label, not as a label internal to a procedure.
runtime/mercury_stack_layout.h:
In the macros for creating proc layouts by hand-written C code,
allow for the absence of static code addresses, and add a new
macro that fills in the code address slot in proc layouts
at initialization time if necessary.
library/benchmarking.m:
library/private_builtin.m:
library/std_util.m:
Add calls to the new initialization macro to accompany hand-written
proc layout structures.
Estimated hours taken: 1
Fix various gcc warnings.
library/std_util.m:
library/benchmarking.m:
extras/trailed_update/tests/func_trail_test.m:
extras/trailed_update/tests/func_trail_test_2.m:
Add some casts -- without these, the code might not compile
with compilers other than gcc.
library/private_builtin.m:
Avoid the use of nested extern declarations, by moving
the declarations out of the enclosing function.
runtime/mercury_array_macros.h:
Initialize `element' in MR_bsearch().
Without this, gcc reports lots of spurious warnings when
compiling trace/*.c.
Estimated hours taken: 18
Make it possible to compile a module (e.g. std_util) without debugging,
while still allowing debuggable code called from that module via higher-order
predicates (e.g. solutions) to have a proper stack trace.
compiler/options.m:
Add the new option --stack-trace-higher-order.
compiler/mercury_compile.m:
Always invoke continuation_info and stack_layout, since it is no
longer the case that either all procedures or none get layout
structures generated for them, and the other modules are in a better
position to make that decision.
compiler/continuation_info.m:
Handle the extra tests required by the change to mercury_compile.m.
When we gather info about a procedure, remember whether that
procedure must have a procedure layout that includes the procedure id
section.
compiler/stack_layout.m:
Use the flag remembered by continuation_info to help decide
whether we need procedure layout structures.
Fix an old space wastage: after generating marker saying that
the second and later groups of fields of a procedure layout are
not present, do not generate another marker saying that the
third group of fields is not present. Since it was in the wrong
position, it did not have the right meaning; it only worked because,
due to the presence of the first marker, it was never looked at anyway.
compiler/code_gen.m:
Use the new capability of continuation_info.m to require
procedure layouts including procedure id sections for any predicate
that has higher-order arguments, if --stack-trace-higher-order is set.
compiler/globals.m:
Rename want_return_layouts as want_return_var_layouts, since this
is a more accurate representation of what the predicate does.
compiler/call_gen.m:
compiler/code_info.m:
Conform to the change in globals.m.
compiler/llds_out.m:
Separate the c_modules containing compiler-generated code into two
groups, those that define labels that have stack layouts and those
that don't. In most cases one or the other category will be empty,
but with --stack-trace-higher-order, the c_modules containing
higher-order procedures will have stack layouts, while others will
not.
Reorganize the way the way the initialization functions are generated,
by putting c_modules falling into different categories into different
bunches. c_module falling into the first category always have their
initialization code included, while those in the second category
have it included only if the old flag MR_MAY_NEED_INITIALIZATION
is set.
Delete the obsolete #define of MR_STACK_TRACE_THIS_MODULE.
Improve some predicate names, in an effort to prevent confusion
about what a "file" is (since the code uses more than one meaning,
given the presence of --split-c-files).
compiler/pragma_c_gen.m:
Fix an old bug: s/NONDET_FIXED_SIZE/MR_NONDET_FIXED_SIZE/.
Required for the change to library/string.m.
doc/user_guide.texi:
Document the new option.
runtime/mercury_goto.c:
Simplify the conditions under which labels get added to the label
table with:
- The macros init_{entry,label,local}_ai always add
the label to the label table without a layout structure.
- The macros init_{entry,label,local}_sl always add it with a layout
structure.
- Whether the macros init_{entry,label,local} with no suffix
add the label to the label table depends on the values of other
configuration parameters, but they will never include a layout
structure.
The intended use is that any label that has a layout structure should
be initialized with a _sl macro. Any other label that should always
be in the label table if the label table is needed at all (labels
such as do_fail) should be initialized with _ai. Everything else
should be initialized with a suffixless macro.
runtime/mercury_conf_params.c:
Remove MR_USE_STACK_LAYOUTS and MR_STACK_TRACE_THIS_MODULE, since
due to the simplification of mercury_goto.h, they are not used anymore.
runtime/mercury_stack_layout.h:
Remove the old macros for creating layout structures with bogus
contents, and replace them with new macros for creating layout
structures with meaningful contents.
runtime/mercury_engine.c:
runtime/mercury_wrapper.c:
Remove bogus layout structures. Ensure the labels defined here
always get into the label table.
runtime/mercury_ho_call.c:
Remove bogus layout structures. Add proper ones where necessary.
runtime/mercury_bootstrap.c:
runtime/mercury_type_info.c:
Remove bogus layout structures.
runtime/mercury_boostrap.h:
Add this new file for bootstrapping purposes.
Temporarily #define NONDET_FIXED_SIZE as MR_NONDET_FIXED_SIZE, since
pragma_c_gen.m refers to the former until the update to it gets
installed.
runtime/Mmakefile:
Add a reference to mercury_boostrap.h.
library/builtin.m:
Remove bogus layout structures.
library/array.m:
library/benchmarking.m:
library/private_builtin.m:
Remove bogus layout structures. Add proper ones.
library/std_util.m:
Remove bogus layout structures. Add proper ones.
Replace references to framevar(n) with references to MR_framevar(n+1).
Fix an old bug in code under #ifndef COMPACT_ARGS: in the
implementation of mercury____Compare___std_util__univ_0_0_i1, the
succip register was not being saved across the call to
mercury__compare_3_0.
library/string.m:
Remove the need for bogus layout structures, by converting the
implementation of string__append(out, out, in) from hand-written
C module into nondet pragma C code.
Estimated hours taken: 30
Changes to compile the compiler using compilers other then gcc. Tested
on 'cc -std1', 'cc -std1 -migrate' on the alphas, 'cc' and 'lcc' on the
sparcs.
boehm_gc/linux_threads.c:
Ensure that the compilation unit isn't empty by always #including at
least on file.
compiler/llds_out.m:
Remove all remaining occurences of (const Word *).
compiler/mercury_compile.m:
Call transform_llds.
compiler/options.m:
Add the option max_jump_table_size. This option is needed because
lcc barfs when the jump_table for computed gotos size is over 128.
compiler/transform_llds.m:
Transform computed_gotos whose table size is over
max_jump_table_size to binary search down to computed gotos whose
table size is less then or equal to max_jump_table_size.
doc/user_guide.texi:
Document --max-jump-table-size.
library/benchmarking.m:
library/math.m:
library/private_builtin.m:
library/std_util.m:
s/\\n/\\\\n/g so that we don't get line breaks in string constants.
library/io.m:
Change an LVALUE_CAST to type Word as RHS of the expression gets
cast to type Word.
scripts/mgnuc.in:
lcc gets called with "-w" flag to avoid spurious warnings. Also if
--no-ansi is defined pass "-D__EXTENSIONS__" to the compiler to
ensure that all of the header files are read.
trace/mercury_trace_internal.c:
Add a cast to (Word *) because LHS of the expression has type (Word *)
Estimated hours taken: 240
This checkin has several major purposes, set out in the sections below,
all connected with the implementation of the new debugger command set.
DOCUMENT NEW DEBUG COMMAND SET
doc/user_guide.texi:
Add a new section on the debugger. The description of the commands
is complete, but some of the background sections, and the section
about how to build debuggable executables, are not yet done.
Update the documentation of the tracing options.
doc/generate_mdb_doc:
A new shell script that automatically converts some of the new
sections of the user guide into the online documentation of the
debugger.
doc/mdb_categories:
The fixed initial part of the online documentation.
doc/Mmakefile:
Add rules for creating mdb_doc, the file that is the online
documentation of the debugger, and for installing it together
with mdbrc.
Mmake.common.in:
Define INSTALL_DOC_DIR for doc/Mmakefile.
scripts/mdbrc.in:
A debugger command script that reads in the online documentation
and then defines some standard aliases.
configure.in:
Define the variable that scripts/mdb.in and scripts/mdbrc.in use
to find the right files, and get configure to perform the
substitutions.
configure.in:
scripts/mdb:
scripts/mdb.in:
Replace mdb with mdb.in. Mdb is now created during configuration
from mdb.in, filling in the name of the file that contains the default
debugger initialization commands.
util/info_to_mdb.c:
A program that does most of the work involved in automatically
converting user guide sections into online documentation.
(This couldn't easily be written in sh, because sh's read
command has no notion of pushback.)
util/Mmakefile:
Add info_to_mdb to the list of targets.
tools/bootcheck:
Make sure that the tests in tests/debugger are executed with an
initialization setup that is equivalent to what users will see
by default.
REORGANIZE TRACING OPTIONS
compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
compiler/trace.m:
Reorganize the handling of trace levels around the new options
--trace-internal, --trace-redo, and --trace-return.
compiler/*.m:
Use the new ways of getting at trace levels.
tests/hard_coded/typeclasses/Mmakefile:
s/--trace all/--trace deep/
SUPPORT RETRY
compiler/trace.m:
After every call to MR_trace(), emit code that checks whether it
should jump away, and if yes, performs the jump. This is used to
implement retry. (The debugger cannot execute the jump itself
because it is in the wrong C stack frame.)
compiler/llds.m:
compiler/continuation_info.m:
compiler/stack_layout.m:
Modify the data structures that record information about live
value at program points, to record the identity of each variable.
This is necessary for the implementation of the restart command,
since we do not want to confuse two distinct variables just because
they have the same name. For example, a variable whose name is X
and number is 5 is now recorded in the name array as "5:X".
Clean up the data structure a bit, so that we don't have to store
dummy names for values that are not variables.
compiler/*.m:
Minor changes to conform to the data structure changes.
runtime/mercury_stack_layout.h:
Redefine an existing macro to strip away the initial number: prefix
from the "name" of a variable (keeping its original function on
changed data), and add a new one to access the raw unstripped data.
runtime/mercury_init.h:
runtime/mercury_wrapper.h:
Update the prototype of MR_trace_{fake,real}, and the type of the
global that points to them.
runtime/mercury_layout_util.h:
Add an extra function, MR_get_register_number, for use by retry.
USE FIXED STACK SLOTS FOR TRACE INFO
compiler/code_gen.m:
compiler/code_info.m:
compiler/live_vars.m:
compiler/trace.m:
If execution tracing is enabled, reserve the first few stack slots
to hold the event number of the call event, the call number, the
call depth, the redo layout structure address (if generating redo
events) and the from_full flag at the time of call (if we are doing
shallow tracing). By allocating the first four of these to fixed stack
slots, the debugger knows where to look for them without having
to be told. It finds out the location of the fifth, if needed,
from a new slot in the proc layout structure. (It is not possible
to allocate all five to fixed stack slots without wasting stack space
in some cases.)
compiler/trace.m:
Remove from the call to MR_trace the parameters that are now in fixed
stack slots, since MR_trace can now look them up itself.
compiler/continuation_info.m:
compiler/stack_layout.m:
Add an extra field to the proc_layout_info. If the module is shallow
traced, this field says which stack slot holds the saved value of
MR_from_full. If it is not shallow traced, this field says that
there is no such stack slot.
runtime/mercury_stack_layout.h:
Add macros for accessing the fixed stack slots holding the event
number of the call event, the call number, the call depth, and,
at a redo event, the redo layout structure address.
Support the new field in proc layouts that gives the location of the
from-full flag (if any).
runtime/mercury_trace_base.[ch]:
trace/mercury_trace.[ch]:
Remove the call number and call depth arguments from MR_trace
and its avatars, since this info is now in fixed stack slots
in every procedure that can call MR_trace. This should reduce
the size of the executable significantly, since there are lots
of calls to MR_trace.
runtime/mercury_init.h:
runtime/mercury_wrapper.h:
Update the prototype of MR_trace_{fake,real}, and the type of the
global that points to them.
START NUMBERING FRAMEVARS FROM ONE
compiler/code_info.m:
compiler/live_vars.m:
compiler/llds_out.m:
compiler/trace.m:
Start numbering framevars from 1 internally to the compiler;
the runtime already starts from 1. This simplifies several tasks.
ADD REDO EVENTS
compiler/trace.m:
compiler/code_gen.m:
Before the code that executes "succeed()", emit code to push a
a temp nondet frame whose redoip points to a label in the runtime
that calls MR_trace for a REDO event and then fails, provided
--trace-redo is set.
compiler/llds.m:
Add a new code address constant, do_trace_redo_fail, which stands
for the address in the trace system to which calls MR_trace for
the redo event and then fails.
compiler/trace.m:
compiler/llds_out.m:
Provided we are doing redo tracing, fill in the slot that holds
the layout information for the REDO event.
compiler/*.m:
Minor changes to conform to handle the new code address constant.
browser/debugger_interface.m:
Add redo to trace_port_type.
runtime/mercury_trace_base.[ch]:
Add a C module containing the code that calls MR_trace for REDO
events.
ENSURE THAT INPUT ARGUMENTS ARE ALWAYS VISIBLE
compiler/trace.m:
When generating the set of live variables at internal ports,
the variables that are in the pre-death set of the goal into which
we are entering may not be available. However, the variables in the
pre-death set that are also in the resume vars set will be available,
so now include info about them in the layout structure for the event.
Since with tracing the non-clobbered input args are in all resume vars
sets, this ensures that these input args will be available from all
internal events.
compiler/code_info.m:
Export a previously internal predicate (current_resume_point_vars)
to make this possible.
BUG FIX: WANT RETURN LAYOUTS
compiler/globals.m:
compiler/call_gen.m:
compiler/code_info.m:
compiler/mercury_compile.m:
Add a new pred globals__want_return_layouts, which says whether the
compiler should generate layout structures for call returns. This pred
centralizes the several previous copies of the test. One of those
copies (the one in call_gen) was faulty, leading to a bug: in the
presence of execution tracing but the absence of accurate gc,
information about the variables that are live at the call return
wasn't being gathered properly.
BUG FIX: #include mercury_trace_base.h
compiler/llds_out.m:
#include mercury_trace_base.h, not mercury_trace.h, since now
mercury_trace_base.h defines everything directly accessible from
modules compiled with tracing.
RECAST MERCURY_TRACE_UTIL AS MERCURY_LAYOUT_UTIL
runtime/mercury_trace_util.[ch]:
runtime/mercury_layout_util.[ch]:
Rename this module from trace_util to layout_util, since it is also
used by the native garbage collector. Remove "trace" from the names
of functions.
Get rid of the global variable MR_saved_regs, and instead thread
a pointer to this data structure through the relevant functions
as an extra argument.
Add a lot more documentation in the header file.
runtime/Mmakefile:
Reflect the module rename.
runtime/*.c:
Refer to the new module.
DELETE EASY-TO-MISUSE MACROS
runtime/mercury_stacks.h:
Delete the based_framevar and based_detstackvar macros, since their
continued use can lead to off-by-one errors, and the saved_framevar
and saved_detstackvar macros, since they are no longer used.
runtime/*.c
Update any references to any macros removed from mercury_stacks.h.
MISC RUNTIME CHANGES
runtime/mercury_trace_base.[ch]:
trace/mercury_trace*.[ch]:
Make typedef'd names conform to the naming convention.
Make MR_trace_call_{seqno,depth} consistently Unsigned, rather than
sometimes Word and sometimes Unsigned.
FIX BUG: MAKE THE DEBUGGER PRINT TO STDOUT, NOT THE CURRENT STREAM
library/io.m:
Export to C code the predicates that return the identities and types
of stdin, stdout and stderr, as well as io__print/[34].
library/std_util.m:
Export to C code a predicate that returns the type_info for the
type stdutil:type_info. This type_info is required if C code
wants to invoke make_permanent on any type_info structure,
as the debugger does.
runtime/mercury_init.h:
Add extern declarations for the C functions now exported from io.m.
runtime/mercury_wrapper.[ch]:
Add new global variables to hold the addresses of these C functions.
runtime/mercury_layout_util.c:
Use indirect calls through these global variables to print Mercury
values, instead of lower-level code.
util/mkinit.c:
Assign the addresses of the functions exported from io.m to the
global variables defined in mercury_wrapper.h.
BUG FIX: STACK TRACE FUNCTIONS DEPEND ON THE LABEL TABLE
runtime/mercury_stack_trace.c:
On entry to any of the functions exported from this module,
ensure that the label table is loaded by calling do_init_modules.
Without a filled-in label table, the stack trace will not be able to
find any stack layout info.
BUG FIX: REMOVE BROWSER/*.C
configure.in:
When removing .c files generated by the C compiler, remove those
in the browser directory as well as the compiler, library and
profiler directories.
IMPLEMENT NEW DEBUGGER COMMAND SET
runtime/mercury_stack_trace.[ch]:
Factor out the code that prints the id of a procedure into a function
of its own, so that it can also be used from the debugger, ensuring
appearance commonality.
Add more documentation in the header file.
trace/mercury_trace_internal.c:
Implement the proposed command set. Command names are now words,
and several commands now have options allowing the user to override
the default print level or strictness of the command, or the
invocation conditions or action of a break point. Allows control
over command echoing and the scrolling of sequences of event reports.
Supports aliases, command file sourcing etc. Implements the retry
command, using the info in the fixed stack slots.
trace/mercury_trace.[ch]:
Extend the trace controls to support the new functionalities
required by the new debugger language, which are print levels,
variable-strictness commands, a more flexible finish command,
and the retry command.
Pass the command structure to MR_trace_event_report, since
the user can now forcibly terminate the scrolling of reports.
trace/mercury_trace_alias.[ch]:
New module to manage aliases for the debugger.
trace/mercury_trace_help.[ch]:
New module to interface to browser/help.m.
trace/mercury_trace_spy.[ch]:
New module to manage break points. The test of whether an event
matches a break point is now much more efficient than before.
The new module also allows several breakpoints with different
actions and different invocation conditions (e.g. all ports,
entry port, interface ports or specific (possibly internal) port)
to be defined on the same procedure.
trace/mercury_trace_tables.[ch]:
New module to manage a table of the debuggable modules, in which
each such module is linked to the list of the layouts of all the
procedures defined in that module. This information allows the
debugger to turn the name of a predicate/function (possibly together
with its arity and mode number) into the procedure layout structure
required by the spy point module. Eventually it may also be useful
in supplying lists of identifiers for command line completion.
Modules for which no stack layout information is available will
not be included in the table, since do_init_modules will not
register any labels for them in the label table.
trace/Mmakefile:
Mention the new files.
runtime/mercury_array_macros.h:
A new file holding macros that can be useful in more than one module.
runtime/Mmakefile:
Mention the new file.
runtime/mercury_conf.h.in:
Mention a new configuration macro, MR_CANNOT_USE_STRUCTURE_ASSIGNMENT,
used by runtime/mercury_array_macros.h.
configure.in:
Find out whether we need to define MR_CANNOT_USE_STRUCTURE_ASSIGNMENT.
ADD TRACE DEPTH HISTOGRAMS
runtime/mercury_conf_param.h:
Document MR_TRACE_HISTOGRAM.
runtime/mercury_trace_base.[ch]:
Define the data structures for the histogram, and print the histogram
when a traced program exits if MR_TRACE_HISTOGRAM is set.
trace/mercury_trace.[ch]:
If MR_TRACE_HISTOGRAM is defined, record a count of the number of
events at each depth. This information can help us evaluate space-time
tradeoffs.
FACTOR OUT SHELL CODE HANDLING GRADE IMPLICATIONS
scripts/final_grade_options.sh-subr:
A new file to contain any code that implements implications between
grade flags; currently implements the implication debug -> use trail.
scripts/mgnuc.in:
scripts/ml.in:
Replace the code that is now in final_grade_options.sh-subr with
an inclusion of final_grade_options.sh-subr.
configure.in:
Handle final_grade_options.sh-subr as {init,parse}_grade_options.sh-subr
are handled.
SIMPLIFY THE MAINTAINANCE OF CONSISTENCY BETWEEN DEBUGGER CODE AND DOCUMENTATION
doc/Mmakefile:
Add rules for creating mdb_command_list, a C code fragment
that can included manually in trace/mercury_trace_internal.c
to supply the list of valid commands, and mdb_command_test.inp,
which is a list of invalid invocations of debugger commands,
which tests whether the help message for such invocations
can be located as expected.
doc/generate_mdb_command_list:
doc/generate_mdb_command_test:
Awk scripts to create mdb_command_list and mdb_command_test.inp
respectively from mdb_doc.
tools/bootcheck:
Copy mdb_command_test.inp from doc to tests/debugger.
tests/debugger/Mmakefile:
Add a new test that checks whether we get an internal error, unable
to locate the right help node, for each invalid command invocation in
mdb_command_test.inp.
UPDATE TEST CASES
tests/debugger/Mmakefile:
Reenable queens. Conform to the new set of options.
tests/debugger/*.inp:
tests/debugger/*.exp:
Update the inputs and expected outputs of the debugger test cases
to use the new command set and output formats.
Estimated hours taken: 0.5
Another fix to my change to ensure that the declarations and definitions
for data constants specify the same linkage (extern or static).
This one is needed to make it work with --split-c-files.
runtime/mercury_goto.h:
Add an `MR_' prefix to the MODULE_STATIC_OR_EXTERN.
library/array.m:
library/builtin.m:
library/std_util.m:
extras/clpr/cfloat.m:
Use MR_MODULE_STATIC_OR_EXTERN instead of `static' on the hand-coded
definitions of the base_type_functors and base_type_layouts for
builtin types.
Estimated hours taken: 3
Ensure that the declarations and definitions for data constants
specify the same linkage (extern or static), because the C standard
says that if the linkage is different, then the behaviour is undefined.
This bug resulted in undefined symbol link errors for the RS/6000 AIX port.
compiler/llds_out.m:
When printing out declarations for data constants,
compute the linkage from the data_name, rather than
always assuming `extern'. When printing out definitions,
add a sanity check to ensure that the linkage that would be
computed from the data_name is the same as the linkage used
for the definition.
compiler/base_type_info.m:
Make base_type_infos always exported from the module, never local.
This is necessary to ensure that the linkage can be
computed from the data_name.
compiler/base_type_layout.m:
Make base_type_functors and base_type_info structures
always local to the module, rather than exported.
This is necessary to ensure that the linkage can be
computed from the data_name.
library/array.m:
library/builtin.m:
library/std_util.m:
Add `static' to the hand-coded definitions of the base_type_functors
and base_type_layouts for builtin types.
compiler/base_typeclass_info.m:
compiler/llds.m:
compiler/stack_layout.m:
Add comments pointing to the new predicate linkage/2 in
llds_out.m, to ensure that future maintenance doesn't break
the assumptions it makes.
Estimated hours taken: 1
Make std_util:type_info/0 different to private_builtin:type_info/1.
library/std_util.m:
Although std_util:type_info/0 is equivalent to
private_builtin:type_info/1, we want to make this equivalence
opaque, so we will reuturn std_util:private_builtin to its
previous definition. Of course it is still implemented as the
same type.
Estimated hours taken: 3
Allow private_builtin:type_info/1 to be printed using io__write.
library/io.m:
Use another horrible hack to find private_builtin:type_info/1
to be detected and handled as if it were std_util:type_info/0
for printing.
library/private_builtin.m:
Add a hand-written type defintion for
private_builtin:type_info/1. (Much the same definition that
was previously used for std_util:type_info/0.
library/std_util.m:
Define std_util:type_info/0 as an abstract equivalence to
private_builtin:type_info/1.
Remove the old type defintions for std_util:type_info/0.
Estimated hours taken: 50
This change implements one by one retrieval of live variables within the
external debugger. To do so, we basically need two new primitives at the
debugger user disposal: 'current_live_var_names/0' to retrieve the live
variables names and their types (to let user chose which variable he wants to
retrieve) and 'current_nth_var/1' to retrieve the live variable given in
argument.
library/debugger_interface.m:
Implement new predicates that are called in mercury_trace_external.c:
output_current_nth_var/5 send to the debugger process the requested
live variable.
output_current_live_var_names/6 send to the debugger process the
list of the internal names of the currently live variables and the
list of their corresponding types.
get_var_number/1 returns the integer 'n' where its argument is of the
form 'current_nth_var(n)'.
library/std_util.m:
Export type_name/1; is is needed to convert type_info into string in
mercury_trace_external.c.
runtime/mercury_init.h:
Add prototype declarations for the new procedures.
runtime/mercury_trace_external.c:
MR_output_current_nth_var() calls the predicate output_current_nth_var/5
defined in library/debugger_interface.m.
MR_output_current_live_var_names() calls the predicate
output_current_live_var_names/6 defined in library/debugger_interface.m.
MR_trace_make_type_list() returns the list of the types of the live
variables.
MR_trace_make_nth_var() returns the requested live variables.
MR_get_var_number() calls the predicate get_var_number/1 defined in
library/debugger_interface.m.
runtime/mercury_trace_util.c:
runtime/mercury_trace_util.h:
Define a new function MR_trace_get_type() that retrieves the
type_info of a live variable. It is the same function as
MR_trace_get_type_and_value() except it does not retrieves the value.
Abstract away the code by folding duplicated code into 2
new functions MR_trace_get_type_and_value_filtered() and
MR_trace_get_type_filtered().
runtime/mercury_wrapper.h:
Declare prototypes of new procedures.
util/mkinit.c:
Handling new procedures.
Estimated hours taken: 90
An initial implementation of the accurate garbage collector.
WORK_IN_PROGRESS:
Add an entry for the accurate garbage collector.
library/builtin.m:
library/mercury_builtin.m:
library/std_util.m:
runtime/mercury_tabling.h:
Deep copy terms using the address of the value instead of
just the value.
library/io.m:
Initialize the garbage collector's rootset with the globals.
runtime/Mmakefile:
Add new files to the Mmakefile.
runtime/mercury_accurate_gc.h:
runtime/mercury_accurate_gc.c:
The new garbage collector.
runtime/mercury_agc_debug.c:
runtime/mercury_agc_debug.h:
Debugging utilities for the new garbage collector.
runtime/mercury_deep_copy.c:
runtime/mercury_deep_copy.h:
runtime/mercury_deep_copy_body.h:
Put the deep copy code in mercury_deep_copy_body.h, and #include
it with appropriate #defines in order to get a variant for
deep_copy(), and one for agc_deep_copy().
agc_deep_copy() forwards pointers as it copies.
Also, deep_copy (all variants) have been modified to take
a pointer to the data to be copied, because some variants
need to be able to modify it.
runtime/mercury_engine.c:
runtime/mercury_engine.h:
Add a second heap_zone which is the to-space of
the copying collector.
Add a debug_heap_zone, which is used as a scratch
heap for debugging.
runtime/mercury_label.c:
Instead of
realloc(entry_table, ....)
do
entry_table = realloc(entry_table, ....)
to avoid horrible bugs.
Also, make sure the tables get initialized before looking up
an entry label.
runtime/mercury_imp.h:
Include mercury_debug.h before most of the modules.
(mercury_engine.h adds a new MemoryZone only if we are
debugging accurate GC).
runtime/mercury_memory.c:
Setup the debug_memory_zone sizes.
Remove an unnecessary prototype.
runtime/mercury_memory_handlers.c:
Add code to get the program counter and the stack pointer
from the signal context.
Call MR_schedule_agc() from default_handler() if doing accurate gc.
runtime/mercury_memory_zones.c:
Setup the hardzone regardless of whether redzones are used.
Add some more debugging information.
runtime/mercury_regorder.h:
runtime/machdeps/alpha_regs.h:
runtime/machdeps/i386_regs.h:
Add definitions to make the real machine registers name/number
for MR_sp available.
runtime/mercury_trace_internal.c:
runtime/mercury_trace_util.c:
runtime/mercury_trace_util.h:
Add MR_trace_write_variable(), which writes terms given their
value and type_info.
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
Change the size of the heap redzone when doing accurate GC.
Use a small heap when debugging agc.
runtime/mercury_debug.h:
runtime/mercury_conf_param.h:
Add new debugging macros and document them.
runtime/mercury_type_info.c:
Add const to the pointer arguments of MR_make_type_info.
Estimated hours taken: 0.5
Fix *another* bug in std_util.
library/std_util.m:
ML_expand used data_value when it should have used data_word.
For types such as ints and chars, it was giving the wrong values
because the tag bits were removed.
Estimated hours taken: 2
Fix some bugs in ML_expand that were triggered when writing out
.opt files with terminiation analysis on.
library/std_util.m:
Initialize functors_indicator (it was being used uninitialized,
so it would indentify a univ as a complicated constant...
Use strip_tag() instead of body() (avoids use of entry_tag, which
is also uninitialized.
Use data_word for enumerations, not data_value (cut and paste
error).
Set type_info_vector to NULL for enumerations.
Estimated hours taken: 4
Use MR_categorize_data to simplify control flow.
library/std_util.m:
runtime/mercury_table_any.c:
Change ML_expand and MR_table_type to use MR_categorize_data.
runtime/mercury_deep_copy.h:
Add a comment about deep_copy and sharing.
runtime/mercury_type_info.h:
runtime/mercury_deep_copy.c:
Change the order of simple and complicated cases, (sometimes
you can reduce a complicated case into a simple case, so
fall-through can be used to reduce code duplication).
configure.in:
Add a test to find the number of words needed to represent a
synchronization term.
boehm_gc/gc.h:
fix a declaration by replacing the args () with (void).
boehm_gc/solaris_pthreads.c:
add a missing include
check the return values of pthread calls.
compiler/*.m:
Add handling for the new HLDS goal type par_conj.
Add handling for the four new LLDS instructions:
init_sync_term
fork
join_and_terminate
join_and_continue
compiler/code_info.m:
add a new alternative for slot_contents - sync_term.
compiler/handle_options.m:
add .par as part of the grade
compiler/hlds_goal.m:
add the new goal type par_conj.
compiler/instmap.m:
add instmap__unify which takes a list of instmaps
and abstractly unifies them.
add unify_instmap_delta which tajes two instmap deltas
and abstractly unifies them.
compiler/llds.m:
add the new llds instructions.
compiler/mode_info.m:
add par_conj as a lock reason.
library/Makefile:
work around a bug in the solaris version pthread.h
library/benchmarking.m:
reference the stack zones from the engine structure
rather than from global variables.
library/{nc,sp}_builtin.nl:
add an op declaration for &.
library/std_util.m:
change references to global variables to references inside
the engine structure.
runtime/Mmakefile:
add mercury_thread.{c,h}
add THREADLIBS to the libraries
runtime/*.{c,h}
Remove some old junk from the previous processes/shrd-mem
changes that found their way into the repository.
Add MR_ prefixes to lots of names.
runtime/mercury_context.c:
Add init_thread_stuff for creating and initializing a
context structure for the current thread.
runtime/mercury_context.h:
add a field to the mercury context which stores the thread id
of the thread where this context originated.
add various macros for implementing the new llds instructions.
runtime/mercury_engine.c:
initialize the engine structure, rather than a bunch of globals.
runtime/mercury_engine.h:
declare the mercury_engine structure.
runtime/mercury_regorder.h:
if MR_THREAD_SAFE, and there is at least one global register
then use mr0 as a pointer to the mercury engine structure.
scripts/init_grade_options.sh-subr
add thread_safe
scripts/mgnuc.in
add THREAD_OPTS
scripts/ml.in:
add THREAD_LIBS
Estimated hours taken: 6
Fix various invasions of the user's namespace by `mercury_builtin.m',
by splitting mercury_builtin.m into two modules, called builtin.m and
private_builtin.m, and ensuring that the latter is imported as if
by `:- use_module' rather than `:- import_module'.
library/builtin.m:
library/private_builtin.m:
Split mercury_builtin.m into two modules, builtin.m,
which contains stuff intended to be public,
and private_builtin.m, which contains implementation
details that are not supposed to be public.
library/mercury_builtin.m:
Add a comment saying that this module is no longer used, and
should eventually be removed. I have not removed it yet, since
that would prevent bootstrapping with the current compiler. It
will be removed as a seperate change later, once all the
changes have propagated.
compiler/prog_util.m:
Change the definition of mercury_private_builtin_module/1 and
mercury_public_builtin_module so that instead of automatically
importing mercury_builtin.m as if by `import_module', the
copiler will now automatically import builtin.m as if by
`import_module' and private_builtin.m as if by `use_module'.
compiler/polymorphism.m:
Change a call to mercury_private_builtin_module/1 for
unsafe_promise_unique to instead call mercury_public_builtin_module/1.
compiler/unify_proc.m:
Avoid hard-coding "mercury_builtin" by instead
calling one of mercury_{private,public}_builtin_module/1.
runtime/mercury_type_info.[ch]:
library/term.m:
library/std_util.m:
compiler/code_util.m:
Change a few hard-coded instances of "mercury_builtin"
to "builtin" or "private_builtin" as appropriate.
runtime/mercury_trace_util.c:
runtime/mercury_trace_internal.c:
library/prolog.m:
compiler/*.m:
Update comments that refer to "mercury_builtin" to instead
refer to either "builtin" or "private_builtin".
doc/Mmakefile:
Don't include the interface to private_builtin.m in the
library reference manual.
tools/bootcheck:
Add `-p'/`--copy-profiler' option. This is needed to get
the above changes to bootstrap.
tools/test_mercury:
Pass `-p' to tools/bootcheck.
tests/term/*.trans_opt_exp:
s/mercury_builtin/builtin/g
Estimated hours taken: 250
Add support for tabling.
This change allows for model_det, model_semidet and model_non memoing,
minimal model and loop detection tabling.
compiler/base_type_layout.m:
Update comments to reflect new runtime naming standard.
compiler/det_analysis.m:
Allow tabling to change the result of det analysis. This is
necessary in the case of minimal model tabling which can
turn a det procedure into a semidet one.
compiler/det_report.m:
compiler/hlds_data.m:
Add code to report error messages for various non compatible
tabling methods and determinism.
compiler/hlds_out.m:
compiler/modules.m:
Remove reference to the old memo marker.
compiler/hlds_pred.m:
Create new type (eval_method) to define which of the available
evaluation methods should be used each procedure.
Add new field to the proc_info structure.
Add several new predicates relating to the new eval_method type.
compiler/inlining.m:
compiler/intermod.m:
Make sure only procedures with normal evaluation are inlined.
compiler/make_hlds.m:
Add code to process new tabling pragmas.
compiler/mercury_compile.m:
Call the tabling transformation code.
compiler/modes.m:
Make sure that all procedures with non normal evaluation have
no unique/partially instantiated modes. Produce error messages
if they do. Support for partially instantiated modes is currently
missing as it represents a large amount of work for a case that
is currently not used.
compiler/module_qual.m:
compile/prog_data.m:
compiler/prog_io_pragma.m:
Add three new pragma types:
`memo'
`loop_check'
`minimal_model'
and code to support them.
compiler/simplify.m:
Don't report infinite recursion warning if a procedure has
minimal model evaluation.
compiler/stratify.m:
Change the stratification analyser so that it reports cases of
definite non-stratification. Rather than reporting warnings for
any code that is not definitely stratified.
Remove reference to the old memo marker.
compiler/switch_detection.m:
Fix a small bug where goal were being placed in reverse order.
Call list__reverse on the list of goals.
compiler/table_gen.m:
New module to do the actual tabling transformation.
compiler/notes/compiler_design.html:
Document addition of new tabling pass to the compiler.
doc/reference_manual.texi:
Fix mistake in example.
library/mercury_builtin.m:
Add many new predicates for support of tabling.
library/std_util.m:
library/store.m:
Move the functions :
ML_compare_type_info
ML_collapse_equivalences
ML_create_type_info
to the runtime.
runtime/mercury_deep_copy.c:
runtime/mercury_type_info.h:
runtime/mercury_type_info.c:
Move the make_type_info function into the mercury_type_info module
and make it public.
runtime/Mmakefile:
runtime/mercury_imp.h:
Add references to new files added for tabling support.
runtime/mercury_string.h:
Change hash macro so it does not cause a name clash with any
variable called "hash".
runtime/mercury_type_info.c:
runtime/mercury_type_info.h:
Add three new functions taken from the library :
MR_compare_type_info
MR_collapse_equivalences
MR_create_type_info.
runtime/mercury_table_any.c:
runtime/mercury_table_any.h:
runtime/mercury_table_enum.c:
runtime/mercury_table_enum.h:
runtime/mercury_table_int_float_string.c:
runtime/mercury_table_int_float_string.h:
runtime/mercury_table_type_info.c:
runtime/mercury_table_type_info.h:
runtime/mercury_tabling.h:
New modules for the support of tabling.
Estimated hours taken: 0.5
library/std_util.m:
library/term.m:
Move det_univ_to_type from term.m to std_util.m, and
add better error reporting (print the types of the univ
and the data).
NEWS:
Document this change to std_util.
Estimated hours taken: 1.5
Fix profiling problems caused by the hand-coded low-level C code
not setting up the profiling information correctly.
library/std_util.m:
Fix some typos in the "caller" argument of call() instructions
in the hand-coded low-level C code for builtin_aggregate/4.
library/string.m:
library/benchmarking.m:
library/std_util.m:
Add calls to set_prof_current_proc() at resumption labels
in hand-coded low-level C code.
For string__append_3_3, use tailcall() rather than GOTO,
so that we set prof_current_proc.
Estimated hours taken: 0.5
library/*.m:
compiler/*.m:
Undo Zoltan's bogus update of all the copyright dates.
The dates in the copyright header should reflect the years
in which the file was modified (and no, changes to the
copyright header itself don't count as modifications).
Estimated hours taken: 5
library/std_util.m:
Fix a bug in ML_create_type_info():
when searching for type parameters to substituting with their
corresponding values, they were only looking at the top level
of the type. To get correct results, it is necessary to
traverse recursively through all levels of the type.
runtime/mercury_deep_copy.c:
Fix a bug similar to the one above in make_type_info().
The fix is a bit more complicated, due to memory management
issues --- we need to keep a linked list of all the memory
cells we allocate so that we can free them when we're done.
Also avoid some duplicated code in mercury_deep_copy.c
by introducing a new function deep_copy_arg().
And fix a bug in deep_copy_type_info(): it should be
allocating memory using incr_saved_hp(), not using
make(). make() calls newmem(), which in non-conservative GC
grades calls malloc(), which results in a memory leak;
whereas incr_saved_hp() allocates on the Mercury heap,
which is (in accurate gc grades) subject to garbage collection.
tests/hard_coded/Mmakefile:
tests/hard_coded/eqv_type_bug.m:
tests/hard_coded/eqv_type_bug.exp:
Regression test for the above-mentioned bug in ML_create_type_info().
Estimated hours taken: 30
Add library and runtime support for stack layouts.
library/array.m:
library/benchmarking.m:
library/mercury_builtin.m:
library/std_util.m:
library/string.m:
runtime/mercury_engine.c:
runtime/mercury_ho_call.c:
runtime/mercury_type_info.c:
Add MR_MAKE_STACK_LAYOUT_* macros to add basic stack layouts for
handwritten C code.
runtime/mercury_type_info.c:
Remove some duplicate label declarations.
runtime/mercury_calls.h:
Don't use ASM_FIXUP_REGS in calls with NATIVE_GC - we don't
want (or need) to use it. We define all labels as entry labels
anyway, so an ASM_FIXUP_REGS is done at each label.
runtime/mercury_label.c:
runtime/mercury_label.h:
runtime/mercury_goto.h:
Insert references to stack layouts into the label table.
Use the label table when NATIVE_GC is defined.
Modify the way labels are declared so they have the necessary
scope.
runtime/mercury_imp.h:
Include mercury_accurate_gc.h
runtime/mercury_accurate_gc.h:
Add some macros to define stack layouts for handwritten
code, and access various fields of the stack layouts.
util/mkinit.c:
Add NATIVE_GC to the #ifdef .... that controls the running of
the initialization code for each module. NATIVE_GC requires the
label table to be initialized.
Fix this code so the two instances of this list of #defines are
replaced by a single string constant. I've been bitten _twice_
by this double definition, and I refuse to be bitten again.
compiler/stack_layout.m:
Rename MR_LIVE_LVAL to Mr_Live_Lval in the documentation.
Estimated hours taken: 0.25
library/benchmarking.m:
library/float.m:
library/int.m:
library/io.m:
library/mercury_builtin.m:
library/std_util.m:
Use "mercury_foo.h" instead of "foo.h".
Use `pragma c_code(...)' instead of the obsolete syntax
`pragma(c_code, ...)' (I only changed some of the
occurrences of this).
Estimated hours taken: 5
This diff starts migrating global variables into virtual registers,
removes some junk code to do with parallelism, and renames the
special registers with MR_ prefixes.
compiler/llds_out.m:
rename hp, etc as MR_hp, etc.
library/std_util.m:
rename hp and solutions_heap_pointer.
runtime/*:
- remove old parallelism stuff that will change completely when
we use posix threads.
- rename the various special registers (hp, sp, etc) with a MR_
prefix.
- make the solutions heap pointer and the minimum heap reclaimation
point virtual registers rather than global variables.
Estimated hours taken: 4
Dectect floundering in solutions/2 and nondet if-then-else.
library/std_util.m:
Change the code for builtin_aggregate to (a) check for
floundering and (b) reset the trail properly.
compiler/code_gen.m:
Change the code for if-then-elses with nondet conditions
so that it checks for floundering.
runtime/mercury_trail.h:
compiler/llds.m:
compiler/llds_out.m:
Add new alternative `MR_solve' to MR_untrail_reason.
This is used to for checking for floundering in the
above-mentioned two cases.
extras/clpr/cfloat.m:
extras/trailed_update/var.m:
Handle the MR_solve case.
doc/reference_manual.texi:
Document MR_solve.
NEWS:
Delete the mention of the limitation that we didn't
dectect floundering in solutions/2 and nondet if-then-else.
Estimated hours taken: 0.25
library/std_util.m:
Fix yet another trivial little bug in the non-gc
version of the C code for builtin_aggregate/4.
This time it was a wrong continuation label.
Estimated hours taken: 3 (+ unknown time by Peter Schachte)
library/std_util.m:
Implement unsorted_aggregate so that it interleaves the
generator and the accumulator, rather than generating all
the solutions before folding them.
Estimated hours taken: 5
library/store.m:
Complete rewrite. Renamed everything in the existing interface,
added lots to the interface, and implemented it efficiently.
This file now contains preliminary support for my idea of
"declaring an imperative data structure".
library/store.nu.nl:
Prolog version of store.m.
library/Mmakefile:
Add store.nu to the list of NU-Prolog files and SICStus files.
library/std_util.m:
Factor out the code for argument/2 into a C function ML_arg()
so that it can also be used in store__arg_ref.
Change ML_expand so that it takes a pointer to the term to expand,
so that it can be used for store__arg_ref on no_tag types.
Add arg/2 and det_arg/2: similar to argument/2 and det_argument/2,
except they take any argument type and fail if the type doesn't
match, rather than returning a univ. (Hmm... is this a good idea?)
Estimated hours taken: 0.25
compiler/code_gen.m:
compiler/ite_gen.m:
library/std_util.m:
Add an XXX comment saying that we should check for delayed
non-linear goals in negations and if-then-else.