Commit Graph

2206 Commits

Author SHA1 Message Date
Julien Fischer
d256d24ea5 Drop support for OSF/1.
configure.ac:
	Drop support for OSF/1.

	Delete more IRIX stuff.

configure.ac:
runtime/mercury_conf.h.in:
runtime/mercury_thread.h:
	Delete workarounds required when using the Digital Unix pthreads
	library.

Mmake.common.in:
runtime/mercury_wrapper.c:
	Delete stuff for IRIX.

README.OSF1:
	Delete this file.

.README.in:
	Delete the pointers to the readme files for IRIX and OSF/1.

NEWS:
	Announce the dropping of support for OSF/1.
2014-06-16 15:08:05 +10:00
Julien Fischer
208b99b879 Fix a problem that broke low-level C grades on Windows.
runtime/mercury_debug.c:
	Protect a reference to the memory zone hardmax with MR_PROTECTPAGE.
2014-04-30 12:11:27 +10:00
Julien Fischer
a9fbc1e528 Only define MR_nondetstack_inclusion_check in low-level C grades.
runtime/mercury_overflow.c:
	As above: compiling this function in high-level C grades
	will fail since it refers to fields of the MR_Context
	structure that do not exist in those grades.
2014-04-22 10:44:02 +10:00
Zoltan Somogyi
41e75fcc78 Fix breakage.
runtime/mercury_stacks.c:
   Fix typo.
2014-04-19 12:31:02 +10:00
Zoltan Somogyi
8d75bd09ea Fix comment. 2014-04-18 02:02:35 +10:00
Zoltan Somogyi
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.
2014-04-18 02:02:35 +10:00
Julien Fischer
7dece9f7c2 Avoid more warnings from clang.
runtime/mercury_bitmap.c:
runtime/mercury_memory.c:
mdbcomp/rtti_access.m:
	As above.
2014-03-31 14:52:38 +11:00
Julien Fischer
e7d8bc7185 Fix up inlining macros for clang.
Currently we use the C89 definitions of MR_STATIC_INLINE and friends with
clang, which is less than ideal in a couple of ways, firstly we might not get
as much inlining as we would like and secondly, for clang, it causes large
numbers of warnings about unused functions to be generated.

Using GNU C style inlining does not work because we enable the -ansi option
when using clang and the (current) behaviour of the -ansi option with clang is
to enforce strict C89 conformance (i.e. disable any GNU C extensions.).

This change avoids all of the above by (1) adding C99 style definitions of
MR_STATIC_INLINE etc for clang and (2) not passing -ansi to clang (i.e. putting
clang into c99, or technically gnu99, mode).  We fall back on the C89 style
definitions if the user does something odd like setting -ansi or -std=c89
themselves.

runtime/mercury_std.h:
	Define MR_STATIC_INLINE and friends for clang in the case where clang
	is in C99 (or equivalent) mode.

configure.ac:
	Set CFLAGS_FOR_ANSI for clang to empty.  Add an explanation of why
	we do this.

scripts/mgnuc.in:
	Don't pass -ansi to clang.
2014-03-25 15:03:13 +11:00
Peter Wang
fdd8e9013e Remove unnecessary detection of sync term size during configure.
The size of a sync term must be kept synchronised between the runtime
and the compiler.  The size is "detected" during configure by running
a small program whose output would always be the same.  It doesn't work
for cross-compilation so a value is hard-coded in configure_mingw_cross,
which is liable to be missed if the sync term ever changes.

configure.ac:
	Hard code sync term size as it measures a number of detstack
	slots, which does not depend on architecture.

runtime/mercury_conf.h.in:
	Define MR_SYNC_TERM_SIZE.

runtime/mercury_std.h:
	Add MR_STATIC_ASSERT macro.

runtime/mercury_context.h:
	Check at compile time that the value of MR_SYNC_TERM_SIZE
	from configure.ac matches the real size.

