mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 13:55:07 +00:00
853622ad8788209e55f3adfbc92e76075d65e32c
99 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
853622ad87 |
Shift most of the STM runtime into the Mercury runtime.
Estimated hours taken: 12 Branches: main Shift most of the STM runtime into the Mercury runtime. Rename a lot of the types and functions used by the STM runtime. Various other fixes and improvements to the STM runtime. library/exception.m: Add a new version of try_stm/4 that is intended for use within atomic blocks by user code. This version filters out and rethrows rollback exceptions. Rename the existing try_stm/4 to unsafe_try_stm/4. library/stm_builtin.m: Move all the STM runtime support from this module into the Mercury runtime. The foreign_procs in this module now just forward their work to the appropriate function or macro there. Rename most of the types and functions associated with STM so that they better conform to our coding standards. Add a unit dummy type for use with atomic blocks that have no outputs, for example atomically swapping the values of two transaction variables. This is needed because the call to unsafe_try_stm introduced by the source-to-source transformation still has to return a value if it succeeds. runtime/mercury_stm.h: runtime/mercury_stm.c: New files containing the runtime support for STM that was in library/stm_builtin.m Define thread identity for the low-level C grades. In such grades it just the context address. Add a macro that returns the identity of the (Mercury) thread that is currently executing. (The implementation of wait queues will need this information.) runtime/mercury_context.c: At program startup initialise the STM lock. runtime/mercury_conf_param.h: Document the macro MR_STM_DEBUG which will be used to enable low-level debugging of the STM runtime. runtime/Mmakefile: Add the new files. |
||
|
|
64b6c216dc |
Remove support for the reserve tag (.rt) grades.
Estimated hours taken: 1 Branches: main Remove support for the reserve tag (.rt) grades. These were only ever needed to support the implementation of Herbrand variables in (older versions of) HAL. NOTE: this change removes the .rt grade, the undocumented reserve_tag pragma is unchanged. runtime/mercury_grade.h: Do not handle the .rt component. Rather than renumbering the grade parts here I have documented that grade part 8 (formerly .rt) is unused. runtime/mercury_tags.h: runtime/mercury_type_info.h: runtime/mercury_conf_param.h: Conform to the above change. compiler/compile_target_code.m: compiler/handle_options.m: compiler/options.m: compiler/make_tags.m: compiler/prog_type.m: Remove the `--reserve-tag' option and modify any code that relied upon it. Such code is largely unchanged since it is still required for the implementation of the reserve_tag pragma. doc/user_guide.texi: Delete documentation for `--reserve-tag'. scripts/canonical_grade.sh-subr: scripts/init_grade_otpions.sh-subr: scripts/mgnuc.in: scripts/parse_grade_options.sh-subr: Remove support for the `.rt' grade component. NEWS: Announce that .rt grades are no longer supported. extras/trailed_update/var.m: extras/trailed_update/samples/Mmakefile: extras/trailed_update/tests/Mmakefile: Update some documentation. tests/debugger/Mmakefile: tests/tabling/Mmakefile: Delete special handling for .rt grades. |
||
|
|
98aae3a961 |
Add a new grade component for use with region-based memory management.
Estimated hours taken: 1 Branches: main Add a new grade component for use with region-based memory management. runtime/mercury_conf_param.h: runtime/mercury_grade.h: compiler/compile_target_code.m: compiler/handle_options.m: compiler/options.m: scripts/canonical_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/mgnuc.in: scripts/parse_grade_options.sh-subr: doc/user_guide.texi: Add the grade component `.rbmm' for use with region-based memory management. |
||
|
|
92966551f1 |
Replace the workaround for the bootstrapping problem with deep profiling grades
Estimated hours taken: 16
Branches: main
Replace the workaround for the bootstrapping problem with deep profiling grades
with a proper fix. The fix requires changing the builtin generic unify and
compare routines by removing the pretest comparing the two argument words
for equality. Since this can alter the algorithmic complexity of the program
(for the worse) which a profiler should definitely avoid, we compensate for
this by adding the pretest to the compiler-generated unify and compare
predicates. Since these pretests are executed even when the deleted pretest
wouldn't be, this can also alter algorithmic complexity (for the better)
at the cost of higher constant factors. However, the likelyhood of such
alteration is much smaller: if the top level of a term doesn't match, chances
are most of the function symbols at the lower levels won't match either.
In any case, the user has the option of getting this better algorithmic
complexity anyway by specifying the new option --should-pretest-equality.
However, until we have more experience with it, the documentation of the
new option is commented out.
runtime/mercury_conf_param.h:
Remove the workaround.
runtime/mercury_unify_compare_body.h:
Remove the problematic pretest, and document the problem that would
occur in its presence. Document the user_by_rtti dummy type
constructor. Fix some misleading abort messages.
compiler/options.m:
Add the --should-pretest-equality option.
Add (commented out) documentation for another option for which it was
missing.
doc/user_guide.texi:
Add (commented out) documentation for the new option, and for some
others which it was missing.
compiler/handle_options.m:
Make deep profiling imply the need for pretests in compiler generated
unify and compare predicates.
compiler/unify_proc.m:
If the new option is set, add pretests to unify and compare predicates.
We have to be careful to make sure that we don't add pretests if they
would try to unify two non-ground terms, or if the unification is
guaranteed to fail (since the casts in the pretest would obscure this
fact).
Implementing this required changing the approach of this module.
Instead of most predicates generating single clauses, they now generate
disjuncts for a disjunction that itself can be put inside the
if-then-else whose condition is the pretest. Since these predicates
not longer generate clauses, their names have been changed accordingly.
compiler/hlds_goal.m:
Add a goal feature for marking an if-then-else as representing
a pretest.
compiler/saved_vars.m:
Handle the new goal feature.
compiler/goal_util.m:
Add a function for stripping pretests away.
compiler/post_term_analysis.m:
compiler/term_constr_build.m:
compiler/term_pass1.m:
compiler/term_pass2.m:
Strip pretests away before termination analysis, since the analysis
can't yet prove termination in the presence of the pretest.
compiler/prog_type.m:
Add some auxilary predicates, and change the signature of an existing
predicate to make it more convenient to use.
compiler/type_util.m:
Conform to the change in prog_type.m, and in the process fix code to
avoid the assumption that the names of standard library modules are
unqualified (since the plan is to put them in package "std").
tests/hard_coded/profdeep_seg_fault.{m,exp}:
Fix the test case to be more readable and to generate properly
line-terminated output, now that we pass it.
BUGS:
Remove the entry for the bug fixed by this diff.
|
||
|
|
360e56cc21 |
Workaround the problem that has been causing the deep profiler to seg fault.
Estimated hours taken: 5 recently, lots more in the past.
Branches: main
Workaround the problem that has been causing the deep profiler to seg fault.
Fix some broken documentation.
Fix some test case failure in deep profiling grades.
runtime/mercury_conf_param.h:
Do not define MR_CHECK_DU_EQ if MR_DEEP_PROFILING is enabled.
The short circuit enabled by the former causes execution to miss a
call to the exit port code, which in turn corrupts the data
structures used by the deep profiler.
runtime/mercury_unify_compare_body.h:
Document the problem with MR_CHECK_DU_EQ and deep profiling.
compiler/options.m:
doc/user_guide.texi:
s/--no-warn-known-bad-format-call/--no-warn-bad-format-calls/
s/--warn-unknown-format-call/--warn-unknown-format-calls/
tests/hard_coded/profdeep_seg_fault.m:
Include an explanation of why this test was failing.
tests/general/Mercury.options:
Run string_format_test_{2,3} with `--no-warn-known-bad-format-calls'
since the implementation of that check catches an exception and
this will cause a compiler built in a deep profiling grade to abort.
tests/invalid/Mmakefile:
Don't run the string_format_bad and string_format_unknown tests
in deep profiling grades for the same reason.
test/hard_coded/Mmakefile:
The test case null_char should not be run in deep profiling grades
since it catches exceptions.
|
||
|
|
c98e978b4b |
Make it easy for the user to select single-precision floats instead of the
Estimated hours taken: 5 Branches: main Make it easy for the user to select single-precision floats instead of the default double-precision floats. This can be done by using the `.spf' grade component, or the option `--single-prec-float'. Code using unboxed floats is incompatible with code using boxed doubles, so we should have a grade for this. NEWS: Mention the changes. compiler/options.m: Add the `--single-prec-float' option (also `--single-precision-float'). Comment out the documentation for `--unboxed-float'. It shouldn't be necessary for users to use it directly any more. compiler/handle_options.m: Handle the `.spf' grade component. Make `--single-prec-float' imply `--unboxed-float'. compiler/compile_target_code.m: Pass `-DMR_USE_SINGLE_PREC_FLOAT' to the C compiler when single-precision floats are enabled. doc/reference_manual.texi: doc/user_guide.texi: Document `.spf' and `--single-prec-float'. runtime/mercury_conf_param.h: Document `MR_USE_SINGLE_PREC_FLOAT' differently now that it is documented in the mmc help and manual. runtime/mercury_float.h: Undefine `MR_BOXED_FLOAT' if `MR_USE_SINGLE_PREC_FLOAT' is defined. runtime/mercury_grade.h: Update the macros that define the MR_GRADE macro to include "_spf" if `MR_USE_SINGLE_PREC_FLOAT' is defined. scripts/canonical_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/mgnuc.in: scripts/parse_grade_options.sh-subr: Update these scripts to support the `.spf' grade component and `--single-prec-float' command-line option. |
||
|
|
b61ea9de44 |
Implement a large chunk of the code that was previously missing for .mmos
Estimated hours taken: 20 Branches: main Implement a large chunk of the code that was previously missing for .mmos grades. The system now correctly computes several answers for the tc_minimal test case, before going into an infinite loop (since the code for recognizing the absence of further solutions is not yet there). Significantly improve the infrastructure for debugging such changes. compiler/table_gen.m: Complete the mmos transformation. compiler/proc_gen.m: Handle the special return requirements of mmos generators, which must return not to a caller (since each generator is the root of its own SLD tree), but to a consumer in another SLD tree that is waiting for an answer. compiler/hlds_pred.m: Provide a mechanism whereby table_gen.m can communicate to proc_gen.m the requirement for this special return. compiler/trace_gen.m: When generating events, include the port and the goal path in a comment. This makes the generated C code significantly easier to understand. compiler/layout_out.m: Export a function for trace_gen.m to use. compiler/hlds_goal.m: Change goal_path_to_string to a function to make it easier to use. compiler/*.m: Conform to the change to goal_path_to_string. runtime/mercury_context.[ch]: In .mmos grades, include the current debugger call sequence number, depth, and event number in contexts, to be saved and loaded with the contexts. This allows each context to have its own separate sequence of events. This capability depends not directly on the grade, but on the macro MR_EXEC_TRACE_INFO_IN_CONTEXT. For now, this is defined only in .mmos grades, but in future, it may be useful in other grades as well. runtime/mercury_conf_param.h: Define and document MR_EXEC_TRACE_INFO_IN_CONTEXT. runtime/mercury_mm_own_stacks.[ch]: runtime/mercury_tabling_preds.h: Implement some predicates needed by the own stack transformation. Implement the code for generators returning answers to consumers, and the code for consumers scheduling generators when they need more answers. At the moment, the code for detecting when generators depend on each other is not yet written. Provide better facilities for debugging own stack minimal model grades. Fix a cut-and-paste bug (wrong macro name guarding the handwritten C module). runtime/Mmakefile: Rebuild only what needs to be rebuilt when mercury_tabling_preds.h changes. runtime/mercury_label.[ch]: Add a utility function for returning the name of an arbitrary label (internal or entry). Rename some fields to give them MR_ prefixes. Always define the functions for recording both entry and internal labels, even if they are not called from most modules, since they may be called from a few handwritten modules in the runtime. Rename a function to avoid a clash with the name of a macro, and thus allow the change to mercury_goto.h. runtime/mercury_goto.h: Fix a bug with MR_init_entry_an. This macro was supposed to always insert the entry label that is its argument into the entry table, but instead of calling the function it was meant to call, it called a macro that could be (and usually way) defined to expand to nothing. The fix is to call the function a different name than the macro, and to call the function, not the macro. runtime/mercury_wrapper.c: In own stack minimal model grades, create a main context separate from the current context, since the current context may be needed to hold a generator's state. Make MR_eng_this_context point to this context. Register all labels in the debugging variants of minimal model grades. runtime/mercury_accurate_gc.c: runtime/mercury_agc_debug.c: runtime/mercury_debug.c: library/exception.m: Conform to the change to runtime/mercury_label.h. runtime/mercury_stack_trace.c: Conform to the change to runtime/mercury_label.h. Document the link to trace/mercury_trace_internal.c. trace/mercury_trace.[ch]: trace/mercury_trace_cmd_forward.c: Split the GOTO command into two: STEP and GOTO. STEP always stops at the next event (without any test), even if it is in a different context (and possibly with a lower event number than the immediately previous event, since the event numbers in different contexts are not related). As before, GOTO always goes to the specified event number, but in .dmmos grades it can now be told that this event number should be matched only in a specified context. The specification is done by an extra argument specifying the short name of the context's generator; the ansence of such an argument means the main context. trace/mercury_trace_cmd_internal.c: In own stack grades, when the current context is that of a generator, print the subgoal the generator is working on before the event number, call depth, call sequence number and the rest of the event report. Document the link to runtime/mercury_stack_trace.c, which has similar code. trace/mercury_trace_cmd_external.c: trace/mercury_trace_cmd_declararive.c: Use the STEP command where GOTO was used for this simpler job, since this is (very slightly) faster. trace/mercury_trace_cmd_developer.c: Fix some bugs with handling own stack tables. doc/user_guide.texi: Document the new functionality of the goto mdb command. The documentation is commented out, since .mmos grades are for developers only at the moment. tools/lmc.in: Turn off C optimizations when C debugging is enabled. For some reason, the default value of --cflags-for-debug does not include -O0. |
||
|
|
ec14dc9c0a |
Expand an explanation.
Estimated hours taken: 0.1 Branches: main runtime/mercury_conf_param.h: Expand an explanation. |
||
|
|
2c7289a290 |
Add conditionally compiled code that can be used to generate a machine
Estimated hours taken: 2 Branches: main runtime/mercury_deep_call_port_body.h: runtime/mercury_deep_leave_port_body.h: runtime/mercury_deep_redo_port_body.h: Add conditionally compiled code that can be used to generate a machine processable log of the updates to the deep profiling tree. Convert to four-space indentation. runtime/mercury_deep_profiling.[ch]: Add support for the new code in the port bodies, and add a mechanism for writing out proc statics and call sites statics at the start of the same machine processable log. runtime/mercury_wrapper.c: Switch on the new debugging mechanism if the --deep-log-file or --deep-log-prog option is given in MERCURY_OPTIONS. runtime/mercury_conf_param.h: Document the macro controlling the new logging mechanism. |
||
|
|
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.) |
||
|
|
e8415df212 |
Enhance the deep profiler by including in the output a measure of execution
Estimated hours taken: 0.5
Branches: main
Enhance the deep profiler by including in the output a measure of execution
time that has much finer granularity than clock ticks: a count of procedure
calls. The deep profiler does not yet display this data; that is for a later
diff.
runtime/mercury_deep_profiling.[ch]:
Add a field containing this counter if the appropriate macro is
defined. Initialize the new field when the profiling metrics structure
it is in is initialized.
Use masks that fit into one byte for the commonly needed fields
of the profiling metrics structure.
runtime/mercury_conf_params.h:
Define this macro in deep profiling grades unless its absence is
expressly requested (for performance tests of the deep profiler
itself).
runtime/mercury_grade.h:
Increment the binary compatibility number for the deep profiling
grades.
runtime/mercury_deep_{call,redo,leave}_port_body.h:
Update the call sequence number global at call sites.
Update the new field when control enters a procedure invocation
through the call or redo ports, and when it leaves the invocation
through the exit or fail ports.
library/exception.m:
Update the new field when control leaves a procedure invocation
through the excp port.
deep_profiler/measurements.m:
Include the new field in the deep profiler's version of the
profiling metric structure.
deep_profiler/read_profile.m:
Read in the updated format now generated by the runtime.
deep_profiler/dump.m:
Include the new field in any dumps of the deep profiler's
internal data structures.
|
||
|
|
898534b36d |
Restore low-level debugging to working state.
Estimated hours taken: 0.5 Branches: main Restore low-level debugging to working state. runtime/mercury_conf_param.h: Fix typos. runtime/mercury_overflow.h: runtime/mercury_wrapper.c: Update references to outdated field names. |
||
|
|
6850026224 |
Delete a doubled up word.
runtime/mercury_conf_param.h: Delete a doubled up word. |
||
|
|
5062c83094 |
Try to reduce the probability of any bug such as the one reported by
Estimated hours taken: 2 Branches: main Try to reduce the probability of any bug such as the one reported by Peter Ross happening again. library/construct.m: Make sure that the relevant switches list all the values of the enum type the switch is on, since this way gcc will generate a warning message if the enum has a value added to it and the switch isn't updated. Include the defaults only if MR_INCLUDE_SWITCH_DEFAULTS is defined; the intention is that this may be useful with non-gcc compilers. Generate separate, more specific error messages for each type_ctor_rep. library/deconstruct.m: Delete some old code that we haven't used in a while, and which we won't want to use in the future either. (The deleted predicate worked on the data representation scheme of the running compiler, whereas we wanted it to work on the data representation scheme of the generated program, which may be different.) I found this when inspecting all uses of switch defaults in the library. runtime/mercury_conf_params.h: Document MR_INCLUDE_SWITCH_DEFAULTS. |
||
|
|
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.
|
||
|
|
4868afa1fb |
Various changes to make Mercury more compatible with Windows.
Estimated hours taken: 10 Branches: main and 0.12 Various changes to make Mercury more compatible with Windows. configure.in: Turn off symbolic links when compiling in cygwin. Previously the configure script checked for certain compiler names or whether the --mno-cygwin option was passed to gcc, however this check is not good enough since the user may specify the mingw version of gcc using the --with-cc option. compiler/mercury_compile.m: mdbcomp/trace_counts.m: Use rstrip to remove trailing newlines, since on Windows there may be more than one character at the end of each line (a newline and a carriage return or line feed - I can't remember which). compiler/passes_aux.m: Remove invoke_shell_command since it is not used anywhere and according to the comment won't work on Windows. If on windows do not use `2>&1' to redirect standard error since this doesn't work on windows 98 and 95 (and possibly other versions too). runtime/mercury_conf_param.h: Use #ifdef instead of just #if when checking for _WIN32. Previously this caused Mercury to use `/' as the directory separator on Windows when it should have used `\'. |
||
|
|
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. |
||
|
|
c0607822b2 |
Complete the first draft of the program transformation for the own minimal
Estimated hours taken: 12 Branches: main Complete the first draft of the program transformation for the own minimal model of minimal model evaluation. The runtime system is still very incomplete. Nothing in this diff changes anything related to non-mmos grades. compiler/table_gen.m: Change the implementation of the own stack transformation from the previous rough sketch to this first draft. It still uses calls to library predicates instead of inlined foreign_procs in some places, but that will be fixed later. Generalize the infrastructure for handling arguments to associate the position and mode with each argument variable, since this is needed for mechanism the own stack transformation uses to transfer the input arguments from the consumer to the generator. Switch to four-space indentation to avoid a bunch of bad line breaks. Conform to the current style for comments. compiler/complexity.m: Rename some predicates to avoid clashes with similarly named predicates in table_gen.m in the tags file. library/table_builtin.m: Add the library predicates the new tabling transformation needs to hang foreign_procs on. Comment out C code fragments that refer to as-yet-nonexistent C macros or functions, to allow the compiler to link in mmos grades. The predicates in which this happens aren't used yet. Conform to the current style for comments. runtime/mercury_conf_param.h: Document the minimal model tabling's requirement for gc that doesn't recover memory on backtracking. runtime/mercury_mm_own_stacks.[ch]: Revise the mechanism for creating new generators, and add an outline of its implementation. Comment out code that doesn't compile yet. Add the globals we need for communicating the input arguments and the location of the generator structure from the consumer to the newly created generator. runtime/mercury_tabling.h: Fix a bug: the table tip node is a generator, not a consumer. runtime/mercury_tabling_preds.h: Replace the previous placeholder definitions of some macros with drafts of actual definitions. runtime/mercury_context.h: Conform to the current style for comments. Switch to four-space indentation to avoid a bunch of bad line breaks. trace/mercury_trace_internal.c: Conform to the change in mercury_tabling.h. |
||
|
|
0126a01164 |
Add a mechanism, conditional on #ifdef MR_CHECK_DU_EQ, for testing
Estimated hours taken: 2 Branches: main runtime/mercury_unify_compare_body.h: Add a mechanism, conditional on #ifdef MR_CHECK_DU_EQ, for testing whether two values are bit-for-bit identical before invoking any of the more specific unify or compare code. Fix some old bugs which showed up only with -DMR_COMPARE_BY_RTTI: we were invoking some macros with the wrong number of arguments. runtime/mercury_conf_param.h: Document MR_CHECK_DU_EQ. Turn it on unless another macro, MR_DISABLE_CHECK_DU_EQ, is defined. This improves performance by six percent. (Thanks to Ralph for the reminder to evaluate this again. When I tried this several years ago, it was a performance loss.) tests/debugger/uci.exp2: Add this new expected output file for this test. While uci.exp contains the expected output without -DMR_CHECK_DU_EQ, uci.exp2 contains the expected output with it, since we no longer get calls to the type-specific unify and compare predicates in some cases. |
||
|
|
6ab59f41ab |
Provide a mechanism for gathering sets of trace counts from both passed and
Estimated hours taken: 6 Branches: main Provide a mechanism for gathering sets of trace counts from both passed and failed test cases. runtime/mercury_trace_base.[ch]: Instead of writing out trace counts to a file with a fixed name, write it out to a file whose name includes the name of the executable and the process id. Export only the functions that need to be exported. Add sanity checking code that looks for and reports occurrences of a situation reported by Peter Wang: positive counts for internal events in a procedure with a missing (and hence zero) count for the CALL event of that same procedure. Make this sanity check conditional on the new configuration macro MR_TRACE_COUNT_DEBUG. The sanity check did not find any anomalies during any of my bootchecks. runtime/mercury_conf_param.h: Document MR_TRACE_COUNT_DEBUG. tests/Mmake.common: tests/run_one_test: Move the code for executing one test from a very long action in Mmake.common to the new shell script run_one_test, to make it possible to edit it without having to worry about line continuations. tests/run_one_test: Make the code for executing one test move the trace count files generated by the test, if any, to the directory for passed or failed test cases, and record their names. Add a mechanism for creating a timestamp file for each test. tools/bootcheck: Clean up the files and directories containing trace counts information from a previous bootcheck before running the tests this time. Add an option --progress, that creates a timestamp file for each test. This allows users to gauge the rate at which bootcheck executes test cases, and provides the information required for detecting performance problems that manifest themselves as slow test case execution. Allow the --trace-count option to be spelt --trace-counts. Since run_one_test now gathers a list of failed test in a much cleaner format than before (a simple list of the names of failed test cases, complete with their directories), print this list at the end of the output. This saves having to grep for FAILED TEST in the output file. The existing --failing-tests option did "dumpster diving" to discover the list of failing test cases, and rerun only them. This behavior is still available as the --error-file option, but --failing-tests now uses the much simpler record of which tests failed to repeat only failed tests. The new --specified-test option allows the rerunning of only a single test. This way, "tools/bootcheck -b- -s debugger/queens" will rerun only the queens test in the debugger directory. While you can often compile and run test cases by hand, it is difficult to compile and run them the same way as bootcheck does, especially for multi-module programs. This way, one can use the bootcheck script as a scalpel, not a club. Make this file use four-space indentation. tests/Mmake.common: Clean up any stray trace count files. Implement the infrastructure required for --specified-test. tests/debugger/Mmakefile: Conform to the new naming scheme for trace counts files. |
||
|
|
e854a5f9d9 |
Major improvements to tabling, of two types.
Estimated hours taken: 32
Branches: main
Major improvements to tabling, of two types. The first is the implementation
of the loopcheck and memo forms of tabling for model_non procedures, and the
second is a start on the implementation of a new method of implementing
minimal model tabling, one that has the potential for a proper fix of the
problem that we currently merely detect with the pneg stack (the detection
is followed by a runtime abort). Since this new method relies on giving each
own generator its own stack, the grade component denoting it is "mmos"
(minimal model own stack). The true name of the existing method is changed
from "mm" to "mmsc" (minimal model stack copy). The grade component "mm"
is now a shorthand for "mmsc"; when the new method works, "mm" will be changed
to be a shorthand for "mmos".
configure.in:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/final_grade_options.sh-subr:
compiler/options.m:
Handle the new way of handling minimal model grades.
scripts/mgnuc.in:
compiler/compile_target_code.m:
Conform to the changes in minimal model grade options.
compiler/table_gen.m:
Implement the transformations required by the loopcheck and memo
tabling of model_non procedures, and the minimal model own stack
transformation.
The new implementation transformations use foreign_procs with extra
args, since there is no point in implementing them both that way and
with separate calls to library predicates. This required making the
choice of which method to use at the top level of each transformation.
Fix an oversight that hasn't caused problems yet but may in the future:
mark goals wrapping the original goals as not impure for determinism
computations.
compiler/handle_options.m:
Handle the new arrangement of the options for minimal model tabling.
Detect simultaneous calls for both forms of minimal model tabling,
and generate an error message. Allow for more than one error message
generated at once; report them all once rather than separately.
compiler/globals.m:
Add a mechanism to allow a fix a problem detected by the changes
to handle_options: the fact that we currently may generate a usage
message more than once for invocations with more than one error.
compiler/mercury_compile.m:
compiler/make.program_target.m:
compiler/make.util.m:
Use the new mechanism in handle_options to avoid generating duplicate
usage messages.
compiler/error_util.m:
Add a utility predicate for use by handle_options.
compiler/hlds_pred.m:
Allow memo tabling for model_non predicates, and handle own stack
tabling.
compiler/hlds_out.m:
Print information about the modes of the arguments of foreign_procs,
since this is useful in debugging transformations such as tabling
that generate them.
compiler/prog_data.m:
compiler/layout_out.m:
compiler/prog_out.m:
runtime/mercury_stack_layout.h:
Mention the new evaluation method.
compiler/goal_util.m:
Change the predicates for creating calls and foreign_procs to allow
more than one goal feature to be attached to the new goal. table_gen.m
now uses this capability.
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/polymorphism.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/typecheck.m:
compiler/unify_proc.m:
Conform to the changes in goal_util.
compiler/code_info.m:
compiler/make_hlds.m:
compiler/modules.m:
compiler/prog_io_pragma.m:
Conform to the new the options controlling minimal model
tabling.
compiler/prog_util.m:
Add a utility predicate for use by table_gen.m.
library/std_util.m:
Conform to the changes in the macros for minimal model tabling grades.
library/table_builtin.m:
Add the types and predicates required by the new transformations.
Delete an obsolete comment.
runtime/mercury_grade.h:
Handle the new minimal model grade component.
runtime/mercury_conf_param.h:
List macros controlling minimal model grades.
runtime/mercury_tabling.[ch]:
Define the types needed by the new transformations,
Implement the performance-critical predicates that need to be
hand-written for memo tabling of model_non predicates.
Add utility predicates for debugging.
runtime/mercury_tabling_preds.h:
Add the implementations of the predicates required by the new
transformations.
runtime/mercury_mm_own_stacks.[ch]:
This new module contains the first draft of the implementation
of the own stack implementation of minimal model tabling.
runtime/mercury_imp.h:
Include the new file if the grade needs it.
runtime/Mmakefile:
Mention the new files, and sort the lists of filenames.
runtime/mercury_tabling_macros.h:
Add a macro for allocating answer blocks without requiring them to be
pointed to directly by trie nodes.
runtime/mercury_minimal_model.[ch]:
The structure type holding answer lists is now in mercury_tabling.h,
since it is now also needed by memo tabling of model_non predicates.
It no longer has a field for an answer num, because while it is ok
to require a separate grade for debugging minimal model tabling,
it is not ok to require a separate grade for debugging memo tabling
of model_non predicates. Instead of printing the answer numbers,
print the answers themselves when we need to identify solutions
for debugging.
Change function names, macro names, error messages etc where this is
useful to distinguish the two kinds of minimal model tabling.
Fix some oversights wrt transient registers.
runtime/mercury_context.[ch]:
runtime/mercury_engine.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
With own stack tabling, each subgoal has its own context, so record
the identity of the subgoal owning a context in the context itself.
The main computation's context is the exception: it has no owner.
Record not just the main context, but also the contexts of subgoals
in the engine.
Add variables for holding the sizes of the det and nondet stacks
of the contexts of subgoals (which should in general be smaller
than the sizes of the corresponding stacks of the main context),
and initialize them as needed.
Initialize the variables holding the sizes of the gen, cut and pneg
stacks, even in grades where the stacks are not used, for safety.
Fix some out-of-date documentation, and conform to our coding
guidelines.
runtime/mercury_memory_zones.[ch]:
Add a function to test whether a pointer is in a zone, to help
debugging.
runtime/mercury_debug.[ch]:
Add some functions to help debugging in the presence of multiple
contexts, and factor out some common code to help with this.
Delete the obsolete, unused function MR_printdetslot_as_label.
runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
Move a bootstrapping #define from mercury_context.h to
mercury_bootstrap.h.
runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
Move a bootstrapping #define from mercury_context.h to
mercury_bootstrap.h.
runtime/mercury_types.h:
Add some more forward declarations of type names.
runtime/mercury_dlist.[ch]:
Rename a field to avoid assignments that dereference NULL.
runtime/mercury_debug.c:
runtime/mercury_memory.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_stacks.[ch]:
trace/mercury_trace_util.c
Update uses of the macros that control minimal model tabling.
runtime/mercury_stack_trace.c:
Provide a mechanism to allow stack traces to be suppressed entirely.
The intention is that by using this mechanism, by the testing system
won't have to provide separate .exp files for hlc grades, nondebug
LLDS grades and debug LLDS grades, as we do currently. The mechanism
is the environment variable MERCURY_SUPPRESS_STACK_TRACE.
tools/bootcheck:
tools/test_mercury:
Specify MERCURY_SUPPRESS_STACK_TRACE.
trace/mercury_trace.c:
When performing retries across tabled calls, handle memo tabled
model_non predicates, for which the call table tip variable holds
a record with a back pointer to a trie node, instead of the trie node
itself.
trace/mercury_trace_internal.c:
When printing tables, handle memo tabled model_non predicates. Delete
the code now moved to runtime/mercury_tabling.c.
Add functions for printing the data structures for own stack minimal
model tabling.
tests/debugger/print_table.{m,inp,exp}:
Update this test case to also test the printing of tables for
memo tabled model_non predicates.
tests/debugger/retry.{m,inp,exp}:
Update this test case to also test retries across memo tabled
model_non predicates.
tests/tabling/loopcheck_nondet.{m,exp}:
tests/tabling/loopcheck_nondet_non_loop.{m,exp}:
New test cases to test loopcheck tabled model_non predicates.
One test case has a loop to detect, one doesn't.
tests/tabling/memo_non.{m,exp}:
tests/tabling/tc_memo.{m,exp}:
tests/tabling/tc_memo2.{m,exp}:
New test cases to test memo tabled model_non predicates.
One test case has a loop to detect, one has a need for minimal model
tabling to detect, and the third doesn't have either.
tests/tabling/Mmakefile:
Add the new test cases, and reenable the existing tc_loop test case.
Rename some make variables and targets to make them better reflect
their meaning.
tests/tabling/test_mercury:
Conform to the change in the name of the make target.
|
||
|
|
cdf0383b52 |
Fix a bunch of problems with tabling that I identified in Uppsala.
Estimated hours taken: 32
Branches: main
Fix a bunch of problems with tabling that I identified in Uppsala. These fall
into two categories.
First, the tabling transformations we were using were dividing work up
too finely. This had three bad effects. First, it caused too much time to be
spent on transmitting data to and from library predicates. Second, it made the
transformations hard to document and hard to explain in a paper. Third, it
caused us to misidentify just what the various forms of tabling have in common,
and what forms of tabling work for what determinisms. To fix this problem,
this diff reorients table_builtin.m and table_gen.m from being divided
primarily by determinism to being divided by evaluation method.
Second, we weren't being careful in separating out the parts of the tabling
data structures that are needed only for debugging the tabling system itself.
The fix for this is to introduce a new grade flag, MR_MINIMAL_MODEL_DEBUG,
intended for use by implementors only, to govern whether the tabling data
structures include debug-only components. (If this flag weren't a grade flag,
the sizes of data structures created in files with different values of this
flag could be inconsistent, which is something you don't want when debugging
the complex code of the tabling infrastructure.)
compiler/table_gen.m:
Reorganize the simple (loopcheck and memo) tabling transformations
completely. Instead of separate transformations for model_det and
model_semi predicates, have separate transformations for loopcheck
and memo predicates, since this makes it easier to see (and to ensure)
that the transformation follows the required scheme. Instead of
generating nested if-then-elses, generate switches when possible.
For model_semi loopcheck and memo predicates, generate Mercury code
that obeys our scope rules by not binding output variables in the
condition of the one remaining if-then-else.
Finetune the minimal model tabling transformation by combining some
operations where this improves clarity and performance.
Order the transformation predicates logically, and move the
documentation of each form of tabling next to the code implementing
that form of tabling.
Attach call_table_gen markers to the setup goals that now all
loopcheck, memo and minimal model tabled predicates have,
to avoid having to special case the last lookup goal, and to avoid
having to have separate code for lookups in call tables versus answer
tables.
Generate unique and more meaningful variable names. Change some
predicate names to be more meaningful, both here and in the
transformed code.
Factor out some common code, e.g. for generating lookup goals,
for generating instmap_deltas and for attaching hide_debug_event
markers to goals.
Report errors in cases where the arguments of a tabled predicate
aren't completely input or output.
compiler/hlds_pred.m:
Be more strict about the determinisms of tabled predicates; permit
only the determinisms we really support in all cases, and do not
permit the ones that may happen to work in some cases.
Conform to the change of the name of a builtin.
compiler/det_report.m:
Improve the error message for cases when the determinism is
incompatible with the selected tabling mechanism.
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/options.m:
Handle the new grade component.
library/private_builtin.m:
Provide a semipure analog of the imp predicate, a call to which makes
predicates semipure rather than impure, for use in table_builtin.m.
library/table_builtin.m:
runtime/mercury_tabling_preds.h:
Change the tabling primitives in the ways required by the changes to
the tabling transformations.
Group the primitives by the tabling methods they support, and change
their names to reflect this.
Change the implementation of each of the affected predicates to be
nothing more than the invocation of a macro defined in the new header
file runtime/mercury_tabling_preds.h. The objective of this change
is to make it possible for table_gen.m to replace sequences of calls
to predicates in table_builtin.m with a single extended foreign_proc
goal whose body just invokes the corresponding macros in sequence.
That change should improve performance by allowing the variables
that flow from one tabling primitive to another to stay in x86
registers, instead of being copied to and from Mercury abstract
machines registers, which on the x86 aren't real machine registers.
Benchmarking in Uppsala verified that this is a major cost.
Mark the foreign types used for tabling as can_pass_as_mercury_type;
this was the intended use of that assertion. Make them private to the
module, since the rest of the compiler can now handle this.
Delete the implementations of the predicates for duplicate checking
and for returning answers for completed subgoals. Profiling with gprof
has shown their performance to be critical to the performance of
minimal model tabling overall, and even with our recent changes,
the compiler still can't create optimal C code for them. They are
now implemented with handwritten code in mercury_minimal_model.c.
library/term.m:
Add two utility predicates for use by table_gen.m.
library/Mmakefile:
Since much of the implementation of table_builtin.m is now in
runtime/mercury_tabling_preds.h, make its object files depend
on that header file.
runtime/mercury_conf_params.h:
runtime/mercury_grade.h:
Include MR_MINIMAL_MODEL_DEBUG when computing the grade.
runtime/mercury_minimal_model.[ch]:
Add handwritten code to implement the predicates declared as external
in table_builtin.m.
Conform to the new names of the suspension and completion predicates.
Conform to the presence of debugging fields in tabling data structures
only if MR_MINIMAL_MODEL_DEBUG is defined.
Collect a lot more statistics than before.
Reorder some functions.
Instead of saving the whole generator stack each time, which the new
statistics showed to have O(n^2) behavior on some benchmarks, save only
the segment we need to save.
runtime/mercury_tabling.h:
Conform to the fact that loopcheck and memo predicates now have
separate sets of status values, and import mercury_tabling_preds.h.
runtime/mercury_tabling.c:
runtime/mercury_hash_lookup_or_add_body.h:
Move a huge macro out of mercury_tabling.c to the new file
mercury_hash_lookup_or_add_body.h for ease of editing, and modify it to
gather more statistics.
Make the statistics report easier to read.
runtime/Mmakefile:
Mention mercury_tabling_preds.h and mercury_hash_lookup_or_add_body.h.
runtime/mercury_wrapper.h:
Provide a mechanism (--tabling-statistics in MERCURY_OPTIONS)
that causes the runtime to print tabling statistics at the ends of
executions, for use in benchmarking.
doc/user_guide.texi:
Document --tabling-statistics. (Minimal model tabling is not yet
stable enough to be documented, which is why .dmm isn't documented
either.)
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/mgnuc.in:
Implement the new grade component.
trace/mercury_trace.c:
trace/mercury_trace_internal.c:
Conform to changes in the runtime.
tests/debugger/*.m:
Avoid now invalid combinations of determinism and evaluation method.
tests/debugger/*.exp:
Conform to new goal paths in procedures transformed by tabling.
tests/tabling/*.m:
For tests which had predicate whose determinisms isn't compatible
with the evaluation method, change the determinism if possible,
and the evaluation method otherwise, if either is possible.
Bring these tests up to date with our coding guidelines, since they
may now appear in papers.
tests/tabling/Mmakefile:
Disable the tests whose combination of determinism and evaluation
method is no longer supported, and in which neither one can be changed.
tests/tabling/loopcheck_no_loop.{m,exp}:
Make this test case tougher.
tests/tabling/test_tabling:
Make this script more robust in the face of different kinds of
test case failures.
tests/invalid/loopcheck.{m,err_exp}:
tests/invalid/Mmakefile:
Test that we get the expected error message for an invalid combination
of determinism and evaluation method. The new test invalid/loopcheck.m
is the old test tabling/loopcheck.m.
tests/valid/Mmakefile:
Use a more general pattern to test for minimal model grades,
now that we also use .dmm as a grade component.
|
||
|
|
c80d143cc8 |
The following change is only 98% complete, not 100%.
Estimated hours taken: 120
Branches: main
The following change is only 98% complete, not 100%. I am committing it in
this state because (1) we pass many more test cases in deep profiling grade
with it than without it, and (2) the double maintanance involved in fixing
CVS conflicts is preventing me from doing the last 2%.
Get the deep profiler to work for code that sets up to catch exceptions,
which for the last year or more has included the compiler, and to get it
almost working for code that actually catching exceptions.
The basic problem is that code that throws exceptions will in general cause
several calls to "return" without executing the exit or fail port codes that
the deep profiling transformation inserted into their bodies, and this leaves
the data structure being built by the deep profiling inconsistent. The solution
uses the same approach as we have adopted for the debugger: have the code that
handles the throwing of exceptions simulate a return from each call between
the throw and the catch, updating the deep profiling data structures as needed.
This requires us to be able to walk the stack at runtime not just in debugging
grades but also in deep profiling grades. Since the debugger already has the
mechanisms required for this, we reuse them. The procedure layouts used by the
debugger were designed to have three segments: the procedure stack walk
information, the procedure id, and the execution tracing information. We now
modify this design to make the third segment contain two pointers: to the
execution tracing information (for use by the debugger), and to the procedure's
proc_static structure (for use by deep profiling). Each pointer will be null
unless the pointed-to structure is required by compile-time options.
This common use by the debugger and by deep profiling of the stack-walk
structure and the procedure id structure (which deep profiling used to
generate independently and possibly redundantly) required some rearrangement
of the compiler's version of these data structures.
To make this rearrangement simpler, this diff removes a capability that
we theoretically supported but never used: turning on stack traces without
turning on execution tracing and vice versa. After this diff, stack tracing
is enabled if and only if either execution tracing or deep profiling is
enabled.
The diff also includes improvements in the debugging infrastructure for
debugging deep profiling, which were necessary for the implementation of the
rest of the changes.
compiler/deep_profiling.m:
The code in exception.m needs to know the locations of the variables
that we would pass to the exit or fail port code, so it can simulate
leaving the procedure invocation through the exception port. Without
this information, throwing an exception leaves the deep profiling
data structures of the procedure invocations between throw and catch
in an inconsistent state.
Deep_profiling.m creates these variables, but it doesn't know where
they will be at runtime, so it records their identities; the code
generator will allocate them stack slots and record the numbers of
these stack slots for placement in the now expanded proc layout
structures. Deep profiling used to generate static data structures
separately from the HLDS, but since the code generator now needs
access to them, we store their information in proc_infos in the HLDS.
Instead of passing the addresses of proc_static structures to the deep
profiling port procedures, pass the address of proc_layout structures,
since the information about the identities of procedures are now stored
not in the proc_static structure, but in the proc_layout structure
that points to the proc_static structure.
compiler/hlds_pred.m:
compiler/layout.m:
Move the definitions of the static data structures generated by deep
profiling from layout.m to hlds_pred.m, to allow deep_profiling.m
to store them in proc_infos.
compiler/hlds_pred.m:
compiler/rtti.m:
Move the definition of rtti_proc_label from rtti.m to hlds_pred.m,
since some of the new data structures in hlds_pred.m need it. Despite
its name, the rtti_proc_label type doesn't contain any info that
doesn't belong in the HLDS.
Add some information to the rtti_proc_label type that is now needed
by deep profiling, e.g. record determinisms instead of just code
models. Record explicitly the outcome of some tests that used to be
duplicated in more than one place in the compiler, e.g. for whether
the procedure (as opposed to the predicate) is imported. Change some
of the field names to be more precise about the field's meaning.
compiler/code_gen.m:
Transmit the contents of the deep profiling data structures stored in
the proc_info by deep_profiling.m to continuation_info.m, together
with the layout structures created for execution tracing and the
identities of the variables needed for handling exceptions,
when code generation for a procedure is complete.
After the goal that generates these variables, save them to stack
for use by the exception handler.
compiler/hlds_goal.m:
Add a feature to mark the goal that generates the deep profiling
variables needed by the exception handler.
compiler/hlds_llds.m:
Add a utility predicate for new code in code_gen.m
compiler/continuation_info.m:
Hold the deep profiling information computed by code_gen.m for use by
stack_layout.m.
compiler/layout.m:
compiler/layout_out.m:
Update the definitions of the data structures describing procedure
layouts, and the code writing them out, to reflect the use of some
parts of procedure layouts by deep profiling as well as debugging.
Change the layout structures generated by deep profiling to use
rtti_proc_labels, which are backend independent, instead of
proc_labels, which are specific to the LLDS backend.
Conform to the changes in runtime/mercury_stack_layout.h.
compiler/stack_layout.m:
Generate the updated version of proc_layout structures.
compiler/mercury_compile.m:
compiler/global_data.m:
Conform to the fact that deep profiling no longer generates layout
structures separate from proc_infos.
compiler/llds_out.m:
Register proc_layout structures instead of proc_static structures
for use by runtime/mercury_deep_profiling.c.
compiler/options.m:
compiler/handle_options.m:
Rename the require_tracing option as exec_trace, since this more
directly reflects its meaning.
Instead of having --debug set both require_tracing and stack_trace,
make it set (be the user-visible name of) just exec_trace;
the value of stack_trace is implied.
Turn off the specialization of deep profiling for self-tail-recursive
procedures for now. Due to the changes made by this diff in the data
structures involved in debugging, it cannot be debugged until this
change has been installed. Handling the full language is more important
than a specialization that reduces only stack space overheads, not
runtime overheads.
compiler/compile_target_code.m:
Conform to the changes in options.m and runtime/mercury_grade.h.
compiler/hlds_data.m:
Replace the deep_profiling_proc_static cons_id, and its associated tag,
to deep_profiling_proc_layout, since we now generate addresses of proc
layout structures, not of proc_static structures.
compiler/code_util.m:
Simplify some code based on the new info in rtti_proc_labels.
compiler/bytecode_gen.m:
compiler/dependency_graph.m:
compiler/higher_order.m:
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_util.m:
compiler/ml_unify_gen.m:
compiler/opt_debug.m:
compiler/proc_label.m:
compiler/prog_rep.m:
compiler/rl_exprn.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/switch_util.m:
compiler/unify_gen.m:
Minor changes to conform to the change from deep_profiling_proc_static
to deep_profiling_proc_layout, to the change in the structure of
rtti_proc_labels, to the changes in types of layout.m, and/or to the
new goal feature.
deep_profiler/measurements.m:
Reserve space for exception counts.
deep_profiler/html_format.m:
Add a column for exception counts.
deep_profiler/profile.m:
deep_profiler/read_profile.m:
Rename the data structures referring to compiler generated unify,
compare and index predicates to avoid misleading names: they are
not the only compiler generated predicates.
deep_profiler/read_profile.m:
runtime/mercury_deep_profiling.c:
Update the string that identifies deep profiling data files.
This is necessary because the format has changed: it now includes
information about exception port counts.
library/exception.m:
In deep profiling grades, execute the exception port code for every
procedure invocation between a throw and a catch, using the procedure
layout structures now generated by the compiler for every procedure.
Rename the function involved to reflect its new, more general purpose.
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code.
Indent C preprocessor directives and foreign_procs according to our
coding standards.
library/profiling_builtin.m:
Change the parameters of the call port code procedures from proc_static
to proc_layout. Reach the proc_static structure from the proc_layout
structure when needed. Include the proc_layout structure in any
messages from assertion failures.
Add some conditionally compiled debugging code.
Give some variables better names.
runtime/mercury_type_info.h:
runtime/mercury_builtin_types.c:
Move the macros required to create the proc_static structures
of unify and compare predicates from mercury_type_info.h
to mercury_builtin_types.c, since the latter is the only file
that needs them.
Use the same macros for creating the proc_static structures
of hand-written unify, compare and compare_reprentation predicates
as for user defined predicates. This required changing their naming
scheme.
runtime/mercury_unify_compare_body.h:
Conform to the new naming scheme.
runtime/mercury_ho_call.c:
Provide the mechanism for mercury_unify_compare_body.h to conform
to the new naming scheme.
Remove the definitions of the proc_static structures for
hand-written unify, compare and compare_reprentation predicates,
since these now have to be defined together with the corresponding
proc_layout structures in mercury_builtin_types.c.
runtime/mercury_builtin_types.[ch]:
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code,
and add the required declarations first.
Handle deep profiling of compare_representation as well as unify
and compare predicates on builtin types.
Handle deep profiling of compare_representation on user-defined types,
since this is done entirely in the runtime, not by compiler generated
predicates.
runtime/mercury_builtin_types_proc_layouts.h:
New header file containing the declarations of the proc layout
structures of the unify, compare and index predicates of builtin types.
Logically, these declarations belong in mercury_builtin_types.h,
but putting them there causes problems for the linker; the details
are explained in the file itself.
runtime/Mmakefile:
Add the new header file.
runtime/mercury_minimal_model.[ch]:
Update the definitions of the hand-written proc_static and proc_layout
structures for the procedures implemented via hand-written C code,
and add the required declarations first.
runtime/mercury_grade.h:
Replace the MR_REQUIRE_TRACING grade option with MR_EXEC_TRACING.
Besides being better named, the MR_EXEC_TRACING option implies
MR_STACK_TRACE.
Besides the overall binary compatibility version number, add subsidiary
version numbers for binary compatibility in deep profiling and
debugging grades. These will make it easier to bootstrap changes
(such as this) that affect binary compatibility only in such grades.
runtime/mercury_trace_base.c:
trace/mercury_trace.c:
Conform to the new names of the configuration parameters.
runtime/mercury_hand_compare_body.h:
runtime/mercury_hand_unify_body.h:
runtime/mercury_hand_unify_compare_body.h:
runtime/mercury_ho_call.c:
tools/make_port_code:
Pass proc_layout structures instead of proc_static structures
to deep profiling port routines.
runtime/mercury_conf_param.h:
Make MR_DEEP_PROFILING as well as MR_EXEC_TRACING imply MR_STACK_TRACE,
since deep profiling now needs stack tracing. (MR_STACK_TRACE needs
to be set in this file, because tests in this file depend on knowing
its value, and this file is among the first files included (in this
case indirectly) in mercury_imp.h.)
Document the macros controlling the debugging of deep profiling.
Enable printing of label names when the relevant deep profiling
debugging macro is set.
runtime/mercury_debug.c:
runtime/mercury_deep_rec_depth_actions.h:
runtime/mercury_deep_rec_depth_body.h:
runtime/mercury_exception_catch_body.h:
Get to proc_statics via proc_layouts.
runtime/mercury_deep_call_port_body.c:
runtime/mercury_deep_leave_port_body.c:
Get to proc_statics via proc_layouts.
Allow the debugger to disable deep profiling in Mercury code that is
part of the debugger, not of the user program being executed.
Add some more assertions.
runtime/mercury_engine.[ch]:
Add a new debugging flag that controls at runtime whether we generate
a human readable Deep.debug equivalent to the binary Deep.data files.
(We already had a mechanism for controlling this at compile time,
but this isn't flexible enough.)
runtime/mercury_wrapper.c:
Allow this new debugging flag to be set from MERCURY_OPTIONS.
runtime/mercury_deep_profiling.[ch]:
Respect this new debugging flag.
Update the hand-written proc_static structures representing the runtime
system.
Print out addresses of proc_layout as well as proc_static structures
when assertions fail.
Add a field to the measurement structure for exception port counts,
and write out this field with the other port counts.
Remove procedure id information from proc_static structures,
deep profiling now uses the procedure id in the proc_layout structure.
Add to proc_static structures fields that specify where, if anywhere,
the variables needed by exception.m to executed the exception port code
are in the procedure's stack frame.
Define a global flag that allows the debugger to disable deep
profiling in Mercury code that is part of the debugger, not of the
user program being executed.
Increase type safety by providing two versions of the function
for registering proc_layouts, one for the proc_layout structures
of user-defined predicates and one for unify, compare and index
predicates.
Fix a bug that occurs only if MR_DEEP_PROFILING_EXPLICIT_CALL_COUNTS is
defined (which it usually isn't): the initial call count was wrong.
runtime/mercury_deep_profiling_hand.h:
Fix a bug: the handwritten code saving deep profiling variables was
saving them in slots that didn't belong to the relevant stack frame.
Update to conform to the modified definitions of proc_static structures
and the fact that we now reach them via proc_layout structures.
runtime/mercury_exception_catch_body.h:
runtime/mercury_stacks.h:
Fix the other side of the bug in mercury_deep_profiling_hand.h
by reserving the right number of stack slots in the stack frames
of the various modes of exception__catch. Make it harder to make
the same bug in the future by getting the needed info from the
place in mercury_stacks.h that defines the structure of the relevant
stack frame.
runtime/mercury_proc_id.h:
Rename the procedure id structure fields referring to compiler
generated unify, compare and index predicates: they are not the only
compiler-generated predicates.
runtime/mercury_stack_layout.h:
Change procedure layout structures to allow them to be used for deep
profiling as well as for debugging, as described in the prologue above.
We don't need the capability to support label layout structures with
links to misnamed proc layout structures, and supporting it is
inconvenient, so delete the capability.
runtime/mercury_debug.c:
runtime/mercury_deep_profiling_hand.h:
runtime/mercury_layout_util.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_types.h:
trace/mercury_trace_external.c:
Conform to the new names of the procedure id structure fields.
runtime/mercury_std.h:
Add some more arities for MR_PASTE for use in some of the modified
modules in the runtime.
trace/mercury_trace_internal.c:
Disable deep profiling actions in Mercury code that is part of the
debugger, not of the program being debugged.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Make changes parallel to the ones in runtime/mercury_grade.h: delete
--stack-trace as an independent option, and make --debug set its
own option, not --require-tracing.
scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/c2init.in:
scripts/mgnuc.in:
scripts/ml.in:
Conform to the changes in grade options for debugging and for deep
profiling.
tools/bootcheck:
If Mmake.stage.{browser,deep,library,runtime,trace}.params exist,
copy them to become the file Mmake.$dir.params in stage2/$dir
(where dir is derived from the name of the original file in the obvious
way). This allows more flexibility in the creation of the stage2;
for example, it allows some directories (e.g. runtime or library)
to be compiled with more debugging than other directories (e.g.
compiler). This may be required because compiling all directories
with lots of debugging may cause the linker to thrash.
Add an option, --disable-debug-libs, that clobbers the libraries
that should be linked in only in debugging grades.
To conserve disk space, remove Deep.data files created by the bootcheck
by default. Add an option, --keep-deep-data, to preserve these files.
Use a consistent mechanism (test -f) for testing the existence of
all files whose existence is tested.
When recording modification times, record the modification times
of some more files.
tests/hard_coded/Mmakefile:
In deep profiling grades, disable the test cases that we don't now
pass in such grades, and document the reasons for their failure.
Fix the misclassification of the write_binary test case.
|
||
|
|
c198124584 |
Make debugging of minimal model code easier.
Estimated hours taken: 0.5 Branches: main Make debugging of minimal model code easier. runtime/mercury_debug.c: If MR_DEBUG_LABEL_GOAL_PATHS is defined, make MR_print_label print the goal path of the label if it is available. runtime/mercury_conf_param.h: Document the new debugging macro MR_DEBUG_LABEL_GOAL_PATHS. runtime/mercury_minimal_model.c: Fix a formatting error in the output: MR_print_label doesn't print a newline, MR_printlabel does. Since the C code that implements the mdb command "nondet_stack -d" has a sanity check requiring the proc layouts of model_non predicates to have -1 in the (ignored) field specifying the stackvar storing succip, put that value in the proc layouts of the hand-written procedures for suspend and resume. |
||
|
|
5ba9584a9b |
Make it easier to debug code that handles typeclass_infos, by
Estimated hours taken: 1 Branches: main Make it easier to debug code that handles typeclass_infos, by - renaming the macros that access the fields of typeclass_infos and base_typeclass_infos to better reflect their purpose, - adding a new macro when one macro was being used for two different purposes, and - providing versions of those macros that perform sanity checks on each access. runtime/mercury_type_info.h: Make the changes described above. runtime/mercury_conf_param.h: Document the macros, MR_CHECK_TYPECLASS_REFS, whose definition enables the runtime checks. library/private_builtin.m: Use the updated names of the macros, and standardize indentation. runtime/mercury_deep_copy_body.h: runtime/mercury_ho_call.c: runtime/mercury_layout_util.c: runtime/mercury_tabling.c: runtime/mercury_type_info.c: runtime/mercury_unify_compare_body.h: Use the updated names of the macros. runtime/mercury_type_info.c: Add a function for reporting violations of the sanity checks. |
||
|
|
ddab616d35 |
Some minor documentation tweeks.
Estimated hours taken: 0.25 Branches: main Some minor documentation tweeks. runtime/mercury_conf_param.h: Delete comment about MR_NATIVE_GC not working, since it does work now, at least in grade hlc.agc (there are still some problems with asm_fast.agc). runtime/mercury_stacks.h: Add a pointer to the documentation in compiler/notes/failure.html. |
||
|
|
f007b45df8 |
Implement the infrastructure for term size profiling.
Estimated hours taken: 400
Branches: main
Implement the infrastructure for term size profiling. This means adding two
new grade components, tsw and tsc, and implementing them in the LLDS code
generator. In grades including tsw (term size words), each term is augmented
with an extra word giving the number of heap words it contains; in grades
including tsc (term size cells), each term is augmented with an extra word
giving the number of heap cells it contains. The extra word is at the start,
at offset -1, to leave almost all of the machinery for accessing the heap
unchanged.
For now, the only way to access term sizes is with a new mdb command,
"term_size <varspec>". Later, we will use term sizes in conjunction with
deep profiling to do experimental complexity analysis, but that requires
a lot more research. This diff is a necessary first step.
The implementation of term size profiling consists of three main parts:
- a source-to-source transform that computes the size of each heap cell
when it is constructed (and increments it in the rare cases when a free
argument of an existing heap cell is bound),
- a relatively small change to the code generator that reserves the extra
slot in new heap cells, and
- extensions to the facilities for creating cells from C code to record
the extra information we now need.
The diff overhauls polymorphism.m to make the source-to-source transform
possible. This overhaul includes separating type_ctor_infos and type_infos
as strictly as possible from each other, converting type_ctor_infos into
type_infos only as necessary. It also includes separating type_ctor_infos,
type_infos, base_typeclass_infos and typeclass_infos (as well as voids,
for clarity) from plain user-defined type constructors in type categorizations.
This change needs this separation because values of those four types do not
have size slots, but they ought to be treated specially in other situations
as well (e.g. by tabling).
The diff adds a new mdb command, term_size. It also replaces the proc_body
mdb command with new ways of using the existing print and browse commands
("print proc_body" and "browse proc_body") in order to make looking at
procedure bodies more controllable. This was useful in debugging the effect
of term size profiling on some test case outputs. It is not strictly tied
to term size profiling, but turns out to be difficult to disentangle.
compiler/size_prof.m:
A new module implementing the source-to-source transform.
compiler/notes/compiler_design.html:
Mention the new module.
compiler/transform_hlds.m:
Include size_prof as a submodule of transform_hlds.
compiler/mercury_compile.m:
If term size profiling is enabled, invoke its source-to-source
transform.
compiler/hlds_goal.m:
Extend construction unifications with an optional slot for recording
the size of the term if the size is a constant, or the identity of the
variable holding the size, if the size is not constant. This is
needed by the source-to-source transform.
compiler/quantification.m:
Treat the variable reference that may be in this slot as a nonlocal
variable of construction unifications, since the code generator needs
this.
compiler/compile_target_code.m:
Handle the new grade components.
compiler/options.m:
Implement the options that control term size profiling.
doc/user_guide.texi:
Document the options and grade components that control term size
profiling, and the term_size mdb command. The documentation is
commented out for now.
Modify the wording of the 'u' HLDS dump flag to include other details
of unifications (e.g. term size info) rather than just unification
categories.
Document the new alternatives of the print and browse commands. Since
they are for developers only, the documentation is commented out.
compiler/handle_options.m:
Handle the implications of term size profiling grades.
Add a -D flag value to print HLDS components relevant to HLDS
transformations.
compiler/modules.m:
Import the new builtin library module that implements the operations
needed by term size profiling automatically in term size profiling
grades.
Switch the predicate involved to use state var syntax.
compiler/prog_util.m:
Add predicates and functions that return the sym_names of the modules
needed by term size profiling.
compiler/code_info.m:
compiler/unify_gen.m:
compiler/var_locn.m:
Reserve an extra slot in heap cells and fill them in in unifications
marked by size_prof.
compiler/builtin_ops.m:
Add term_size_prof_builtin.term_size_plus as a builtin, with the same
implementation as int.+.
compiler/make_hlds.m:
Disable warnings about clauses for builtins while the change to
builtin_ops is bootstrapped.
compiler/polymorphism.m:
Export predicates that generate goals to create type_infos and
type_ctor_infos to add_to_construct.m. Rewrite their documentation
to make it more detailed.
Make orders of arguments amenable to the use of state variable syntax.
Consolidate knowledge of which type categories have builtin unify and
compare predicates in one place.
Add code to leave the types of type_ctor_infos alone: instead of
changing their types to type_info when used as arguments of other
type_infos, create a new variable of type type_info instead, and
use an unsafe_cast. This would make the HLDS closer to being type
correct, but this new code is currently commented out, for two
reasons. First, common.m is currently not smart enough to figure out
that if X and Y are equal, then similar unsafe_casts of X and Y
are also equal, and this causes the compiler do not detect some
duplicate calls it used to detect. Second, the code generators
are also not smart enough to know that if Z is an unsafe_cast of X,
then X and Z do not need separate stack slots, but can use the same
slot.
compiler/type_util.m:
Add utility predicates for returning the types of type_infos and
type_ctor_infos, for use by new code in polymorphism.m.
Move some utility predicates here from other modules, since they
are now used by more than one module.
Rename the type `builtin_type' as `type_category', to better reflect
what it does. Extend it to put the type_info, type_ctor_info,
typeclass_info, base_typeclass_info and void types into categories
of their own: treating these types as if they were a user-defined
type (which is how they used to be classified) is not always correct.
Rename the functor polymorphic_type to variable_type, since types
such as list(T) are polymorphic, but they fall into the user-defined
category. Rename user_type as user_ctor_type, since list(int) is not
wholly user-defined but falls into this category. Rename pred_type
as higher_order_type, since it also encompasses functions.
Replace code that used to check for a few of the alternatives
of this type with code that does a full switch on the type,
to ensure that they are updated if the type definition ever
changes again.
compiler/pseudo_type_info.m:
Delete a predicate whose updated implementation is now in type_util.m.
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Still treat type_infos, type_ctor_infos, typeclass_infos and
base_typeclass_infos as user-defined types, but prepare for when
they won't be.
compiler/hlds_pred.m:
Require interface typeinfo liveness when term size profiling is
enabled.
Add term_size_profiling_builtin.increase_size as a
no_type_info_builtin.
compiler/hlds_out.m:
Print the size annotations on unifications if HLDS dump flags call
for unification details. (The flag test is in the caller of the
modified predicate.)
compiler/llds.m:
Extend incr_hp instructions and data_addr_consts with optional fields
that allow the code generator to refer to N words past the start of
a static or dynamic cell. Term size profiling uses this with N=1.
compiler/llds_out.m:
When allocating memory on the heap, use the macro variants that
specify an optional offset, and specify the offset when required.
compiler/bytecode_gen.m:
compiler/dense_switch.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/goal_form.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/inst_match.m:
compiler/intermod.m:
compiler/jumpopt.m:
compiler/lambda.m:
compiler/livemap.m:
compiler/ll_pseudo_type_info.m:
compiler/lookup_switch.m:
compiler/magic_util.m:
compiler/middle_rec.m:
compiler/ml_code_util.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modecheck_unify.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/post_typecheck.m:
compiler/reassign.m:
compiler/rl.m:
compiler/rl_key.m:
compiler/special_pred.m:
compiler/stack_layout.m:
compiler/static_term.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
Minor updates to conform to the changes above.
library/term_size_prof_builtin.m:
New module containing helper predicates for term size profiling.
size_prof.m generates call to these predicates.
library/library.m:
Include the new module in the library.
doc/Mmakefile:
Do not include the term_size_prof_builtin module in the library
documentation.
library/array.m:
library/benchmarking.m:
library/construct.m:
library/deconstruct.m:
library/io.m:
library/sparse_bitset.m:
library/store.m:
library/string.m:
Replace all uses of MR_incr_hp with MR_offset_incr_hp, to ensure
that we haven't overlooked any places where offsets may need to be
specified.
Fix formatting of foreign_procs.
Use new macros defined by the runtime system when constructing
terms (which all happen to be lists) in C code. These new macros
specify the types of the cell arguments, allowing the implementation
to figure out the size of the new cell based on the sizes of its
fields.
library/private_builtin.m:
Define some constant type_info structures for use by these macros.
They cannot be defined in the runtime, since they refer to types
defined in the library (list.list and std_util.univ).
util/mkinit.c:
Make the addresses of these type_info structures available to the
runtime.
runtime/mercury_init.h:
Declare these type_info structures, for use in mkinit-generated
*_init.c files.
runtime/mercury_wrapper.[ch]:
Declare and define the variables that hold these addresses, for use
in the new macros for constructing typed lists.
Since term size profiling can refer to a memory cell by a pointer
that is offset by one word, register the extra offsets with the Boehm
collector if is being used.
Document the incompatibility of MR_HIGHTAGS and the Boehm collector.
runtime/mercury_tags.h:
Define new macros for constructing typed lists.
Provide macros for preserving the old interface presented by this file
to the extent possible. Uses of the old MR_list_cons macro will
continue to work in grades without term size profiling. In term
size profiling grades, their use will get a C compiler error.
Fix a bug caused by a missing backslash.
runtime/mercury_heap.h:
Change the basic macros for allocating new heap cells to take
an optional offset argument. If this is nonzero, the macros
increment the returned address by the given number of words.
Term size profiling specifies offset=1, reserving the extra
word at the start (which is ignored by all components of the
system except term size profiling) for holding the size of the term.
Provide macros for preserving the old interface presented by this file
to the extent possible. Since the old MR_create[123] and MR_list_cons
macros did not specify type information, they had to be changed
to take additional arguments. This affects only hand-written C code.
Call new diagnostic macros that can help debug heap allocations.
Document why the macros in this files must expand to expressions
instead of statements, evn though the latter would be preferable
(e.g. by allowing them to declare and use local variables without
depending on gcc extensions).
runtime/mercury_debug.[ch]:
Add diagnostic macros to debug heap allocations, and the functions
behind them if MR_DEBUG_HEAP_ALLOC is defined.
Update the debugging routines for hand-allocated cells to print the
values of the term size slot as well as the other slots in the relevant
grades.
runtime/mercury_string.h:
Provide some needed variants of the macro for copying strings.
runtime/mercury_deconstruct_macros.h:
runtime/mercury_type_info.c:
Supply type information when constructing terms.
runtime/mercury_deep_copy_body.h:
Preserve the term size slot when copying terms.
runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
Reduce code duplication by using a now standard macro for copying
strings.
runtime/mercury_grade.h:
Handle the two new grade components.
runtime/mercury_conf_param.h:
Document the C macros used to control the two new grade components,
as well as MR_DEBUG_HEAP_ALLOC.
Detect incompatibilities between high level code and profiling.
runtime/mercury_term_size.[ch]:
A new module to house a function to find and return term sizes
stored in heap cells.
runtime/mercury_proc_id.h:
runtime/mercury_univ.h:
New header files. mercury_proc_id.h contains the (unchanged)
definition of MR_Proc_Id, while mercury_univ.h contains the
definitions of the macros for manipulating univs that used to be
in mercury_type_info.h, updated to use the new macros for allocating
memory.
In the absence of these header files, the following circularity
would ensue:
mercury_deep_profiling.h includes mercury_stack_layout.h
- needs definition of MR_Proc_Id
mercury_stack_layout.h needs mercury_type_info.h
- needs definition of MR_PseudoTypeInfo
mercury_type_info.h needs mercury_heap.h
- needs heap allocation macros for MR_new_univ_on_hp
mercury_heap.h includes mercury_deep_profiling.h
- needs MR_current_call_site_dynamic for recording allocations
Breaking the circular dependency in two places, not just one, is to
minimize similar problems in the future.
runtime/mercury_stack_layout.h:
Delete the definition of MR_Proc_Id, which is now in mercury_proc_id.h.
runtime/mercury_type_info.h:
Delete the macros for manipulating univs, which are now in
mercury_univ.h.
runtime/Mmakefile:
Mention the new files.
runtime/mercury_imp.h:
runtime/mercury.h:
runtime/mercury_construct.c:
runtime/mercury_deep_profiling.h:
Include the new files at appropriate points.
runtime/mercury.c:
Change the names of the functions that create heap cells for
hand-written code, since the interface to hand-written code has
changed to include type information.
runtime/mercury_tabling.h:
Delete some unused macros.
runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
Use the new macros supplying type information when constructing lists.
scripts/canonical_grade_options.sh-subr:
Fix an undefined sh variable bug that could cause error messages
to come out without identifying the program they were from.
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade_options.sh-subr:
scripts/mgnuc.in:
Handle the new grade components and the options controlling them.
trace/mercury_trace_internal.c:
Implement the mdb command "term_size <varspec>", which is like
"print <varspec>", but prints the size of a term instead of its value.
In non-term-size-profiling grades, it prints an error message.
Replace the "proc_body" command with optional arguments to the "print"
and "browse" commands.
doc/user_guide.tex:
Add documentation of the term_size mdb command. Since the command is
for implementors only, and works only in grades that are not yet ready
for public consumption, the documentation is commented out.
Add documentation of the new arguments of the print and browse mdb
commands. Since they are for implementors only, the documentation
is commented out.
trace/mercury_trace_vars.[ch]:
Add the functions needed to implement the term_size command, and
factor out the code common to the "size" and "print"/"browse" commands.
Decide whether to print the name of a variable before invoking the
supplied print or browse predicate on it based on a flag design for
this purpose, instead of overloading the meaning of the output FILE *
variable. This arrangement is much clearer.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
Supply type information when constructing terms.
browser/program_representation.m:
Since the new library module term_size_prof_builtin never generates
any events, mark it as such, so that the declarative debugger doesn't
expect it to generate any.
Do the same for the deep profiling builtin module.
tests/debugger/term_size_words.{m,inp,exp}:
tests/debugger/term_size_cells.{m,inp,exp}:
Two new test cases, each testing one of the new grades.
tests/debugger/Mmakefile:
Enable the two new test cases in their grades.
Disable the tests sensitive to stack frame sizes in term size profiling
grades.
tests/debugger/completion.exp:
Add the new "term_size" mdb command to the list of command completions,
and delete "proc_body".
tests/debugger/declarative/dependency.{inp,exp}:
Use "print proc_body" instead of "proc_body".
tests/hard_coded/nondet_c.m:
tests/hard_coded/pragma_inline.m:
Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
that allocate cells also allocate space for the term size slot if
necessary.
tests/valid/Mmakefile:
Disable the IL tests in term size profiling grades, since the term size
profiling primitives haven't been (and probably won't be) implemented
for the MLDS backends, and handle_options causes a compiler abort
for grades that combine term size profiling and any one of IL, Java
and high level C.
|
||
|
|
89a4d190c5 |
Library changes required to make the compiler work on Windows
Estimated hours taken: 120
Branches: main
Library changes required to make the compiler work on Windows
without Cygwin. (Compiler changes to come separately).
library/dir.m:
Handle Windows-style paths.
Change the determinism of dir.basename and dir.split_name.
dir.basename now fails for root directories (a new function
dir.basename_det calls error/1 rather than failing).
dir.split_name fails for root directories or if the pathname
passed doesn't contain a directory separator.
Add predicates dir.make_directory, dir.path_name_is_absolute
and dir.path_name_is_root_directory.
Add a multi predicate dir.is_directory separator which
returns all separators for the platform (including '/' on
Windows), not just the standard one.
Add a function dir.parent_directory (returns "..").
Add dir.foldl2 and dir.recursive_foldl2, to iterate through
the entries in a directory (and maybe its subdirectories).
Change '/' to correctly handle Windows paths of the form
"C:"/"foo" and "\"/"foo".
Don't add repeated directory separators in '/'.
library/io.m:
Add io.file_type and io.check_file_accessibility.
Add predicates to deal with symlinks -- io.have_symlinks,
io.make_symlink and io.follow_symlink.
Add io.file_id for use by dir.foldl2 to detect
symlink loops. This is a bit low level, so it's
not included in the user documentation.
Add io.(binary_)input_stream_foldl2_io_maybe_stop, which
is like io.(binary_)input_stream_foldl2_io, but allows
stopping part of the way through. This is useful for
implementing `diff'-like functionality to replace
mercury_update_interface.
Use Windows-style paths when generating temporary file
names on Windows.
Add versions of the predicates to generate error messages
to handle Win32 errors.
Add versions of the predicates to generate error messages
which take a system error code, rather than looking up
errno. This simplifies things where the error we
are interested in was not from the last system call.
library/exception.m:
Add a predicate finally/6 which performs the same function
as the `finally' clause in languages such as C# and Java.
Add predicates try_det, try_io_det and try_store_det,
which only have one mode so they are more convenient
to pass to promise_only solution.
library/Mmakefile:
Add dependencies on runtime/mercury_conf.h for files which
use the MR_HAVE_* macros.
library/string.m:
Add a function version of string__index.
NEWS:
Document the new predicates and functions and the change
of determinism of dir.split_name and dir.basename.
configure.in:
runtime/mercury_conf.h.in:
Test for lstat, mkdir, symlink and readlink.
runtime/mercury_conf_param.h:
Add a macro MR_BROKEN_ST_INO, which is true if the st_ino
field of `struct stat' is garbage. Currently defined iff
MR_WIN32 is defined.
compiler/compile_target_code.m:
compiler/modules.m:
compiler/options_file.m:
compiler/prog_io.m:
compiler/source_file_map.m:
Changes required by the change of determinism of
dir.split_name and dir.basename.
tests/hard_coded/Mmakefile:
tests/hard_coded/dir_test.{m,exp,exp2}:
Test case.
|
||
|
|
8c830b3fa3 |
Add a mechanism that can detect data structure corruption.
Estimated hours taken: 2 Branches: main Add a mechanism that can detect data structure corruption. The mechanism takes the form of an option to mdb's forward movement commands, but is enabled only if the trace directory is compiled with an implementor-only compile-time flag. The option is therefore not documented. runtime/mercury_conf_param.h: Document the compile-time flag. runtime/mercury_trace_base.[ch]: Add a mechanism that allows a message to be printed by the debugger when a program being run under mdb crashes. trace/mercury_trace.[ch]: If the compile-time flag is defined, add a field to mdb commands that says whether or not integrity checks are supposed to be done, and act on its value. The integrity check consists of printing all the variables in all the ancestor stack frames at every event: this is useful when looking for code generation errors that cause cells to be built wrong. trace/mercury_trace_external.c: If the compile-time flag is defined, set this field to false. trace/mercury_trace_internal.c: If the compile-time flag is defined, set this field based on whether the last forward movement command included the --integrity or -i option. trace/mercury_trace_vars.[ch]: If the compile-time flag is defined, add a function that implements the integrity check. |
||
|
|
50b174b910 |
Add an MR_ prefix.
Estimated hours taken: 0.1 Branches: main runtime/mercury_conf_param.h: runtime/mercury_regs.h: runtime/mercury_wrapper.c: Add an MR_ prefix. |
||
|
|
57b9d92601 |
Ensure that the global heap and solutions heap are not used
Estimated hours taken: 4 Branches: main Ensure that the global heap and solutions heap are not used in accurate GC grades. runtime/mercury_conf_param.h: Define new parameters MR_RECLAIM_HP_ON_FAILURE and MR_MIGHT_RECLAIM_HP_ON_FAILURE. These will not be defined for accurate GC grades. runtime/mercury_engine.h: runtime/mercury_engine.c: Only allocate the solutions heap and the global heap if MR_MIGHT_RECLAIM_HP_ON_FAILURE is set. library/std_util.m: Don't define MR_RECLAIM_HP_ON_FAILURE, since it is now defined in runtime/mercury_conf_param.h. library/exception.m: When an exception is throw, reset the heap iff MR_RECLAIM_HP_ON_FAILURE is set, rather than iff MR_CONSERVATIVE_GC is not set. runtime/mercury_deep_copy.h: runtime/mercury_deep_copy.c: Change MR_make_permanent() and MR_make_long_lived() so that they copy data to the global heap iff MR_MIGHT_RECLAIM_HP_ON_FAILURE is set, rather than iff MR_CONSERVATIVE_GC is not set. |
||
|
|
ddb677279c |
Ensure that in MLDS grades, arguments with arg_mode `top_unused' do not
Estimated hours taken: 2 Branches: main Ensure that in MLDS grades, arguments with arg_mode `top_unused' do not get passed. Previously, different parts of the compiler had different and inconsistent ideas about if/how they should get passed, which caused problems, including an internal error for tests/hard_coded/foreign_type2.m in grade `java'. The comments in mlds.m said they should not get passed, the code in ml_call_gen.m passed them as if they were output arguments, and the code in ml_code_util declared them as if they were input arguments. compiler/hlds_pred.m: Add some detailed comments about the meaning of the `arg_mode' type. compiler/ml_call_gen.m: compiler/ml_code_util.m: compiler/ml_code_gen.m: Ensure that arguments with arg_mode `unused' do not get passed, declared, or converted (respectively). runtime/mercury_grade.h: Bump the binary compatibility version number for MLDS grades. This is needed because the calling convention for procedures with `unused' mode arguments has changed. |
||
|
|
e86057942c |
Apply Zoltan's deep profiler changes to the main branch.
Estimated hours taken: 2 Branches: main Apply Zoltan's deep profiler changes to the main branch. Zoltan committed these changes to the release branch, but forgot to commit them to the main branch. Mmakefile: NEWS: configure.in: bindist/Mmakefile: bindist/bindist.Makefile.in: doc/user_guide.texi: library/exception.m: library/io.m: runtime/mercury_conf.h.in: runtime/mercury_conf_param.h: runtime/mercury_misc.c: runtime/mercury_misc.h: scripts/Mmakefile: deep_profiler/.nocopyright: deep_profiler/Mercury.options: deep_profiler/Mmakefile: deep_profiler/callgraph.m: deep_profiler/cliques.m: deep_profiler/conf.m: deep_profiler/html_format.m: deep_profiler/interface.m: deep_profiler/mdprof_cgi.m: deep_profiler/query.m: deep_profiler/startup.m: deep_profiler/timeout.m: deep_profiler/mdprof_server.m: deep_profiler/server.m: Merge in changes from the release branch. Enclosed below is Zoltan's original log message. ---------- Estimated hours taken: 0.3 (on release branch) Branches: release Make the deep profiler work again. The existing process structure of the deep profiler made it very hard to debug, mainly because the Mercury debugger is confused by forks and stymied by execs. This change completely replaces the process structure. The old structure had two separate programs, mdprof_cgi and mdprof_server, the first always acting as client and the second always acting as server. The new structure has only one program, mdprof_cgi, which acts as a server if there is no existing server for the relevant profiling data file, and as a client otherwise. Although mdprof_cgi normally forks when it becomes a server to let the parent exit and let the web server know that the web page it has generated is complete, the fork can be disabled for debugging via an option. This allows the communication between client and server to be debugged by running two instances of mdprof_cgi in different windows, one or both under mdb. deep_profiler/DESIGN: New file describing the new process structure, its race conditions, and their solutions. deep_profiler/.nocopyright: Add DESIGN. deep_profiler/mdprof_cgi.m: A complete rewrite of this module to enable it act as both client and server. deep_profiler/mdprof_test.m: A new module to hold the testing functionality of mdprof_server.m. deep_profiler/mdprof_server.m: deep_profiler/server.m: Delete these now unnecessary modules. Mmakefile: Replace references to mdprof_server with references to mdprof_test. deep_profiler/Mmakefile: Replace references to mdprof_server with references to mdprof_test. Move the include of Mmake.deep.params, to allow it to override top level parameter settings. deep_profiler/Mercury.options: Work around a compiler bug by turning off the offending optimization. deep_profiler/timeout.m: A rewrite of major parts of this module to support the new design of mdprof_cgi.m, and to make unexpected signals easier to debug. deep_profiler/interface.m: Implement the mechanisms needed by the new process structure. Change the characters we use to separate components of the URL. The old ones were special to the shell, and screwed up command lines. (As double insurance, we ignore the command line anyway when invoked by the web server.) Change some names to be more expressive. deep_profiler/conf.m: Add a new function, getpid, for use by interface.m. Rewrite some code to use streams explicitly, not implicitly. deep_profiler/callgraph.m: deep_profiler/cliques.m: Add (now commented out) code to help debug these modules, for use in cases where mdb doesn't help, because the program works perfectly with debugging enabled :-( deep_profiler/query.m: Move the predicate try_exec here from the deleted file server.m. deep_profiler/html_format.m: Trivial change to conform to name change in interface.m. deep_profiler/startup.m: Generate debugging output to a caller specified stream, not to stdout and stderr. Disable the generation of statistics temporarily, since the diff to make statistics reporting routines write to a specified stream instead of stdout and stderr won't be committed on the release branch. Currently, they always write to stdout, which in the new design goes to the web page, not to the startup file. configure.in: Detect the presence of opendir, readdir and closedir, and the header file they need, dirent.h. Enable the deep profiler only if all exist, since the deep profiler now needs them. runtime/mercury_conf.h.in: Support the changes to configure.in. runtime/mercury_misc.[ch]: Add a mechanism for registering cleanup functions to be executed when we terminate the program due to an uncaught exception. library/exception.m: Invoke the registered cleanup functions just before terminating the program due to an uncaught exception. |
||
|
|
63378db019 |
Remove the --disable-decl-debug configuration option, and all conditional
Estimated hours taken: 0.25 Branches: main Remove the --disable-decl-debug configuration option, and all conditional compilation of the declarative debugging implementation. configure.in: Remove the configuration option. runtime/mercury_conf.h.in: Don't document the configuration macro. runtime/mercury_conf_param.h: Don't calculate the conditional compilation macro. trace/mercury_trace_declarative.c: trace/mercury_trace_declarative.h: trace/mercury_trace_internal.c: trace/mercury_trace_internal.h: Compile the declarative debugging code unconditionally. |
||
|
|
c0f4d93a3c |
Add a new grade component, .decldebug. It is as proposed on mercury-developers,
Estimated hours taken: 2 Branches: main Add a new grade component, .decldebug. It is as proposed on mercury-developers, minus the implications about I/O tabling. Those will come later. compiler/options.m: Add a new option, --decl-debug, that switches on declarative debugging. compiler/trace_params.m: The procedure that converts strings representing trace levels to trace levels themselves now has an extra argument, which gives the value of the --decl-debug option. If set, it raises the minimum trace level, and turn explicitly specifying trace levels `shallow' and `deep' into errors (since they are not sufficient for declarative debugging). compiler/handle_options.m: Pass the value of the --decl-debug option to trace_params, and handle the errors that may result. Handle the implications of --decl-debug and the .decldebug grade component. compiler/compile_target_code.m: Define MR_DECL_DEBUG when invoking the C compiler if --decl-debug is set. runtime/mercury_conf_param.h: Document MR_DECL_DEBUG, which is defined iff the grade is a .decldebug grade. runtime/mercury_grade.h: Take MR_DECL_DEBUG into account when computing the grade component related to debugging. Update the list of places that need to be modified when adding new grade components. doc/user_guide.texi: Document --decl-debug and the .decldebug grade component. Document the events used by declarative debugging, since Mark didn't. Fix some minor unrelated omissions. scripts/init_grade.sh-subr: scripts/parse_grade_options.sh-subr: scripts/final_grade.sh-subr: scripts/canonical_grade.sh-subr: scripts/mgnuc.in: scripts/ml.in: Add a new shell variable, decl_debug, to represent the value of MR_DECL_DEBUG, and handle it as appropriate. tests/debugger/Mmakefile: Do not execute shallow traced tests in .decldebug grades, since we don't support shallow tracing in such grades. Specify --trace decl instead of --trace deep in .decldebug grades when compiling the other tests, since we don't support --trace deep in .decldebug grades. |
||
|
|
17d5aa732e |
Add support for interfacing Mercury with the MPS garbage collector.
Estimated hours taken: 20
Branches: main
Add support for interfacing Mercury with the MPS garbage collector.
This change is broken into three parts:
1. Import version 1.100.1 of the MPS kit into the Mercury
CVS repository, in the directory `mps_gc'.
2. Make some changes to the MPS kit for Mercury,
to support fully-conservative collection and tagged pointers,
and to wrap it in an interface that is similar to that of
the Boehm collector.
3. Modify the rest of the Mercury implementation
to support linking with the MPS kit instead
of the Boehm collector. This involved defining
`mps' as a new GC method and a new grade component.
This is part 3 of 3.
Mmake.workspace:
Include the MPS directories in the header file and library search
paths.
tools/bootcheck:
Link the mps_gc directory into the stage2 and stage3 directories.
Mmake.workspace:
runtime/Mmakefile:
scripts/ml.in:
For *.mps grades, link in mps.a.
(XXX ml.in is linking in libmps.a, which is wrong.)
runtime/Mmakefile:
trace/Mmakefile:
In the rule for `check_headers', which checks macro namespace
cleanliness, allow names to start with `MPS_' or `mps_'.
runtime/RESERVED_MACRO_NAMES:
Add `mercury_mps_h', which is used by mps_gc/code/mercury_mps.h
for its header guard. (Normally it would be better to use
uppercase for header guard macro names, but that would be
inconsistent with the coding style used in mps_gc/code.)
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade.sh-subr:
Handle the new `mps' GC method and grade component.
compiler/globals.m:
compiler/options.m:
doc/user_guide.texi:
Replace gc_method `conservative' with two alternatives
`boehm' and `mps'. ("--gc conservative" is still allowed,
and treated as equivalent to "--gc boehm".)
Add new function `gc_is_conservative' to globals.m.
compiler/mercury_compile.m:
compiler/handle_options.m:
Use `gc_is_conservative' rather than `= conservative'.
compiler/handle_options.m:
Handle the "mps" grade component.
(XXX need to document this in options.m and user_guide.texi)
compiler/compile_target_code.m:
Pass the appropriate C defines for the new GC methods.
compiler/mercury_compile.m:
Wrap the work-around for a Boehm GC bug inside `#ifndef MR_MPS_GC'.
library/array.m:
Use GC_FREE() rather than GC_free().
This is needed for two reasons:
- so that it works with MPS, which only defines GC_FREE
- so that it works with then Boehm collector when
GC debugging is enabled
library/benchmarking.m:
Output GC statistics for the MPS collector.
runtime/mercury.h:
runtime/mercury_heap.h:
runtime/mercury_init.h:
runtime/mercury_memory.h:
If MR_MPS_GC is defined, use mercury_mps.h rather than gc.h.
runtime/mercury_conf_param.h:
Add configuration macros MR_BOEHM_GC and MR_MPS_GC.
Set MR_CONSERVATIVE_GC if either of these is set.
Default to MR_BOEHM_GC if only MR_CONSERVATIVE_GC is set.
runtime/mercury_context.h:
runtime/mercury_deep_copy.h:
runtime/mercury_engine.h:
runtime/mercury_float.h:
runtime/mercury_heap.h:
Explictly #include "mercury_conf.h", so that
MR_CONSERVATIVE_GC will be set properly before it is tested.
runtime/mercury_grade.h:
Handle the .mps grade component.
runtime/mercury_memory.c:
runtime/mercury_wrapper.c:
runtime/mercury_memory_handlers.c:
Move the call to MR_setup_signals() earlier in the
initialization sequence, so that the MPS signal handlers
get installed after our signal handlers. This is needed
because our signal handlers assume that any signals that
they can't handle are fatal errors, which interfere's
with MPS's use of signal handlers for memory barriers.
runtime/mercury_wrapper.c:
Add code to initialize the MPS collector.
Put code which is specific to the Boehm collector inside
#ifdef MR_BOEHM_GC rather than #ifdef MR_CONSERVATIVE_GC.
runtime/mercury_wrapper.h:
Update a comment.
|
||
|
|
2e5d2802ef |
Standardize formatting.
Estimated hours taken: 0.1 Branches: main runtime/mercury_conf_param.h: Standardize formatting. |
||
|
|
8d8959aa14 |
Catch attempts to mix high level code with debugging intended for low
Estimated hours taken: 0.1 Branches: main runtime/mercury_conf_param.h: Catch attempts to mix high level code with debugging intended for low level code. |
||
|
|
22d1aa615d |
Make the accurate GC debugging code a run-time option
Estimated hours taken: 1 Branches: main Make the accurate GC debugging code a run-time option rather than a compile-time option. The run-time cost of this is very small -- just a few `if' statements per garbage collection -- and it is more convenient if agc debugging can be enabled by setting MERCURY_OPTIONS rather than by having to recompile the Mercury runtime. runtime/mercury_engine.h: Add a new debug flag `MR_agc_debug', for debugging accurate GC. runtime/mercury_wrapper.c: Set the flag if the -dA or -dG options are specified in MERCURY_OPTIONS. runtime/mercury_accurate_gc.c: Change the code which was using `#ifdef MR_AGC_DEBUG_COLLECTION' to instead use `if (MR_agc_debug)'. runtime/mercury_conf_param.h: Delete the documentation of the now unused configuration macro MR_AGC_DEBUG_COLLECTION, and add a mention of the -dG option. |
||
|
|
515d0fcca2 |
Add missing MR_ prefix and fix the base macro name.
Estimated hours taken: 0.2 Branches: main runtime/mercury_conf_param.h: Add missing MR_ prefix and fix the base macro name. |
||
|
|
0b2c0c6b6c |
Remove the code that reserves two stack slots for declarative debugging.
Estimated hours taken: 0.5 Branches: main Remove the code that reserves two stack slots for declarative debugging. Now that code for MR_USE_DECL_STACK_SLOT no longer exists, there is no chance that the stack slots will be required. compiler/layout.m: Remove the maybe_decl_debug_slot field from proc_layout_exec_trace. compiler/layout_out.m: Don't print the field that was just removed. Update a couple of comments. compiler/trace.m: Remove the slot_decl field from trace_slot_info. Don't reserve the two slots. compiler/llds_common.m: compiler/code_info.m: compiler/stack_layout.m: Propagate the effects of the above changes. compiler/trace_params.m: Remove trace_level_needs_decl_debug_slots. runtime/mercury_stack_layout.h: Remove the MR_exec_maybe_decl_debug field from MR_Exec_Trace. runtime/mercury_conf_param.h: Don't document MR_USE_DECL_STACK_SLOT. trace/mercury_trace_declarative.c: Remove the prototypes of two unused functions whose definitions were removed earlier. |
||
|
|
a90c10a7d2 |
Document MR_COMPARE_BY_RTTI.
Estimated hours taken: 0.5 Branches: main runtime/mercury_conf_param.h: Document MR_COMPARE_BY_RTTI. runtime/mercury_ho_call.c: runtime/mercury_unify_compare_body.h: Delete the undocumented configuration macros MR_UNIFY_COMPARE_BY_CTOR_REP_SPEC_[12]. |
||
|
|
56e818af67 |
Implement compare_representation/3, which is like compare except that it
Estimated hours taken: 5.5 Branches: main Implement compare_representation/3, which is like compare except that it is cc_multi, and it doesn't abort on non-canonical types. The implementation only works for the LLDS backend; in other cases, the runtime aborts with a "sorry" message. For this reason, it is not officially part of the standard library yet. library/std_util.m: Add the new predicate, which is implemented via "external". runtime/mercury_ho_call.c: Implement compare_representation/3, and also a C version. runtime/mercury_unify_compare_body.h: Implement the body of compare_representation/3. When the macro include_compare_rep_code is defined comparison of preds and funcs doesn't abort, the code that is used for MR_COMPARE_BY_RTTI is enabled, and usereq types are treated as normal types. runtime/mercury_conf_param.h: Document the fact that calls to compare_representation are counted as calls to compare for the purposes of MR_TYPE_CTOR_STATS. runtime/Mmakefile: Bug fix: add missing pic_o versions of the explicit dependencies. Use variables for the suffixes in these dependencies. runtime/mercury.c: runtime/mercury.h: Supply a HIGHLEVEL_CODE version of the new predicate. This just gives a "Sorry, not implemented" message and aborts. tests/hard_coded/Mmakefile: tests/hard_coded/compare_rep_usereq.exp: tests/hard_coded/compare_rep_usereq.m: tests/hard_coded/compare_representation.exp: tests/hard_coded/compare_representation.m: Test cases. tests/hard_coded/compare_rep_array.m: A test case which doesn't work yet. |
||
|
|
fac6d208e3 |
More MR_ prefix changes.
Estimated hours taken: 0.25 Branches: main More MR_ prefix changes. runtime/mercury_conf_param.h: Remove support for the non-prefixed versions of the command line configuration parameters. Installations which use these are now considered to be too old by configure.in. runtime/mercury_boostrap.h: Move everything into the section disabled by MR_NO_BACKWARDS_COMPAT. No definitions are required for bootstrapping at the moment. runtime/Mmakefile: trace/Mmakefile: Define MERCURY_BOOTSTRAP_H rather than MR_NO_BACKWARDS_COMPAT to suppress inclusion of backwards compatibility definitions. The runtime and trace sources shouldn't contain references to the definitions needed for bootstrapping. trace/mercury_trace_internal.c: deep_profiler/server.m: Add missing MR_ prefixes. |
||
|
|
831b6b9b7b |
Support `--reclaim-heap-on-failure' in grade hlc.agc.
Estimated hours taken: 4 Branches: main Support `--reclaim-heap-on-failure' in grade hlc.agc. runtime/mercury_accurate_gc.h: runtime/mercury_accurate_gc.c: runtime/mercury_deep_copy.c: runtime/mercury_deep_copy_body.h: Handle copying of saved heap pointers. We do this by building a list of them while traversing the roots, and then once we've finished copying all the other data, we reset them all to point to the new heap pointer. runtime/mercury_conf_param.h: Document the new configuration macro MR_DEBUG_AGC_SAVED_HPS. |
||
|
|
d00176a1e5 |
Fix an omission in my last change. TAGBITS is defined on
Estimated hours taken: 0.2 runtime/mercury_conf_param.h: Fix an omission in my last change. TAGBITS is defined on the gcc command line by mercury_compile (but not by mgnuc), so we need to define MR_TAGBITS to have the value of TAGBITS here. runtime/mercury_conf_bootstrap.h: Define TAGBITS if it is not already defined. runtime/mercury_bootstrap.h: Remove the old backwards compatibility definition of TAGBITS, which would not be correct in the case where TAGBITS is defined on the command line. |
||
|
|
b7c4a317e9 |
Add MR_ prefixes to the remaining non-prefixed symbols.
Estimated hours taken: 4 Branches: main Add MR_ prefixes to the remaining non-prefixed symbols. This change will require all workspaces to be updated The compiler will start generating references to MR_TRUE, MR_bool, etc., which are not defined in the old runtime header files. runtime/mercury_std.h: Add MR_ prefixes to bool, TRUE, FALSE, max, min, streq, strdiff, strtest, strntest, strneq, strndiff, strntest, NO_RETURN. Delete a commented out definition of `reg'. runtime/mercury_tags.h: Add an MR_ prefix to TAGBITS. configure.in: runtime/mercury_goto.h: runtime/machdeps/i386_regs.h/mercury_goto.h: Add an MR_ prefix to PIC. runtime/mercury_conf_param.h: Allow non-prefixed PIC and HIGHTAGS to be defined on the command line. runtime/mercury_bootstrap.h: Add backwards compatibility definitions. RESERVED_MACRO_NAMES: Remove the renamed macros. compiler/export.m: compiler/ml_code_gen.m: Use MR_bool rather than MR_Bool (MR_Bool is meant to be for references to the Mercury type bool__bool). runtime/mercury_types.h: Add a comment the MR_Bool is for references to bool__bool. */*.c: */*.h: */*.m: Add MR_ prefixes. |
||
|
|
3dc7964b6c |
Add MR_ prefixes to the configuration macros.
Estimated hours taken: 5 Add MR_ prefixes to the configuration macros. This change only adds prefixes to the definitions of the macros, not the uses. configure.in: aclocal.m4: runtime/mercury_conf.h.in: runtime/RESERVED_MACRO_NAMES: Add MR_ prefixes to all configuration macros. Consistently use a `_H' suffix for macros which indicate whether a header file exists. Remove unused macros RETSIGTYPE and USE_TYPE_LAYOUT. runtime/Mmakefile: runtime/mercury_conf_bootstrap.h: Define the non-prefixed macros for backwards compatibility. |
||
|
|
678fa1075f |
Add a capability for measuring statistics about the stack frame usage
Estimated hours taken: 6
Branches: main
Add a capability for measuring statistics about the stack frame usage
of a program.
configure.in:
Find out the symbolic names of the max values for the 16 and 32 bit
integer types.
runtime/mercury_conf.h.in:
Include MR_{UINT,INT}_LEAST{16,32}_MAX among the macros whose values
are determined by autoconfiguration.
runtime/mercury_conf_param.h:
Document MR_STACK_FRAME_STATS as a macro whose definition causes the
program to collect statistics on stack frame sizes.
Fix an obsolete reference: PARALLEL was renamed MR_THREAD_SAFE a long
time ago.
Document the incompatibility between MR_THREAD_SAFE and the statistics
collection flags.
runtime/mercury_stacks.h:
If MR_STACK_FRAME_STATS is defined, then record statistics every time
we create a stack frame.
runtime/mercury_stacks.c:
Define the global variables and functions needed for stack frame
statistics.
runtime/mercury_heap_profile.h:
runtime/mercury_dword.h:
Move the macros for managing 64-bit counters from
mercury_heap_profile.h to a new header file, mercury_dword.h,
since mercury_stacks.h now needs such counters too.
Rewrite the macros to make fewer assumptions, using MR_int_least64_t
and MR_int_least32_t instead of "long long" and "int".
Add expression-like forms of some of the macros for use in
mercury_stacks.h.
Rename the type MR_dword as MR_Dword.
runtime/mercury_heap_profile.c:
#include the new header file.
runtime/mercury_prof.c:
Conform to the change from MR_dword to MR_Dword.
runtime/Mmakefile:
Add the new header file to the list of header files.
runtime/mercury_wrapper.c:
If MR_STACK_FRAME_STATS is defined, initialize the stack frame stats
before execution starts and write out the statistics when execution
ends.
tools/speedtest:
Add an option that when set, causes the script to report stack frame
stats for each variant being tested.
|
||
|
|
74645f2293 |
Fix a bug that caused a core dump if the debugger attempted to look at stack
Estimated hours taken: 6
Branches: main
Fix a bug that caused a core dump if the debugger attempted to look at stack
frames with more than 64 live variables on the stack.
runtime/mercury_stack_layout.h:
Fix a bug. The array of lval descriptors in a label layout structures
has two components: the long descriptors and the short descriptors.
The bug was that we were using an index with respect to the start
of the first subarray to index into the second subarray. The fix is
to subtract the length of the first subarray from the index first.
(This problem rarely bit before because the first subarray's length
is almost always zero.)
runtime/mercury_layout_util.c:
Improve existing debugging code, but make its compilation conditional.
The difference this makes in runtime is not significant for the
debugger, but would be significant for native gc.
runtime/mercury_conf_param.h:
Document the macro the debugging code is conditional on.
trace/mercury_trace_vars.c:
Set unused fields of Var_Spec structures to explicitly invalid values,
to avoid possible misinterpretation when using gdb.
tests/debugger/lval_desc_array.{m,inp,exp,exp2}:
A regression test to check for the presence of the bug.
tests/debugger/Mmakefile:
Enable the new test case.
|