mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-13 04:44:39 +00:00
ecdc285bc705d08e5dc08a0e88d6fde20c24bd1c
26 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f007b45df8 |
Implement the infrastructure for term size profiling.
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.
|
||
|
|
c0f4d93a3c |
Add a new grade component, .decldebug. It is as proposed on mercury-developers,
Estimated hours taken: 2 Branches: main Add a new grade component, .decldebug. It is as proposed on mercury-developers, minus the implications about I/O tabling. Those will come later. compiler/options.m: Add a new option, --decl-debug, that switches on declarative debugging. compiler/trace_params.m: The procedure that converts strings representing trace levels to trace levels themselves now has an extra argument, which gives the value of the --decl-debug option. If set, it raises the minimum trace level, and turn explicitly specifying trace levels `shallow' and `deep' into errors (since they are not sufficient for declarative debugging). compiler/handle_options.m: Pass the value of the --decl-debug option to trace_params, and handle the errors that may result. Handle the implications of --decl-debug and the .decldebug grade component. compiler/compile_target_code.m: Define MR_DECL_DEBUG when invoking the C compiler if --decl-debug is set. runtime/mercury_conf_param.h: Document MR_DECL_DEBUG, which is defined iff the grade is a .decldebug grade. runtime/mercury_grade.h: Take MR_DECL_DEBUG into account when computing the grade component related to debugging. Update the list of places that need to be modified when adding new grade components. doc/user_guide.texi: Document --decl-debug and the .decldebug grade component. Document the events used by declarative debugging, since Mark didn't. Fix some minor unrelated omissions. scripts/init_grade.sh-subr: scripts/parse_grade_options.sh-subr: scripts/final_grade.sh-subr: scripts/canonical_grade.sh-subr: scripts/mgnuc.in: scripts/ml.in: Add a new shell variable, decl_debug, to represent the value of MR_DECL_DEBUG, and handle it as appropriate. tests/debugger/Mmakefile: Do not execute shallow traced tests in .decldebug grades, since we don't support shallow tracing in such grades. Specify --trace decl instead of --trace deep in .decldebug grades when compiling the other tests, since we don't support --trace deep in .decldebug grades. |
||
|
|
17d5aa732e |
Add support for interfacing Mercury with the MPS garbage collector.
Estimated hours taken: 20
Branches: main
Add support for interfacing Mercury with the MPS garbage collector.
This change is broken into three parts:
1. Import version 1.100.1 of the MPS kit into the Mercury
CVS repository, in the directory `mps_gc'.
2. Make some changes to the MPS kit for Mercury,
to support fully-conservative collection and tagged pointers,
and to wrap it in an interface that is similar to that of
the Boehm collector.
3. Modify the rest of the Mercury implementation
to support linking with the MPS kit instead
of the Boehm collector. This involved defining
`mps' as a new GC method and a new grade component.
This is part 3 of 3.
Mmake.workspace:
Include the MPS directories in the header file and library search
paths.
tools/bootcheck:
Link the mps_gc directory into the stage2 and stage3 directories.
Mmake.workspace:
runtime/Mmakefile:
scripts/ml.in:
For *.mps grades, link in mps.a.
(XXX ml.in is linking in libmps.a, which is wrong.)
runtime/Mmakefile:
trace/Mmakefile:
In the rule for `check_headers', which checks macro namespace
cleanliness, allow names to start with `MPS_' or `mps_'.
runtime/RESERVED_MACRO_NAMES:
Add `mercury_mps_h', which is used by mps_gc/code/mercury_mps.h
for its header guard. (Normally it would be better to use
uppercase for header guard macro names, but that would be
inconsistent with the coding style used in mps_gc/code.)
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade.sh-subr:
Handle the new `mps' GC method and grade component.
compiler/globals.m:
compiler/options.m:
doc/user_guide.texi:
Replace gc_method `conservative' with two alternatives
`boehm' and `mps'. ("--gc conservative" is still allowed,
and treated as equivalent to "--gc boehm".)
Add new function `gc_is_conservative' to globals.m.
compiler/mercury_compile.m:
compiler/handle_options.m:
Use `gc_is_conservative' rather than `= conservative'.
compiler/handle_options.m:
Handle the "mps" grade component.
(XXX need to document this in options.m and user_guide.texi)
compiler/compile_target_code.m:
Pass the appropriate C defines for the new GC methods.
compiler/mercury_compile.m:
Wrap the work-around for a Boehm GC bug inside `#ifndef MR_MPS_GC'.
library/array.m:
Use GC_FREE() rather than GC_free().
This is needed for two reasons:
- so that it works with MPS, which only defines GC_FREE
- so that it works with then Boehm collector when
GC debugging is enabled
library/benchmarking.m:
Output GC statistics for the MPS collector.
runtime/mercury.h:
runtime/mercury_heap.h:
runtime/mercury_init.h:
runtime/mercury_memory.h:
If MR_MPS_GC is defined, use mercury_mps.h rather than gc.h.
runtime/mercury_conf_param.h:
Add configuration macros MR_BOEHM_GC and MR_MPS_GC.
Set MR_CONSERVATIVE_GC if either of these is set.
Default to MR_BOEHM_GC if only MR_CONSERVATIVE_GC is set.
runtime/mercury_context.h:
runtime/mercury_deep_copy.h:
runtime/mercury_engine.h:
runtime/mercury_float.h:
runtime/mercury_heap.h:
Explictly #include "mercury_conf.h", so that
MR_CONSERVATIVE_GC will be set properly before it is tested.
runtime/mercury_grade.h:
Handle the .mps grade component.
runtime/mercury_memory.c:
runtime/mercury_wrapper.c:
runtime/mercury_memory_handlers.c:
Move the call to MR_setup_signals() earlier in the
initialization sequence, so that the MPS signal handlers
get installed after our signal handlers. This is needed
because our signal handlers assume that any signals that
they can't handle are fatal errors, which interfere's
with MPS's use of signal handlers for memory barriers.
runtime/mercury_wrapper.c:
Add code to initialize the MPS collector.
Put code which is specific to the Boehm collector inside
#ifdef MR_BOEHM_GC rather than #ifdef MR_CONSERVATIVE_GC.
runtime/mercury_wrapper.h:
Update a comment.
|
||
|
|
04e614485d |
Implement deep profiling; merge the changes on the deep2 branch back
Estimated hours taken: 500 Branches: main Implement deep profiling; merge the changes on the deep2 branch back onto the trunk. The main documentation on the general architecture of the deep profiler is the deep profiling paper. doc/user_guide.texi: Document how to use the deep profiler. deep_profiler: deep_profiler/Mmakefile: A new directory holding the deep profiler and its mmakefile. Mmakefile: Add targets for the new directory. Add support for removing inappropriate files from directories. deep_profiler/interface.m: The deep profiler consists of two programs: mdprof_cgi.m, which acts as a CGI "script", and mdprof_server.m, which implements the server process that the CGI script talks to. Interface.m defines the interface between them. script/mdprof.in: A shell script template. ../configure uses it to generate mdprof, which is a wrapper around mdprof_cgi that tells it how to find mdprof_server. deep_profiler/mdprof_cgi.m: The CGI "script" program. deep_profiler/mdprof_server.m: The top level predicates of the server. deep_profiler/profile.m: The main data structures of the server and their operations. deep_profiler/read_profile.m: Code for reading in profiling data files. deep_profiler/startup.m: Code for post-processing the information in profiling data files, propagating costs from procedures to their ancestors and performing various kinds of summaries. deep_profiler/server.m: Code for responding to requests from the CGI script. deep_profiler/cliques.m: Code to find cliques in graphs. deep_profiler/array_util.m: deep_profiler/util.m: Utility predicates. deep_profiler/dense_bitset.m: An implementation of (part of) the set ADT with dense bit vectors. deep_profiler/measurements.m: Operations on profiling measurements. deep_profiler/timeout.m: An implementation of a timeout facility. deep_profiler/conf.m: Functions that depend on autoconfigured settings. configure.in: Find out what command to use to find the name of the local host. Install deep profiling versions of the standard library along with the other profiling versions. runtime/mercury_conf.h.in: Add some macros for deep_profiler/conf.m to use. library/profiling_builtin.m: runtime/mercury_deep_call_port_body.h: runtime/mercury_deep_leave_port_body.h: runtime/mercury_deep_redo_port_body.h: A new library module that implements deep profiling primitives. Some of these primitives have many versions, whose common code is factor is factored out in three new include files in the runtime. compiler/deep_profiling.m: New module to perform the program transformations described in the paper. compiler/notes/compiler_design.html: Document the new compiler module. compiler/mercury_compiler.m: Invoke the new module in deep profiling grades. Allow global static data to be generated by deep_profiling.m. compiler/options.m: Add options to turn on deep profiling and (for benchmarking purposes) control its implementation. Add an optiooption disable tailcall optimization in the LLDS backend, to help benchmarking deep profiling. compiler/jumpopt.m: compiler/optimize.m: Obey the option to disable tailcalls. compiler/handle_options.m: Handle the implications of deep profiling. compiler/modules.m: In deep profiling grades, automatically import profiling_builtin.m. compiler/prog_util.m: doc/Makefile: library/library.m: Handle the new builtin module. compiler/export.m: In deep profiling grades, wrap deep profiling code around exported procedures to handle the "unscheduled call" aspects of callbacks to Mercury from the foreign language. compiler/higher_order.m: profiler/demangle.m: util/demangle.c: When creating a name for a higher-order-specialized predicate, include the mode number in the name. compiler/add_trail_ops.m: compiler/type_util.m: Move c_pointer_type from add_trail_ops to type_util, so it can also be used by deep_profiling.m. compiler/hlds_goal.m: Add a new goal feature that marks a tail call, for use by deep_profiling.m. compiler/hlds_pred.m: Add a new field to proc_info structures for use by deep_profiling.m. Add a mechanism for getting proc_ids for procedure clones. Remove next_proc_id, an obsolete and unused predicate. compiler/hlds_data.m: Add a new cons_id to refer to the proc_static structure of a procedure. compiler/bytecode_gen.m: compiler/code_util.m: compiler/dependency_graph.m: compiler/hlds_out.m: compiler/mercury_to_mercury.m: compiler/ml_unify_gen.m: compiler/opt_debug.m: compiler/prog_rep.m: compiler/rl_exprn.m: compiler/switch_util.m: compiler/unify_gen.m: Trivial changes to handle the new cons_id, goal feature and/or proc_info argument. compiler/rtti.m: Add a utility predicate for extracting pred_id and proc_id from an rtti_proc_label, for use by hlds_out.m compiler/layout.m: compiler/layout_out.m: compiler/llds.m: compiler/llds_common.m: Add support for proc_static and call_site_static structures. compiler/layout_out.m: compiler/llds_out.m: Add code for the output of proc_static structures. compiler/code_util.m: Make code_util__make_proc_label_from_rtti a function, and export it. util/mkinit.c: compiler/llds_out.m: compiler/layout.m: compiler/modules.m: Add support for a fourth per-module C function, for writing out proc_static structures (and the call_site_static structures they contains). Since proc_static structures can be referred to from LLDS code (and not just from other static structures and compiler-generated C code), reorganize the declarations of static structures slightly. Change the schema for the name of the first per-module C function slightly, to make it the addition of the fourth function easier. The scheme now is: mercury__<modulename>__init mercury__<modulename>__init_type_tables mercury__<modulename>__init_debugger mercury__<modulename>__write_out_proc_statics Improve formatting of the generated C code. library/*.m: runtime/mercury.c: runtime/mercury_context.c: runtime/mercury_engine.c: runtime/mercury_ho_call.c: runtime/mercury_tabling.c: runtime/mercury_trace_base.c: runtime/mercury_wrapper.c: trace/mercrury_trace.[ch]: trace/mercrury_trace_declarative.c: trace/mercrury_trace_external.c: trace/mercrury_trace_internal.c: Conform to the new scheme for initialization functions for hand-written modules. compiler/mercury_compile.m: library/benchmarking.m: runtime/mercury_conf_param.h: runtime/mercury.h: runtime/mercury_engine.c: runtime/mercury_goto.c: runtime/mercury_grade.h: runtime/mercury_ho_call.c: runtime/mercury_label.[ch]: runtime/mercury_prof.[ch]: Add an MR_MPROF_ prefix in front of the C macros used to control the old profiler. compiler/handle_options.m: runtime/mercury_grade.h: scripts/canonical_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: Make deep profiling completely separate from the old profiling system, by making the deep profiling grade independent of MR_MPROF_PROFILE_TIME and the compiler option --profile-time. library/array.m: library/builtin.m: library/std_util.m: runtime/mercury_hand_unify_body.h: runtime/mercury_hand_compare_body.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of hand-written unification and comparison procedures. Make the reporting of array bounds violations switchable between making them fatal errors, as we currently, and reporting them by throwing an exception. Throwing an exception makes debugging code using arrays easier, but since exceptions aren't (yet) propagated across engine boundaries, we keep the old behaviour as the default; the new behaviour is for implementors. runtime/mercury_deep_profiling_hand.h: New file that defines macros for use in Mercury predicates whose definition is in hand-written C code. library/exception.m: runtime/mercury_exception_catch_body.h: runtime/mercury_stacks.h: In deep profiling grades, wrap the deep profiling call, exit, fail and redo codes around the bodies of the various modes of builtin_catch. Provide a function that C code can use to throw exceptions. library/benchmarking.m: library/exception.m: library/gc.m: library/std_util.m: runtime/mercury_context.[ch]: runtime/mercury_engine.[ch]: runtime/mercury_debug.c: runtime/mercury_deep_copy.c: runtime/mercury_overflow.h: runtime/mercury_regs.h: runtime/mercury_stacks.h: runtime/mercury_thread.c: runtime/mercury_wrapper.c: Add prefixes to the names of the fields in the engine and context structures, to make code using them easier to understand and modify. runtime/mercury_deep_profiling.[ch]: New module containing support functions for deep profiling and functions for writing out a deep profiling data file at the end of execution. runtime/mercury_debug.[ch]: Add support for debugging deep profiling. Add support for watching the value at a given address. Make the buffered/unbuffered nature of debugging output controllable via the -du option. Print register contents only if -dr is specified. runtime/mercury_goto.h: runtime/mercury_std.h: Use the macros in mercury_std.h instead of defining local variants. runtime/mercury_goto.h: runtime/mercury_stack_layout.h: runtime/mercury_stack_trace.c: runtime/mercury_tabling.c: trace/mercury_trace.c: trace/mercury_trace_declarative.c: trace/mercury_trace_external.c: trace/mercury_trace_vars.c: Standardize some of the macro names with those used in the debugger paper. runtime/mercury_heap.h: Add support for memory profiling with the deep profiler. runtime/mercury_prof.[ch]: runtime/mercury_prof_time.[ch]: Move the functionality that both the old profiler and the deep profiler need into the new module mercury_prof_time. Leave mercury_prof containing stuff that is only relevant to the old profiler. runtime/mercury_prof.[ch]: runtime/mercury_strerror.[ch]: Move the definition of strerror from mercury_prof to its own file. runtime/mercury_wrapper.[ch]: Add support for deep profiling. Add suppory for controlling whether debugging output is buffered or not. Add support for watching the value at a given address. runtime/Mmakefile: Mention all the added files. scripts/mgnuc.in: Add an option for turning on deep profiling. Add options for controlling the details of deep profiling. These are not documented because they are intended only for benchmarking the deep profiler itself, for the paper; they are not for general use. tools/bootcheck: Compile the deep_profiler directory as well as the other directories containing Mercury code. Turn off the creation of deep profiling data files during bootcheck, since all but one of these in each directory will be overwritten anyway. Add support for turning on --keep-objs by default in a workspace. tools/speedtest: Preserve any deep profiling data files created by the tests. trace/mercury_trace.c: Trap attempts to perform retries in deep profiling grades, since they would lead to core dumps otherwise. util/Mmakefile: Avoid compile-time warnings when compiling getopt. tests/*/Mmakefile: tests/*/*/Mmakefile: In deep profiling grades, switch off the tests that test features that don't work with deep profiling, either by design or because the combination hasn't been implemented yet. |
||
|
|
19ceeaf30f |
Merge the changes from the HAL branch onto the main branch.
Estimated hours taken: 40
(to do this merge... 100s of hours on the HAL branch
itself by myself and Warwick Harvey though).
Merge the changes from the HAL branch onto the main branch. With the recent
changes made to the HAL implementation, this means adding just one grade,
`.rt' or --reserve-tag, which reserves one tag (zero) in each type for
use by HAL's Herbrand constraint solver. This disables no-tag types and
enumerations.
This grade will now bootstrap, and passes all tests, except for a few failing
cases in the debugger and tabling directories.
compiler/options.m:
compiler/handle_options.m:
Add the `.rt' or --reserve-tag grade option.
runtime/mercury_conf_param.h:
Document the macro MR_RESERVE_TAG
doc/user_guide.texi:
Document the `.rt' grade.
compiler/make_hlds.m:
Don't record any types as no-tag types if we are in a .rt grade.
compiler/make_tags.m:
compiler/type_ctor_info.m:
Allocate tags starting from `1' in .rt grades.
compiler/rtti_out.m:
In .rt grades, output a dummy ptag definition for tag `0'.
compiler/type_util.m:
Add predicates `type_util__constructors_are_dummy_argument_type' and
`type_constructors_are_type_info' for use when allocating tags to
ensure that type infos and dummy types (io__state/0 and store__store/1)
are still treated as no-tag types in .rt grades.
library/sparse_bitset.m:
When allocating a sparse bitset element, use tag `1' if we are in a
.rt grade.
runtime/mercury_tags.h:
Define a macro `MR_UNIV_TAG' which is `1' is we in a .rt grade and
`0' otherwise. (Now that univ is a user defined type, it is a also
assigned a `var' tag).
Also make the definitions of MR_RAW_TAG_NIL and MR_RAW_TAG_CONS take the
.rt grade into account.
runtime/mercury_type_info.h:
Define `MR_unravel_univ' and
`MR_initialise_univ' for taking apart and putting together univs.
Add a new secondary tag alternative: MR_SECTAG_VARIABLE, used to
represent Herbrand variables.
library/std_util.m:
Use MR_UNIV_TAG, MR_unravel_univ and MR_initialise_univ when
manipulating univs.
Handle the new MR_SECTAG_VARIABLE secondary tag by aborting.
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
Handle the new MR_SECTAG_VARIABLE secondary tag by aborting.
library/std_util.m:
Add a constant for MR_SECTAG_VARIABLE in the MC++ back end.
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
Process the new grade.
scripts/mmake.in:
Add an option `--include-makefile', which includes a Makefile given
as a command line argument into the Makefile generated by mmake.
This is used to implement `halmake', a make program for HAL which
just passes a bunch of extra rules and variable definitions onto
mmake.
tests/debugger/existential_type_classes.m:
tests/hard_coded/existential_types_test.m:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
Use MR_UNIV_TAG.
TODO:
- The declarative debugger falls over in .rt grades. This is possibly
because compiler/static_term.m assumes that the generated code uses
the same data representation as the compiler itself. This should be
fixed, although it is not critical; the declarative debugger won't
work with trailing as is, and the .rt grade is only ever used in
conjunction with trailing (.tr) at this stage.
|
||
|
|
3360d1cb59 |
Fix some more bugs in the handling of `DEFAULT_GRADE' and the
Estimated hours taken: 0.5 scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: Fix some more bugs in the handling of `DEFAULT_GRADE' and the `-s<grade>' option. Obviously this code had never been exercised. |
||
|
|
e09f36c7dd |
Fix another cut-and-paste error: change the second "case 0)" to
Estimated hours taken: 0.25 scripts/parse_grade_options.sh-subr: Fix another cut-and-paste error: change the second "case 0)" to "case *)". |
||
|
|
9602919bbe |
Added new compiler options to support the Java backend and
Estimated hours taken: 4
Added new compiler options to support the Java backend and
updated documentation to reflect this.
compiler/globals.m:
Removed comment about Java backend not being implemented.
Replaced it by one say that it is work in progress.
compiler/mercury_compile.m:
If Target = java then call the Java backend.
compiler/options.m:
Added new options for compiling Java files:
`--java'
`--java-only'
`--java-compiler' ('--javac')
`--java-flags'
`--java-classpath'
`--java-object-file-extension'
compiler/handle_options.m:
If compiling to Java then don't link.
Added "java" grade.
compiler/mlds_to_java.m
New file.
XXX Currently just prints an error message about
the Java backend not being implemented.
doc/user_guide.texi:
Documented new options for compiling Java files.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/final_grade_options.sh-subr:
Added support for "java" grade.
|
||
|
|
3de6904858 |
Merge my recent changes on the gcc-backend-branch back onto
Estimated hours taken: 0.5 mercury/Mmake.common.in: mercury/configure.in: mercury/compiler/Mmakefile: mercury/compiler/maybe_mlds_to_gcc.pp: mercury/compiler/mercury_compile.m: mercury/compiler/mlds_to_gcc.m: mercury/compiler/modules.m: mercury/runtime/mercury_type_info.h: mercury/runtime/mercury_wrapper.c: mercury/runtime/mercury_wrapper.h: mercury/scripts/Mmake.rules: mercury/scripts/Mmake.vars.in: mercury/scripts/final_grade_options.sh-subr: mercury/scripts/init_grade_options.sh-subr: mercury/scripts/mmake.in: mercury/scripts/parse_grade_options.sh-subr: gcc/Make-lang.in: gcc/Makefile: gcc/Mmakefile: gcc/lang-specs.h: gcc/mercury-gcc.c: Merge my recent changes on the gcc-backend-branch back onto the main branch. |
||
|
|
6d78224020 |
Add new options and grades for the IL back-end.
Estimated hours taken: 24 (by fjh)
Add new options and grades for the IL back-end.
Implement an option to handle output parameters for nondeterministic
procedures by passing the outputs (by value) to the continuation,
rather than using pass-by-reference. This is needed for IL
because IL does not allow managed pointers (which we used to
implement pass-by-refernece) to be stored as fields of environment
structs.
Also add an option to return outputs by value in det/semidet code.
This is not yet tested, since none of our target languages support
returning multiple values.
(Note that the IL backend is not activated by these changes -- it
hasn't been checked in).
compiler/globals.m:
Use field names for the globals structure.
Add new `target' field to the globals.
compiler/options.m:
compiler/handle_options.m:
Add new options `--target', `--target-only', `--il', and `--il-only'.
`--target' specifies the output langauge (e.g. C or IL).
`--target-only' says to only compile to the output language
(e.g. similar to -C or --compile-to-c option).
`--il' sets target to IL.
`--il-only' sets target to IL and specifies --target-only.
Add new grades `il' and `ilc'.
These grades are used for compiling to il grades. `il' is the
normal `il' grade, while `ilc' uses low-level (C-like) data
representations.
Change `--compile-to-c' from a boolean option to an abbreviation
for `--target c --target-only', and move it from the "Output options"
section to the "Compilation model options" section.
Comment out the documentation for `--generate-prolog' and
`--prolog-dialect', since those options are not yet implemented.
Document the `--infer-all' option.
compiler/mercury_compile.m:
Check the `target_code_only' option rather than `compile_to_c',
since the latter is just an abbreviation now, not a real option.
compiler/ml_call_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_unify_gen.m:
Use the `--det-copy-out' option to decide whether to pass
output arguments for model_det/model_semi procedures by
reference, or whether to just return multiple values.
Use the `--nondet-copy-out' option to decide whether to pass
output arguments for model_non procedures by reference, or
whether to just pass them to the continuation.
compiler/mlds.m:
Change the mlds__cont_type so that it includes a list of
the continuation's argument types (if any).
compiler/mlds_to_c.m:
Update to reflect the change to mlds.m.
doc/user_guide.texi:
Update the documentation to reflect the above changes.
scripts/parse_grade_options.sh-subr:
Add new options `--target' and `--il'.
scripts/init_grade_options.sh-subr
Add new grades `il' and `ilc'.
scripts/final_grade_options.sh-subr
Make `--target il' imply `--high-level-code'.
|
||
|
|
6c6cffc50f |
Allow -H' as a synomym for --high-level-code',
Estimated hours taken: 0.1 scripts/parse_grade_options.sh-subr: Allow `-H' as a synomym for `--high-level-code', to match the behaviour of mmc. |
||
|
|
b376c06e11 |
Report an error if any of the grade components are unknown.
Estimated hours taken: 0.1 scripts/parse_grade_options.sh-subr: Report an error if any of the grade components are unknown. |
||
|
|
3d45791e77 |
Fix some bugs in the MLDS back-end support.
Estimated hours taken: 0.75 Fix some bugs in the MLDS back-end support. scripts/parse_grade_options.sh-subr: Fix a bug: s/high_level/highlevel/g scripts/final_grade_options.sh-subr: Ensure that --high-level-code disables the use of the low-level gcc extensions, as is done in compiler/handle_options.m. |
||
|
|
9599c55ae8 |
Implement new grades and options for the MLDS back-end.
Estimated hours taken: 3 Implement new grades and options for the MLDS back-end. compiler/options.m: Rename --highlevel-c as --highlevel-code. Add new option --highlevel-data. compiler/mercury_compile.m: scripts/mgnuc.in: Convert the grade options --highlevel-code, --highlevel-data, and --gcc-nested-functions into C flags -DMR_HIGHLEVEL_CODE, -DMR_HIGHLEVEL_DATA, and -DMR_USE_GCC_NESTED_FUNCTIONS respectively. compiler/handle_options.m: scripts/parse_grade_options.sh-subr: scripts/init_grade_options.sh-subr: scripts/final_grade_options.sh-subr: scripts/ml.in: Add new grades `hl', `hlc', `hl_nest', and `hlc_nest'. Add code to handle the new options and grades. scripts/ml.in: If --high-level-code is set, then don't invoke the demangler, since it doesn't (yet) understand the new name mangling scheme. |
||
|
|
22840901fd |
Fix potential problems with the way we were handling grade components: the
Estimated hours taken: 5 Fix potential problems with the way we were handling grade components: the places that know about grade components were not being kept totally in sync. This change fixes previous damage and aims to prevent future damage. The file runtime/mercury_grade.h contains a list of all the files in the compiler that know about grade components. All these files now process the grade components in the same order, so that they can be checked for consistency more easily. runtime/mercury_grade.h: Add the list. runtime/mercury_conf_param.h: Remove a comment about an obsolete grade component. scripts/init_grade_options.sh-subr: Remove initializations of variables that do not correspond to grade components, add missing initializations of shell variables that do correspond to grade components, and concentrate the grade options component of usage messages here, to prevent double maintenance. Update list of user scripts. scripts/final_grade_options.sh-subr: Add missing initializations in processing the --grade superoption. Standardize the order of processing options, and the indentation. Update list of user scripts. scripts/c2init.in: Take the usage message for grade component options from init_grade_options.sh-subr. scripts/mgnuc.in: Take the usage message for grade component options from init_grade_options.sh-subr. Standardize the order of processing grade options, and separate the processing of grade options and non-grade options. scripts/ml.in: Take the usage message for grade component options from init_grade_options.sh-subr. Standardize the order of processing grade options. Process some missing ones. compiler/handle_options.m: Standardize the order of processing grade options. Remove code to handle an obsolete grade component. |
||
|
|
541ab2829f |
Add a new option for deep profiling to the compiler and the scripts.
Estimated hours taken: 0.5 Add a new option for deep profiling to the compiler and the scripts. compiler/options.m: Add the new profiling options `profile-deep' and `deep-profiling'. compiler/handle_options.m: Add code to handle the above options. scripts/init_grade_options.sh-subr: Initialize the profile_deep option to false. scripts/parse_grade_options.sh-subr: Add code handle the deep-profiling options. |
||
|
|
c6812299c2 |
Remove support for --args simple. We don't use it, we won't use it even for
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. |
||
|
|
dc03496d06 |
Rewrite significant parts of minimal model tabling so that it works
Estimated hours taken: 130
Rewrite significant parts of minimal model tabling so that it works
in a much wider variety of situations, including coups. Also, clean up
the tabling implementation to make it more maintainable, and introduce
a new grade component, .mm, that enables minimal model tabling.
(Minimal model tabling requires distributed fat, and we don't want to
incur such costs unless necessary.)
compiler/options.m:
Add a new option --use-minimal-model, which for now is documented
as "not for general use". This option is a grade option, and is
required if minimal model tabling is to work.
compiler/handle_options.m:
When --use-minimal-model is given, do not allow nondet frame hijacks,
since minimal model tabling cannot cope with hijacks.
Make --use-minimal-model a grade component.
compiler/code_info.m:
When --use-minimal-model is given, insert calls to MR_commit_{mark,cut}
around goals being committed across. This is now necessary, so that we
can detect and handle sitations where a goal being committed across
starts but does not complete a tabled goal.
compiler/table_gen.m:
Rename many of the tabling helper predicates, using a naming scheme
that separates predicates used for model_non procedures from those
used to implement simpler forms of tabling, while bringing out
the parallels between these two sets of predicates.
When calls to two tabling helper predicates always occur
one after the other, merge the two into one.
Generate and use more meaningful variable names; having all of the
several variables inserted by this transformation named TableVar
was quite confusing.
library/private_builtin.m:
Reorganize this file, to separate out the different sections.
The contents of the non-tabling sections were not modified, only
moved around.
Rename the predicates referred to by table_gen.m.
Move most of the type declarations and complex code out of here,
into runtime/mercury_tabling.c. This makes it easier to debug them,
since (a) creating a new executable is quicker, since you don't have
to wait for lots of mercury compiler invocations, and (b) gdb doesn't
get confused by #line directives. It also makes it easier to write
them, since you don't have to !&(*U&( remember to double all your
double quotes and to backslash all your backslashes.
runtime/mercury_grade.h:
Include a grade component reflecting whether MR_USE_MINIMAL_MODEL
is defined.
runtime/mercury_conf_param.h:
Document MR_USE_MINIMAL_MODEL.
runtime/mercury_stacks.[ch]:
The changes to tabling require the addition of two new stacks,
the generator stack and the cut stack. This module defines the
structures of the frames of these stacks and provides the
operations on these stacks.
The header file also contains some additional macros that return
the addresses of fixed nondet stack slots, not their contents,
for use by tabling code.
runtime/mercury_context.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
Declare and set up the two new stacks, both in saved contexts and in
the active context, if MR_USE_MINIMAL_MODEL is defined.
runtime/mercury_regorder.h:
Add four new global virtual machine registers to hold pointers
to the memory areas of the two new stacks and the current offsets
within them. These are defined whether MR_USE_MINIMAL_MODEL is defined
or not, since the cost is minimal and the potential bugs we avoid
would be hard to track down.
runtime/mercury_engine.h:
runtime/mercury_wrapper.c:
Add support for a new debugging flag, -dS, which prints the contents
of the nondet stack at several points during tabling.
runtime/mercury_tabling.[ch]:
The implementation of the new tabling system. Much of the new code here
is stuff moved from library/private_builtin.m, but in a significantly
rewritten form. There is also substantial new code, e.g. to handle
the extension of saved stack segments, and to manage dependencies
between subgoals in general.
Improve the documentation considerably.
Replace lists stored as Mercury data structures with lists stored
as linked structures in the usual C fashion. This allows us to use
debuggers such as ddd on these data structures, whose complexity
requires this.
Ensure that global names start with MR_.
runtime/mercury_init.h:
Explicitly include mercury_regs.h at the start. Without this,
we get an error, because now mercury_wrappers.h, which mercury_init.h
includes, also includes mercury_regs.h, but not before functions
have been declared.
runtime/Mmakefile:
Refer to the new file mercury_stacks.c (mercury_stacks.h already
existed, but the module consisted entirely of macros.)
Fix a sorting error.
scripts/{init,parse,final}_grade_options.sh-subr:
scripts/mgnuc.in:
Handle the new grade component.
tests/tabling/*
Add several new test cases that we now pass, most of which we couldn't
pass before. Also add some new test cases that we don't pass yet,
due to interactions between tabling and negated contexts.
trace/mercury_trace_internal.c:
If MR_USE_MINIMAL_MODEL is defined, add a new command to print
the generator stack. (The new command is deliberately not documented
in doc/mdb_doc yet, since (a) it is intended for developers only,
and (b) there is no way to test MR_USE_MINIMAL_MODEL in mdb_doc.)
|
||
|
|
5927080429 |
When parsing a --grade option, set all the grade options to the
Estimated time taken: 1 sripts/parse_grade_options.sh-subr: When parsing a --grade option, set all the grade options to the appropriate `off' value. As a result the last --grade option overides all earlier ones. compiler/handle_options.m: Add a table for the `off' values for grade options, and reset the grade options to those values when processing a --grade option. |
||
|
|
1665b44c55 |
A bug fix from Warwick Harvey.
Estimated hours taken: 0.25 A bug fix from Warwick Harvey. scripts/parse_grade_options.sh-subr: If a grade is specified, the GC method should default to `none' rather than `conservative'. |
||
|
|
b1aa225ce3 |
This change makes the parsing of GRADE/--grade strings more flexible.
Estimated hours taken: 4 This change makes the parsing of GRADE/--grade strings more flexible. The GRADE string can now have its components given in any order. The only places that depend on the order are those that use the grade as part of a pathname: ml and install_grades. There is also a new option to the compiler `--output-grade-string' which prints the grade string for the set of options given to mmc/mmake. NEWS: mention the changes. compiler/handle_options.m: Reimplement convert_grade_option to accept a grade string with its components in any order. The conversion is now table-driven, which should make it easier to add new dimensions to the grade and new values to existing ones. Reimplement compute_grade to use the same table as convert_grade_option. compiler/mercury_compile.m: If --output-grade-string option was given, just compute the grade string and print it. compiler/options.m: Add the --output-grade-string option. library/list.m: Add an extra mode to list__foldl2 (gee, it would be nice to be able to make higher order predicates polymorphic in their determinism). scripts/ml.in: Include .par in the grade string. (bugfix) scripts/parse_grade_options.sh-subr: split the grade string into . separated pieces and process them in a loop, setting the appropriate options. doc/user_guide.texi: Add documentation on --output-grade-string. Change the description of how grades are handled to match the implementation. Add a some missing bits. |
||
|
|
a70b59e83c |
Add a test to find the number of words needed to represent a
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
|
||
|
|
fcdf5e117b |
Fix a cut-and-paste error in the handling of `debug' grade.
Estimated hours taken: 0.1 scripts/parse_grade_options.sh-subr: Fix a cut-and-paste error in the handling of `debug' grade. (Thanks to Warwick Harvey for reporting this bug.) |
||
|
|
6921e0e015 |
Add a `--debug' option for Mercury-level debugging
Estimated hours taken: 6 Add a `--debug' option for Mercury-level debugging using the trace-based debugger. scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: scripts/mgnuc.in: scripts/ml.in: compiler/options.m: compiler/handle_options.m: compiler/mercury_compile.m: Split the old `--debug' option into `--low-level-debug' (formerly the absence of -DSPEED, now handle by -DLOWLEVEL_DEBUG) and `--c-debug' (passes -g to C compiler). Delete the old `debug' grade. Add support for new options `--require-tracing' (makes --trace minimum equivalent to --trace interfaces, and passes -DMR_REQUIRE_TRACING to C compiler) `--stack-trace' (passes -DMR_STACK_TRACE to C compiler; actually this one was already supported) and `--debug' (implies previous two), with corresponding grade modifiers `.trace', `.strce', and `.debug'. Actually I think there's little point in specifying just one of `--require-tracing' and `--stack-trace' so for the moment I'm just providing `--debug': the code for the more fine-grained options and grade modifiers has been added but commented out. runtime/mercury_conf_param.h: Document the new configuration parameter MR_REQUIRE_TRACING and the existing but undocumented parameter MR_STACK_TRACE. runtime/mercury_grade.h: Include MR_REQUIRE_TRACING in the mangled grade identifier. compiler/globals.m: compiler/handle_options.m: compiler/options.m: Allow new tracing type `--trace default', and make it the default. This gets replaced with `full' if require_tracing is yes or `minimal' if require_tracing is no. Also `--trace minimum' gets replaced with `interface' if require_tracing is yes. doc/user_guide.texi: Document the new `--debug', `--low-level-debug', and `--c-debug' options. scripts/mgnuc.in: compiler/mercury_compile.m: doc/user_guide.texi: Change things so that `--c-debug' does not imply `--no-c-optimize'. configure.in: Add `-fomit-frame-pointer' to CFLAGS_FOR_GOTOS on alpha-*. Empirically, this seems to be needed, otherwise lots of the test cases fail when compiled with `--no-c-optimize'. (It might also be needed for other architectures, I don't know.) |
||
|
|
e6ac077bae |
Add support for memory profiling.
Estimated hours taken: 40 (+ unknown time by Zoltan)
Add support for memory profiling.
(A significant part of this change is actuallly Zoltan's work. Zoltan
did the changes to the compiler and a first go at the changes to the
runtime and library. I rewrote much of Zoltan's changes to the runtime
and library, added support for the new options/grades, added code to
interface with mprof, did the changes to the profiler, and wrote the
documentation.)
[TODO: add test cases.]
NEWS:
Mention support for memory profiling.
runtime/mercury_heap_profile.h:
runtime/mercury_heap_profile.c:
New files. These contain code to record heap profiling information.
runtime/mercury_heap.h:
Add new macros incr_hp_msg(), tag_incr_hp_msg(),
incr_hp_atomic_msg(), and tag_incr_hp_atomic_msg().
These are like the non-`msg' versions, except that if
PROFILE_MEMORY is defined, they also call MR_record_allocation()
from mercury_heap_profile.h to record heap profiling information.
Also, fix up the indentation in lots of places.
runtime/mercury_prof.h:
runtime/mercury_prof.c:
Added code to dump out memory profiling information to files
`Prof.MemoryWords' and `Prof.MemoryCells' (for use by mprof).
Change the format of the `Prof.Counts' file so that the
first line says what it is counting, the units, and a scale
factor. Prof.MemoryWords and Prof.MemoryCells can thus have
exactly the same format as Prof.Counts.
Also cleaned up the interface to mercury_prof.c a bit, and did
various other minor cleanups -- indentation changes, changes to
use MR_ prefixes, additional comments, etc.
runtime/mercury_prof_mem.h:
runtime/mercury_prof_mem.c:
Rename prof_malloc() as MR_prof_malloc().
Rename prof_make() as MR_PROF_NEW() and add MR_PROF_NEW_ARRAY().
runtime/mercury_wrapper.h:
Minor modifications to reflect the new interface to mercury_prof.c.
runtime/mercury_wrapper.c:
runtime/mercury_label.c:
Rename the old `-p' (primary cache size) option as `-C'.
Add a new `-p' option to disable profiling.
runtime/Mmakefile:
Add mercury_heap_profile.[ch].
Put the list of files in alphabetical order.
Delete some obsolete stuff for supporting `.mod' files.
Mention that libmer_dll.h and libmer_globals.h are
produced by Makefile.DLLs.
runtime/mercury_imp.h:
Mention that libmer_dll.h is produced by Makefile.DLLs.
runtime/mercury_dummy.c:
Change a comment to refer to libmer_dll.h rather than
libmer_globals.h.
compiler/llds.m:
Add a new field to `create' and `incr_hp' instructions
holding the name of the type, for heap profiling.
compiler/unify_gen.m:
Initialize the new field of `create' instructions with
the appropriate type name.
compiler/llds_out.m:
Output incr_hp_msg() / tag_incr_hp_msg() instead of
incr_hp() / tag_incr_hp().
compiler/*.m:
Minor changes to most files in the compiler back-end to
accomodate the new field in `incr_hp' and `create' instructions.
library/io.m:
Add `io__report_full_memory_stats'.
library/benchmarking.m:
Add `report_full_memory_stats'. This uses the information saved
by runtime/mercury_heap_profile.{c,h} to print out a report
of memory usage by procedures and by types.
Also modify `report_stats' to print out some of that information.
compiler/mercury_compile.m:
If `--statistics' is enabled, call io__report_full_memory_stats
at the end of main/2. This will print out full memory statistics,
if the compiler was compiled with memory profiling enabled.
compiler/options.m:
compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/ml.in:
scripts/mgnuc.in:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Add new option `--memory-profiling' and new grade `.memprof'.
Add `--time-profiling' as a new synonym for `--profiling'.
Also add `--profile-memory' for more fine-grained control:
`--memory-profiling' implies both `--profile-memory' and
`--profile-calls'.
scripts/mprof_merge_runs:
Update to handle the new format of Prof.Counts and to
also merge Prof.MemoryWords and Prof.MemoryCells.
profiler/options.m:
profiler/mercury_profile.m:
Add new options `--profile memory-words' (`-m'),
`--profile memory-cells' (`-M') and `--profile time' (`-t').
Thes options make the profiler select a different count file,
Prof.MemoryWords or Prof.MemoryCells instead of Prof.Counts.
specific to time profiling.
profiler/read.m:
profiler/process_file.m:
profiler/prof_info.m:
profiler/generate_output.m:
Update to handle the new format of the counts file.
When reading the counts file, look at the first line of
the file to determine what is being profiled.
profiler/globals.m:
Add a new global variable `what_to_profile' that records
what is being profiled.
profiler/output.m:
Change the headings to reflect what is being profiled.
doc/user_guide.texi:
Document memory profiling.
Document new options.
doc/user_guide.texi:
compiler/options.m:
Comment out the documentation for `.proftime'/`--profile-time',
since doing time and call profiling seperately doesn't work,
because the code addresses change when you recompile with a
different grade. Ditto for `.profmem'/`--profile-memory'.
Also comment out the documentation for
`.profcalls'/`--profile-calls', since it is redundant --
`.memprof' produces the same information and more.
configure.in:
Build a `.memprof' grade. (Hmm, should we do this only
if `--enable-all-grades' is specified?)
Don't ever build a `.profcalls' grade.
|
||
|
|
eb7bcf0fd9 |
Change mgnuc and ml to support the same
compilation model options as mmc. Allow the user to mix `--grade foo' options with other options that affect the grade such as `--profiling'. Compute the final grade to link with from the options. Also add a few new options and grade modifiers. compiler/options.m: compiler/mercury_compile.m: Add `--profile-time' and `--profile-calls' options. Change `--profiling' to now just imply both of those. Add `--pic-reg' option (just implies `-DPIC_REG' in cflags). compiler/handle_options.m: Add support for grade modifiers `.proftime' and `.profcalls'. Make `.debug' a grade modifier, rather than having a base grade `debug'. scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: New files containing sh subroutines for parsing grade-related options. configure.in: bindist/bindist.configure.in: Use AC_SUBST_FILE to allow #inclusion of the above-mentioned `.sh-subr' files. scripts/ml.in: scripts/mgnuc.in: Use the above-mentioned sh subroutines. scripts/ml.in: compiler/mercury_compile.m: compiler/handle_options.m: Compute the final grade to link with from the various grade-related options. scripts/mgnuc.in: Support the `--inline-alloc' option. doc/user_guide.texi: README.Linux: Document the above changes. |