tools/configure_mingw_cross:
	Delete mercury_cv_sync_term_size as no longer needed.
2014-03-25 12:34:01 +11:00
Julien Fischer
6bae4e41b4 Fix compilation of runtime when MR_TABLE_DEBUG is defined.
runtime/mercury_tabling.c:
	Fix the broken definition for the MR_table_assert macro.
2014-03-21 15:03:47 +11:00
Julien Fischer
eec4f9f125 Fix more issues in the runtime identified using clang -Wall.
runtime/mercury_wrapper.c:
	Declare MR_usage to be a noreturn function.  This avoids
	warnings in other parts of this module.

runtime/mercury_context.c
	Only define MR_write_out_profiling_parallel_execution if
	MR_PROFILE_PARALLEL_EXECUTION_SUPPORT is defined; it is
	otherwise unused.

	Fix incorrect conversion specifiers in some calls to fprintf.

	Only define the function action_shutdown_engine and friends
	if MR_THREAD_SAFE is defined.

	Do not define MR_checking_pending_contexts if MR_HIGHLEVEL_CODE
	is defined.

runtime/mercury_debug.c:
	Protect a group of function prototypes with MR_LOWLEVEL_DEBUG.
	(The corresponding definitions were already protected by this
	macro.)

runtime/mercury_label.c:
	Delete the declaration of the function compare_entry_by_addr
	as that function is not defined anywhere.

	Delete an unused local variable.

runtime/mercury_make_type_info_body.h:
	Delete an unused local variable.

runtime/mercury_memory.c:
	Delete left over function prototypes for try_munprotect and
	explain_context.  (The functions were moved into the module
	mercury_memory_handlers a long time ago.)

runtime/mercury_memory_handlers.c:
	Protect functions that are only used in the low-level agc
	grades by the appropriate macros.

runtime/mercury_minimal.c:
runtime/mercury_mm_own_stacks.c:
	Don't define some global variables in high-level C grades that
	are not necessary in those grades.

runtime/mercury_tabling.c:
	Only define MR_table_assert_failed if MR_TABLE_DEBUG is defined
	since it is otherwise unused.
2014-03-21 14:56:36 +11:00
Julien Fischer
bd1fd12b07 Use GCC's cast to union extension with clang.
runtime/mercury_float.h:
	Define MR_float_to_word and MR_word_to_float as macros using GCC's
	cast to union extension with clang, since it also supports that
	extension.
2014-03-20 18:01:55 +11:00
Julien Fischer
e9d90b2891 Avoid warnings from clang in the runtime and util directories.
runtime/mercury_stack_trace.c:
	In the function MR_dump_stack_from_layout_clique initialise the variable
	lines_dumped_so_far.  (This appears to be an actual bug.)

runtime/mercury_prof.c:
	Only define the static global in_profiling_code if either of call count
	profiling or time profiling is enabled.

runtime/mercury_context.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_profiling.c:
	Only define some local variables in grades that require them.

runtime/mercury_float.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_construct.c:
runtime/mercury_memory_zones.c:
runtime/mercury_stm.c:
runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
	Delete unused local variables.

util/mdemangle.c:
	Delete an unused static global variable.

	Use fputs in place of fprintf in a couple of places in order
	to avoid warnings about format strings that are not string literals.

	Delete an unused function.

util/mkinit.c:
util/mkinit_erl.c:
	Delete unused local variables.
2014-03-20 17:01:15 +11:00
Paul Bone
f6c00fb17c Conform to changes in libhwloc's API (Bug #289)
The 'cpuset' functions in libhwloc have been made more generic and renamed
to 'bitmap' functions.  This patch updates the Mercury runtime system
appropriately.

runtime/mercury_context.c:
    As above.

configure.ac:
    We now require at least version 1.1 of libhwloc (previously we required
    at least 1.0).
