mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-24 05:43:53 +00:00
083d376e6598628362ee91c2da170febd83590f4
149 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
05ef8e01fb |
Rename the .ll_debug grade component to .c_debug.
Rename mmc and mgnuc options that set this grade component to --c-debug-grade.
Let the options named --c-debug of both mmc and mgnuc enable C level debugging
of only the module being compiled.
runtime/mercury_grade.h:
Rename the .ll_debug grade component to .c_debug. Also rename the C macro
that controls the presence or absence of this grade component
from MR_LL_DEBUG to MR_C_DEBUG_GRADE.
runtime/mercury_conf_param.h:
runtime/mercury_debug.c:
runtime/mercury_debug.h:
runtime/mercury_engine.c:
runtime/mercury_label.c:
runtime/mercury_memory_zones.c:
runtime/mercury_memory_zones.h:
runtime/mercury_overflow.c:
runtime/mercury_std.h:
runtime/mercury_wrapper.c:
Rename the MR_LOWLEVEL_DEBUG macro to MR_DEBUG_THE_RUNTIME.
Previously, the name of this macro wrongly implied that it had
something to do with the old .ll_debug grade component, even though
- the MR_LOWLEVEL_DEBUG macro was designed to debug LLDS grades,
since only these existed when it was created, while
- the .ll_debug grade component (now .c_debug) is useful only for
MLDS grades targeting C.
compiler/options.m:
Rename the old confusingly named low_level_debug option to c_debug_grade.
Move it to the list of grade options, and fix its documentation, which
was completely wrong:
- code in compile_target_code.m treated it as being a synonym of
the .ll_debug (now .c_debug) grade component, while
- its (commented out) documentation here in options.m said it called for
the enabling of what is now MR_DEBUG_THE_RUNTIME.
compiler/compile_target_code.m:
Conform to the rename just above.
Define MR_C_DEBUG_GRADE instead of MR_LL_DEBUG if c_debug_grade is enabled.
Pass -g to the C compiler if either c_debug_grade or target_debug
is enabled.
Add an XXX about a missing safety check for an obsolete experimental
feature.
compiler/compute_grade.m:
When given a grade with a .c_debug grade component, set only the
c_debug_grade option; don't set the target_debug option, which is NOT
a grade option. The change to compile_target_code.m above handles the
only situation in which this implication was formerly required.
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
Look for and process the .c_debug grade component instead of .ll_debug.
Use a sh variable named c_debug_grade to record its absence/presence.
Look for and process the --c-debug-grade grade-component option,
setting the same sh variable, c_debug_grade. (All grade components
can be set piecemeal using sh options to the scripts using these
subroutines.) This replaces the old, confusingly named option
--low-level-debug.
scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
Consistently use the sh variable c_debug to record the presence of
the (non-grade) --c-debug option to mgnuc, and the sh variable
c_debug_grade to record the presence of the .c_debug grade component.
Stop looking for and handling the --low-level-debug option, which
mgnuc used to document, even though this duplicated the same documentation
in init_grade_options.sh-subr, which mgnuc includes. The difference was
that init_grade_options.sh-subr meant it to represent the old .ll_debug
MLDS grade component, while mgnuc treated it as specifying what is now
MR_DEBUG_THE_RUNTIME for LLDS grades. It didn't help that two sh variables
with quite different semantics had names that differed only in an
underscore: LLDEBUG_OPTS vs LL_DEBUG_OPTS.
scripts/Mmakefile:
Add a missing dependency to force the rebuild of mgnuc after each update
of its sh subroutine mgnuc_file_ops.sh-subr.
doc/user_guide.texi:
Document the --c-debug-grade option of mmc. This option was not publicly
documented under its original misleading name (--low-level-debug), but
its documentation is now possible without contorted dancing around the
name.
Clarify the documentation of mgnuc's --c-debug option.
README.sanitizers:
configure.ac:
Conform to the rename of the grade component.
grade_lib/grade_spec.m:
grade_lib/grade_string.m:
grade_lib/grade_structure.m:
grade_lib/try_all_grade_structs.m:
Conform to the rename of the grade component .ll_debug to .c_debug.
Don't allow the .c_debug grade component in LLDS grades.
In grade_string.m, add some obvious implications of some grade components.
grade_lib/choose_grade.m:
grade_lib/grade_lib.m:
grade_lib/test_grades.m:
grade_lib/var_value_names.m:
Fix white space.
scripts/ml.in:
tools/lmc.in:
tools/test_mercury:
Conform to the change in compile_target_code.m to the naming of
Boehm gc library variants.
|
||
|
|
bb98e8c7ba |
Delete unused MR_CAN_GET_PC_AT_SIGNAL macro.
runtime/mercury_conf_param.h:
As above.
|
||
|
|
3e894a7a9d |
Remove the hl grade component.
As we discussed, it has fallen into disuse. Its main purpose was to
pave the way for the .net backend and later for the java and csharp grades.
Now that the .net backend is ancient history and the java and csharp grades
are established, that purpose is gone, and for every other purpose,
hlc is better because it is simpler and faster.
compiler/options.m:
Delete the --high-level-data option. It is no longer needed,
bacause the data representation scheme is now a direct function
of the target language.
doc/user_guide.texi:
Delete references to the --high-level-data option.
NEWS:
Mention that --high-level-data is no longer supported.
compiler/compute_grade.m:
Delete references to the hl grade component, and conform
to the deletion of the --high-level-data option.
compiler/compile_target_code.m:
Give some predicates more meaningful names, and conform to the
deletion of the --high-level-data option.
compiler/const_struct.m:
compiler/du_type_layout.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/lco.m:
compiler/mercury_compile_main.m:
compiler/ml_gen_info.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen_construct.m:
compiler/mlds_to_c_data.m:
compiler/mlds_to_c_func.m:
compiler/mlds_to_c_type.m:
compiler/mlds_to_c_util.m:
Conform to the deletion of the --high-level-data option.
grade_lib/grade_spec.m:
grade_lib/grade_vars.m:
Delete the datarep solver variable, since the data representation
is now a direct function of the target language.
Delete the requirements involving the deleted solver variable.
grade_lib/grade_structure.m:
Delete the datarep component of the representation of MLDS C grades,
since its value would now be fixed.
grade_lib/grade_solver.m:
grade_lib/grade_string.m:
grade_lib/try_all_grade_structs.m:
grade_lib/var_value_names.m:
Conform to the changes above.
grade_lib/Mmakefile:
Link the grade library's test programs statically, like we do
the executables in the other directories.
library/io.m:
library/robdd.m:
library/rtti_implementation.m:
runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
runtime/mercury_hlc_types.h:
Remove references to MR_HIGHLEVEL_DATA, as well as any code
that was guarded by #ifdef MR_HIGHLEVEL_DATA.
scripts/Mmake.vars.in:
scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
scripts/mmake.in:
scripts/mmc.in:
scripts/mtc:
scripts/parse_grade_options.sh-subr:
scripts/parse_ml_options.sh-subr.in:
Remove references to --high-level-data options.
In canonical_grade.sh-subr, compute the base grade more directly.
Remove a few left-over references to the assembler backend.
Add or fix vim modelines where relevant.
Fix inconsistent indentation.
Add missing ;;s in case statements.
Switch to using ${var} references instead of just $var.
tests/invalid/Mercury.options:
Make the test_feature_set test case run in grade java instead of hl.gc.
tests/invalid/test_feature_set.err_exp:
Update the expected out for the grade change.
|
||
|
|
f60caca91c |
Use trail segments by default in trailing grades.
Until now, we have supported two variants of trailing grades, those that use a
fixed-size trail (.tr) and those that use trail segments (.trseg). This change
removes support for fixed sized trails, and renames the .trseg grade component
to .tr. The .trseg grade now acts a synonym for .tr; it is deprecated, since we
intend to eventually delete it. Until then, the behavior of the old .tr grade
component should be available, though to developers only, by compiling the
whole system with EXTRA_CFLAGS = -DMR_USE_FIXED_SIZE_TRAIL.
runtime/mercury_conf_param.h:
Delete the MR_TRAIL_SEGMENTS macro. Its effect is now implied by
MR_USE_TRAIL, unless a new macro, MR_USE_FIXED_SIZE_TRAIL, is defined.
Developers can use this new macro to disable trail segments, should the
need for doing that arise.
runtime/mercury_grade.h:
Add a new macro that defines a binary compatibility version number for
trailing; use that in the grade part for trailing.
Use "_trfix" or "_trseg" as the prefix of the trailing part of the
MR_GRADE_VAR depending on if MR_USE_FIXED_SIZE_TRAIL is defined or
not.
runtime/mercury_trail.[ch]:
runtime/mercury_context.h:
Enable trail segments by default, only disabling them if
MR_USE_FIXED_SIZE_TRAIL is enabled.
runtime/mercury_wrapper.c:
trace/mercury_trace_cmd_developer.c:
Conform to the above changes.
compiler/compile_target_code.m:
Do not pass options for trail segments to the C compiler.
compiler/compute_grade.m:
Treat trseg as a synonym for tr.
compiler/options.m:
Deprecate --trail-segments.
grade_lib/grade_spec.m:
grade_lib/grade_string.m:
grade_lib/grade_structure.m:
grade_lib/grade_vars.m:
grade_lib/try_all_grade_structs.m:
grade_lib/var_value_names.m:
Remove the trseg component.
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
Remove support for the --trail-segments option.
doc/user_guide.texi:
Update the documentation for the --trail-segments.
Comment out the documentation of the --trail-size and --trail-size-kwords
runtime options; they are no longer useful to non-developers.
NEWS:
Announce this change.
|
||
|
|
de3a95a874 |
Delete tags_high.
We last used in the mid 1990s, and there is no reason to ever use it again.
compiler/globals.m:
Delete the tags_high alternative in the tags_method type.
compiler/builtin_ops.m:
Delete the mktag and unmktag operations, since they are no-ops
in the absence of tags_high.
compiler/bytecode.m:
compiler/c_util.m:
compiler/compile_target_code.m:
compiler/const_struct.m:
compiler/erl_call_gen.m:
compiler/handle_options.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/ml_unify_gen.m:
compiler/mlds_dump.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
compiler/options.m:
compiler/peephole.m:
compiler/tag_switch.m:
compiler/unify_gen.m:
Conform to the changes above.
runtime/mercury_conf_param.h:
Delete the MR_HIGHTAGS macro, which is what calls for the tags_high
representation in the runtime.
runtime/mercury_grade.h:
runtime/mercury_tags.h:
runtime/mercury_wrapper.c:
Delete references to MR_HIGHTAGS, and the code that was included
only if it was defined.
|
||
|
|
d465fa53cb |
Update the COPYING.LIB file and references to it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
|
||
|
|
e1282bebaa |
Check for sched.h CPU set macros at configure time.
This fixes a build problem on Linux distributions with glibc version < 2.7.
configure.ac:
runtime/mercury_conf.h.in:
Define MR_HAVE_SCHED_CPUSET_MACROS if sched.h includes the
dynamic-sized CPU set macros (CPU_ALLOC, CPU_*_S, etc.)
that first appeared in glibc 2.7.
runtime/mercury_conf_param.h:
Do not define MR_HAVE_THREAD_PINNING if sched_[gs]etaffinity are
available but not the dynamic-sized CPU set macros.
runtime/mercury_context.c:
Check for MR_HAVE_SCHED_CPUSET_MACROS instead of CPU_* macros.
|
||
|
|
b58cc673e4 |
Fix boxing/unboxing of 64-bit integers in pregen grades.
64-bit integers should be boxed in .pregen grades. We forgot to define MR_BOXED_INT64S in .pregen grades so the wrong definitions of the MR_(un)box_(u)int64 macros were being used when compiling pregenerated C source files on 64-bit machines. Fixes bug #454. runtime/mercury_conf_param.h: Define MR_BOXED_INT64S in .pregen grades. Add reference to handle_options.m runtime/mercury_conf.h.in: runtime/mercury_engine.h: Update some comments. compiler/handle_options.m: Add reference to mercury_conf_param.h |
||
|
|
50e9569df1 |
Remove runtime support for reserved addresses.
configure.ac:
Require that the installed compiler is recent enough that it
can't generate type representations using reserved addresses.
runtime/mercury_type_info.h:
Delete the parts of the RTTI that dealt with du types
whose representations included reserved addresses.
runtime/mercury_tags.h:
Delete the definitions dealing with the representation of lists
in the presence of reserved addresses.
library/construct.m:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_table_type_body.h:
runtime/mercury_types.h:
runtime/mercury_unify_compare_body.h:
trace/mercury_trace_cmd_developer.c:
trace/mercury_trace_tables.c:
Conform to the change above by deleting code that dealt with reserved
addresses.
runtime/mercury_conf_param.h:
Delete an obsolete entry in a list.
|
||
|
|
f4e0059a49 |
Eliminate hlc_nest and hl_nest grades ...
... by eliminating the grade component that calls for the use of gcc nested
functions.
runtime/mercury_grade.h:
compiler/compute_grade.m:
Delete the gcc_nested_functions grade component, and the C macro
that specifies its presence, MR_USE_GCC_NESTED_FUNCTIONS.
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
Delete the code that parses the deleted grade component,
and delete the code that signals its absence in other grades.
compiler/options.m:
Delete the gcc_nested_functions grade option.
Delete also the gcc_local_labels option, since it was useful
only if gcc_nested_functions was set.
configure.ac:
Delete the code that sometimes added hl*_nest grades to the list of grades
to be installed.
Fix a bunch of comments.
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/ml_args_util.m:
compiler/ml_call_gen.m:
compiler/ml_code_util.m:
compiler/ml_commit_gen.m:
compiler/ml_gen_info.m:
compiler/mlds_to_c.m:
library/backjump.m:
library/exception.m:
runtime/mercury_hlc_types.h:
runtime/mercury_tabling.c:
runtime/mercury_tabling.h:
Delete code that was active only in grades with the deleted grade
component.
compiler/ml_accurate_gc.m:
compiler/notes/grade_library.html:
runtime/mercury_conf_param.h:
Delete mentions of the deleted grade component.
compiler/ml_code_gen.m:
Delete mentions of the deleted grade component, and a bunch of other
obsolete comments.
doc/user_guide.texi:
Fix a line break.
|
||
|
|
f99dba9120 |
Disable file IDs on Windows.
Since the original commit
|
||
|
|
1fc495c33c |
Fix bug #357: parallel conjunction broken on OS X.
The parallel version of the runtime makes use of POSIX unnamed semaphores,
which do not exist on OS X (although annoyingly most of the relevant functions
*do* exist, they just don't do anything). This was originally a problem for
the low-level C version of the parallel runtime, but now affects both C
backends (i.e. it's currently impossible to use threads or parallel
conjunctions on OS X). The fix is to replace the use of POSIX unnamed
semaphores on OS X, with the semaphore implementation for libdispatch (which is
part of Grand Central Dispatch). Note that the .par grades are (presumably)
still broken in versions of OS X prior to 10.6 -- they'll now just fail to
compile rather than fail at runtime.
configure.ac:
runtime/mercury_conf.h.in:
Check whether libdispatch is present.
runtime/mercury_conf_param.h:
Define a macro that says whether we want to use libdispatch; always
define this macro on OS X. Using libdispatch (optionally) on other systems
is future work.
runtime/mercury_thread.{c,h}
Define the MercurySem type and its associated operations appropriately
when using libdispatch.
library/Mmakefile:
Recompile the thread and thread.semaphore if any of the runtime headers
that define the macros they use change.
|
||
|
|
53b573692a |
Convert C code to use // style comments.
runtime/*.[ch]:
trace/*.[chyl]:
As above. In some places, improve comments, e.g. by expanding contractions
such as "we've". Add #ifndef guards against double inclusion around
the trace/*.h files that did not already have them.
tools/*:
Make the corresponding changes in shell scripts that generate .[ch] files
in the runtime.
tests/*:
Conform to a slight change in the text of a message.
|
||
|
|
67326f16e4 |
Fix style issues in the runtime.
Move all .h and .c files to four-space indentation without tabs, if they weren't there already. Use the same vim line for all .h and .c files. Align all backslashes at the ends of lines in macro definitions. Align close comment signs. In some places, fix inconsistent indentation. Fix a bunch of comments. Add XXXs to a few of them. |
||
|
|
7836eb68e6 |
Move grade compatibility tests to mercury_grade.h.
Fix some comments (mostly in layout) in all the touched runtime headers.
runtime/mercury.h:
Simplify the error message on the one grade compatibility test
that is best kept out of mercury_grade.h, because it is next to
the cause of the potential incompatibility.
runtime/mercury_grade.h:
Add a comment about the grade compatibility test still in mercury.h.
Move all the grade compatibility tests from mercury_conf_param.h here.
Reword their error messages to talk directly about the user-visible
grade components (or the Mercury compiler options enabling them,
if there is no single grade component name for them) instead of the
names of the C macros representing them.
Group some related existing tests together.
runtime/mercury_conf_param.h:
Move all the grade compatibility tests here to mercury_grade.h.
compiler/compile_target_code.m:
Add a XXX.
|
||
|
|
d5bef1437c |
Fix a typo.
runtime/mercury_conf_param.h:
Add a missing space.
|
||
|
|
c8d718ec57 |
Remove the .regparm and .picreg grade components.
For picreg, this is only the first half of the change; it deletes code
that generates references to this grade component. When this diff has been
installed on all our machines, will come the second half, which will delete
the code that understands references to picreg. The delay is needed because
your current installed compiler is still generating such references.
runtime/mercury_grade.h:
Remove both regparm and picreg as grade components.
doc/user_guide.texi:
Remove the (commented out) documentation of picreg; regparm had
no documentation to delete.
runtime/mercury_std.h:
Remove the small bit of code that implemented regparm.
runtime/mercury_conf_param.h:
Don't define MR_PIC_REG.
runtime/machdeps/i386_regs.h:
runtime/mercury_conf_bootstrap.h:
Remove references to picreg.
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
Keep in place the code that accepts picreg grade components,
but make them do nothing. Mark such do-nothing code so that
it can be deleted when this first-half diff has been bootstrapped.
configure.ac:
Delete the autoconfigured variable EXT_FOR_LINK_WITH_PIC_OBJECTS,
which could be set to either 'lpic_o' or just 'o', because it is now
*always* the latter.
scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
Remove code that transmitted the value of EXT_FOR_LINK_WITH_PIC_OBJECTS
to the compiler via the --link-with-pic-object-file-extension option.
compiler/options.m:
Keep the --link-with-pic-object-file-extension and --pic-reg options,
but mark them for deletion in the second half of this change.
compiler/compile_target_code.m:
Change the code that dealt with the value of the
--link-with-pic-object-file-extension and --pic-reg options to assume
that the former is always the same as the non-pic file extension,
and that --pic-reg is never needed. The former means that we don't need
to handle link_with_pic as a separate category of object files from
just plain non_pic.
compiler/compute_grade.m:
Keep accepting picreg grades, but mark the code that does this
for deletion.
compiler/make.program_target.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
Conform to the changes above.
|
||
|
|
59e6180eb9 |
Fix a portability issue with 64-bit Cygwin.
library/float.m:
MR_in_least64_t is a long on 64-bit Cygwin systems.
runtime/mercury_conf_param.h:
Define macros that allow us to distinguish between 32-
and 64-bit Cygwin.
|
||
|
|
cd72d000a8 |
Remove support for the MPS garbage collector.
As Tomas By's recent emails suggest, this support is doing more harm than good,
by falsely implying to people that MPS is a viable alternative to the Boehm
collector. The MPS collector was only ever experimental, and never performed
as well as Boehm. MPS isn't even in the git repository on git hub. It was
stored in a separate CVS repository on mundula, and (as far as I know)
wasn't carried over to github. The code of MPS was last touched a long time
ago; I would be surprised if it worked on today's systems without changes.
Mmake.common.in:
Mmake.workspace:
RESERVED_MACRO_NAMES:
boehm_gc/Mmakefile:
compiler/add_pragma.m:
compiler/compile_target_code.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c.m:
compiler/options.m:
compiler/peephole.m:
doc/user_guide.texi:
library/benchmarking.m:
runtime/Mmakefile.m:
runtime/mercury.h:
runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
runtime/mercury_heap.h:
runtime/mercury_init.h:
runtime/mercury_memory.h:
runtime/mercury_wrapper.[ch]:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/ml.in:
scripts/parse_grade_options.sh-subr:
util/mkinit.c:
Remove all references to MPS.
|
||
|
|
f6fafa150d |
Fix Mantis bug 314 for temp frames created by nondet procedures.
Also fix some bugs in related code, and improve the related debugging
infrastructure.
-------------------
runtime/mercury_stacks.[ch]:
Fix bug 314 for temp frames created by nondet procedures. The fix will
probably also work for *det* procedures that create temp frames on the
nondet stack, but I can't think of a way to test that, because det
procedures create such frames only in very specific circumstances,
and I cannot think of a way to nest a recursive call inside those
circumstances.
The problem was that when we were creating new temp frames on
the nondet stack, we did not check whether the current nondet stack segment
had room for them. We now do.
The stack trace tracing code needs to know the size of each nondet stack
frame, since it uses the size to classify frames as temp or ordinary.
The size is given by the difference in address between the address of the
frame and the address of the previous frame. This difference would yield
an incorrect size and hence an incorrect frame classification if a temp
frame were allowed to have a frame on a different segment as its
immediate predecessor.
We prevent this by putting an ordinary (i.e. non-temp) frame at the bottom
of every new nondet stack segment as a sentinel. We hand-build this frame,
since it is not an "ordinary" ordinary frame. It is not created by a call,
so it has no meaningful success continuation, and since it does not make
any calls, no other frame's success continuation can point to it either.
If backtracking reaches this sentinel frame, we use this fact to free
all the segments beyond the one the sentinel frame is in, but keep the
frame the sentinel frame is in, since we are likely to need it again.
Document the reason why MR_incr_sp_leaf() does not have to check
whether a new stack segment is needed. (See the fix to llds_out_instr.m
below.)
runtime/mercury_stack_trace.[ch]:
When traversing the nondet stack, treat the sentinel frame specially.
We have to, since it is an ordinary frame (i.e. it is not a temp frame),
but it is not an "ordinary" ordinary frame: it does not make calls,
and hence calls cannot return to it, and it does not return to any
other frame either. It therefore does not have the layout structures
(label and proc) that the nondet stack traversal expects to find.
Fix an old bug: the nondet stack traversal used a simple directional
pointer comparison to check whether it has reached the bottom of the nondet
stack. This is NOT guaranteed to work in the presence of stack segments:
depending on exactly what addresses new stack segments get, a stack frame
can have an address BELOW the address of the initial stack frame
even if it is logically ABOVE that stack frame.
Another old bug was that a difference between two pointers, which could
be 64 bit, was stored in an int, which could be 32 bit.
The nondet stack traversal code used a similar directional comparison
to implement optionally stopping at an arbitrary point on the nondet stack.
Fixing this facility (the limit_addr parameter of MR_dump_nondet_stack)
while preserving reasonable efficiency would not be trivial, but it would
also be pointless, since the facility is not actually used. This diff
deletes the parameter instead.
Move some loop invariant code out of its loop.
trace/mercury_trace_cmd_developer.c:
trace/mercury_trace_external.c:
Don't pass the now-deleted parameter to mercury_stack_trace.c.
runtime/mercury_wrapper.c:
Record the zone of the initial nondet stack frame, since the fix
of mercury_stack_trace.c needs that info, and it is much more efficient
to set it up just once.
tests/hard_coded/bug314.{m,exp}:
The regression test for this bug.
tests/hard_coded/Mercury.options:
Compile the new test case with the options it needs.
tests/hard_coded/Mmakefile:
Enable the new test case.
-------------------
runtime/mercury_wrapper.c:
The compiler knows the number of words in a stack frame it is creating,
not necessarily the number of bytes (though it could put bounds on that
from the number of tag bits). Since this size must sync with the runtime,
change the runtime's variable holding this size to also be in words.
Note that similar changes would also be beneficial for other sizes.
compiler/llds_out_instr.m:
Conform to the change in mercury_wrapper.c, fixing an old bug
(mercury_wrapper.c reserved 128 BYTES for leaf procedures, but
llds_out_instr.m was using that space for procedures whose frames
were up to 128 WORDS in size.)
compiler/mercury_memory.c:
Conform to the change in mercury_wrapper.c.
-------------------
runtime/mercury_memory_zones.h:
Instead of starting to use EVERY zone at a different offset, do this
only for the INITIAL zones in each memory area, since only on these
is it useful. When the program first starts up, it WILL be using
the initial parts of the det stack, nondet stack and heap, so it is
useful to make sure that these do not collide in the cache. However,
when we allocate e.g. the second zone in e.g. the nondet stack, we are
no more likely to be beating on the initial part of any segment
of the det stack than on any other part of such segments.
If a new debug macro, MR_DEBUG_STACK_SEGMENTS_SET_SIZE is set (to an int),
use only that many words in each segment. This allows the segment switchover
code to be exercised and debugged with smaller test cases.
runtime/mercury_conf_param.h:
Document the MR_DEBUG_STACK_SEGMENTS_SET_SIZE macro.
Convert this file to four-space indentation with tabs expanded.
-------------------
runtime/mercury_overflow.h:
Make abort messages from overflows and underflows more useful by including
more information.
runtime/mercury_overflow.c:
Add a new function to help with the better abort messages.
Since this file did not exist before, create it.
runtime/Mmakefile:
Add the new source file to the list of source files.
-------------------
runtime/mercury_debug.[ch]:
Fix problems with the formatting of the debugging output from existing
functions.
Add new functions for dumping info about memory zones.
Factor out some common code.
Convert the header file to four-space indentation.
-------------------
runtime/mercury_grade.c:
Generate an error if stack segments are specified together with stack
extension
-------------------
trace/.gitignore:
util/.gitignore:
tests/debugger/.gitignore:
List some more files.
-------------------
runtime/mercury_context.c:
runtime/mercury_engine.[ch]:
runtime/mercury_misc.h:
compiler/notes/failure.html:
Fix white space.
|
||
|
|
1094f42cc9 |
Conform to memory alignment requirements on doubles.
On some 32-bit architectures, we were violating memory alignment requirements for double-precision floats, in cell fields and on det and nondet stacks. Bug #299. We now only take the address of a double field when it occurs on an aligned memory address, i.e. when it starts at an even word offset from the start of a cell (this assumption is incompatible with term-size profiling which adds a hidden word before the start of the cell). For the det stack, we can round up allocations to keep the stack pointer double-aligned, then allocate slots for doubles at even word offsets from the stack pointer. It would be trickier for the nondet stack. Multiple frame types exist on the nondet stack, and the different frame types are identified by their sizes: 3-word and 4-word temporary frames, and 5/6+ word ordinary frames. Rather than rounding up frame sizes to even numbers of words, we would probably want to dynamically pad ordinary frame allocations, such that any doubles in the frame will be at aligned addresses. However, in this change, we simply store box floats on the nondet stack. compiler/globals.m: Add predicate which returns whether double-width floats should be stored on the det stack. compiler/handle_options.m: Disable double-word fields in term-size profiling grades. compiler/code_info.m: Add a predicate to round up det stack frame sizes. Remember the width of floats stored on the det stack in exprn_opts. compiler/hlds_llds.m: compiler/llds.m: compiler/stack_layout.m: Delete the possibility of double-width slots on the nondet stack. Remember det_stack_float_width in exprn_opts. compiler/llds_out_data.m: Add wrapper macro `MR_dword_ptr' when taking the address of a double. Only take the address of doubles on the det stack. compiler/llds_out_instr.m: compiler/llds_out_util.m: Only assign a double field in a single C statement when it is aligned. Assert that the stack pointer is incremented by an even number, if necessary. compiler/mlds_to_c.m: Only take the address of doubles when aligned. compiler/middle_rec.m: compiler/proc_gen.m: Round up det stack frame allocations to even numbers of words when necessary. compiler/stack_alloc.m: Add padding as required so that double-word variables will be allocated at even-word offsets from the stack pointer. compiler/opt_debug.m: compiler/par_conj_gen.m: Conform to changes. runtime/mercury_conf_param.h: runtime/mercury_float.h: Add macro `MR_dword_ptr' to be wrapped around instances where the address of a double is taken. When `MR_DEBUG_DWORD_ALIGNMENT' is defined (and using gcc or clang) the address is checked to be properly aligned. Almost all our development is done on x86 or x86-64 architecture which do not have strict memory alignment requirements, making violations hard to check otherwise. runtime/mercury_deconstruct.c: runtime/mercury_layout_util.c: Use `MR_float_from_dword' over `MR_float_from_dword_ptr' as the former does not require dword alignment. Related fix: looking up `double' variables on the nondet stack used the stack pointer for the det stack instead. Fix it, though the code now won't be executed after this change. tests/debugger/nondet_stack.exp5: Add new expected output. This is the same as nondet_stack.exp except that det stack frames have been rounded up. |
||
|
|
5c0082083c |
Work around `isinf' link error on Solaris.
On Solaris, `isinf' is detected by configure but we pass -fno-builtin for global registers on x86/x86-64, and that causes an undefined reference to `isinf' when linking. configure.ac: runtime/mercury_conf.h.in: Check for existence of `finite'. runtime/mercury_conf_param.h: Define MR_SOLARIS if appropriate. runtime/mercury_float.c: Don't use `isinf' or `isinff' on Solaris. Add a better `MR_is_inf' fallback using `finite'. |
||
|
|
b8aed192cd |
Fix float.float64_bits_string/1 on MinGW64.
library/float.m:
Use the appropriate conversion specifier for
MR_int_least64_t on MinGW64 in a spot.
runtime/mercury_conf_param.h:
Define MR_MINGW64 on MinGW64 systems.
|
||
|
|
bdf0261af6 |
Avoid warnings in high-level C runtime with MinGW64.
runtime/mercury_conf_param.h:
On MinGW64, define the macro __USE_MINGW_ANSI_STDIO.
This avoids problems with incomplete (i.e. broken) support
for long long format specifiers in formatted I/O functions
in Microsoft's C library.
|
||
|
|
ad4b79e6ee |
Add a `pregen' grade component.
Add a `pregen' grade component and associated option `--pregenerated-dist',
intended for use in the pre-generated C files in the source distribution
ONLY.
Traditionally, by forcing the use of 2 tag bits and boxed floats, we
could provide one set of pre-generated C files, nominally targeting
32-bit platforms but also working on 64-bit platforms.
This became insufficient after I made two data representation changes.
The same constructor may have different layouts of its arguments
for --bits-per-word=32 and --bits-per-word=64:
- double-precision `float' arguments can be stored across two
words on 32-bit, whereas only one word is required on 64-bit;
- consecutive enum arguments can be packed into a single word
but the number of arguments that can be packed differs.
As a result, data structures created in a user module could be
misinterpreted when passed to a pre-generated standard library module,
and vice versa. (The enum case probably does not occur in practice.)
The solution adopted here is to allow configure to detect normal 64-bit
settings (3 tag bits, unboxed floats) irrespective of whether a usable
Mercury installation already exists. When present, the `pregen' grade
component causes the compiler and scripts to override the configuration
and enforce settings for portable C source files. The source
distribution should supply C source files from a `pregen' grade.
During installation, if required, the pre-generated C source files are
used to build and install a Mercury compiler _in a .pregen grade_.
Then it is used to install the libraries _in non-.pregen grades_,
so that configured settings have their usual effect.
Another benefit is that a user on a 64-bit system will get the "optimal"
installation using 3 tag bits and unboxed floats without additional
effort.
A small disadvantage is that a minimal installation of Mercury takes
slightly longer, as the default library grade no longer comes from the
pre-generated C source files.
compiler/options.m:
Add `--pregenerated-dist' option (same as `pregen' grade component).
Add `--arg-pack-bits <n>' internal option.
`--allow-argument-packing' is obsolete.
Add `--allow-double-word-fields' internal option.
compiler/handle_options.m:
Add `pregen' grade component. `pregen' implies boxed floats and
`spf' (single-prec float) implies unboxed floats, so we consider
them incompatible. There should be no need to use both at once.
In `pregen' grades, override settings to create portable C
source files.
Handle the internal `--arg-pack-bits <n>' option.
compiler/make_hlds_passes.m:
Pack only as many consecutive arguments as will fit into the
number of bits specified by `--arg-pack-bits', rather than into
the number of word bits. `pregen' implies --arg-pack-bits=32
Use `--allow-double-word-fields' to decide whether to store
floats across two words. `pregen' disables it.
compiler/compile_target_code.m:
Define MR_PREGENERATED_DIST when compiling C files in a `pregen'
grade.
compiler/c_util.m:
Write PREGENERATED_DIST={yes,no} into the grade info header at
the top of C files. This is checked by configure.
runtime/mercury_conf_param.h:
Make MR_PREGENERATED_DIST force the same settings as the
`--pregenerated-dist' option.
runtime/mercury_grade.h:
Add "_pregen" to the MR_GRADE macro so that `pregen' and
non-`pregen' object files are not accidentally mixed.
configure.ac:
As above, do NOT force 2 tag bits and unboxed floats when there
is no usable Mercury compiler installed.
BOOTSTRAP_GRADE is now a grade containing `.pregen'.
Make a minimal installation install $BEST_GRADE_FOR_COMPILER as
the default grade, not the grade that the compiler happens to be
built in, which might be a `pregen' grade.
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
Support `pregen' grade component and `--pregenerated-dist'
in shell scripts.
tools/test_mercury:
Add a note.
|
||
|
|
36ac880e97 |
Fix bug #243: the management of memory zones on Windows was broken, causing a
Branches: main, 11.07 Fix bug #243: the management of memory zones on Windows was broken, causing a memory leak in trseg and (presumably) stseg grades. In grades that use conservative GC on most systems (e.g. Linux or Mac OS X), allocation of memory for memory zones is handled by the Boehm collector. On Windows, the situation was a bit different because we were trying to emulate mprotect style memory protection. Instead of allocating the memory for the zone using the Boehm collector, the memory was reserved using a call to VirtualAlloc and then all the memory within the zone was added to the Boehm GC's root set. We could then use VirtualAlloc and friends to emulate mprotect. In principle, this is fine, in practice there are number of problems with it. When a memory zone was deallocated the call to VirtualFree was silently failing (the return value of this call wasn't checked) -- this meant that the memory in the zone was not being freed, hence the leak. The immediate cause of this is that we are calling VirtualFree with the wrong argument values for those used in the corresponding call to VirtulAlloc. Unfortunately, putting the "correct" value in, just results in a segmentation fault. (I suspect we haven't actually been allocating the memory correctly either.) Aside from this a second problem is that while we register the words in the memory zone as GC roots when we allocate it, we do not remove them from the GC root set when we deallocate the zone. One rather obvious reason for this is that the Boehm GC doesn't support doing this on Windows! Yet another issue with all this is that while MR_protect_pages calls VirtualAlloc, the documentation in the code suggests it should be calling VirtualProtect. The fix here is to replace the VirtualAlloc way of managing memory zones on Windows with the Boehm GC approach used on all the other systems. The former is pretty much completely broken and only appeared to work because most grades only allocate a few memory zones at program startup and never deallocate them. This does mean the mprotect emulation we were doing on Windows will no longer work, but that's the lesser of two evils. (It may be possible to reinstate something like it using VirtualProtect, but that will require looking carefully at exactly how the Boehm collector allocates memory on Windows.) runtime/mercury_memory_zones.c: Use the Boehm GC for allocating memory zones on Windows when in grade that uses conservative GC. Delete the flawed approach that uses VirtualAlloc. runtime/mercury_conf_param.h: Do not define the macro MR_WIN32_VIRTUAL_ALLOC on Windows: we no longer use VirtualAlloc anywhere. Do not define MR_PROTECTPAGE and MR_CHECK_OVERFLOW_VIA_MPROTECT on Windows, since we no longer do any mprotect emulation on Windows. runtime/mercury_memory_handlers.c: Properly protect some code in the handler for Windows memory access errors that assumes that memory zones have a redzone. (After this change they won't have a redzone.) |
||
|
|
b060797cf7 |
A step towards getting a subset of deep profiling to work on Windows.
Branches: main, 11.07 A step towards getting a subset of deep profiling to work on Windows. runtime/mercury_conf_param.h: Re-order some definitions so that macros that specify C compiler or OS specific properties are defined first. This allows them to be used in subsequent definitions. Undefine MR_DEEP_PROFILING_TIMING if we are on Windows. Time profiling is not currently supported on Windows since it is implemented using setitimer and that function doesn't exist on Windows. (It does exist in Cygwin, but is rather dodgy IIRC -- I'll check on this separately a re-enable it in the Cygwin version if it turns out to work.) runtime/mercury_prof_time.[ch]: Fix incorrect guards: the contents of these files should only be visible if MR_DEEP_PROFILING_TIMING is enabled. |
||
|
|
a071eaba53 |
Improve thread pinning:
+ Now pins threads intelligently on SMT systems by balancing threads among
cores.
+ performs fewer migrations when pinning threads (If a thread's current
CPU is a valid CPU for pinning, then it is not migrated).
+ Handle cases where the user requests more threads than available CPUs.
+ Handle cases where the process is restricted to a subset of CPUs by its
environment. (for instance, Linux cpuset(7))
This is largely made possible by the hwloc library
http://www.open-mpi.org/projects/hwloc/ However, hwloc is not required and the
runtime system will fall back to sched_setaffinity(), it will simply be less
intelligent WRT SMT.
runtime/mercury_context.h:
runtime/mercury_context.c:
Do thread pinning either via hwloc or sched_setaffinity. Previously only
sched_setaffinity was used.
Update thread-pinning algorithm, this:
Include the general thread pinning code only if MR_HAVE_THREAD_PINNING is
defined.
Use a combination of sysconf and sched_getaffinity to detect the number of
processors when hwloc isn't available. This makes the runtime compatible
with Linux cpuset(7) when hwloc isn't available.
configure.in:
Mmake.common.in:
Detect presence of the hwloc library.
configure.in:
Detect sched_getaffinity()
aclocal.m4:
acinclude.m4:
Move aclocal.m4 to acinclude.m4, the aclocal program will build aclocal.m4
and retrieve macros from the system and the contents of acinclude.m4.
Mmakefile:
Create a make target for aclocal.m4.
runtime/Mmakefile:
Link the runtime with libhwloc in low-level C parallel grades.
Include CFLAGS for libhwloc.
scripts/ml.in:
Link programs and libraries with libhwloc in low-level C parallel grades.
runtime/mercury_conf.h.in:
Define MR_HAVE_HWLOC when it is available.
Define MR_HAVE_SCHED_GETAFFINITY when it is available.
runtime/mercury_conf_param.h:
Define MR_HAVE_THREAD_PINNING if either hwloc or [sched_setaffinity and
sched_getaffinity] are available.
runtime/mercury_thread.c:
runtime/mercury_wrapper.c:
Only call MR_pin_thread and MR_pin_primordial_thread if
MR_HAVE_THREAD_PINNING is defined.
runtime/mercury_thread.h:
runtime/mercury_context.h:
Move the declaration of MR_pin_primordial_thread to mercury_context.h from
mercury_thead.h since it's definition is in mercury_context.c.
Require MR_HAVE_THREAD_PINNING for the declaration of
MR_pin_primordial_thread.
runtime/mercury_wrapper.c:
Conform to changes in mercury_context.h
INSTALL_CVS:
tools/test_mercury
Run aclocal at the right times while testing Mercury.
|
||
|
|
573e6f2f00 |
Support unboxed float fields in high-level C grades.
Branches: main Support unboxed float fields in high-level C grades. When the representation of `float' is no wider than a machine word, d.u. functor arguments of type `float' (or equivalent) will be stored directly within cells constructed for that functor, instead of a pointer to the box containing the value. This was already so for low-level C grades. compiler/mlds.m: Add an option to mlds_type, equivalent to `mlds_array_type(mlds_generic_type)' except that some elements are known to be floats. Update some comments. compiler/ml_global_data.m: Remember the `--unboxed-float' option in `ml_global_data'. Special case generic arrays in `ml_gen_static_scalar_const_addr' and `ml_gen_static_scalar_const_value'. Float literals cannot be used to initialize an element of a generic array in C. If any appear, replace the generic array type by an instance of `mlds_mostly_generic_array_type' with float fields in the positions which have float initializers. compiler/ml_code_util.m: Make `ml_must_box_field_type' and `ml_gen_box_const_rval' depend on the `--unboxed-float' option. Delete some now-misleading comments. Delete an unused predicate. compiler/mlds_to_c.m: Update code that writes out scalar static data to handle `mlds_mostly_generic_array_type'. In one case, for `--high-level-data' only, output float constants by their integer representation, so that they may be cast to pointer types. compiler/ml_unify_gen.m: Rename some predicates for clarity. compiler/ml_accurate_gc.m: compiler/ml_lookup_switch.m: compiler/ml_proc_gen.m: compiler/ml_simplify_switch.m: compiler/mlds_to_cs.m: compiler/mlds_to_gcc.m: compiler/mlds_to_il.m: compiler/mlds_to_java.m: Conform to changes. library/float.m: Add hidden functions to return the integer representation of the bit layout of floating point values. library/exception.m: Delete mention of MR_AVOID_MACROS. runtime/mercury.c: runtime/mercury.h: Make MR_box_float/MR_unbox_float act like "casts" when MR_BOXED_FLOAT is undefined, and only define them in high-level grades. I think they should be replaced by MR_float_to_word/MR_word_to_float (which have less confusing names when there is no boxing) but that would require some header file reshuffling which I don't want to undertake yet. Delete references to MR_AVOID_MACROS. Apparently it existed to support the defunct gcc back-end but I cannot see it ever being defined. runtime/mercury_conf_param.h: MR_HIGHLEVEL_CODE no longer implies MR_BOXED_FLOAT. Delete mention of MR_AVOID_MACROS. runtime/mercury_float.h: Fix a comment. tests/hard_coded/Mmakefile: tests/hard_coded/float_ground_term.exp: tests/hard_coded/float_ground_term.m: Add a test case. |
||
|
|
ecbd4773d6 |
Respond to review comments from Paul.
Branches: main, 11.07 Respond to review comments from Paul. runtime/mercury_conf_param.h: Fix some spacing. runtime/mercury_std.h: Fix s/MR_GNUC/__GNUC__/ in a comment. |
||
|
|
8af00f7a2a |
Avoid using the __GNUC__ macro in the runtime as a test for the presence of
Branches: main, 11.07 Avoid using the __GNUC__ macro in the runtime as a test for the presence of gcc, since clang also defines that macro. Since clang doesn't support all of the GNU C extensions, we can't actually use __GNUC__ without also checking whether we are actually using clang. runtime/mercury_conf_param.h: Add three new macros, MR_CLANG, MR_GNUC and MR_MSVC that are defined only when the C compiler is clang, gcc, or Visual C respectively. (In particular, MR_GNUC will _not_ be defined when the C compiler is clang.) runtime/mercury.c: runtime/mercury.h: runtime/mercury_atomic_ops.c: runtime/mercury_atomic_ops.h runtime/mercury_bitmap.h: runtime/mercury_float.h: runtime/mercury_getopt.c: runtime/mercury_goto.h: runtime/mercury_heap.h: runtime/mercury_std.h: Replace uses of the __GNUC__ and __clang__ macros with the above. runtime/mercury_regs.h: As above, also #include mercury_conf_param.h directly since this file is #included by some of the tests in the configure script. |
||
|
|
7e26b55e74 |
Implement a new form of memory profiling, which tells the user what memory
Branches: main
Implement a new form of memory profiling, which tells the user what memory
is being retained during a program run. This is done by allocating an extra
word before each cell, which is used to "attribute" the cell to an
allocation site. The attribution, or "allocation id", is an address to an
MR_AllocSiteInfo structure generated by the Mercury compiler, giving the
procedure, filename and line number of the allocation, and the type
constructor and arity of the cell that it allocates.
The user must manually instrument the program with calls to
`benchmarking.report_memory_attribution', which forces a GC and summarises
the live objects on the heap using the attributions. The mprof tool is
extended with a new mode to parse and present that data.
Objects which are unattributed (e.g. by hand-written C code which hasn't
been updated) are still accounted for, but show up in profiles as "unknown".
Currently this profiling mode only works in conjunction with the Boehm
garbage collector, though in principle it can work with any memory allocator
for which we can access a list of the live objects. Since term size
profiling relies on the same technique of using an extra word per memory
cell, the two profiling modes are incompatible.
The output from `mprof -s' looks like this:
------ [1] some label ------
cells words cumul procedure / type (location)
14150 38872 total
* 1949/ 13.8% 4872/ 12.5% 12.5% <predicate `parser.parse_rest/7' mode 0>
975/ 6.9% 1950/ 5.0% list.list/1 (parser.m:502)
487/ 3.4% 1948/ 5.0% term.term/1 (parser.m:501)
487/ 3.4% 974/ 2.5% term.const/0 (parser.m:501)
* 1424/ 10.1% 4272/ 11.0% 23.5% <predicate `parser.parse_simple_term_2/6' mode 0>
708/ 5.0% 2832/ 7.3% term.term/1 (parser.m:643)
708/ 5.0% 1416/ 3.6% term.const/0 (parser.m:643)
...
boehm_gc/alloc.c:
boehm_gc/include/gc.h:
boehm_gc/misc.c:
boehm_gc/reclaim.c:
Add a callback function to be called for every live object after a GC.
Add a function to write out the GC_size_map array.
compiler/layout.m:
Define the alloc_site_info type which is equivalent to the
MR_AllocSiteInfo C structure.
Add alloc_site_array as a kind of "layout" array.
compiler/llds.m:
Add allocation sites to `cfile' structure.
Replace TypeMsg argument (which was also for profiling) on `incr_hp'
instructions by an allocation site identifier.
Add a new foreign_proc_component for allocation site ids.
compiler/code_info.m:
compiler/global_data.m:
compiler/proc_gen.m:
Keep the set of allocation sites in the code_info and global_data
structures.
compiler/unify_gen.m:
Add allocation sites to LLDS allocation instructions.
compiler/layout_out.m:
compiler/llds_out_file.m:
compiler/llds_out_instr.m:
Output MR_AllocSiteInfo arrays in generated C files.
Output code to register the MR_AllocSiteInfo array with the Mercury
runtime.
Output allocation site ids for memory allocation instructions.
compiler/llds_out_util.m:
Add allocation sites to llds_out_info.
compiler/pragma_c_gen.m:
compiler/ml_foreign_proc_gen.m:
Generate a macro MR_ALLOC_ID which resolves to an allocation site
structure, for every foreign_proc whose C code contains the string
"MR_ALLOC_ID". This is to be used by hand-written C code which
allocates memory.
MR_PROC_LABELs are retained for backwards compatibility. Though
they were introduced for profiling, they seem to have been co-opted
for printf-debugging since then.
compiler/ml_global_data.m:
Add allocation site structures to the MLDS global data.
compiler/mlds.m:
compiler/ml_unify_gen.m:
Add allocation site id to `new_object' instruction.
compiler/mlds_to_c.m:
Output allocation site arrays and allocation ids in high-level C code.
Output a call to register the allocation site array with the Mercury
runtime.
Delete an unused predicate.
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/mercury_compile_llds_back_end.m:
compiler/middle_rec.m:
compiler/ml_accurate_gc.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_util.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/use_local_vars.m:
compiler/var_locn.m:
Conform to changes.
compiler/pickle.m:
compiler/prog_event.m:
compiler/timestamp.m:
Conform to changes in memory allocation macros.
library/benchmarking.m:
Add the `report_memory_attribution' instrumentation predicates.
Conform to changes to MR_memprof_record.
library/array.m:
library/bit_buffer.m:
library/bitmap.m:
library/construct.m:
library/deconstruct.m:
library/dir.m:
library/io.m:
library/mutvar.m:
library/store.m:
library/string.m:
library/thread.semaphore.m:
library/version_array.m:
Use attributed memory allocation throughout the standard library so
that objects don't show up in the memory profile as "unknown".
Replace MR_PROC_LABEL by MR_ALLOC_ID.
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
Replace MR_PROC_LABEL by MR_ALLOC_ID.
profiler/Mercury.options:
profiler/globals.m:
profiler/mercury_profile.m:
profiler/options.m:
profiler/output.m:
profiler/snapshots.m:
Add a new mode to `mprof' to parse and present the data from
`Prof.Snapshots' files.
Add options for the new profiling mode.
profiler/process_file.m:
Fix a typo.
runtime/mercury_conf_param.h:
#define MR_MPROF_PROFILE_MEMORY_ATTRIBUTION if memory profiling
is enabled and we are using Boehm GC.
runtime/mercury.h:
Make MR_new_object take an allocation id argument.
Conform to changes in memory allocation macros.
runtime/mercury_memory.c:
runtime/mercury_memory.h:
runtime/mercury_types.h:
Define MR_AllocSiteInfo.
Add memory allocation functions and macros which take into the
account the additional word necessary for the new profiling mode.
These should be used in preferences to the raw memory allocation
functions wherever possible so that objects do not show up in the
profile as "unknown".
Add analogues of realloc/free which take into account the offset
introduced by the attribution word.
Add function versions of the MR_new_object macros, which can't be
written in standard C. They are only used when necessary.
Add built-in allocation site ids, to be used in the runtime and
other hand-written code when context-specific ids are unavailable.
runtime/mercury_heap.h:
Make MR_tag_offset_incr_hp_msg and MR_tag_offset_incr_hp_atomic_msg
allocate an extra word when memory attribution is desired, and store
the allocation id there.
Similarly for MR_create{1,2,3}_msg.
Replace proclabel arguments in allocation macros by alloc_id
arguments.
Replace MR_hp_alloc_atomic by MR_hp_alloc_atomic_msg. It was only
used for boxing floats.
Conform to change to MR_new_object macro.
runtime/mercury_bootstrap.h:
Delete obsolete macro hp_alloc_atomic.
runtime/mercury_heap_profile.c:
runtime/mercury_heap_profile.h:
Add the code to summarise the live objects on the Boehm GC heap and
writes out the data to `Prof.Snapshots', for display by mprof.
Don't store the procedure name in MR_memprof_record: the procedure
address is enough and faster to compare.
runtime/mercury_prof.c:
Finish and close the `Prof.Snapshots' file when the program
terminates.
Conform to changes in MR_memprof_record.
runtime/mercury_misc.h:
Add a macro to expand to the name of the allocation sites array
in LLDS grades.
runtime/mercury_bitmap.c:
runtime/mercury_bitmap.h:
Pass allocation id through bitmap allocation functions.
Delete unused function MR_string_to_bitmap.
runtime/mercury_string.h:
Add MR_make_aligned_string_copy_msg.
Make string allocation macros take allocation id arguments.
runtime/mercury.c:
runtime/mercury_array_macros.h:
runtime/mercury_context.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deconstruct_macros.h:
runtime/mercury_dlist.c:
runtime/mercury_engine.c:
runtime/mercury_float.h:
runtime/mercury_hash_table.c:
runtime/mercury_ho_call.c:
runtime/mercury_label.c:
runtime/mercury_prof_mem.c:
runtime/mercury_stacks.c:
runtime/mercury_stm.c:
runtime/mercury_string.c:
runtime/mercury_thread.c:
runtime/mercury_trace_base.c:
runtime/mercury_trail.c:
runtime/mercury_type_desc.c:
runtime/mercury_type_info.c:
runtime/mercury_wsdeque.c:
Use attributed memory allocation throughout the runtime so that
objects don't show up in the profile as "unknown".
runtime/mercury_memory_zones.c:
Attribute memory zones to the Mercury runtime.
runtime/mercury_tabling.c:
runtime/mercury_tabling.h:
Use attributed memory allocation macros for tabling structures.
Delete unused MR_table_realloc_* and MR_table_copy_bytes macros.
runtime/mercury_deep_copy_body.h:
Try to retain the original attribution word when copying values.
runtime/mercury_ml_expand_body.h:
Conform to changes in memory allocation macros.
runtime/mercury_tags.h:
Replace proclabel arguments by alloc_id arguments in allocation macros.
runtime/mercury_wrapper.c:
If memory attribution is enabled, tell Boehm GC that pointers may be
displaced by an extra word.
trace/mercury_trace.c:
trace/mercury_trace_tables.c:
Conform to changes in memory allocation macros.
extras/net/tcp.m:
extras/solver_types/library/any_array.m:
extras/trailed_update/tr_array.m:
Conform to changes in memory allocation macros.
doc/user_guide.texi:
Document the new profiling mode.
doc/reference_manual.texi:
Update a commented out example.
|
||
|
|
a59abb6d8d |
Define MR_CYGWIN if we using Cygwin.
Branches: main, 11.01 runtime/mercury_conf_param.h: Define MR_CYGWIN if we using Cygwin. library/io.m: Avoid using the macro __CYGWIN__ directly and use MR_CYGWIN instead. |
||
|
|
cd23a21717 |
Fix a problem with the handling of the environ "global variable" on MinGW
Branches: main
Fix a problem with the handling of the environ "global variable" on MinGW
that was resulting in a C compiler warning being emitted when the io
module was compiled.
library/io.m:
Don't declare the global variable environ on MinGW. On that
system it is a macro that expands to a function call that returns
the user environment.
Document the above. Also, gather the documentation about how
the environ "global" is handled on various systems into one comment.
runtime/mercury_conf_param.h:
Define MR_MINGW when we are using MinGW.
|
||
|
|
58211e2f2e |
Allow more than 2^15 vars in a procedure representation.
Estimated hours taken: 12 Branches: main Allow more than 2^15 vars in a procedure representation. mdbcomp/program_representation.m: Allow a variable number to be represented by four bytes as well as two and one. This means that we also have to represent the number of variables in a procedure using a four-byte number, not a two-byte number. Use four bytes to represent line numbers. Programs that overflow 16-bit var numbers may also overflow 16 bit line numbers. These requires a change in the deep profiler data's binary compatibility version number. compiler/prog_rep.m: Encode vars using four bytes if necessary. Be consistent in using only signed 8-bit as well as signed 16-bit numbers. compiler/implicit_parallelism.m: Conform to the change in program_representation.m. deep_profiler/profile.m: deep_profiler/read_profile.m: Add a compression flag to the set of flags read from the data file. Put the flags into the profile_stats as a group, not one-by-one. deep_profiler/canonical.m: deep_profiler/create_report.m: deep_profiler/dump.m: deep_profiler/mdprof_feedback.m: deep_profiler/old_html_format.m: deep_profiler/old_query.m: deep_profiler/query.m: Conform to the change in profile.m. runtime/mercury_deep_profiling.c: Prepare for compression of profiling data files being implemented. runtime/mercury_stack_layout.h: Fix some documentation rot. runtime/mercury_conf_param.h: Add an implication between debug flags to make debugging easier. |
||
|
|
7e7d77e23f |
Make coverage profiling data 'deep'.
The deep profiler associates measurements with their context in the call graph
modulo recursion. This has been true for all measurements except for coverage
profiling data. This patch allows coverage data to be associated with
ProcDynamic structures so that it is keyed by this context not just the static
procedure. This new behaviour is the default the old option of static coverage
profiling is still available for testing, as is no coverage profiling. Note
that, as before, coverage profiling is supported by default however coverage
points are not inserted by default.
This change will be used to measure the depth of recursion, and therefore the
average cost of recursion as well as the likely times when variables are
produced in calls for the automatic parallelisation analysis.
runtime/mercury_conf_param.h:
Create three new preprocessor macros:
MR_DEEP_PROFILING_COVERAGE - defined when coverage profiling is
enabled.
MR_DEEP_PROFILING_COVERAGE_STATIC - defined when static coverage
profiling is being used.
MR_DEEP_PROFILING_COVERAGE_DYNAMIC - defined when dynamic coverage
profiling is being used.
runtime/mercury_deep_profiling.h:
Update data structures to support dynamic coverage profiling.
Use conditional compilation to allow us to test the deep profiler in three
different modes, without coverage profiling, with static coverage profiling
and with dynamic coverage profiling.
Rename MR_PROFILING_MALLOC, since it takes a type rather than a size in
bytes it should be called MR_PROFILING_NEW to conform with existing malloc
and new functions.
runtime/mercury_deep_profiling.c:
Avoid a C compiler warning.
MR_write_out_coverage_point has been removed, it's replaced with:
MR_write_out_coverage_points_static and
MR_write_out_coverage_points_dynamic.
These write out more than one coverage point and write out either static or
dynamic coverage points.
Write a 64bit flags value (a bitfield) to the header of the Deep.data file.
This replaces the canonical byte (with a bit). and the byte that describes
the word size. This value also includes two bits describing the whether no
coverage data, static coverage data or dynamic coverage data is present in
the file. A bit is reserved ti indicate if the data is compressed (which
is not yet supported).
MR_write_fixed_size_int now writes out 8 byte integers, this is only used
for some counts present at the beginning of the data file along with the
new flags value. It now takes a MR_uint_least64_t integer as it's
parameter. The assertion to test for negative numbers has been removed
since this type is unsigned.
Increment the Deep.data file format version number.
compiler/layout_out.m:
Conditionally compile the NULL pointer that represents the coverage points
list in proc statics. This is conditional on the
MR_DEEP_PROFILING_COVERAGE_STATIC macro being defined.
compiler/coverage_profiling.m:
Add support for generating dynamic coverage points.
compiler/options.m:
compiler/handle_options.m:
Implement the new developer options for controlling coverage profiling.
library/profiling_builtin.m:
Specialize increment_coverage_point_count for both static and dynamic
coverage profiling. This creates
increment_{static,dynamic}_coverage_point_count.
deep_profiler/profile.m:
Add an extra field to profile_stats, this tracks whether the file reader
should try to read none, static or dynamic coverage data.
Add an extra field to proc_dynamic, An array of coverage counts wrapped by
a maybe type. It's indexed the same as the array of coverage infos in
proc_static. This array is present if dynamic coverage profiling is being
done (the default).
Modify the coverage_points field in proc static, now there are two fields,
an array of coverage_point_info values which store compile-time data. And
an optional array of coverage points (present if static coverage profiling
was performed).
Updated the formatting of the proc static structure.
Moved the coverage_point type to coverage.m.
Created a new type, coverage_data_type which enumerates the possibilities
for coverage profiling: none, static and dynamic.
deep_profiler/coverage.m:
Move the coverage point type here from profile.m, as the profile data
structure no longer refers to it directly.
Create a predicate coverage_point_arrays_to_list/3 which merges coverage
point information and the counts themselves into coverage points. This can
be used to construct a list of coverage points regardless of whether static
or dynamic coverage points are being used.
deep_profiler/read_profile.m:
Conform to changes in runtime/mercury_deep_profiling.c.
Refactored reading of the file header, a new named predicate is now used
rather than a lambda expression.
Incremented the Deep.data version number.
deep_profiler/report.m:
Updated the proc dynamic dump report structure to include a list of
coverage points.
deep_profiler/create_report.m:
deep_profiler/display_report.m:
Conform to changes in profile.m.
The proc dynamic dump now shows coverage information that was contained in
that proc dynamic.
deep_profiler/canonical.m:
deep_profiler/dump.m:
Conform to changes in profile.m.
deep_profiler/io_combinator.m:
Add a 13-arg version of maybe_error_sequence.
deep_profiler/Mercury.options:
Documented another trace flag.
|
||
|
|
8db94039a6 |
Address review comments on the introduction of macros to control alternative
code selection.
runtime/mercury_atomic_ops.h:
runtime/mercury_conf_param.h:
Updated contents and prose used in comments to make them more clear.
Updated formatting of comments.
|
||
|
|
e13234f35c |
Fix atomic_ops bug on PowerPC on Linux as reported by Keri Harris.
This change introduces three new C preprocessor macros that can be used to
override which code is used to implement atomic operations. This allows us to
test more portable but less efficient code on platforms that support the
efficient code.
runtime/mercury_atomic_ops.h:
Fix the bug.
Introduce extra declarations that control which implementation of atomic
operations is selected.
Re-order code, so that all the declarations occur before any definitions.
This fixes another bug that was uncovered by the new macros.
runtime/mercury_conf_param.h:
Document the new macros.
|
||
|
|
df2349838f |
Introduce Ralph's History based Garbage Collector (HGC).
This change set creates a new value 'hgc' for the garbage collector grade
component. This enables a new garbage collector included with the runtime
system. Note that this garbage collector is experimental and this grade does
not work yet.
This change set represents work done by both myself and Ralph Becket.
runtime/mercury_hgc.c:
runtime/mercury_hgc.h:
Include the new garbage collector.
runtime/mercury_expanding_array.h:
This new header file provides a template for a type safe expanding array,
it is used by HGC.
runtime/Mmakefile:
Include the new modules in the runtime directory mercury_hgc.[ch] and
mercury_expanding_array.h.
Sort the lists of source files and header files.
compiler/globals.m:
Include 'hgc' in the options for which garbage collector to use.
compiler/handle_options.m:
Handle the new 'hgc' value for the garbage collector type.
compiler/options.m:
Print out information about the new 'hgc' option in the --help text of the
compiler.
compiler/compile_target_code.m:
Pass the -DMR_HGC option to the C compiler for hgc grades.
compiler/add_pragma.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c.m:
compiler/peephole.m:
Conform to changes in globals.m.
library/benchmarking.m:
Fix a use of MR_CONSERVATIVE_GC that should have been MR_BOEHM_GC.
robdd/bryant.h:
Include the mercury_hgc.h header file when MR_HGC is defined.
runtime/mercury_init.h:
runtime/mercury_heap.h:
Include mercury_hgc.h when MR_HGC is defined.
runtime/mercury_memory_zones.c:
Use mercury_hgc_add_roots_range when appropriate.
runtime/mercury_wrapper.c:
Include initialisation code for HGC.
util/mkinit.c:
Include a call to mercury_hgc_set_stack_bot in init files in the HGC grade.
runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
scripts/canonical_grade.sh-subr
scripts/init_grade_options.sh-subr
scripts/mgnuc.in
scripts/ml.in
scripts/parse_grade_options.sh-subr
Add the new hgc value for the garbage collector grade component.
|
||
|
|
83a6f14708 |
Create a threadscope grade component.
Threadscope grades are enabled by using the grade component 'threadscope'.
They are supported only with low-lavel C parallel grades. Support for
threadscope in high level C grades is intended in the future but does not work
now.
runtime/mercury_conf_param.h:
Create the MR_THREADSCOPE macro that is defined if the grade is a
threadscope grade.
Define MR_PROFILE_FOR_PARALLEL_EXECUTION if MR_THREADSCOPE is defined.
Emit an error if MR_LL_PARALLEL_CONJ is defined before it is implied by
MR_THREADSAFE and ! MR_HIGHLEVEL_CODE
runtime/mercury_grade.h
Update the grade symbol for the threadscope grade component.
runtime/mercury_atomic_ops.c:
runtime/mercury_atomic_ops.h:
runtime/mercury_context.c:
runtime/mercury_context.h:
runtime/mercury_engine.c:
runtime/mercury_engine.h:
runtime/mercury_thread.c:
runtime/mercury_threadscope.c:
runtime/mercury_threadscope.h:
runtime/mercury_wrapper.c:
Now that MR_PROFILE_FOR_IMPLICIT_PARALLELISM is implied by MR_THREADSAFE we
don't need to test for MR_THREADSAFE when we test for
MR_PROFILE_FOR_IMPLICIT_PARALLELISM. The same is true for
MR_LL_PARALLEL_CONJ which is implied by MR_THREADSAFE &&
!MR_HIGHLEVEL_CODE.
Replace some occurances of MR_PROFILE_FOR_IMPLICIT_PARALLELISM with
MR_THREADSCOPE where the conditionally compiled code is used to support
threadscope profiling.
scripts/init_grade_options.sh-subr:
scripts/canonical_grade.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/mgnuc.in:
compiler/handle_options.m:
compiler/options.m:
compiler/compile_target_code.m:
configure.in:
Add support for the new grade component.
Pass -DMR_THREADSCOPE to the C compiler when using a threadscope grade.
Add assertions to ensure that the 'threadscope' grade component is used
only with the 'par' grade component.
doc/user_guide.texi:
Added commented-out documentation for the threadscope greate component.
Adjusted documentation of the --profile-parallel-execution runtime option
to describe the correct prerequisite compile time options.
Added my name to the authors list.
runtime/mercury_context.c:
Corrected grammar and prose in comments in the MR_do_join_and_continue code.
|
||
|
|
14f6b188c3 |
Fix a mistake in my previous two patches where I used
MR_PROFILE_PARALLEL_EXECUTION instead of
MR_PROFILE_PARALLEL_EXECUTION_SUPPORT
tools/test_mercury:
doc/user_guide.texi:
As above.
runtime/mercury_conf_param.h:
Document MR_PROFILE_PARALLEL_EXECUTION_SUPPORT
|
||
|
|
c59863f857 |
Convert the parts of the runtime support for RBMM that have been implemented
Estimated hours taken: 10
Branch: main
Convert the parts of the runtime support for RBMM that have been implemented
fully using macros to macros that finally are expanded to function calls.
Using pure macros may improve the performance of small programs but not what
we want in general.
The function version is the default while the macros are kept for experimental
purposes. The macros can be turned on by specifying the C flag
MR_RBMM_USE_MACROS when compiling programs.
This change is the completion of Zoltan's unfinished work before.
runtime/mercury_conf_param.h:
Add MR_RBMM_USE_MACROS flag as an experimental option.
runtime/mercury_region.h:
runtime/mercury_region.c:
Implement the functions corresponding to the old macros. There is no
change in terms of algorithm.
|
||
|
|
9c98a60bd5 |
Add a mechanism for dynamically growing the trail by adding new segments to it
Estimated hours taken: 20
Branches: main
Add a mechanism for dynamically growing the trail by adding new segments to it
in a similar fashion to what we do for the stacks with stack segments. The
mechanism is enabled by the trseg (trail segments) grade component. Unlike
stack segments the trail segment mechanism also works with the high-level C
backend.
The mechanism works by adding a test to MR_trail_{value,function} that checks
if we are about to run out of a trail and allocates a new trail segment if
that test succeeds.
Extend mdb's trail_details command to print the current number of trail
segments in trseg grades.
Fix a bug where the MR_trail_ptr was not being reset correctly after
a trail reset.
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
trail segments.
runtime/mercury_memory_zones.h:
Shift the definition MR_MemoryZones to this file in order break
a cyclic dependency between header files.
runtime/mercury_context.h:
Add a new field to the context structure to hold a list previous
trail segments.
Delete the definition of the type MR_MemoryZones from here.
runtime/mercury_trail.[ch]:
When adding a new trail entry in trseg grades first check whether we
need to extend the trail and do so if necessary.
Export the definitions of MR_TRAIL_{BASE,ZONE}.
Add a macro, MR_PREV_TRAIL_ZONES, for accessing the list of trail zones
in a grade independent manner.
Fix a typo in a comment.
Add functions for creating and destroying trail segments.
Handle trail segments in the code that handles untrailing and
resets. This also fixes a bug with trail reset where MR_trail_ptr
was not being reset along with the rest of the trail state.
compiler/options.m:
compiler/handle_options.m:
compiler/compile_target_code.m:
scripts/canonical_grade.sh-subr:
scripts/init_grade_option.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
Handle the new grade component.
trace/mercury_trace_cmd_developer.c:
Make the trail_details command print out the number of trail segments
in trseg grades.
tests/trailing/Mmakefile:
tests/trailing/tr_reset_bug.{m,exp}:
Regression test for the bug with trail resets.
|
||
|
|
e0ff2b1903 |
Implement conditional structure reuse for LLDS backends using Boehm GC.
Estimated hours taken: 15
Branches: main
Implement conditional structure reuse for LLDS backends using Boehm GC.
Verify at run time, just before reusing a dead cell, that the base address of
the cell was dynamically allocated. If not, fall back to allocating a new
object on the heap. This makes structure reuse safe without having to disable
static data.
In the simple case, the generated C code looks like this:
MR_tag_reuse_or_alloc_heap(dest, tag, addr_of_reuse_cell,
MR_tag_alloc_heap(dest, tag, count));
...assign fields...
If some of the fields are known to already have the correct values then we can
avoid assigning them. We need to handle both reuse and non-reuse cases:
MR_tag_reuse_or_alloc_heap_flag(dest, flag_reg, tag, addr_of_reuse_cell,
MR_tag_alloc_heap(dest, tag, count));
/* flag_reg is non-zero iff reuse is possible */
if (flag_reg) {
goto skip;
}
...assign fields which don't need to be assigned in reuse case...
skip:
...assign fields which must be assigned in both cases...
It may be that it is not worth the branch to avoid assigning known fields.
I haven't yet checked.
compiler/llds.m:
Extend the `incr_hp' instruction to hold information for structure
reuse.
compiler/code_info.m:
Generate a label and pass it to `var_locn_assign_cell_to_var'. The
label is only needed for the type of code shown above.
compiler/var_locn.m:
Change the code generated for cell reuse. Rather than assigning the
dead cell's address to the target lval unconditionally, generate an
`incr_hp' instruction with the reuse field filled in.
Generate code that avoids filling in known fields if possible.
Abort if we see `construct_statically(_)' in
`var_locn_assign_dynamic_cell_to_var'.
runtime/mercury_heap.h:
runtime/mercury_conf_param.h:
Add a macro to check if an address is between
`GC_least_plausible_heap_addr' and `GC_greatest_plausible_heap_addr',
which are therefore in the heap.
Add macros to conditionally reuse a cell or otherwise fall back to
allocating a new object.
Make it possible to revert to unconditional structure reuse by
defining the C macro `MR_UNCONDITIONAL_STRUCTURE_REUSE'.
compiler/llds_out.m:
Call the new macros in `mercury_heap.h' for `incr_hp' instructions
with reuse information filled in.
compiler/dupelim.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_to_x86_64.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/reassign.m:
compiler/unify_gen.m:
compiler/use_local_vars.m:
Conform to the changed `incr_hp' instruction.
|
||
|
|
0e7318c378 |
Update some documentation.
Estimated hours taken: 0.1 Branches: main Update some documentation. runtime/mercury_conf_param.h: Document that MR_PIC_REG is currently unused. |
||
|
|
3fc45c3182 |
Fix a linking error in .par grades on Mac OS X due to an undefined symbol.
Estimated hours taken: 1 Branches: main Fix a linking error in .par grades on Mac OS X due to an undefined symbol. library/io.m: On Mac OS X shared libraries cannot access environ directly but must instead look its address up at runtime using the function _NSGetEnviron(). runtime/mercury_conf_param.h: Add a new macro MR_MAC_OSX that is defined Mac OS X systems. |
||
|
|
4953e5e574 |
Update files as required for the addition of the new library `libmer_ssdb',
Estimated hours taken: 8 Branches: main Update files as required for the addition of the new library `libmer_ssdb', and make the changes to add a new grade component `ssdebug'. Mmake.workspace: Mmakefile: Add `mer_ssdb.init', `libmer_ssdb' and `ssdb' directory to the appropriate lists. Order "ssdb" occurrences according to its position in the list of which libraries can call functions in which other libraries. configure.in: Check the bootstrap compiler supports the `--no-ssdb' option. browser/MDB_FLAGS.in: library/LIB_FLAGS.in: mdbcomp/MDBCOMP_FLAGS.in: Add `--no-ssdb' to break the cyclic dependencies between these libraries and `libmer_ssdb' that would be introduced if the source-to-source debugging transformation was applied these libraries. It also prevents the infinite recursion which would result from ssdb procedures calling transformed library procedures and vice versa. analysis/.mgnuc_copts: analysis/ANALYSIS_FLAGS.in: analysis/Mmakefile: profiler/.mgnuc_copts: profiler/PROF_FLAGS.in: slice/.mgnuc_copts: slice/Mmakefile: slice/SLICE_FLAGS.in: Search the `ssdb' directory for files. compiler/Mmakefile: Remove the explicit `libmer_ssdb.a' from MLOBJS as it is redundant. Make the compiler binary depend on `libmer_ssdb'. compiler/compile_target_code.m: scripts/mgnuc.in: Pass "-DMR_SS_DEBUG" when compiling a C file if `--ssdb' is enabled. Implicitly include `mer_ssdb.init' and `libmer_ssdb' in various lists when `--ssdb' is enabled. runtime/mercury_conf_param.h: Document `MR_SS_DEBUG' preprocessor macro. compiler/handle_options.m: runtime/mercury_grade.h: scripts/canonical_grade.sh-subr: scripts/init_grade_options.sh-subr: scripts/parse_grade_options.sh-subr: Add "ssdebug" grade component. Add "--ss-debug" option as an alias for "--ssdb" to be consistent with "--decl-debug". Move the clauses to the right position. scripts/c2init.in: scripts/ml.in: Link in `libmer_ssdb' if `--ssdb' enabled. tools/lmc.in: tools/lml: Link in `libmer_ssdb' and add `mer_ssdb.init'. tools/bootcheck: Delete `ssdb' directory if `--disable-debug-libs' option enabled. tools/binary: tools/linear: Link `ssdb' directory. compiler/notes/overall_design.html: Mention `ssdb' directory. doc/user_guide.texi: Add commented out documentation for the `--ss-debug' option and the `ssdebug' grade component. |
||
|
|
fa80b9a01a |
Make the parallel conjunction execution mechanism more efficient.
Branches: main Make the parallel conjunction execution mechanism more efficient. 1. Don't allocate sync terms on the heap. Sync terms are now allocated in the stack frame of the procedure call which originates a parallel conjunction. 2. Don't allocate individual sparks on the heap. Sparks are now stored in preallocated, growing arrays using an algorithm that doesn't use locks. 3. Don't have one mutex per sync term. Just use one mutex to protect concurrent accesses to all sync terms (it's is rarely needed anyway). This makes sync terms smaller and saves initialising a mutex for each parallel conjunction encountered. 4. We don't bother to acquire the global sync term lock if we know a parallel conjunction couldn't be executing in parallel. In a highly parallel program, the majority of parallel conjunctions will be executed sequentially so protecting the sync terms from concurrent accesses is unnecessary. par_fib(39) is ~8.4 times faster (user time) on my laptop (Linux 2.6, x86_64), which is ~3.5 as slow as sequential execution. configure.in: Update the configuration for a changed MR_SyncTerm structure. compiler/llds.m: Make the fork instruction take a second argument, which is the base stack slot of the sync term. Rename it to fork_new_child to match the macro name in the runtime. compiler/par_conj_gen.m: Change the generated code for parallel conjunctions to allocate sync terms on the stack and to pass the sync term to fork_new_child. compiler/dupelim.m: compiler/dupproc.m: compiler/exprn_aux.m: compiler/global_data.m: compiler/jumpopt.m: compiler/livemap.m: compiler/llds_out.m: compiler/llds_to_x86_64.m: compiler/middle_rec.m: compiler/opt_debug.m: compiler/opt_util.m: compiler/reassign.m: compiler/use_local_vars.m: Conform to the change in the fork instruction. compiler/liveness.m: compiler/proc_gen.m: Disable use of the parallel conjunction operator in the compiler as older versions of the compiler will generate code incompatible with the new runtime. runtime/mercury_context.c: runtime/mercury_context.h: Remove the next pointer field from MR_Spark as it's no longer needed. Remove the mutex from MR_SyncTerm. Add a field to record if a spark belonging to the sync term was scheduled globally, i.e. if the parallel conjunction might be executed in parallel. Define MR_SparkDeque and MR_SparkArray. Use MR_SparkDeques to hold per-context sparks and global sparks. Change the abstract machine instructions MR_init_sync_term, MR_fork_new_child, MR_join_and_continue as per the main change log. Use a preprocessor macro MR_LL_PARALLEL_CONJ as a shorthand for !MR_HIGHLEVEL_CODE && MR_THREAD_SAFE. Take the opportunity to clean things up a bit. runtime/mercury_wsdeque.c: runtime/mercury_wsdeque.h: New files containing an implementation of work-stealing deques. We don't do work stealing yet but we use the underlying data structure. runtime/mercury_atomic.c: runtime/mercury_atomic.h: New files to contain atomic operations. Currently it just contains compare-and-swap for gcc/x86_64, gcc/x86 and gcc-4.1. runtime/Mmakefile: Add the new files. runtime/mercury_engine.h: runtime/mercury_mm_own_stacks.c: runtime/mercury_wrapper.c: Conform to runtime changes. runtime/mercury_conf_param.h: Update an outdated comment. |
||
|
|
fb4b5c30a2 |
Allow the specification of RBMM debugging and profiling via grades.
Estimated hours taken: 2 Branches: main Allow the specification of RBMM debugging and profiling via grades. runtime/mercury_grade.h: Add rbmmd and rbmmp as grade components denoting RBMM with debugging and profiling respectively, while rbmmdp is RBMM with both. compiler/options.m: Add --use-regions-debug and --use-regions-profiling as the Mercury compiler options specifying RBMM debugging and profiling. compiler/handle_options.m: compiler/compile_target_code.m: runtime/mercury_conf_param.h: scripts/canonical_grade.sh-subr: scripts/final_grade_options.sh-subr: scripts/init_grade_options.sh-subr: scripts/mgnuc.in: scripts/parse_grade_options.sh-subr: Handle the new grade components. configure.in: Add the new option --enable-rbmm-grades, for use by Quan and me for now, that causes the installation of all four RBMM grades. Once RBMM is ready for use by non-implementors, we can change this to install only the rbmm grade, and not the rbmmd/rbmmp/rbmmdp grades. |
||
|
|
0fcd954631 |
Implement the runtime system for region-based memory management.
Estimated hours taken: 50 by quan, 8 by zs Branches: main Implement the runtime system for region-based memory management. This includes the implementation of regions, region instructions and support for backtracking. Support for backtracking deals with preventing the destruction of backward live regions and provides instant reclaiming of space in regions when backtracking reaches a resume point. This support now exploits the data in rbmm_goal_info structures. The mechanisms are documented in the papers/rbmm module of the Mercury repository. compiler/code_info.m: Change the option to control the addition of region operations from use_region to region_analysis so that no region operations are introduced when compiling a compiler in .rbmm grade. This is temporary, as is the re-adding of --region-analysis option. Make use of rbmm_goal_info when generating backtrack-supporting code for commit operations. compiler/commit_gen.m: Make use of rbmm_goal_info when generating backtrack-supporting code. compiler/disj_gen.m: Make use of rbmm_goal_info when generating semidet disjunction. Correct one error so that use_region_disj_later is not generated in the code for the first disjunct. compiler/ite_gen.m: Make use of rbmm_goal_info. compiler/options.m: Modify the size of disj_protect(ion) to 1 instead of 2. library/region_builtin.m: Change the region builtins to call to the correct region operations in the region runtime system. Add a predicate to print out profiling information for region-based memory management. runtime/mercury_region.h runtime/mercury_region.c New files containing the implementation of the region runtime system. This runtime system supports its own profiling and debugging messages, which can be turned on and off via the MR_RBMM_PROFILING and MR_RBMM_DEBUG flags. Note that these files are still in a state of flux. runtime/mercury_types.h: Add typedefs needed by declarations in mercury_region.h. runtime/mercury_conf_paramh: Document MR_RBMM_PROFILING and MR_RBMM_DEBUG. runtime/mercury_imp.h: #include mercury_region.h in rbmm grades. runtime/Mmakefile: Link the region runtime system into the runtime system of Mercury. tests/tabling/Mmakefile: Avoid accidental matches on the "mm" in "rbmm". |