mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 13:55:07 +00:00
ada4e26dd11e052f8f244cb0af94208f4d329452
170 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f0964815a3 |
Support line numbers in the debugger. You now get contexts (filename:lineno
Estimated hours taken: 40
Support line numbers in the debugger. You now get contexts (filename:lineno
pairs) printed in several circumstances, and you can put breakpoints on
contexts, when they correspond to trace events or to calls. The latter are
implemented as breakpoints on the label layouts of the return sites.
This required extending the debugging RTTI, so that associated with each
module there is now a new data structure listing the source file names that
contribute labels with layout structures to the code of the module. For each
such source file, this table gives a list of all such labels arising from
that file. The table entry for a label gives the line number within the file,
and the pointer to the label layout structure.
compiler/llds.m:
Add a context field to the call instruction.
compiler/continuation_info.m:
Instead of the old division of continuation info about labels into
trace ports and everything else, divide them into trace ports, resume
points and return sites. Record contexts with trace ports, and record
contexts and called procedure information with return sites.
compiler/code_info.m:
Conform to the changes in continuation_info.m.
compiler/options.m:
Add a new option that allows us to disable the generation of line
number information for size benchmarking (it has no other use).
compiler/stack_layout.m:
Generate the new components of the RTTI, unless the option says not to.
compiler/code_gen.m:
compiler/pragma_c_gen.m:
compiler/trace.m:
Include contexts in the information we gather for the layouts
associated with the events we generate.
compiler/call_gen.m:
Include contexts in the call LLDS instructions, for association
with the return site's label layout structure (which is done after
code generation is finished).
compiler/handle_options.m:
Delete the code that tests or sets the deleted options.
compiler/mercury_compile.m:
Delete the code that tests the deleted options.
compiler/basic_block.m:
compiler/dupelim.m:
compiler/frameopt.m:
compiler/livemap.m:
compiler/llds_common.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/value_number.m:
compiler/vn_*.m:
Trivial changes to conform to the changes to llds.m.
compiler/jumpopt.m:
Do not optimize away jumps to labels with layout structures.
The jumps we are particularly concerned about now are the jumps
that return from procedure calls. Previously, it was okay to redirect
returns from several calls so that all go to the same label, since
the live variable information associated with the labels could be
merged. However, we now also associate line numbers with calls, and
these cannot be usefully merged.
compiler/optimize.m:
Pass the information required by jumpopt to it.
doc/user_guide.texi:
Document that you can now break at line numbers.
Document the new "context" command, and the -d or --detailed option
of the stack command and the commands that set ancestor levels.
runtime/mercury_stack_layout.h:
Extend the module layout structure definition with the new tables.
Remove the conditional facility for including label numbers in label
layout structures. It hasn't been used in a long time, and neither
Tyson or me expect to use it to debug either gc or the debugger itself,
so it has no uses left; the line numbers have superseded it.
runtime/mercury_stack_trace.[ch]:
Extend the code to print stack traces to also optionally print
contexts.
Add some utility predicates currently used by the debugger that could
also be use for debugging gc or for more detailed stack traces.
trace/mercury_trace_internal.c:
Implement the "break <context>" command, the "context" command, and
the -d or --detailed option of the stack command and the commands
that set ancestor levels.
Conditionally define a conditionally used variable.
trace/mercury_trace_external.c:
Minor changes to keep up with the changes to stack traces.
Delete an unused variable.
trace/mercury_trace_spy.[ch]:
Check for breakpoints on contexts.
trace/mercury_trace_tables.[ch]:
Add functions to search the RTTI data structures for labels
corresponding to a given context.
trace/mercury_trace_vars.[ch]:
Remember the context of the current environment.
tests/debugger/queen.{inp,exp}:
Test the new capabilities of the debugger.
tests/debugger/*.{inp,exp}:
Update the expected output of the debugger to account for contexts.
In some cases, modify the input script to put contexts where they don't
overflow lines.
|
||
|
|
89065f0a1e |
Fix a bug in frameopt reported by Serge Varennes on April 15, 1999.
Estimated hours taken: 8
Fix a bug in frameopt reported by Serge Varennes on April 15, 1999.
The bug was that frameopt recognized that a procedure did not need a
stack frame, and deleted the frame setup code, but did not redirect the
failure branches inside inlined model_semi pragma_c instructions,
so that they still led to code that deallocated the (now nonexistent)
stack frame. This meant that calls to this procedure violated the
invariant which says that calls leave MR_sp unchanged.
compiler/llds.m:
Add a new pragma C component (pragma_c_fail_to) that represents the
branch to a label on failure of a model_semi piece of C code, instead
of handling this by generating a string containing the C code that
branches to this label. Record the failure label as a new field
in pragma_c instructions.
The point of this change is that it makes it possible to substitute
the failure label in frameopt.
Add also a pragma_c_noop component to make the generated code somewhat
better optimizable.
compiler/pragma_c_gen.m:
Generate the new LLDS components.
compiler/llds_out.m:
Output the new LLDS components.
Move a predicate declaration away from the middle of another predicate.
compiler/frameopt.m:
Perform substitutions on pragma C code labels that occur only
in pragma_c_fail_to components.
If a pragma_c instruction has any other references to labels, we now
assume that the block containing the instruction needs a stack frame,
since those labels can't be substituted with their non-teardown
parallels if this block is moved to a context without a stack frame.
compiler/basic_block.m:
compiler/dupelim.m:
compiler/frameopt.m:
compiler/opt_util.m:
Both basic_block.m and dupelim.m had code that substantially
duplicated code in frameopt.m. This change factors out the differences
among the versions and moves the unified predicates to opt_util.m.
compiler/code_gen.m:
compiler/code_info.m:
compiler/dupelim.m:
compiler/livemap.m:
compiler/llds_common.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/trace.m:
compiler/value_number.m:
compiler/vn_*.m:
Trivial updates to conform to the changes in llds.m.
tests/hard_coded/frameopt_pragma_redirect.{m,exp}:
A new test case that exhibits the problem. (It is not the original
test cases submitted by Serge Varennes, because that code depended
on non-standard functions in ieeefp.h.)
tests/hard_coded/Mmakefile:
Enable the new test case.
|
||
|
|
d551dd1dc9 |
Handle quantification analysis of bi-implication (`<=>') goals correctly.
Estimated hours taken: 10
Handle quantification analysis of bi-implication (`<=>') goals correctly.
Previously we used to expand bi-implications before doing quantification
analysis, which stuffed up the results of quantification analysis for
those goals. We need to do quantification analysis first, and only
then can we expand bi-implications. In addition, elimination of double
negation needs to come after expansion of bi-implication, so I moved
that from make_hlds.m to purity.m.
compiler/hlds_goal.m:
Add a new alternative to the HLDS goal type for bi-implications.
Also add a new predicate negate_goal, for use by purity.m.
compiler/make_hlds.m:
Don't expand bi-implication here, instead just use the new
bi_implication/2 HLDS goal type.
Don't eliminated double negation here.
compiler/quantification.m:
Handle quantification for bi-implications.
Expand bi-implications.
compiler/purity.m:
Eliminate double negation.
compiler/hlds_out.m:
Add code to print out bi-implication goals.
compiler/*.m:
Trivial changes to handle the new bi_implication/2
alternative in the HLDS goal type.
compiler/notes/compiler_design.html:
Document the above changes.
tests/hard_coded/Mmakefile:
tests/hard_coded/quantifier2.m:
tests/hard_coded/quantifier2.exp:
A regression test for the above change.
|
||
|
|
466c844964 |
Make the retry command work in trailing grades (e.g. for HAL).
Estimated hours taken: 18 Make the retry command work in trailing grades (e.g. for HAL). compiler/trace.m: In trailing grades, reserve two stack slots to hold (a) the trail pointer on entry, and (b) a new ticket obtained on entry. Arrange to put the numbers of these stack slots in the proc layout. compiler/stack_layout.m: Put the number of the first of these stack slots in the proc layout. compiler/code_info.m: Arrange the default: there are no such slots if debugging is not enabled. compiler/code_gen.m: Insert code to discard the allocated ticket, in the success epilog of model_det procedures, the success and failure epilogs of model_semi procedures, and the failure epilogs of model_non procedures. (Model_det procedures don't have failure epilogs, and discarding the ticket in the success epilog of a model_non procedure would be premature.) compiler/llds.m: Add two new alternatives to the type describing stack slots: a stack slot may contain a trail pointer or a ticket. Add a new reason for resetting the trail: a retry in the debugger. compiler/llds_out.m: Minor changes to conform to llds.m, and to make diagnostic output less misleading. library/builtin.m: Add the type_ctor_info for the new "types" describing stored trail pointers and tickets. Bring up to date the type_ctor_infos of other "types" used only for describing stack slots. library/std_util.m: Add the missing code to handle the type_ctor_infos of trail pointers, tickets and other "types" used only for describing stack slots. runtime/mercury_type_info.h: Add a new type_ctor representation value for stored trail pointers, tickets, and for other "types" used only for describing stack slots. runtime/mercury_deep_copy_body.h: runtime/mercury_tabling.c: Add the missing code to handle the type_ctor_infos of trail pointers, tickets and other "types" used only for describing stack slots. runtime/mercury_stack_layout.h: Add a field to proc layouts to hold either the number of the first of the two stack slots holding trail info, or -1. runtime/mercury_trail.h: Add the new reason why the trail may be reset. trace/mercury_trace.c: In trailing grades, reset the trail, with the reason being given as retry, when the debugger's retry command is executed. extras/references/scoped_update.m: extras/trailed_update/var.m: clpr/cfloat.m: extras/trailed_update/tests/func_trail_test.m: extras/trailed_update/tests/func_trail_test_2.m: Handle MR_retry as a reason for unwinding the trail. |
||
|
|
2725b1a331 |
Aditi update syntax, type and mode checking.
Estimated hours taken: 220
Aditi update syntax, type and mode checking.
Change the hlds_goal for constructions in preparation for
structure reuse to avoid making multiple conflicting changes.
compiler/hlds_goal.m:
Merge `higher_order_call' and `class_method_call' into a single
`generic_call' goal type. This also has alternatives for the
various Aditi builtins for which type declarations can't
be written.
Remove the argument types field from higher-order/class method calls.
It wasn't used often, and wasn't updated by optimizations
such as inlining. The types can be obtained from the vartypes
field of the proc_info.
Add a `lambda_eval_method' field to lambda_goals.
Add a field to constructions to identify which RL code fragment should
be used for an top-down Aditi closure.
Add fields to constructions to hold structure reuse information.
This is currently ignored -- the changes to implement structure
reuse will be committed to the alias branch.
This is included here to avoid lots of CVS conflicts caused by
changing the definition of `hlds_goal' twice.
Add a field to `some' goals to specify whether the quantification
can be removed. This is used to make it easier to ensure that
indexes are used for updates.
Add a field to lambda_goals to describe whether the modes were
guessed by the compiler and may need fixing up after typechecking
works out the argument types.
Add predicate `hlds_goal__generic_call_id' to work out a call_id
for a generic call for use in error messages.
compiler/purity.m:
compiler/post_typecheck.m:
Fill in the modes of Aditi builtin calls and closure constructions.
This needs to know which are the `aditi__state' arguments, so
it must be done after typechecking.
compiler/prog_data.m:
Added `:- type sym_name_and_arity ---> sym_name/arity'.
Add a type `lambda_eval_method', which describes how a closure
is to be executed. The alternatives are normal Mercury execution,
bottom-up execution by Aditi and top-down execution by Aditi.
compiler/prog_out.m:
Add predicate `prog_out__write_sym_name_and_arity', which
replaces duplicated inline code in a few places.
compiler/hlds_data.m:
Add a `lambda_eval_method' field to `pred_const' cons_ids and
`pred_closure_tag' cons_tags.
compiler/hlds_pred.m:
Remove type `pred_call_id', replace it with type `simple_call_id',
which combines a `pred_or_func' and a `sym_name_and_arity'.
Add a type `call_id' which describes all the different types of call,
including normal calls, higher-order and class-method calls
and Aditi builtins.
Add `aditi_top_down' to the type `marker'.
Remove `aditi_interface' from type `marker'. Interfacing to
Aditi predicates is now handled by `generic_call' hlds_goals.
Add a type `rl_exprn_id' which identifies a predicate to
be executed top-down by Aditi.
Add a `maybe(rl_exprn_id)' field to type `proc_info'.
Add predicate `adjust_func_arity' to convert between the arity
of a function to its arity as a predicate.
Add predicates `get_state_args' and `get_state_args_det' to
extract the DCG state arguments from an argument list.
Add predicate `pred_info_get_call_id' to get a `simple_call_id'
for a predicate for use in error messages.
compiler/hlds_out.m:
Write the new representation for call_ids.
Add a predicate `hlds_out__write_call_arg_id' which
replaces similar code in mode_errors.m and typecheck.m.
compiler/prog_io_goal.m:
Add support for `aditi_bottom_up' and `aditi_top_down' annotations
on pred expressions.
compiler/prog_io_util.m:
compiler/prog_io_pragma.m:
Add predicates
- `prog_io_util:parse_name_and_arity' to parse `SymName/Arity'
(moved from prog_io_pragma.m).
- `prog_io_util:parse_pred_or_func_name_and_arity to parse
`pred SymName/Arity' or `func SymName/Arity'.
- `prog_io_util:parse_pred_or_func_and_args' to parse terms resembling
a clause head (moved from prog_io_pragma.m).
compiler/type_util.m:
Add support for `aditi_bottom_up' and `aditi_top_down' annotations
on higher-order types.
Add predicates `construct_higher_order_type',
`construct_higher_order_pred_type' and
`construct_higher_order_func_type' to avoid some code duplication.
compiler/mode_util.m:
Add predicate `unused_mode/1', which returns `builtin:unused'.
Add functions `aditi_di_mode/0', `aditi_ui_mode/0' and
`aditi_uo_mode/0' which return `in', `in', and `out', but will
be changed to return `di', `ui' and `uo' when alias tracking
is implemented.
compiler/goal_util.m:
Add predicate `goal_util__generic_call_vars' which returns
any arguments to a generic_call which are not in the argument list,
for example the closure passed to a higher-order call or
the typeclass_info for a class method call.
compiler/llds.m:
compiler/exprn_aux.m:
compiler/dupelim.m:
compiler/llds_out.m:
compiler/opt_debug.m:
Add builtin labels for the Aditi update operations.
compiler/hlds_module.m:
Add predicate predicate_table_search_pf_sym, used for finding
possible matches for a call with the wrong number of arguments.
compiler/intermod.m:
Don't write predicates which build `aditi_top_down' goals,
because there is currently no way to tell importing modules
which RL code fragment to use.
compiler/simplify.m:
Obey the `cannot_remove' field of explicit quantification goals.
compiler/make_hlds.m:
Parse Aditi updates.
Don't typecheck clauses for which syntax errors in Aditi updates
are found - this avoids spurious "undefined predicate `aditi_insert/3'"
errors.
Factor out some common code to handle terms of the form `Head :- Body'.
Factor out common code in the handling of pred and func expressions.
compiler/typecheck.m:
Typecheck Aditi builtins.
Allow the argument types of matching predicates to be adjusted
when typechecking the higher-order arguments of Aditi builtins.
Change `typecheck__resolve_pred_overloading' to take a list of
argument types rather than a `map(var, type)' and a list of
arguments to allow a transformation to be performed on the
argument types before passing them.
compiler/error_util.m:
Move the part of `report_error_num_args' which writes
"wrong number of arguments (<x>; expected <y>)" from
typecheck.m for use by make_hlds.m when reporting errors
for Aditi builtins.
compiler/modes.m:
compiler/unique_modes.m:
compiler/modecheck_call.m:
Modecheck Aditi builtins.
compiler/lambda.m:
Handle the markers for predicates introduced for
`aditi_top_down' and `aditi_bottom_up' lambda expressions.
compiler/polymorphism.m:
Add extra type_infos to `aditi_insert' calls
describing the tuple to insert.
compiler/call_gen.m:
Generate code for Aditi builtins.
compiler/unify_gen.m:
compiler/bytecode_gen.m:
Abort on `aditi_top_down' and `aditi_bottom_up' lambda
expressions - code generation for them is not yet implemented.
compiler/magic.m:
Use the `aditi_call' generic_call rather than create
a new procedure for each Aditi predicate called from C.
compiler/rl_out.pp:
compiler/rl_gen.m:
compiler/rl.m:
Move some utility code used by magic.m and call_gen.m into rl.m.
Remove an XXX comment about reference counting being not yet
implemented - Evan has fixed that.
library/ops.m:
compiler/mercury_to_mercury.m:
doc/transition_guide.texi:
Add unary prefix operators `aditi_bottom_up' and `aditi_top_down',
used as qualifiers on lambda expressions.
Add infix operator `==>' to separate the tuples in an
`aditi_modify' call.
compiler/follow_vars.m:
Thread a `map(prog_var, type)' through, needed because
type information is no longer held in higher-order call goals.
compiler/table_gen.m:
Use the `make_*_construction' predicates in hlds_goal.m
to construct constants.
compiler/*.m:
Trivial changes to add extra fields to hlds_goal structures.
doc/reference_manual.texi:
Document Aditi updates.
Use @samp{pragma base_relation} instead of
@samp{:- pragma base_relation} throughout the Aditi documentation
to be consistent with other parts of the reference manual.
tests/valid/Mmakefile:
tests/valid/aditi_update.m:
tests/valid/aditi.m:
Test case.
tests/valid/Mmakefile:
Remove some hard-coded --intermodule-optimization rules which are
no longer needed because `mmake depend' is now run in this directory.
tests/invalid/*.err_exp:
Fix expected output for changes in reporting of call_ids
in typecheck.m.
tests/invalid/Mmakefile
tests/invalid/aditi_update_errors.{m,err_exp}:
tests/invalid/aditi_update_mode_errors.{m,err_exp}:
Test error messages for Aditi updates.
tests/valid/aditi.m:
tests/invalid/aditi.m:
Cut down version of extras/aditi/aditi.m to provide basic declarations
for Aditi compilation such as `aditi__state' and the modes
`aditi_di', `aditi_uo' and `aditi_ui'. Installing extras/aditi/aditi.m
somewhere would remove the need for these.
|
||
|
|
d66c8481ae |
Some more changes to minimize the complexity of the intermodule dependencies.
Estimated hours taken: 4 Some more changes to minimize the complexity of the intermodule dependencies. In particular, ensure that hlds_module.m does not need to import llds.m. compiler/hlds_module.m: compiler/llds.m: Move the definition of the c_interface_info type (and the types used for all its fields) from llds.m into hlds_module.m, since this type contains high-level information about the user-level C interface stuff that is not directly related to the LLDS and is needed by other back-ends. compiler/hlds_module.m: compiler/llds.m: compiler/mercury_compile.m: compiler/code_gen.m: compiler/stack_layout.m: compiler/table_gen.m: Move the `global_data' type from hlds_module.m into llds.m, since this type contains low-level stuff that is dependent on the LLDS. Delete the `global_data' field of the module_info, instead passing it around as a separate argument where needed. Move the code for inserting llds__tabling_pointer_vars into the global_data from table_gen.m to code_gen.m, since this is dependent on the LLDS and table_gen.m should be a pure HLDS->HLDS transformation, so that it can work with other back-ends. compiler/continuation_info.m: Update some comments which this change makes obsolete. compiler/optimize.m: Delete the import of module hlds_data, since it is no longer needed. |
||
|
|
ca0b3b7c6b |
Add an option that causes the compiler to pass information to the
Estimated hours taken: 8 Add an option that causes the compiler to pass information to the execution tracing system in one struct, rather than four separate arguments. Two of these arguments are pointers, which each require two instructions to set up on SPARC, MIPS and other RISCs that do not use a global pool. The other two arguments are small constants. Therefore on 32-bit RISCs, replacing MR_trace/4 with MR_trace_struct/1 will probably replace six instructions with two, which saves four instructions' worth of time and 16 bytes of code, at the cost of 12 bytes of data, and possibly the cost of some instructions later loading the info from the struct into registers. However, this loading cost does not have to be paid if tracing is not enabled, and other optimizations may reduce the cost even if tracing is enabled. For example, I strongly suspect that on out-of-order machines, which means most CPUs you can buy today, the load instructions are effectively free, because they happen while the indirect jump to MR_trace_real takes place. I intend to benchmark this option on our various platforms, and have autoconfigure set it on the machines in which it is beneficial. doc/user_guide.texi: Document the new --call-trace-struct option, and say it is not for general use. compiler/options.m: Add the new option. compiler/trace.m: If the option is set, call MR_trace_struct instead of MR_trace, and create a new kind of static (in both senses) global data structure to hold the arguments. Move the definition of trace_port to llds.m, and the procedure to convert it to string to llds_out.m compiler/code_info.m: Add an extra code_info slot to hold this new kind of global data, and its access predicates. compiler/code_gen.m: Transfer this new kind of global data from code_info to the global_data part of module_info. compiler/hlds_module.m: Add a new field to the global_data data structure to hold this data. compiler/mercury_compile.m: Include the new global data in the list of things we give to llds_out. compiler/llds.m: Add a new kind of comp_gen_c_data to hold MR_trace_struct arguments. Also move the definition of trace_port from trace.m to here, since the new kind of comp_gen_c_data refers to this type. compiler/llds_out.m: Add code to print the new kind of comp_gen_c_data. Move the code to print trace_ports from trace.m to here. compiler/llds_common.m: Ignore the new kind of comp_gen_c_data, since by construction its contents are never common with anything else. runtime/mercury_trace_base.[ch]: Add a new variant of MR_trace, MR_trace_struct, that consolidates the arguments into a single MR_Trace_Call_Info struct. Fix a bad variable name: the int argument to MR_trace is a max r register number, not a max mr register number. |
||
|
|
3bf462e0b7 |
Switch to a closure representation that includes runtime type and procedure id
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.
|
||
|
|
18430aaef1 |
Aditi compilation.
Estimated hours taken: 1200
Aditi compilation.
compiler/options.m:
The documentation for these is commented out because the Aditi
system is not currently useful to the general public.
--aditi: enable Aditi compilation.
--dump-rl: write the intermediate RL to `<module>.rl_dump'.
--dump-rl-bytecode: write a text version of the bytecodes
to `<module>.rla'
--aditi-only: don't produce a `.c' file.
--filenames-from-stdin: accept a list of filenames to compile
from stdin. This is used by the query shell.
--optimize-rl, --optimize-rl-cse, --optimize-rl-invariants,
--optimize-rl-index, --detect-rl-streams:
Options to control RL optimization passes.
--aditi-user:
Default owner of any Aditi procedures,
defaults to $USER or "guest".
--generate-schemas:
write schemas for base relations to `<module>'.base_schema
and schemas for derived relations to `<module>'.derived_schema.
This is used by the query shell.
compiler/handle_options.m:
Handle the default for --aditi-user.
compiler/hlds_pred.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
Add some Aditi pragma declarations - `aditi', `supp_magic', `context',
`naive', `psn' (predicate semi-naive), `aditi_memo', `aditi_no_memo',
`base_relation', `owner' and `index'.
Separate out code to parse a predicate name and arity.
compiler/hlds_pred.m:
Add predicates to identify Aditi procedures.
Added markers `generate_inline' and `aditi_interface', which
are used internally for Aditi code generation.
Add an `owner' field to pred_infos, which is used for database
security checks.
Add a field to pred_infos to hold the list of indexes for a base
relation.
compiler/make_hlds.m:
Some pragmas must be exported if the corresponding predicates
are exported, check this.
Make sure stratification of Aditi procedures is checked.
Predicates with a mode declaration but no type declaration
are no longer assumed to be local.
Set the `do_aditi_compilation' field of the module_info if there
are any local Aditi procedures or base relations.
Check that `--aditi' is set if Aditi compilation is required.
compiler/post_typecheck.m:
Check that every Aditi predicate has an `aditi__state' argument,
which is used to ensure sequencing of updates and that Aditi
procedures are only called within transactions.
compiler/dnf.m:
Changed the definition of disjunctive normal form slightly
so that a call followed by some atomic goals not including
any database calls is considered atomic. magic.m can handle
this kind of goal, and it results in more efficient RL code.
compiler/hlds_module.m:
compiler/dependency_graph.m:
Added dependency_graph__get_scc_entry_points which finds
the procedures in an SCC which could be called from outside.
Added a new field to the dependency_info, the
aditi_dependency_ordering. This contains all Aditi SCCs of
the original program, with multiple SCCs merged where
possible to improve the effectiveness of differential evaluation
and the low level RL optimizations.
compiler/hlds_module.m:
Add a field to record whether there are any local Aditi procedures
in the current module.
Added versions of module_info_pred_proc_info and
module_info_set_pred_proc_info which take a pred_proc_id,
not a separate pred_id and proc_id.
compiler/polymorphism.m:
compiler/lambda.m:
Make sure that predicates created for closures in Aditi procedures
have the correct markers.
compiler/goal_util.m:
Added goal_util__switch_to_disjunction,
goal_util__case_to_disjunct (factored out from simplify.m)
and goal_util__if_then_else_to_disjunction. These are
require because supplementary magic sets can't handle
if-then-elses or switches.
compiler/type_util.m:
Added type_is_aditi_state/1.
compiler/mode_util.m:
Added partition_args/5 which partitions a list of arguments
into inputs and others.
compiler/inlining.m:
Don't inline memoed procedures.
Don't inline Aditi procedures into non-Aditi procedures.
compiler/intermod.m:
Handle Aditi markers.
Clean up handling of markers which should not appear in `.opt' files.
compiler/simplify.m:
Export a slightly different interface for use by magic.m.
Remove explicit quantifications where possible.
Merge multiple nested quantifications.
Don't report infinite recursion warnings for Aditi procedures.
compiler/prog_out.m:
Generalised the code to output a module list to write any list.
compiler/code_gen.m:
compiler/arg_info.m:
Don't process Aditi procedures.
compiler/mercury_compile.m:
Call magic.m and rl_gen.m.
Don't perform the low-level annotation passes on Aditi procedures.
Remove calls to constraint.m - sometime soon a rewritten version
will be called directly from deforestation.
compiler/passes_aux.m:
Add predicates to process only non-Aditi procedures.
compiler/llds.m:
compiler/llds_out.m:
Added new `code_addr' enum members, do_{det,semidet,nondet}_aditi_call,
which are defined in extras/aditi/aditi.m.
compiler/call_gen.m:
Handle generation of do_*_aditi_call.
compiler/llds_out.m:
Write the RL code for the module as a constant char array
in the `.c' file.
compiler/term_errors.m:
compiler/error_util.m:
Move code to describe predicates into error_util.m
Allow the caller to explicitly add line breaks.
Added error_util:list_to_pieces to format a list of
strings.
Reordered some arguments for currying.
compiler/hlds_out.m:
Don't try to print clauses if there are none.
runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
Added a function `mercury__load_aditi_rl_code()' to the generated
`<module>_init.c' file which throws all the RL code for the program
at the database. This should be called at connection time by
`aditi__connect'.
Added an option `--aditi' which controls the output
`mercury__load_aditi_rl_code()'.
compiler/notes/compiler_design.html:
Document the new files.
Mmakefile:
bindist/Mmakefile:
Don't distribute extras/aditi yet.
New files:
compiler/magic.m:
compiler/magic_util.m:
Supplementary magic sets transformation. Report errors
for constructs that Aditi can't handle.
compiler/context.m:
Supplementary context transformation.
compiler/rl_gen.m:
compiler/rl_relops.m:
Aditi code generation.
compiler/rl_info.m:
Code generator state.
compiler/rl.m:
Intermediate RL representation.
compiler/rl_util:
Predicates to collect information about RL instructions.
compiler/rl_dump.m:
Print out the representation in rl.m.
compiler/rl_opt.m:
Control low-level RL optimizations.
compiler/rl_block.m:
Break a procedure into basic blocks.
compiler/rl_analyse.m:
Generic dataflow analysis for RL procedures.
compiler/rl_liveness.m:
Make sure all relations are initialised before used, clear
references to relations that are no longer required.
compiler/rl_loop.m:
Loop invariant removal.
compiler/rl_block_opt.m:
CSE and instruction merging on basic blocks.
compiler/rl_key.m:
Detect upper/lower bounds for which a goal could succeed.
compiler/rl_sort.m:
Use indexing for joins and projections.
Optimize away unnecessary sorting and indexing.
compiler/rl_stream.m:
Detect relations which don't need to be materialised.
compiler/rl_code.m:
RL bytecode definitions. Automatically generated from the Aditi
header files.
compiler/rl_out.m:
compiler/rl_file.m:
Output the RL bytecodes in binary to <module>.rlo (for use by Aditi)
and in text to <module>.rla (for use by the RL interpreter).
Also output the schema information if --generate-schemas is set.
compiler/rl_exprn.m:
Generate bytecodes for join conditions.
extras/aditi/Mmakefile:
extras/aditi/aditi.m:
Definitions of some Aditi library predicates and the
interfacing and transaction processing code.
|
||
|
|
27f024b2e9 |
Reorganize the handling of global data structures, and expose the table
Estimated hours taken: 16 Reorganize the handling of global data structures, and expose the table pointers for tabled predicates to allow the tables to be reset to empty by hand-written C code for benchmarking purposes. compiler/hlds_module.m: Introduce a new submodule for dealing with global data. At the moment it deals with (a) layout structures and (b) tabling pointers. compiler/continuation_info.m: Remove the data structures and predicates whose equivalents are now in hlds_module. compiler/llds.m: Introduce a new kind of item, that of compiler-generated variables whose value is not defined by rvals. At the moment, the only such item is a tabling pointer variable. compiler/mercury_compile.m: Include the new kind of item in the generated LLDS. compiler/table_gen.m: Use the new kind of item instead of a static variable declaration in pragma C code to hold the tabling pointer. Remove lots of spaces at ends of lines, since many of these screw up paragraph commands in vi. compiler/base_type_layout.m: compiler/bytecode_gen.m: compiler/code_gen.m: compiler/code_util.m: compiler/dependency_graph.m: compiler/hlds_out.m: compiler/llds_out.m: compiler/mercury_to_mercury.m: compiler/switch_gen.m: compiler/transform_llds.m: compiler/unify_gen.m: Handle the changes in the data structures. library/private_builtin.m: Remove the predicate get_table, which is no longer used after the changes to table_gen.m. |
||
|
|
5c955626f2 |
These changes make var' and term' polymorphic.
Estimated hours taken: 20 These changes make `var' and `term' polymorphic. This allows us to make variables and terms representing types of a different type to those representing program terms and those representing insts. These changes do not *fix* any existing problems (for instance there was a messy conflation of program variables and inst variables, and where necessary I've just called varset__init(InstVarSet) with an XXX comment). NEWS: Mention the changes to the standard library. library/term.m: Make term, var and var_supply polymorphic. Add new predicates: term__generic_term/1 term__coerce/2 term__coerce_var/2 term__coerce_var_supply/2 library/varset.m: Make varset polymorphic. Add the new predicate: varset__coerce/2 compiler/prog_data.m: Introduce type equivalences for the different kinds of vars, terms, and varsets that we use (tvar and tvarset were already there but have been changed to use the polymorphic var and term). Also change the various kinds of items to use the appropriate kinds of var/varset. compiler/*.m: Thousands of boring changes to make the compiler type correct with the different types for type, program and inst vars and varsets. |
||
|
|
650fb78cd5 |
Add compiler support for Mark's declarative debugger.
Estimated hours taken: 5 Add compiler support for Mark's declarative debugger. The runtime support will come later. from Mark. compiler/options.m: Add a new option, --trace-decl, that causes the compiler to reserve two extra stack slots in every stack frame. The declarative debugger will use these slots to store pointers to the proof tree node of the current call, and the location in the parent's proof tree node where the proof tree node of this call ought to be inserted. Since there is no runtime support yet, the option is not yet included in the help message. compiler/trace.m: Generalize the code for reserving stack slots for tracing, and expand it to conditionall allocate two slots for the declarative debugger. Add a new type trace_slot_info, and use that instead of maybe(int) to describe the stack slots used by the trace system, for passing through code_info and code_gen to continuation_info. compiler/code_info.m: compiler/code_gen.m: compiler/continuation_info.m: Minor changes (mostly to variable names and comments) to refer to trace_slot_info. compiler/stack_layout.m: Include the numbers of the two stack slots used for declarative debugging in the procedure's stack layout structure. Actually, since these two stack slots are always adjacent, we only store the number of the first. runtime/mercury_stack_layout.h: Extend the MR_Stack_Layout_Entry struct to cover the new entry. doc/user_guide.texi: Add documentation of the new option, commented out for now. |
||
|
|
085c8b8113 |
Make it possible to compile a module (e.g. std_util) without debugging,
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.
|
||
|
|
6b9583eb74 |
Extend the layout scheme to handle typeinfos inside typeclass infos,
Estimated hours taken: 16
Extend the layout scheme to handle typeinfos inside typeclass infos,
and thus enable the debugger (and later native gc) to work with programs
that use type classes and existential types.
compiler/llds.m:
Change the data structure that holds information about the locations
of the typeinfo variables of the tvars active at call return sites
from set(pair(tvar, lval)) to map(tvar, set(layout_locn)).
The change from set to map avoids the possibility of inadvertently
duplicating the info for a give type variable.
The change to explicitly keep a set of locations in which the typeinfo
var may be found allows us to use set intersection on those sets if
(a) the program point may be reached via more than one path, and
(b) not all paths have the same sets. Both of these can happen in
programs that use type classes.
The change from lval to layout_locn (which encodes either an lval,
or an lval representing a typeclass info and an (indirect) offset
inside that typeclass info) is necessary support programs with
type classes.
compiler/continuation_info.m:
Change the data structure that holds information about the locations
of the typeinfo variables of the tvars active at a particular program
point the same way and for the same reasons as in llds.m.
Take set intersections of typeinfo var locations whenever we find
multiple live variable info records for the same label.
compiler/call_gen.m:
Delay the construction of the return live variable information
until the code generator state has been updated to reflect where
things will be on return, instead of trying to cobble up this
info into the code generator state that reflects the point just
before the call. Apart from being cleaner, this is necessary
to avoid compiler aborts for programs that use existential types.
The old compiler could not find the typeinfos of any existentially
quantified type vars, since they do not exist before the call.
compiler/code_info.m:
Rewrite and generalize the code for generating live value information.
compiler/trace.m:
Remove the specialized code for generating live value information;
call code_info instead.
compiler/stack_layout.m:
Pick one of several possible locations for a typeinfo var.
Generate the new indirect layout location descriptions.
Reduce the number of tag bits used to describe different kinds of
lvals, to leave more room for the indirect information.
compiler/*.m:
Conform to the above data structure changes.
compiler/hlds_pred.m:
Clarify the documentation of type_info_locn.
runtime/mercury_stack_layout.h:
Update the section that deals with MR_Live_Lval to take
indirect typeinfo locations into account.
runtime/mercury_layout_util.c:
Handle indirect typeinfo locations when interpreting layout structures.
runtime/mercury_layout_util.c:
trace/mercury_trace_internal.c:
Ignore variables whose names start with TypeClassInfo.
runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
Add markers to remind Tyson to handle indirect typeinfo locations.
tests/debugger/implied_instance.{m,inp,exp}:
tests/debugger/multi_paramster.{m,inp,exp}:
tests/debugger/existential_type_classes.{m,inp,exp}:
Copies of the tests in tests/hard_coded/typeclasses, modified to
avoid or delay I/O, so that the calls to I/O preds that may or may
not be traced to do not affect the output.
tests/debugger/Mmakefile:
Add the new test cases.
Remove references to the *_lib variants of the old test cases.
They are not necessary if I/O is delayed until after the last
reported trace event.
tests/hard_coded/typeclasses/Mmakefile:
Remove --trace deep from existential_type_classes, since that
aspect of the test case is now covered in the debugger directory.
|
||
|
|
16f3d4ccaa |
This checkin has several major purposes, set out in the sections below,
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.
|
||
|
|
2b605fa6e8 |
Fix several bugs in the runtime engine to do with thread-safe execution.
Estimated hours taken: 15
Fix several bugs in the runtime engine to do with thread-safe execution.
Add a new flag to pragma c_code/import to allow programmers to specify
whether or not the C code is thread-safe or not, and modify code generation
to put a lock around C code that isn't thread_safe.
runtime/mercury_thread.{c,h}:
Add a global lock.
Change the handling of thread creation. create_thread now takes
a "closure" (a C struct with a fn pointer and an argument to pass
the function) which it calls in the new thread. (The same mechanism
is used in the Boehm collector), or NULL which causes the thread
to wait for work to appear in the Mercury runqueue.
runtime/mercury_context.c:
initialize the global lock.
runtime/mercury_engine.{c,h}:
Add a new field to the MercuryEngine structre which is used to
store a list of saved thread ids. These were being saved in a
local variable in call_engine_inner which was a bug because
call_engine_inner's (C) stack frame gets scribbled on by Mercury
execution. For more detail see the comments in mercury_engine.h
runtime/mercury_wrapper.c:
Use the new interface to create_thread.
compiler/prog_io_pragma.m:
Parse either a single attribute or a list of attributes instead
of just 'may_call_mercury' in pragma c code and pragma import.
These are stored in an abstract type 'pragma_c_code_attributes'
that uses a bit array (aka int) to store the attributes.
compiler/pragma_c_gen.m:
Get the code generator to emit c code to obtain and release the
global lock for pragma c code that isn't thread_safe.
compiler/<various>.m:
Change may_call_mercury to pragma_c_code_attributes.
doc/reference_manual.m:
Document the change to pragma c code.
scripts/mgnuc.in:
Pass some extra C flags for thread-safe compilation for Linux.
|
||
|
|
d1855187e5 |
Implement new methods of handling failures and the end points of branched
Estimated hours taken: 260
Implement new methods of handling failures and the end points of branched
control structures.
compiler/notes/failure.html:
Fix an omission about the handling of resume_is_known in if-then-elses.
(This omission lead to a bug in the implementation.)
Optimize cuts across multi goals when curfr is known to be equal
to maxfr.
Clarify the wording in several places.
compiler/code_info.m:
Completely rewrite the methods for handling failure.
Separate the fields of code_info into three classes: those which
do not change after initialization, those which record state that
depends on where in the HLDS goal we are, and those which contain
persistent data such as label and cell counters.
Rename grab_code_info and slap_code_info as remember_position
and reset_to_position, and add a wrapper around the remembered
code_info to make it harder to make mistakes in its use.
(Only the location-dependent fields of the remembered code_info
are used, but putting only them into a separate data structure would
result in more, not less, memory being allocated.)
Gather the predicates that deal with handling branched control
structures into a submodule.
Reorder the declarations and definitions of access predicates
to conform to the new order of fields.
Reorder the declarations and definitions of the failure handling
submodule to better reflect the separation of higher-level and
lower-level predicates.
compiler/code_gen.m:
Replace code_gen__generate_{det,semi,non}_goal_2 with a single
predicate, since for most HLDS constructs the code here is the same
anyway (the called preds check the code model when needed).
Move classification of the various kinds of unifications to unify_gen,
since that is where it belongs.
Move responsibility for initializing the code generator's trace
info to code_info.
Move the generation of code for negations to ite_gen, since the
handling of negations is a cut-down version of the handling of
negations. This should make the required double maintenance easier,
and more likely to happen.
compiler/disj_gen.m:
compiler/ite_gen.m:
These are the two modules that handle most failures; they have
undergone a significant rewrite. As part of this rewrite, factor
out the remaining common code between model_non and model_{det,semi}
goals.
compiler/unify_gen.m:
Move classification of the various kinds of unifications here from
code_gen. This allows us to keep several previously exported
predicates private.
compiler/call_gen.m:
Factor out some code that was common to ordinary calls, higher order
calls and method calls. Move the common code that checks whether
we are doing tracing to trace.m.
Replace call_gen__generate_{det,semi,nondet}_builtin with a single
predicate.
Delete the commented out call_gen__generate_complicated_unify,
since it will never be needed and in any case suffered from
significant code rot.
compiler/llds.m:
Change the mkframe instruction so that depending on one of its
arguments, it can create either ordinary frames, or the cut-down
frames used by the new failure handling algorithm (they have only
three fixed fields: prevfr, redoip and redofr).
compiler/llds_out.m:
Emit a #define MR_USE_REDOFR before including mercury_imp.h, to
tell the runtime we are using the new failure handling scheme.
This effectively changes the grade of the compiled module.
Emit MR_stackvar and MR_framevar instead of detstackvar and framevar.
This is a step towards cleaning up the name-space, and a step towards
making both start numbering at 0. For the time being, the compiler
internally still starts counting framevars at 0; the code in llds_out.m
adds a +1 offset.
compiler/trace.m:
Change the way trace info is initialized to fit in with the new
requirements of code_info.m.
Move the "are we tracing" check from the callers to the implementation
of trace__prepare_for_call.
compiler/*.m:
Minor changes in accordance with the major ones above.
compiler/options.m:
Introduce a new option, allow_hijacks, which is set to "yes" by
default. It is not used yet, but the idea is that when it is set to no,
the code generator will not generate code that hijacks the nondet
stack frame of another procedure invocation; instead, it will create
a new temporary nondet stack frame. If the current procedure is
model_non, it will have three fields: prevfr, redoip and redofr.
If the current procedure is model_det or model_semi, it will have
a fourth field that is set to the value of MR_sp. The idea is that
the runtime system, which will be able to distinguish between
ordinary frames (whose size is at least 5 words), 3-word and 4-word
temporary frames, will now be able to use the redofr slots of
all three kinds of frames and the fourth slot values of 4-word
temporary frames as the addresses relative to which framevars
and detstackvars respectively ought to be offset in stack layouts.
compiler/handle_options.m:
Turn off allow_hijacks if the gc method is accurate.
runtime/mercury_stacks.h:
Change the definitions for the nondet stack handling macros
to accommodate the new nondet stack handling discipline.
Define a new macro for creating temp nondet frames.
Define MR_based_stackvar and MR_based_framevar (both of which start
numbering slots at 1), and express other references, including
MR_stackvar and MR_framevar and backward compatible definitions of
detstackvar and framevar for hand-written C code, in terms of those
two.
runtime/mercury_stack_trace.[ch]:
Add a new function to print a dump of the fixed elements nondet stack,
for debugging my changes. (The dump does not include variable values.)
runtime/mercury_trace_internal.c:
Add a new undocumented command "D" for dumping the nondet stack
(users should not know about this command, since the output is
intelligible only to implementors).
Add a new command "toggle_echo" that can cause the debugger to echo
all commands. When the input to the debugger is redirected, this
echo causes the output of the session to be much more readable.
runtime/mercury_wrapper.c:
Save the address of the artificial bottom nondet stack frame,
so that the new function in mercury_stack_trace.c can find out
where to stop.
runtime/mercury_engine.c:
runtime/mercury_wrapper.c:
Put MR_STACK_TRACE_THIS_MODULE at the tops of these modules, so that
the labels they define (e.g. do_fail and global_success) are registered
in the label table when their module initialization functions are
called. This is necessary for a meaningful nondet stack dump.
runtime/mercury_grade.h:
Add a new component to the grade string that specifies whether
the code was compiled with the old or the new method of handling
the nondet stack. This is important, because modules compiled
with different nondet stack handling disciplines are not compatible.
This component depends on whether MR_USE_REDOFR is defined or not.
runtime/mercury_imp.h:
If MR_DISABLE_REDOFR is defined, undefine off MR_USE_REDOFR before
including mercury_grade.h. This is to allow people to continue
working on un-updated workspaces after this change is installed;
they should put "EXTRA_CFLAGS = -DMR_DISABLE_REDOFR" into
Mmake.stage.params. (This way their stage1 will use the new method
of handling failure, while their stage2 2&3 will use the old one.)
This change should be undone once all our workspaces have switched
over to the new failure handling method.
tests/hard_coded/cut_test.{m,exp}:
A new test case to tickle the various ways of handling cuts in the
new code generator.
tests/hard_coded/Mmakefile:
Enable the new test case.
|
||
|
|
16e50a0244 |
Fix a bug in the generation of init_entry_sl(...) code.
Estimated hours taken: 2 Fix a bug in the generation of init_entry_sl(...) code. compiler/code_gen.m: compiler/continuation_info.m: compiler/stack_layout.m: Previously the code used a proc_label to describe an entry label, and stored (incorrectly) as local(proc_label) in a list of labels (the list of labels that had stack_layouts). Later when deciding whether an "init_entry" or "init_entry_sl" should be generated, it looked for the label in the list of labels for which stack layouts had been generated, but would compare with the actual label for the entry. In particular, the label might be exported(....) instead of local(....), which means init_entry was used instead of init_entry_sl. Fix this by correctly generating labels rather than assuming they are local(...), and using "label" where "proc_label" was used before. |
||
|
|
4ab3f397b1 |
Allow the debugger to print the values of variables in ancestors
Estimated hours taken: 20 Allow the debugger to print the values of variables in ancestors of the current call. This requires knowledge about which named variables are live at call return sites. Providing this information properly required fixing the interaction of execution tracing and accurate garbage collection. compiler/globals.m: Introduce a new trace level, so that there are now four: none, interface, interface_ports (corresponding to the existing three levels) and the new level interface_ports_returns, each of which requires all the information required by lower levels. Make the trace level abstract, since in the future we may want to introduce trace levels for new combinations, e.g. interfaces and returns but not internal ports. Introduce the necessary new predicates. compiler/continuation_info.m: Redefine internal_label_info to allow us to record separate info about the sets of vars needed at (a) internal ports of execution tracing and at (b) call return points for accurate gc or (now) uplevel printing during execution tracing. Neither is a subset of the other, and they need to be treated differently. compiler/mercury_compile.m: Gather information about vars at return labels if the trace level requires uplevel printing capability, even if agc is off. compiler/stack_layout.m: Fix the handling of labels which are needed both by agc and by execution tracing. If information at a return label is needed only by uplevel printing in execution tracing and not by agc, then discard all info about lvals which do not hold named variables or their typeinfos (in fact we keep all typeinfos at the moment). If a label is both the label of a port and a return label, we include in the layout structure the union of the information recorded for the two roles. Sort the var_info vector before using it to generate layout structures in an attempt to make llds_common more effective and to make lists of variables printed by the debugger look better. Record a distinguished value when there is no info about the vars live at a label, rather than (incorrectly) recording that there are no live variables. Before up-level printing, the lie was harmless; now it isn't. Remove the label number from return label layouts, since the tracer isn't expecting it. It used to be included for debugging purposes if the label was for agc, but it is possible for a label to be needed both for agc and for execution tracing. If Tyson finds he needs the label number, it can be easily turned back on for all label layouts. compiler/code_info.m: Conform to the new definition of internal_label_info. Rename an internal pred for clarity. Rename some bool parameter to correctly reflect their new meaning. compiler/*.m: Trivial changes, mostly due to making trace_level an abstract type. runtime/mercury_stack_layout.h: Remove the label number from return label layouts, since the tracer isn't expecting it. runtime/mercury_stack_trace.[ch]: Add a new function that returns the label layout structure at the Nth ancestor return continuation, together with the values of sp and curfr at that point. This required changing MR_stack_walk_step to step from an entry layout only to the return label layout. runtime/mercury_stacks.h: Add macros that let us access detstackvars and framevars based on these synthesized values of sp and curfr. runtime/mercury_trace_util.[ch]: Generalize several functions to allow them to use synthesized (as opposed to saved) values of sp and curfr in looking up values. Retain functions with the original names and signatures that call the new, general versions with the necessary additional parameters. runtime/mercury_trace_internal.c: Add a new command that sets the "ancestor level". For example, "l 2" sets it to 2, which means that the command "v" and "p" will refer to the grandparent of the current call. The ancestor level persists while the debugger is at the current event; after that it is reset to 0. The implementation involves calling the new function in mercury_stack_trace.c and the generalized functions in mercury_trace_util.c. Also add a deliberately undocumented extra command, X, which prints the stack pointers. NEWS: Add a reminder about removing the X command before release. tests/debugger/* Update half the test cases (those which assume a non-debug-grade library) to conform to the changes in the debugger interface. The others will need to be updated later. |
||
|
|
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
|
||
|
|
d10af74168 |
This change introduces interface tracing, and makes it possible to successfully
Estimated hours taken: 50
This change introduces interface tracing, and makes it possible to successfully
bootstrap the compiler with tracing (either interface or full).
compiler/options.m:
Change the bool options --generate-trace into a string option --trace
with three valid values: minimal, interface and full. The last two mean
what they say; the intention is that eventually minimal will mean
no tracing in non-tracing grades and interface tracing in tracing
grades.
compiler/globals.m:
Add a new global for the trace level.
compiler/handle_options.m:
Convert the argument of --trace to a trace level.
Use only consistent 4-space indentation in the deeply nested
if-then-else.
compiler/trace.m:
Implement interface tracing.
Rename trace__generate_depth_reset_code as trace__prepare_for_call,
since it does more than reset the depth if this module is compiled
with interface tracing.
Do not check whether tracing is enabled before calling MR_trace;
let MR_trace make the check. This trades increased non-tracing
execution time for a substantial code size reduction (which may
in turn benefit execution time).
compiler/call_gen.m:
Call trace__generate_depth_reset_code by its new name.
compiler/code_info.m:
Fix a bug in the handling of non/semi commits. When entering a commit,
we used to push a clone of whatever the top failure continuation was.
However, the resume setup for this continuation could have started
with a label that assumed that the resume vars were in their original
locations (which are often registers), whereas the method of
backtracking to that point only guarantees the survival of stack slots,
not registers.
(This bug caused two lines of incorrect code to be generated among
the approx 30 million lines of code in the stage 2 compiler when
compiled with tracing.)
Fix another bug (previously untriggered as far as I know) in the
handling of multi/det commits. This one was breaking the invariant
that the resume vars set of each entry on the failure continuation
stack included the resume vars set of every other entry below it,
which meant that the values of these resume vars were not guaranteed
to be preserved.
compiler/stack_layout.m:
Make layout structures local to their module. They are not (yet)
referred to by name from other modules, and by declaring them
to be global we caused their names to be included even in stripped
executables, adding several megabytes to the size of the binary.
(The names are not stripped because a dynamically linked library
may want to refer to them.)
Change the mercury_data__stack_layout__ prefix on the names of
generated globals vars to just mercury_data__layout__. It is now
merely too long instead of far too long.
Include the label number in the label layout structure and the number
of typeinfo variables in a var_info structure only with native gc.
Their only use is in debugging native gc.
Fix some documentation rot.
compiler/llds.m:
Add a new field to the pragma_c instruction that says whether the
compiler-generated C code fragments access any stack variables.
compiler/frameopt.m:
Use the new field in pragma_c's to avoid a bug. Because frameopt was
assuming that the pragma_c instruction that filled in the stack slots
containing the call sequence number and depth did not access the stack,
it moved the pragma_c before the incr_sp that allocates the frame
(it was trying to get it out of the loop).
compiler/*.m:
Minor changes to set or ignore the extra field in pragma_c, to refer
to layout structures via the new prefix, or to handle the --trace
option.
doc/user_guide.texi:
Update the documentation for --trace.
runtime/mercury_types.h:
Add the type Unsigned.
runtime/mercury_goto.h:
Use the shorter layout prefix.
runtime/mercury_stack_layout.h:
Use the shorter layout prefix, and include the label number only with
native gc.
runtime/mercury_trace.[ch]:
runtime/mercury_trace_internal.[ch]:
runtime/mercury_trace_external.[ch]:
runtime/mercury_trace_util.[ch]:
Divide the old mercury_trace.[ch] into several components, with one
module for the internal debugger, one for the interface to the
external debugger, one for utilities needed by both. Mercury_trace.c
now has only the top-level stuff that steers between the two
debuggers.
runtime/mercury_trace.[ch]:
Add the new global variable MR_trace_from_full. Before each call,
the calling procedure assigns TRUE to this variable if the caller
is fully traced, and FALSE otherwise. Interface traced procedures
generate trace events only if this variable is TRUE when they are
called (fully traced callee procedures ignore the initial value of
the variable).
Make MR_trace return immediately without doing anything unless
tracing is enabled and a new extra argument to MR_trace is TRUE.
This extra argument is always TRUE for trace events in fully traced
procedures, while for trace events from interface traced procedures,
its value is set from the value of MR_trace_from_full at the time
that the procedure was called (i.e. the event is ignored unless the
interface traced procedure was called from a fully traced procedure).
runtime/mercury_trace.[ch]:
runtime/mercury_trace_internal.[ch]:
For global variables that are stored in stack slots, make their type
Word rather than int.
Use a new function MR_trace_event_report instead of calling
MR_trace_event with a NULL command structure pointer to indicate
that the event is to be reported but there is to be no user
interaction.
Use %ld formats in printfs and casts to long for better portability.
runtime/mercury_trace_internal.c:
Save trace-related globals across calls to Mercury library code
in the debugger, since otherwise any trace events in this code
could screw up e.g. the event number or the call number sequence.
Create separate functions for printing port names and determinisms.
runtime/mercury_wrapper.h:
Disable the tracing of the initialization and finalization code
written in Mercury.
runtime/Mmakefile:
Update for the new source and header files.
tests/debugger/{debugger_regs,interpreter,queens}_lib.{m,inp,exp}:
One new copy of each existing test case. These ones are intended
to be used when the stage 2 library is compiled with tracing, which
affects the tests by adding events for the library procedures called
from the test programs.
The .m files are the same as before; one of the .inp files is a bit
different; the .exp files reflect the correct output when the library
is compiled with full tracing.
tests/debugger/Mmakefile:
Provide separate targets for the new set of test cases.
Use --trace full instead of --generate-trace.
tests/debugger/runtests:
Try both the new set of test cases if the old set fails, and report
failure only if both sets fail. This is simpler than trying to figure
out which set should be really tested, and the probability of a false
positive is negligible.
|
||
|
|
67d8308260 | Same as previous message. | ||
|
|
11d8161692 |
Add support for nested modules.
Estimated hours taken: 50
Add support for nested modules.
- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
which name sub-modules
- a sub-module has access to all the declarations in the
parent module (including its implementation section).
This support is not yet complete; see the BUGS and LIMITATIONS below.
LIMITATIONS
- source file names must match module names
(just as they did previously)
- mmc doesn't allow path names on the command line any more
(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
`include_module').
BUGS
- doesn't check that the parent module is imported/used before allowing
import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced
-------------------
NEWS:
Mention that we support nested modules.
library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
Add `include_module' as a new prefix operator.
Change the associativity of `:' from xfy to yfx
(since this made parsing module qualifiers slightly easier).
compiler/prog_data.m:
Add new `include_module' declaration.
Change the `module_name' and `module_specifier' types
from strings to sym_names, so that module names can
themselves be module qualified.
compiler/modules.m:
Add predicates module_name_to_file_name/2 and
file_name_to_module_name/2.
Lots of changes to handle parent module dependencies,
to create parent interface (`.int0') files, to read them in,
to output correct dependencies information for them to the
`.d' and `.dep' files, etc.
Rewrite a lot of the code to improve the readability
(add comments, use subroutines, better variable names).
Also fix a couple of bugs:
- generate_dependencies was using the transitive implementation
dependencies rather than the transitive interface dependencies
to compute the `.int3' dependencies when writing `.d' files
(this bug was introduced during crs's changes to support
`.trans_opt' files)
- when creating the `.int' file, it was reading in the
interfaces for modules imported in the implementation section,
not just those in the interface section.
This meant that the compiler missed a lot of errors.
library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
Add `:- import_module' declarations to the interface needed
by declarations in the interface. (The previous version
of the compiler did not detect these missing interface imports,
due to the above-mentioned bug in modules.m.)
compiler/mercury_compile.m:
compiler/intermod.m:
Change mercury_compile__maybe_grab_optfiles and
intermod__grab_optfiles so that they grab the opt files for
parent modules as well as the ones for imported modules.
compiler/mercury_compile.m:
Minor changes to handle parent module dependencies.
(Also improve the wording of the warning about trans-opt
dependencies.)
compiler/make_hlds.m:
compiler/module_qual.m:
Ignore `:- include_module' declarations.
compiler/module_qual.m:
A couple of small changes to handle nested module names.
compiler/prog_out.m:
compiler/prog_util.m:
Add new predicates string_to_sym_name/3 (prog_util.m) and
sym_name_to_string/{2,3} (prog_out.m).
compiler/*.m:
Replace many occurrences of `string' with `module_name'.
Change code that prints out module names or converts
them to strings or filenames to handle the fact that
module names are now sym_names intead of strings.
Also change a few places (e.g. in intermod.m, hlds_module.m)
where the code assumed that any qualified symbol was
fully-qualified.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Move sym_name_and_args/3, parse_qualified_term/4 and
parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
since they are very similar to the parse_symbol_name/2 predicate
already in prog_io.m. Rewrite these predicates, both
to improve maintainability, and to handle the newly
allowed syntax (module-qualified module names).
Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.
compiler/prog_io.m:
Rewrite the handling of `:- module' and `:- end_module'
declarations, so that it can handle nested modules.
Add code to parse `include_module' declarations.
compiler/prog_util.m:
compiler/*.m:
Add new predicates mercury_public_builtin_module/1 and
mercury_private_builtin_module/1 in prog_util.m.
Change most of the hard-coded occurrences of "mercury_builtin"
to call mercury_private_builtin_module/1 or
mercury_public_builtin_module/1 or both.
compiler/llds_out.m:
Add llds_out__sym_name_mangle/2, for mangling module names.
compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
Move the predicates in_mode/1, out_mode/1, and uo_mode/1
from special_pred.m to mode_util.m, and change various
hard-coded definitions to instead call these predicates.
compiler/polymorphism.m:
Ensure that the type names `type_info' and `typeclass_info' are
module-qualified in the generated code. This avoids a problem
where the code generated by polymorphism.m was not considered
type-correct, due to the type `type_info' not matching
`mercury_builtin:type_info'.
compiler/check_typeclass.m:
Simplify the code for check_instance_pred and
get_matching_instance_pred_ids.
compiler/mercury_compile.m:
compiler/modules.m:
Disallow directory names in command-line arguments.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
Add a `--make-private-interface' option.
The private interface file `<module>.int0' contains
all the declarations in the module; it is used for
compiling sub-modules.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Add support for creating `.int0' and `.date0' files
by invoking mmc with `--make-private-interface'.
doc/user_guide.texi:
Document `--make-private-interface' and the `.int0'
and `.date0' file extensions.
doc/reference_manual.texi:
Document nested modules.
util/mdemangle.c:
profiler/demangle.m:
Demangle names with multiple module qualifiers.
tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
Change the `:- module string__format_test' declaration in
`string__format_test.m' to `:- module string_format_test',
because with the original declaration the `__' was taken
as a module qualifier, which lead to an error message.
Hence rename the file accordingly, to avoid the warning
about file name not matching module name.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
Regression test to check that the compiler reports
errors for missing `import_module' in the interface section.
tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
Update the expected diagnostics output for the test cases to
reflect a few minor changes to the warning messages.
tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
Two simple tests case for the use of nested modules with
separate compilation.
|
||
|
|
3fc8750607 |
Put type parameter locations into stack layouts.
Estimated hours taken: 15 Put type parameter locations into stack layouts. compiler/code_gen.m: Generate typeinfos for entry and exit points. compiler/stack_layout.m: Output the type parameters vector. |
||
|
|
5ef3bb6fdc |
Use stack layout tables to transmit information to the tracer, to allow
Estimated hours taken: 20
Use stack layout tables to transmit information to the tracer, to allow
the tracer to print the names and values of variables at CALL and EXIT ports.
Extend stack layout tables to permit this.
For the time being the tables do not contain information about how to fill
in pseudo-typeinfos, so printing only works for monomorphic procedures.
compiler/llds.m:
Allow space for variable names in the information we gather about live
variables at given labels.
compiler/llds_out.m:
Print out variable names in the information we gather about live
variables at given labels in comments.
compiler/continuation_info.m:
Include variable names in the information we gather about live
variables at given labels.
Record the determinism of each procedure, not its code model.
compiler/{call_gen,code_gen,code_info}.m:
Include the names of variables in the data given to
continuation_info.m.
compiler/options.m:
Add a new developer-only option, --procid-stack-layout, whose effect
is to extend stack_layout structures with static info identifying the
procedure. This is used by execution tracing, and could (should) be
used by stack tracing and profiling.
Rename --alternate-liveness as --typeinfo-liveness. This is more
expressive. Later we should add a new option --trace-liveness, which
preserves every variable until the end of the clause for use by
the trace debugger.
compiler/handle_options.m:
Handle the option implications of --procid-stack-layout.
compiler/stack_layout.m:
Include the encoded determinism instead of the code model in stack
layout tables.
Include variable names in the live data section of stack layout tables
if they are available.
Include procedure identification information in the stack layout tables
if --procid-stack-layout is set.
compiler/trace.m:
Use the new interface to MR_trace.
compiler/*.m:
Trivial changes following from the renaming of --alternate-liveness.
runtime/mercury_accurate_gc.h:
Add macros to decode encoded determinisms.
Define structs for accessing the stack layout tables.
runtime/mercury_regs.h:
Define a macro similar to virtual_reg, except in that it can refer
to an arbitrary memory area, not just fake_reg.
runtime/{mercury_string,mercury_types}.h:
Move the typedefs of Char, UnsignedChar, String and ConstString
from mercury_string.h to mercury_types.h to avoid problems with
circular #includes.
runtime/mercury_trace.[ch]:
Revise the interface to MR_trace so that it takes the layout table
of the procedure as an argument. From the layout table, we can get
to the module name, predicate name, arity, mode number, and
determinism of the procedure, so we don't need to pass these any more,
reducing parameter passing overhead. We can also get to information
about where the input and output arguments are. We now use this
information to allow the user to print out the value of the arguments
at the CALL and EXIT ports.
Change the prompt to a less intrusive "mtrace> ".
runtime/mercury_wrapper.[ch]:
Add a new global variable, MR_library_trace_browser. We reserve space
for this variable in mercury_wrapper.c. It will be initialized by the
automatically generated xxx_init.c file to point to the procedure
that the tracer will invoke to let the user browse the values of
variables. This mechanism allows the runtime to maintain its current
ignorance about the contents of the standard library.
util/mkinit.c:
Generate additional code in the xxx_init.c files to fill in the value
of MR_library_trace_browser.
tests/misc_tests/debugger_test.{inp,exp}:
Add a few printing commands into the input for this test case, and
update the expected output.
|
||
|
|
51e8fd3d51 |
Reorganize options for accurate GC, stack tracing and execution tracing.
Estimated hours taken: 20 Reorganize options for accurate GC, stack tracing and execution tracing. The new options are: --stack-trace Turn on stack traces (incomplete, just turns on required stack layouts at the moment). --basic-stack-layout Turns on stack layouts for each procedure, and (currently) each internal label. --agc-stack-layout Turns on stack layouts for accurate gc. implies --basic-stack-layout. --trace-stack-layout Turns on stack layouts for execution tracing. Implies --basic-stack-layout. --alternate-liveness Use what was previously called the "accurate gc" liveness calculation method. Execution tracing needs this too. Add live value information (at entry and exit) for execution tracing. compiler/call_gen.m: compiler/handle_options.m: compiler/live_vars.m: compiler/liveness.m: compiler/mercury_compile.m: compiler/options.m: compiler/unused_args.m: Use new options. Handle new option dependencies. compiler/code_gen.m: Use new options. Generate live value information for entry and exit points if we are doing execution tracing. Add typeinfos to livevals(...) instruction so that value numbering doesn't move them. compiler/continuation_info.m: Add support for collecting information on live values at entry and exit. Change the data structures to accomodate the new data collection needed. compiler/stack_layout.m: Output tracing liveness information if needed. Use new options. |
||
|
|
5013dd9c76 |
Implement nondet pragma C codes.
Estimated hours taken: 40
Implement nondet pragma C codes.
runtime/mercury_stacks.h:
Define a new macro, mkpragmaframe, for use in the implementation
of nondet pragma C codes. This new macro includes space for a
struct with a given sruct tag in the nondet stack frame being created.
compiler/{prog_data.m,hlds_goal.m}:
Revise the representation of pragma C codes, both as the item and
in the HLDS.
compiler/prog_io_pragma.m:
Parse nondet pragma C declarations.
Fix the indentation in some places.
compiler/llds.m:
Include an extra argument in mkframe instructions. This extra argument
gives the details of the C structure (if any) to be included in the
nondet stack frame to be created.
Generalize the LLDS representation of pragma C codes. Instead of a
fixed sequence of <assign from inputs, user c code, assign to outputs>,
let the sequence contain these elements, as well as arbitrary
compiler-generated C code, in any order and possibly with repetitions.
This flexibility is needed for nondet pragma C codes.
Add a field to pragma C codes to say whether they can call Mercury.
Some optimizations can do a better job if they know that a pragma C
code cannot call Mercury.
Add another field to pragma C codes to give the name of the label
they refer to (if any). This is needed to prevent labelopt from
incorrectly optimizing away the label definition.
Add a new alternative to the type pragma_c_decl, to describe the
declaration of the local variable that points to the save struct.
compiler/llds_out.m:
Output mkframe instructions that specify a struct as invoking the new
mkpragmaframe macro, and make sure that the struct is declared just
before the procedure that uses it.
Other minor changes to keep up with the changes to the representation
of pragma C code in the LLDS, and to make the output look a bit nicer.
compiler/pragma_c_gen.m:
Add code to generate code for nondet pragma C codes. Revise the utility
predicates and their data structures a bit to make this possible.
compiler/code_gen.m:
Add code for the necessary special handling of prologs and epilogs
of procedures defined by nondet pragma C codes. The prologs need
to be modified to include a programmer-defined C structure in the
nondet stack frame and to communicate the location of this structure
to the pragma C code, whereas the functionality of the epilog is
taken care of by the pragma C code itself.
compiler/make_hlds.m:
When creating a proc_info for a procedure defined by a pragma C code,
we used to insert unifications between the headvars and the vars of
the pragma C code into the body goal. We now perform substitutions
instead. This removes a factor that would complicate the generation
of code for nondet pragma C codes.
Pass a moduleinfo down the procedures that warn about singletons
(and other basic scope errors). When checking whether to warn about
an argument of a pragma C code not being mentioned in the C code
fragment, we need to know whether the argument is input or output,
since input variables should appear in some code fragments in a
nondet pragma C code and must not appear in others. The
mode_is_{in,out}put checks need the moduleinfo.
(We do not need to check for any variables being mentioned where
they shouldn't be. The C compiler will fail in the presence of any
errors of that type, and since those variables could be referred
to via macros whose definitions we do not see, we couldn't implement
a reliable test anyway.)
compiler/opt_util.m:
Recognize that some sorts of pragma_c codes cannot affect the data
structures that control backtracking. This allows peepholing to
do a better job on code sequences produced for nondet pragma C codes.
Recognize that the C code strings inside some pragma_c codes refer to
other labels in the procedure. This prevents labelopt from incorrectly
optimizing away these labels.
compiler/dupelim.m:
If a label is referred to from within a C code string, then do not
attempt to optimize it away.
compiler/det_analysis.m:
Remove a now incorrect part of an error message.
compiler/*.m:
Minor changes to conform to changes to the HLDS and LLDS data
structures.
|
||
|
|
bb4442ddc1 |
Update copyright dates for 1998.
Estimated hours taken: 0.5 compiler/*.m: Update copyright dates for 1998. |
||
|
|
b4813457c9 |
A rewrite of termination analysis to make it significantly easier to modify,
Estimated hours taken: 60
A rewrite of termination analysis to make it significantly easier to modify,
and to extend its capabilities.
compiler/error_util.m:
A new file containing code that makes it easier to generate
nicely formatted error messages.
compiler/termination.m:
Updates to reflect the changes to the representation of termination
information.
Instead of doing pass 1 on all SCCs and then pass 2 on all SCCs,
we now do both pass 1 and 2 on an SCC before moving on to the next.
Do not insist that either all procedures in an SCC are
compiler-generated or all are user-written, since this need not be
true in the presence of user-defined equality predicates.
Clarify the structure of the code that handles builtins and compiler
generated predicates.
Concentrate all the code for updating module_infos in this module.
Previously it was scattered in several places in several files.
Put all the code for writing out termination information at the
end of the module in a logical order.
compiler/term_traversal.m:
A new file containing code used by both pass 1 and pass 2 to
traverse procedure bodies.
compiler/term_pass1.m:
Use the new traversal module.
Clarify the fixpoint computation on the set of output supplier
arguments.
Remove duplicates from the list of equations given to the solver.
This avoids a det stack overflow in lp.m when doing termination
analysis on options.m.
If an output argument of a predicate makes sense only in the absence
of errors, then return it only in the absence of errors.
compiler/term_pass2.m:
Use the new traversal module. Unlike the previous code, this allows us
to ignore recursive calls with input arguments bigger than the head
if those calls occur after goals that cannot succeed (since those
calls will never be reached).
Implement a better way of doing single argument analysis, which
(unlike the previous version) works in the presence of mutual recursion
and other calls between the recursive call and the start of the clause.
Implement a more precise way of checking for recursions that don't
cause termination problems. We now allow calls from p to q in which
the recursive input supplier arguments can grow, provided that on
any path on which q can call p, directly or indirectly, the recursive
input supplier arguments shrink by a greater amount.
If an output argument of a predicate makes sense only in the absence
of errors, then return it only in the absence of errors.
compiler/term_util.m:
Updates to reflect the changes to the representation of termination
information.
Reorder to put related code together.
Change the interface of several predicates to better reflect the
way they are used.
Add some more utility predicates.
compiler/term_errors.m:
Small changes to the set of possible errors, and major changes in
the way the messages are printed out (we now use error_util).
compiler/options.m:
Change --term-single-arg from being a bool to an int option,
whose value indicates the maximum size of an SCC in which we try
single argument analysis. (Large SCCs can cause single-arg analysis
to require a lot of iterations.)
Add an (int) option that controls the max number of paths
that we are willing to analyze (analyzing too many paths can cause
det stack overflow).
Add an (int) option that controls the max number of causes of
nontermination that we print out.
compiler/hlds_pred.m:
Use two separate slots in the proc_info to hold argument size data
and termination info, instead of the single slot used until now.
The two kinds of information are produced and used separately.
Make the layout of the get and set procedures for proc_infos more
regular, to facilitate later updates.
The procedures proc_info_{,set_}variables did the same work as
proc_info_{,set_}varset. To eliminate potential confusion, I
removed the first set.
compiler/*.m:
Change proc_info_{,set_}variables to proc_info_{,set_}varset.
compiler/hlds_out.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
Change the code to handle the arg size data and the termination
info separately.
compiler/prog_data.m:
Change the internal representation of termination_info pragmas to
hold the arg size data and the termination info separately.
compiler/prog_io_pragma.m:
Change the external representation of termination_info pragmas to
group the arg size data together with the output supplier data,
to which it is logically connected.
compiler/module_qual.m:
compiler/modules.m:
Change the code to accommodate the change to the internal
representation of termination_info pragmas.
compiler/notes/compiler_design.html:
Fix some documentation rot, and clarify some points.
Document termination analysis.
doc/user_guide.texi:
Document --term-single-arg and the new options.
Remove spaces from the ends of lines.
library/bag.m:
Add a new predicate, bag__least_upper_bound.
Fix code that would do the wrong thing if executed by Prolog.
Remove spaces from the ends of lines.
library/list.m:
Add a new predicate, list__take_upto.
library/set{,_ordlist}.m:
Add a new predicate, set{,_ordlist}__count.
tests/term/*:
A bunch of new test cases to test the behaviour of termination
analysis. They are the small benchmark suite from our paper.
tests/Mmakefile:
Enable the new test case directory.
|
||
|
|
7406335105 |
This change implements typeclasses. Included are the necessary changes to
Estimated hours taken: 500 or so This change implements typeclasses. Included are the necessary changes to the compiler, runtime and library. compiler/typecheck.m: Typecheck the constraints on a pred by adding constraints for each call to a pred/func with constraints, and eliminating constraints by applying context reduction. While reducing the constraints, keep track of the proofs so that polymorphism can produce the tyepclass_infos for eliminated constraints. compiler/polymorphism.m: Perform the source-to-source transformation which turns code with typeclass constraints into code without constraints, but with extra "typeclass_info", or "dictionary" parameters. Also, rather than always having a type_info directly for each type variable, sometimes the type_info is hidden inside a typeclass_info. compiler/bytecode*.m: Insert some code to abort if bytecode generation is used when typeclasses are used. compiler/call_gen.m: Generate code for a class_method_call, which forms the body of a class method (by selecting the appropriate proc from the typeclass_info). compiler/dead_proc_elim.m: Don't eliminate class methods if they are potentially used outside the module compiler/hlds_data.m: Define data types to store: - the typeclass definitions - the instances of a class - "constraint_proof". ie. the proofs of redundancy of a constraint. This info is used by polymorphism to construct the typeclass_infos for a constraint. - the "base_tyepclass_info_constant", which is analagous the the base_type_info_constant compiler/hlds_data.m: Define the class_method_call goal. This goal is inserted into the body of class method procs, and is responsible for selecting the appropriate part of the typeclass_info to call. compiler/hlds_data.m: Add the class table and instance table to the module_info. compiler/hlds_out.m: Output info about base_typeclass_infos and class_method_calls compiler/hlds_pred.m: Change the representation of the locations of type_infos from "var" to type_info_locn, which is either a var, or part of a typeclass_info, since now the typeclass_infos contain the type_infos for the type that they constrain. Add constraints to the pred_info. Add constraint_proofs to the pred_info (so that typeclass.m can annotate the pred_info with the reasons that constraints were eliminated, so that polymorphism.m can in turn generate the typeclass_infos for the constraints). Add the "class_method" marker. compiler/lambda.m: A feable attempt at adding class ontexts to lambda expressions, untested and almost certainly not working. compiler/llds_out.m: Output the code addresses for do_*det_class_method, and output appropriately mangled symbol names for base_typeclass_infos. compiler/make_hlds.m: Add constraints to the types on pred and func decls, and add class and instance declarations to the class_table and instance_table respectively. compiler/mercury_compile.m: Add the check_typeclass pass. compiler/mercury_to_mercury.m: Output constraints of pred and funcs, and output typeclass and instance declarations. compiler/module_qual.m: Module qualify typeclass names in pred class contexts, and qualify the typeclass and instance decls themselves. compiler/modules.m: Output typeclass declarations in the short interface too. compiler/prog_data.m: Add the "typeclass" and "instance" items. Define the types to store information about the declarations, including class contexts on pred and func decls. compiler/prog_io.m: Parse constraints on pred and func declarations. compiler/prod_out.m: Output class contexts on pred and func decls. compiler/type_util.m: Add preds to apply a substitution to a class_constraint, and to a list of class constraints. Add type_list_matches_exactly/2. Also add typeclass_info and base_typeclass_info as types which should not be optimised as no_tag types (seeing that we cheat a bit about their representation). compiler/notes/compiler_design.html: Add notes on module qualification of class contexts. Needs expansion to include more stuff on typeclasses. compiler/*.m: Various minor changes. New Files: compiler/base_typeclass_info.m: Produce one base_typeclass_info for each instance declaration. compiler/prog_io_typeclass.m: Parse typeclass and instance declarations. compiler/check_typeclass.m: Check the conformance of an instance declaration to the typeclass declaration, including building up a proof of how superclass constraints are satisfied so that polymorphism.m is able to construct the typeclass_info, including the superclass typeclass_infos. library/mercury_builtin.m: Implement that base_typeclass_info and typeclass_info types, as well as the predicates type_info_from_typeclass_info/3 to extract a type_info from a typeclass_info, and superclass_from_typeclass_info/3 for extracting superclasses. library/ops.m: Add "typeclass" and "instance" as operators. library/string.m: Add a (in, uo) mode for string__length/3. runtime/mercury_ho_call.c: Implement do_call_*det_class_method, which are the pieces of code responsible for extracting the correct code address from the typeclass_info, setting up the arguments correctly, then executing the code. runtime/mercury_type_info.h: Macros for accessing the typeclass_info structure. |
||
|
|
24954933b5 |
Fix some problems Fergus pointed out after reviewing my
Estimated hours taken: 1 Fix some problems Fergus pointed out after reviewing my stack layouts change. compiler/continuation_info.m: Separate library imports from compiler imports. compiler/handle_options.m: compiler/options.m: Add some comments to explain the stack_layouts option. Comment out the documentation of the stack-layouts option, as it is a developer only option. compiler/code_gen.m: compiler/llds.m: compiler/llds_common.m: compiler/llds_out.m: compiler/mercury_compile.m: compiler/optimize.m: Remove llds_proc_id from c_procedure, as pred_proc_id is available instead. |
||
|
|
2a97f96d1a |
Generate stack layouts for accurate garbage collection.
Estimated hours taken: 50 Generate stack layouts for accurate garbage collection. compiler/base_type_layout.m: Change the order of some arguments so that threaded data structures are more often in the final two arguments (allows easy use of higher order predicates). Simplify some code using higher order preds. Export base_type_layout__construct_pseudo_type_info, as stack_layout.m needs to be able to generate pseudo_type_infos too. Fix problems with cell numbers being re-used -- get the next cell number from module_info, and update module_info after processing base_type_layouts. compiler/code_gen.m: Add information about each procedure to the continuation info. Handle new field in c_procedure. compiler/continuation_info.m: Redesign most of this module to deal with labels that are continuation points for multiple calls. Change the order of some arguments so that threaded data structures are in the final two arguments. Cleaned up and documented code. compiler/dupelim.m: compiler/exprn_aux.m: Handle new label_entry data type. compiler/export.m: compiler/opt_debug.m: Handle new label_entry and general data types. compiler/llds_out.m: Add an argument to get_proc_label to control whether a "mercury_" prefix is wanted. Handle new label_entry and general data types. compiler/llds.m: Add a new alternative for data_const - a label_entry. Add a new alternative for data_name - general, which allows any sort of data, with names generated elsewhere. Add the pred_proc_id as a field of c_procedure. compiler/optimize.m: compiler/llds_common.m: compiler/optimize.m: Handle new field in c_procedure. compiler/mercury_compile.m: Generate layout information after code has been generated, and output stack layouts. compiler/notes/compiler_design.html: Document new stack_layout module. compiler/stack_layout.m: New file - generates the LLDS code that defines global constants to hold the stack_layout structures. compiler/options.m: compiler/handle_options.m: Add --stack-layout option which outputs stack layouts. Make accurate gc imply stack_layout. |
||
|
|
6ba2ecb1cf |
Fix a wrong XXX comment about checking for floundering in negations
Estimated hours taken: 0.25 compiler/code_gen.m: Fix a wrong XXX comment about checking for floundering in negations (we already do that). |
||
|
|
248d00e14b |
First implementation of the generation of traces for Opium-style trace
Estimated hours taken: 7 First implementation of the generation of traces for Opium-style trace analysis. In this initial implementation, there are only three ports: call, exit and fail. Later versions will add ports that indicate entry to an arm of a switch or disjunction and to the then or else part of an if-then-else. compiler/options.m: Add a new option, --generate-trace. compiler/handle_options.m: When --generate-trace is on, turn off HLDS->HLDS optimizations that would change the behavior of the trace. compiler/code_info.m: Add a new field in code_into for storing information that is needed when generating trace code. (At the moment, this info is the identity of two stack slots storing the sequence number and depth of the current procedure call.) This info must be in the code_info structure, because it is used not only by code_gen.m but also by call_gen.m, and later by switch_gen.m, disj_gen.m and ite_gen.m. compiler/code_gen.m: Add code to initialize the tracing info in code_info and to add trace statements to procedure prologs and epilogs if --generate-trace is on. compiler/call_gen.m: Clean up the generation of code for calls, merging the three predicates for det, semi and non procedures into one, and factoring out some common code between the generation of code for normal calls and higher order calls. Add code to reset the call depth just before each (normal or higher-order) call if --generate-trace is on. compiler/trace.m: New file responsible for the generation of trace statements in the C file output by the compiler. Code in code_gen.m and call_gen.m calls trace.m; so will code in switch_gen.m, disj_gen.m and ite_gen.m. compiler/mercury_compile.m: When --generate-trace is on, include mercury_trace.h at the top of generated C files. runtime/mercury_trace.[ch]: The new runtime tracing module. The proper version will be written in Rennes, this is just for initial testing. runtime/Mmakefile: Include the new module in the runtime library. doc/user_guide.texi: Document --generate-trace. |
||
|
|
91ca25776f |
This checkin is only cosmetic; it does not modify what the compiler does.
Estimated hours taken: 0.5 This checkin is only cosmetic; it does not modify what the compiler does. code_gen: generate_proc_code was passed an I/O state, but used it only to access the globals. This change passes the globals directly, and dispenses with the unnecessary use of DCG notation. mercury_compile: Pass the globals to generate_proc_code, not the io__state. Look up options in the globals directly, rather than getting them from the io__state. |
||
|
|
f4051b8155 |
Simplify the handling of procedure prologs and epilogs.
Estimated hours taken: 1.5 code_gen.m: Simplify the handling of procedure prologs and epilogs. Whereas we used to have separate predicates for procedures of the three code models, we now use one predicate for prologs for procedures of all code models, and another for epilogs. |
||
|
|
6963f6f611 |
Add an XXX comment saying that we should check for delayed
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, if-then-else, and solutions/2. |
||
|
|
5976f769f7 |
Fix a bug for the case of a higher-order function call in code
Estimated hours taken: 1 Fix a bug for the case of a higher-order function call in code with common sub-expression; mercury 0.7 failed this test, reporting "Software Error: modecheck fails when repeated", due to confusion between h.o. _function_ call and h.o. _predicate_ call. compiler/hlds_goal.m: Add `pred_or_func' field to HLDS higher_order_calls. compiler/modes.m: compiler/modecheck_call.m: compiler/hlds_out.m: compiler/*.m: Add code to handle new field for higher_order_call goals. tests/valid/Mmake: tests/valid/ho_func_call.m: Regression test for the above-mentioned bug. |
||
|
|
02f3e99e41 |
Change the generated code for trailing to match the new trailing interface.
Estimated hours taken: 3 Change the generated code for trailing to match the new trailing interface. compiler/code_gen.m: When generating code for negations, ensure that we generate a discard_ticket instruction to discard the current ticket before failing. compiler/llds.m: compiler/llds_out.m: compiler/code_info.m: Change the `restore_ticket(Rval)' instruction to `reset_ticket(Rval, Reason)', where Reason is one of undo, commit, exception, or gc, as per runtime/mercury_trail.h. A reset with Reason = undo gives the old "restore" behaviour. compiler/frameopt.m: compiler/livemap.m: compiler/llds_common.m: compiler/middle_rec.m: compiler/opt_*.m: compiler/peephole.m: compiler/value_number.m: compiler/vn_*.m: Trivial changes to handle reset_ticket/2 instead of restore_ticket/1. compiler/code_gen.m: compiler/ite_gen.m: compiler/disj_gen.m: Change the places that called code_gen__maybe_discard_ticket to instead call code_gen__maybe_reset_and_discard_ticket(...commit...). |
||
|
|
63ce305441 |
This change is part one of a group of changes to generalize the
current support for trailing. This part just involves changing the names from application-specific (--constraints) to more general ones (--use-trail). scripts/mgnuc.in: compiler/handle_options.m: Rename the `*.cnstr' grades as `*.tr', and use `-DMR_USE_TRAIL' rather than `-DCONSTRAINTS'. compiler/options.m: Rename the `--constraints' option as `--use-trail'. compiler/code_gen.m: compiler/disj_gen.m: compiler/ite_gen.m: compiler/mercury_compile.m: Trivial changes to handle the renaming of the `constraints' option as `use_trail'. |
||
|
|
04b720630b |
Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne". |
||
|
|
d86ea8fb5a |
Fix a couple of bugs with nondet code generation.
Estimated hours taken: 12 Fix a couple of bugs with nondet code generation. compiler/code_info.m: Fix two bugs in code_info__make_known_failure cont. The first bug was that the way it checked for whether a temp frame had been created was incorrect; it was only checking the HaveTempFrame parameter, which was true only if the most recent disjunction had required creation of a temp frame, whereas it needs to check the whole failure continuation stack. The second bug was that it was doing the wrong thing in the case where the current failure continuation was unknown, but a temp frame had been created. It was just clobbering the current redoip, whereas what it needs to do is to create another temp frame. compiler/code_gen.m: compiler/disj_gen.m: compiler/ite_gen.m: Don't pass the HaveTempFrame parameters to and from code_info__make_known_failure_cont. |
||
|
|
62b46f531b |
Fix the insts of live variables in continuation_info.
Estimated hours taken: 1.5 Fix the insts of live variables in continuation_info. They were calculated using the insts before the call instead of after the call. compiler/call_gen.m: compiler/code_info.m: Apply the instmap_delta of the current goal to the instmap when looking up the insts of live variables. Make the hlds_goal_info of the current goal available when generating calls. compiler/code_gen.m: Make the hlds_goal_info of the current goal available when generating calls. |
||
|
|
ab20991f00 |
Changes to clean up the collection of live value information.
Estimated hours taken: 30 Changes to clean up the collection of live value information. Instead of requesting shape numbers and outputting .garb files, we store the needed information for later processing, so we can generate typeinfos for such types later, when we create stack_layout tables. The compiler actually _shrinks_ as a result of this change. compiler/call_gen.m: - Don't request shape numbers for live data, store their types and insts instead. compiler/code_gen.m: - Call continuation_info__add_proc_info for each procedure generated. - Pass around continuation_infos rather than shape_tables. compiler/code_info.m: - Don't request shape numbers for live data, store their types and insts instead. - Provide predicate for converting lvals into live_value_types. - Replace shape_table with continuation_info compiler/continuation_info.m: - New module for storing information about continuations needed for accurate garbage collection. This will later be used to output stack_layout structures. compile/hlds_module.m: - Remove shape_table from module_info, put continuation_info in its place. compiler/llds.m: - Add new live_value_type, which describes a live value (succip, curfr, maxfr, redoip, hp, var(type, inst), unwanted). This will replace the shape_num type. compiler/llds_out.m: - Output live_value_types instead of shape_nums. compiler/make_hlds.m: - Don't add abstract_exports to the shape table - we don't use them anymore. compiler/mercury_compile.m: - Document `join_string_list' and `join_module_list' as their names are a bit cryptic. - Don't output .garb files, don't do abstract exports pass. - Replace handling of shape_table with continuation_info. compiler/garbage_out.m: compiler/shapes.m: - Remove these files, as they are no longer used. runtime/mercury_accurate_gc.h: - Add new file with defintions for accurate gc. |
||
|
|
cbcb23d17b |
Enable --warn-interface-imports by default.
Estimated hours taken: 3
Enable --warn-interface-imports by default. This was turned off while
list and term were defined in mercury_builtin.m, since it caused many
warnings.
Fix all the unused interface imports that have been added since then.
compiler/options.m:
Enable --warn-interface-imports by default.
compiler/module_qual.m:
Fix formatting inconsistencies with module names in warning
messages. (".m" was not appended to module names if there was
only one module).
compiler/*.m:
library/*.m:
tests/invalid/type_loop.m:
tests/warnings/*.m:
Remove usused interface imports, or move them into
implementation (mostly bool, list and std_util).
|
||
|
|
651108aac9 |
Fix a bug introduced by Zoltan's changes to delay flushing
Estimated hours taken: 16 compiler/dense_switch.m: Fix a bug introduced by Zoltan's changes to delay flushing of variables needed on backtracking. The bug was that it was the final code_info after a nondet dense_switch had not unset the top failure continuation. This caused the code generator to generate incorrect C code for the code following the dense switch: the generated C code clobbered the topmost redoip, rather than using a new temp frame. The fix was to ensure that we use the code_info from the end of one of the switch branches (for which we will have called code_info__unset_failure_cont from code_info__branch_end) rather than using the initial code_info and just resetting the live variables. compiler/code_gen.m: compiler/code_info.m: compiler/disj_info.m: compiler/ite_gen.m: Various minor improvements to the comments. tests/general/space.m: Regression test for the above-mentioned bug. |
||
|
|
e3471f333f |
Fix a bug in inlining of polymorphic pragma c_code procedures.
Estimated hours taken: 3 Fix a bug in inlining of polymorphic pragma c_code procedures. The bug was that if the actual argument type has a specific type of say `float', then the C variable for the corresponding formal parameter will be declared to have type `Float', whereas without inlining the argument type would have been polymorphic and so the C variable would have been declared to have type `Word'. Hence we need to keep track of the original argument types, before any inlining or specialization has occurred, and use these original argument types to determine how to declare the C variables, rather than using the actual argument types for this particular specialization. compiler/hlds_goal.m: Add a new field to pragma_c_code goals, holding the original argument types (before any inlining or specialization) of the pragma_c_code procedure. compiler/make_hlds.m: Initialize this field with the declared argument types for the pragma c_code procedure. compiler/polymorphism.m: Update this field to account for the inserted type_info variables. compiler/code_gen.m: Pass this field to pragma_c_gen.m. compiler/pragma_c_gen.m: Use the original argument types field for the pragma variable declarations, rather than looking up the actual types of the arguments. compiler/*.m: Trivial changes to handle new field. compiler/live_vars.m: Comment out some code to avoid a warning about `fail' in the condition of an if-then-else. |
||
|
|
f4d3661ea6 |
Module qualify predicate names attached to incr_sp instructions to
Estimated hours taken: 0.5 Module qualify predicate names attached to incr_sp instructions to improve error reporting in debug grades. compiler/code_gen.m: compiler/code_info.m: compiler/middle_rec.m: Various minor changes to do above. |
||
|
|
d7319104f9 |
Making the types pred_id and proc_id (almost) abstract.
Estimated hours taken: 7
Making the types pred_id and proc_id (almost) abstract.
compiler/code_util.m:
Changed the type of several predicates:
code_util__make_uni_label/4 (arg 3 was int, now proc_id)
code_util__inline_builtin/4 (arg 3 was proc_id, now int)
Added predicate code_util__translate_builtin_2/6.
compiler/hlds_module.m:
Moved invalid_pred_id/1 to hlds_pred.m
compiler/hlds_pred.m:
Types pred_id/0 and proc_id are now abstract.
Added predicates:
hlds_pred__initial_pred_id/1, hlds_pred__initial_proc_id/1,
hlds_pred__next_pred_id/2, hlds_pred__next_proc_id/2,
pred_id_to_int/2, proc_id_to_int/2,
hlds_pred__in_in_unification_proc_id/1
Moved predicate invalid_pred_id/1 (from hlds_module.m).
compiler/*.m:
Miscellaneous minor changes to cast pred/proc_ids to ints
where appropriate.
|
||
|
|
3ec8a17ffc |
Enable the code to treat `__' as an alternative syntax for module
Estimated hours taken: 8 Enable the code to treat `__' as an alternative syntax for module qualification, after fixing various places in the compiler where we use `__' in ways that are incompatible with this. compiler/prog_io.m: compiler/prog_io_goal.m: Uncomment the code to handle `__' as module qualification. compiler/intermod.m: compiler/hlds_module.m: compiler/modecheck_unify.m: Fix bugs in the handling of module qualified higher-order terms. compiler/*.m: s/hlds__/hlds_/g compiler/passes_aux.m: s/process__/process_/g compiler/pragma_c_gen.m: compiler/code_gen.m: s/code_gen__/pragma_c_gen__/ for the predicates defined in pragma_c_gen.m (this ought to have been done when the code was first moved from code_gen.m to pragma_c_gen.m). compiler/llds.m: s/llds__proc_id/llds_proc_id/g The reason for this was to avoid ambiguity between proc_id in hlds_pred.m and llds__proc_id in llds.m. compiler/quantification.m: compiler/make_hlds.m: compiler/mercury_to_c.m: s/goal_vars/quantification__goal_vars/g The reason for this was to avoid ambiguity between goal_vars in quantification.m and goal_util__goal_vars in goal_util.m. compiler/dupelim.m: compiler/optimize.m: s/dupelim__main/dupelim_main/g The reason for this change is that a program can only have one main/2 predicate. compiler/prog_io_dcg.m: Remove the old "temporary hack" to strip off and ignore io__gc_call/1, since the new handling of `__' broke it. It was only useful for optimizing NU-Prolog performance, which we don't care about anymore. compiler/mercury_compile.m: compiler/modules.m: compiler/intermod.m: compiler/prog_io.m: Remove occurrences of io__gc_call. compiler/llds_out.m: compiler/base_type_info.m: Ensure that we properly handle the special hacks in mercury_builtin where predicates from other modules (e.g. term__context_init) are defined in mercury_builtin because they are needed for type_to_term and term_to_type. llds_out.m: don't put `mercury_builtin' in the mangled names for those symbols. base_type_info.m: handle types whose status is "imported" in their own module. |