2014-02-04 12:31:10 +11:00
Julien Fischer
326f36313e Avoid compiler warnings from MSVC in generated code.
runtime/mercury_float.h:
	Avoid warnings from MSVC about the types of the formal and actual parameters
	of calls to MR_float_from_dword differing.  The formal parameters have type
	MR_Word, but the Mercury compiler doesn't emit casts for the arguments.
	(For GCC and clang, MR_float_from_dword is defined as a macro and the
	necessary casts occur in its body.)  The fix is to rename the function
	version of MR_float_from_dword and make MR_float_from_dword a forwarding macro
	that inserts the necessary casts.
2014-01-28 18:41:52 +11:00
Zoltan Somogyi
ba57f4a5df Reorganize the way we handle reserved C macro names.
RESERVED_MACRO_NAMES:
*/RESERVED_MACRO_NAMES:
    Add a macro, _FORTIFY_SOURCE, that gcc defines by default on some recent
    versions of Linux.

    I could have added it in SIX separate RESERVED_MACRO_NAMES files.
    Instead, I moved the content common to all these files to a
    RESERVED_MACRO_NAMES file in the top directory, leaving the
    RESERVED_MACRO_NAMES files of the subdirectories containing only
    macros that *don't* occur in all those subdirectories.

tools/bootcheck:
   Copy the top-level RESERVED_MACRO_NAMES names to the stage 2 directory.

Mmake.common.in:
   Filter out the contents of the top level RESERVED_MACRO_NAMES file,
   as well as the RESERVED_MACRO_NAMES file in the current directory.
2014-01-22 08:55:58 +11:00
Paul Bone
982d22247b Merge branch 'version-13_05-branch' 2013-11-28 13:21:39 +11:00
Peter Wang
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.
2013-10-29 17:30:39 +11:00
Peter Wang
9a31b64bab Improve indentation in mercury_float.h.
runtime/mercury_float.h:
	Improve indentation.
2013-10-29 17:30:20 +11:00
Paul Bone
95a089b5b3 Add more patterns to .gitignore files
A number of patterns and filenames where missing from .gitignore files,
especially in the tests/ directory.

.gitignore:
boehm_gc/.gitignore:
boehm_gc/libatomic_ops/pkgconfig/.gitignore:
runtime/.gitignore:
scripts/.gitignore:
tests/.gitignore:
tests/analysis/table/.gitignore:
tests/analysis/trail/.gitignore:
tests/benchmarks/.gitignore:
tests/debugger/.gitignore:
tests/invalid/.gitignore:
tests/mmc_make/.gitignore:
tests/mmc_make/lib/.gitignore:
    Add new patterns to .gitignore files.

    Remove some patterns that are implicit because they're in a parent
    directory's file.

tests/analysis/.gitignore:
    After removing superfluous patterns this file was empty.  I've deleted
    it.
2013-10-02 20:54:06 +10:00
Julien Fischer
000e81e2da Fix a problem that broke the rotds on some platforms.
runtime/mercury_grade.h:
	MR_GRADE_OPT_PART_11 wasn't being defined if we were using boxed
	double-precision floats.
2013-09-30 20:16:43 +10:00
Peter Wang
7d760a2713 Add ".pregen" or ".spf" to MR_GRADE_OPT variable.
".pregen" and ".spf" are settable on the command-line and should
therefore be included in MR_GRADE_OPT.

runtime/mercury_grade.h:
	As above.
2013-09-17 16:20:33 +10:00
Julien Fischer
4e6828214d Fix bug #288.
Components of the Mercury system that were implemented directly in C were not
respecting the mmake LDFLAGS and EXTRA_LDFLAGS variables (or LD_LIBFLAGS,
EXTRA_LDLIBFLAGS for libraries).

The following patch was contributed by Keri Harris -- I have extended it
slightly to fix some omissions in the handling of .dylib files (i.e.  Mac OS X
style shared libraries).

NEWS:
    Announce the resolution of bug #288.

