Commit Graph

17378 Commits

Author SHA1 Message Date
Julien Fischer
6682cc0a44 Improve the wording of some error messages.
Use the word "corresponding" instead of "preceding" in error messages like:

    Error: clause for predicate `foo'/0 without preceding `:- pred'
    declaration.

The language imposes no ordering on declarations so there is no sense in which
the `:- pred' declaration has to precede the clause.  This is doubly true for
`:- typeclass' and `:- instance' declarations, which may also occur in
different source files from each other.

compiler/make_hlds_error.m:
compiler/add_class.m:
	Make the above change.

	Delete a comment regarding this issue.

tests/invalid/*/.err_exp:
	Update expected error outputs.
2014-08-25 15:02:37 +10:00
Peter Wang
f494e7945f Backport Boehm GC changes for Winpthreads support.
Make our changes to support Winpthreads match those of upstream
bdwgc commit 94b85eea2e2713c7a6071f1965b1e98e645e65a7

boehm_gc/include/private/gc_locks.h:
boehm_gc/win32_threads.c:
	As above.
2014-08-25 11:18:49 +10:00
Julien Fischer
79ea51024a Workaround bug #354 in the cairo binding.
extras/graphics/mercury_cairo/Mercury.options:
	Add a workaround for bug #354.

	Don't attempt to install his library in the csharp grade.
2014-08-25 03:52:56 +10:00
Julien Fischer
058fc67317 Add synonyms for some command line options.
compiler/options.m:
doc/user_guide.texi:
	'vars' is used as a abbreviation for 'variables' in all compiler
	command line options except two: --no-warn-singleton-variables and
	--no-warn-undefined-options-variables.  Add synonyms for these options
	that use 'vars'.
2014-08-22 17:17:58 +10:00
Zoltan Somogyi
9b85c594b8 Add forgotten module. 2014-08-21 12:39:58 +02:00
Zoltan Somogyi
633141efcb Remove most non-core predicates from hlds_goal.m.
compiler/hlds_goal.m:
    As above.

    Put some of the remaining stuff in a more logical order.

compiler/make_goal.m:
    This new module contains the predicates, previously in hlds_goal.m,
    that construct new goals.

compiler/hlds.m:
compiler/notes/compiler_design.html:
    Include the new module.

compiler/goal_form.m:
    Move to this existing module the predicates previously in hlds_goal.m
    that test whether goals have particular forms (which is the task of
    this module).

compiler/*.m:
    Conform to the above. Note that no module requires a new import
    of BOTH make_goal and goal_form.
2014-08-21 12:14:50 +02:00
Zoltan Somogyi
d11ed2327f Allow the compiler to bootstrap with --delay-partial-instantiations.
compiler/modes.m:
    As above.
2014-08-20 16:28:43 +02:00
Julien Fischer
8ad3aaca76 Merge branch 'version-14_01-branch' 2014-08-15 09:26:20 +10:00
Zoltan Somogyi
6df4ab343b Reorganize delay_partial_inst.m before working on it.
compiler/delay_partial_inst.m:
    Separate out the important code: handling constructions and deconstructions
    involving partially instantiated terms.

    Put the predicates in a logical order.

compiler/hlds_goal.m:
    Provide insts for each kind of unification.

    Remove some existing insts that were redundant.

compiler/accumulator.m:
compiler/distance_granularity.m:
compiler/higher_order.m:
compiler/lco.m:
compiler/structure_reuse.indirect.m:
    Conform to the change to hlds_goal.m.
2014-08-14 15:01:00 +02:00
Peter Wang
3f1e77f2bf Fix configuration of thread support for MinGW-w64 32-bit target.
configure.ac:
	Relax a host pattern to cover MinGW-w64 x86 targets (i*86)
	in addition to x86_64.
2014-08-13 16:08:44 +10:00
Peter Wang
d75aa06e99 Account for Winpthreads in configure.
configure.ac:
	Always build the par_gc library with GC_WIN32_PTHREADS when
	pthread.h is detected on MinGW* systems.  Previously, if the
	pthread implementation is not pthread-win32 we would fallback to
	building Boehm GC with GC_WIN32_THREADS (no "P"), so it would
	NOT provide pthread wrapper functions.  But since pthread.h was
	found, the Mercury implementation would make pthread calls, calls
	which are not intercepted by Boehm GC and thus unsafe.

	Change `--with-gc-pthreads-win32' to `--with-gc-win32-pthreads',
	to mean either of pthreads-win32 or winpthreads.
2014-08-13 16:08:33 +10:00
Peter Wang
d77dfad3ba Support building Boehm GC with Winpthreads.
Winpthreads is a pthreads implementation from the MinGW-w64 project,
different from pthreads-win32.  A similar patch to this should make its
way into Boehm GC upstream.  As we will not be upgrading Boehm GC on the
14.01 branch, apply this small change to our copy of the library for now.

boehm_gc/include/private/gc_locks.h:
	Winpthreads uses scalar thread IDs.

boehm_gc/win32_threads.c:
	Winpthread thread IDs should be practically unique but make the
	conservative assumption anyway.
2014-08-13 16:08:25 +10:00
Julien Fischer
f522a3dbaf Define atomic ops in high-level .par grades.
runtime/mercury_atomic_ops.c:
	Fix a mismatch between the macros protecting the declarations and
	the definitions of the atomic ops.
2014-08-13 14:36:41 +10:00
Julien Fischer
ba8ccb9023 Make the lmc script work in grade hlc.par.gc.ll_debug.
tools/lmc.in:
	As above.
2014-08-12 17:43:50 +10:00
Peter Wang
03f90b6ada Enable thread-local allocation and parallel marking on more platforms.
The changes to the platforms that I am unable to test are based on the
boehm_gc/configure script.  If that script allows the features to be
enabled then I assume that the features are usable.

configure.ac:
	Enable parallel marking on Solaris (untested by me).

	Enable on Cygwin (untested by me).

	Enable on MinGW32 (tested).

	Enable on MinGW-w64 (tested with winpthreads, which requires some
	other changes).

	Enable on Darwin (tested by Julien).
2014-08-12 16:27:25 +10:00
Peter Wang
2664ce2ed9 Fix implicit declaration of GC_setup_mark_lock.
boehm_gc/misc.c:
	Include pthread_support.h for GC_setup_mark_lock,
	a Mercury-specific addition.
2014-08-12 16:22:06 +10:00
Zoltan Somogyi
01390ef861 Make is_exist_constr a proper type, not a synonym for boolean.
compiler/hlds_goal.m:
    The is_exist_constr field of rhs_functor, which used to be represented by
    a synonym of boolean. Make this type an enum type.

compiler/*.m:
    Conform to the above change.
2014-08-11 13:15:35 +02:00
Julien Fischer
d60a021efc Merge branch 'version-14_01-branch' 2014-08-11 11:57:20 +10:00
Zoltan Somogyi
1e184398f0 Fix the has_parallel_conj field of generated procedures (Mantis bug 351).
The event sequence that lead to the compiler abort in Mantis 351 was:

1 With -O5 --intermod-opt, the loop invariant optimization finds a loop
  invariant in the pos_mul_karatsuba predicate in library/integer.m.

2 To create the inner predicate (the one that has the already-computed
  invariant passed to it), it tries to make a copy of the original predicate,
  but sets the has_parallel_conj field of the new proc's proc_info to the
  default value, which is has_no_parallel_conj.

3 A later compiler pass has the task of (in par grades) adding synchronization
  to parallel conjunctions, and (in non-par grades) converting the parallel
  conjunctions to sequential. However, due to the has_no_parallel_conj flag
  in the proc_info, it thinks it has no work to do. It therefore leaves the
  parallel conjunction intact.

4 The pre-code-generation simplification pass traverses the entire body of
  the predicate, and, seeing a parallel conjunction, puts a has_parallel_conj
  flag on the proc_info.

5 generate_proc_code sees this flag, but since the target grade is not
  parallel, it ignores the flag. Since debugging is not enabled either,
  it does NOT create a ContainingGoalMap. (The debugger and parallel
  conjunctions are the two things that need this map.)

6 When trying to create the id for the parallel conjunction, par_conj_gen.m
  looks for the ContainingGoalMap. Not finding it, it aborts.

The problem arises in step 2, and the main part of the bug fix is to step 2.
However, it adds a sanity check to step 5 as well, to make any such problems
easier to diagnose in the future.

compiler/hlds_pred.m:
    Require callers of proc_info_create and similar predicates to specify
    whether the new procedure has parallel conjunctions or not.

    Arrange the code of these predicates so that all the fields in the
    proc_info are filled in with variables whose names say what they stand
    for. Previously, many of the fields were just "no" or "[]", not saying
    what `maybe' type or list there was no information for.

    Put these variables in the same order as the fields.

    Add a XXX about the possibility of similar bugs.

compiler/loop_inv.m:
    When creating the inner procedure (and its containing predicate),
    pass the has_parallel_conj flag of the original predicate. This is
    the actual bug fix.

compiler/par_conj_gen.m:
    Improve some comments.

compiler/parallel_to_plain_conj.m:
    Set a procedure's flag to has_no_parallel_conj right after eliminating
    all the parallel conjunctions in it.

compiler/proc_gen.m:
    Add a sanity check: if a procedure has has_parallel_conj, then require
    that the grade be a parallel grade.

compiler/accumulator.m:
compiler/add_pred.m:
compiler/add_special_pred.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/clause_to_proc.m:
compiler/clause_to_proc.m:
compiler/lambda.m:
compiler/make_hlds.m:
compiler/par_loop_control.m:
compiler/pd_info.m:
compiler/stm_expand.m:
compiler/table_gen.m:
compiler/tupling.m:
compiler/unify_proc.m:
compiler/untupling.m:
    Conform to the changes above.
2014-08-11 02:54:17 +02:00
Zoltan Somogyi
4c75d921bc Make filling in goal ids faster.
compiler/goal_path.m:
    When filling in the goal ids in a procedure body, avoid building 234 trees
    that we have keep modifying. Build a simple list, and convert it to a
    234 tree all at once at the end. Repeated insertions into a 234 tree
    leave several garbage cells behind per insertion (at least one per level of
    the tree), whereas our new method leaves just one pair cell and one cons
    cell per goal id.
2014-08-10 14:17:15 +02:00
Zoltan Somogyi
233b899714 Avoid some C compiler warnings in the trace directory.
trace/mercury_trace.h:
    Avoid a warning from the C compiler about casting -1 to an enum
    by adding bool next to the enum that says whether the enum is actually
    defined, or is supposed to be set later (the latter is what the cast -1
    meant).

trace/mercury_trace_cmds.h:
    Rename the type MR_Trace_Command_Info to MR_TraceCmdTableEntry,
    since this (a) says more about the values of the type, (b) avoids
    confusion with the separate MR_TraceCmdInfo type (the one that
    contained the enum mentioned above), and (c) avoids combining
    underscores with CamelCase.

trace/mercury_trace_spy.c:
    Avoid some warnings about switches on enums specifying -1 as a case.

trace/mercury_trace.c:
trace/mercury_trace_*.[ch]:
    Conform to the above changes.
2014-08-09 02:19:35 +02:00
Zoltan Somogyi
1f82bd0606 Minor cleanup before fixing Mantis bug 351. (This is NOT the bug fix.)
compiler/hlds_pred.m:
    Replace some uses of booleans in proc_infos with specialized types.
    Put the fields involved into a more logical order. Give their access
    predicates more meaningful names.

    When creating new proc_infos, give names to all the arguments of
    proc_infos and proc_sub_infos. (I believe Mantis bug 351 is in
    these arguments.)

compiler/hlds_module.m:
    Use the new types in hlds_pred.m where relevant.

compiler/parallel_to_plain_conj.m:
    Add some conditionally combined debugging output that helped me track down
    the problem.

compiler/loop_inv.m:
mdbcomp/mdbcomp.goal_path.m:
    Minor cleanup of some comments.

compiler/code_info.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/distance_granularity.m:
compiler/granularity.m:
compiler/hlds_out_pred.m:
compiler/inlining.m:
compiler/introduce_parallelism.m:
compiler/lambda.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_middle_passes.m:
compiler/par_loop_control.m:
compiler/proc_gen.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_conj.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/trace_gen.m:
compiler/trace_params.m:
    Conform to the changes above.
2014-08-09 02:16:24 +02:00
Julien Fischer
fdab59cfdf Enable the Java and C# grades by default.
configure.ac:
	As above, also rename --enable-{java,csharp}-grade to
	--disable-{java,csharp}-grade.

.INSTALL.in:
	Conform to the above change.
2014-08-08 10:10:20 +10:00
Peter Wang
8917279e2b Document that --link-object and MLOBJS may specify archives.
It was not explicitly stated that --link-object and MLOBJS may specify
archives to link with.  The Mercury build system uses that fact, the
documentation contains some examples doing so, and it has been a
consideration since at least commit eadcd7ab00,
so document it as a supported feature.

compiler/options.m:
doc/reference_manual.texi:
doc/user_guide.texi:
	Mention archives in --link-object and MLOBJS documentation.
2014-08-06 13:46:04 +10:00
Peter Wang
05ec654cb4 Fix --link-object <archive> with --restricted-command-line.
When --restricted-command-line is enabled, we try to shorten the link
command by creating a temporary archive of object files, including files
specified with --link-object.  --link-object can also be used to specify
archives (.a) to link with, which results in nested archives in the
temporary archive.  The linker does not look for object files in nested
archives so it does not work as intended.

compiler/compile_target_code.m:
	Create the temporary archive for --restricted-command-line
	consisting of only the file names in ObjectsList with known
	object file extensions.  Pass any other names in ObjectsList
	to the link command directly.
2014-08-06 13:13:47 +10:00
Zoltan Somogyi
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.
2014-08-05 15:45:33 +02:00
Paul Bone
461050b350 Merge branch 'version-14_01-branch' 2014-08-04 16:55:28 +10:00
Paul Bone
295c788773 Address weak_pointer test review comments.
tests/general/weak_ptr.m:
tests/general/weak_ptr.exp:
tests/hard_coded/Mmakefile:
tests/general/Mmakefile:
    Move week_ptr test into tests/hard_coded

    The weak_ptr test should te executed conditionally, this is easy to do in
    the hard_coded/ test suite.

tests/general/weak_ptr.m:
    Fix spelling error.

tests/general/weak_ptr.exp2:
    Remove unnecessary file.
2014-08-04 16:51:38 +10:00
Paul Bone
a3c59abaaa Fix weak pointer test.
This test was broken in non-C grades due to an omission.

general/weak_ptr.m:
general/weak_ptr.exp2:
    As above.
2014-08-01 15:21:31 +10:00
Paul Bone
496952e5ab Use a thread pool to manage threads on the Java backend
Thread pools are often used to reduce poor performance on embarrassingly
parallel work loads.  This isn't immediately necessary on the Java backend
however I've implemented it because:
    + It will be required when we implement parallel conjunctions for the
      Java backend.
    + I want to implement parallel profiling on the Java backend and don't
      want to have to implement this once now, and then re-implement it after
      introducing thread pools later.

We want the thread pool to generally restrict the number of threads that are
in use, this reduces overheads.  However, when one or more tasks become
blocked then it can be desirable to create extra threads, this helps ensure
that all processors are kept busy and that thread pooling doesn't contribute
to any deadlocks itself.  The implementation is a work in prograss and
currently does not implement this second feature.

Java's API provides several different thread pools, see
java.util.concurrent.Executors, none of which are suitable.  Specifically
the fixed thread pool is unsuitable as we want to be able to temporarily
exceed the normal number of threads as explained above; and the cached
thread pools, which are also very similar to the ThreadPoolExecutor class,
do not implement the correct algorithm for determining when a new thread
should be created (they can still perform poorly for embarassingly parallel
workloads).  Additionally we cannot instrument this code as easily for
parallel profiling.

These changes alter the behaviour of Mercury threads on the Java backend in
two ways, they now behave more correctly and more like threads on the C
backends.
    + If a thread throws an exception it is now reported and the program is
      aborted.  Previously it was ignored and let pass to the Java runtime
      where I assume it was reported.
    + The program now exits only after all threads have exited.

The ThreadPool will automatically detect the number of threads to use, or if
the -P flag is given in the MERCURY_OPTIONS environment variable it will
honor that.

java/runtime/MercuryThread.java:
java/runtime/MercuryThreadPool.java:
java/runtime/MercuryWorkerThread.java:
java/runtime/Task.java:
java/runtime/ThreadStatus.java:
    These new classes make up the thread pool.  A MercuryThread is an
    abstract class for Mercury threads, MercuryWorkerThread is a concrete
    subclass of MercuryThread which includes the worker thread behaviour.
    A Task is a computation/closure that has not yet been started, it
    provides some methods not available in Java's generic Runnable and
    Callable classes.  The others should be self-explanatory and all files
    contain documentation.

java/runtime/Getopt.java:
java/runtime/MercuryOptions.java:
    Parse the MERCURY_OPTIONS environment variable for the -P flag.

java/runtime/JavaInternal.java:
    Add support for handling Mercury exceptions, this is used in case a
    worker thread's task (a Mercury thread) throws an exception.

compiler/mlds_to_java.m:
    The main method of the main Java class of an application now starts and
    uses the thread pool to execute main/2.

library/exception.m:
    Export exception reporting code to the Java runtime system.

library/thread.m:
    Use the thread pool for thread.spawn.
2014-08-01 12:32:51 +10:00
Julien Fischer
90b2d233c0 Improve more error messages.
Make consistency improvements to error messages concerning initialise, finalise
and mutable declarations.

compiler/make_hlds_error.m:
	Pass a list of format_components to error_if_exported/5 and
	error_is_exported/4 as the item description instead of a string.

compiler/add_pragma.m:
compiler/make_hlds_passes.m:
	Conform to the above change.

compiler/modes.m:
	Use the pragma_decl/1 format component in a couple of spots.

tests/invalid/bad_finalise_decl.err_exp:
tests/invalid/bad_initialise_decl.err_exp:
tests/invalid/bad_mutable.err_exp:
tests/invalid/imported_mode.err_exp:
tests/invalid/not_in_interface.err_exp:
tests/invalid/uniq_mutable.err_exp:
	Conform to the above changes.
2014-07-31 09:02:07 +10:00
Julien Fischer
7b5c98a725 Fix a typo in the library documentation.
library/float.m:
	s/float point/floating point/ in a spot.
2014-07-30 23:27:26 +10:00
Julien Fischer
d5cdd701b1 Further consistency improvements for error and warning messages.
The two main changes in this commit are:

(1) Use the error_util library's decl/1 and pramga_decl/1 format components in more
places.

(2) Quote type variables that appear in error messages.

compiler/error_util.m:
	Add a version of list_to_pieces/1 that places each of the strings in
	the input list in single quotes.

compiler/prog_io_type_defn.m:
	Quote type variables names in error messages.

compiler/add_class.m:
compiler/add_pragma.m:
compiler/add_pred.m:
compiler/check_typeclass.m:
compiler/make_hlds_error.m:
compiler/post_typecheck.m:
compiler/prog_io.m:
	Use the error_util library's decl/1 and pragma_decl/1 format components
	in more places.

compiler/mode_errors.m:
	Quote program variables and insts in some error messages.

compiler/post_term_analysis.m:
	Format a type ctor and arity in an error message properly.

tests/invalid/*.err_exp:
tests/warnings/*.exp:
	Conform to the above changes.
2014-07-30 23:09:39 +10:00
Zoltan Somogyi
248301f699 Merge branch 'master' of https://github.com/Mercury-Language/mercury 2014-07-30 13:09:48 +02:00
Zoltan Somogyi
4b44c29c2e Fix mantis bug 311.
compiler/simplify_goal_disj.m:
    Look for the conditions that lead to the bug (a disjunction that
    further instantiates an already partially instantiated variable).
    Generate an error message when found, PROVIDED that this happens
    in a context in which the surrounding procedure can succeed
    more than once. (If it cannot, then you cannot invoke an all-solutions
    predicate on it, and the bug cannot happen.)

    This condition (a model_non surrounding procedure) was motivated
    by mdbcomp/feedback.m, which does not compile without it.

compiler/simplify_info.m:
    The simplify_info type used to contain four different kinds of fields:

    1 static fields; set and then never changed, such as the id of the
      containing procedure
    2 global information, such as the varset and vartypes, which are updated
      as new variable are added, and whose updates need to be kept regardless
      of what part of the procedure is analyzed next
    3 information about the context surrounding the goal currently being
      analyzed, such as the number of lambda expressions we are inside
    4 information about the point in the code before the goal currently being
      analyzed, such as the set of equivalences that currently hold between
      variables (part of common_info).

    The code of the simplify_goal*.m modules used to have jump through hoops
    to handle 3 and 4 properly, given that the simplify_info was being
    threaded through code in a way that was suitable only for 1 and 2.

    This change takes categories 3 and 4 out of the simplify_info.
    It creates a new type, simplify_nested_context, for category 3,
    and adds information about the ability of the procedure surrounding
    the current point to succeed more than once (needed for the bug311 fix)
    to this new type.

compiler/simplify_tasks.m:
    Rename the do_once task to mark_code_model_changes, since this
    expresses what the task is much less ambiguously.

compiler/simplify_goal*.m:
compiler/simplify_proc.m:
compiler/common.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
    Conform to the changes to simplify_info (and simplify_tasks).
    Pass the current instmap and common_info (the two category 4 fields)
    separately.

    Mark some places that could be improved.

compiler/hlds_out_mode.m:
    Generate easier-to-understand debugging output. I needed this to track
    down a bug in my initial fix.

compiler/inst_match.m:
    Remove a redundant unification that couldn't fail (since it was invoked
    only if the exact same unification succeeded a few lines earlier).
    Apply another minor optimizations.

compiler/instmap.m:
    Remove references to the alias branch. It won't be coming back.

compiler/error_util.m:
    Fix some documentation.

mdbcomp/feedback.m:
    Put related stuff together.

tests/warnings/bug311.{m,err_exp}:
    New test case for the bug.

tests/warnings/Mmakefile:
    Enable the new test case.
2014-07-30 12:10:39 +02:00
Julien Fischer
ef6af8bab9 Improve consistency of error and warning messages.
Add two new format components to the error_util library: decl/1 and
pragma_decl/1.  These are converted into strings as follows:

   decl(<Decl>)        ==> `:- <Decl>'
   pragma_decl(<Decl>) ==> `:- pragma <Decl>'

The motivation for this change is that error messages about declarations
often contain text similar to:

    ... in `:- foo' declaration ...

At least that is what occurs most of the time; in some cases the `:-' part is
omitted, in other cases the quotes are omitted.  Using the new format
components makes these consistency problems less likely to occur.  The error
specs are also more concise as well.

This commit also addresses a number of other minor issues related to error.

compiler/error_util.m:
	Add the two new format components describe above.

	Use add_quotes/1 as a single point of control for how single quotes
	are added where possible in this module.

	Call unexpected/3 in preference to error/1.

compiler/goal_expr_to_goal.m;
	Quote the word 'else' when referring the 'else' part of a try goal
	in an error message.

compiler/hlds_out_util.m:
	Add an XXX comment about cons_ids being incorrectly quoted in
	error messages.

compiler/det_report.m:
	Pass the message description to report_determinism_problem/7 as a list
	of format_components rather than as a string.

compiler/make_hlds_warn.m:
	Capitalize the word "Warning" when it occurs at the beginning of a warning.

compiler/typecheck_errors.m:
compiler/modules.m:
	Fix problems I noticed during my previous change.

compiler/add_pragma.m:
compiler/add_type.m:
compiler/det_analysis.m:
compiler/make_hlds_passes.m:
compiler/modules.m:
compiler/oisu_check.m:
compiler/prog_io.m:
compiler/prog_io_mode_defn.m:
compiler/prog_io_mutable.m:
compiler/prog_io_pragma.m:
compiler/prog_io_sym_name.m:
compiler/term_constr_errors.m:
compiler/term_errors.m
compiler/termination.m:
compiler/typecheck_errors.m:
	Conform to the above changes.

tests/invalid/bad_finalise_decl.err_exp:
tests/invalid/bad_initialise_decl.err_exp:
tests/invalid/bad_mutable.err_exp:
tests/invalid/bug83.err_exp:
tests/invalid/ee_invalid.err_exp:
tests/invalid/foreign_enum_import.err_exp:
tests/invalid/foreign_enum_invalid.err_exp:
tests/invalid/foreign_type_missing.err_exp:
tests/invalid/hawkins_mm_fail_reset.err_exp:
tests/invalid/loopcheck.err_exp:
tests/invalid/nested_impl_in_int.err_exp:
tests/invalid/oisu_check_add_pragma_errors.err_exp:
tests/invalid/oisu_check_semantic_errors.err_exp:
tests/invalid/reserve_tag.err_exp:
tests/invalid/try_io_else.err_exp:
tests/warnings/foreign_term_invalid.exp:
tests/warnings/warn_return.exp*:
tests/warnings/warn_succ_ind.exp*:
	Update expected (error) outputs to conform to the above.
2014-07-30 17:04:29 +10:00
Julien Fischer
c3c4ec7772 Delete the LLDS->x86_64 asm backend.
No progress has been made on the LLDS->x86_64 backend since the initial work on
it and it is now more have a maintenance headache then anything else.

compiler/llds_to_x86_64.m:
compiler/llds_to_x86_64_out.m:
compiler/x86_64_instrs.m:
compiler/x86_64_out.m:
compiler/x86_64_regs.m:
	Delete these modules.

compiler/globals.m:
	Delete the x86_64 target type.

compiler/*.m:
	Conform to the above changes.
2014-07-30 17:04:29 +10:00
Peter Wang
d63a294e1f Use mmap for Boehm GC in threaded grades on Linux.
The glibc implementation of malloc (commonly used on Linux) can use sbrk
to acquire more memory, and so does Boehm GC in its default configuration
on Linux.  When both allocators are invoked simultaneously from different
threads then memory corruption may result.

configure.ac:
	Add --enable-gc-mmap option.

	Make --enable-gc-munmap imply --enable-gc-mmap.

	Detect mmap and set MR_HAVE_MMAP.

	Detect sbrk and set MR_HAVE_SBRK.

	On Linux (and potentially other platforms), build Boehm GC for
	threaded grades with -DUSE_MMAP if mmap was found.

Mmake.common.in:
	Add ENABLE_BOEHM_USE_MMAP.

runtime/mercury_conf.h.in:
	Add MR_HAVE_MMAP, although it is not used anywhere yet.

	Add MR_HAVE_SBRK.  It is only for used by the test program.

tests/hard_coded/Mmakefile:
tests/hard_coded/thread_sbrk.exp:
tests/hard_coded/thread_sbrk.exp2:
tests/hard_coded/thread_sbrk.m:
	Add test program.

NEWS:
	Announce changes.
2014-07-30 15:53:47 +10:00
Zoltan Somogyi
e09d7f65c9 Changes that function as a post-commit review of Julien's previous change.
compiler/add_clause.m:
compiler/det_report.m:
compiler/mode_errors.m:
compiler/modes.m:
    Use the sym_name_and_arity format component where appropriate.

compiler/term_constr_errors.m:
    Fix whitespace.

tests/invalid/invalid_main.err_exp:
    Conform to the above.
2014-07-28 22:16:00 +02:00
Julien Fischer
12503b84f3 Do not hardcode quoting style in error messages.
Replace spots in error message specs. where single quotes are hardcoded as `' with
the error_util library's quote/1 constructor.

Fix minor issues with some error messages and add a couple of XXX comments
about some others.

compiler/accumulator.m:
compiler/add_clause.m:
compiler/add_pragma.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/goal_expr_to_goal.m:
compiler/make_hlds_error.m:
compiler/mercury_compile.m:
compiler/mode_errors.m:
compiler/modes.m:
compiler/modules.m:
compiler/options_file.m:
compiler/post_typecheck.m:
compiler/prog_io.m:
compiler/prog_io_pragma.m:
compiler/simplify_goal.m:
compiler/simplify_proc.m:
compiler/term_constr_errors.m:
compiler/term_errors.m:
compiler/termination.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
	As above.

tests/invalid/errors.err_exp:
tests/invalid/missing_det_decl.err_exp:
tests/invalid/no_exports.err_exp:
tests/invalid/predmode.err_exp:
tests/invalid/undef_type.err_exp:
	Conform to the above changes.
2014-07-28 12:09:44 +10:00
Zoltan Somogyi
60b81a998b Simplify the code that simplifies conjunctions.
compiler/simplify_conj.m:
    As above. Use a cord to store the sequence of already processed conjuncts,
    instead of reversing and rereversing lists of goals. (The original code
    was written before cords were available.)
2014-07-25 22:50:20 +02:00
Zoltan Somogyi
72497d7bbf Put "task" in the name of the types that define simplify's tasks.
compiler/simplify_tasks.m:
    As above.

compiler/*.m:
    Conform to the change to simplify_tasks.m.
2014-07-25 13:35:12 +02:00
Peter Wang
419da4d9bd Fix type of MR_compare_tuple_pred for high-level C grades.
runtime/mercury_ho_call.h:
	Fix the type of MR_compare_tuple_pred function pointer
	for high-level C grades.
2014-07-25 17:45:33 +10:00
Peter Wang
8bf7634ad8 Delete unused type io.stream_putback.
library/io.m:
	As above.
2014-07-25 17:45:33 +10:00
Peter Wang
7688546d03 Add thread_safe and not_thread_safe attributes.
library/benchmarking.m:
library/bit_buffer.m:
library/exception.m:
library/gc.m:
library/io.m:
library/library.m:
library/thread.m:
library/time.m:
	Add `thread_safe' or `not_thread_safe' to foreign procs
	where it is clear which is correct.
2014-07-25 17:45:33 +10:00
Peter Wang
39f41fd262 Use mutvar in benchmarking.
library/benchmarking.m:
	Use store mutvar type in `benchmark_nondet_loop'.

	Delete redundant implementation of a reference type.
2014-07-25 17:45:33 +10:00
Peter Wang
b1782c8057 Add thread_safe attribute to store procedures.
The mutvar procedures are not truly thread-safe but neither does
obtaining a global lock make them become thread-safe in a useful way,
except perhaps avoiding data races.  On the other hand, the global lock
inhibits parallelism in programs that do use mutvars in a thread-safe
manner.

library/store.m:
	As above.

NEWS:
	Announce change.
2014-07-25 17:45:33 +10:00
Zoltan Somogyi
4a292707cf Replace simplify.m (which had 4500 lines) with several submodules.
The objective of this change is to improve module cohesion, with each
of the new modules doing only one task, or two or three closely related tasks.
Moving common.m into the new simplify package also improves information hiding,
since the details of the simplify_info data structure that common.m needs
aren't exposed to the rest of the compiler anymore.

This change mostly moves code around. There are no algorithmic changes.
In several places I did

- make predicate names more meaningful,
- reordered predicate definitions to put related predicates together
  (previously, the predicates involved in simplifying a particular kind of goal
  were often interspersed with predicates that worked only on other kinds of
  goals), and
- improved documentation (in some places expanding it, in some places
  correcting comments that suffered bit-rot and were out-of-date).

compiler/simplify.m:
    This file is now a package, including its submodules,
    but no code anymore.

compiler/simplify_goal.m:
    New submodule containing generic processing of goals.

compiler/simplify_goal_call.m:
compiler/simplify_goal_unify.m:
compiler/simplify_goal_conj.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_switch.m:
compiler/simplify_goal_ite.m:
compiler/simplify_goal_scope.m:
    New submodules containing goal-type-specific processing of goals.
    Each of these modules is much more cohesive than the original simplify.m
    ever was; most export only one predicate per handled goal type.

compiler/simplify_info.m:
    New submodule containing the definition of simplify_info
    and its access predicates.

compiler/simplify_tasks.m:
    New submodule listing the tasks that the simplification pass
    may be asked to perform.

compiler/simplify_proc.m:
    New submodule containing the top-level processing of procedures.

compiler/common.m:
    Make this module a part of the simplify package. It is only ever invoked
    by simplification, and leaving it outside the package would require
    exporting more than a few internal details of simplify_info.

compiler/format_call.m:
    Make this module a part of the simplify package. It does its job during
    simplification, even though the need for it is noted during determinism
    analysis.

compiler/check_hlds.m:
    Remove common.m and format_call.m from the list of direct submodules
    of check_hlds.m. (They are now indirect submodules, through
    check_hlds.simplify.)

compiler/notes/compiler_design.html:
    Document the new modules, and the new status of common and format_call..

compiler/pd_util.m:
    Move some code from here to the new simplify_proc.m, since it allows us
    to avoid exposing internal details of how simplification works.

compiler/mercury_compile_front_end.m:
    Move a predicate here from the old simplify.m, since the job it does
    belongs here.

    Remove the ability to disable the invocation of cse_detection.
    This capability was only ever needed when measuring the effectiveness
    of determinism analysis for a paper; it hasn't been needed in a decade.

compiler/cse_detection.m:
    Improve the top level comment.

compiler/options.m:
doc/user_guide.texi:
    Remove the option that used to control the invocation of cse_detection.

compiler/*.m:
    Conform to the split of simplify.m, importing its submodules where needed.
2014-07-24 10:47:12 +02:00
Julien Fischer
fb35005cde Add the fused multiply-add operation to the math module.
Support the fused multiply-add operation in C grades, where the underlying math
library provides it.  Add a predicate that allows program to test for the
presence of this operation.
(The non-C target languages do not currently provide this operation.)

library/math.m:
	Add the function fma/3.

	Add the predicate have_fma/0 which can be used to test for the
	presence of fma operation in the current grade / platform.

configure.ac:
runtime/mercury_conf.h.in:
	Check whether the C99 fma() function is available.

NEWS:
	Announce the above.
2014-07-21 15:04:26 +10:00
Zoltan Somogyi
4c5930c939 Minor cleanups before work on bug 311.
compiler/delay_partial_inst.m:
    Avoid unnecessarily splitting a predicate in two.

    Eliminate a number of unnecessary accesses and updates to the module
    info.

    Return the list of changed pred ids in order.

    Add conditional trace goals to write out procedure bodies
    if this pass changes them.
2014-07-20 00:46:01 +02:00