Branches: main, 11.07
Fix bug #241: a typo was preventing require_semidet scopes from being
recognised.
compiler/prog_io.m;
Fix a typo: s/require_semi/require_semidet/
tests/valid/Mmakefile:
tests/valid/require_bug.m:
Add a test the above.
Estimated hours taken: 0.5
Branches: main
graph_colour: get not least var, but greatest
compiler/mercury_compile.m:
Fix Mantis bug 238.
tests/invalid/bug238.{m,err_exp}:
New test case for Mantis bug 238.
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
Enable the new test case.
Branches: main, 11.07
Fix a problem that prevents Java 1.7 from compiling the Java code generated by
the Mercury compiler. Previously, the TypeInfo_Struct class in the Java
version of Mercury's runtime defined the following constructors:
public TypeInfo_Struct(TypeInfoStruct ti, int arity, Object... as)
public TypeInfo_Struct(TypeInfoStruct ti, Object... as)
Changes to the way most specific varargs method selection works in Java 1.7
means the above is now rejected by the Java compiler. (It should apparently
have never been allowed in the first place.)
The fix is to delete the first constructor above from the runtime and not
generate code that provides the arity. (The arity argument was only ever used
as a sanity check on the number of the following arguments.)
java/runtime/TypeInfo_Struct.java
Delete one of the ambiguous constructors from this class.
compiler/rtti_to_mlds.m:
Don't pass an arity argument to the constructor for TypeInfo_Struct
objects.
Estimated hours taken: 0.3
Branches: main, release
Fix Mantis bug 237.
compiler/polymorphism.m:
If the processing of a promise_solution scope generates new variables
(e.g. PolyConst variables), do not reuse them outside the scope,
since that leads to Mantis bug 237.
tests/hard_coded/promise_eqv_solns_typeclasses.exp.{m,exp}:
New test case for this bug.
tests/hard_coded/Mmakefile:
Enable the new test case.
Branches: main, 11.07
Fix bug #229. A term with an argument produced in a from_ground_term_construct
scope was not itself being marked to be constructed statically. A side-effect
was an exception being thrown while generating a lookup switch in high-level C
grades.
compiler/mark_static_terms.m:
Add the variable constructed in a from_ground_term_construct scope
to the set of static variables.
tests/valid/Mercury.options:
tests/valid/Mmakefile:
tests/valid/mark_static_bug.m:
Add test case.
Branches: main
Fix bug #230. When compiling a sub-module we could incorrectly use the
direct argument functor representation for a d.u. functor when:
1. the outer type is defined and exported from an ancestor module, and
2. the functor argument type is defined in the same ancestor module,
but the type definition is NOT exported.
e.g.
:- module ancestor.
:- interface.
:- type outer ---> f(inner) ; ... .
:- type inner.
:- implementation.
:- type inner ---> inner( ... ).
To solve the problem, the sub-module must be able to distinguish between type
definitions which are available from the ancestor module's public interface,
and type definitions which the ancestor only exported to sub-modules.
The distinction was not apparent in the `.int0' private interface files --
all items were contained into a single interface section, no matter
where they came from in the original source file.
This change separates `.int0' files into two sections: the interface section
for items in the public interface, and the implementation section for items in
the private interface.
compiler/modules.m:
Change `.int0' files to have two sections as described.
Sort the contents of the individual sections.
compiler/add_type.m:
Do not let other statuses override
`status_imported(import_locn_ancestor_private_interface_proper)'.
compiler/make_tags.m:
Fix the main bug described.
Fix a bug where a type with `status_abstract_exported' was not
considered exported-to-submodules, which it is.
compiler/prog_data.m:
Rename and clarify that `import_locn_ancestor_private_interface_proper'
really, really means that it came from the actual, true, and proper
private interface of a module and nowhere else.
compiler/prog_item.m:
Rename `md_private_interface' to what it really means.
compiler/equiv_type.m:
compiler/hlds_out_pred.m:
compiler/hlds_pred.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
Conform to changes.
tests/hard_coded/Mmakefile:
tests/hard_coded/daf_bug.exp:
tests/hard_coded/daf_bug.m:
tests/hard_coded/daf_bug_parent.m:
tests/hard_coded/daf_bug_sub.m:
Add test case.
tests/invalid/ii_parent.ii_child.err_exp:
Update expected output.
Branches: main
Add a new option, --debug-type-rep, that causes the compiler to print a summary
of its type representation choices. At the moment this is restricted to
printing a summary (per module) of those types to which the direct arg functor
optimisation is applied. In particular, the new option is useful for checking
that each module chooses to represent each type in the same way. (I needed
this capability when isolating bug #233.)
compiler/options.m:
Add the new option.
compiler/make_tags.m:
If --debug-type-rep is enabled, the print a summary of those types
(and which ctors) the direct arg functor optimisation is applied to.
Reformat the comments at the head of this module.
doc/user_guide.texi:
Document the new option.
Julien.
Index: compiler/make_tags.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_tags.m,v
retrieving revision 1.66
diff -u -r1.66 make_tags.m
--- compiler/make_tags.m 25 Jul 2011 03:32:07 -0000 1.66
+++ compiler/make_tags.m 21 Nov 2011 04:49:00 -0000
@@ -9,50 +9,43 @@
% File: make_tags.m.
% Main author: fjh.
%
-% This module is where we determine the representation for
-% discriminated union types. Each d.u. type is represented as
-% a word. In the case of functors with arguments, we allocate
-% the arguments on the heap, and the word contains a pointer to
-% those arguments.
+% This module is where we determine the representation for discriminated union
+% types. Each d.u. type is represented as a word. In the case of functors
+% with arguments, we allocate the arguments on the heap, and the word contains
+% a pointer to those arguments.
%
-% For types which are just enumerations (all the constructors
-% are constants), we just assign a different value for each
-% constructor.
+% For types which are just enumerations (all the constructors are constants),
+% we just assign a different value for each constructor.
%
-% For types which have only one functor of arity one, there is
-% no need to store the functor, and we just store the argument
-% value directly; construction and deconstruction unifications
-% on these type are no-ops.
+% For types which have only one functor of arity one, there is no need to store
+% the functor, and we just store the argument value directly; construction and
+% deconstruction unifications on these type are no-ops.
%
-% For other types, we use a couple of bits of the word as a
-% tag. We split the constructors into constants and functors,
-% and assign tag zero to the constants (if any). If there is
-% more than one constant, we distinguish between the different
-% constants by the value of the rest of the word. Then we
-% assign one tag bit each to the first few functors. The
-% remaining functors all get the last remaining two-bit tag.
-% These functors are distinguished by a secondary tag which is
-% the first word of the argument vector for those functors.
+% For other types, we use a couple of bits of the word as a tag. We split the
+% constructors into constants and functors, and assign tag zero to the
+% constants (if any). If there is more than one constant, we distinguish
+% between the different constants by the value of the rest of the word. Then
+% we assign one tag bit each to the first few functors. The remaining functors
+% all get the last remaining two-bit tag. These functors are distinguished by
+% a secondary tag which is the first word of the argument vector for those
+% functors.
%
-% If there are no tag bits available, then we try using reserved
-% addresses (e.g. NULL, (void *)1, (void *)2, etc.) instead.
-% We split the constructors into constants and functors,
-% and assign numerical reserved addresses to the first constants,
-% up to the limit set by --num-reserved-addresses.
-% After that, for the MLDS back-end, we assign symbolic reserved
-% addresses to the remaining constants, up to the limit set by
-% --num-reserved-objects; these symbolic reserved addresses
-% are the addresses of global variables that we generate specially
-% for this purpose. Finally, the functors and any remaining
-% constants are distinguished by a secondary tag, if there are more
-% than one of them.
+% If there are no tag bits available, then we try using reserved addresses
+% (e.g. NULL, (void *)1, (void *)2, etc.) instead. We split the constructors
+% into constants and functors, and assign numerical reserved addresses to the
+% first constants, up to the limit set by --num-reserved-addresses. After
+% that, for the MLDS back-end, we assign symbolic reserved addresses to the
+% remaining constants, up to the limit set by --num-reserved-objects; these
+% symbolic reserved addresses are the addresses of global variables that we
+% generate specially for this purpose. Finally, the functors and any remaining
+% constants are distinguished by a secondary tag, if there are more than one of
+% them.
%
-% If there is a `pragma reserve_tag' declaration for the type,
-% or if the `--reserve-tag' option is set,
-% then we reserve the first primary tag (for representing
-% unbound variables). This is used by HAL, for Herbrand constraints
-% (i.e. Prolog-style logic variables).
-% This also disables enumerations and no_tag types.
+% If there is a `pragma reserve_tag' declaration for the type, or if the
+% `--reserve-tag' option is set, then we reserve the first primary tag (for
+% representing unbound variables). This is used by HAL, for Herbrand
+% constraints (i.e. Prolog-style logic variables). This also disables
+% enumerations and no_tag types.
%
%-----------------------------------------------------------------------------%
@@ -105,14 +98,18 @@
:- implementation.
:- import_module hlds.hlds_pred.
+:- import_module hlds.hlds_out.
+:- import_module hlds.hlds_out.hlds_out_util.
:- import_module libs.globals.
:- import_module libs.options.
:- import_module mdbcomp.prim_data.
:- import_module parse_tree.prog_type.
+:- import_module parse_tree.prog_out.
:- import_module assoc_list.
:- import_module bool.
:- import_module int.
+:- import_module io.
:- import_module map.
:- import_module pair.
:- import_module require.
@@ -445,11 +442,13 @@
TermSizeCells = no
->
module_info_get_type_table(!.HLDS, TypeTable0),
+ module_info_get_name(!.HLDS, ModuleName),
get_all_type_ctor_defns(TypeTable0, TypeCtorsDefns),
globals.lookup_int_option(Globals, num_tag_bits, NumTagBits),
+ globals.lookup_bool_option(Globals, debug_type_rep, DebugTypeRep),
MaxTag = max_num_tags(NumTagBits) - 1,
- convert_direct_arg_functors(MaxTag, TypeCtorsDefns,
- TypeTable0, TypeTable, [], Specs),
+ convert_direct_arg_functors(ModuleName, DebugTypeRep, MaxTag,
+ TypeCtorsDefns, TypeTable0, TypeTable, [], Specs),
module_info_set_type_table(TypeTable, !HLDS)
;
% We cannot use direct arg functors in term size grades.
@@ -467,24 +466,25 @@
Specs = []
).
-:- pred convert_direct_arg_functors(int::in,
+:- pred convert_direct_arg_functors(module_name::in, bool::in, int::in,
assoc_list(type_ctor, hlds_type_defn)::in, type_table::in, type_table::out,
list(error_spec)::in, list(error_spec)::out) is det.
-convert_direct_arg_functors(_, [], !TypeTable, !Specs).
-convert_direct_arg_functors(MaxTag, [TypeCtor - TypeDefn | TypeCtorsDefns],
- !TypeTable, !Specs) :-
- convert_direct_arg_functors_if_suitable(MaxTag, TypeCtor, TypeDefn,
- !TypeTable, !Specs),
- convert_direct_arg_functors(MaxTag, TypeCtorsDefns,
- !TypeTable, !Specs).
+convert_direct_arg_functors(_, _, _, [], !TypeTable, !Specs).
+convert_direct_arg_functors(ModuleName, DebugTypeRep, MaxTag,
+ [TypeCtorDefn | TypeCtorsDefns], !TypeTable, !Specs) :-
+ TypeCtorDefn = TypeCtor - TypeDefn,
+ convert_direct_arg_functors_if_suitable(ModuleName, DebugTypeRep, MaxTag,
+ TypeCtor, TypeDefn, !TypeTable, !Specs),
+ convert_direct_arg_functors(ModuleName, DebugTypeRep, MaxTag,
+ TypeCtorsDefns, !TypeTable, !Specs).
-:- pred convert_direct_arg_functors_if_suitable(int::in,
- type_ctor::in, hlds_type_defn::in, type_table::in, type_table::out,
+:- pred convert_direct_arg_functors_if_suitable(module_name::in, bool::in,
+ int::in, type_ctor::in, hlds_type_defn::in, type_table::in, type_table::out,
list(error_spec)::in, list(error_spec)::out) is det.
-convert_direct_arg_functors_if_suitable(MaxTag, TypeCtor, TypeDefn,
- !TypeTable, !Specs) :-
+convert_direct_arg_functors_if_suitable(ModuleName, DebugTypeRep, MaxTag,
+ TypeCtor, TypeDefn, !TypeTable, !Specs) :-
get_type_defn_body(TypeDefn, Body),
(
Body = hlds_du_type(Ctors, _ConsTagValues, _MaybeCheaperTagTest,
@@ -543,6 +543,15 @@
DirectArgFunctorNames =
list.map(constructor_to_sym_name_and_arity,
DirectArgFunctors),
+ (
+ DebugTypeRep = yes,
+ trace [io(!IO)] (
+ output_direct_arg_functor_summary(ModuleName, TypeCtor,
+ DirectArgFunctorNames, !IO)
+ )
+ ;
+ DebugTypeRep = no
+ ),
DirectArgBody = hlds_du_type(Ctors, DirectArgConsTagValues,
MaybeCheaperTagTest, DuKind, MaybeUserEqComp,
yes(DirectArgFunctorNames), ReservedTag, ReservedAddr,
@@ -584,7 +593,7 @@
% Trust the `direct_arg' attribute of an imported type.
status_is_imported(TypeStatus) = yes,
list.contains(AssertedDirectArgCtors, ConsName / Arity)
- ->
+ ->
ArgCond = direct_arg_asserted
;
% Tuples are always acceptable argument types as they are represented
@@ -623,9 +632,9 @@
(
status_defined_in_this_module(TypeStatus) = yes,
list.contains(AssertedDirectArgCtors, ConsName / Arity)
- ->
+ ->
ArgCond = direct_arg_asserted
- ;
+ ;
ArgTypeCtor = type_ctor(ArgTypeCtorSymName, _ArgTypeCtorArity),
sym_name_get_module_name(ArgTypeCtorSymName, ArgTypeCtorModule),
( TypeCtorModule = ArgTypeCtorModule ->
@@ -636,7 +645,6 @@
)
)
),
-
check_direct_arg_cond(TypeStatus, ArgCond).
:- type direct_arg_cond
@@ -766,6 +774,18 @@
constructor_to_sym_name_and_arity(ctor(_, _, Name, Args, _)) =
Name / list.length(Args).
+:- pred output_direct_arg_functor_summary(module_name::in, type_ctor::in,
+ list(sym_name_and_arity)::in, io::di, io::uo) is det.
+
+output_direct_arg_functor_summary(ModuleName, TypeCtor, DirectArgFunctorNames,
+ !IO) :-
+ write_sym_name(ModuleName, !IO),
+ io.write_string(" : ", !IO),
+ write_type_ctor(TypeCtor, !IO),
+ io.write_string(" : ", !IO),
+ io.write_list(DirectArgFunctorNames, ", ", write_sym_name_and_arity, !IO),
+ io.nl(!IO).
+
%-----------------------------------------------------------------------------%
%
% Auxiliary functions and predicates.
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.708
diff -u -r1.708 options.m
--- compiler/options.m 8 Nov 2011 02:22:42 -0000 1.708
+++ compiler/options.m 21 Nov 2011 04:47:57 -0000
@@ -180,6 +180,7 @@
; debug_intermodule_analysis
; debug_mm_tabling_analysis
; debug_indirect_reuse
+ ; debug_type_rep
% Output options
; make_short_interface
@@ -1161,7 +1162,8 @@
debug_mode_constraints - bool(no),
debug_intermodule_analysis - bool(no),
debug_mm_tabling_analysis - bool(no),
- debug_indirect_reuse - bool(no)
+ debug_indirect_reuse - bool(no),
+ debug_type_rep - bool(no)
]).
option_defaults_2(output_option, [
% Output Options (mutually exclusive)
@@ -2032,6 +2034,7 @@
long_option("debug-intermodule-analysis", debug_intermodule_analysis).
long_option("debug-mm-tabling-analysis", debug_mm_tabling_analysis).
long_option("debug-indirect-reuse", debug_indirect_reuse).
+long_option("debug-type-rep", debug_type_rep).
% output options (mutually exclusive)
long_option("generate-source-file-mapping", generate_source_file_mapping).
@@ -3683,7 +3686,9 @@
"\toption.",
"--debug-indirect-reuse",
"\tOutput detailed debugging traces of the indirect reuse pass of",
- "\t`--structure-reuse' option."
+ "\t`--structure-reuse' option.",
+ "--debug-type-rep",
+ "\tOutput debugging traces of type representation choices."
% The mode constraints code is still experimental so this option is
% currently commented out.
% "--debug-mode-constraints",
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.642
diff -u -r1.642 user_guide.texi
--- doc/user_guide.texi 8 Nov 2011 23:19:49 -0000 1.642
+++ doc/user_guide.texi 21 Nov 2011 04:50:19 -0000
@@ -6771,6 +6771,11 @@
Output detailed debugging traces of the indirect reuse pass of
`--structure-reuse' option.
+@sp 1
+@item --debug-type-rep
+@findex --debug-type-rep
+Output debugging traces of type representation choices.
+
@end table
@node Output options
Estimated hours taken: 1
Branches: main
Fix Mantis bug 227.
compiler/det_report.m:
When looking for violations of require_detism scopes, look inside
lambda goals.
tests/invalid/require_det_in_lambda.{m,err_exp}:
New test case for this bug.
tests/invalid/Mmakefile:
Enable the new test case.
Branches: main
Fix one of the bugs that is preventing the trunk compiling with MSVC in the
hlc.gc grade. MSVC complains about the forward declaration of the DuArgLocn
array for the token/0 type in library/lexer.m having unknown size. The array
size is not being printed in the forward declaration (as it should be) because
when we convert the RTTI to MLDS the initializer is set to be an initializer
for a struct, not an array.
compiler/rtti_to_mlds.m:
Use the correct kind of initializer for DuArgLocn arrays.
reviews.
The configure script now supports the --without-hwloc option to disable the use
of hwloc, even if it is installed.
configure.in:
Allow the use of libhwloc to be disabled with the --without-hwloc option.
Distribute the autoconf macros for pkg-config with Mercury.
This allows mercury to be compiled from CVS on hosts that don't have these
macros in their autoconf installation.
acinclude.m4:
m4/mercury.m4:
Moved acinclude.m4 to m4/mercury.m4. This file contains mercury-specific
macros.
m4/pkg.m4:
Copied pkg.m4 from the autoconf installation on taura. This file contains
pkg-config macros.
INSTALL_CVS:
Mmakefile:
tools/test_mercury:
When calling aclocal pass the -I m4 option.
tools/bootcheck:
Create a link to the m4 directory when setting up stage directories.
Fix static linking with mmc --make and hwloc.
compiler/compile_target_code.m:
Conform to changes in scripts/ml.in (where static linking and hwloc is
already handled correctly).
compiler/options.m:
Create new options so that Mercury.config can tell mmc what options are
needed for linking to hwloc.
scripts/Mercury.config:
Pass hwloc linking options to the compiler.
Branches main, 11.07
Add options for disabling the output generated when type and mode inference are
enabled.
compiler/options.m:
Add the new options.
compiler/typecheck.m:
compiler/mode_errors.m:
Implement them.
doc/user_guide.texi:
Document the new options.
Estimated hours taken: 1
Branches: main
Fix a bug in the RBMM system identified by reviewers of the paper.
runtime/mercury_region.h:
Add a slot to commit frames for saving and restoring the ite stack
pointer.
Do the saving and restoring around commits.
compiler/options.m:
Conform to the changes in mercury_region.h.
Branches: main, 11.07
Allow mutable variables to be initialised by impure functions.
Also fix bug #223. Make thread.semaphore.init/1 and thread.mvar.init/1
impure, as they should be. They were introduced to be used as mutable
initialisers, which led to the oversight of making them pure.
compiler/make_hlds_passes.m:
compiler/prog_mutable.m:
Modify the generated mutable initialisation predicates such that the
initial value may be the return value of a impure function call.
compiler/purity.m:
Ignore warnings about unnecessary impure annotations on goals in
generated mutable predicates. These would now appear when
a mutable is initialised by a call to a pure function, or
by a constant.
doc/reference_manual.texi:
NEWS:
Document the language change.
library/thread.mvar.m:
library/thread.semaphore.m:
Make thread.semaphore.init/1 and thread.mvar.init/1 impure.
tests/hard_coded/Mmakefile:
tests/hard_coded/mutable_init_impure.exp:
tests/hard_coded/mutable_init_impure.m:
Add test case.
Don't transform left-recursive parallel loops into right-recursive loops when
loop control is enabled.
compiler/par_conj_gen.m:
If a loop control scope instantiates a non-local variable that is not
protected by a future ensure that it has a stack slot allocated, and that
the code_info state (used by the code generator) knows where this variable
will be on the stack so that once it is needed it can be used.
An example of this is the variable Y in list.map.
Use a correctly-sized (but not compressed) stack frame for the spawned off
code.
Fix a silly typeo that prevented get_future goals from being added when
they where needed.
Tidy up some code.
compiler/code_util.m:
compiler/opt_util.m:
Move instr_get_rvals_and_lvals from opt_util.m to code_util.m and export it
so that it can be used by par_conj_gen. Modify this predicate so that it
stores rvals and lvals in sets, hopefully reducing the number of rvals and
lvals that need to be represented.
compiler/dep_par_conj.m:
Because left recursion has historically been faster than right recursion,
we used to detect when it was possible to transform right into left
recursion (by swapping the conjuncts in a parallel conjunction). Now that
loop control is effective we disable this hack when loop control is
enabled.
This change made it easy for me to test non tail-recursive loop control
cases like list.map
compiler/live_vars.m:
When a parallel conjunction is transformed into a loop control scope and
then liveness analysis is applied it mis-calculates the death of variables
that die in the loop control scope.
map_foldl(M, F, [X | Xs], !Acc) :-
spawn_off(
M(X, Y),
F(Y, !Acc)
),
...
some_other_code_that_needs_stack_slots,
...
map_foldl(M, F, Xs, !Acc).
X dies after the call to M (post death), Similarly Y dies after the call to
F, depending on dep_par_conj.m Y may also need a stack slot. However,
since M is executing in parallel with
some_other_code_that_needs_stack_slots, the stack slots used by X and Y are
still being used by the spawned off code. And they may continue to be used
up to the recursive call. It is okay if they die within the spawned off
scope, but according to the some_other_code_that_needs_stack_slots, they
need to be alive. so that they have correctly allocated stack slots. They
may then die after the recursive call (at which point the barrier for the
spawned off code will have completed).
live_vars.m therefore tracks these variables and delays their death (after
resurrecting them at the end of the scope) until the recursive call.
Part of this should probably be handled in liveness.m, however the loop
control scope will still need to resurrect these variables. Additionally
there is already code in live_vars to recognize loop control scopes and
their implicit barriers.
Branches: main, 11.07
Fix the decldebug grades with MSVC.
(XXX Most of the system can now be built in none.gc.decldebug with MSVC
except for the deep profiler; the Windows header files #define interface
and this stuffs up compilation of deep_profiler/interface.m.)
compiler/layout_out.
Avoid declarations for layout structures that contain incomplete
types. MSVC treats them as erroneous definitions rather than
declarations. Use the existing mechanism we have in the LLDS
backend for doing this, the MR_STATIC_LINKAGE macro.
Replace my earlier fix or alloc_sites arrays with the
above as well.
library/thread.semaphore.m:
browser/declarative_debugger.m:
browser/util.m:
Use don't care variables for the I/O state in more
foreign procs in order to avoid warnings from MSVC.
Branches: main, 11.07
Make the none.gc.memprof grade work with MSVC again.
Avoid more warnings when compiling with MSVC.
compiler/layout_out.m:
Avoid an incomplete type in the declaration of the alloc_sites
array. (Similar changes need to be made for the layout structures
related to debugging and deep profiling - I am in the process of
testing the former, the latter doesn't currently work on Windows
any way.)
browser/listing.m:
Use don't-care variables in some foreign_procs.
This avoids warnings about assignments from uninitialized
variables with MSVC.
*/.cvsignore:
Update cvsignore entries.
Ignore files generated by mprof.
compiler/par_conj_gen.m:
Make the generated code for copying the stack frame conform to the
macros I've provided in the runtime system.
runtime/par_builtin.h:
Correct bugs in the runtime code for manipulating stack frames.
Estimated hours taken: 3
Branches: main
compiler/par_loop_control.m:
Add draft support for copying shared variables to child stacks
in order to enable tail recursion.
Branches: main, 11.07
Make the hlc.gc.memprof grade work with MSVC again.
compiler/mlds_to_c.m:
Don't use incomplete array types in forward declarations
of static arrays of MR_AllocSitesInfos since MSVC reports
an error for them.
compiler/par_loop_control.m:
If --par-loop-control-preserve-tail-recursion is specified then recursive
calls in parallel conjunctions are detected, they will not be annotated
with the must_not_tail_call feature, and any loop control scope reasons
will say that they must create a frame on the worker context's stack.
Note: This doesn't yet handle unwinding the stack frames on the child
context's stack.
compiler/options.m:
Turn --par-loop-control-preserve-tail-recursion off by default.
Branches: main
Fix a bug in higher order specialization where it incorrectly specialized a
call to a variable after a branch if the variable was constructed in the branch
and its value was known in one branch arm, but not the others.
higher_order.m uses a map to track the possible values of higher order
variables. The map maps variables to either a constant value, or a
'multiple_values' functor to indicate that the variable can contain multiple
values (and is therefore not specializable). The problem was there was
some confusion about what it meant if a variable did not appear in this map.
merge_post_branch_infos was expecting the post_branch_info maps it was merging
to contain all the higher order variables in the arms, when in fact it only
contained variables that the goal traversal routines had deemed specializable.
Any entries it found in one post_branch_info but not the other, would be
copied to the resulting post_branch_info. This was incorrect, because if a
variable did not occur in one post_branch_info its value might simply be
unknown in that arm (in which case is should not be specializable after
the branch).
The fix is to remove the multiple_values functor altogether. A variable now
only appears in the post_branch_info if its value is known and unique.
merge_post_branch_infos has been changed so that it drops variables that
don't appear in both post_branch_infos.
There is one exception to the above where one switch arm is reachable and the
others are unreachable. In this case we can copy any variables with unique
known values in the reachable arm's post_branch_info to the merged
post_branch_info. The reachablility of each arm is therefore now also included
in the post_branch_infos.
compiler/higher_order.m:
As above.
Also remove some comments about the complexity of the
merge_post_branch_infos algorithm, as the current algorithm is the obvious
one given the new meaning of the post_branch_info maps.
tests/general/Mercury.options:
tests/general/Mmakefile:
tests/general/ho_spec_branch_bug.exp:
tests/general/ho_spec_branch_bug.m:
Add a regression test.
This patch prevents dep_par_conj.m from inserting get_future goals where they
are not necessary. These goals where preventing tail recursion in examples
such as map_foldl (not the library predicate, but the one in our paper).
This patch also modifies the loop control scope reason, adding an extra field
that says if the spawned off code may use the parent stack or should setup a
new stack frame.
This patch makes it possible for Zoltan to begin contributing the missing parts
in the code generator. Meanwhile I will work on the runtime system and the
par_loop_control.m code.
compiler/dep_par_conj.m:
Don't insert calls to get_future if they're not needed.
They prevent tail recursion from being possible and are not being optimized
away.
compiler/hlds_goal.m:
Add a new field to the loop_control scope reason, lc_use_parent_stack.
This field is used to tell the code generator if it should generate
references to the parent stack frame or if it should create a new stack
frame on the child's stack.
compiler/code_gen.m:
compiler/par_conj_gen.m:
Pass UseParentStack to the generate_loop_control predicate, and place some
notes in this predicate about how to handle the different values of
UseParentStack.
compiler/constraint.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/erl_code_gen.m:
compiler/goal_util.m:
compiler/hlds_desc.m:
compiler/hlds_out_goal.m:
compiler/interval.m:
compiler/lambda.m:
compiler/make_hlds_warn.m:
compiler/modecheck_goal.m:
compiler/par_loop_control.m:
compiler/polymorphism.m:
compiler/quantification.m:
compiler/saved_vars.m:
compiler/simplify.m:
compiler/stm_expand.m:
compiler/try_expand.m:
compiler/typecheck.m:
compiler/unique_modes.m:
Conform to changes in hlds_goal.m
compiler/live_vars.m:
Conform to changes and make a revisit note about stack slot allocation when
we don't use the parent's stack frame.
compiler/purity.m:
Conform to changes and remove a revisit note.
Estimated hours taken: 1
Branches: main
compiler/par_loop_control.m:
Simplify some code. Fix some comments. Give some predicates
more meaningful names.
Branches: main
Add float registers to the Mercury abstract machine, implemented as an
array of MR_Float in the Mercury engine structure.
Float registers are only useful if a Mercury `float' is wider than a word
(i.e. when using double precision floats on 32-bit platforms) so we let them
exist only then. In other cases floats may simply be passed via the regular
registers, as before.
Currently, higher order calls still require the use of the regular registers
for all arguments. As all exported procedures are potentially the target of
higher order calls, exported procedures must use only the regular registers for
argument passing. This can lead to more (un)boxing than if floats were simply
always boxed. Until this is solved, float registers must be enabled explicitly
with the developer only option `--use-float-registers'.
The other aspect of this change is using two consecutive stack slots to hold a
single double variable. Without that, the benefit of passing unboxed floats
via dedicated float registers would be largely eroded.
compiler/options.m:
Add developer option `--use-float-registers'.
compiler/handle_options.m:
Disable `--use-float-registers' if floats are not wider than words.
compiler/make_hlds_passes.m:
If `--use-float-registers' is in effect, enable a previous change that
allows float constructor arguments to be stored unboxed in structures.
compiler/hlds_llds.m:
Move `reg_type' here from llds.m and `reg_f' option.
Add stack slot width to `stack_slot' type.
Add register type and stack slot width to `abs_locn' type.
Remember next available float register in `abs_follow_vars'.
compiler/hlds_pred.m:
Add register type to `arg_loc' type.
compiler/llds.m:
Add a new kind of lval: double-width stack slots.
These are used to hold double-precision floating point values only.
Record setting of `--use-float-registers' in exprn_opts.
Conform to addition of float registers and double stack slots.
compiler/code_info.m:
Make predicates take the register type as an argument,
where it can no longer be assumed.
Remember whether float registers are being used.
Remember max float register for calls to MR_trace.
Count double width stack slots as two slots.
compiler/arg_info.m:
Allocate float registers for procedure arguments when appropriate.
Delete unused predicates.
compiler/var_locn.m:
Make predicates working with registers either take the register type as
an argument, or handle both register types at once.
Select float registers for variables when appropriate.
compiler/call_gen.m:
Explicitly use regular registers for all higher-order calls,
which was implicit before.
compiler/pragma_c_gen.m:
Use float registers, when available, at the interface between Mercury
code and C foreign_procs.
compiler/export.m:
Whether a float rval needs to be boxed/unboxed when assigned to/from a
register depends on the register type.
compiler/fact_table.m:
Use float registers for arguments to predicates defined by fact tables.
compiler/stack_alloc.m:
Allocate two consecutive stack slots for float variables when
appropriate.
compiler/stack_layout.m:
Represent double-width stack slots in procedure layout structures.
Conform to changes.
compiler/store_alloc.m:
Allocate float registers (if they exist) for float variables.
compiler/use_local_vars.m:
Substitute float abstract machine registers with MR_Float local
variables.
compiler/llds_out_data.m:
compiler/llds_out_instr.m:
Output float registers and double stack slots.
compiler/code_util.m:
compiler/follow_vars.m:
Count float registers separately from regular registers.
compiler/layout.m:
compiler/layout_out.m:
compiler/trace_gen.m:
Remember the max used float register for calls to MR_trace().
compiler/builtin_lib_types.m:
Fix incorrect definition of float_type_ctor.
compiler/bytecode_gen.m:
compiler/continuation_info.m:
compiler/disj_gen.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/hlds_out_goal.m:
compiler/jumpopt.m:
compiler/llds_to_x86_64.m:
compiler/lookup_switch.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/proc_gen.m:
compiler/string_switch.m:
compiler/tag_switch.m:
compiler/tupling.m:
compiler/x86_64_regs.m:
Conform to changes.
runtime/mercury_engine.h:
Add an array of fake float "registers" to the Mercury engine structure,
when MR_Float is wider than MR_Word.
runtime/mercury_regs.h:
Document float registers in the Mercury abstract machine.
Add macros to access float registers in the Mercury engine.
runtime/mercury_stack_layout.h:
Add new MR_LongLval cases to represent double-width stack slots.
MR_LONG_LVAL_TAGBITS had to be increased to accomodate the new cases,
which increases the number of integers in [0, 2^MR_LONG_LVAL_TAGBITS)
equal to 0 modulo 4. These are the new MR_LONG_LVAL_TYPE_CONS_n cases.
Add max float register field to MR_ExecTrace.
runtime/mercury_layout_util.c:
runtime/mercury_layout_util.h:
Extend MR_copy_regs_to_saved_regs and MR_copy_saved_regs_to_regs
for float registers.
Understand how to look up new kinds of MR_LongLval: MR_LONG_LVAL_TYPE_F
(previously unused), MR_LONG_LVAL_TYPE_DOUBLE_STACKVAR,
MR_LONG_LVAL_TYPE_DOUBLE_FRAMEVAR.
Conform to the new MR_LONG_LVAL_TYPE_CONS_n cases.
runtime/mercury_float.h:
Delete redundant #ifdef.
runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
Conform to changes (untested).
trace/mercury_trace.c:
trace/mercury_trace.h:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
trace/mercury_trace_spy.c:
trace/mercury_trace_vars.c:
trace/mercury_trace_vars.h:
Handle float registers in the trace subsystem. This is mostly a matter
of saving/restoring them as with regular registers.
--ignore-par-conjunctions has been created to replace parallel conjunctions
with plain conjunctions, this is helpful for testing. Note that this does not
affect implicit parallelism.
compiler/options.m:
Created new option.
compiler/simplify.m:
Handle the new option within the simplification pass.
doc/user_guide.texi:
Document new option.
Variables communicated to and from the spawned off computation now have stack
slots allocated.
Variables that need stack slots in the spawned off computation must have
distinct stack slots to those that need stack slots between the spawned off
computation and the recursive call, including the recursive call itself.
compiler/live_vars.m:
Refactored the parallel_stackvars structure. It now makes a little more
sense for loop control scopes. It is also abstracted away by a number of
new predicates, making it easier to work with.
To support this a new field has been added to the alloc_data type, this is
necessary for detecting recursive calls.
A new method has been added to the stack_alloc_info(T) typeclass to
communicate information about loop control scopes to the stack slot
allocation algorithm.
compiler/hlds_llds.m:
Create a new type, need_for_loop_control that contains the sets of
stackvars that must have distinct stack slots for the purposes of loop
control.
Update a comment on the maybe_need field of the llds_code_gen_structure to
refer to loop control scopes as well as parallel conjunctions.
compiler/par_conj_gen.m:
Make corrections in how variable locations are managed during code
generation for loop control scopes.
compiler/set_of_var.m:
Provide new set operations cartesian_product and cartesian_product_list.
compiler/stack_alloc.m:
compiler/stack_opt.m:
compiler/tupling.m:
Conform to changes in live_vars.m
Branches: main, 11.07 (maybe)
Avoid warnings from MSVC concerning assignments from uninitialized variables.
These assignments arise due to the assignment of the initial I/O state to the
final I/O state in foreign_proc bodies. In low-level C grades this leads to
code like the following:
{
MR_Word IO0;
MR_Word IO;
...
IO = IO0;
}
Even though IO is itself unused, MSVC still emits a warning about the
assignment (many hundreds of warnings when the io module is opt-imported).
To avoid this, use don't-care variables for the I/O state in foreign procs
and don't include references to the I/O state in their bodies at all.
(We already did this in some places but not others.)
library/benchmarking.m:
library/dir.m:
library/io.m:
library/par_builtin.m:
library/stm_builtin.m:
library/thread.semaphore.m:
library/time.m:
compiler/make.util.m:
compiler/process_util.m:
Make the above change.
Delete the MR_update_io macro that is defined in a couple of spots.
library/io.m:
Unrelated change: s/MR_CONSERVATIVE_GC/MR_BOEHM_GC/ in a spot
since the former does not imply the later and the code that is
protecting is Boehm GC specific.
tests/debugger/poly_io_retry2.m:
Conform the the above change.
Branches: main, 11.07
Fix a problem with the handling of the --grade option.
compiler/handle_options.m:
Reset some grade options that were not being reset
before the effects of a --grade option were applied to
the option table.
This patch commits the code-generator parts of the loop control transformation.
It also makes corrections and changes to the source-to-source, runtime and
library parts of the transformation.
Preliminary results look good, loop controlled right-recursive dependent code
performs as fast as independent right-recursive code, and it does so using the
minimum number of contexts (8 on apollo (an i7)). Previously, when
transforming code by hand, we needed 32 contexts on a 4 core system (taura).
The reason for this is that we changed our design so that the master context
would become blocked if there was no free slot. This ensures that once a
worker finishes it's current job new work is either already available or can be
made available promptly.
compiler/par_conj_gen.m:
compiler/code_gen.m:
Generate code for the new loop_control scope.
compiler/llds_out_instr.m:
Write out the lc_spawn_off instruction correctly.
compiler/code_info.m:
Add support for storing out-of-line code in the code_info structure.
compiler/proc_gen.m:
After generating a procedure's body add any out-of-line code stored in the
code_info structure onto the end of the procedure (after the exit code).
compiler/par_loop_control.m:
Add missing parts to the loop control transformation:
+ Add the barrier in the base case.
+ Transform non-parallel recursive calls.
+ Add a join_and_terminate call to the end of the forked-off code.
Make minor corrections to comments.
runtime/mercury_par_builtin.h:
runtime/mercury_par_builtin.c:
MR_lc_wait_free_slot and MR_lc_spawn_off no-longer mangle the labels they
are passed.
Fix a typeo that caused a bug.
Add debugging code.
library/par_builtin.m:
Store the value of LC in a stack slot during lc_wait_for_slot, This makes
sure it is available in the case that lc_wait_for_slot suspends the
context.
Remove the loop_control_slot type, we now use integers to represent the
position of a slot within a loop control structure.
Branches: main, 11.07
Fix the remainder of bug #99: when using --restricted-command-line with MSVC we
need to manually tell the linker some extra details that it usually infers from
the object files. (With --restricted-command-line all the object files are
placed in a temporary archive beforehand, so there are no object files on the
command line used to invoke the linker.)
compiler/compile_target_code.m:
When using MSVC and --restricted-command-line to link an executable
manually set the target machine type, program entry point and subsystem
type. Also, specify that we need to link against libc.
Add a note about revisiting some of this when we add support for
64-bit Windows.
Branches: main, 11.07
Don't use -o when creating executables with MSVC. (For some silly
reason its been deprecated and we have to use -Fe instead.)
Note that mmc --make already uses -Fe with MSVC, this change only
affects mmake.
configure.in:
scripts/Mmake.vars.in:
Define a new variable, EXEFILE_OPT, whose variable gives the option
used to name executables.
compiler/write_deps_file.m:
Use the above variable instead of hardcoding the option to be
"-o".
Branches: main, 11.07
Fix a bug that causes the compiler to erroneously emit an error message about
multiple foreign_enum pragmas when --intermodule-optimization is enabled.
The problem only shows up with a particular arrangement of submodules and
module imports -- illustrated in the test case -- it is caused by the fact that
the foreign_enum pragma ends up in both the .int and .int0 file and the
existing code for adding pragmas to the HLDS didn't take account of the fact
that both might be present.
compiler/add_pragma.m:
Don't emit an error about duplicate foreign_enum pragmas if one of
them is opt-imported.
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/Mercury.options:
tests/hard_coded/sub-modules/g12_fe_bug*.m:
tests/hard_coded/sub-modules/g12_fe_bug.exp:
Add a regression test.
Branches: main
compiler/quantification.m:
Shift a construction unifiction so that it occurs after all its
arguments have been produced. (The compiler doesn't care but
it does make this code quite difficult to read.)
Estimated hours taken: 8
Branches: main
Add four LLDS instructions Paul will soon need to implement the loop control
transformation.
compiler/llds.m:
Add the new instructions.
compiler/llds_out_instr.m:
Output the new instructions. Paul may want to change the code
we generate.
compiler/dupelim.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_to_x86_64.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/peephole.m:
compiler/reassign.m:
compiler/use_local_vars.m:
Handle the new instructions.
In opt_util.m, fix two old bugs. First, the restore_maxfr instruction
behaved as if it updated hp, not maxfr. Second, the keep_assign
instruction wasn't being handled as an assignment operation.
In peephole.m, fix an old bug, in which assignments through mem_refs
were not considered to invalidate the cached value of an lval.
In use_local_vars, fix an old bug: the keep_assign instruction
wasn't being handled as an assignment operation. Assignments
themselves weren't being as optimized as they could be.
Branches: main
The lambda expansion pass sometimes created predicates with misordered argument
modes. I noticed this problem when compiling exception.m.
`expand_lambda' creates a map from corresponding lists of OrigVars and
OrigArgModes. OrigVars was taken from a `unify_rhs.rhs_lambda_goal' term,
whereas OrigArgModes is derived from the uni_modes of a `unification.construct'
term.
compiler/lambda.m:
Take OrigVars from the list of arguments in the `unification.construct'
term, which must be in the same order as the list of uni_modes right
next to it.
Add sanity check.
compiler/hlds_goal.m:
State that the `rhs_lambda_goal' nonlocals list is in no particular
order.
Estimated hours taken: 0.5
Branches: main
The first part of my post-commit review of Paul's loop control diff,
covering everything except the transformation.
compiler/goal_util.m:
Remove the new expand_plain_conj predicate Paul just added,
since it exactly duplicates the existing goal_to_conj_list.
compiler/par_loop_control.m:
Conform to the above.
runtime/mercury_par_builtin.h:
Fix a bug introduced by Paul's diff: the extendable array MUST be
the last slot in the MR_LoopControl structure.
Fix some of the documentation and the formatting.
runtime/mercury_par_builtin.c:
Fix some of the documentation and the formatting.
Add some XXXs.
remaining part is the code generation for code that is to be spawned off. It
must be handled in the code generator since it uses the parent stack pointer in
many cases.
I'm committing this now so that Zoltan can begin to review it while I work on
the code generator component.
compiler/par_loop_control.m:
This new file contains the source-to-source part of the parallel loop
control transformation..
compiler/transform_hlds.m.
Include the par_loop_control module within the transform_hlds module.
compiler/mercury_compile_middle_passes.m:
Call the loop control transformation at stage 206 - after the dependant
parallel conjunction transformation.
Move the last call optimisation pass from stage 175 to 206 since it will
most-likely prevent loop control from working. Where both transformations
are applicable, the loop control transformation is preferred.
compiler/options.m:
Add new options for loop control.
compiler/handle_options.m:
Disable loop control if we're not in a grade that supports parallel
conjunctions.
Other tests that should have been testing for parallel conjunction support
but only tested parallel support have been fixed.
compiler/hlds_goal.m:
Add the feature_do_not_tailcall feature.
compiler/call_gen.m:
Mark LLCS call goals that may not have last call optimisation applied to
them if they have the feature_do_not_tailcall feature set in their HLDS
info.
compiler/goal_util.m:
Create a new predicate expand_plain_conj, this returns a list of the sub
goals of a plain conjunction, or returns the goal in a singleton list.
XXX: Could someone review the name of this predicate.
compiler/hlds_pred.m:
Add a symbol for the new transformation in the pred_transformation type.
Corrected a comment to match the arguments in the predicate it refers to.
compiler/prog_util.m:
Add support to make_pred_name for creating names for loop control
predicates.
compiler/dep_par_conj.m:
Fix grammer in a comment.
compiler/saved_vars.m:
Conform to the change in hlds_goal.m
compiler/layout_out.m:
Conform to the change in hlds_pred.m
runtime/mercury_par_builtin.[ch]:
Add support for lc_wait_free_slot/2, the blocking version of
lc_get_free_slot/2. This means that other loop control builtins have
changed, for instance, lc_join_and_terminate/2 must wake up a context
blocked in lc_wait_free_slot/2 after making the slot it was using free.
Use a spin lock in the loop control structure rather than a POSIX mutex.
runtime/mercury_wrapper.[ch]:
Add support for a runtime variable, the number of contexts per loop control.
This can be controlled with a MERCURY_OPTIONS option.
mdbcomp/program_representation.m:
Include lc_wait_free_slot/2 in the list of external predicates.
mdbcomp/mdbcomp.goal_path.m:
Add two new predicates goal_path_remove_first/3 and goal_path_get_first/2.
library/par_builtin.m:
Add new builtins to support the loop control transformation:
lc_wait_free_slot/2 will block the context until a new slot is
available.
lc_default_num_contexts/1 will return the number of contexts to use, by
default, for a loop-controlled loop.
Add myself as an author of this module.
doc/user_guide.texi:
Document the runtime --num-contexts-per-lc-per-thread option. It is
currently commented out since it is not intended for users, at least for
now.
Document the loop control options for the compiler.
---
The change below was written by Zoltan, I reviewed when I applied his diff to
my workspace.
Allow the compiler to mark calls in the LLDS as calls that cannot have last
call optimization applied to them. Paul will soon need this capability
in order to implement parallel conjunctions in which earlier conjuncts
are spawned off, and later conjuncts contain recursive calls, but the
earlier conjuncts need the stack frame.
compiler/llds.m:
Add a flag to det and semi calls. (Model_non calls have had a similar
flag for a long time, for a totally different reason.)
compiler/call_gen.m:
By default, say that det and semi calls may have LCO applied to them.
compiler/jumpopt.m:
Apply LCO to det and semi calls only if this flag allows it.
compiler/opt_debug.m:
Include the flag in debugging dumps.
Estimated hours taken: 0.2
Branches: main
Mmakefile:
compiler/introduce_parallelism.m:
compiler/options.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/message.m:
Remove all references to mdprof_feedback, and replace it with
references to mdprof_create_feedback and/or mdprof_report_feedback,
as appropriate.
remaining part is the code generation for code that is to be spawned off. It
must be handled in the code generator since it uses the parent stack pointer in
many cases.
I'm committing this now so that Zoltan can begin to review it while I work on
the code generator component.
compiler/par_loop_control.m:
This new file contains the source-to-source part of the parallel loop
control transformation..
compiler/transform_hlds.m.
Include the par_loop_control module within the transform_hlds module.
compiler/mercury_compile_middle_passes.m:
Call the loop control transformation at stage 206 - after the dependant
parallel conjunction transformation.
Move the last call optimisation pass from stage 175 to 206 since it will
most-likely prevent loop control from working. Where both transformations
are applicable, the loop control transformation is preferred.
compiler/options.m:
Add new options for loop control.
compiler/handle_options.m:
Disable loop control if we're not in a grade that supports parallel
conjunctions.
Other tests that should have been testing for parallel conjunction support
but only tested parallel support have been fixed.
compiler/hlds_goal.m:
Add the feature_do_not_tailcall feature.
compiler/call_gen.m:
Mark LLCS call goals that may not have last call optimisation applied to
them if they have the feature_do_not_tailcall feature set in their HLDS
info.
compiler/goal_util.m:
Create a new predicate expand_plain_conj, this returns a list of the sub
goals of a plain conjunction, or returns the goal in a singleton list.
XXX: Could someone review the name of this predicate.
compiler/hlds_pred.m:
Add a symbol for the new transformation in the pred_transformation type.
Corrected a comment to match the arguments in the predicate it refers to.
compiler/prog_util.m:
Add support to make_pred_name for creating names for loop control
predicates.
compiler/dep_par_conj.m:
Fix grammer in a comment.
compiler/saved_vars.m:
Conform to the change in hlds_goal.m
compiler/layout_out.m:
Conform to the change in hlds_pred.m
runtime/mercury_par_builtin.[ch]:
Add support for lc_wait_free_slot/2, the blocking version of
lc_get_free_slot/2. This means that other loop control builtins have
changed, for instance, lc_join_and_terminate/2 must wake up a context
blocked in lc_wait_free_slot/2 after making the slot it was using free.
Use a spin lock in the loop control structure rather than a POSIX mutex.
runtime/mercury_wrapper.[ch]:
Add support for a runtime variable, the number of contexts per loop control.
This can be controlled with a MERCURY_OPTIONS option.
mdbcomp/program_representation.m:
Include lc_wait_free_slot/2 in the list of external predicates.
mdbcomp/mdbcomp.goal_path.m:
Add two new predicates goal_path_remove_first/3 and goal_path_get_first/2.
library/par_builtin.m:
Add new builtins to support the loop control transformation:
lc_wait_free_slot/2 will block the context until a new slot is
available.
lc_default_num_contexts/1 will return the number of contexts to use, by
default, for a loop-controlled loop.
Add myself as an author of this module.
doc/user_guide.texi:
Document the runtime --num-contexts-per-lc-per-thread option. It is
currently commented out since it is not intended for users, at least for
now.
Document the loop control options for the compiler.
---
The change below was written by Zoltan, I reviewed when I applied his diff to
my workspace.
Allow the compiler to mark calls in the LLDS as calls that cannot have last
call optimization applied to them. Paul will soon need this capability
in order to implement parallel conjunctions in which earlier conjuncts
are spawned off, and later conjuncts contain recursive calls, but the
earlier conjuncts need the stack frame.
compiler/llds.m:
Add a flag to det and semi calls. (Model_non calls have had a similar
flag for a long time, for a totally different reason.)
compiler/call_gen.m:
By default, say that det and semi calls may have LCO applied to them.
compiler/jumpopt.m:
Apply LCO to det and semi calls only if this flag allows it.
compiler/opt_debug.m:
Include the flag in debugging dumps.
Estimated hours taken: 20
Branches: main
Change the types that represent forward and reverse goal paths from being
wrappers around lists of steps, to being full discriminated union types.
This is meant to accomplish two objectives.
First, since taking the wrappers off and putting them back on is inconvenient,
code often dealt with naked lists of steps, with the meaning of those steps
sometimes being unclear.
Second, in a future change I intend to change the way the debugger represents
goal paths from being strings to being statically allocated terms of the
reverse_goal_path type. This should have two benefits. One is reduced memory
consumption, since two different goal path strings cannot share memory
but two different reverse goal paths can share the memory containing their
common tail (the goal paths steps near the root). The other is that the
declarative debugger won't need to do any conversion from string to structure,
and should therefore be faster.
Having the compiler generate static terms of the reverse_goal_path type into
the .c files it generates for every Mercury program being compiled with
debugging requires it to have access to the definition of that type and all
its components. The best way to do this is to put all those types into a new
builtin module in the library (a debugging equivalent of e.g.
profiling_builtin.m). We cannot put the definition of the list type into
that module without causing considerable backward incompatibilities.
mdbcomp/mdbcomp.goal_path.m:
Make the change described above.
Add some more predicates implementing abstract operations on goal
paths.
browser/declarative_tree.m:
compiler/goal_path.m:
compiler/goal_util.m:
compiler/hlds_goal.m:
compiler/introduce_parallelism.m:
compiler/mode_ordering.m:
compiler/push_goals_together.m:
compiler/rbmm.condition_renaming.m:
compiler/trace_gen.m:
compiler/tupling.m:
compiler/unneeded_code.m:
deep_profiler/autopar_costs.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/create_report.m:
deep_profiler/message.m:
deep_profiler/program_representation_utils.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
Conform to the change in representation. In some cases, remove
predicates whose only job was to manipulate wrappers. In others,
replace concrete operations on lists of steps with abstract operations
on goal paths.
compiler/mode_constraints.m:
Comment out some code that I do not understand, which I think never
worked (not surprising, since the whole module has never been
operational).
mdbcomp/slice_and_dice.m:
Since this diff changes the types representing goal paths, it also
changes their default ordering, as implemented by builtin.compare.
When ordering slices and dices by goal paths, make the ordering
explicitly work on the forward goal path, since ordering by the
reverse goal path (the actual data being used) gives nonintuitive
results.
library/list.m:
Speed up some code.
mdbcomp/feedback.automatic_parallelism.m:
Fix some formatting.
Estimated hours taken: 2
Branches: main
Remove references to nondet foreign_proc from the definition of the data
structures that define stack layouts.
runtime/mercury_stack_layout.h:
Remove the trace ports that could occur in nondet foreign_procs
from the definition of the trace port type used in C code.
mdbcomp/prim_data.m:
Remove the trace ports that could occur in nondet foreign_procs
from the definition of the trace port type used in Mercury code.
compiler/layout_out.m:
compiler/stack_layout.m:
compiler/trace_params.m:
mdbcomp/trace_counts.m:
runtime/mercury_trace_base.h:
trace/mercury_trace_declarative.h:
Delete references to those ports.
runtime/mercury_stack_layout.h:
Update the binary compatibility version number for debuggable
executables, since the port number of user events has changed.
Estimated hours taken: 6
Branches: main
Reduce the size of the string tables in debuggable executables by encoding
variable names that fit a few standard templates, the most important of which
is STATE_VARIABLE_name_number.
The effect on the compiler is to reduce the string table size from about
3.1Mb to about 2.1Mb, which is about a 30% reduction.
compiler/stack_layout.m:
Look for the names fitting the patterns in variable names, and encode
them.
runtime/mercury_stack_layout.[ch]:
Add a function for looking up variable names, decoding them if needed.
Since goal paths cannot fit any of the patterns, access them without
using that function.
mdbcomp/rtti_access.m:
Use the new function to retrieve variable names.
runtime/mercury_grade.h:
Increment the debugging compatibility version number, since debuggable
executables in which some modules were produced by a compiler without
this diff and some were produced by a compiler with this diff won't
work together.
Branches: main, 11.07
More Visual C related stuff.
compiler/globals.m:
Allow the C compiler type string for Visual C to have the form
"msvc_<VERSION>" as well as "cl_<VERSION>". Support for the
latter form will eventually be dropped.
configure.in:
Avoid pattern matching on the value of CC; it isn't a reliable
way of telling what the C compiler is.
Use the "-" form of options for MSVC in more places.
scripts/ml.in:
Use the "-" form of options for MSVC.