boehm_gc/Makefile.direct:
runtime/Mmakefile
trace/Mmakefile:
util/Mmakefile:
	Pass options set via LD_FLAGS or EXTRA_LDFLAGS (or the library
	versions) to the linker when building executables (or shared
	libraries) in these directories.
2013-06-20 18:13:41 +10:00
Julien Fischer
c1f361e2fc Fix a typo.
runtime/mercury_float.c:
	s/_FPCLASS_INF/_FPCLASS_PINF/
2013-05-31 17:45:21 +10:00
Julien Fischer
63c8afdad7 Provide MSVC specific definitions for MS_is_nan and MR_is_inf.
runtime/mercury_float.c:
	As above.
2013-05-31 17:42:36 +10:00
Peter Wang
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'.
2013-05-29 16:44:01 +10:00
Julien Fischer
cb3cb3691e More fixes for float.float64_bits_string/1.
The implementation of float64_bits_string/1 does not work correctly on
platforms where sizeof(long) == 4.  This is the case for the i386 version of
NetBSD.  Also, make the code in the float module consistent with the fact the
runtime allows there to be no 64-bit integer type defined at all.

configure.ac:
runtime/mercury_conf.h.in:
	Define a new macro that expands to the integer length modifier for
	the MR_int_least64_t type.

library/float.m:
	Use the new macro to avoid a spot that was assuming that a long is
	a 64-bit quantity.  (TODO: we can probably now simplify some of the
	Windows specific code here, but I don't want to do that until I have
	tested it.)

	Have float64_bits_string/1 call MR_fatal_error() if MR_INT_LEAST64_TYPE
	is not defined.
2013-05-23 13:36:41 +10:00
Julien Fischer
e131b228db Add and/or update .gitignore files.
mfilterjavac/.gitignore:
	Add a .gitignore file for this directory.

browser/.gitignore:
mbdcomp/.gitignore:
runtime/.gitignore:
ssdb/.gitignore:
trace/.gitignore:
	Ignore .so files.
2013-05-21 14:17:33 +10:00
Julien Fischer
2ac3592b02 Fail gracefully if we try to compile a .prof grade on Windows.
runtime/mercury_proc.c:
    If MR_CLOCK_TICK_PER_SECOND is not defined we should
    abort with an error message.  (This is what happens
    for the module mercury_time_prof, but of course,
    this one is typically compiled *before* that ...)
2013-04-07 22:32:58 +10:00
Julien Fischer
633594eb24 Fix up profiling runtime code for MinGW64.
runtime/mercury_prof.c:
    Do not assume that an address will fit inside a long.
    That is not the case for 64-bit Windows.
2013-04-07 22:18:09 +10:00
Julien Fischer
8151ec691c More MinGW64 related cleanups.
runtime/mercury_mm_own_stacks.c:
    Use Sleep() instead of sleep() on Windows.

    Avoid warnings from the C compiler.

samples/concurrency/dining_philosophers/philo.m:
samples/concurrency/dining_philosophers/philo3.m:
	Use '.' as a module qualifier in a spot.

	Replace calls to obsolete predicates.
2013-04-07 22:05:00 +10:00
Julien Fischer
4987cd686e Initial support for .par grades with MinGW64.
The pthreads-win32 has worked with 64-bit compilers since version 2.9.
This diff adds the initial support for the .par grades with MinGW64 and
pthreads-win32.

configure.ac:
	Set C compiler and linker flags for x86_64-w64-mingw32.
	(This is provisional; on my system the library appears
	to have a different name, but I'm not sure how normal
	this is.)

runtime/mercury_thread.h:
	Adjust the definition of the MR_SELF_THREAD_ID macro
	so that the integer it expands to is at least as big
	as a pointer.  (Needed for pthreads-win32 since thread
	ids are pointer values, not integers with that.)

runtime/mercury_thread.c:
	Avoid warnings in some debugging code.
