mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 13:55:07 +00:00
14cdb854dd4682e6f1e3a393a34d71a5796a0aef
214 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
14cdb854dd |
Disable the test which causes us to not pass type-infos to C
Estimated hours taken: 0.1
Branches: main
(This change was sent to mecury-reviews by dgj. I'm committing it
now so that the installation on earth will succeed tonight).
compiler/polymorphism.m:
Disable the test which causes us to not pass type-infos to C
code which do not use the variable corresponding to that type-info.
For some reason, this is causing the compiler to abort when
compiling stage2/browser/declarative_execution.m.
|
||
|
|
d701d8ba06 |
Use pred_const cons_ids in the unify_rhs field for constructions
Estimated hours taken: 4
Use pred_const cons_ids in the unify_rhs field for constructions
of higher-order terms. Previously there would be a `cons(sym_name, arity)'
cons_id in the `unify_rhs', and a pred_const in the `unification'.
This avoids multiple calls to get_pred_id_and_proc_id, and is more
consistent with how other cons_ids are handled.
compiler/post_typecheck.m:
Find the pred_const cons_id for constructions of higher-order terms.
Make sure the sym_name field of a call goal is fully module qualified.
compiler/higher_order.m:
compiler/lambda.m:
Use `pred_const' rather than `cons(sym_name, arity)' in the
`unify_rhs' of constructions of higher-order terms.
compiler/polymorphism.m:
compiler/modecheck_unify.m:
Change the interface of polymorphism__convert_pred_to_lambda_goal
to reflect the fact that the pred_proc_id of the higher-order term
has already been computed by post_typecheck.m.
compiler/purity.m:
Don't attempt to resolve overloading if there were type errors.
If the type inference iteration limit was exceeded the code
to resolve overloading of higher-order terms in post_typecheck.m
can abort. This occurred with tests/invalid/type_inf_loop.m.
compiler/hlds_goal.m:
Remove documentation about the restrictions on cons_ids
in a unify_rhs, since they no longer apply.
compiler/intermod.m:
Remove code duplicated from post_typecheck.m.
compiler/hlds_data.m:
Add a comment that code_addr_const cons_ids are no longer
used (they are left over from an old method of constructing
type_ctor_infos).
compiler/hlds_out.m:
Don't abort on code_addr_consts in hlds_out__write_functor_cons_id.
This will avoid problems if anyone decides to start using
code_addr_consts again.
tests/invalid/Mmakefile:
tests/invalid/aditi_update_errors.m:
tests/invalid/aditi_update_derived_relation.{m,err_exp}:
Separate out parts of aditi_update_errors.m which
were no longer being tested because post_typecheck
is no longer run when there are type errors.
tests/invalid/aditi_update_errors.err_exp:
tests/invalid/aditi_update_mode_errors.err_exp:
Update the expected output.
|
||
|
|
204e151516 |
Do not pass a type-info or typeclass-info to C code that does not use
Estimated hours taken: 9
mercury/compiler/polymorphism.m:
Do not pass a type-info or typeclass-info to C code that does not use
the variable.
To check if the C code uses the variable, we simply check for the
occurence of the variable name in the string that represents the C
code. This is potentially unsafe if the user decides to do something
horrible with the preprocessor, but I don't think this needs to be
specially documented --- AFAIK there is no user-visible documentation
about passing type-infos to and from C anyway.
|
||
|
|
3ea6e2e88d |
Fix a bug reported by Nick Nethercote. The symptom of this bug was that
Estimated hours taken: 4 Fix a bug reported by Nick Nethercote. The symptom of this bug was that the compiler aborted during the polymorphism transformation for predicates whose type contained a repeated type class constraint. library/map.m: Add a new predicate map__set_from_corresponding_lists which is like map__det_insert_from_corresponding_lists but uses map__set rather than map__det_insert. ie. it does not abort if a duplicate key is provided. Also add a pred map__set_from_assoc_list and function versions of these two new preds to be consistent with map__det_insert_from_corresponding_lists. compiler/polymorphism.m: When building the initial type class info variable map, use map__set_from_corresponding_lists rather than map__det_insert_from_corresponding_lists to take the case of repeated type class constraints into account. tests/valid/Mmakefile: tests/valid/repeated_class_constraint.m: A test case for this. |
||
|
|
59250e8f20 |
Fix bugs with the handling of existentially typed data types
Estimated hours taken: 8 Branches: main, release Fix bugs with the handling of existentially typed data types in various parts of the RTTI code. Most of these bugs were due to passing in the pointer to the secondary tag, rather than the pointer to the first real argument (one word past the secondary tag). library/std_util.m: Fix bugs in ML_expand() and du_get_functor_info. runtime/mercury_tabling.c: Fix bug in MR_table_type(). runtime/mercury_deep_copy_body.h: Fix bug in MR_agc_deep_copy(), the accurate GC version of deep_copy(). Also fix another bug in the same function: when copying existentially typed data types, it was trying to use the type_infos in the original data after they had already been replaced by forwarding pointers. compiler/polymorphism.m: For existentially typed data types, make sure that the type_infos come BEFORE the typeclass_infos, not vice versa. This is needed to match the code in the runtime system. It's also consistent with the way we order them for procedure calls. runtime/mercury_type_info.h: Improve the comments a little. tests/hard_coded/Mmakefile: tests/hard_coded/deep_copy_exist.m: tests/hard_coded/deep_copy_exist.exp: Regression tests. |
||
|
|
36bb97d223 |
Fix a bug where the compiler was silently accepting invalid code.
Estimated hours taken: 6 Branches: main, release Fix a bug where the compiler was silently accepting invalid code. doc/reference_manual.texi: Document that type class methods must have their modes and determinism explicitly declared. compiler/make_hlds.m: Report errors for predicate type class methods with no modes or with modes but no determinism. compiler/check_typeclass.m: compiler/polymorphism.m: Handle the case where a method has no declared determinism: since make_hlds.m will have already reported the error, we just need to avoid aborting or issuing spurious flow-on errors. tests/invalid/Mmakefile: tests/invalid/typeclass_missing_mode.m: tests/invalid/typeclass_missing_mode.err_exp: tests/invalid/typeclass_missing_mode_2.m: tests/invalid/typeclass_missing_mode_2.err_exp: tests/invalid/typeclass_missing_det.m: tests/invalid/typeclass_missing_det.err_exp: tests/invalid/typeclass_missing_det_2.m: tests/invalid/typeclass_missing_det_2.err_exp: tests/invalid/typeclass_missing_det_3.m: tests/invalid/typeclass_missing_det_3.err_exp: Add some regression tests. tests/invalid/tc_err1.err_exp: Update the expected output for this existing test. |
||
|
|
1c65d003f7 |
Add the shorthand_goal_expr wrapper type to ease hlds->hlds transformations.
Estimated hours taken: 4.5
Branches: main
Add the shorthand_goal_expr wrapper type to ease hlds->hlds transformations.
compiler/hlds_goal.m
Create a new type, the `shorthand_goal_expr', for goals kinds that
are implemented by a (ordinary_hlds + shorthand) -> (ordinary_hlds)
transformation. At present, bi_implication is the only kind of
of goal that is implemented in this way.
Moved bi_implication functor from the type goal_expr to the new
shorthand_goal_expr type.
Added the functor shorthand to the goal_expr type.
compiler/*.m
Change switches on hlds_goal_expr that call error when they recognise
`bi_implication' from calling error when they recognise
`bi_implication' to calling error when they recognise `shorthand'.
For all predicates K that
a) switch on hlds_goal_expr and
b) perform non-trivial processing when they recognise
`bi_implication'
change K such that it now calls K_shorthand upon recognising the
functor `shorthand'. Define K_shorthand to switch on
shorthand_goal_expr, where the code for the `bi_implication' case
formerly contained in K is now contained in K_shorthand.
|
||
|
|
711da78188 |
Rename foreign_code as foreign_proc where appropriate in the compiler.
Estimated hours taken: 4.0 Branches: main Rename foreign_code as foreign_proc where appropriate in the compiler. The rationale for this change is that it makes maintaining the code much simpler because it is clear whether `foreign' refers to a slab of code (foreign_code) or a procedure (foreign_proc). :- type pragma_foreign_code_attributes :- type pragma_foreign_proc_attributes The functors for pragma_type foreign(Lang, BodyCode) foreign(Attributes, Name, PredOrFunc, Vars, Varset, Impl) become foreign_code(Lang, BodyCode) foreign_proc(Attributes, Name, PredOrFunc, Vars, Varset, Impl) And the HLDS goal `pragma_foreign_code' becomes `foreign_proc'. compiler/*.m: Update the compiler to use the new names. |
||
|
|
29baab7783 |
Fix a bug reported by petdr on October 30th last year.
Estimated hours taken: 12
Fix a bug reported by petdr on October 30th last year.
compiler/polymorphism.m:
When looking up the variable which contains a typeclass info for
a particular constraint to be passed to a call, handle the case where
there is *no* variable for such a constraint. This occurs in the case
where the producer of the variable occurs later on in the goal (but
will get re-ordered by the mode checker). The solution is to just
create a variable for the typeclass info, and whenever creating
a `head' variable to hold a constraint being produced by a call,
check first whether there is already a variable allocated for that
constraint.
doc/reference_manual.texi:
Delete mention of this bug from the "Known Bugs" in the existential
types section.
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/reordered_existential_constraint.exp:
tests/hard_coded/typeclasses/reordered_existential_constraint.m:
A test case for this. (Not the same as petdr's original test case,
but much simpler and exhibits the same bug).
|
||
|
|
7fc6ce8792 |
Fix a bug which caused some programs using typeclasses to
Estimated hours taken: 6
Fix a bug which caused some programs using typeclasses to
crash with a segmentation fault.
compiler/polymorphism.m:
For typeclass method implementations, make sure the
order of the type-info and typeclass-info arguments
matches the order used by do_call_class_method.
The type-infos for the unconstrained type variables in
the instance declaration and the typeclass-infos for the
constraints on the instance declaration must come
before any other type-infos and typeclass-infos.
compiler/hlds_pred.m:
Add a field to the pred_info type to record for each
typeclass method implementation which class constraints
come from the `:- instance' declaration and which come
from the predicate or function declaration in the
`:- typeclass' declaration.
compiler/check_typeclass.m:
Fill in the new field in the pred_info.
compiler/typecheck.m:
Apply the necessary renamings to the types and
class constraints in the new field in the pred_info.
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/typeclass_order_bug.{m,exp}
tests/hard_coded/typeclasses/typeclass_order_bug2.{m,exp}
tests/hard_coded/typeclasses/typeclass_order_bug3.{m,exp}
Test cases.
|
||
|
|
477ecb18f6 |
Implement pragma foreign_code for Managed C++.
Estimated hours taken: 60 Implement pragma foreign_code for Managed C++. Currently you can only write MC++ code if your backend is capable of generating use MC++ as its "native" foreign language. The IL backend is the only backend that does this at the moment (the other backends have C as their "native" foreign language). Most of the machinery is in place to call from C to (normal) C++ but there is little work done on actually spitting out the C++ code into a separate file. The IL backend does this step already with managed C++. The intention is to turn foreign_code for C++ into a pragma import (which imports the C++ function from a separate file) and foreign_code for C (which calls the imported function). The C++ code will be inserted into a separate file that is compiled using C linkage. The important improvement this change gives is that you can write a module with a C and a MC++ implementations side-by-side. The target backend will select the most appropriate foreign language to use. You can override its choice using --use-foreign-language. Later on we will probably want more flexibility than just a single language selection option). This change also implements :- pragma foreign_decl, which allows header file style declarations to be written in languages other than C. compiler/code_gen.m: Reject code that is not C when generating LLDS. compiler/export.m: Start renaming C as foreign. Reject code that is not C when generating exports. compiler/foreign.m: A new module to handle foreign language interfacing. The bulk of the code for pragma import has been moved here from make_hlds. compiler/globals.m: Convert foreign language names to foreign_language. This code has been moved closer to the similar conversion we do for target language names. Add globals__io_lookup_foreign_language_option to make it easier to deterministically lookup the options relating to foreign languages. compiler/hlds_module.m: Move module_add_foreign_decl and module_add_foreign_body_code from make_hlds.m (where they were called module_add_c_header and module_add_c_code). compiler/hlds_out.m: Write the foreign language out in HLDS dumps. compiler/llds.m: Change foreign_header_info to foreign_decl_info. Change definitions of foreign_decl_code and foreign_body_code to include the language. compiler/llds_out.m: Reject code that is not C when writing out LLDS. compiler/make_hlds.m: Add foreign language information to the bodys and decls when creating them. Update error messages to refer to foreign code instead of C code. Use foreign.m to generate interfaces from the backend language to the foreign language. Hardcode C as the language for fact tables. compiler/mercury_compile.m: Collect the appropriate foreign language code together for output to the backend. compiler/intermod.m: compiler/mercury_to_mercury.m: Output the foreign language string. Change a few names to foreign_code instead of c_code. compiler/ml_code_gen.m: Filter the foreign language bodys and decls so that we only get the ones we are in (given by the use-foreign-language option). compiler/mlds_to_c.m: Abort if we are given non C foreign language code to output (we might handle it here in future, or we might handle it elsewhere). compiler/mlds_to_ilasm.m: Abort if we are given non MC++ foreign language code to output (we might handle it here in future, or we might handle it elsewhere). compiler/options.m: compiler/handle_options.m: Add --use-foreign-language as a user option to control the preferred foreign language to use as the implementation of this module. Add backend_foreign_language as an internal option which stores the foreign language that the compiler will use as a default (e.g. the natural foreign language for the backend to use). Set the preferred backend foreign language depending on the target. compiler/prog_data.m: Add managedcplusplus as a new alternative for the foreign_language type. Make c_header_code into foreign_decl. Give the foreign language for foreign_code as an attribute of the code. Write code to turn attributes into a list of strings (suitable for writing out by mercury_to_mercury). This fixes what appears to be a bug in tabled_for_io -- the tabled_for_io attribute was not being written out. Structure the code so this bug is difficult to repeat in future. compiler/prog_io_pragma.m: Parse foreign_decl. Turn c_header_code into a special case of foreign_decl. compiler/*.m: Remove the language field from pragma_foreign_code, it is now an attribute of the code. Various type and variable renamings. tests/invalid/pragma_c_code_and_clauses1.err_exp: tests/invalid/pragma_c_code_dup_var.err_exp: tests/warnings/singleton_test.exp: Update the tests to reflect the new error messages talking about :- pragma foreign_code rather than :- pragma c_code. |
||
|
|
e29f9a3d2f |
Fix a bug whereby polymorphism was not using the complete set of class
Estimated hours taken: 5
Fix a bug whereby polymorphism was not using the complete set of class
constraint proofs when generating a type class info, resulting in a map
lookup failure under certain conditions.
compiler/polymorphism.m:
When generating a type class info, don't just pass the proofs for
the instance declaration that we calculated in check_typeclass.m.
These proofs just specify how to build the type class infos for any
superclass constraints *given the constraints on the instance
declaration*. Instead, we pass the union of those constraints and
those local to the predicate. This provides proofs for the constraints
on the instance declaration too.
compiler/typecheck.m:
Rather than using the headvars as the set of variables that must not
be bound when searching the superclass relation, use all the variables
in the varset. This remove a parameter from the exported constraint
reduction predicate.
compiler/check_typeclass.m:
Remove the redundant parameter.
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/superclass_bug2.exp:
tests/hard_coded/typeclasses/superclass_bug2.m:
A test case for this.
|
||
|
|
e6769ef622 |
Record the module that each instance declaration came from.
Estimated hours taken: 8 Record the module that each instance declaration came from. This is needed for the IL back-end, which includes that module name in the symbol name that it generates for each instance declaration. compiler/prog_data.m: Add a module_name field to the `instance' item. compiler/prog_io_typeclass.m: When parsing `instance' declarations, store the module name that they came from in the module_name field of the `instance' item. compiler/hlds_data.m: Add a module_name field to the `hlds_instance_defn' structure. compiler/make_hlds.m: Copy the module_name field from the `instance' item to the `hlds_instance_defn' structure. compiler/polymorphism.m: Fix an old XXX: when constructing `base_typeclass_info_const's, use the module name from the `hlds_instance_defn', rather than hard-coding the invalid value "some bogus module name". compiler/rtti.m: Add a module_name field to the `base_typeclass_info' rtti_name and rtti_data. compiler/base_typeclass_info.m: Copy the module_name field in the `hlds_instance_defn' to the module_name field in the `base_typeclass_info' rtti_data and rtti_name. compiler/rtti_to_mlds.m: When constructing mlds `data_addr's, use the module_name from the `base_typeclass_info' rtti_name, rather than assuming that such references always refer to instance declarations in the current module. (That assumption would be a safe one currently, but doing it this way is probably a bit more robust against future changes.) compiler/*.m: Trivial changes to reflect the above data structure changes. |
||
|
|
82378c381b |
Allow polymorphic ground insts. This change assumes that all inst
Estimated hours taken: 80 Allow polymorphic ground insts. This change assumes that all inst parameters in the mode declaration for a predicate or function are constrained to be ground-shared. This is a temporary measure until we work out a nice syntax to allow the programmer to tell the compiler that certain inst parameters may be treated as ground insts. Since we don't currently support unconstrained inst parameters anyway, this shouldn't cause a problem. TODO: - Add syntax, something like `:- mode p(in(I)) <= ground(I).', to specify that an inst parameter represents a ground inst. - Allow abstract ground insts that are treated in a similar way to what we've done here with ground inst parameters. - Make mode checking more efficient (i.e. rewrite the mode system). compiler/inst.m: Add a new alternative for ground insts: `constrained_inst_var(inst_var)'. Define the type `inst_var_sub'. compiler/inst_match.m: Change inst_matches_initial so that it: - handles constrained_inst_vars correctly; - returns the inst_var substitutions necessary for the call; - handles inst_matches_initial(ground(...), bound(...), ...) properly (this requires knowing the type of the variable). The last change has also been made for inst_matches_final and inst_matches_binding. However, the check is disabled for now because, without alias tracking, the mode checker becomes too conservative. compiler/hlds_pred.m: compiler/mode_info.m: compiler/simplify.m: compiler/det_util.m: Include the inst_varset in the proc_info, mode_info and simplify_info. Add a vartypes field to the det_info. Remove the vartypes field from the simplify_info since it is now in the det_info. Use record syntax for these data structures and their access predicates to make future changes easier. compiler/prog_io.m: When processing pred and func mode declarations, convert all inst_var(V) insts to ground(shared, constrained_inst_var(V)). compiler/prog_data.m: compiler/hlds_data.m: compiler/make_hlds.m: compiler/mode_util.m: Use inst_vars instead of inst_params. compiler/modes.m: compiler/modecheck_call.m: compiler/unique_modes.m: compiler/mode_util.m: When checking or recomputing initial insts of a call, build up an inst_var substitution (using the modified inst_matches_initial) and apply this to the final insts of the called procedure before checking/recomputing them. compiler/mode_util.m: Make sure that recompute_instmap_delta recomputes the instmap_deltas for lambda_goals even when RecomputeAtomic = no. compiler/type_util.m: Add a new predicate, type_util__cons_id_arg_types which nondeterministically returns the cons_ids and argument types for a given type. Add a new predicate type_util__get_consid_non_existential_arg_types which is the same as type_util__get_existential_arg_types except that it fails rather than aborting for existenially typed arguments. compiler/accumulator.m: compiler/check_typeclass.m: compiler/clause_to_proc.m: compiler/common.m: compiler/continuation_info.m: compiler/deforest.m: compiler/det_analysis.m: compiler/det_report.m: compiler/det_util.m: compiler/dnf.m: compiler/follow_code.m: compiler/goal_store.m: compiler/goal_util.m: compiler/higher_order.m: compiler/inst_util.m: compiler/instmap.m: compiler/lambda.m: compiler/magic.m: compiler/magic_util.m: compiler/mercury_to_mercury.m: compiler/modecheck_unify.m: compiler/module_qual.m: compiler/pd_info.m: compiler/pd_util.m: compiler/polymorphism.m: compiler/post_typecheck.m: compiler/prog_io_util.m: compiler/prog_rep.m: compiler/saved_vars.m: compiler/stack_layout.m: compiler/table_gen.m: compiler/unify_proc.m: compiler/unneeded_code.m: compiler/unused_args.m: Pass inst_varsets and types where needed. Changes to reflect change in definition of the inst data type. compiler/inlining.m: Recompute the instmap deltas for a procedure after inlining. This bug showed up compiling tests/hard_coded/lp.m with inlining and deforestation turned on: deforestation was getting incorrect instmap deltas from inlining, causing the transformation to break mode-correctness. It has only just shown up because of the added call to `inst_matches_initial' from within `recompute_instmap_delta'. tests/invalid/Mmakefile: tests/invalid/unbound_inst_var.m: tests/invalid/unbound_inst_var.err_exp: tests/valid/Mmakefile: tests/valid/unbound_inst_var.m: Move the `unbound_inst_var' test case from `invalid' to `valid' and extend its coverage a bit. |
||
|
|
3cf329a739 |
Fix bugs in explicit type qualification.
Estimated hours taken: 4
Fix bugs in explicit type qualification.
compiler/make_hlds.m:
Make the code to handle type qualification expressions match
the documentation. Variables occurring in type qualifications
but not in the predicate's argument types are local to the
clause in which they occur.
Don't export clauses_info_init -- it's not used anywhere else.
Add field labels to the qual_info type.
compiler/hlds_pred.m:
compiler/*.m:
Add a field to the clauses_info to contain the mapping from
type variable names to type variables for the head types.
This needs to be maintained because type variables added
while processing type qualifications in a clause should
not be added to the map used for other clauses.
compiler/typecheck.m:
Apply substitutions to the explicit vartypes at the end
of each pass of typechecking to keep them in sync with
the type variables in the argument types.
compiler/type_util.m:
Add a predicate type_util__apply_variable_renaming_to_type_map
for use by typecheck.m.
doc/reference_manual.texi:
Add some more comments about the handling of explicit type
qualifications to the documentation about valid type assignments.
Change references to existential type _qualifiers_ to consistently
refer to existential type _quantifiers_.
tests/hard_coded/type_qual.{m,exp}:
Add some more tests.
tests/hard_coded/Mmakefile:
Pass `--infer-all' to mmc when compiling type_qual.m.
|
||
|
|
46a8da81cb |
Implement builtin tuple types, similar to those in Haskell.
Estimated hours taken: 30
Implement builtin tuple types, similar to those in Haskell.
Tuples are constructed and deconstructed using
the syntax X = {Arg1, Arg2, ...}.
Tuples have type `{Arg1, Arg2, ...}'.
Unary tuples (X = {Arg}) do work, unlike in Haskell. The rationale
for this is that it is useful to be able to construct unary tuples
to be passed to a polymorphic predicate which uses std_util__deconstruct
to deal with a tuple of any arity. Since this is probably the only
use for unary tuples, it's not really worth the effort of treating
them as no_tag types, so we don't.
The type-infos for tuples have the same structure as for higher-order
types. There is a single type_ctor_info for tuples, and the arity
is placed before the argument type_infos.
library/parser.m:
Change the way '{}/N' terms are parsed, so that the parsed
representation is consistent with the way other functors
are represented (previously the arguments were left as
unparsed ','/2 terms). This avoids special case code
in prog_io__parse_qualified_term, term__term_to_type
and term__type_to_term.
compiler/prog_io_dcg.m:
compiler/prog_io_util.m:
Handle the new structure of '{}/N' terms when parsing DCG escapes
by converting the argument list back into a single ','/2 term.
compiler/module_qual.m:
Treat tuples as a builtin type.
compiler/typecheck.m:
Typecheck tuple constructors.
compiler/mode_util.m:
Propagate types into tuple bound insts.
compiler/type_util.m:
Add type_is_tuple/2 and type_id_is_tuple/1 to identify tuple types.
Add tuples to the list of types which are not atomic types.
Handle tuple types in `type_constructors' and
`get_cons_id_arg_types' and `switch_type_num_functors'.
compiler/tabling.m:
Handle tabling of tuples.
compiler/term_util.m:
Handle tuples in the code to compute functor norms.
compiler/magic_util.m:
compiler/rl.m:
compiler/rl_key.m:
Handle tuple types in the Aditi back end.
compiler/mercury_to_mercury.m:
library/io.m:
library/term_io.m:
Handle output of '{}/N' terms.
compiler/higher_order.m:
compiler/simplify.m:
Don't specialize complicated unifications of tuple
types into calls to a specific unification procedure --
even if the procedure were implemented, it probably
wouldn't be that much more efficient.
compiler/unify_proc.m:
Generate unification procedures for complicated unifications
of tuples (other than in-in unifications). These are generated
lazily as required.
compiler/make_hlds.m:
Export add_special_pred for use by unify_proc.m.
compiler/polymorphism.m:
Export polymorphism__process_pred for use by unify_proc.m.
compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/ml_code_util.m:
Handle unify procedure names and tags for tuple types.
compiler/mlds_to_c.m:
Output tuple types as MR_Tuple.
compiler/ml_unify_gen.m:
Compute the field types for tuples.
compiler/polymorphism.m:
compiler/pseudo_type_info.m:
Treat tuple type_infos in a similar way to higher-order type_infos.
compiler/hlds_data.m:
Document how cons_ids for tuple types are represented.
compiler/switch_gen.m:
compiler/table_gen.m:
Add tuple types to switches on type_util__builtin_type.
compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
Transform items named "{}" to "f_tuple" when mangling symbols.
library/builtin.m:
Define the type_ctor_info used for tuples.
library/private_builtin.m:
Add `builtin_unify_tuple/2' and `builtin_compare_tuple/3',
both of which abort. All comparisons and in-in unifications
of tuples are performed by the generic unification functions
in runtime/mercury_ho_call.c and runtime/mercury.c.
library/std_util.m:
Implement the various RTTI functions for tuples.
Encode tuple `TypeCtorDesc's in a similar way to that
used for higher-order types. This has the consequence that the limit
on the arity of higher-order types is now MAX_VIRTUAL_REG,
rather than 2*MAX_VIRTUAL_REG.
Avoid calling MR_GC_free for the type-info vector returned
from ML_expand() for tuples because unlike the vectors
for du types, it is not copied.
runtime/mercury_type_info.h:
Add macros for extracting fields from tuple type-infos.
These just call the macros for extracting fields from higher-order
type-infos.
Add a macro MR_type_ctor_rep_is_variable_arity(), which
returns TRUE for tuples and higher-order types.
The distinction between higher-order and first-order types
is now misnamed -- the distinction is really between fixed arity
types and builtin variable arity types. I'm not sure whether
it's worth renaming everything.
runtime/mercury.h:
runtime/mercury.c:
Define unification and comparison of tuples in
high-level code grades.
runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
Handle tuple types in code which traverses data using RTTI.
tests/hard_coded/construct.{m,exp}:
tests/hard_coded/expand.{m,exp}:
Test RTTI functions from std_util.m applied to tuples.
tests/hard_coded/tuple_test.{m,exp}:
Test unification, comparison, term_to_type etc. applied to tuples.
tests/hard_coded/deep_copy.{m,exp}:
Test deep copy of tuples.
tests/hard_coded/typeclasses/tuple_instance.{m,exp}:
Test instance declarations for tuples.
tests/tabling/expand_tuple.{m,exp}:
Test tabling of tuples.
tests/hard_coded/write.m:
Add some module qualifications for code which uses
`{}/1' constructors which are not tuples.
tests/invalid/errors2.{m,err_exp,err_exp2}:
Test handling of tuples in type errors messages.
NEWS:
doc/reference_manual.texi:
w3/news/newsdb.inc:
Document tuples.
doc/transition_guide.texi:
Document the change to the parsing of '{}/N' terms.
|
||
|
|
2490aac4dd |
Generate declarations and clauses for the compiler-generated
Estimated hours taken: 10 Generate declarations and clauses for the compiler-generated unification and comparison procedures only when they are needed. The vast majority of these procedures are never used. This change speeds up `mmc -C make_hlds' by about 5%. compiler/make_hlds.m: Export add_special_pred_for_real and add_special_pred_decl_for_real for use by unify_proc.m. Don't generate declarations or clauses for unification or comparison predicates for imported types immediately unless the predicate needs to be typechecked. Don't generate clauses for comparison predicates for imported types -- they will never be used because the predicate has import_status `imported'. compiler/special_pred.m: compiler/typecheck.m: Add predicate special_pred_for_type_needs_typecheck, which succeeds for types with user-defined equality and types with existentially typed constructors. compiler/unify_proc.m: Make sure the declarations and clauses for the unification predicate for a type have been generated before processing a unify_request for that type. Add predicates for use by higher_order.m to force generation of a special predicate when required for specialization of a call to unify/2 or compare/3. Simplify the code for unification predicates for enumeration types. The code that was being generated cast the arguments to int, then called unify/2 on the ints. The simpler version just creates a unify goal. Enumerations are atomic types, so modecheck_unify.m will treat the unification as a simple_test. compiler/polymorphism.m: Add a predicate polymorphism__process_generated_pred to be used by unify_proc.m to process the bodies of the generated unification predicates. compiler/post_typecheck.m: Add versions of post_typecheck__finish_pred and post_typecheck__finish_imported_pred which don't require an io__state, for use by unify_proc.m. Errors should never be reported in post_typecheck.m for unification or comparison predicates. compiler/simplify.m: Don't generate calls to the type-specific predicate for an in-in complicated unification if the predicate is generated lazily. higher_order.m will handle the specialization in that case. compiler/higher_order.m: Call unify_proc.m to generate the declarations for a special pred when there is a call to that special pred which could be specialized. Add field labels to the higher_order_info type. compiler/type_util.m: Add predicates type_id_is_atomic and classify_type_id, which are similar to type_is_atomic and classify_type, for use by special_pred.m. |
||
|
|
10a433374b |
Restore the clipping of instmap deltas to the nonlocals set, undoing most of
Estimated hours taken: 16 Restore the clipping of instmap deltas to the nonlocals set, undoing most of a recent change of mine. (The general cleanup parts of that change, e.g. added field names, stay.) The reason is that the previous diff changed the clipping algorithm only where the instmap deltas were being originally computed, whereas for completeness you also need to do this in places where they are recomputed after optimizations such as deforestation, and doing so would have required changes in several more parts of the compiler, which would have been tedious to maintain. Instead, I now use a different technique to solve the original problem. This technique is to change liveness.m so that it considers the first occurrence of any type(class)info variable to be a value giving occurrence even if the variable is not referred to by the instmap delta of the goal. This assumption is true in the current polymorphism design and in any extension of it that I can foresee. Type(class)info variables will therefore be born in the first goal that refers to them, even if they are not in the nonlocal set of that goal. If there are any later references to variables whose type is described in whole or in part by that typeinfo, the typeinfo will die at the last such reference, otherwise it will die in the goal in which it is born. From now on, the only module of the compile which needs to worry about the extension of the life of type(class)info variables beyond the goals referring to them is liveness.m. compiler/quantification.m: compiler/mode_info.m: compiler/mode_util.m: Reset the interfaces of quantification and mode checking to the old ones, which do not require knowing typeinfo_liveness and typeinfo varmaps. compiler/modes.m: compiler/unique_modes.m: Clip instmap deltas to the nonlocals, not the completed nonlocals. compiler/hlds_goal.m: Add a utility pred which gets the nonlocals from a goal, not a goal_info. compiler/liveness.m: Add special handling for type(class)info vars as described above. compiler/accumulator.m: compiler/cse_detection.m: compiler/deforest.m: compiler/follow_code.m: compiler/higher_order.m: compiler/lambda.m: compiler/magic.m: compiler/make_hlds.m: compiler/pd_util.m: compiler/polymorphism.m: compiler/saved_vars.m: compiler/simplify.m: compiler/unify_proc.m: compiler/unify_proc.m: compiler/unneeded_code.m: compiler/unused_args.m: Use the reset interfaces of quantification and mode checking, and eliminate redundant local copies of goal_get_nonlocals. |
||
|
|
ec4a898e2b |
This change fixes a bug reported by Tom Conway yesterday.
Estimated hours taken: 2
This change fixes a bug reported by Tom Conway yesterday. The problem was
that when a construction using a constructor with existentially quantified
args appeared in more than one disjunct, the necessary typeclass infos were
only created on one branch.
compiler/polymorphism.m:
Only update the locations of typeclass info variables when doing
a deconstruction of a functor with existentially typed arguments.
(ie. don't do it for constructions). This is analagous to our handling
of universally/existentially quantified arguments to predicate calls.
tests/hard_coded/typeclasses/exist_disjunction.{m,exp}:
A test case for this change.
tests/hard_coded/typeclasses/Mmakefile:
Turn this test case on.
|
||
|
|
695425d66b |
Fix type specialization of calls to class methods for which
Estimated hours taken: 4 Fix type specialization of calls to class methods for which the instance declaration has unconstrained type variables. Fix bugs in the specialization of existentially quantified procedures. compiler/higher_order.m: Extract the type_infos for the unconstrained type variables from the typeclass_info and pass them to the call. Only pass the universally quantified type parameters, not the head_type_params, when working out type substitutions for specialized versions of predicates, since the existentially quantified type variables can be bound by the substitution. compiler/polymorphism.m: Make sure that the types of the type_infos for existentially quantified types match the types of the variables they describe. We were getting this right for the types returned by pred_info_arg_types, but the types in the vartypes fields of the clauses_infos and proc_infos weren't bound enough. As a result, polymorphism was producing unifications such as `TypeInfo_for_T : type_info(T) = TypeInfo_for_string : type_info(string)'. This is likely to cause problems for optimization passes. tests/hard_coded/typeclasses/Mmakefile: Remove `--no-user-guided-type-specialization' flags which were used to work around these bugs. tests/hard_coded/typeclasses/instance_unconstrained_tvar_type_spec.m: tests/hard_coded/typeclasses/instance_unconstrained_tvar_type_spec.exp: Test case. |
||
|
|
e6f09bff49 |
Fix a bug in the handling of typeclass methods with unconstrained
Estimated hours taken: 0.5 Fix a bug in the handling of typeclass methods with unconstrained existentially typed arguments. The modes of the extra arguments introduced by polymorphism.m were added in the wrong order, resulting in a mode error. compiler/polymorphism.m: Add the modes for type_infos before the modes of typeclass_infos, not the other way around. tests/hard_coded/Mmakefile: tests/hard_coded/typeclass_exist_method_2.m: Test case. |
||
|
|
c192d50143 |
Add preliminary support for a new pragma:
Estimated hours taken: 15 Add preliminary support for a new pragma: :- pragma foreign_code(LanguageString, .... <same args as c_code>). This is intended to be the eventual replacement of pragma c_code. Presently the only valid language is "C". The existing pragma c_code is simply turned into pragma foreign_code. pragma foreign_code is not a supported pragma at the moment. There are several other changes that are intended (for example, foreign_code will be impure by default). This change also changes the HLDS goal pragma_c_code/7 to pragma_foreign_code/8 where the extra argument is the foreign language. Any code currently generating output for pragma C code simply checks that the foreign language is set to "c". Since this is the only alternative of the type foreign_language, it will always succeed. However when new alternatives are added it should be fairly easy to find where the changes need to be made. Some type names and predicate names have also been updated, however there are many more that haven't yet been touched. compiler/prog_io_pragma.m: Accept the new syntax. Turn the old syntax into the new item. compiler/hlds_goal.m: Change pragma_c_code/7 to pragma_foreign_code/8. Define the foreign_language type. compiler/llds.m: Change user_c_code/2 to user_foreign_code/3. compiler/*.m: Update the rest of the compiler to handle these types. Make a few small changes to update variable names, predicate names and type names. |
||
|
|
891b89e650 |
Make sure that all parts of the compiler use a consistent idea of which
Estimated hours taken: 4 Make sure that all parts of the compiler use a consistent idea of which predicates should have typeinfo liveness applied to their bodies when the relevant option is set. This set is all predicates except the few in the builtin modules which do not have the required arguments. compiler/hlds_pred.m: Expand the interface of the should_use_typeinfo_liveness family of predicates to include an id of the predicate in question, to enable them to test whether the pred is a no_type_info_builtin. compiler/hlds_pred.m: compiler/polymorphism.m: Move the list of no_type_info_builtins from polymorphism to hlds_pred, since body_should_use_typeinfo_liveness also needs it now. compiler/*.m: Minor changes to pass the right arguments to predicates of the should_use_typeinfo_liveness family, directly or indirectly. |
||
|
|
a0a6daa06f |
If we are using typeinfo liveness, then clip the instmap delta fields in
Estimated hours taken: 16 If we are using typeinfo liveness, then clip the instmap delta fields in goal_infos not to the nonlocals, but to the nonlocals plus the type info or typeclass info variables needed to describe the types of the nonlocals (this set is now called the "typeinfo completed nonlocals"). This is necessary for the proper handling of code such as resume_typeinfos.m in tests/debugger. This involves a call to a procedure with an existentially typed argument, where the returned argument is processed only in ways that do not need the typeinfo describing it. The compiler therefore considered the typeinfo to be local to the call binding it. Its binding was therefore not recorded in the instmap delta, which in turn meant that in the absence of a value-giving occurrence, liveness.m considered it not to be born anywhere. On the other hand, with typeinfo liveness, occurrences of the argument are also considered value-using occurrences of the typeinfo, so the typeinfo was considered to die at the last such occurrence. Therefore the typeinfo died without being born. The current code generator is sloppy enough not to mind this, but the upcoming eager code generator isn't. compiler/hlds_goal.m: Document the new semantics of instmap_deltas. compiler/quantification.m: compiler/mode_util.m: compiler/modes.m: compiler/unique_modes.m: If typeinfo liveness is set, include the relevant typeinfo variables in the set of variables the instmap is limited to. compiler/modes.m: Delete some unused predicates. compiler/hlds_pred.m: Centralize the code for (maybe) completing a set of vars with the set of typeinfo vars describing their types here. compiler/call_gen.m: compiler/live_vars.m: Use the central code in hlds_pred.m. compiler/accumulator.m: compiler/cse_detection.m: compiler/follow_code.m: compiler/higher_order.m: compiler/lambda.m: compiler/liveness.m: compiler/magic.m: compiler/make_hlds.m: compiler/mode_info.m: compiler/pd_util.m: compiler/polymorphism.m: compiler/simplify.m: compiler/unify_proc.m: compiler/unneeded_code.m: compiler/unused_args.m: Call quantification and/or mode_util with the right arguments. In some cases, introduce field names, predmode declarations and/or shorter type names to make this change easier. |
||
|
|
a48beedc9d |
Fix a bug where pragma imports of polymorphic predicates where not
Estimated hours taken: 16
Fix a bug where pragma imports of polymorphic predicates where not
having typeinfos prepended to the call.
compiler/prog_data.m:
Add a the new functor import/4 to pragma_c_code impl.
The functor stores all the information needed to constuct a C code
fragment a pragma import.
compiler/make_hlds.m:
Rather then constructing the C code fragment immediately, construct
the sub-parts and store them in import/4.
compiler/polymorphism.m:
Prepend the typeinfos to the list of variables passed to the
imported C function.
compiler/ml_code_gen.m:
compiler/pragma_c_gen.m:
Construct the C code fragment then call the routine which handles
`ordinary' pragma c_code.
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
Add code to recognise the import/4 functor.
|
||
|
|
a5b691091c |
Simplify the code of maybe_init_second_cell by not testing conditions
Estimated hours taken: 1 compiler/polymorphism.m: Simplify the code of maybe_init_second_cell by not testing conditions twice. |
||
|
|
018c2aeb94 |
Replace a series of list__appends with a list__condense.
Estimated hours taken: 0.1
compiler/polymorphism.m:
Replace a series of list__appends with a list__condense.
|
||
|
|
082b084ac7 |
Implement static allocation of grounds terms for the
Estimated hours taken: 20 Implement static allocation of grounds terms for the MLDS back-end. compiler/hlds_goal.m: Change the `maybe(cell_to_reuse)' field of `construct' unifications from a `maybe(cell_to_reuse)' into a `how_to_construct' type with three alternatives, `reuse_cell(cell_to_reuse)', `construct_dynamically', and the new alternative `construct_statically(static_cons)'. `static_cons' is a new type that provides information on how to construct a static ground term. compiler/goal_util.m: compiler/lambda.m: compiler/magic.m: compiler/magic_util.m: compiler/modecheck_unify.m: compiler/polymorphism.m: compiler/quantification.m: Trivial changes to handle the change to the `maybe(cell_to_reuse)' field of `construct' unifications. compiler/mark_static_terms.m: New module. This traverses the HLDS and marks terms which can be construction unifications which can be allocated statically with the `construct_statically' flag. compiler/mercury_compile.m: For the MLDS back-end, if the static_ground_terms option is set, invoke the mark_static_terms pass. compiler/ml_unify_gen.m: When generating code for construction unifications, pass down the `how_to_reuse' field. If this is `construct_statically', then generate a local initialized static constant, rather than using `new_object' to allocate the memory dynamically. (This required some fairly substantial reorganization. I changed ml_gen_construct so that no_tag types and compound terms, including closures, are handled separately from constants. I moved some of the code from ml_gen_construct_rep into ml_gen_construct, and the remainder, which deals with constants, was simplified and renamed ml_get_constant. The code for constructing closures was moved into a separate predicate ml_gen_closure, and was simplified by elimination of some code duplication. I also added a bunch of new procedures for generating static constants.) compiler/mlds.m: Add a new alternative `mlds__array_type' to the mlds__type type. This is needed by ml_unify_gen.m for static constants. compiler/mlds_to_c.m: Handle `mlds__array_type'. This required splitting mlds_output_type into mlds_output_type_prefix and mlds_output_type_suffix. compiler/ml_code_util.m: Reorder the code slightly, to improve readability. |
||
|
|
54678e871a |
Fix a bug that broke tests/hard_coded/existential_type_classes in MLDS
Estimated hours taken: 1 Fix a bug that broke tests/hard_coded/existential_type_classes in MLDS grades. The bug was that the typeclass_info type generated for pragma c_code instructions was wrong: it was missing the `constraint' parameter. This caused the MLDS code generator (specifically ml_gen_box_or_unbox_rval) to insert an unnecessary cast, which in turn mean that the generated rval was one that ml_gen_c_code_for_rval didn't know how to handle. compiler/polymorphism.m: Change the code that generates types for typeclass_info variables in `pragma c_code' instructions so that it does so using `polymorphism__generate_typeclass_info_type', rather than hand-coding it, since the hand-coded version was wrong. Similarly, change a few places to use `polymorphism__build_type_info_type' to construct types for type_infos, rather than hand-coding it (in this case the hand-coding was OK, but the new code is more maintainable). |
||
|
|
7622eb1d36 |
Finish the implementation of Aditi updates.
Estimated hours taken: 120 Finish the implementation of Aditi updates. compiler/hlds_goal.m: Refactor the aditi_builtin type so that operations with similar syntax and implementations are grouped together. Add operations to delete a single tuple (`aditi_delete') and to modify tuples (`aditi_bulk_modify'). compiler/*.m: Minor changes required by refactoring the aditi_builtin type. compiler/make_hlds.m: Parse `aditi_delete' and `aditi_bulk_modify' goals. Parse a nicer syntax for `aditi_bulk_delete' and `aditi_bulk_insert' goals (e.g. aditi_bulk_delete(p(_, X, _) :- X > 2)). compiler/rl_out.pp: For each base relation, generate RL procedures to apply deletions and modifications to the relation. `aditi_bulk_modify' takes a closure which produces tuples which contain both the attributes of the tuple to delete and the tuple to insert. The modification RL procedure performs two projections on the closure result to produce the tuples to delete and the tuples to delete. The input stream to the rl_PROC_delete RL instruction must contain only tuples taken from the relation to delete from -- the deletion is done using the tuple-id rather than the tuple contents. The generated deletion procedure performs a semi-join of the relation to delete from with the relation containing the tuples to delete. compiler/rl.m: Add predicates to generate the names of the modification and deletion RL procedures generated for each base relation. compiler/rl_exprn.m: Generate the projection expressions required by the modification RL procedures generated for each base relation. Generate the equi-join expressions required by the modification and deletion RL procedures generated for each base relation. compiler/unify_gen.m: Implement code generation for `aditi_bottom_up' closures. compiler/rl.m: compiler/magic.m: Factor out the code used to create the name of the RL procedure used to interface top-down Mercury to Aditi, for use by unify_gen.m to generate `aditi_bottom_up' closures. compiler/code_util.m: Add predicate code_util__make_user_proc_label, which constructs a label name from the given all the individual pieces of information used to construct it, rather than just a pred_id and proc_id. This is used to produce the RL procedure name for an `aditi_bottom_up' closure, so that the code doesn't have to work out what the pred_id of the magic sets transformed procedure is. compiler/magic.m: Always create new procedures to interface Mercury to Aditi, to make it easier for unify_gen.m to work out what the name of the interface procedure is -- don't optimize the case of a predicate with no input arguments. Alter the goal generated for the interface procedures so that it doesn't matter whether the interface procedure and the procedure it interfaces to are compiled together by rl_gen.m -- the old code generated for these procedures assumed they were compiled separately, which wasn't always the case. Don't pass a `magic_info' through the code to generate the C interface procedures -- only the module_info field was required. compiler/magic_util.m: compiler/magic.m: compiler/context.m: Don't pass a `magic_info' through magic_util__create_input_test_unifications -- only the module_info and proc_info fields were used. compiler/post_typecheck.m: compiler/magic_util.m: Don't report errors for the second `aditi__state' argument of the closure passed to `aditi_bulk_modify'. compiler/purity.m: Change the mode of the second `aditi__state' argument of the closure passed to `aditi_bulk_modify' to `unused'. compiler/call_gen.m: Generate `aditi_delete' and `aditi_bulk_modify'. Remove the `aditi__state' from the tuple to insert passed to an `aditi_insert' or `aditi_delete' operation -- the relation on disk does not contain the `aditi__state' attribute. extras/aditi/aditi.m: Implement the updates. Allocate all memory on the Mercury heap to avoid memory leaks when a transaction aborts. Uncaught exceptions within a transaction now cause the transaction to abort, and the exception is rethrown to the caller. If using trailing, add trail entries for the output relation and cursor created for a call to an Aditi procedure, so that they will be cleaned up if only one solution of the call is needed or if an exception is thrown. Include line numbers in the debugging messages if an Aditi API function fails. compiler/llds.m: compiler/*.m: Rename the `do_aditi_modify' label to `do_aditi_bulk_modify' -- we may eventually want to implement a modification goal type which doesn't produce all modified tuples before applying the update. doc/reference_manual.texi: Document `aditi_delete' and `aditi_bulk_modify'. Add some extra spacing in the Aditi update section to improve readability. tests/valid/aditi_update.m: tests/invalid/aditi_update_errors.m: tests/invalid/aditi_update_errors.err_exp: tests/invalid/aditi_update_mode_errors.m: tests/invalid/aditi_update_mode_errors.err_exp: Changed to fit in with the new syntax. tests/valid/Mmakefile: Code generation for Aditi updates now works, so enable full compilation of the aditi_update.m test case, rather than just checking for errors. |
||
|
|
281796aa9a |
Make an addition to the type class info structure; add type infos for
Estimated hours taken: 10
Make an addition to the type class info structure; add type infos for
any type variables from the head of the instance declaration which are
unconstrained, and make the class method call mechanism insert these as
arguments to method calls. The implementations of methods expect to be passed
a type info for each unconstrained type variable and a type class info for
each constraint. Previously we were not passing the appropriate type infos.
Also move the documentation about the type class transformation from
polymorphism.m to a new file, compiler/notes/type_class_transformation.html.
compiler/base_typeclass_info.m:
Generate the appropriate part of the new structure in the
base_typeclass_info.
compiler/polymorphism.m:
Add the appropriate type infos to the typeclass_info.
compiler/type_util.m:
Add a new predicate `get_unconstrained_tvars'.
runtime/mercury_deep_copy_body.h:
Update copy_typeclass_info to reflect the new structure.
runtime/mercury_ho_call.c:
Copy the extra type infos to the beginning of the arguments when
doing a class method call.
runtime/mercury_type_info.h:
Update the macros used to access the type class info.
compiler/notes/type_class_transformation.html:
The documentation about the type class transformation has been
moved from polymorphism.m to here. This change corrects that
documentation in several places and updates that documentation to
reflect the changes to the typeclass_info structure from this diff.
tests/hard_coded/typeclasses/instance_unconstrained_tvar.exp:
tests/hard_coded/typeclasses/instance_unconstrained_tvar.m:
A test case for this change.
tests/hard_coded/typeclasses/Mmakefile:
Turn this test case on. For the moment, type specialisation is
turned off for this test case as the specialiser does not insert the
extra type infos that are needed.
|
||
|
|
184e4710b1 |
Get the system to work with --no-special-preds, relying on RTTI interpretation
Estimated hours taken: 30
Get the system to work with --no-special-preds, relying on RTTI interpretation
to perform unifications and comparisons, in almost all cases. The only thing
that doesn't work is comparisons involving types with user-defined equality;
the generated exception does not get propagated across MR_call_engine
boundaries properly.
compiler/make_hlds.m:
With --no-special-spreds, do not generate even declarations for
type-specific index and compare predicates. Generate declarations
and clauses for type-specific unify predicates, since we may need
them for unifications that are not (in,in). However, we prevent
the generation of code for the (in,in) case (i.e. mode 0) by pretending
that the unify predicate is pseudo_imported, even in the module
defining the type. There is one exception to this: for types with
user-defined equality, we do generate a proper __Unify__ predicate,
since this is the only convenient way to convert the specified
sym_name of the equality predicate into a pred_id and proc_id,
and a proper __Compare__ predicate, since this is the only convenient
way to generate the full type name for the error message at runtime
(due to polymorphism, the full type may not be known at compile time).
(Finding the pred_id may require resolving type overloading,
and finding the proc_id may require mode checking.)
compiler/simplify.m:
When converting complicated unifications to calls, call the generic
unify/2 and compare/3 predicates instead of the type-specific
__Unify__ and __Compare__ predicates, if the latter do not exist.
compiler/higher_order.m:
Do not specialize calls to the generic unify/2 and compare/3 predicates
to type-specific __Unify__ and __Compare__ predicates, if the latter
do not exist.
Previously, we were not specializing comparisons of builtins and
enumerations here, leaving it to inlining. In the absence of
--special-preds, that doesn't work for enumerations, since there
is no compiler-generated comparison predicate to do the inlining in.
We therefore now perform both specializations.
compiler/polymorphism.m:
Fix a bug: the code for looking up the special preds for user defined
types was handling enums as builtins, which they are not: they can have
user-defined equality.
compiler/type_ctor_info.m:
Even with --no-special-preds, the type has type-specific __Unify_
and __Compare__ predicates if it has user-defined equality. These
predicates must be, and now are, put into the type_ctor_info.
runtime/mercury_wrapper.[ch]:
Expand the facilities for collecting statistics about unify, index
and compare operations. We used to collect only counts of operations
for each type_ctor_rep; we now also collect counts of operations
for each specific type. Rename MR_CTOR_REP_STATS as MR_TYPE_CTOR_STATS
to reflect this expansion.
runtime/mercury_conf_param.h:
Document MR_TYPE_CTOR_STATS instead of MR_CTOR_REP_STATS.
runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
Fix a bug that showed with --no-special-preds: the Mercury predicate
unify_2_0 cannot call the MR_generic_compare function to handle the
arguments of a function symbol, because comparison is not defined
on types with user-defined equality. Instead, we need to call the new
MR_generic_unify C function, which does work on such types.
Fix a bug that showed with --no-special-preds: the MR_succip register
has to be saved and restored across calls to MR_generic_unify, since
for types with user-defined equality, such calls involve a recursive
invocation of the Mercury engine.
Optimize the unification of du types by performing only one
functor_desc lookup instead of two, and failing as early as possible.
Use the new statistics facilities provided by mercury_wrapper.c.
tools/bootcheck
If the new --type-stats option is given, preserve the type constructor
statistics derived from (a) the stage 3 compilation process, and (b)
compiling the test suite, for later analysis.
tools/type_ctor_stats:
A new shell script to analyze type constructor statistics in their
new, expanded format.
tests/hard_coded/user_defined_equality.{m,exp}:
Test comparisons as well as unifications on enums with user-defined
equality.
|
||
|
|
c2a696d8b6 |
Clean up the runtime system's handling of type_infos and pseudo_type_infos.
Estimated hours taken: 40
Clean up the runtime system's handling of type_infos and pseudo_type_infos.
This cleanup has two major aspects. First, it represents type_infos and
pseudo_type_infos with distinct C types, and reducing the use of casts
to the minimum. These casts are in two kinds of places: in a few macros
defined in runtime/mercury_type_info.h, and at the interfaces between C code
and Mercury code (since Mercury code represents (pseudo-)type_infos, like
everything else, as Words). Part of this aspect is the separation of the
type "MR_TypeInfo" from the type "MR_TypeInfoParams"; a MR_TypeInfo can be
used as a source of type parameters directly only when it is first order.
Second, it removes the confusion between the types named "type_info" and
"type_ctor_info" defined by the modules private_builtin.m and std_util.m,
by renaming the types defined in std_util.m to "type_desc" and
"type_ctor_desc".
To avoid doing this cleanup twice, this diff also removes support for the
old type_ctor_info representation. This in turn makes it feasible to provide
conditionally enabled code to support unification and comparison by RTTI.
runtime/mercury_grade.h:
Increment the binary compatibility version number. This is required
by the dropping of support for old type_ctor_info representations.
runtime/mercury_type_info.h:
Define the types MR_TypeInfo, MR_PseudoTypeInfo and MR_TypeInfoParams,
and macros that operate on them.
Remove the types and macros that were useful only with the old RTTI
representation.
Move the section that deals with initializing code addresses in
type_ctor_info structure for grades without static code addresses
to the logical place.
Add a const qualifier to the MR_sectag_alternatives field in
MR_DuPtagLayout, since this simplifies code manipulating du types.
Convert the whole file to 4 space indentation, since it is a nuisance
if only part of it is so indented.
runtime/mercury_deep_copy.h:
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.h:
runtime/mercury_tabling.c:
Clean up the implementation as described above.
runtime/mercury_type_info.c:
runtime/mercury_make_type_info_body.h:
Clean up the implementation as described above.
Eliminate the code duplication between the function MR_make_type_info
and MR_create_type_info, and their helpers, which do the same thing
except for how they allocate memory, by putting the common code into
the new file mercury_make_type_info_body.h, and including it twice
in two different #define contexts.
Move the (updated) documentation of those functions to
mercury_type_info.h, where it belongs.
runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
Clean up the implementation as described above.
Eliminate the code duplication between the implementation of unify
and compare, which do very similar jobs, by putting the common code
into the new file mercury_unify_compare_body.h, and including it three
times in two different #define contexts. The third time is for defining
the body of a C function which does the same thing as compare. This
is necessary for unification and comparison by RTTI, since the
unification or comparison of two structured terms requires comparing
their subterms. (There is no need for a separate C function for
unification; the C comparison function is sufficient.)
mercury_unify_compare_body.h has conditional support for unification
and comparison by RTTI. Although this has been tested and is known
to work, it is turned off for the moment. This may change after
benchmarking.
runtime/Mmakefile:
Add the new include files to the list.
library/std_util.m:
Rename type_info to type_desc and type_ctor_info to type_info_desc.
Keep the old names as equivalence types, for the time being.
Document the representations.
Move the macros that refer to type_descs and type_ctor_descs here from
runtime/mercury_type_info.h, since this is the only place where they
are used. Rename them to conform to the new names of the types.
Clean up the implementation of the RTTI predicates and functions
as described above. In the process, fix some bugs where type variables
were expanded twice, with the second expansion's code being incorrect.
Also factor out some common code, and unfactor some uncommon code
(where a function had two uses, but its implementation was inefficient
overkill for one of them).
library/builtin.m:
library/private_builtin.m:
library/io.m:
library/store.m:
runtime/mercury_layout_util.[ch]:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_vars.[ch]:
When calling C functions involving type_infos, cast them to the new
types.
runtime/mercury_stack_layout.h:
Fix a bug that was masked by casts in its client code.
compiler/rtti_out.m:
Delete from the output a cast made unnecessary by the new const
qualifier on MR_sectag_alternatives.
browser/browse.m:
browser/help.m:
library/io.m:
library/term.m:
tests/hard_coded/construct.m;
tests/hard_coded/existential_types_test.m:
tests/hard_coded/higher_order_type_manip.{m,exp}:
Refer to the types defined in std_util.m by their new names.
tests/hard_coded/existential_rtti.{m,exp}:
Make the test tougher by printing out not just one deconstructed term,
but deconstructed versions of all the terms created by this test.
|
||
|
|
6434c9a02e |
Include the number of typeclass methods in the base_typeclass_info
Estimated hours taken: 0.25
Include the number of typeclass methods in the base_typeclass_info
structure, making the structure self-describing. This information
is not used at the moment, but may be useful.
compiler/base_typeclass_info.m:
Add the new information.
compiler/polymorphism.m:
Update the documentation.
runtime/mercury_type_info.h:
Update and add macros for the new structure.
|
||
|
|
5940825cdb |
Implement syntax for getting and setting fields of constructors.
Estimated hours taken: 70 Implement syntax for getting and setting fields of constructors. compiler/make_hlds.m: Add information about field definitions to the module_info. Check that user-defined field access functions for exported fields are also exported, otherwise predicates in other modules could use a different method to access a field than predicates in module defining the field. Add a `predicate preds_add_implicit_report_error' to allow that check to be performed for functions which are added to the module_info by some means other than a `:- func' declaration. Parse field access goals and expressions. Add predicates `insert_arg_unifications_with_supplied_contexts', and `append_arg_unification', which allow more control over the contexts given to the added unifications. These are useful because the field value for an update is really an argument of the inner-most update function call, while the input term is an argument of the outer-most function call. compiler/prog_io_dcg.m: Allow DCG goals of the form `:=(DCGArg)', which unifies `DCGArg' with the output DCG argument, ignoring the input DCG argument. The rationale for this change is that if we have convenient syntax for updating parts of a DCG argument, we should also have convenient syntax for updating the whole DCG argument. compiler/typecheck.m: Add a default clause for field access functions for which the user has supplied type and mode declarations but no clauses. Typecheck field access function calls. Use `io__write_list' to remove some duplication of code to write out comma separated lists of error descriptions. compiler/post_typecheck.m: Expand field accessor goals into the equivalent unifications. They are expanded inline rather than generating new get and set predicates for field name to avoid having to work out how to mode the generated predicates. Remove an unnecessary goal traversal to qualify function calls and constructors. That code is now called from purity.m. compiler/prog_data.m: compiler/prog_io.m: compiler/mercury_to_goedel.m: compiler/mercury_to_mercury.m: Store field names as `sym_name's rather than strings. Use a `maybe' type rather than an empty string to designate an unlabelled field. compiler/hlds_data.m: Define data structures to hold information about the field names visible in a module. compiler/hlds_module.m: Add a field to type module_info to hold information about the fields visible in a module. compiler/hlds_pred.m: Add predicates to identify field access function names, and to handle the arguments of field access functions. compiler/make_hlds.m: compiler/hlds_goal.m: compiler/modecheck_call.m: compiler/higher_order.m: compiler/purity.m: compiler/polymorphism.m: compiler/dnf.m: compiler/cse_detection.m: compiler/lambda.m: Move `create_atomic_unification' from make_hlds.m to hlds_goal.m because it is used by several other modules. compiler/hlds_goal.m: Add a version of goal_info_init which takes the context of the goal, for use by make_hlds.m. compiler/type_util.m: Add a predicate `type_util__get_type_and_cons_defn' to get the hlds_type_defn and hlds_cons_defn for a user-defined constructor. compiler/prog_util.m: Add predicates to add and remove prefixes or suffixes from the unqualified part of a sym_name. compiler/prog_out.m: Add a predicate to convert a `sym_name/arity' to a string. compiler/hlds_out.m: Add `hlds_out__simple_call_id_to_string' to convert a `pred_or_func - sym_name/arity' to a string for use in error messages. compiler/purity.m: Thread through the pred_info so that the expansion of field accessor goals can add new variables. compiler/mercury_to_mercury.m: library/ops.m: Reduce precedence of `^/2' for use as a field name separator. Add operator `^'/1 to designate which side of the `:=' is the field name in a DCG field access goal. Add operator `:=/2' for field update expressions. doc/reference_manual.texi: Document the new syntax. doc/transition_guide.texi: Document the new operators. tests/hard_coded/Mmakefile: tests/hard_coded/record_syntax.m: tests/hard_coded/record_syntax.exp: tests/invalid/Mmakefile: tests/invalid/record_syntax_errors.m: tests/invalid/record_syntax_errors.err_exp: Test cases. |
||
|
|
f62d759c2e |
Update the documentation describing the layout of a base_typeclass_info
Estimated hours taken: 0.25
compiler/polymorphism.m:
Update the documentation describing the layout of a base_typeclass_info
to include the new information introduced in my recent changes to
the RTTI.
|
||
|
|
17cd4afa40 |
Fix a bug in my last change - some imports in the interface
Estimated hours taken: 0.1 compiler/polymorphimsm.m: Fix a bug in my last change - some imports in the interface should have been in the implementation. |
||
|
|
38dfae4f7c |
Implement handling of typeclasses for inter-module optimization.
Estimated hours taken: 15 Implement handling of typeclasses for inter-module optimization. compiler/hlds_data.m: compiler/*.m: Add fields to type hlds_class_defn for use by intermod.m - the import_status of the `:- typeclass' declaration. - the original class interface from the `:- typeclass' declaration. compiler/intermod.m: Write all local typeclasses, instances, types, insts and modes to the `.opt' file, instead of trying to work out which are needed. The old code to do this missed some types, insts and modes (test case tests/valid/intermod_test.m). compiler/polymorphism.m: Expand class method bodies for imported predicates so that method lookups for those classes can be optimized. compiler/hlds_pred.m: compiler/check_typeclass.m: compiler/higher_order.m: compiler/hlds_out.m: Add a marker `class_instance_method', used to identify predicates introduced by check_typeclass.m to call the methods for each instance. Don't export `check_typeclass__introduced_pred_name_prefix/0' - higher_order.m now checks for a `class_instance_method' marker instead. compiler/dead_proc_elim.m: Analyse all instance declarations, not just those defined in the current module, so that declarations for imported instance methods are not removed before method lookups have been specialized. tests/valid/Mmakefile: tests/valid/intermod_test.m: tests/valid/intermod_test2.m: Check that nested types and modes are written to the `.opt' file. tests/valid/intermod_typeclass.m: tests/valid/intermod_typeclass2.m: Check that local typeclass and instance declarations are written to the `.opt' file. |
||
|
|
f71e59b6de |
Improve the comment describing when goals need to be requantified.
Estimated hours taken: 0.1 compiler/polymorphism.m: Improve the comment describing when goals need to be requantified. |
||
|
|
d551dd1dc9 |
Handle quantification analysis of bi-implication (`<=>') goals correctly.
Estimated hours taken: 10
Handle quantification analysis of bi-implication (`<=>') goals correctly.
Previously we used to expand bi-implications before doing quantification
analysis, which stuffed up the results of quantification analysis for
those goals. We need to do quantification analysis first, and only
then can we expand bi-implications. In addition, elimination of double
negation needs to come after expansion of bi-implication, so I moved
that from make_hlds.m to purity.m.
compiler/hlds_goal.m:
Add a new alternative to the HLDS goal type for bi-implications.
Also add a new predicate negate_goal, for use by purity.m.
compiler/make_hlds.m:
Don't expand bi-implication here, instead just use the new
bi_implication/2 HLDS goal type.
Don't eliminated double negation here.
compiler/quantification.m:
Handle quantification for bi-implications.
Expand bi-implications.
compiler/purity.m:
Eliminate double negation.
compiler/hlds_out.m:
Add code to print out bi-implication goals.
compiler/*.m:
Trivial changes to handle the new bi_implication/2
alternative in the HLDS goal type.
compiler/notes/compiler_design.html:
Document the above changes.
tests/hard_coded/Mmakefile:
tests/hard_coded/quantifier2.m:
tests/hard_coded/quantifier2.exp:
A regression test for the above change.
|
||
|
|
0e07b6a20d |
Fix a spurious mode error for constructions involving
Estimated hours taken: 0.25 Fix a spurious mode error for constructions involving existentially typed constructors. compiler/polymorphism.m: Add the type-info variables added for the existential type variables of a constructor to the non-locals of the construction. tests/valid/Mmakefile: tests/valid/existential_cons.m: Test case. |
||
|
|
34d52a4091 |
Fix a bug with switches on existential types.
Estimated hours taken: 12 Fix a bug with switches on existential types. This bug meant that existential types with two or more functors did not work at all, due to internal compiler errors when compiling the unification and comparison predicates for those types. compiler/type_util.m: Add new function cons_id_adjusted_arity, which computes the arity _including_ the extra typeinfo and typeclassinfo arguments inserted for existential data types. compiler/type_util.m: compiler/polymorphism.m: Move the predicates constraint_list_get_tvars and constraint_get_tvars from polymorphism.m into type_util.m, for use in cons_id_adjusted_arity. compiler/modes.m: compiler/unique_modes.m: When modechecking the functor test in switch statements, use cons_id_adjusted_arity to compute the arity of the inst, compiler/instmap.m: In instmap__bind_var_to_functor (and the instmap_delta version), use cons_id_adjusted_arity to compute the arity of the inst. compiler/goal_util.m: compiler/pd_info.m: compiler/pd_util.m: compiler/saved_vars.m: compiler/mode_util.m: compiler/deforest.m: compiler/follow_code.m: compiler/higher_order.m: compiler/simplify.m: Pass the type(s) down to recompute_instmap_delta and instmap__bind_var_to_functor, since cons_id_adjusted_arity needs to know the type. compiler/hlds_pred.m: compiler/hlds_out.m: Add a `vartypes' typedef, defined by `:- type vartypes == map(prog_var, type)', and make use of it. Rename the `vartypes' type in hlds_out as `maybe_vartypes'. tests/hard_coded/Mmakefile: tests/hard_coded/existential_type_switch.m: tests/hard_coded/existential_type_switch.exp: Add a regression test. tests/hard_coded/Mmakefile: Enable the existential_types_test.m test case, which should have been enabled previously. (The reason that it wasn't seems to be that I made a mistake when merging in the changes from the existential types branch.) |
||
|
|
00df2750bd |
Remove the limitation of user-guided type specialization that
Estimated hours taken: 50 Remove the limitation of user-guided type specialization that the replacement types must be ground. compiler/higher_order.m: Only add extra type-infos, not typeclass-infos when --typeinfo-liveness is set, extracting type-infos from typeclass-infos where necessary. The arguments of the specialized version are now independent of the class context of the requesting procedure, which maximises the chance of multiple specialized calls to the same procedure being able to use the same code. The code to specialize calls is now slightly simpler because it does not have to work out how to order extra typeclass-info arguments. Specialize special preds for no-tag types where the wrapped type is an atomic type and the no-tag type does not have a user-defined equality pred. This will be useful for specializations involving type `term__var/1'. Make sure the proc_infos for specialized procedures are valid before reanalyzing the goals requesting the specializations. Rework the handling of branched goals to ensure that pred_infos and proc_infos are single threaded through branched goals - when higher_order.m was first written they were constant. Always go over all procedures for every predicate to make sure unifications are specialized in all procedures. compiler/make_hlds.m: Check for type variables substituted multiple times or occurring on both sides of the substitution. Adjust the arity for specializations of functions. compiler/polymorphism.m: Make sure the vartypes field for imported procedures is valid by copying it from the clauses_info to the proc_info. compiler/polymorphism.m: compiler/simplify.m: compiler/table_gen.m: compiler/magic.m: Remove an unused argument from polymorphism__make_type_info_vars. compiler/type_util.m: compiler/det_analysis.m: Add a predicate `type_util__type_has_user_defined_equality_pred' replacing similar code in det_analysis.m. compiler/post_typecheck: Don't overwrite the vartypes field in the pred_info for automatically generated unification procedures for imported types. library/varset.m: Add predicates `varset__merge_without_names' and `varset__merge_subst_without_names'. compiler/equiv_type.m: Use the new predicates in varset.m to avoid adding the variable names from the declarations of equivalence types into the tvarsets of declarations which use those types. This is needed so that `varset__create_name_var_map' (used by make_hlds.m for `:- pragma type_spec' declarations and explicit type qualifications) is not confused by multiple occurrences of a variable name. doc/reference_manual.texi: Remove documentation of the limitation that the substituted types must be ground. tests/hard_coded/type_spec.m: tests/hard_coded/type_spec.err_exp: Tests for non-ground substitutions and specialization of unification of no-tag types. tests/invalid/type_spec.err_exp: Remove the error for a non-ground substitution. Add tests for recursive type substitutions and type variables with multiple replacement types. |
||
|
|
97aead8a4a |
Don't specialize calls to unify/2, index/2 and compare/3 into
Estimated hours taken: 0.5 compiler/polymorphism.m: Don't specialize calls to unify/2, index/2 and compare/3 into type-specific versions here because it stuffs up the predicate names in mode error messages. The optimization is done in higher_order.m. tests/invalid/Mmakefile: tests/invalid/unify_mode_error.m: tests/invalid/unify_mode_error.err_exp: Test case. |
||
|
|
79ab7d373d |
Extend the assertion system by
Estimated hours taken: 56
Extend the assertion system by
* handling assertions in the interface of a module differently to
those in the implementation.
* testing an assertion for the commutivity property.
compiler/polymorphism.m:
Remove the resolving of function calls and data constructors, do it
in post_typecheck instead so that assertions are fully resolved.
compiler/post_typecheck.m:
Add the resolving of function calls and data constructors.
Also call assertion__in_interface_check, if an assertion is in the
interface.
compiler/purity.m:
post_typecheck__finish_assertion can now print error messages so
pass the io__states.
compiler/hlds_data.m:
Add assertion_table_pred_ids, so that intermod knows which pred_ids
are assertions.
compiler/hlds_out.m:
Add predicate hlds_out__write_assertion, which is used by intermod
to write assertions to .opt files.
Change the behaviour of outputing a call, so that if the call is a
function it gets written out in functional syntax. This is
necessary because the resolving of function symbols now occurs in
post_typecheck (pre writing .opt files) rather than in polymorphism
(post writing .opt files).
compiler/intermod.m:
Change intermod so that it writes out any assertion in the
interface to the .opt file.
compiler/modules.m:
Ensure that assertions in the interface are not written to the
.int files. Assertions should only appear in .opt files.
compiler/dead_proc_elim.m:
When intermodule optimization is turned on dead_proc_elim gets run
before typechecking and the assertion predicates are removed. This
change makes dead_proc_elim keep assertions.
compiler/make_hlds.m:
The head variables for an assertion are already known, so initialise
the clause_info structure to those variables rather then creating
Arity fresh variables.
Also don't insert unifications with the head of the assertion, since
we already know that only variables are in the head.
compiler/goal_util.m:
Add mode `goal_calls_pred_id(in, out) is nondet' for use by
assertion__record_preds_used_in.
compiler/assertion.m:
Add a predicate assertion__is_comutativity_assertion, which given
an assertion_id determines whether or not that assertion declares
the commutivity of a pred/func.
Add a predicate assertion__in_interface_check, which checks that an
assertion doesn't refer to any constructors, functions and
predicates defined in the implementation of that module (note
doesn't handle modules imported in the implementation section
correctly).
Rewrite assertion__record_preds_used_in to use the nondet mode of
goal_calls_pred_id.
compiler/accumulator.m:
Remove the facts which declare '+' and '*' to be commutative, and
instead use the new assertion__is_commutivity_assertion predicate.
Also remove the bool from assoc_fact which is the commutivity of the
predicate, since only associative predicates reside in the table
now.
library/int.m:
Add commutivity declarations for '+' and '*', now that they have
been removed from the assoc_fact table. This allows me to test that
all of these changes actually work!
compiler/hlds_goal.m:
Clear up the documentation (I hope) for the type call_unify_context,
so that it is clear that the unification may also have been a
function application.
doc/reference_manual.texi:
doc/transition_guide.texi:
Document assertions.
|
||
|
|
6017919521 |
Rather that map__det_inserting the type info locations into the varmap,
Estimated hours taken: 0.5
(but much more trying to get the @#$%! debugger working!)
compiler/polymorphism.m:
Rather that map__det_inserting the type info locations into the varmap,
map__set them: a type info may appear in more than one location if
the type variable appears more than once in a constraint.
tests/valid/typeclass_multi_repeat.m:
A test case for this.
tests/valid/Mmakefile:
Add the test case.
|
||
|
|
c9d753dfec |
Make the type and type class info varmaps and the varset valid for
Estimated hours taken: 1.5 compiler/polymorphism.m: Make the type and type class info varmaps and the varset valid for imported procedures. |
||
|
|
2725b1a331 |
Aditi update syntax, type and mode checking.
Estimated hours taken: 220
Aditi update syntax, type and mode checking.
Change the hlds_goal for constructions in preparation for
structure reuse to avoid making multiple conflicting changes.
compiler/hlds_goal.m:
Merge `higher_order_call' and `class_method_call' into a single
`generic_call' goal type. This also has alternatives for the
various Aditi builtins for which type declarations can't
be written.
Remove the argument types field from higher-order/class method calls.
It wasn't used often, and wasn't updated by optimizations
such as inlining. The types can be obtained from the vartypes
field of the proc_info.
Add a `lambda_eval_method' field to lambda_goals.
Add a field to constructions to identify which RL code fragment should
be used for an top-down Aditi closure.
Add fields to constructions to hold structure reuse information.
This is currently ignored -- the changes to implement structure
reuse will be committed to the alias branch.
This is included here to avoid lots of CVS conflicts caused by
changing the definition of `hlds_goal' twice.
Add a field to `some' goals to specify whether the quantification
can be removed. This is used to make it easier to ensure that
indexes are used for updates.
Add a field to lambda_goals to describe whether the modes were
guessed by the compiler and may need fixing up after typechecking
works out the argument types.
Add predicate `hlds_goal__generic_call_id' to work out a call_id
for a generic call for use in error messages.
compiler/purity.m:
compiler/post_typecheck.m:
Fill in the modes of Aditi builtin calls and closure constructions.
This needs to know which are the `aditi__state' arguments, so
it must be done after typechecking.
compiler/prog_data.m:
Added `:- type sym_name_and_arity ---> sym_name/arity'.
Add a type `lambda_eval_method', which describes how a closure
is to be executed. The alternatives are normal Mercury execution,
bottom-up execution by Aditi and top-down execution by Aditi.
compiler/prog_out.m:
Add predicate `prog_out__write_sym_name_and_arity', which
replaces duplicated inline code in a few places.
compiler/hlds_data.m:
Add a `lambda_eval_method' field to `pred_const' cons_ids and
`pred_closure_tag' cons_tags.
compiler/hlds_pred.m:
Remove type `pred_call_id', replace it with type `simple_call_id',
which combines a `pred_or_func' and a `sym_name_and_arity'.
Add a type `call_id' which describes all the different types of call,
including normal calls, higher-order and class-method calls
and Aditi builtins.
Add `aditi_top_down' to the type `marker'.
Remove `aditi_interface' from type `marker'. Interfacing to
Aditi predicates is now handled by `generic_call' hlds_goals.
Add a type `rl_exprn_id' which identifies a predicate to
be executed top-down by Aditi.
Add a `maybe(rl_exprn_id)' field to type `proc_info'.
Add predicate `adjust_func_arity' to convert between the arity
of a function to its arity as a predicate.
Add predicates `get_state_args' and `get_state_args_det' to
extract the DCG state arguments from an argument list.
Add predicate `pred_info_get_call_id' to get a `simple_call_id'
for a predicate for use in error messages.
compiler/hlds_out.m:
Write the new representation for call_ids.
Add a predicate `hlds_out__write_call_arg_id' which
replaces similar code in mode_errors.m and typecheck.m.
compiler/prog_io_goal.m:
Add support for `aditi_bottom_up' and `aditi_top_down' annotations
on pred expressions.
compiler/prog_io_util.m:
compiler/prog_io_pragma.m:
Add predicates
- `prog_io_util:parse_name_and_arity' to parse `SymName/Arity'
(moved from prog_io_pragma.m).
- `prog_io_util:parse_pred_or_func_name_and_arity to parse
`pred SymName/Arity' or `func SymName/Arity'.
- `prog_io_util:parse_pred_or_func_and_args' to parse terms resembling
a clause head (moved from prog_io_pragma.m).
compiler/type_util.m:
Add support for `aditi_bottom_up' and `aditi_top_down' annotations
on higher-order types.
Add predicates `construct_higher_order_type',
`construct_higher_order_pred_type' and
`construct_higher_order_func_type' to avoid some code duplication.
compiler/mode_util.m:
Add predicate `unused_mode/1', which returns `builtin:unused'.
Add functions `aditi_di_mode/0', `aditi_ui_mode/0' and
`aditi_uo_mode/0' which return `in', `in', and `out', but will
be changed to return `di', `ui' and `uo' when alias tracking
is implemented.
compiler/goal_util.m:
Add predicate `goal_util__generic_call_vars' which returns
any arguments to a generic_call which are not in the argument list,
for example the closure passed to a higher-order call or
the typeclass_info for a class method call.
compiler/llds.m:
compiler/exprn_aux.m:
compiler/dupelim.m:
compiler/llds_out.m:
compiler/opt_debug.m:
Add builtin labels for the Aditi update operations.
compiler/hlds_module.m:
Add predicate predicate_table_search_pf_sym, used for finding
possible matches for a call with the wrong number of arguments.
compiler/intermod.m:
Don't write predicates which build `aditi_top_down' goals,
because there is currently no way to tell importing modules
which RL code fragment to use.
compiler/simplify.m:
Obey the `cannot_remove' field of explicit quantification goals.
compiler/make_hlds.m:
Parse Aditi updates.
Don't typecheck clauses for which syntax errors in Aditi updates
are found - this avoids spurious "undefined predicate `aditi_insert/3'"
errors.
Factor out some common code to handle terms of the form `Head :- Body'.
Factor out common code in the handling of pred and func expressions.
compiler/typecheck.m:
Typecheck Aditi builtins.
Allow the argument types of matching predicates to be adjusted
when typechecking the higher-order arguments of Aditi builtins.
Change `typecheck__resolve_pred_overloading' to take a list of
argument types rather than a `map(var, type)' and a list of
arguments to allow a transformation to be performed on the
argument types before passing them.
compiler/error_util.m:
Move the part of `report_error_num_args' which writes
"wrong number of arguments (<x>; expected <y>)" from
typecheck.m for use by make_hlds.m when reporting errors
for Aditi builtins.
compiler/modes.m:
compiler/unique_modes.m:
compiler/modecheck_call.m:
Modecheck Aditi builtins.
compiler/lambda.m:
Handle the markers for predicates introduced for
`aditi_top_down' and `aditi_bottom_up' lambda expressions.
compiler/polymorphism.m:
Add extra type_infos to `aditi_insert' calls
describing the tuple to insert.
compiler/call_gen.m:
Generate code for Aditi builtins.
compiler/unify_gen.m:
compiler/bytecode_gen.m:
Abort on `aditi_top_down' and `aditi_bottom_up' lambda
expressions - code generation for them is not yet implemented.
compiler/magic.m:
Use the `aditi_call' generic_call rather than create
a new procedure for each Aditi predicate called from C.
compiler/rl_out.pp:
compiler/rl_gen.m:
compiler/rl.m:
Move some utility code used by magic.m and call_gen.m into rl.m.
Remove an XXX comment about reference counting being not yet
implemented - Evan has fixed that.
library/ops.m:
compiler/mercury_to_mercury.m:
doc/transition_guide.texi:
Add unary prefix operators `aditi_bottom_up' and `aditi_top_down',
used as qualifiers on lambda expressions.
Add infix operator `==>' to separate the tuples in an
`aditi_modify' call.
compiler/follow_vars.m:
Thread a `map(prog_var, type)' through, needed because
type information is no longer held in higher-order call goals.
compiler/table_gen.m:
Use the `make_*_construction' predicates in hlds_goal.m
to construct constants.
compiler/*.m:
Trivial changes to add extra fields to hlds_goal structures.
doc/reference_manual.texi:
Document Aditi updates.
Use @samp{pragma base_relation} instead of
@samp{:- pragma base_relation} throughout the Aditi documentation
to be consistent with other parts of the reference manual.
tests/valid/Mmakefile:
tests/valid/aditi_update.m:
tests/valid/aditi.m:
Test case.
tests/valid/Mmakefile:
Remove some hard-coded --intermodule-optimization rules which are
no longer needed because `mmake depend' is now run in this directory.
tests/invalid/*.err_exp:
Fix expected output for changes in reporting of call_ids
in typecheck.m.
tests/invalid/Mmakefile
tests/invalid/aditi_update_errors.{m,err_exp}:
tests/invalid/aditi_update_mode_errors.{m,err_exp}:
Test error messages for Aditi updates.
tests/valid/aditi.m:
tests/invalid/aditi.m:
Cut down version of extras/aditi/aditi.m to provide basic declarations
for Aditi compilation such as `aditi__state' and the modes
`aditi_di', `aditi_uo' and `aditi_ui'. Installing extras/aditi/aditi.m
somewhere would remove the need for these.
|
||
|
|
8c97633e71 |
Allow construction unifications for existentially typed functors,
Estimated hours taken: 6 Allow construction unifications for existentially typed functors, using the syntax "X = 'new foo'(Y)" rather than the usual "X = foo(Y)". We need to use a special syntax for exisentially typed constructions because type analysis and polymorphism need to know which occurrences of existentially typed functors are constructors and which are deconstructors. Note that we still don't yet support RTTI for existentially typed data types. compiler/typecheck.m: For existentially typed functors, allow the functor to have a "new " prefix, and if so, make the quantifiers and constraints universal rather than existential. compiler/polymorphism.m: For unifications with existentially typed functors, check for a "new " prefix on the functor. If the functor has such a prefix, strip off the prefix, and treat the unification as a construction rather than treating it as a deconstruction. compiler/type_util.m: Define a new predicate `remove_new_prefix', for use by typecheck.m and polymorphism.m. compiler/modecheck_unify.m: For construction unifications, check that all the type_info and typeclass_info arguments introduced by polymorphism.m are ground. tests/hard_coded/typeclasses/existential_data_types.m: Change the test case to use this new feature, rather than hacking it using the C interface. doc/reference_manual.texi: Document the new features. |
||
|
|
6f4970a41d |
Use more meaningful variable names, as suggested by dgj's code review.
Estimated hours taken: 0.25 compiler/polymorphism.m: Use more meaningful variable names, as suggested by dgj's code review. |