Commit Graph

22 Commits

Author SHA1 Message Date
Julien Fischer
e7d28ff90f Update copyright notices in stdlib.
library/*.m:
    As above.
2022-06-07 21:51:03 +10:00
Zoltan Somogyi
12605f8c10 Use checked type/inst/modes in parse_tree_int[123]s.
With this change, we guarantee that if any type, inst or mode
has inconsistent definitions in its defining module, those inconsistencies
will not make it into the the module's .int/.int2/.int3 files, where
they would confuse any compiler invocation that reads them in.

compiler/prog_item.m:
    Replace {type,inst,mode}_ctor_defn_maps, which are unchecked,
    with {type,inst,mode}_ctor_checked_maps in parse_tree_int[123]s.

    To make this possible,

    - generalize the items containing inst and mode definitions the way that
      items containing type definitions have been generalized previously,
      to allow them to store particular *kinds* of inst or mode definitions;

    - move the definitions of type_ctor_checked_map and its components
      here from check_type_inst_mode_defns.m; and

    - add similar, but simpler, definitions for {inst,mode}_ctor_checked_map.

compiler/check_type_inst_mode_defns.m:
    Delete the type definitions moved to prog_item.m.

    Modify the checking process slightly to allow it to check properly
    the definitions we now put into .int, .int2 and .int3 files.

    Add code to check inst and mode definitions as well as type definitions.
    Since insts and modes have only one non-abstract kind of definition,
    these codes are much simpler than the code for checking types.

compiler/comp_unit_interface.m:
    Construct checked type, inst and mode definitions to put into
    .int, .int2 and .int3 files. The .int2 and .int3 parts were
    reasonably simple, but the .int part requires some detailed
    case-by-case analysis.

compiler/convert_parse_tree.m:
    Check the type, inst and mode definitions read in from .int/.int2/.int3
    files when creating their parse trees. If those files were generated
    by a compiler that has this diff, then this checking process should
    not find any problems.

compiler/equiv_type.m:
    Operate on checked type, inst and mode definitions instead of their
    unchecked versions.

    Delete an unneeded field from a structure.

compiler/error_util.m:
    Add {qual,unqual}_{inst,mode}_ctor as format components, so that
    any error messages about inst and mode definitions do not have to convert
    inst_ctors and mode_ctors to symname/arity pairs.

compiler/item_util.m:
    Add some utility predicates and functions needed by the changes above.

compiler/module_qual.collect_mq_info.m:
    Since checked type, inst and mode definitions can contain info that is
    derived from both the interface and implementation sections of a module,
    add the capability to get only the *publicly* declared types, insts and
    modes from their respective kinds of checked definitions.

compiler/module_qual.qualify_items.m:
    Module qualify checked type, inst and mode definitions.

compiler/module_qual.qual_errors.m:
    Treat references to inst_ctors and mode_ctors in qualification error
    messages the same way as we treat type_ctors.

    Also replace mq_ids that are intended to represent classes with class_ids,
    to represent the intent better.

compiler/parse_tree_out.m:
    Output the updated parse_trees of .int/.int2/.int3 files.

compiler/prog_data.m:
    Add an XXX about a future change.

compiler/decide_type_repn.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/make_hlds_separate_items.m:
compiler/pred_table.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
    Conform to the changes above.

library/maybe.m:
    Add utility predicates needed by the code above.

NEWS:
    Announce the new predicates in maybe.m.

tools/intdiffall:
    A script that shows differences between the automatically generated
    interface files between stage 1 and stage 2, which helped debug this diff.
2021-10-01 17:57:15 +10:00
Zoltan Somogyi
a12692a0de Replace /* */ comments with // in the library.
Keep the old style comments where they do not go to the end of the line,
or where it is important that the comment line not have a // on it.
2018-06-21 18:55:08 +02:00
Mark Brown
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.
2018-06-09 17:43:12 +10:00
Zoltan Somogyi
d9e576a2b2 Specify the type for inst definitions.
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
mdbcomp/*.m:
ssdb/*.m:
    Specify the type constructor for every inst definition that lists
    the functors that values of that type may be bound to.

    In library/maybe.m, delete the inst maybe_errors/1, because
    (a) its name is misleading, since it is for the maybe_error/1 type (no s),
    and (b) there is already an inst with the non-misleading name maybe_error
    which had an identical definition.

    In compiler/dep_par_conj.m, delete two insts that were duplicates
    of insts defined in hlds_goal.m, and replace references to them
    accordingly.
2017-11-08 16:54:18 +11:00
Zoltan Somogyi
4a9c3772f7 Fix typo in comment. 2017-04-05 05:01:35 +10:00
Paul Bone
ae29f96b5c Move some code from std_util.m to maybe.m
Deprecate the maybe_pred and maybe_func code in std_lib.m and add a
new function func_to_maybe to maybe.m.

library/std_util.m:
library/maybe.m:
    As above.

NEWS:
    Update news file.
2016-09-02 16:44:54 +10:00
Paul Bone
a2e626f69d Add maybe.semidet_to_maybe
library/maybe.m:
    As above.

NEWS:
    Announce the change.
2016-08-10 16:45:16 +10:00
Paul Bone
26807be53f Add maybe_default/2 standard library function
library/maybe.m:
    As above.

NEWS:
    Announce the new addition.
2016-08-01 23:38:00 +10:00
Paul Bone
db5fc3a1cc Fix whitespace in library/maybe.m
library/maybe.m:
    As above.
2015-03-06 22:30:29 +11:00
Sebastian Godelet
0a98e09047 Fix maybe.fold_maybe/2 documentation
The application of the yes value in the fold_maybe/2 function was not mentioned
in the documentation.

library/maybe.m:
    see above.
2015-03-06 22:25:51 +11:00
Julien Fischer
670a208246 Add the predicate maybe.fold2_maybe/6 to the standard library.
Add a predicate version of ground_pseudo_type_desc_to_type_desc.

library/maybe.m:
	Add the above predicate.

	Re-order some existing declarations as per the coding standard.

library/type_desc.m:
	Add a predicate verison of ground_pseudo_type_desc_to_type_desc.

NEWS:
	Announce the above.
2014-12-29 14:59:59 +11:00
Zoltan Somogyi
2945d69732 Simplify and improve calls to format preds.
library/string.parse_runtime.m:
    Replace the two previous two level scheme for representing format string
    components with a simpler one level scheme, which should avoid some
    memory allocations, and which should also make switches faster.

library/string.format.m:
    Conform to the change in string.parse_runtime.m.

compiler/parse_string_format.m:
    Replace the two previous two level scheme for representing format string
    components with a one level scheme, as in string.parse_runtime.m.

    Record the context of all the values to be printed.

compiler/format_call.m:
    Previously, when we replaced calls to format predicates with calls
    that formatted each value to be printed, we used term.context_init as
    the context of the replacement goals. We now use the contexts recorded for
    the value. Likewise, for the calls to predicates that concatenated the
    results together, we now use the context of the original call.
    This should give more useful information to anyone who uses the deep
    profiler on code that was transformed by format_call.m.

    Avoid unnecessary updates to the conj_maps, which should make
    the operation of format_call.m itself faster.

    Gather identified format call sites immediately even inside disjunctions,
    instead of creating a list of the sites inside each disjunct, and then
    appending it to the end of the list of sites so far. This should also
    improve the speed of format_call.m.

library/maybe.m:
    Add a maybe_errors type, which is like maybe_error, but in which the
    error case contains one OR MORE error indications.

NEWS:
    Mention the new maybe_errors type.
2014-12-02 16:29:12 +11:00
Zoltan Somogyi
7f9791aa26 Standardize divider line lengths in the library.
library/*.m:
    As above.

tool/stdlines:
    A new shell script to do the job.
2014-11-23 22:05:34 +11:00
Paul Bone
b36d60b494 Fix whitespace in maybe.m
library/maybe.m:
    A tab was used where four spaces should have been used.  This was
    causing strange formatting in the documentation.
2014-06-06 21:59:14 +10:00
Paul Bone
f96e4579ea The maybe_error type is now polymorphic in the type of error
The maybe_error type now takes a second type argument allowing users to
customise the type of error that can be represented.

library/maybe.m:
    As above.

NEWS:
    Add a dot point for this change.
2013-02-14 12:21:06 +11:00
Julien Fischer
cd4bd74002 Add the predicate map_fold3_maybe/9.
Branches: main

library/maybe.m:
	Add the predicate map_fold3_maybe/9.

	Add further modes for the other fold predicates
	in this module.

NEWS:
	Announce the above changes.
2011-06-23 03:36:10 +00:00
Paul Bone
881039cfed Correct problems in the automatic parallelism analysis.
This patch fixes various problems, the most significant is the calculation of
variable use information.  The parallelisation analysis uses deep profiling
data.  In other words, profiling data that is attached to context information
referring to not just the procedure but the chain of calls leading to that
invocation of that procedure (modulo recursion).  The variable use analysis did
not use deep profiling data, therefore comparing the time that a variable is
produced with a call to the time in total of that call was not sound, and
sometimes resulted in information that is not possible, such as a variable
being produced or consumed after the call that produces or consumes it has
exited.

This change-set updates the variable use analysis to use deep profiling data to
avoid these problems.  At the same time it provides more accurate information
to the automatic parallelisation pass.  This is possible because of an earlier
change that allowed the coverage data to use deep profiling data.

In its current state, the parallelisation analysis now finishes without errors
and computes meaningful results when analysing a profile of the mercury
compiler's execution.

deep_profiler/report.m:
    The proc var use report is now a call site dynamic var use report.
       1) It now uses deep profiling data.
       2) It makes more sense from the callers perspective so it's now based
          around a call site rather than a proc.

    Add inst subtypes to the recursion_type type.

deep_profiler/query.m:
    The proc var use query is now a call site dynamic var use query, see
    report.m.

deep_profiler/var_use_analysis.m:
    Fix a bug here and in mdprof_fb.automatic_parallelism.m: If a
    variable is consumed by a call and appears in it's argument list more than
    once, take the earliest consumption time rather than the one for the
    earliest argument.

    Variable use analysis now uses recursion_patterns.m to correctly compute
    the cost of recursive calls.  It also uses 'deep' profiler data.

    Only measure variable use relative to the entry into a procedure, rather
    than either relative to the entry or exit.  This allows us to simplify a
    lot of code.

deep_profiler/create_report.m:
    The proc var use info report is now a call site dynamic var use info
    report.

    Move some utility code from here to the new analysis_utils.m module.

deep_profiler/display_report.m:
    Conform to changes in report.m.

    Improve the information displayed for variable first-use time
    reports.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Conform to changes in report.m

    Refactored the walk down the clique tree.  This no-longer uses the
    clique reports from the deep profiling tool.

    We now explore the same static procedure more than once.  It may be best to
    parallelise it in some contexts rather than others but for now we assume
    that the benefits in some context are worth the costs without benefit in
    the other contexts.  This is better than reaching a context where it is
    undesirable first and never visiting a case where parallelisation is
    desirable.

    Fix a bug in the calculation of how much parallelisation is used by
    parallelisations in a clique's parents.  This used to trigger an
    assertion.

    Don't try to parallelize anything in the "exception" module.
    There's probably other builtin code we should skip over here.

    Removed an overzealous assertion that was too easily triggered by the
    inaccuracies of IEEE-754 arithmetic.

    Compute variable use information lazily for each variable in each call.  I
    believe that this has made our implementation much faster as it no-longer
    computes information that is never used.

    Refactor and move build_recursive_call_site_cost_map to the new
    module analysis_utils.m where it can be used by other analyses.

    Call site cost maps now use the cs_cost_csq type to store costs,
    code in this module now conforms to this change.

    Conform to changes in messages.m

deep_profiler/recursion_patterns.m:
    Export a new predicate, recursion_type_get_maybe_avg_max_depth/2.  This
    retrieves the average maximum recursion depth from recursion types that know
    this information.

    Move code that builds a call site cost map for a procedure to
    analysis_utils.m where it can be used by other analyses.

deep_profiler/analysis_utils.m:
    Added a new module containing various utility predicates for profile
    analysis.

deep_profiler/coverage.m:
    Added an extra utility predicate get_coverage_after/2.

deep_profiler/message.m:
    Each message has a location that it refers to, a new location type has
    been added: call_site_dynamic.

    Added a new warning that can be used to describe when a call site's
    argument's use time cannot be computed.

    Added new predicates for printing out messages whose level is below a
    certain threshold.  These predicates can be called from io trace goals.
    Message levels start at 0 and currently go to 4, more critical messages
    have lower levels.  The desired verbosity level is stored in a module local
    mutable.

deep_profiler/mdprof_feedback.m:
    Move the message printing code from here to message.m.

deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
    Conform to changes in query.m.

mdbcomp/feedback.automatic_parallelism.m:
    Added a new function for computing the 'cpu time' of a parallel
    computation.

library/lazy.m:
    Moved lazy.m from extras to the standard library.

library/list.m:
    Add a new predicate member_index0/3.  Like member/2 except it also gives
    the zero-based index of the current element within the list.

library/maybe.m:
    Add two new insts.
        maybe_yes(I) for the maybe type's yes/1 constructor.
        maybe_error_ok(I) for the maybe_error type's ok/1 constructor.

library/Mercury.options:
    Add a work around for compiling lazy.m with intermodule optimisations.

NEWS:
    Update news file for the addition of lazy.m and the member_index0 predicate
    in list.m

deep_profiler/.cvsignore:
    Ignore feedback.automatic_parallelism.m which is copied by Mmakefile from
    the mdbcomp/ directory.
2010-10-07 02:38:10 +00:00
Paul Bone
79c3f39a68 Implicit parallelism work.
The implicit parallelism algorithm, feedback file format and therefore compiler
have been updated.  They now support parallelisation across other goals and, in
theory, parallelising three or more calls against one another.  The algorithm
is far from complete and very much experimental, it has been tested on a
modified version of icfp_2000 where it improves the runtime.  Note that
automatic parallelisation of dependant conjunctions is disabled for now.

mdbcomp/feedback.m:
    Modify deep profiling feedback data, a candidate parallel conjunct now
    contains a list of sequential conjunctions that contain other goals.
    Previously only two calls to be parallelised against one-another where
    listed.

    Document restrictions on the new candidate parallel conjunct structure that
    can't be expressed by the type system.

    Incremented the feedback file format number.

mdbcomp/program_representation.m:
    Made a semidet predicate version of empty_goal_path.

    Created maybe_search_var_name which returns it's result wrapped in a maybe
    structure, this is a deterministic alternative to search_var_name.  It is
    useful as an argument to list.map

deep_profiler/mdprof_feedback.m:
    When printing messages out to stderr also print the newlines between the
    messages to stderr.

deep_profiler/measurements.m:
    Re-aranged the order of arguments and added a four argument version for
    sub_computation_parallelism.

    Added a new function, some_parallelism/1, that initialises a parallelism
    amount as.

deep_profiler/message.m:
    Added extra messages.

    Pretty-print program locations using the conventional string representation
    for procedures and goal paths.  Export the predicate that does this.

deep_profiler/program_representation_utils.m:
    Export a predicate to format a procedure identifier nicely.

    Add code for calculating and manipulating inst_map_delta objects similar to
    those in the compiler.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Various code cleanups/simplifications.

    Re-worked the parallelisation algorithm, it can now parallelise across
    cheaper calls and (theoretically) handle parallel conjunctions with any
    number of conjuncts.

    Conform to new candidate parallel conjunction representation.

    Internally use a structure similar to the candidate parallel conjunct
    structure in feedback.m  This makes the maybe_call_conjunct structure
    obsolete, the old structure has been removed.

compiler/implicit_parallelism.m:
    Updated implicit parallelism transformation to conform to the new feedback
    file format.

compiler/goal_util.m:
    Added goal_is_atomic/2
    Modified create_conj_from_list to simply return the only goal in the list
    when the list contains exactly one goal.

library/maybe.m:
    Add a simple predicate (maybe_is_yes/2) that 'opens' a maybe and returns the result or
    fails.

NEWS:
    Announce maybe_is_yes/2
2010-01-09 05:49:41 +00:00
Julien Fischer
e0f5ac47db Make it easier for vi to jump past the initial comments
Estimated hours taken: 0.1
Branches: main

library/*.m:
	Make it easier for vi to jump past the initial comments
	at the head of a module.
2006-04-19 05:18:00 +00:00
Julien Fischer
5e92224eec Improve the library reference manual by formatting the beginning of
Estimated hours taken: 0.2
Branches: main, release

library/*.m:
	Improve the library reference manual by formatting the beginning of
	library modules consistently.

library/integer.m:
	Fix some bad indentation.
2006-04-13 06:08:05 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00