2013-04-05 17:12:09 +11:00
Julien Fischer
fc29b6c0b6 Update the list of reserved macro names.
browser/RESERVED_MACRO_NAMES:
library/RESERVED_MACRO_NAMES:
mdbcomp/RESERVED_MACRO_NAMES:
runtime/RESERVED_MACRO_NAMES:
ssdb/RESERVED_MACRO_NAMES:
trace/RESERVED_MACRO_NAMES:
	Ignore the __USE_MINGW_ANSI_STDIO macro which we
	need to define on MinGW64.

	Ignore the __GCC_HAVE_DWARF2_CFI_ASM macro which
	some versions of GCC define if -g is enabled.

compiler/.gitignore:
deep_profiler/.gitignore:
profiler/.gitignore:
slice/.gitignore:
util/.gitignore:
	Have git ignore .exe files in these directories.
2013-04-03 15:21:22 +11:00
Julien Fischer
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.
2013-03-25 14:05:03 +11:00
Julien Fischer
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.
2013-03-25 12:17:09 +11:00
Julien Fischer
e91646474e Avoid more GCC warnings in the runtime on 64-bit Windows.
runtime/mercury_ml_expand_body.h:
	Fix another spot where we are incorrectly assuming that
	the machine word size is <= sizeof(long).

runtime/mercury_debug.c:
runtime/mercury_memory_zones.c:
runtime/mercury_wrapper.c:
	s/MR_WORD_TYPE/MR_Integer/ in my last change.
2013-03-21 18:27:17 +11:00
Julien Fischer
c9cf5adf4c Avoid GCC warnings in runtime on 64-bit Windows.
runtime/mercury_debug.c:
runtime/mercury_memory_zones.c:
runtime/mercury_wrapper.c:
   Fix some spots that assumed the machine word size is
   <= sizeof(long).  This is not true on 64-bit Windows.
2013-03-21 17:51:23 +11:00
Peter Wang
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.
2013-03-18 15:44:16 +11:00
Peter Wang
ec8f199bc5 Define GC_LINUX_THREADS instead of LINUX_THREADS.
Pass -DGC_LINUX_THREADS for Boehm GC instead of -DLINUX_THREADS.
The latter is a deprecated synonym.

configure.ac:
	As above.

*/RESERVED_MACRO_NAMES:
	LINUX_THREADS no longer needs to be excluded from the
	namespace check.
2013-02-20 11:55:48 +11:00
Peter Wang
20ea47995f Fix crashes when dumping stack traces.
In MR_dump_stack_from_layout_clique two variables could be accessed
without being initialised when jumping to the label 'done'.

Also, pair calls to MR_malloc/MR_realloc with MR_free instead of free.
This is purely cosmetic while MR_free is an alias for free.

runtime/mercury_stack_trace.c:
	As above.
2013-02-12 14:20:12 +11:00
Julien Fischer
1eda59e3da Convert .cvsignore files into .gitignore files.
Delete the empty lazy_evaluation directory from extras.

*/.cvsignore:
     Make this into .gitignore files.
     (Update them where necessary.)

extra/lazy_evalution:
    Delete this directory; its former contents were moved
    elsewhere some time ago.
2013-01-03 13:12:22 +11:00
Julien Fischer
f4e6964509 Delete old files resurrected by cvs2git.
bcheck:
compiler/call_graph.m:
compiler/implication.m:
compiler/ml_dense_switch.m:
compiler/vn_livemap.m:
library/nc_builtin.m:
library/np_builtin.m:
runtime/Makefile.conf.in:
runtime/autoconf.h.in:
runtime/conf.h:
runtime/configure.in:
runtime/ext_signal.h:
runtime/ext_stdio.h:
runtime/ext_stdlib.h:
runtime/iface.h:
runtime/iface.mod:
runtime/iface_g.y:
runtime/iface_s.l:
runtime/io.h:
runtime/io.mod:
runtime/list.c:
runtime/list.h:
	As above.
