mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 13:23:53 +00:00
ada4e26dd11e052f8f244cb0af94208f4d329452
193 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0d6c3c9fdf |
Satisfy a request by Peter Ross: give mdb users the ability to specify
Estimated hours taken: 8
Branches: main
Satisfy a request by Peter Ross: give mdb users the ability to specify
exactly which events inside a procedure they want to put breakpoints on.
Amongst other things, this can make checking postconditions easier:
you can now put a conditional breakpoint on only the exit event.
runtime/mercury_stack_layout.h:
Add to the exec trace part of proc layouts fields describing an array
of the label layouts describing the events of the procedure. This is
the most direct way to implement the new functionality. (In theory,
we could search the data structures that map file names and line
numbers to label layouts, but that would be complex, inefficient,
and *error prone*.)
To make room for the new fields, and to prepare for making the
procedure body available to the deep profiler as well (which could
use it to map execution frequencies of calls back to their location
in the procedure body, and thus to things like the frequencies with
which various switch arms are selected), move the procedure body
of the execution-trace-specific part of the proc layout, and to
where the deep profiler could in the future also get at it.
runtime/mercury_goto.h:
Add macros for declaring more than one label layout structure at a
time.
compiler/layout.m:
Implement the changes in mercury_stack_layout.h in the compiler's
data structures as well.
compiler/stack_layout.m:
Conform to the changes in mercury_stack_layout.h.
Turn some tuples into named types.
compiler/layout_out.m:
Conform to the changes in mercury_stack_layout.h.
Add a mechanism to declare the label layouts in the new array before
referring to them, by generalizing some existing code. Make this code
require that the label layouts we refer to via the macros in
mercury_goto.h match the declarations generated by those macros,
i.e. that they have information about variables (if debugging is
enabled, they will).
compiler/opt_debug.m:
Conform to the change to layout.m.
compiler/prog_rep.m:
Make a predicate name more expressive.
trace/mercury_trace_cmd_breakpoint.c:
Implement the new way of using the "break" command, which is
to add a port name after the procedure specification.
Register procedures at the start of the function implementing
the "break" command, instead of "on demand", since all alternatives
eventually do demand it.
Write ambiguity reports wholly to mdb's stdout, instead of partially to
stderr and partially to stdout.
trace/mercury_trace_spy.c:
Print the port and the goal path for breakpoints on specific events.
Make the invocation conditions left-aligned, not right-aligned.
doc/user_guide.texi:
Document the new way of using the "break" command.
NEWS:
Announce the new capability.
tests/queens.{inp,exp,exp2}:
Add tests of the new capability.
tests/breakpoints.{exp,exp}:
tests/lval_desc_array.{exp,exp2}:
Expect the new alignment of invocation conditions.
|
||
|
|
5647714667 |
Make all functions which create strings from characters throw an exception
Estimated hours taken: 15 Branches: main Make all functions which create strings from characters throw an exception or fail if the list of characters contains a null character. This removes a potential source of security vulnerabilities where one part of the program performs checks against the whole of a string passed in by an attacker (processing the string as a list of characters or using `unsafe_index' to look past the null character), but then passes the string to another part of the program or an operating system call that only sees up to the first null character. Even if Mercury stored the length with the string, allowing the creation of strings containing nulls would be a bad idea because it would be too easy to pass a string to foreign code without checking. For examples see: <http://insecure.org/news/P55-07.txt> <http://www.securiteam.com/securitynews/5WP0B1FKKQ.html> <http://www.securityfocus.com/archive/1/445788> <http://www.securityfocus.com/archive/82/368750> <http://secunia.com/advisories/16420/> NEWS: Document the change. library/string.m: Throw an exception if null characters are found in string.from_char_list and string.from_rev_char_list. Add string.from_char_list_semidet and string.from_rev_char_list_semidet which fail rather throwing an exception. This doesn't match the normal naming convention, but string.from_{,rev_}char_list are widely used, so changing their determinism would be a bit too disruptive. Don't allocate an unnecessary extra word for each string created by from_char_list and from_rev_char_list. Explain that to_upper and to_lower only work on un-accented Latin letters. library/lexer.m: Check for invalid characters when reading Mercury strings and quoted names. Improve error messages by skipping to the end of any string or quoted name containing an error. Previously we just stopped processing at the error leaving an unmatched quote. library/io.m: Make io.read_line_as_string and io.read_file_as_string return an error code if the input file contains a null character. Fix an XXX: '\0\' is not recognised as a character constant, but char.det_from_int can be used to make a null character. library/char.m: Explain the workaround for '\0\' not being accepted as a char constant. Explain that to_upper and to_lower only work on un-accented Latin letters. compiler/layout.m: compiler/layout_out.m: compiler/c_util.m: compiler/stack_layout.m: compiler/llds.m: compiler/mlds.m: compiler/ll_backend.*.m: compiler/ml_backend.*.m: Don't pass around strings containing null characters (the string tables for the debugger). This doesn't cause any problems now, but won't work with the accurate garbage collector. Use lists of strings instead, and add the null characters when writing the strings out. tests/hard_coded/null_char.{m,exp}: Change an existing test case to test that creation of a string containing a null throws an exception. tests/hard_coded/null_char.exp2: Deleted because alternative output is no longer needed. tests/invalid/Mmakefile: tests/invalid/null_char.m: tests/invalid/null_char.err_exp: Test error messages for construction of strings containing null characters by the lexer. tests/invalid/unicode{1,2}.err_exp: Update the expected output after the change to the handling of invalid quoted names and strings. |
||
|
|
7b7dabb89a |
Extend this optimization to handle temporaries being both defined in
Estimated hours taken: 12
Branches: main
compiler/use_local_vars.m:
Extend this optimization to handle temporaries being both defined in
and used by foreign_proc_code instructions. This should eliminate
unnecessary accesses to the MR_fake_reg array, and thus speed up
programs that use foreign code a lot, including typeclass- and
tabling-intensive programs, since those features are implemented using
inline foreign code. I/O intensive should also benefit, but not much,
since the cost of the I/O itself overwhelms the cost of the
MR_fake_reg accesses.
Group together the LLDS instructions that are handled similarly.
Factor out some common code.
compiler/opt_util.m:
Allow for the fact that foreign_proc_codes can now refer to
temporaries.
compiler/opt_debug.m:
Print more useful information about foreign_proc_code components.
compiler/prog_data.m:
Rename the types and function symbols of the recently added
foreign_proc attributes to avoid clashing with the keywords
representing them in source code.
Add a new foreign_proc attribute, proc_may_duplicate that governs
whether the body of foreign code is allowed to be duplicated.
compiler/table_gen.m:
Include does_not_affect_liveness among the annotations for the
foreign_proc calls generated by this module. Some of these procedures
affect memory beyond their arguments, but that memory is in tables,
not in unlisted registers.
Allow some of the smaller code fragments generated by this module
to be duplicated.
compiler/inlining.m:
Respect the may_not_duplicate foreign_proc attribute.
compiler/pragma_c_gen.m:
Transmit any annotations about liveness from the HLDS to the LLDS,
since without does_not_affect_liveness annotations use_local_vars.m
cannot optimize foreign_proc_codes.
Transmit any annotations about may_duplicate from the HLDS to the LLDS,
since with them jumpopt can do a better job.
compiler/llds.m:
Use the new foreign_proc attribute instead of a boolean to represent
whether a foreign code fragment may be duplicated.
compiler/simplify.m:
Generate an error message if a may_duplicate or may_not_duplicate
attribute on a foreign_proc conflicts with a no_inline or inline pragma
(respectively) on the predicate it belongs to.
compiler/hlds_pred.m:
Fix some comment rot.
compiler/jumpopt.m:
compiler/livemap.m:
compiler/proc_gen.m:
compiler/trace_gen.m:
Conform to the changes above.
doc/reference_manual.texi:
Document the new foreign_proc attribute.
library/array.m:
library/builtin.m:
library/char.m:
library/dir.m:
library/float.m:
library/int.m:
library/io.m:
library/lexer.m:
library/math.m:
library/private_builtin.m:
library/string.m:
library/version_array.m:
Add does_not_affect_liveness annotations to the C foreign_procs that
deserve them.
configure.in:
Require the installed compiler to support does_not_affect_liveness.
tests/invalid/test_may_duplicate.{m,err_exp}:
Add a new test case to test the error checking code in simplify.m.
tests/invalid/Mmakefile:
Enable the new test case.
|
||
|
|
e53d899ba0 |
Add some foreign_proc attributes that Ben needs for his work on the native
Estimated hours taken: 1 Branches: main Add some foreign_proc attributes that Ben needs for his work on the native garbage collector. One group of attributes (allocates_memory) is intended for optimization: they let the compiler figure out whether it needs to emit code to check the amount of available heap space before the foreign_proc. The second group (registers_roots) is intended for catching errors: foreign procs that do not register (or at least do not *assert* that they register) the roots they may hold. compiler/prog_data.m: Define the attributes. Standardize on spelling "does_not" instead of "doesnt". compiler/prog_io_pragma.m: Parse the attributes. compiler/*.m: Conform to the new spelling of attribute names. doc/reference_manual.texi: Add documentation for the attributes. Since they are for developers only at the moment, leave the documentation commented out. |
||
|
|
ba93a52fe7 |
This diff changes a few types from being defined as equivalent to a pair
Estimated hours taken: 10 Branches: main This diff changes a few types from being defined as equivalent to a pair to being discriminated union types with their own function symbol. This was motivated by an error message (one of many, but the one that broke the camel's back) about "-" being used in an ambiguous manner. It will reduce the number of such messages in the future, and will make compiler data structures easier to inspect in the debugger. The most important type changed by far is hlds_goal, whose function symbol is now "hlds_goal". Second and third in importance are llds.instruction (function symbol "llds_instr") and prog_item.m's item_and_context (function symbol "item_and_context"). There are some others as well. In several places, I rearranged predicates to factor the deconstruction of goals into hlds_goal_expr and hlds_goal_into out of each clause into a single point. In many places, I changed variable names that used "Goal" to refer to just hlds_goal_exprs to use "GoalExpr" instead. I also changed variable names that used "Item" to refer to item_and_contexts to use "ItemAndContext" instead. This should make reading such code less confusing. I renamed some function symbols and predicates to avoid ambiguities. I only made one algorithmic change (at least intentionally). In assertion.m, comparing two goals for equality now ignores goal_infos for all kinds of goals, whereas previously it ignored them for most kinds of goals, but for shorthand goals it was insisting on them being equal. This seemed to me to be a bug. Pete, can you confirm this? |
||
|
|
6de3b102ba |
Add support for deconstructing by functor number rather than name,
Estimated hours taken: 20 Branches: main Add support for deconstructing by functor number rather than name, for use by write_binary. library/deconstruct.m: runtime/mercury_deconstruct.h: runtime/mercury_deconstruct.c: runtime/mercury_ml_expand_body.h: runtime/mercury_ml_deconstruct_body.h: Add predicates deconstruct.functor_number and deconstruct.deconstruct.du, which returns a functor number suitable for use by construct.construct rather than a functor name. library/construct.m: library/term.m: browser/term_rep.m: extras/quickcheck/qcheck.m: tests/valid/agc_unbound_typevars.m: tests/valid/agc_unbound_typevars2.m: Add a function get_functor_lex, which returns the lexicographic functor number given an ordinal functor number. Add equivalence types to make it clearer which ordering is being used by which functor numbers. Remove a C-ism: num_functors now fails rather than returning -1 for types without functors. NEWS: Document the new predicates and functions. runtime/mercury_type_info.h: runtime/mercury_builtin_types.c: runtime/mercury_mcpp.h: compiler/rtti.m: compiler/rtti_out.m: compiler/type_ctor_info.m: compiler/rtti_to_mlds.m: compiler/opt_debug.m: Add a field to MR_TypeCtorInfo which contains a mapping from an ordinal functor number to a lexicographic functor number which can be passed to construct.construct. Bump MR_RTTI_VERSION. tests/hard_coded/expand.m: tests/hard_coded/expand.exp: tests/hard_coded/expand.exp2: tests/hard_coded/construct_test.m: tests/hard_coded/construct_test.exp: tests/hard_coded/construct_test_exist.m: tests/hard_coded/construct_test_exist.exp: Test cases. |
||
|
|
d66ed699a1 |
Add fields to structures representing the C code itself that says whether
Estimated hours taken: 4 Branches: main Add fields to structures representing the C code itself that says whether or not the C code affects the liveness of lvals. This is intended as the basis for future improvements in the optimization of such code. Implement a new foreign_proc attribute that allows programmers to set the value of this field. Eliminate names referring to `pragma c_code' in the LLDS backend in favor of names referring to foreign_procs. compiler/llds.m: Make the changes described above. Consistently put the field containing C code last in the function symbols that contain them. compiler/prog_data.m: Make the changes described above. Rename some other function symbols to avoid ambiguity. compiler/prog_io_pragma.m: Parse the new foreign_proc attribute. doc/reference_manual.texi: Document the new attribute. compiler/pragma_c_gen.m: Rename the main predicates. compiler/opt_util.m: Change some predicates into functions, for more convenient invocation. compiler/livemap.m: Rename the predicates in this module to avoid ambiguity and the need for module qualification. compiler/*.m: Conform to the changes above. |
||
|
|
aa25c53cf6 |
For each attribute of each user event, record the order in which the attribute
Estimated hours taken: 6 Branches: main For each attribute of each user event, record the order in which the attribute it depends on, indirectly as well as directly, should be synthesized. This information allows each attribute to materialized independently of other attributes, a capability we don't yet need, but may need someday. compiler/prog_event.m: Generate this information. compiler/prog_data.m: Make room for the information generated by prog_event. compiler/layout.m: compiler/layout_out.m: Record this information in the layout structures we generate. compiler/opt_debug.m: Conform to the change to layout.m. runtime/mercury_stack_layout.h: Allow the -1 sentinel at the end of the attribute number vector. trace/mercury_trace_vars.c: Make the var_details mdb command (which is for developers only) to print the newly collected information. |
||
|
|
544aae2355 |
Implement synthesized attributes at user events.
Estimated hours taken: 32
Branches: main
Implement synthesized attributes at user events.
doc/user_guide.texi:
Document synthesized attributes.
runtime/mercury_stack_layout.h:
Include information about synthesized attributes in layout structures.
Move the the information about user events that is not specific to a
given event occurrence to a central table of user event specifications
in the module layout structure, to reduce the space overhead, and allow
a future Ducasse style execution monitor to look up information about
each event without having to search all label layout structures (e.g.
when compiling a set of user commands about what to do at each event
into a state machine).
Update the current layout structure version number.
Introduce a named type to represent HLDS variable numbers in layout
structures.
runtime/mercury_types.h:
Add typedefs for the new types in mercury_stack_layout.h.
compiler/prog_data.m:
compiler/prog_event.m:
Record the call that synthesizes synthesized attributes in terms of
attribute numbers (needed by the layout structures) as well as in terms
of attribute names (the user-friendly notation). Record some other
information now needed by the layout structures, e.g. the evaluation
order of synthesized attributes. (Previously, we computed this order
-in reverse- but then threw it away.)
Do not separate out non-synthesized attributes, now that we can handle
even synthesized ones. Return *all* attributes to call_gen.m.
Pass the filename of the event set specification file to the event
spec parser, for use in error messages.
Generate better error messages for semantic errors in event set
specifications.
compiler/continuation_info.m:
compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
Generate the new layout structures, the main changes being the
inclusion of synthesized attributes, and generating information about
event attribute names, types and maybe synthesis calls for all possible
events at once (for the module layout) instead of separately at each
user event occurrence.
In stack_layout.m, rename a couple of predicates to avoid ambiguities.
In layout_out.m, eliminate some repetitions of terms.
compiler/call_gen.m:
When processing event calls, match the supplied attributes against the
list of all attributes, and include information about the synthesized
attributes in the generated layout structures.
compiler/equiv_type.m:
compiler/module_qual.m:
Conform to the change in prog_data.m.
compiler/opt_debug.m:
Conform to the change in layout.m.
compiler/hlds_out.m:
Generate valid Mercury for event calls.
trace/mercury_event_spec.[ch]:
Record the name of the file being parsed, for use in syntax error
messages when the parser is invoked by the compiler.
Add a field for recording the line numbers of attributes, for use in
better error messages.
trace/mercury_event_parser.y:
trace/mercury_event_scanner.l:
Record the line numbers of attributes.
Modify the grammar for event set specifications to allow C-style
comments.
trace/mercury_trace_internal.c
Pass a dummy filename to mercury_event_spec. (The event set
specifications recorded in layout structures should be free of errors,
since the compiler generates them and it checked the original version
for errors.)
trace/mercury_trace_tables.[ch]:
Conform to the new design of layout structures, and record the extra
information now available.
trace/mercury_trace_vars.[ch]:
Record the values of attributes in two passes: first the
non-synthesized attributes, then the synthesized attributes
in the evaluation order recorded in the user event specification.
tests/debugger/synth_attr.{m,inp,exp}:
tests/debugger/synth_attr_spec:
New test case to test the debugger's handling of synthesized
attributes.
tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
Enable the new test case.
tests/invalid/syntax_error_event.{m,err_exp}:
tests/invalid/syntax_error_event_spec:
New test case to test the handling of syntax errors in event set
specifications.
tests/invalid/synth_attr_error.{m,err_exp}:
tests/invalid/synth_attr_error_spec:
New test case to test the handling of semantic errors in event set
specifications.
tests/invalid/Mmakefile:
Enable the new test cases.
|
||
|
|
b3d4ab1760 |
For disjunctions in which all disjuncts are just facts, generate code
Estimated hours taken: 12
Branches: main
For disjunctions in which all disjuncts are just facts, generate code
that does table lookup.
compiler/disj_gen.m:
Implement lookup disjunctions. The new code based on the code in
lookup_switch.m for generating switches in which some some switch arms
are disjunctions. The code we generate is a specialized version
we would generate for such switch arms.
compiler/lookup_switch.m:
compiler/lookup_util.m:
Move some predicates from lookup_switch.m to lookup_util.m, to allow
disj_gen.m to call them also.
Reorder some argument lists to group related arguments together.
Give some predicates more descriptive names.
In lookup_switch.m, improve some comments. In lookup_util.m, avoid
computing ExprnOpts many times.
compiler/switch_gen.m:
Fix some obsolete some comments.
compiler/continuation_info.m:
Provide for a description of the stack slot used by the new code in
disj_gen.m.
compiler/opt_debug.m:
Pass a maybe(proc_label) argument to the predicates that dump rvals
and things that may contain rvals, so that rvals that are code
constants may be printed in the short, user-friendly format
(e.g. local_1, instead of the full, usually very long label name).
This was helpful in debugging the change to disj_gen.m.
Remove the old predicates whose sole purpose was to supply a
proc_label for this purpose (e.g. dump_label_for_proc), since now
even the predicates they are based on (e.g. dump_label) can now
be given a proc_label.
compiler/frameopt.m:
compiler/use_local_vars.m:
compiler/switch_gen.m:
Conform to the change to opt_debug.m.
tests/hard_coded/lookup_disj.{m,exp}:
New test case to test the handling of the lookup tables.
Existing test cases, specifically do_while, nasty_nondet, and
nondet_ite* in general, and pretty_printing in hard_coded,
are already tough tests of the handling of the code generator's
internal data structures (such as the failure stack and the set of
reserved stack slots).
tests/hard_coded/Mmakefile:
Enable the new test case.
|
||
|
|
45fd0daf5a |
Implement some of Mark's wish list for making user events more useful.
Estimated hours taken: 20
Branches: main
Implement some of Mark's wish list for making user events more useful.
1. When executing "print *" in mdb, we used to print both the values of all
attributes and the values of all live variables. Since some attributes'
values were given directly by live variables, this lead to some things being
printed twice. This diff eliminates this duplication.
2. At user events, we now print the name of the event. Whether we print the
other stuff we also print at events (the predicate containing the event,
and its source location) is now controlled by a new mdb command,
"user_event_context".
3. We would like different solvers to be compilable independently of one
another. This means that neither solver's event set should depend on the
existence of the events needed by the other solvers. This diff therefore
eliminates the requirement that all modules of the program be compiled with
the same event set specification. Instead, a program may contain modules
that were compiled with different event sets. Each event set is named;
the new requirement is that different named event sets may coexist in the
program (each being used to compile some modules), but two event sets with
the same name must be identical in all other respects as well (we need this
requirement to prevent inconsistencies arising between different versions of
the same event set).
4. We now generate user events even from modules compiled with --trace shallow.
The problem here is that user events can occur in procedures that do not
get caller events and whose ancestors may not get caller events either.
Yet these procedures must still pass on debugger information such as call
sequence numbers and the call depth to the predicate with the user event.
This diff therefore decouples the generation of code for this basic debugger
infrastructure information from the generation of call events by inventing
two new trace levels, settable by the compiler only (i.e. not from the
command line). The trace level "basic_user" is for procedures containing a
user event whose trace level (in a shallow traced module) would otherwise be
"none". The trace level "basic" is for procedures not containing a user
event but which nevertheless may need to transmit information (e.g. depth)
to a user event. For the foreseeable future, this means that shallow traced
modules containing user events will have some debugging overhead compiled
into *all* their procedures.
runtime/mercury_stack_layout.h:
Add a new field to MR_UserEvent structures, giving the HLDS number of
the variable representing each attribute.
Add a new field to module layout structures, giving the name of the
event set (if any) the module was compiled with.
Add the new trace levels to the MR_TraceLevel type.
Update the current layout structure version number.
runtime/mercury_stack_trace.[ch]:
Allow the printing of the containing predicate's name and/or the
filename/linenumber context to be turned off when printing contexts.
Factor out some of the code involved in this printing.
Give a bunch of variables better names.
Rename a type to get rid of unnecessary underscores.
compiler/prog_data.m:
compiler/prog_event.m:
Include the event set name in the information we have about the event
set.
compiler/simplify.m:
Mark each procedure and each module that contains user events
as containing user events.
Use the same technique to mark each procedure that contains parallel
conjunctions as containing parallel conjunctions, instead of marking
the predicate containing the procedure. (Switch detection may eliminate
arbitrary goals, including parallel conjunctions, from switch arms
that are unreachable due to initial insts, and in any case we want to
handle the procedures of a predicate independently from each other
after mode analysis.)
Also, change the code handling generic calls to switch on the generic
call kind, and factor out some common code.
compiler/hlds_module.m:
compiler/hlds_pred.m:
Provide slots in the proc_info and the module_info for the information
gathered by simplify.
compiler/trace_params.m:
Implement the new trace levels described above. This required changing
the signature of some of the predicates of this module.
compiler/code_info.m:
Record whether the compiler generated any trace events. We need to know
this, because if it did, then we must generate a proc layout structure
for it.
compiler/proc_gen.m:
Act on the information recorded by code_info.m.
Factor out the code for generating the call event and its layout
structure, since the conditions for generating this event have changed.
compiler/continuation_info.m:
compiler/call_gen.m:
For each user event, record the id of the variables corresponding to
each argument of a user event.
compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
Generate the new field (giving the HLDS variable number of each
attribute) in user event structures, and the new field (event set name)
in module layout structures.
Allow the call event's layout structure to be missing. This is needed
for user events in shallow traced modules.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compiler.m:
Rename the option for specifying event sets from --event-spec-file-name
to --event-set-file-name, since it specifies only one event set, not
all events.
compiler/jumpopt.m:
Give some predicates better names.
compiler/dep_par_conj.m:
compiler/deforest.m:
compiler/granularity.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/liveness.m:
compiler/modes.m:
compiler/opt_debug.m:
compiler/optimize.m:
compiler/size_proc.m:
compiler/stack_alloc.m:
compiler/store_alloc.m:
compiler/table_gen.m:
compiler/trace_gen.m:
compiler/typecheck.m:
Conform to the changes above.
doc/mdb_categories:
Mention the new mdb command.
doc/user_guide.texi:
Update the documentation of user events to account for the changes
above.
trace/mercury_event_parser.y:
trace/mercury_event_scanner.l:
Modify the grammar for event set specifications to a name for the
event set.
trace/mercury_event_spec.[ch]:
Instead of recording information about event sets internally
in this module, return a representation of each event set read in
to the callers, for them to do with as they please.
Include the event set name when we print the Mercury term for
compiler/prog_event.m.
trace/mercury_trace.c:
Do not assume that every procedure that contains an event contains a
call event (and hence a call event layout structure), since that
is not true anymore.
trace/mercury_trace_cmd_parameter.[ch]:
Implement the new mdb command "user_event_context".
trace/mercury_trace_cmd_internal.[ch]:
Include "user_event_context" in the list of mdb commands.
Print the user event name at user events. Let the current setting
of the user_event_context mdb command determine what else to print
at such events.
Instead of reading in one event set on initialization, read in
all event sets that occur in the program.
trace/mercury_trace_tables.[ch]:
Allow the gathering of information for more than one event set
from the modules of the program.
trace/mercury_trace_vars.[ch]:
For each attribute value of a user event, record what the HLDS variable
number of the attribute is. When printing all variables at an event,
mark the variable numbers of printed attributes as being printed
already, causing the variable with the same number not to be printed.
Include the name of the variable (if it has one) in the description
of an attribute. Without this, users may wonder why the value of the
variable wasn't printed.
trace/mercury_trace_cmd_browsing.[ch]:
Pass the current setting of the user_event_context mdb command to
runtime/mercury_stack_trace.c when printing the context of an event.
tests/debugger/user_event_shallow.{m,inp,exp}:
New test case to test the new functionality. This test case is the same
as the user_event test case, but it is compiled with shallow tracing,
and its mdb input exercises the user_event_context mdb command.
tests/debugger/user_event_spec:
tests/invalid/invalid_event_spec:
Update these event set spec files by adding an event set name.
tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
Enable the new test case.
tests/debugger/user_event.exp:
Update the expected output of the old user event test case, which now
prints event names, but doesn't print attribute values twice.
tests/debugger/completion.exp:
Expect the new "user_event_context" mdb command in the command list.
tests/debugger/mdb_command_test.inp:
Test the existence of the documentation for the new mdb command.
tests/invalid/Mercury.options:
Conform to the name change of the --event-spec-file-name option.
|
||
|
|
b4c3bb1387 |
Clean up in unused module imports in the Mercury system detected
Estimated hours taken: 3 Branches: main Clean up in unused module imports in the Mercury system detected by --warn-unused-imports. analysis/*.m: browser/*.m: deep_profiler/*.m: compiler/*.m: library/*.m: mdbcomp/*.m: profiler/*.m: slice/*.m: Remove unused module imports. Fix some minor departures from our coding standards. analysis/Mercury.options: browser/Mercury.options: deep_profiler/Mercury.options: compiler/Mercury.options: library/Mercury.options: mdbcomp/Mercury.options: profiler/Mercury.options: slice/Mercury.options: Set --no-warn-unused-imports for those modules that are used as packages or otherwise break --warn-unused-imports, e.g. because they contain predicates with both foreign and Mercury clauses and some of the imports only depend on the latter. |
||
|
|
9ec86d6a6d |
The objective of this diff is to switch from a table of solver events built
Estimated hours taken: 32
Branches: main
The objective of this diff is to switch from a table of solver events built
into the compiler (and eventually the debugger) into a table of events
defined by a file provided by the user to the compiler, which the compiler
then records in the executable for use by the debugger.
The current design, for speed of implementation, uses temporary files parsed
by a bison-generated parser. Since the compiler needs to be able to invoke
the parser even if it is compiled in a non-debug grade, the parser is in
a new library, the eventspec library, that is always linked into the Mercury
compiler and is always linked into any Mercury program with debugging enabled
(but is of course linked only once into a Mercury compiler which has debugging
enabled).
Modify the debugger to give it the ability to print the attributes of
user-defined events (for now, only the non-synthesized attributes).
Implement a new debugger command, "user", which goes to the next user-defined
event.
configure.in:
Require flex and and bison to be available.
doc/user_guide.texi:
Document user defined events and the new debugger capabilities.
doc/mdb_categories:
Include "user" in the list of forward movement commands.
Fix some earlier omissions in that list.
runtime/mercury_stack_layout.h:
Include an event number in the user-defined event structure.
Include a string representing an event set specification in module
layout structures.
runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.[ch]:
runtime/mercury_types.h
Switch from solver events to user events in names.
runtime/mercury_trace_term.[ch]:
Provide a representation of flat terms, for use in representing
the calls that generate synthesized attributes.
Ensure that exported field names have an MR_ prefix.
browser/cterm.m:
Conform to the change to runtime/mercury_trace_term.h.
scripts/c2init.in:
scripts/ml.in:
Include the eventspec library in programs compiled with debugging
enabled.
compiler/Mmakefile:
Include the eventspec library in the compiler.
compiler/options.m:
Add a new option, --event-spec-file-name, that allows the user to
specify the set of user-defined events the program may use.
compiler/handle_options.m:
Set this optimization from an environment variable (which may be
set by the mmc script) if the new option is not explicitly given.
compiler/prog_data.m:
Define the data structures for the compiler's representation of the
event set specification.
Move some definitions around to group them more logically.
compiler/hlds_module.m:
Include the event set specification as a new field in the module_info.
compiler/prog_event.m:
Add the code for invoking the parser in the eventspec library,
and for converting the simple term output by the parser to the
compiler own representation, which contains more information
(to wit, the types of the function attributes) and which has had
a whole bunch of semantic checks done on it (e.g. whether synthesized
attributes depend on themselves or on nonexistent attributes).
Provide a function to generate a canonicalized version of the event
specification file.
compiler/module_qual.m:
compiler/equiv_type.m:
Process event spec specifications as well as items, to module qualify
the names of the types of event arguments, and expanding out
equivalence types.
In equiv_type.m, rename some variables to make clear what kind of info
they represent.
compiler/mercury_compile.m:
Process the event set specification file if one has been selected:
read it in, module qualify it, expand its equivalence types, and add
to the module_info.
compiler/compile_target_code.m:
Include the event_spec library when linking debuggable executables.
compiler/call_gen.m:
compiler/continuation_info.m:
compiler/trace_gen.m:
compiler/trace_params.m:
mdbcomp/prim_data.m:
mdbcomp/trace_counts.m:
runtime/mercury_goto.h:
Generate user-defined events instead of solver events.
compiler/layout.m:
compiler/layout_out.m:
compiler/stack_layout.m:
Include a canonicalized version of the event specification file
in the module layout if the module has any user-defined events.
compiler/code_info.m:
compiler/llds_out.m:
compiler/modes.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/typecheck.m:
Conform to the changes above.
compiler/passes_aux.m:
Rename a predicate to avoid an ambiguity.
trace/Mmakefile:
Add the definition and rules required to build the eventspec library.
trace/mercury_event_scanner.l:
trace/mercury_event_parser.y:
A scanner and a parser for reading in event spec specifications.
trace/mercury_event_spec_missing.h:
Provide the declarations that should be (but aren't) provided by
flex and bison.
trace/mercury_event_spec.[ch]:
The main module of the eventspec library. Provides functions to read
in event set specifications from a file, and to write them out as a
Mercury term in the form needed by the compiler.
trace/mercury_trace_tables.c:
If the module layouts being registered include event set
specifications, then check their consistency. Make the specification
and the consistency indication available to other modules.
trace/mercury_trace_internal.c:
During initialization, if the modules contain a consistent set of event
set specifications, then read that specification into the debugger.
(We don't yet make use of this information.)
Add an extra mdb command, "user", which goes forward to the next
user-defined event.
trace/mercury_trace.[ch]:
trace/mercury_trace_cmd_forward.[ch]:
Implement the new mdb command.
trace/mercury_trace_vars.[ch]:
For user-defined events, include the attributes' values among the
values that can be printed or browsed.
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_declarative.c:
Minor changes.
scripts/scripts/prepare_tmp_dir_grade_part:
Copy the .y and .l files to the tmp dir we use for installs.
tools/bootcheck:
Copy the .y and .l files of the trace directory to stage 2.
tools/lmc.in:
Include the eventspec library when linking debuggable executables.
tests/debugger/user_event.{m,inp,exp}:
tests/debugger/user_event_spec:
New test case to test the new functionality.
tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
Enable the new test case.
tests/debugger/completion.exp:
Expect the new "user" mdb command in the completion output.
|
||
|
|
ecf1ee3117 |
Add a mechanism for growing the stacks on demand by adding new segments
Estimated hours taken: 20 Branches: main Add a mechanism for growing the stacks on demand by adding new segments to them. You can ask for the new mechanism via a new grade component, stseg (short for "stack segments"). The mechanism works by adding a test to each increment of a stack pointer (sp or maxfr). If the test indicates that we are about to run out of stack, we allocate a new stack segment, allocate a placeholder frame on the new segment, and then allocate the frame we wanted in the first place on top of the placeholder. We also override succip to make it point code that will (1) release the new segment when the newly created stack frame returns, and then (2) go to the place indicated by the original, overridden succip. For leaf procedures on the det stack, we optimize away the check of the stack pointer. We can do this because we reserve some space on each stack for the use of such stack frames. My intention is that doc/user_guide.texi and NEWS will be updated once we have used the feature ourselves for a while and it seems to be stable. runtime/mercury_grade.h: Add the new grade component. runtime/mercury_conf_param.h: Document the new grade component, and the option used to debug stack segments. runtime/mercury_context.[ch]: Add new fields to contexts to hold the list of previous segments of the det and nondet stacks. runtime/mercury_memory_zones.[ch]: Include a threshold in all zones, for use in stack segments. Set it when a zone is allocated. Restore the previous #ifdef'd out function MR_unget_zone, for use when freeing stack segments execution has fallen out of. runtime/mercury_debug.[ch]: When printing the offsets of pointers into the det and nondet stacks, print the number of the segment the pointer points into (unless it is the first, in which case we suppress this in the interest of brevity and simplicity). Make all the functions in this module take a FILE * as an input argument; don't print to stdout by default. runtime/mercury_stacks.[ch]: Modify the macros that allocate stack frames to invoke the code for adding new stack segments when we are about to run out of stack. Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. Conform to the changes in mercury_debug.c. runtime/mercury_stack_trace.c: When traversing the stack, step over the placeholder stack frames at the bottoms of stack segments. Conform to the changes in mercury_debug.c. runtime/mercury_wrapper.[ch]: Make the default stack size small in grades that support stack segments. Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. Conform to the changes in mercury_debug.c. runtime/mercury_memory.c: Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. runtime/mercury_engine.[ch]: runtime/mercury_overflow.h: Standardize on "nondet" over "nond" as the abbreviation referring to the nondet stack. Convert these files to four-space indentation. runtime/mercury_minimal_model.c: trace/mercury_trace.c: trace/mercury_trace_util.c: Conform to the changes in mercury_debug.c. compiler/options.m: Add the new grade option for stack segments. compiler/compile_target_code.m: compiler/handle_options.m: Add the new grade component, and handle its exclusions with other grade components and optimizations. compiler/llds.m: Extend the incr_sp instruction to record whether the stack frame is for a leaf procedure. compiler/llds_out.m: Output the extended incr_sp instruction. compiler/proc_gen.m: Fill in the extra slot in incr_sp instructions. compiler/goal_util.m: Provide a predicate for testing whether a procedure body is a leaf. compiler/delay_slot.m: compiler/dupelim.m: compiler/dupproc.m: compiler/exprn_aux.m: compiler/frameopt.m: compiler/global_data.m: compiler/jumpopt.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/peephole.m: compiler/reassign.m: compiler/use_local_vars.m: Conform to the change in llds.m. scripts/canonicate_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: scripts/final_grade_options.sh-subr: scripts/mgnuc.in: Handle the new grade component. Convert parse_grade_options.sh-subr to four-space indentation. Mmake.workspace: Fix an old bug that prevented bootcheck from working in the new grade: when computing the gc grade, use the workspace's version of ml (which in this case understands the new grade components), rather than the installed ml (which does not). (This was a devil to track down, because neither make --debug nor strace on make revealed how the installed ml was being invoked, and there was no explicit invocation in the Makefile either; the error message appeared to come out of thin air just before the completion of the stage 2 library. It turned out the invocation happened implicitly, as a result of expanding a make variable.) |
||
|
|
e21193c283 |
Rename a bunch of predicates and function symbols to eliminate
Estimated hours taken: 6 Branches: main browser/*.m: compiler/*.m: Rename a bunch of predicates and function symbols to eliminate ambiguities. The only real change is factoring out some common code in the mlds and llds code generators, replacing them with single definitions in switch_util.m. |
||
|
|
9eed887d33 |
This diff is the second step in implementing trace events.
Estimated hours taken: 24 Branches: main This diff is the second step in implementing trace events. It modifies label layouts to include room for solver-event-specific information, and modifies the compiler to generate this information. Modifications to the debugger to use this information, user-level documentation and test cases will come later. runtime/mercury_stack_layout.h: Modify label layouts to allow them to hold information about solver events. Modify the macros creating label layouts to include a null pointer as the value of the label layout's solver event field. For each such macro, add a version that puts a pointer to the label's solver event structure in that field. Modify the definition of the MR_Long_Lval type to allow the representation of constants, since without this capability solver events would often need to be preceded by code to put constant values (e.g. solver ids) into lvals. To make it easier to locate all the places where MR_Long_Lvals are used (which need to be updated), change the type MR_Long_Lval from a synonym for an int to a structure containing an int. runtime/mercury_types.h: Add the typedefs now required for mercury_stack_layout.h. runtime/mercury_goto.h: Add a macro needed by mercury_stack_layout.h. runtime/mercury_grade.h: Change the binary compatibility version number for debug grades, due to the change to label layouts. runtime/mercury_layout_util.c: Update the functions interpreting MR_Long_Lvals to conform to the change in mercury_stack_layout.h. runtime/mercury_deep_profiling_hand.h: Fix a bug, possibly the bug preventing us from bootchecking in deep profiling grades: stack slot numbers of ProcStatic structures are supposed to be plain integers, not MR_Long_Lvals. runtime/mercury_stack_trace.c: library/exception.m: trace/mercury_trace.c: Conform the change in MR_Long_Lval. runtime/mercury_trace_base.[ch]: Add a new port: the solver event port. Add a macro and a function for solver events: MR_SOLVER_EVENT and MR_solver_trace. For now, they do the same thing as MR_EVENT and MR_trace, but in future, they can do something else (e.g. generate information for a visualization tool). mdbcomp/prim_data.m: Add a new port: the solver event port. Rename all ports to eliminate clashes with language keywords such as "call". mdbcmp/trace_counts.m: browser/declarative_execution.m: slice/mcov.m: compiler/tupling.m: Conform to the change in port names, and to the addition of the new port. compiler/trace_params.m: Conform to the change in port names, and to the addition of the new port. Rename some function symbols to avoid some ambiguities. trace/mercury_trace_declarative.c: Ignore the solver port when building the annotated trace, since it doesn't fit into it. compiler/prog_event.m: Extend the representation of events to include names for the event attributes. compiler/call_gen.m: Implement event goals. The implementation consists of a call to MR_SOLVER_EVENT with a layout structure whose solver event field points to a solver event structure giving the event goal's arguments. Rename some function symbols to avoid some ambiguities. compiler/trace_gen.m: Add a predicate for generating solver events. Conform to the change in port names. Rename some function symbols to avoid some ambiguities. compiler/code_info.m: When recording trace layout information for a label, take an extra argument describing the label layout's associated solver event, if any. compiler/continuation_info.m: Extend the first representation of label layouts to include room for solver events. compiler/stack_layout.m: Convert the representation of solver events in continuation_info.m's data structure to the data structure required by layout_out.m. Conform to the changes in MR_Long_Lvals. compiler/layout.m: Extend the compiler's internal representation of the contents of label layout structures to accommodate the optional solver event field. compiler/layout_out.m: Generate the extended label layout structures, using the new macros in mercury_stack_layout.h if necessary. Conform to the change in the MR_Long_Lval type. Conform to the change in port names. Rename some function symbols to avoid some ambiguities. compiler/global_data.m: Modify rval_type_as_arg to require only the value of the relevant option, not a package of such options. This is for the new code in stack_layout.m. compiler/var_locn.m: Conform to the change in global_data.m. compiler/llds_out.m: Conform to the change in continuation_info.m. Delete this module's unused definition of rval_type_as_arg. compiler/opt_debug.m: Conform to the change in continuation_info.m. |
||
|
|
712027f307 |
This patch changes the parallel execution mechanism in the low level backend.
Estimated hours taken: 100 Branches: main This patch changes the parallel execution mechanism in the low level backend. The main idea is that, even in programs with only moderate parallelism, we won't have enough processors to exploit it all. We should try to reduce the cost in the common case, i.e. when a parallel conjunction gets executed sequentially. This patch does two things along those lines: (1) Instead of unconditionally executing all parallel conjuncts (but the last) in separate Mercury contexts, we allow a context to continue execution of the next conjunct of a parallel conjunction if it has just finished executing the previous conjunct. This saves on allocating unnecessary contexts, which can be a big reduction in memory usage. We also try to execute conjuncts left-to-right so as to minimise the need to suspend contexts when there are dependencies between conjuncts. (2) Conjuncts that *are* executed in parallel still need separate contexts. We used to pass variable bindings to those conjuncts by flushing input variable values to stack slots and copying the procedure's stack frame to the new context. When the conjunct finished, we would copy new variable bindings back to stack slots in the original context. What happens now is that we don't do any copying back and forth. We introduce a new abstract machine register `parent_sp' which points to the location of the stack pointer at the time that a parallel conjunction began. In parallel conjuncts we refer to all stack slots via the `parent_sp' pointer, since we could be running on a different context altogether and `sp' would be pointing into a new detstack. Since parallel conjuncts now share the procedure's stack frame, we have to allocate stack slots such that all parallel conjuncts in a procedure that could be executing simultaneously have distinct sets of stack slots. We currently use the simplest possible strategy, i.e. don't allow variables in parallel conjuncts to reuse stack slots. Note: in effect parent_sp is a frame pointer which is only set for and used by the code of parallel conjuncts. We don't call it a frame pointer as it can be confused with "frame variables" which have to do with the nondet stack. compiler/code_info.m: Add functionality to keep track of how deep inside of nested parallel conjunctions the code generator is. Add functionality to acquire and release "persistent" temporary stack slots. Unlike normal temporary stack slots, these don't get implicitly released when the code generator's location-dependent state is reset. Conform to additions of `parent_sp' and parent stack variables. compiler/exprn_aux.m: Generalise the `substitute_lval_in_*' predicates by `transform_lval_in_*' predicates. Instead of performing a fixed substitution, these take a higher order predicate which performs some operation on each lval. Redefine the substitution predicates in terms of the transformation predicates. Conform to changes in `fork', `join_and_terminate' and `join_and_continue' instructions. Conform to additions of `parent_sp' and parent stack variables. Remove `substitute_rval_in_args' and `substitute_rval_in_arg' which were unused. compiler/live_vars.m: Introduce a new type `parallel_stackvars' which is threaded through `build_live_sets_in_goal'. We accumulate the sets of variables which are assigned stack slots in each parallel conjunct. At the end of processing a parallel conjunction, use this information to force variables which are assigned stack slots to have distinct slots. compiler/llds.m: Change the semantics of the `fork' instruction. It now takes a single argument: the label of the next conjunct after the current one. The instruction now "sparks" the next conjunct to be run, either in a different context (possibly in parallel, on another Mercury engine) or is queued to be executed in the current context after the current conjunct is finished. Change the semantics of the `join_and_continue' instruction. This instruction now serves to end all parallel conjuncts, not just the last one in a parallel conjunction. Remove the `join_and_terminate' instruction (no longer used). Add the new abstract machine register `parent_sp'. Introduce "parent stack slots", which are similar to normal stack slots but relative to the `parent_sp' register. compiler/par_conj_gen.m: Change the code generated for parallel conjunctions. That is: - use the new `fork' instruction at the beginning of a parallel conjunct; - use the `join_and_continue' instruction at the end of all parallel conjuncts; - keep track of how deep the code generator currently is in parallel conjunctions; - set and restore the `parent_sp' register when entering a non-nested parallel conjunction; - after generating the code of a parallel conjunct, replace all references to stack slots by parent stack slots; - remove code to copy back output variables when a parallel conjunct finishes. Update some comments. runtime/mercury_context.c: runtime/mercury_context.h: Add the type `MR_Spark'. Sparks are allocated on the heap and contain enough information to begin execution of a single parallel conjunct. Add globals `MR_spark_queue_head' and `MR_spark_queue_tail'. These are pointers to the start and end of a global queue of sparks. Idle engines can pick up work from this queue in the same way that they can pick up work from the global context queue (the "run queue"). Add new fields to the MR_Context structure. `MR_ctxt_parent_sp' is a saved copy of the `parent_sp' register for when the context is suspended. `MR_ctxt_spark_stack' is a stack of sparks that we decided not to put on the global spark queue. Update `MR_load_context' and `MR_save_context' to save and restore `MR_ctxt_parent_sp'. Add the counters `MR_num_idle_engines' and `MR_num_outstanding_contexts_and_sparks'. These are used to decide, when a `fork' instruction is reached, whether a spark should be put on the global spark queue (with potential for parallelism but also more overhead) or on the calling context's spark stack (no parallelism and less overhead). Rename `MR_init_context' to `MR_init_context_maybe_generator'. When initialising contexts, don't reset redzones of already allocated stacks. It seems to be unnecessary (and the reset implementation is buggy anyway, though it's fine on Linux). Rename `MR_schedule' to `MR_schedule_context'. Add new functions `MR_schedule_spark_globally' and `MR_schedule_spark_locally'. In `MR_do_runnext', add code for idle engines to get work from the global spark queue. Resuming contexts are prioritised over sparks. Rename `MR_fork_new_context' to `MR_fork_new_child'. Change the definitions of `MR_fork_new_child' and `MR_join_and_continue' as per the new behaviour of the `fork' and `join_and_continue' instructions. Delete `MR_join_and_terminate'. Add a new field `MR_st_orig_context' to the MR_SyncTerm structure to record which context originated the parallel conjunction instance represented by a MR_SyncTerm instance, and update `MR_init_sync_term'. This is needed by the new behaviour of `MR_join_and_continue'. Update some comments. runtime/mercury_engine.h: runtime/mercury_regs.c: runtime/mercury_regs.h: runtime/mercury_stacks.h: Add the abstract machine register `parent_sp' and code to copy it to and from the fake_reg array. Add a macro `MR_parent_sv' to access stack slots via `parent_sp'. Add `MR_eng_parent_sp' to the MercuryEngine structure. runtime/mercury_wrapper.c: runtime/mercury_wrapper.h: Add Mercury runtime option `--max-contexts-per-thread' which is saved in the global variable `MR_max_contexts_per_thread'. The number `MR_max_outstanding_contexts' is derived from this. It sets a soft limit on the number of sparks we put in the global spark queue, relative to the number of threads we are running. We don't want to put too many sparks on the global queue if there are plenty of ready contexts or sparks already on the global queues, as they are likely to result in new contexts being allocated. When initially creating worker engines, wait until all the worker engines have acknowledged that they are idle before continuing. This is mainly so programs (especially benchmarks and test cases) with only a few fork instructions near the beginning of the program don't execute the forks before any worker engines are ready, resulting in no parallelism. runtime/mercury_engine.c: runtime/mercury_thread.c: Don't allocate a context at the time a Mercury engine is created. An engine only needs a new context when it is about to pick up a spark. configure.in: compiler/options.m: scripts/Mercury.config.in: Update to reflect the extra field in MR_SyncTerm. Add the option `--sync-term-size' and actually make use the result of the sync term size calculated during configuration. compiler/code_util.m: compiler/continuation_info.m: compiler/dupelim.m: compiler/dupproc.m: compiler/global_data.m: compiler/hlds_llds.m: compiler/jumpopt.m: compiler/livemap.m: compiler/llds_out.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/reassign.m: compiler/stack_layout.m: compiler/use_local_vars.m: compiler/var_locn.m: Conform to changes in `fork', `join_and_terminate' and `join_and_continue' instructions. Conform to additions of `parent_sp' and parent stack variables. XXX not sure about the changes in stack_layout.m library/par_builtin.m: Conform to changes in the runtime system. |
||
|
|
f9cac21e3e |
Get rid of a bunch more ambiguities by renaming predicates, mostly
Estimated hours taken: 8
Branches: main
Get rid of a bunch more ambiguities by renaming predicates, mostly
in polymorphism.m, {abstract,build,ordering}_mode_constraints.m, prog_type.m,
and opt_debug.m in the compiler directory and term_io.m, term.m, parser.m,
and string.m in the library.
In some cases, when the library and the compiler defined the same predicate
with the same code, delete the compiler's copy and give it access to the
library's definition by exporting the relevant predicate (in the undocumented
part of the library module's interface).
NEWS:
Mention that the names of some library functions have changed.
library/*.m:
compiler/*.m:
mdbcomp/*.m:
browser/*.m:
Make the changes mentioned above, and conform to them.
test/general/string_test.m:
test/hard_coded/string_strip.m:
test/hard_coded/string_strip.exp:
Conform to the above changes.
|
||
|
|
6a6cfaf18e |
Add options to perform code generation and liveness detection for the low-level
Estimated hours taken: 30 Branches: main Add options to perform code generation and liveness detection for the low-level backend using parallel threads. These are enabled with `--parallel-code-gen' and `--parallel-liveness' options respectively, for compilers built in grades supporting multiple engines, and running with multiple engines enabled. Currently we only attempt to use two threads. compiler/global_data.m: Use a new type `type_num' instead of `int' everywhere for common cell type numbers. Add a function `bump_type_num_counter' which takes a global_data structure and returns a global_data with the common cell type number counter incremented by some amount. This is to allow multiple threads to add new types to their own copies of the global_data structure without type numbers clashing when we try to merge them later. Add a predicate `merge_global_datas' which takes two global_datas and merges their static cell information. Add a predicate `remap_static_cell_references' which updates code using the second global_data structure (passed to merge_global_datas) to refer to static cells in the combined global_data structure. compiler/layout_out.m: compiler/llds.m: compiler/llds_out.m: compiler/opt_debug.m: Conform to the type change of common cell type numbers. compiler/options.m: doc/user_guide.texi: Add `--parallel-liveness' and `--parallel-code-gen' options. The documentation is commented out for now. compiler/handle_options.m: Make the `--parallel-liveness' and `--parallel-code-gen' options imply `--no-trad-passes'. compiler/liveness.m: Add parallel liveness detection support. The sequential liveness detection code took I/O states in order to output debugging information; make it take values of a typeclass `debug_liveness_io' instead, and make io.state an instance of the typeclass. In the parallel case we pass dummy values that don't try to output debugging information. compiler/mercury_compile.m: Run parallel liveness detection if it is enabled and liveness debugging is not enabled (see above). compiler/proc_gen.m: Add parallel code generation support. Run it if selected by the user and `--very-verbose' is not enabled (as that would require I/O). |
||
|
|
00741b0162 |
This diff contains no algorithmic changes.
Estimated hours taken: 6 Branches: main This diff contains no algorithmic changes. It merely renames apart a bunch more function symbols to reduce ambiguity. After this diff, the summary line from the mdb command "ambiguity -f" is Total: 351 names used 975 times, maximum 31, average: 2.78 browser/*.m: compiler/*.m: Rename function symbols to eliminate ambiguities. tests/debugger/declarative/dependency.exp: tests/debugger/declarative/dependency2.exp: Update the expected out where some internal function symbol names appear in the output of the debugger. (This output is meant for implementors only.) |
||
|
|
2b2f3d3cbe |
This diff contains no algorithmic changes.
Estimated hours taken: 8 Branches: main This diff contains no algorithmic changes. It merely renames apart a bunch of function symbols to reduce ambiguity. Basically I went through prog_data.m, prog_item.m, hlds_data.m, hlds_goal.m and hlds_pred.m looking for type definitions containing function symbol names that were either language "keywords" (e.g. "terminates", which is an annotation on foreign_procs), used with slightly different meanings in several types (e.g. "sym"), or both (e.g. "call"). When I found such type definitions, I changed the names of the function symbols, usually by adding a prefix or suffix indicating the type to all function symbols of the type. For example, the old function symbol "foreign_proc" in type "pragma_type" is now named "pragma_foreign_proc", and the names of all other function symbols in that type also start with "pragma_". All of this should yield simpler compiler error messages when we make mistakes, and will make it more likely that looking up a function symbol using a tags file will take you to the actual definition of the relevant instance of that function symbol. However, the most important benefit is the increase in the readability of unfamiliar code; the reader won't have to emulate the compiler's type ambiguity resolution algorithm (which in many cases used to require distinguishing between f/14 and f/15 by counting the arguments, e.g. for "pred_or_func"). compiler/prog_data.m: compiler/prog_item.m: compiler/hlds_data.m: compiler/hlds_goal.m: compiler/hlds_pred.m: Rename function symbols as explained above. compiler/*.m: Conform to the function symbol renames. In some cases, rename other function symbols as well. Minor style fixes, e.g. replace if-then-elses with switches, or simple det predicates with functions. |
||
|
|
4924dfb1c9 |
One of Hans Boehm's papers says that heap cells allocated by GC_MALLOC_ATOMIC
Estimated hours taken: 5 Branches: main One of Hans Boehm's papers says that heap cells allocated by GC_MALLOC_ATOMIC are grouped together into pages, and these pages aren't scanned during the sweep phase of the garbage collector. I therefore modified the compiler to use GC_MALLOC_ATOMIC instead of GC_MALLOC whereever possible, i.e when the cell being allocated is guaranteed not to have any pointer to GCable memory inside it. My first benchmarking run showed a speedup of 4.5% in asm_fast.gc: EXTRA_MCFLAGS = --use-atomic-cells mercury_compile.01 average of 6 with ignore=1 18.30 EXTRA_MCFLAGS = --no-use-atomic-cells mercury_compile.02 average of 6 with ignore=1 19.17 However, later benchmarks, after the upgrade to version 7.0 of boehm_gc, show a less favourable and more mixed picture, with e.g. a 4% speedup in hlc.gc at -O3, a 3% slowdown in asm_fast.gc at -O4, and little effect otherwise: EXTRA_MCFLAGS = -O1 --use-atomic-cells GRADE = asm_fast.gc mercury_compile.01 average of 6 with ignore=1 23.30 EXTRA_MCFLAGS = -O1 --no-use-atomic-cells GRADE = asm_fast.gc mercury_compile.02 average of 6 with ignore=1 23.28 EXTRA_MCFLAGS = -O2 --use-atomic-cells GRADE = asm_fast.gc mercury_compile.03 average of 6 with ignore=1 18.51 EXTRA_MCFLAGS = -O2 --no-use-atomic-cells GRADE = asm_fast.gc mercury_compile.04 average of 6 with ignore=1 18.66 EXTRA_MCFLAGS = -O3 --use-atomic-cells GRADE = asm_fast.gc mercury_compile.05 average of 6 with ignore=1 18.44 EXTRA_MCFLAGS = -O3 --no-use-atomic-cells GRADE = asm_fast.gc mercury_compile.06 average of 6 with ignore=1 18.48 EXTRA_MCFLAGS = -O4 --use-atomic-cells GRADE = asm_fast.gc mercury_compile.07 average of 6 with ignore=1 18.28 EXTRA_MCFLAGS = -O4 --no-use-atomic-cells GRADE = asm_fast.gc mercury_compile.08 average of 6 with ignore=1 17.70 EXTRA_MCFLAGS = -O1 --use-atomic-cells GRADE = hlc.gc mercury_compile.09 average of 6 with ignore=1 24.78 EXTRA_MCFLAGS = -O1 --no-use-atomic-cells GRADE = hlc.gc mercury_compile.10 average of 6 with ignore=1 24.69 EXTRA_MCFLAGS = -O2 --use-atomic-cells GRADE = hlc.gc mercury_compile.11 average of 6 with ignore=1 19.36 EXTRA_MCFLAGS = -O2 --no-use-atomic-cells GRADE = hlc.gc mercury_compile.12 average of 6 with ignore=1 19.26 EXTRA_MCFLAGS = -O3 --use-atomic-cells GRADE = hlc.gc mercury_compile.13 average of 6 with ignore=1 18.64 EXTRA_MCFLAGS = -O3 --no-use-atomic-cells GRADE = hlc.gc mercury_compile.14 average of 6 with ignore=1 19.38 EXTRA_MCFLAGS = -O4 --use-atomic-cells GRADE = hlc.gc mercury_compile.15 average of 6 with ignore=1 19.39 EXTRA_MCFLAGS = -O4 --no-use-atomic-cells GRADE = hlc.gc mercury_compile.16 average of 6 with ignore=1 19.41 runtime/mercury_heap.h: Define atomic equivalents of the few heap allocation macros that didn't already have one. These macros are used by the LLDS backend. runtime/mercury.h: Define an atomic equivalent of the MR_new_object macro. These macros are used by the MLDS backend. Use MR_new_object_atomic instead of MR_new_object to box floats. compiler/hlds_data.m: compiler/llds.m: compiler/mlds.m: Modify the representations of the heap allocations constructs to include a flag that says whether we should use the atomic variants of the heap allocation macros. compiler/llds_out.m: compiler/mlds_to_c.m: Respect this extract flag when emitting C code. In mlds_to_c.m, also add some white space that makes the code easier for humans to read. compiler/type_util.m: Add a mechanism for finding out whether we can put a value of a given type into an atomic cell. Put the definitions of functions and predicates in this module in the same order as their declarations. Turn some predicates into functions. Change the argument order of some predicates to conform to our usual conventions. compiler/unify_gen.m: compiler/ml_unify_gen.m: Use the new mechanism in type_util.m to generate code that creates atomic heap cells if this is possible and is requested. compiler/code_info.m: compiler/var_locn.m: Act on the information provided by unify_gen.m. compiler/options.m: doc/user_guide.texi: Add an option to control whether the compiler should try to use atomic cells. compiler/dupelim.m: compiler/dupproc.m: compiler/exprn_aux.m: compiler/higher_order.m: compiler/jumpopt.m: compiler/livemap.m: compiler/middle_rec.m: compiler/ml_code_util.m: compiler/ml_elim_nested.m: compiler/ml_optimize.m: compiler/ml_util.m: compiler/mlds_to_gcc.m: compiler/mlds_to_il.m: compiler/mlds_to_java.m: compiler/modecheck_unify.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/par_conj_gen.m: compiler/polymorphism.m: compiler/reassign.m: compiler/size_prof.m: compiler/structure_sharing.domain.m: compiler/use_local_vars.m: Minor diffs to conform to the changes above. compiler/structure_reuse.direct.choose_reuse.m: Add an XXX comment about the interaction of the new capability with structure reuse. |
||
|
|
469f1dc09b |
This diff contains no algorithmic changes.
Estimated hours taken: 1.5 Branches: main This diff contains no algorithmic changes. compiler/llds.m: compiler/mlds.m: Rename some function symbols and field names to avoid ambiguities with respect to language keywords. compiler/*.m: Conform to the changes in llds.m and mlds.m. |
||
|
|
9d23d8e2e7 |
Implement the trace goal construct we discussed, for now for the LLDS backends
Estimated hours taken: 70
Branches: main
Implement the trace goal construct we discussed, for now for the LLDS backends
only.
Since the syntax of trace goals is non-trivial, useful feedback on syntax
errors inside trace goal attributes is essential. With the previous setup, this
wasn't possible, since the code that turned terms into parse tree goals turned
*all* terms into goals; it couldn't recognize any errors, sweeping them under
the rug as calls. This diff changes that. Now, if this code recognizes a
keyword that indicates a particular construct, it insists on the rest of the
code following the syntax required for that construct, and returns error
messages if it doesn't.
We handle the trace goal attributes that specify state variables to be threaded
through the trace goal (either the I/O state or a mutable variable) in
add_clause.m, at the point at which we transform the list of items to the HLDS.
We handle the compile-time condition on trace goals in the invocation of
simplify at the end of semantics analysis, by eliminating the goal if the
compile-time condition isn't met. We handle run-time conditions on trace goals
partially in the same invocation of simplify: we transform trace goals with
runtime conditions into an if-then-else with the trace goal as the then part
and `true' as the else part, the condition being a foreign_proc that is handled
specially by the code generator, that special handling being to replace
the actual code of the foreign_proc (which is a dummy) with the evaluation of
the runtime condition.
Since these changes require significant changes to some of our key data
structures, I took the liberty of doing some renaming of function symbols
at the same time to avoid using ambiguities with respect to language keywords.
library/ops.m:
Add "trace" as an operator.
compiler/prog_data.m:
Define data types to represent the various attributes of trace goals.
Rename some function symbols to avoid ambiguities.
compiler/prog_item.m:
Extend the parse tree representation of goals with a trace goal.
compiler/mercury_to_mercury.m:
Output the new kind of goal and its components.
compiler/hlds_goal.m:
Extend the HLDS representation of scopes with a scope_reason
representing trace goals.
Add a mechanism (an extra argument in foreign_procs) to allow
the representation of goals that evaluate runtime trace conditions.
Since this requires modifying all code that traverses the HLDS,
do some renames that were long overdue: rename not as negation,
rename call as plain_call, and rename foreign_proc as
call_foreign_proc. These renames all avoid using language keywords
as function symbols.
Change the way we record goals' purities. Instead of optional features
to indicate impure or semipure, which is error-prone, use a plain
field in the goal_info, accessed in the usual way.
Add a way to represent that a goal contains a trace goal, and should
therefore be treated as if it were impure when considering whether to
optimize it away.
Reformat some comments describing function symbols.
compiler/hlds_out.m:
Output the new construct in the HLDS.
compiler/prog_io_util.m:
Generalize the maybe[123] types to allow the representation of more
than one error message. Add functions to extract the error messages.
Add a maybe4 type. Rename the function symbols of these types to
avoid massive ambiguity.
Change the order of some predicates to bring related predicates
next to each other.
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
Rework these modules almost completely to find and accumulate syntax
errors as terms are being parsed. In some cases, this allowed us to
replace "XXX this is a hack" markers with meaningful error-reporting
code.
In prog_io_goal.m, add code for parsing trace goals.
In a bunch of places, update obsolete coding practices, such as using
nested chains of closures instead of simple sequential code, and
using A0 and A to refer to values of different types (terms and goals
respectively). Use more meaningful variable names.
Break up some too-large predicates.
compiler/superhomogeneous.m:
Find and accumulate syntax errors as terms are being parsed.
compiler/add_clause.m:
Add code to transform trace goals from the parse tree to the HLDS.
This is where the IO state and mutable variable attributes of trace
goals are handled.
Eliminate the practice of using the naming scheme Body0 and Body
to refer to values of different types (prog_item.goal and hlds_goal
respectively).
Use error_util for some error messages.
library/private_builtin.m:
Add the predicates referred to by the transformation in add_clause.m.
compiler/goal_util.m:
Rename a predicate to avoid ambiguity.
compiler/typecheck.m:
Do not print error messages about missing clauses if some errors have
been detected previously.
compiler/purity.m:
Instead of just computing purity, compute (and record) also whether
a goal contains a trace goal. However, treat trace goals as pure.
compiler/mode_info.m:
Add trace goals as a reason for locking variables.
Rename some function symbols to avoid ambiguity.
compiler/modes.m:
When analyzing trace goal scopes, lock the scope's nonlocal variables
to prevent them from being further instantiated.
compiler/det_analysis.m:
Insist on the code in trace goal scopes being det or cc_multi.
compiler/det_report.m:
Generate the error message if the code in a trace goal scope isn't det
or cc_multi.
compiler/simplify.m:
At the end of the front end, eliminate trace goal scopes if their
compile-time condition is false. Transform trace goals with runtime
conditions as described at the top.
Treat goals that contain trace goals as if they were impure when
considering whether to optimize them away.
compiler/mercury_compile.m:
Tell simplify when it is being invoked at the end of the front end.
Rename a predicate to avoid ambiguity.
compiler/trace_params.m:
Provide the predicates simplify.m need to be able to evaluate the trace
goal conditions regarding trace levels.
compiler/trace.m:
compiler/trace_gen.m:
Rename the trace module as trace_gen, since "trace" is now an operator.
Rename some predicates exported by the module, now that it is no longer
possible to preface calls with "trace." as a module qualifier.
compiler/notes/compiler_design.html:
Document this name change.
compiler/options.m:
Rename the trace option as trace_level internally, since "trace"
is now an operator. The user-visible name remains the same.
Add the new --trace-flag option.
Delete an obsolete option.
compiler/handle_options.m:
Rename the function symbols of the grade_component type,
since "trace" is now an operator.
compiler/llds.m:
Extend the LLDS with a mechanism to refer to C global variables.
For now, these are used to refer to C globals that will be created
by mkinit to represent the initial values of the environment variables
referred to by trace goals.
compiler/commit_gen.m:
Check that no trace goal with a runtime condition survives to code
generation; they should have been transformed by simplify.m.
compiler/code_gen.m:
Tell commit_gen.m what kind of scope it is generating code for.
compiler/pragma_c_gen.m:
Generate code for runtime conditions when handling the foreign_procs
created by simplify.m.
compiler/code_info.m:
Allow pragma_c_gen.m to record what environment variables it has
generated references to.
compiler/proc_gen.m:
Record the set of environment variables a procedure refers to
in the LLDS procedure header, for efficient access by llds_out.m.
compiler/llds_out.m:
Handle the new LLDS construct, and tell mkinit which environment
variables need C globals created for them.
compiler/pd_util.m:
Rename some predicates to avoid ambiguity.
compiler/*.m:
Conform to the changes above, mainly the renames of function symbols
and predicates, the changed signatures of some predicates, and the new
handling of purity.
util/mkinit.c:
Generate the definitions and the initializations of any C globals
representing the initial status (set or not set) of environment
variables needed by trace goals.
library/assoc_list.m:
Add some predicates that are useful in prog_io*.m.
library/term_io.m:
Minor cleanup.
tests/hard_coded/trace_goal_{1,2}.{m,exp}:
New test cases to test the new construct, identical except for whether
the trace goal is enabled at compile time.
tests/hard_coded/trace_goal_env_{1,2}.{m,exp}:
New test cases to test the new construct, identical except for whether
the trace goal is enabled at run time.
tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
Enable the new test cases.
tests/invalid/*.err_exp:
Update the expected output for the new versions of the error messages
now being generated.
|
||
|
|
74ce85d476 |
Provide a mechanism for collecting statistics about tabling operations,
Estimated hours taken: 60
Branches: main
Provide a mechanism for collecting statistics about tabling operations,
and provide a much more convenient mechanism for resetting tables.
Since it would too complex to do this while preserving the capability
of setting --tabling-via-extra-args to no, eliminate that capability
and the option. That option was useful only for measurements of the
performance boost from setting --tabling-via-extra-args to yes in any case,
so users lose no functionality.
Previously, the only way to debug the low level details of the tabling
mechanism was to build a runtime with a specific C macro (MR_TABLE_DEBUG)
and link with that runtime; this was cumbersome. Change that so that
every one of the debuggable tabling macros has a bool argument that says
whether debugging is enabled or not. The compiler can then set this to
MR_TRUE if the new option --table-debug is given, and to MR_FALSE otherwise.
If set to MR_FALSE, the C compiler should optimize away the debug code,
with zero impact on program size or speed.
Since these changes to macros require nontrivial bootstrapping, which we don't
want to do unnecessarily, modify the interface of the tabling macros as
required to support size limits on tables. This diff also implements the
parsing of size limit specifications on tables, but does not implement them
yet; that is for a future change.
To make the syntax simpler, this diff deletes the free-standing fast_loose_memo
pragma. The same functionality is now available with a fast_loose annotation
on an ordinary memo pragma.
Make a bunch of changes to improve readability and maintainability
in the process. These mostly take the form of renaming ambiguous and/or
not sufficiently expressive function symbols.
runtime/mercury_stack_layout.h:
runtime/mercury_tabling.h:
Move the description of structure of tables from mercury_stack_layout.h
to mercury_tabling.h, since we now need it for statistics even if
execution tracing is not enabled.
Modify those data structures to have room for the statistics.
Don't distinguish "strict", "fast_loose" and "specified" memoing
as separate eval methods; treat them as just different kinds
of the same eval method: "memo".
Remove underscores from the names of some types that the style guide
says shouldn't be there.
runtime/mercury_tabling_preds.h:
runtime/mercury_tabling_macros.h:
Modify the approach we use for macros that implement the predicates
of library/table_builtin.m. Instead of selecting between debug and
nondebug based on whether MR_TABLE_DEBUG is defined or not, add
an explicit argument controlling this to each debuggable macro.
The advantage of the new arrangement is that it scales. Another
argument controls whether we are computing statistics (and if yes,
where do we put it), and a third argument controls whether we maintain
back links in the tries and hash tables (this last argument is present
but is ignored for now).
Since the values of the arguments will be known when the .c files
containing calls to these macros are compiled, we pay the space and
time cost of debugging, statistics gathering and the maintenance of
back links if and only we need the revelant functionality.
Provide macros for limited backward compatibility with the old set
of macros; these allow workspaces created by old compilers to work
with the new macros in the runtime. The old macros followed the
naming scheme MR_table_*, the new ones are named MR_tbl_*.
runtime/mercury_table_int_fix_index_body.h:
runtime/mercury_table_int_start_index_body.h:
runtime/mercury_table_type_body.h:
New files containing parts of the old mercury_tabling.c. Each of these
files contains the body of the functions that used to be in
mercury_tabling.c. The new mercury_tabling.c #includes each of these
files more than once, to provide more than one variant of the old
function. These variants differ in aspects such as whether debugging
is enabled or statistics is being collected. Each variant therefore
incurs only the time costs it needs to. (We pay the space cost of
having all these variants all the time of course, but this cost
is negligible.)
runtime/mercury_tabling_stats_defs.h:
runtime/mercury_tabling_stats_nodefs.h:
runtime/mercury_tabling_stats_undefs.h:
New files that serve as wrappers around the newly #included files,
controlling how they handle statistics.
runtime/mercury_tabling.c:
Delete functions now in the new files, and #include them instead.
Delete the data structures that used to contain summary statistics;
the new approach keeps statistics in compiler-generated,
procedure-specific data structures.
runtime/mercury_trace_base.c:
Use the new versions of the tabling macros to access the I/O table.
runtime/mercury_type_info.h:
Update some documentation for the movement of code out of
mercury_tabling.c.
runtime/mercury_types.h:
Provide forward declarations of the identifiers denoting the new types
in mercury_tabling.h.
runtime/mercury_grade.h:
Increment the exec trace version number, since we have changed
a part of the exec trace structure.
runtime/mercury_bootstrap.h:
Fix some temporary issues that arise from some renames above.
runtime/mercury_hash_lookup_or_add_body.h:
Fix comment.
runtime/Mmakefile:
Mention the new files and the dependencies that involve them.
library/table_builtin.m:
Provide a type for representing statistics and a predicate for
printing statistics.
Use the updated versions of the macros in
runtime/mercury_tabling_preds.h.
compiler/prog_item.m:
Change representation of tabling pragmas to allow room for the new
attributes.
Allow an item to be marked as being generated by the compiler
as a result of a pragma memo attribute. We use this for the reset
and statistics predicates.
compiler/mercury_to_mercury.m:
Write out the new attributes of the tabling pragma.
compiler/prog_data.m:
compiler/hlds_data.m:
Change the cons_id that used to refer to a procedure's call table root
to refer to the entirety of the new data structure now containing it.
The compiler now needs a way to refer to the other components of this
new data structure, since it contains the statistics.
As in the runtime, don't distinguish "strict", "fast_loose" and
"specified" memoing as separate eval methods; treat them as just
different kinds of the same eval method: "memo".
Rename some of the uses of the function symbols "c", "java", "il".
compiler/hlds_pred.m:
Add an extra field in proc_infos for storing any tabling attributes.
Change the existing proc_info field that records information about
the kinds of arguments of tabled procedures to record the information
needed by the debugger too. This was needed to allow us to shift all
the RTTI for procedure-specific tables (as opposed to the RTTI for
the global I/O table) from mercury_stack_layout.h to mercury_tabling.h
without duplicating the data (which would be a maintenance problem).
Reformat some comments to make them easier to read.
compiler/layout.m:
compiler/layout_out.m:
Delete the part of the exec trace information that used to record
RTTI for tables, since this information is not generated only as
part of the debugger data structures anymore.
compiler/prog_io_pragma.m:
Recognize the updated syntax for tabling pragmas.
compiler/add_pragma.m:
When processing tabling pragmas for inclusion in the HLDS, create
any reset and statistics predicates they ask for.
compiler/make_hlds_passes.m:
Export a predicate now needed by add_pragma.m.
Handle the new attributes on tabling pragmas
compiler/globals.m:
Change the function symbols of the types describing backends and
foreign languages to say what they are. Previously, both types (as well
as several others) included the function symbol "c"; now, they are
target_c and lang_c respectively.
compiler/table_gen.m:
Implement the changes described at the top.
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/goal_util.m:
compiler/hlds_goal.m:
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/rtti.m:
Provide types for representing the runtime's data structures for
tabling (which are now significantly more complex than a single word)
and predicates for manipulating them, for use by both the ml and ll
backends.
compiler/llds.m:
Replace the comp_gen_c_var type with the tabling_info_struct type,
which contains the information needed to create the per-procedure
tabling data structures.
Replace references to call tables with references to the various
components of the new tabling data structures.
compiler/llds_out.m:
Add code to write out tabling_info_structs.
Delete the code required for the old, hacky way of resetting tables.
Reorder some code more logically.
compiler/proc_gen.m:
Generate tabling_info_structs.
compiler/stack_layout.m:
Don't generate the information now generated in proc_gen.m.
compiler/mlds.m:
Give mlds_proc_labels their own function symbols, instead of using
a pair. Rename some other function symbols to avoid ambiguity and add
expressiveness.
Provide for the representation of references to the various components
of the new tabling data structures, and for the representation of their
types.
compiler/ml_code_gen.m:
When generating code for a tabled procedure, generate also the data
structures required for its table.
compiler/rtti_to_mlds.m:
compiler/ml_util.m:
Move some predicates from rtti_to_mlds.m to ml_util.m, since we
now also want to call them from ml_code_gen.m.
compiler/name_mangle.m:
Add some utility predicates.
compiler/options.m:
Delete the old --allow-table-reset option.
Add the new --table-debug option.
Comment out an implementor-only option.
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_trail_ops.m:
compiler/add_type.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/dependency_graph.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/foreign.m:
compiler/global_data.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/proc_label.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_util.m:
compiler/recompilation.version.m:
compiler/size_prof.m:
compiler/special_pred.m:
compiler/switch_util.m:
compiler/transform_llds.m:
compiler/tupling.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
Conform to the changes above, and/or improve some comments.
mdbcomp/prim_data.m:
Make the names of the function symbols of the proc_label type more
expressive and less ambiguous.
mdbcomp/prim_data.m:
mdbcomp/mdbcomp.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
Use . instead of __ as module qualifier.
Conform to the change to prim_data.m.
browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
Conform the change to mdbcomp/prim_data.m.
tests/debugger/Mercury.options:
Don't specify --allow-table-reset for fib.m, since that option
doesn't exist anymore.
tests/debugger/fib.m:
Use the new mechanism for resetting the table.
tests/debugger/print_table.m:
Use the new syntax for pragma memo attributes.
tests/invalid/specified.{m,err_exp}:
Use to the new syntax and reset method for pragma memo attributes.
Test the handling of errors in the new attribute syntax.
tests/tabling/Mercury.options:
Don't specify --allow-table-reset for specified.m, since that option
doesn't exist anymore.
tests/tabling/specified.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables. We could also use this test case
for testing the printing of statistics, but the format of that
output is still not final.
tests/tabling/fast_loose.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables.
trace/mercury_trace.c:
trace/mercury_trace_cmd_developer.c:
Conform to the changes in the RTTI data structures regarding tabling.
Remove underscores from the names of some types that the style guide
says shouldn't be there.
library/robdd.m:
Comment out the tabling pragma until this change is bootstrapped.
Without this, the conflict between the old calls to macros generated
by the existing compiler and the new definition of those macros
in the runtime would cause errors from the C compiler.
|
||
|
|
d5d5986472 |
Implement lookup switches in which a switch arm may contain more than one
Estimated hours taken: 40
Branches: main
Implement lookup switches in which a switch arm may contain more than one
solution, such as this code here:
p(d, "four", f1, 4.4).
p(e, "five", f2, 5.5).
p(e, "five2", f3(5), 55.5).
p(f, "six", f4("hex"), 6.6).
p(g, "seven", f5(77.7), 7.7).
p(g, "seven2", f1, 777.7).
p(g, "seven3", f2, 7777.7).
Such code occurs frequently in benchmark programs used to evaluate the
performance of tabled logic programming systems.
Change frameopt.m, which previously worked only on det and semidet code,
to also work for nondet code. For predicates such as the one above, frameopt
can now arrange for the predicate's nondet stack frame to be created only
when a switch arm that has more than one solution is selected.
compiler/lookup_switch.m:
Extend the existing code for recognizing and implementing lookup
switches to recognize and implement them even if they are model_non.
compiler/lookup_util.m:
New module containing utility predicates useful for implementing
both lookup switches, and in the future, lookup disjunctions (i.e.
disjunctions that correspond to a nondet arm of a lookup switch).
compiler/ll_backend.m:
Include the new module.
compiler/notes/compiler_design.html:
Mention the new module.
compiler/global_data.m:
Move the job of filling in dummy slots to our caller, in this case
lookup_switch.m.
compiler/frameopt.m:
Generalize the existing code for delaying stack frame creation,
which worked only on predicates that live on the det stack, to work
also on predicates that live on the nondet stack. Without this,
predicates whose bodies are model_non lookup switches would create
a nonstack stack frame before the switch is ever entered, which
is wasteful if the selected switch arm has at most one solution.
Since the structure of model_non predicates is more complex (you can
cause a branch to a label by storing its address in a redoip slot,
you can succeed from the frame without removing the frame), this
required considerable extra work. To make the new code debuggable,
record, for each basic block that needs a stack frame, *why* it
needs that stack frame.
compiler/opt_util.m:
Be more conservative about what refers to the stack. Export some
previously internal functionality for frameopt. Turn some predicates
into functions, and rename them to better reflect their purpose.
compiler/opt_debug.m:
Print much more information about pragma_c and call LLDS instructions.
compiler/prog_data.m:
Add an extra attribute to foreign_procs that says that the code
of the foreign_proc assumes the existence of a stack frame.
This is needed to avoid frameopt optimizing the stack frame away.
compiler/add_pragma.m:
When processing fact tables, we create foreign_procs that assume
the existence of the stack frame, so set the new attribute.
compiler/pragma_c_gen.m:
When processing foreign_procs, transmit the information in the
attribute to the generated LLDS code.
compiler/llds.m:
Rename the function symbols referring to the fixed slots in nondet
stack frames to make them clearer and to avoid overloading function
symbols such as curfr and succip.
Rename the function symbols of the call_model type to avoid overloading
the function symbols of the code_model type.
Add a new field to the c_procedure type giving the code_model of the
procedure, and give names to all the fields.
Describe the stack slots used by lookup switches to the debugger
and native gc.
compiler/options.m:
doc/user_guide.texi:
Add a new option, --debug-opt-pred-name, that does when the existing
--debug-opt-pred-id options does, but taking a user-friendly predicate
name rather than a pred_id as its argument.
compiler/handle_options.m:
Process --debug-opt-pred-name, and make --frameopt-comments imply
--auto-comments, since it is not useful without it.
Reformat some existing comments that were written in the days of
8-space indentation.
compiler/optimize.m:
Implement the new option.
Use the new field of the c_procedure type to try only the version
of frameopt appropriate for the code model of the current procedure.
Do a peephole pass after frameopt, since frameopt can generate code
sequences that peephole can optimize.
Make the mechanism for recording the process of optimizing procedure
bodies more easily usable by including the name of the optimization
that created a given version of the code in the name of the file
that contains that version of the code, and ensuring that all numbers
are two characters long, so that "vi procname*.opt*" looks at the
relevant files in the proper chronological sequence, instead of having
version 11 appear before version 2.
compiler/peephole.m:
Add a new optimization pattern: a "mkframe, goto fail" pair (which
can be generated by frameopt) should be replaced by a simple "goto
redo".
compiler/code_gen.m:
Factor out some common code.
compiler/llds_out.m:
Ensure that C comments nested inside comment(_) LLDS instructions
aren't emitted as nested C comments, since C compilers cannot handle
these.
compiler/code_info.m:
compiler/code_util.m:
compiler/continuation_info.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/mercury_compile.m:
compiler/middle_rec.m:
compiler/ml_code_gen.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/peephole.m:
compiler/stack_layout.m:
compiler/transform_llds.m:
compiler/var_locn.m:
Conform to the change to prog_data.m, opt_util.m and/or llds.m.
compiler/handle_options.m:
Don't execute the code in stdlabel.m if doing so would cause a compiler
abort.
tests/hard_coded/dense_lookup_switch_non.{m,exp}:
New test case to exercise the new algorithm.
tests/hard_coded/Mmakefile:
Enable the new test case.
tests/hard_coded/cycles.m:
Make this test case conform to our coding convention.
|
||
|
|
46a67b0b48 |
When the typechecker finds highly ambiguous overloading, print what symbols
Estimated hours taken: 16
Branches: main
When the typechecker finds highly ambiguous overloading, print what symbols
were overloaded, and where they occurred. Without this information, it is
very hard to fix the error if the predicate body is at all large.
Fix some software engineering problems encountered during this process.
Modify some predicates in error_util in order to simplify their typical usage.
Change the type_ctor type to be not simply a sym_name - int pair but a type
with its own identifying type constructor. Change several other types that
were also sym_name - int pairs (mode_id, inst_id, item_name, module_qual.id
and the related simple_call_id) to have their own function symbols too.
compiler/typecheck_info.m:
Add a field to the typecheck_info structure that records the overloaded
symbols encountered.
compiler/typecheck.m:
When processing ambiguous predicate and function symbols, record this
fact in the typecheck_info.
Add a field to the cons_type_info structure to make this possible.
compiler/typecheck_errors.m:
When printing the message about highly ambiguous overloading,
what the overloaded symbols were and where they occurred.
compiler/error_util.m:
Make error_msg_specs usable with plain in and out modes by separating
out the capability requiring special modes (storing a higher order
value in a function symbol) into its own, rarely used type.
Make component_list_to_line_pieces a bit more flexible.
compiler/prog_data.m:
compiler/module_qual.m:
compiler/recompilation.m:
Change the types listed above from being equivalence types (pairs)
to being proper discriminated union types.
compiler/*.m:
Conform to the changes above.
In some cases, simplify the code's use of error_util.
tests/warnings/ambiguous_overloading.{m,exp}:
Greatly extend this test case to test the new functionality.
tests/recompilation/*.err_exp.2
Reflect the fact that the expected messages now use the standard
error_util way of quoting sym_name/arity pairs.
|
||
|
|
4fe703c7b9 |
Implement a more cache-friendly translation of lookup switches.
Estimated hours taken: 8
Branches: main
Implement a more cache-friendly translation of lookup switches. Previously,
for a switch such as the one in
:- pred p(foo::in, string::out, bar::out, float::out) is semidet.
p(d, "four", f1, 4.4).
p(e, "five", f2, 5.5).
p(f, "six", f4("hex"), 6.6).
p(g, "seven", f5(77.7), 7.7).
we generated three static cells, one for each argument, and then indexed
into each one in turn to get the values of HeadVar__2, HeadVar__3 and
HeadVar__4. The different static cells each represent a column here.
Each of the loads accessing the columns will access a different cache block,
so with this technique we expect to get as many cache misses as there are
output variables.
This diff changes the code we generate to use a vector of static cells
where each cell represents a row. The assignments to the output variables
will now access the different fields of a row, which will be next to each
other. We thus expect only one cache miss irrespective of the number of output
variables, at least up to the number of variables that actually fit into one
cache block.
compiler/global_data.m:
Provide a mechanism for creating not just single (scalar) static cells,
but arrays (vectors) of them.
compiler/lookup_switch.m:
Use the new mechanism to generate code along the lines described above.
Put the information passed between the two halves of the lookup switch
implementation (detection and code generation) into an opaque data
structure.
compiler/switch_gen.m:
Conform to the new interface of lookup_switch.m.
compiler/ll_pseudo_type_info.m:
compiler/stack_layout.m:
compiler/string_switch.m:
compiler/unify_gen.m:
compiler/var_locn.m:
Conform to the change to global_data.m.
compiler/llds.m:
Define the data structures for holding vectors of static cells. Rename
the function symbols we used to use to refer to static cells to make
clear that they apply to scalar cells only. Provide similar mechanisms
for representing static cell vectors and references to them.
Generalize heap_ref heap references to allow the index to be computed
at runtime, not compile time. For symmetry's sake, do likewise
for stack references.
compiler/llds_out.m:
Add the code required to write out static cell vectors.
Rename decl_ids to increase clarity and avoid ambiguity.
compiler/code_util.m:
compiler/exprn_aux.m:
Modify code that traverses rvals to now also traverse the new rvals
inside memory references.
compiler/name_mangle.m:
Provide the prefix for static cell vectors.
compiler/layout_out.m:
compiler/rtti_out.m:
compiler/opt_debug.m:
Conform to the change to data_addrs and decl_ids.
compiler/code_info.m:
Provide access to the new functionality in global_data.m, and conform
to the change to llds.m.
Provide a utility predicate needed by lookup_switch.m.
compiler/hlds_llds.m:
Fix the formatting of some comments.
tools/binary:
tools/binary_step:
Fix the bit rot that has set in since they were last used (the rest
of the system has changed quite a lot since then). I had to do so
to debug one part of this change.
tests/hard_coded/dense_lookup_switch2.{m,exp}:
tests/hard_coded/dense_lookup_switch3.{m,exp}:
New test cases to exercise the new algorithm.
tests/hard_coded/Mmakefile:
Enable the new test cases, as well as an old one (from 1997!)
that seems never to have been enabled.
|
||
|
|
459847a064 |
Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18 Branches: main Move the univ, maybe, pair and unit types from std_util into their own modules. std_util still contains the general purpose higher-order programming constructs. library/std_util.m: Move univ, maybe, pair and unit (plus any other related types and procedures) into their own modules. library/maybe.m: New module. This contains the maybe and maybe_error types and the associated procedures. library/pair.m: New module. This contains the pair type and associated procedures. library/unit.m: New module. This contains the types unit/0 and unit/1. library/univ.m: New module. This contains the univ type and associated procedures. library/library.m: Add the new modules. library/private_builtin.m: Update the declaration of the type_ctor_info struct for univ. runtime/mercury.h: Update the declaration for the type_ctor_info struct for univ. runtime/mercury_mcpp.h: runtime/mercury_hlc_types.h: Update the definition of MR_Univ. runtime/mercury_init.h: Fix a comment: ML_type_name is now exported from type_desc.m. compiler/mlds_to_il.m: Update the the name of the module that defines univs (which are handled specially by the il code generator.) library/*.m: compiler/*.m: browser/*.m: mdbcomp/*.m: profiler/*.m: deep_profiler/*.m: Conform to the above changes. Import the new modules where they are needed; don't import std_util where it isn't needed. Fix formatting in lots of modules. Delete duplicate module imports. tests/*: Update the test suite to confrom to the above changes. |
||
|
|
3ebda6545f |
Move the stuff currently in hlds_pred.m that deals with clauses into a new
Estimated hours taken: 1.5 Branches: main Move the stuff currently in hlds_pred.m that deals with clauses into a new module, hlds_clauses.m. Move the stuff currently in hlds_pred.m that deals with RTTI into a new module, hlds_rtti.m. Move the stuff currently in hlds_module.m that deals with predicate tables into a new module, pred_table.m. These changes make hlds_pred.m and hlds_module.m much more cohesive, but there are no changes in algorithms. compiler/hlds_clauses.m: compiler/hlds_rtti.m: compiler/pred_table.m: New modules as described above. In some cases, fix mixleading or ambiguous predicate names in the process, and convert a few predicates to functions. compiler/hlds_pred.m: compiler/hlds_module.m: Delete the stuff moved to other modules. compiler/*.m: In modules that need the functionality moved a new module, import the new module. It is rare for all the new modules to be needed, and many modules don't need any of the new modules at all. (For example, of the 200+ modules that import hlds_module.m, only about 40 need pred_table.m.) Conform to the few minor changes to e.g. predicate names. compiler/notes/compiler_design.html: Document the new modules. |
||
|
|
276ed0f120 |
Change the way we represent static cells. Instead of generating a separate
Estimated hours taken: 6 Branches: main Change the way we represent static cells. Instead of generating a separate global variable for each static cell, generate global variables that are arrays, each containing all the static cells of the same type. By reducing the number of symbols requiring relocation, this reduces link times, especially in debug grades (since those have lots of static cells). compiler/global_data.m: Rewrite the part of this module that handles static cells in line with the above. compiler/llds.m: Modify the data structures for representing static cells in line with the above. compiler/llds_out.m: Delete all the code for grouping together all the static cells of the same type, since it is not needed anymore. Replace with simpler code to print out the new arrays of static cells. Rename some predicates to eliminate ambiguity. compiler/opt_debug.m: Conform to the change in llds.m. compiler/rtti_out.m: Conform to the change in llds_out.m. runtime/mercury_misc.h: runtime/mercury_stack_layout.h: Create variants of the existing shorthand macros to refer to static cells not using a specified global variable but using a specified offset in a specified array. Once this change has been bootstrapped on all our machines, the old variants can be deleted. |
||
|
|
be5b71861b |
Convert almost all the compiler modules to use . instead of __ as
Estimated hours taken: 6 Branches: main compiler/*.m: Convert almost all the compiler modules to use . instead of __ as the module qualifier. In some cases, change the names of predicates and types to make them meaningful without the module qualifier. In particular, most of the types that used to be referred to with an "mlds__" prefix have been changed to have a "mlds_" prefix instead of changing the prefix to "mlds.". There are no algorithmic changes. |
||
|
|
9d8ca0ad37 |
Remove residual parts of the Aditi backend that weren't deleted the other day.
Estimated hours taken: 1.5 Branches: main Remove residual parts of the Aditi backend that weren't deleted the other day. configure.in: Mmake.common.in: Remove support for enabling the Aditi backend. runtime/mercury_aditi.h: Remove this file. runtime/Mmakefile: runtime/mercury.h: runtime/mercury_imp.h: runtime/mercury_ho_call.[ch]: runtime/mercury_wrapper.[ch]: Delete support for Aditi in the runtime. scripts/Mmake.rules: scripts/Mmake.vars.in: scripts/c2init.in: scripts/parse_ml_options.sh-subr.in: Remove mmake support for building .rlo files, etc. util/mkinit.c: Remove Aditi specific code. compiler/bytecode_data.m: compiler/closure_analysis.m: compiler/code_model.m: compiler/compile_target_code.m: compiler/det_analysis.m: compiler/handle_options.m: compiler/hlds_goal.m: compiler/hlds_module.m: compiler/make.dependencies.m: compiler/make.m: compiler/make.module_target.m: compiler/make.program_target.m: compiler/make.util.m: compiler/make_hlds_error.m: compiler/make_hlds_passes.m: compiler/mercury_to_mercury.m: compiler/mlds_to_gcc.m: compiler/modecheck_call.m: compiler/modules.m: compiler/opt_debug.m: compiler/options.m: compiler/prog_data.m: compiler/prog_foreign.m: compiler/prog_mode.m: compiler/prog_type.m: compiler/rtti.m: compiler/rtti_out.m: compiler/rtti_to_mlds.m: compiler/term_errors.m: compiler/unify_proc.m: mdbcomp/prim_data.m: Remove residual support for Aditi. library/ops.m: Remove the 'aditi_bottom_up' and 'aditi_top_down' operators from the ops table. doc/reference_manual.texi: doc/user_guide.texi: Delete the sections on the Aditi interface. extras/aditi/*: Delete this. |
||
|
|
f9fe8dcf61 |
Improve the error messages generated for determinism errors involving committed
Estimated hours taken: 8
Branches: main
Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.
The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.
compiler/det_analysis.m:
Keep track of goals to the right of the current goal that could fail,
and include them in the error representation if required.
compiler/det_report.m:
Include the list of failing goals to the right in the representations
of determinism errors involving committed committed choice goals.
Convert the last part of this module that wasn't using error_util
to use error_util. Make most parts of this module just construct
error message specifications; print those specifications (using
error_util) in only a few places.
compiler/hlds_out.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
compiler/compiler_util.m:
Error_util is still changing reasonably often, and yet it is
included in lots of modules, most of which need only a few simple
non-parse-tree-related predicates from it (e.g. unexpected).
Move those predicates to a new module, compiler_util.m. This also
eliminates some undesirable dependencies from libs to parse_tree.
compiler/libs.m:
Include compiler_util.m.
compiler/notes/compiler_design.html:
Document compiler_util.m, and fix the documentation of some other
modules.
compiler/*.m:
Import compiler_util instead of or in addition to error_util.
To make this easier, consistently use . instead of __ for module
qualifying module names.
tests/invalid/det_errors_cc.{m,err_exp}:
Add this new test case to test the error messages for cc contexts.
tests/invalid/det_errors_deet.{m,err_exp}:
Add this new test case to test the error messages for unifications
inside function symbols.
tests/invalid/Mmakefile:
Add the new test cases.
tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
Change the expected output to conform to the change in det_report.m,
which is now more consistent.
|
||
|
|
b2012c0c0e |
Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst'
Estimated hours taken: 8 Branches: main compiler/*.m: Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst' and 'mer_mode'. This is to avoid the need to parenthesize these type names in some contexts, and to prepare for the possibility of a parser that considers those words to be reserved words. Rename some other uses of those names (e.g. as item types in recompilation.m). Delete some redundant synonyms (prog_type, mercury_type) for mer_type. Change some type names (e.g. mlds__type) and predicate names (e.g. deforest__goal) to make them unique even without module qualification. Rename the function symbols (e.g. pure, &) that need to be renamed to avoid the need to parenthesize them. Make their replacement names more expressive. Convert some more modules to four space indentation. Avoid excessively long lines, such as those resulting from the automatic substitution of 'mer_type' for 'type'. |
||
|
|
2842fe4ffb |
Some style fixes. Make some predicates into functions, and delete
Estimated hours taken: 0.3 Branches: main compiler/llds_out.m: Some style fixes. Make some predicates into functions, and delete redundant llds_out__ prefixes to eliminate some excessively long lines. There are no algorithmic changes. compiler/opt_debug.m: compiler/fact_table.m: Conform to the changes in llds_out.m. compiler/rtti_out.m: Conform to the changes in llds_out.m. Convert to four-space indentation. |
||
|
|
753d9755ae |
When returning from det and semidet predicates, load the return address into a
Estimated hours taken: 3 Branches: main When returning from det and semidet predicates, load the return address into a local C variable instead of the succip abstract machine "register" before popping the stack frame and returning. This gives the C compiler more freedom to reorder instructions. This diff gets a 1.4% speed increase on the compiler. runtime/mercury_stacks.h: Provide a new macro, MR_decr_sp_and_return, to do the combined job that its name describes. compiler/llds.m: Add a new LLDS instruction that corresponds to the new macro. compiler/llds_out.m: Output the new LLDS instruction. compiler/peephole.m: Add a predicate that looks for and exploits opportunities for using the new instruction. compiler/optimize.m: Invoke the new peephole predicate as the next-to-last optimization pass. (The last is wrapping up blocks created by --use-local-vars.) compiler/*.m: Minor changes to handle the new instruction. |
||
|
|
1ed891b7b1 |
Introduce a mechanism for extending the det and nondet stacks when needed.
Estimated hours taken: 24
Branches: main
Introduce a mechanism for extending the det and nondet stacks when needed.
The mechanism takes the form of a new grade component, .exts ("extend stacks").
While the new mechanism may be useful in its own right, it is intended mainly
to support a new implementation of minimal model tabling, which will use a
separate Mercury context for each distinct subgoal. Each context has its own
det and nondet stack. Clearly, we can't have hundreds of contexts each with
megabyte sized det stacks. The intention is that the stacks of the subgoals
will start small, and be expanded when needed.
The runtime expansion of stacks doesn't work yet, but it is unnecessarily
hard to debug without an installed compiler that understands the new grade
component, which is why this diff will be committed before that is fixed.
compiler/handle_options.m:
compiler/options.m:
runtime/mercury_grade.h:
scripts/canonical_grade.sh-subr
scripts/init_grade_options.sh-subr
scripts/parse_grade_options.sh-subr
scripts/mgnuc.in
Handle the new grade component.
runtime/mercury_memory_zones.h:
Add MR_ prefixes to the names of the fields of the zone structure.
Record not just the actual size of each zone, which includes various
kinds of buffers, but also the desired size of the zone exclusive of
buffers.
Format the documentation of the zone structure fields more
comprehensibly.
runtime/mercury_memory_zones.c:
Instead of implementing memalign if it is not provided by the operating
system, implement a function that allows us to reallocate the returned
area of memory.
Provide a prototype implementation of memory zone extension. It doesn't
work yet.
Factor out the code for setting up redzones, since it is now needed
in more than place.
Convert to four space indentation.
Make the debugging functions a bit more flexible.
runtime/mercury_wrapper.c:
Conform to the improved interface of the debugging functions.
runtime/mercury_overflow.h:
runtime/mercury_std.h:
Move a generally useful macro from mercury_overflow.h to mercury_std.h.
runtime/mercury_stacks.c:
Add functions to extend the stacks.
runtime/mercury_stacks.h:
Add the tests required to invoke the functions that extend the stacks.
Add the macros needed by the change to compiler/llds.m.
Convert to four space indentation.
runtime/mercury_conf.h.in:
Prepare for the use of the posix_memalign function, which is the
current replacement of the obsolete memalign library function.
We don't yet use it.
runtime/mercury_context.h:
Format the documentation of the context structure fields more
comprehensibly.
Put MR_ prefixes on the names of the fields of some structures
that didn't previously have them.
Conform to the new names of the fields of the zone structure.
runtime/mercury_context.c:
runtime/mercury_debug.c:
runtime/mercury_deep_copy.c:
runtime/mercury_engine.c:
runtime/mercury_memory_handlers.c:
library/benchmarking.m:
library/exception.m:
Conform to the new names of the fields of the zone structure.
In some cases, add missing MR_ prefixes to function names
and/or convert to four space indentation.
runtime/mercury_engine.h:
Add a new low level debug flag for debugging stack extensions.
Format the documentation of the engine structure fields more
comprehensibly.
Convert to four space indentation.
runtime/mercury_conf_param.h:
Document a new low level debug flag for debugging stack extensions.
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/options.m:
Handle the new grade component.
compiler/llds.m:
Add two new kinds of LLDS instructions, save_maxfr and restore_maxfr.
These are needed because the nondet stack may be relocated between
saving and the restoring of maxfr, and the saved maxfr may point to
the old stack. In .exts grades, these instructions will save not a
pointer but the offset of maxfr from the start of the nondet stack,
since offsets are not affected by the movement of the nondet stack.
compiler/code_info.m:
Use the new instructions where relevant. (Some more work may be
needed on this score; the relevant places are marked with XXX.)
compiler/dupelim.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/reassign.m:
compiler/use_local_vars.m:
Handle the new LLDS instructions.
tools/bootcheck:
Provide a mechanism for setting the initial stack sizes for a
bootcheck.
|
||
|
|
df0d9036cf |
Optimize calls that would be tail calls in Prolog but are followed by
Estimated hours taken: 40 Branches: main Optimize calls that would be tail calls in Prolog but are followed by construction unifications in Mercury: last call modulo construction. For now, the optimization is available only for the LLDS backend. compiler/lco.m: Turn this module from a placeholder to a real implementation of the optimization. compiler/hlds_goal.m: Allow lco.m to attach to construction unifications a note that says that certain arguments, instead of being filled in by the unification, should have their addresses taken and stored in the corresponding variables. Group this note together with the note that asks for term size profiling to avoid an increase in the sizes of goals in the compiler in most cases. compiler/hlds_pred.m: Provide a predicate for setting the name of a predicate after its creation. This functionality is used by lco.m. Extend the pred_transformation part of the pred_origin type to allow it to express that a procedure was created by lco.m. List the new primitive store_at_ref as a no-typeinfo builtin. Fix some problems with indentation. compiler/layout_out.m: Handle the new pred_transformation. compiler/unify_gen.m: When processing construction unifications that have the new feaure turned on, perform the requested action. Fix some departures from coding style. Shorten lines by deleting unnecessary module qualifications. Add some auxiliary predicates to make the code easier to read. compiler/var_locn.m: Fix an earlier oversight: when materializing variables inside rvals and lvals, look inside memory references too. Previously, the omission didn't matter, since we didn't generate such references, but now we do. Fix some departures from coding style. compiler/llds_out.m: Fix some old XXXs in code handling memory references. We didn't use to generate such references, but now we do. Move some functionality here from code_aux.m. compiler/code_info.m: Provide some primitive operations needed by the new code in var_locn.m. Delete an unneeded predicate. compiler/options.m: Rename the existing option optimize_constructor_last_call as optimize_constructor_last_call_accumulator, since that optimization is done by accumulator.m. Make optimize_constructor_last_call be the option that calls for the new optimization. compiler/handle_options.m: Handle the implications of the new option. compiler/mercury_compile.m: Invoke the lco module by its new interface. librrary/private_builtin.m: Add a new primitive operation, store_at_ref, for use by the new optimization. Switch the module to four-space indentation. compiler/add_clause.m: Comment out the warning for clauses for builtin, since this is needed to bootstrap the addition of the new builtin. compiler/term_constr_initial.m: Handle the new builtin. compiler/accumulator.m: Conform to the change in options. compiler/builtin_ops.m: Provide a third template for builtins, for use by store_at_ref. Convert the file to four-space indentation. compiler/call_gen.m: Generate code following the new builtin template. compiler/rl_exprn.m: Minor changes to conform to the changes in builtin templates. compiler/quantification.m: Minor changes to conform to the changes in construct unifications. Don't make the "get" predicates operating on quantification_infos to return the "new" quantification_info: it is always the same as the old one. compiler/aditi_builtin_ops.m: compiler/common.m: compiler/deep_profiling.m: compiler/higher_order.m: compiler/hlds_out.m: compiler/lambda.m: compiler/magic_util.m: compiler/ml_unify_gen.m: compiler/modecheck_unify.m: compiler/polymorphism.m: compiler/size_prof.m: Minor changes to conform to the changes in construct unifications. compiler/dependency_graph.m: Add a new predicate to recompute the dependency information, even if a previous (and possibly now inaccurate) version is present. Change the interface to make it clearer, by changing bools into types specific to the situation. Convert the file to four-space indentation. compiler/mode_constraints.m: Minor changes to conform to the changes in dependency_graph.m. compiler/code_aux.m: Delete this module. Half its functionality has been moved into llds_out.m, half to middle_rec.m (its only user). compiler/goal_form.m: Move the predicates in this module that are used only by middle_rec.m to middle_rec.m. Convert the file to four-space indentation. compiler/goal_util.m: compiler/det_util.m: Move update_instmap from det_util to goal_util, since it is usefulness extends beyond determinism analysis. Convert det_util.m to four-space indentation. compiler/middle_rec.m: Move here the code required only here from code_aux and goal_form. Update the moved code for the changes in construct unifications. The updates are specific to middle_rec.m: they wouldn't be of use to other modules. They basically say that any code that takes the addresses of fields cannot be handled by middle_rec.m. compiler/code_gen.m: compiler/det_analysis.m: compiler/live_vars.m: compiler/ll_backend.m: compiler/loop_inv.m: compiler/switch_detection.m: compiler/switch_gen.m: compiler/notes/compiler_design.html: Minor changes to conform to the deletion of code_aux.m and/or the movement of code from det_util to goal_util.m. compiler/opt_debug.m: Print info for vars in rvals. compiler/hlds_module.m: Convert a lambda to an explicit predicate to make some code easier to read. Switch the module to four-space indentation. |
||
|
|
f0dbbcaa34 |
Generate better code for base relations such as the ones in the transitive
Estimated hours taken: 16 Branches: main Generate better code for base relations such as the ones in the transitive closure benchmarkings in the paper on minimal model tabling. These improvements yield speedups ranging from 5 to 25% on those benchmarks. compiler/use_local_vars.m: Make this optimization operate on extended basic blocks instead of plain basic blocks. The greater length of extended basic blocks allows the local variables to have maximum scope possible. The price is that the test for whether assignment to a given lvalue can be avoided or not is now dependent on which of the constituent basic blocks of extended basic block contains the assignment, and thus the test has to be evaluate once for each assignment we try to optimize instead of once per block. Don't allocate temporary variables if the optimization they are intended for turns out not to be allowed. This change avoids having declarations for unused temporary variables in the resulting C code. If --auto-comments is set, insert use_local_vars.m's main data structure, the livemap, into the generated LLDS code as a comment. compiler/peephole.m: Look for the pattern mkframe(Size, Redoip) <straight line instructions that don't use stack slots> succeed and optimize away the mkframe. This pattern always arises for procedures that are actually semidet but are declared nondet (such as the base relations in the tabling benchmarks), and may also arise for semidet branches of nondet procedures. compiler/llds.m: Allow an existing peephole pattern to work better. The pattern is mkframe(Seize, do_fail) <straight line instructions> redoip(curfr) = Redoip Previously, if some compiler-generated C code was among the straight line instructions, the pattern couldn't be applied, since peephole.m couldn't know whether it branched away through the redoip slot of the frame. This diff adds an extra slot to the relevant pragma_c component that tells peephole.m (actually, the predicate in opt_util.m that peephole relies on) whether this is the case. compiler/basic_block.m: Provide functionality for merging basic blocks into extended basic blocks. compiler/dupelim.m: Conform to the change in basic_block.m's interface. Convert to four-space indentation, and fix departures from our style guidelines. compiler/opt_util.m: Provide extra information now needed by use_local_vars. Convert to four-space indentation, and fix departures from our style guidelines. compiler/opt_debug.m: Show the user friendly versions of label names when dumping livemaps and instructions. Shorten the dumped descriptions of registers and stack slots. Dump instructions inside blocks. compiler/frameopt.m: Conform to the changes in opt_util and opt_debug's interfaces. compiler/optimize.m: Use the facilities of opt_debug instead of llds_out when dumping the LLDS after each optimization, since these are now more compact and thus reader friendly. Print unmangled names when writing progress messages. Put the dump files we generate with --opt-debug in a separate subdirectory, since when compiling e.g. tree234.m, the process can generate more than a thousand files. Give the dump files minimally mangled names. compiler/code_gen.m: compiler/pragma_c_gen.m: Convert to four-space indentation, and fix departures from our style guidelines. Conform to the change in llds.m. compiler/code_info.m: compiler/exprn_aux.m: compiler/ite_gen.m: compiler/jumpopt.m: compiler/livemap.m: compiler/llds_out.m: compiler/middle_rec.m: compiler/trace.m: Conform to the change in llds.m. |
||
|
|
5b105a0968 |
Optimize higher order calls by providing variants of the relevant code that
Estimated hours taken: 6 Branches: main Optimize higher order calls by providing variants of the relevant code that are specialized to a given number of explicitly given arguments. runtime/mercury_ho_call.[ch]: Define variants of do_call_closure and do_call_class_method specialized to 0, 1, 2 or 3 explicit input arguments. Apart from not needing to be passed the number of explicit input arguments in a register, these avoid some runtime tests and unroll loops. Harmonize the variable names used in the do_call_closure and do_call_class_method variants. Since they are near-copies of each other, factor out their documentation. (Factoring out the code itself would be possible, but would not make maintenance easier and would make the code harder to read.) Provide a mechanism to gather statistics about the numbers of hidden and explicit arguments if the macro MR_DO_CALL_STATS is set. compiler/options.m: Add options that specify how many of these variants exist. These provide the necessary synchronization between the runtime and the compiler. They are not meant to be set from the command line, even by implementors. runtime/mercury_conf_params.h: Document MR_DO_CALL_STATS. runtime/mercury_wrapper.c: If MR_DO_CALL_STATS is set, print the gathered statistics when execution ends. runtime/mecury_mm_own_stack.c: Fix a typo that prevented the stage2 library from linking in jump.gc grade. compiler/llds.m: Provide a way to represent the labels of the new specialized variants. compiler/llds__out.m: Output the labels of the new specialized variants if required. Convert to four-space indentation. compiler/call_gen.m: Call the specialized variants of do_call_closure or do_call_class_method if they are applicable. code_info/follow_vars.m: code_info/interval.m: code_info/tupling.m: Conform to the change in call_gen.m. code_info/dupproc.m: code_info/exprn_aux.m: code_info/livemap.m: code_info/opt_util.m: Conform to the change in llds.m. compiler/code_info.m: Minor style cleanups. tools/bootcheck: Enable the collection of statistics from the compilation of stage 3 and the test cases, for use when the stage 2 is built with MR_DO_CALL_STATS enabled. tools/ho_call_stats: A new script to analyze the statistics collected. tools/makebatch: Add a new option --save-stage2-on-no-compiler, which is a variant of the existing option --save-stage2-on-error. |
||
|
|
828d969e67 |
Significantly improve the capabilities of the LLDS optimization that tries
Estimated hours taken: 20 Branches: main Significantly improve the capabilities of the LLDS optimization that tries to delay the creation of the stack frame, in the hope that on some computation paths the frame won't need to be created at all. Previously, the delayed setup of the stack frame could take place only when a block without a stack frame fell through to a block that needed a stack frame. If block B1 jumped to another block B2 that needed a frame, this was taken as meaning that B1 also had to have a frame. This was a problem, because if B1 ends with a computed goto, some of whose targets need stack frames and some do not, this limitation effectively gave all of them a stack frame, whether they wanted it or not, and thus required them to execute the stack frame teardown code. This diff removes the limitation, optimization allows B1 in this case to not have a stack frame. Instead of jumping to B2, B1 will not jump to a label B3 it inserts immediately before B2, the code at B3 setting up the stack frame and falling through to B2. (We also insert code to jump around B3 if the code immediately preceding it could fall into it accidentally.) The new code in frameopt is conceptually cleaner than it was before, because we now handle transitions from blocks that don't have a stack stack to blocks that do in a much more uniform manner. Most of the changes to other modules are to make the change to frameopt.m easier to debug. The motivation for the change was that we were beaten by YAP (Yet Another Prolog) on the deriv benchmark due to the limitation of frameopt. I haven't measured against YAP yet, but the runtime for 1.5 million iterations has been reduced from about 20 seconds to about 13. Since the compiler doesn't have any predicates that are both frequently used and can benefit from the removal of that old limitation (which is why the limitation wasn't really noticed before), there is no measurable effect on the speed of the compiler itself. compiler/frameopt.m: Effectively rewrite the optimization that delays stack frame creation along the lines above. The code for the optimization that keeps the stack frame for recursive calls if possible is unaffected. If the new option --frameopt-comments is specified, insert into the generated LLDS code a nicely formatted description of the main frameopt.m data structures. These are much easier to read that the term browser in the debugger. compiler/options.m: Add the new developer-only option --frameopt-comments. compiler/llds_out.m: Change the way we output comments to make the coments generated by frameopt.m easier to read. (We output comments only if --auto-comments is given, which it usually isn't.) compiler/opt_debug.m: Provide the functionality of printing local labels in an easier-to-read form that doesn't repeat the (possibly long) procedure name. Local labels can now be printed as e.g. local_15. Rewrite the module to use functions instead of predicates for appending strings, since this makes the code shorter, easier to use and to read. The original code was written before Mercury had functions. compiler/switch_util.m: When gathering information about switches, return the cons_id with each goal. Switch to four-space indentation. compiler/tag_switch.m: When generating code for switches, insert a comment at the start of each case saying what cons_id it is for, using the new information from switch_util. This is to make the generated code easier to understand. Switch to four-space indentation. compiler/ml_tag_switch.m: Conform to the change in switch_util. compiler/optimize.m: Conform to the slightly modified interface of frameopt.m. Switch to four-space indentation. compiler/peephole.m: Switch to four-space indentation, and fix some coding style issues. compiler/basic_block.m: When dividing a procedure body into basic blocks, remember for each block whether it could be fallen into. This modification is not strictly required for this change, since frameopt has its own (specialized) code for creating basic blocks, but it could be useful in the future. compiler/dupelim.m: compiler/use_local_vars.m: Conform to the change in basic_block.m. |
||
|
|
68b1a6c0ea |
Add a new LLDS optimization we discussed on thursday: elimination of procedures
Estimated hours taken: 4 Branches: main Add a new LLDS optimization we discussed on thursday: elimination of procedures whose code is an exact copy of the code of another mode of the same predicate. This happens with in,out vs di,uo and also possibly with in,out vs any,any. The new optimization reduces the compiler's code size by 0.6%. compiler/dupproc.m: A new module implementing the new optimization. compiler/ll_backend.m: Add dupproc.m as a new submodule. compiler/notes/compiler_design.html: Mention the new module. compiler/options.m: Add an option, --optimize-proc-dups, enabling the new optimization. Make --opt-space imply the new option. doc/user_guide.texi: Document the new option. compiler/mercury_compile.m: Invoke the new optimization when compiling by predicates. Move the imports of library modules to their own section. compiler/handle_options.m: Make --optimize-proc-dups imply compiling by predicates. The rest of these changes are cosmetic only. compiler/llds.m: Delete an obsolete form of constant we haven't used in a long time. compiler/exprn_aux.m: compiler/jumpopt.m: compiler/llds_out.m: compiler/opt_debug.m: compiler/opt_util.m: Conform to the change in llds.m. compiler/dependency_graph.m: Clean up some comments. compiler/dupelim.m: Fix some variable names. compiler/hlds_module.m: compiler/hlds_pred.m: Minor cleanups. |
||
|
|
309910d736 |
Change the mechanism we use to transmit a representation of procedure bodies
Estimated hours taken: 16 Branches: main Change the mechanism we use to transmit a representation of procedure bodies from the compiler to the declarative debugger from Mercury terms to a bytecode. This achieves two objectives. First, the code for Mercury terms worked only as long as the compiler used the same data representation as the program being compiled; it generated incorrect term representations when e.g. the compiler generating code in reserve tag grades. Second, the new representation is significantly smaller. The total size of the .c files in the compiler directory in grade asm_fast.gc.decldebug.tr is now only 213 Mb compared with 313 Mb previously (a reduction of almost one third). The executable file size of a compiler compiled in asm_fast.gc.decldebug.tr is now only 59 Mb, compare with 64 Mb previously (a reduction of almost 8%, and there is room for further reductions). The overhead of the decldebug grade when compared with a plain debug grade now only about 25%, compared to about 36% before. The downside is that the procedure body representation must now be constructed by the declarative debugger from the bytecode instead of being available directly. We minimize this effect by using a cache to ensure that each procedure's body representation is constructed at most once. browser/declarative_execution.m: Do not include the procedure representation in call nodes. This should make the annotated trace somewhat smaller and quicker to construct. Since this code will be executed many more times than the number of procedures whose bodies are needed by subterm dependency tracking, the overall effect of this change on speed should be positive. Instead, add code to construct procedure body representations on demand from bytecode, which is reachable indirectly through the call's node label label structure. browser/declarative_tree.m: Conform to the new structure of call nodes. compiler/prog_rep.m: Replace the code that generated the term representation of procedure bodies with code that generates a bytecode representation of procedure bodies. compiler/static_term.m: Delete this file, since it is no longer needed. compiler/notes/compiler_design.html: Document the deletion of static_term.m. mdbcomp/program_representation.m: Add the definitions related to the structure of the bytecode that are shared by the compiler and the declarative debugger. This includes the representations of determinisms. compiler/code_model.m: To prevent requiring double maintenance, use the facilities now in mdbcomp/program_representation.m to encode determinisms. runtime/mercury_stack_layout.h: compiler/layout.m: compiler/layout_out.m: compiler/opt_debug.m: compiler/stack_layout.m: Replace the proc layout field holding the procedure representation term with the field holding the procedure representation bytecode. runtime/mercury_grade.h: Record the breaking of backward compatibility in debug grades. compiler/options.m: Add an option for use by compiler implementors while implementing changes like this. runtime/mercury_trace_base.[ch]: Add the hash table that caches the results of bytecode translations. trace/mercury_trace_declarative.c: Do not include procedure representations when constructing call nodes, since it is no longer necessary. trace/mercury_trace_internal.c: Update the code that deals with procedure bodies to use the bytecode representation. |
||
|
|
3c60c0e485 |
Change a bunch of modules to import only one module per line, even
Estimated hours taken: 4 Branches: main compiler/*.m: Change a bunch of modules to import only one module per line, even from the library. compiler/mlds_to_il.m: compiler/mlds_to_managed.m: Convert these modules to our current coding style. Use state variables where appropriate. Use predmode declarations where possible. |
||
|
|
601fe20aba |
Simplify the structure of the compiler by removing the cycle
Estimated hours taken: 3.5 Branches: main Simplify the structure of the compiler by removing the cycle parse_tree -> backend_libs -> check_hlds -> parse_tree from the package dependency graph. I've done this by factoring out the code in backend_libs.foreign and backend_libs.name_mangle that is needed by the frontend of the compiler and putting it in a new module, parse_tree.prog_foreign. This removes the dependency between the parse_tree and backend_libs packages. The obvious downside to this is that the name mangler is now split in two, although such a division was always in implicit in the predicates of the name_mangle module anyway, ie. between those bits that operate on the HLDS/MLDS/LLDS level data structures and those that don't. compiler/name_mangle.m: compiler/foreign.m: compiler/prog_foreign.m: Move code for dealing with foreign language procedures that is required by the parse_tree package into a new module, prog_foreign. Update the formatting in some of these modules so that they match our current coding standard. compiler/*.m: Update to reflect the above change. compiler/notes/compiler_design.html: Include the new module. Fix some spelling errors. |
||
|
|
4970242093 |
Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id
Estimated hours taken: 4 Branches: main Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id defined in mdb.declarative_execution and delete proc_id, since these data structures are almost identical. browser/declarative_execution.m Remove proc_id and flat_module_name types. Use mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name instead. browser/declarative_debugger.m browser/declarative_oracle.m browser/declarative_tree.m browser/declarative_user.m Use mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name instead of mdb.declarative_execution.proc_id and mdb.declarative_execution.module_name. mdbcomp/prim_data.m compiler/prog_out.m Move sym_name_to_string from prog_out to prim_data. Fix comment for prog_out.sym_name_and_arity_to_string. compiler/bytecode.m compiler/check_typeclass.m compiler/code_gen.m compiler/deforest.m compiler/higher_order.m compiler/hlds_code_util.m compiler/hlds_error_util.m compiler/hlds_module.m compiler/hlds_out.m compiler/intermod.m compiler/layout_out.m compiler/make.module_target.m compiler/make_hlds.m compiler/mercury_compile.m compiler/mercury_to_mercury.m compiler/ml_elim_nested.m compiler/mlds_to_c.m compiler/mlds_to_gcc.m compiler/mlds_to_il.m compiler/mlds_to_java.m compiler/mlds_to_managed.m compiler/modes.m compiler/modules.m compiler/opt_debug.m compiler/options_file.m compiler/polymorphism.m compiler/prog_io.m compiler/prog_rep.m compiler/rl.m compiler/rl_exprn.m compiler/rl_gen.m compiler/rl_info.m compiler/rl_out.pp compiler/rtti.m compiler/rtti_out.m compiler/rtti_to_mlds.m compiler/source_file_map.m compiler/table_gen.m compiler/trans_opt.m compiler/unify_gen.m compiler/unique_modes.m compiler/unused_args.m Use mdbcomp.prim_data.sym_name_to_string instead of prog_out.sym_name_to_string. |
||
|
|
59d2d4a573 |
This adds a module mdbcomp__trace_counts that reads in the
Estimated hours taken: 17 Branches: main This adds a module mdbcomp__trace_counts that reads in the .mercury_trace_counts files produced by the compiler's trace mechanism. The format of said files was slightly changed. As the new module is to be used by the compiler and the debugger, it is placed in the mdbcomp module. This required bringing some types from the compiler into a new module within mdbcomp. browser/trace_counts.m: New module for reading execution trace summaries. browser/prim_data.m: New module holding types and predicates moved in from the compiler. Types: pred_or_func, sym_name, module_name, proc_label, special_pred_id, trace_port Predicates: string_to_sym_name, insert_module_qualifier The mode field of proc_label is now an int instead of a proc_id to avoid pulling proc_id into mdbcomp. browser/mdbcomp.m: Add trace_counts and prim_data to the mdbcomp module. browser/declarative_execution.m: Renamed mdb's definition of module_name to flat_module_name to avoid conflicts with the definition in mdbcomp__prim_data. runtime/mercury_trace_base.c: In the format of .mercury_trace_counts, write module and predicate names now use quoted atom syntax so that names with spaces and non-printable characters can be machine-parsed. browser/: compiler/: Many changes to account for movement of types, and the change to proc_label. |
||
|
|
42025cecfc |
Allow Aditi to call Mercury. At the moment, this involves Aditi
Estimated hours taken: 200
Branches: main
Allow Aditi to call Mercury. At the moment, this involves Aditi
loading a shared library containing the user's code.
runtime/mercury_aditi.h:
Define a structure MR_Aditi_Proc_Info used to describe
a procedure called by Aditi. Aditi will use dlsym() to
look up these structures in the shared library supplied
by the user.
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/ml_code_util.m:
compiler/mlds_to_gcc.m:
compiler/opt_debug.m:
Add an aditi_proc_info alternative to the rtti_data type,
which corresponds to an MR_AditiProcInfo structure in
the generated code.
In the rtti_proc_label type, record the determinism rather
than the code_model for use by Aditi.
compiler/options.m:
doc/user_guide.texi:
Add an option `--aditi-calls-mercury'.
This is needed for the Aditi tests, which currently don't
handle loading the shared libraries for user defined code.
Move `--aditi' into the compilation model options section.
compiler/rl.m:
Sort the constructors for d.u. types when creating an Aditi
type declaration to make it easier to find a particular
constructor.
compiler/code_model.m:
compiler/stack_layout.m:
Move represent_determinism into code_model.m, for use
by rtti_to_mlds.m.
compiler/rl_exprn.m:
compiler/rl_file.pp:
compiler/rl_out.pp:
compiler/hlds_module.m:
compiler/mercury_compile.m:
Create the procedures for each top-down Mercury goal which
needs to be called from Aditi.
Each created procedure has one input and one output argument,
both of which will have a `{}/N' type.
Allow nondet join conditions.
compiler/rl_exprn.m:
Use record syntax.
compiler/rl_out.pp:
Minor changes to the support for memoing.
runtime/Mmakefile:
runtime/mercury_imp.h:
runtime/mercury.h:
Add mercury_aditi.h.
runtime/mercury_stack_layout.m:
Add a comment about the duplication between MR_DETISM_*
and code_model.represent_determinism.
tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/aditi_calls_mercury.m:
Test case.
Also, enable the Aditi tests in hlc grades.
|
||
|
|
ba38a2d1d2 |
Add a mechanism for collecting information about how many times each event
Estimated hours taken: 8 Branches: main Add a mechanism for collecting information about how many times each event is executed. Later changes will exploit this information, for coverage testing and for better search strategies in the declarative debugger. runtime/mercury_stack_layout.h: Extend the module layout structure to contain a pointer to an array of counters, with one counter for each label layout structure corresponding an event. Extend label layout structures to contain the label's index into this array. The new field fits into a hole in the existing structure required by alignment considerations, so the size of label layout structures is unaffected. The memory cost of the new facility is thus only one word per event. Extend the macros for defining label layout structures to take an extra argument for the new field. runtime/mercury_grade.m: Update the binary compatibility version number for debug grades, since runtimes before this change and the compiler-generated C files in debug grades from after this change are not compatible, and neither are runtimes after this change and the compiler-generated C files in debug grades from before this change. runtime/mercury_trace_base.[ch]: Add a third alternative function to call from MR_trace; besides MR_trace_real (in the trace directory) and MR_trace_fake (in this module), add MR_trace_count, which returns after incrementing the counter of the event's label layout structure. Instead of a single variable, MR_trace_enabled, controlling whether MR_trace is enabled or not and debugging is enabled or not, use two separate variables: MR_trace_func_enabled controlling whether MR_trace is enabled or not, and MR_debug_enabled controlling whether debugging is enabled or not. MR_trace_func_enabled is always set to the disjunction of MR_debug_enabled and a new variable MR_trace_count_enabled, the variable controlling whether the facility for counting label executions is enabled. Add a function for writing out the gathered execution counts. runtime/mercury_trace_base.[ch]: trace/mercury_trace_tables.[ch]: Move the table of module_infos from mercury_trace_tables to mercury_trace_base, since the code to write out execution counts needs it. runtime/mercury_wrapper.c: When MERCURY_OPTIONS contains --trace-count and debugging is not, enable the mechanism for counting the execution of events, and write out the results. library/exception.m: library/io.m: library/table_builtin.m: runtime/mercury_tabling_preds.h: trace/mercury_trace_declarative.c: trace/mercury_trace_external.c: trace/mercury_trace_vars.c: Conform to the changes involving the replacement of MR_trace_enabled. tools/bootcheck: Add an new option, --trace-count, for enabling the new mechanism. compiler/layout.m: Change the compiler's data structures for label layouts and module layouts to conform to the changes in mercury_stack_layout.h. compiler/layout_out.m: Update the code for writing out label layouts and module layouts. compiler/stack_layout.m: Allocate slots in the execution count array to the label layout structures of all events. Delete the unnecessary last arguments of `get' field access predicates. compiler/llds_out.m: compiler/opt_debug.m: Conform to the changes in layout.m. |