2013-01-03 13:12:21 +11:00
Zoltan Somogyi
7a5817acad Fix comment layout.
Estimated hours taken: 0.1
Branches: main

runtime/mercury_goto.h:
	Fix comment layout.
2012-12-23 21:37:31 +00:00
Zoltan Somogyi
1962dd6990 Avoid a core dump that we used to get when traversing stack frames
Estimated hours taken: 0.5
Branches: main

runtime/mercury_stack_trace.c:
	Avoid a core dump that we used to get when traversing stack frames
	without debug info, such as the stack frames of hand-written procedures
	like builtin_catch.
2012-11-14 07:02:23 +00:00
Zoltan Somogyi
2d0bfc0674 The algorithm that decides whether the order independent state update
Estimated hours taken: 120
Branches: main

The algorithm that decides whether the order independent state update
transformation is applicable in a given module needs access to the list
of oisu pragmas in that module, and to information about the types
of variables in the procedures named in those pragmas. This diff
puts this information in Deep.procrep files, to make them available
to the autoparallelization feedback program, to which that algorithm
will later be added.

Compilers that have this diff will generate Deep.procrep files in a new,
slightly different format, but the deep profiler will be able to read
Deep.procrep files not just in the new format, but in the old format as well.

runtime/mercury_stack_layout.h:
	Add to module layout structures the fields holding the new information
	we want to put into Deep.procrep files. This means three things:

	- a bytecode array in module layout structures encoding the list
	  of oisu pragmas in the module;
	- additions to the bytecode arrays in procedure layout structures
	  mapping the procedure's variables to their types; and
	- a bytecode array containing the encoded versions of those types
	  themselves in the module layout structure. This allows us to
	  represent each type used in the module just once.

	Since there is now information in module layout structures that
	is needed only for deep profiling, as well as information that is
	needed only for debugging, the old arrangement that split a module's
	information between two structures, MR_ModuleLayout (debug specific
	info) and MR_ModuleCommonLayout (info used by both debugging and
	profiling), is no longer approriate. We could add a third structure
	containing profiling-specific info, but it is simpler to move
	all the info into just one structure, some of whose fields
	may not be used. This wastes only a few words of memory per module,
	but allows the runtime system to avoid unnecessary indirections.

runtime/mercury_types.h:
	Remove the type synonym for the deleted type.

runtime/mercury_grade.h:
	The change in mercury_stack_layout.h destroys binary compatibility
	with previous versions of Mercury for debug and deep profiling grades,
	so bump their grade-component-specific version numbers.

runtime/mercury_deep_profiling.c:
	Write out the information in the new fields in module layout
	structures, if they are filled in.

	Since this changes the format of the Deep.procrep file, bump
	its version number.

runtime/mercury_deep_profiling.h:
runtime/mercury_stack_layout.c:
	Conform to the change to mercury_stack_layout.h.

mdbcomp/program_representation.m:
	Add to module representations information about the oisu pragmas
	defined in that module, and the type table of the module.
	Optionally add to procedure representations a map mapping
	the variables of the procedure to their types.

	Rename the old var_table type to be the var_name_table type,
	since it contains just names. Make the var to type map separate,
	since it will be there only for selected procedures.

	Modify the predicates reading in module and procedure representations
	to allow them to read in the new representation, while still accepting
	the old one. Use the version number in the Deep.procrep file to decide
	which format to expect.

mdbcomp/rtti_access.m:
	Add functions to encode the data representations that this module
	also decodes.

	Conform to the changes above.

mdbcomp/feedback.automatic_parallelism.m:
	Conform the changes above.

mdbcomp/prim_data.m:
	Fix layout.

compiler/layout.m:
	Update the compiler's representation of layout structures
	to conform to the change to runtime/mercury_stack_layout.h.

compiler/layout_out.m:
	Output the new parts of module layout structures.

compiler/opt_debug.m:
	Allow the debugging of code referring to the new parts of
	module layout structures.

compiler/llds_out_file.m:
	Conform to the move to a single module layout structure.

compiler/prog_rep_tables.m:
	This new module provided mechanisms for building the string table
	and the type table components of module layouts. The string table
	part is old (it is moved here from stack_layout.m); the type table
	part is new.

	Putting this code in a module of its own allows us to remove
	a circular dependency between prog_rep.m and stack_layout.m;
	instead, both now just depend on prog_rep_tables.m.

compiler/ll_backend.m:
	Add the new module.

compiler/notes/compiler_design.html:
	Describe the new module.

compiler/prog_rep.m:
	When generating the representation of a module for deep profiling,
	include the information needed by the order independent state update
	analysis: the list of oisu pragmas in the module, if any, and
	information about the types of variables in selected procedures.

	To avoid having these additions increasing the size of the bytecode
	representation too much, convert some fixed 32 bit numbers in the
	bytecode to use variable sized numbers, which will usually be 8 or 16
	bits.

	Do not use predicates from bytecode_gen.m to encode numbers,
	since there is nothing keeping these in sync with the code that
	reads them in mdbcomp/program_representation.m. Instead, use
	new predicates in program_representation.m itself.

compiler/stack_layout.m:
	Generate the new parts of module layouts.

	Remove the code moved to prog_rep_tables.m.

compiler/continuation_info.m:
compiler/proc_gen.m:
	Make some more information available to stack_layout.m.

compiler/prog_data.m:
	Fix some formatting.

compiler/introduce_parallelism.m:
	Conform to the renaming of the var_table type.

compiler/follow_code.m:
	Fix the bug that used to cause the failure of the
	hard_coded/mode_check_clauses test case in deep profiling grades.

deep_profiler/program_representation_utils.m:
	Output the new parts of module and procedure representations,
	to allow the correctness of this change to be tested.

deep_profiler/mdprof_create_feedback.m:
	If we cannot read the Deep.procrep file, print a single error message
	and exit, instead of continuing with an analysis that will generate
	a whole bunch of error messages, one for each attempt to access
	a procedure's representation.

deep_profiler/mdprof_procrep.m:
	Give this program an option that specifies what file it is to
	look at; do not hardwire in "Deep.procrep" in the current directory.

deep_profiler/report.m:
	Add a report type that just prints the representation of a module.
	It returns the same information as mdprof_procrep, but from within
	the deep profiler, which can be more convenient.

deep_profiler/create_report.m:
deep_profiler/display_report.m:
	Respectively create and display the new report type.

deep_profiler/query.m:
	Recognize a query asking for the new report type.

deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/autopar_types.m:
deep_profiler/branch_and_bound.m:
deep_profiler/coverage.m:
deep_profiler/display.m:
deep_profiler/html_format.m:
deep_profiler/mdprof_test.m:
deep_profiler/measurements.m:
deep_profiler/query.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/top_procs.m:
deep_profiler/top_procs.m:
	Conform to the changes above.

	Fix layout.

tests/debugger/declarative/dependency.exp2:
	Add this file as a possible expected output. It contains the new
	field added to module representations.
2012-10-24 04:59:55 +00:00
Paul Bone
e17a22caaa Parallel RTS changes for idle engines and notifications.
This redesign prevents at least one race condition that could previously
occur with scheduling of contexts.  This work actually represents an attempt
to design and check these algorithms rather than my previous work which was
no-where near as thorough.

runtime/mercury_context.[ch]:
    Modified along with this are the actions that an engine can undertake,
    many have been renamed but MR_ENGINE_ACTION_CONTEXT_ADVICE has been
    added, which is given to an engine to instruct that engine to check the
    context run queue.

    There are now two procedures for notifying/waking engines.
    try_wake_engine and try_notify_engine, the former is used only when an
    engine is sleeping, the latter is to be used when the engine is idle but
    not sleeping.

    I've also modified how the MR_num_idle_engines counter is used.  It
    now counts the number of engines in the stealing or sleeping states.

    A lot of fprintfs have been added for thread debugging.  They use the
    MR_DEBUG_THREADS macro and --debug-threads runtime option.

    We now support polling and non-polling modes for work stealing.  Engines
    can either be notified when there is a new spark, slowing down spark
    creation time.  Or engines can wake up and poll other engines for
    sparks meaning that the system doesn't idle well.

    Remove MR_do_idle_clean_context which was a specialised entry point for
    the MR_do_idle code.  However there is not much difference between it
    and MR_do_idle, so it is not worth maintaining two procedures.

    Remove MR_do_idle_dirty_context, this logic has been re-implemented in
    MR_join_and_continue where it can be faster.

    Make MR_attempt_steal_spark skip stealing from the current engine.

    Add a memory fence to MR_join_and_continue to make sure that context
    data is saved before marking the context as runnable.

    Modify the spark deque structure to reduce false-sharing.  (Very minor
    speed-up).
2012-10-18 06:12:03 +00:00
Paul Bone
ecaecf2981 Prevent two different race conditions in the wsdeque implementation.
Chase & Lev's algorithm for circular work stealing deques does not
specify a memory model, and appears to assume a strict memory model such
as Java provides, this I have inferred because the examples in their
paper use Java syntax.

When we translated their algorithms into C we introduced two bugs by
assuming that we could write the code in C as it appeared in the Java
examples.  C has no specific memory model and allows your processor to
re-order many memory operations.  This patch corrects both bugs by
introducing one memory fence operation per bug and explains the bugs and
fixes in comments.

Unfortunately this causes the fibs micro benchmark (without granularity
control) to slow down by almost one third.  Which is disappointing bot
unavoidable.

runtime/mercury_wsdeque.h:
    As above.
2012-09-19 13:41:43 +00:00
Paul Bone
08896533f2 Document a bug without fixing it.
I've found the cause of a long standing race condition in the parallel
runtime system.  The fix is to properly design the engine state and
notification system in the parallel runtime system.  I've worked on a design
and committed a description.  I've started implementing the changes but found
a new different race condition.  I don't currently have the time to complete
this change, therefore I will commit the documentation of the current
problem and proposed solution.

runtime/mercury_context.c:
    As above, document the current race.

    Also comment on a bug where an idle engine could be notified of a
    context to execute.  This notification could be dropped in some
    situations causing the context to be lost.

runtime/notes/par_engine_state.txt:
runtime/notes/par_engine_state.dot:
    As above, document the proposed new engine state and notification
    design.
2012-09-04 11:42:53 +00:00
Paul Bone
50daad3ff7 Document a bug without fixing it.
I've found the cause of a long standing race condition in the parallel
runtime system.  The fix is to properly design the engine state and
notification system in the parallel runtime system.  I've worked on a design
and committed a description.  I've started implementing the changes but found
a new different race condition.  I don't currently have the time to complete
this change, therefore I will commit the documentation of the current
problem and proposed solution.

runtime/mercury_context.c:
    As above, document the current race.

    Also comment on a bug where an idle engine could be notified of a
    context to execute.  This notification could be dropped in some
    situations causing the context to be lost.

runtime/notes/par_engine_state.txt:
runtime/notes/par_engine_state.dot:
    As above, document the proposed new engine state and notification
    design.
2012-09-04 11:08:38 +00:00
Paul Bone
05fc5f1c41 Fix my fix to my earlier patch.
When I fixed this comment last night I didn't read the code it was next to.
This caused me to document a different loop and race condition elsewhere in
the runtime system.  This change replaces the comment with one that makes
sense in this location.

runtime/mercury_context.c:
    As above.
2012-08-09 00:36:26 +00:00