compiler/parse_item.m:
Don't accept `:- external' items.
compiler/prog_item.m:
Require the presence of a pred_or_func flag on external pragmas.
They are specified by `:- pragma external_{pred/func}' pragmas,
which are still supported.
compiler/parse_pragma.m:
When parsing external_{pred/func} pragmas, allow the predicate name
to contain a module qualifier; they were allowed on `:- external' items.
We do require the module qualifier to specify the expected (i.e. the
current) module.
compiler/add_pragma.m:
compiler/parse_tree_out_pragma.m:
compiler/recompilation.version.m:
Conform to the changes above.
tests/hard_coded/backend_external.m:
tests/hard_coded/constant_prop_2.m:
tests/invalid/external.err_exp:
tests/invalid/external.m:
tests/invalid/io_in_ite_cond.err_exp:
tests/invalid/io_in_ite_cond.m:
tests/invalid/overloading.m:
tests/invalid/tricky_assert1.m:
tests/invalid/type_spec.err_exp:
tests/invalid/type_spec.m:
tests/invalid/uniq_neg.err_exp:
tests/invalid/uniq_neg.m:
tests/valid/dcg_test.m:
tests/valid/inst_perf_bug_1.m:
tests/valid/lambda_recompute.m:
tests/valid/semidet_disj.m:
tests/valid/solv.m:
tests/valid/solver_type_bug.m:
tests/valid/stack_alloc.m:
tests/valid/tricky_assert2.m:
Replace `:- external' items with external_{pred/func} pragmas.
Modernize the code where needed, replacing DCGs with state variables.
On tools/speedtest -l, my three tests shows speedups between 7% and 12%
for this diff. For Dirk's stress test module, for which the compiler
spends almost all its time handling insts, the speedup was bigger:
the compilation time went from 3.6 to 2.3 seconds.
compiler/inst_user.m:
A new module that pretests user defined bound insts, and records
the results in the insts themselves, so that those tests won't
have to be done repeatedly, each time the compiler needs their results.
compiler/check_hlds.m:
compiler/notes/compiler_design.html:
Include the new module.
compiler/mercury_compile_front_end.m:
Invoke the new module.
compiler/inst_check.m:
Rewrite this module to record, for each user defined bound inst, the type
constructor(s) that the top-level bound insts match. This should allow a
later diff to make inst_user.m more effective by pre-pushing the one
matching type constructor into the inst, for insts that *do* have exactly
*one* matching type constructor.
The information needed for this also allows us to generate more precise
error messages, fulfilling an earlier TODO.
compiler/hlds_data.m:
Add a field to inst definitions to allow this recording.
Don't hide the representation of the table of user insts. It just makes
code working with it harder, and provides no benefit, since any useful
structure imposed on top of the current simple map would require the
lookups to be done *inside* the abstraction barrier, which the current
design does not allow.
compiler/prog_data.m:
Add a redundant field to the representation of data constructors (function
symbols) in type definitions. This field holds the number of arguments
of the function symbols, computed just once when the representation is
created, rather than many times later on in many parts of the compiler.
compiler/prog_io_type_defn.m:
Fill in the new redundant field when the constructor representations
are created.
compiler/mode_util.m:
Avoid the use of higher order code in a predicate that happens to be
performance critical when compiling Dirk's stress test module.
compiler/add_mode.m:
compiler/add_type.m:
compiler/check_typeclass.m:
compiler/du_type_layout.m:
compiler/equiv_type.m:
compiler/export.m:
compiler/hhf.m:
compiler/hlds_module.m:
compiler/hlds_out_module.m:
compiler/inst_check.m:
compiler/intermod.m:
compiler/make_tags.m:
compiler/mercury_to_mercury.m:
compiler/ml_type_gen.m:
compiler/module_qual.m:
compiler/post_typecheck.m:
compiler/prog_type.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/special_pred.m:
compiler/term_constr_build.m:
compiler/term_norm.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/unify_proc.m:
compiler/unused_imports.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the changes above.
library/Mercury.options:
Disable the trace flag that calls for the runtime testing of the invariants
of the tree_bitset.m module. We have tested it far more than necessary,
and it has been just overhead for a long time now. This helps speed up
quantification, which takes nontrivial time on Dirk's module.
library/multi_map.m:
Add a utility predicate needed above. It is a reverse set, i.e. a set
with a value, key argument order.
Put the code for the function versions of predicates next to the code
for the predicate versions.
tests/warnings/inst_with_no_type.m:
tests/valid/inst_perf_bug_1.m:
Fix indentation.
tests/warnings/inst_with_no_type.exp:
Update this file to expect the new and improved error messages now
generated by inst_check.m.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
Branches: main
valid/deforest_loop.m:
valid/exported_foreign_type2.m:
valid/headvar_not_found.m:
valid/ho_and_type_spec_bug.m:
valid/inst_perf_bug_1.m:
valid/intermod_impure2.m:
valid/lambda_recompute.m:
valid/livevals_seq.m:
valid/mostly_uniq_neg.m:
valid/multidet_prune1.m:
valid/nondet_live.m:
valid/param_mode_bug.m:
valid/simplify_bug.m:
valid/soln_context.m:
valid/switch_detection_bug2.m:
valid/tricky_assert2.m:
valid/uniq_unify.m:
valid/vn_float.m:
warnings/purity_warnings.m:
warnings/singleton_test.m:
Add Erlang pragma foreign_* for these test cases.
warnings/singleton_test.exp:
Update line numbers in expected output for C.
warnings/singleton_test.exp2:
warnings/singleton_test.exp3:
Update line numbers and format C# and Java (untested).
warnings/singleton_test.exp4:
Add expected output for Erlang.
Estimated hours taken: 10
Fix a performance problem reported by Tom Conway,
that caused the compiler to take forever when compiling
very simple test cases making use of user-defined insts.
compiler/inst_match.m:
compiler/inst_util.m:
In the implementation of the procedures that traverse insts, e.g.
inst_matches_initial, inst_matches_final, inst_is_ground, etc., ensure
that we thread the set of already processed inst names through the
code, i.e. pass it both in and out, rather than just passing it in.
This ensures that we don't traverse the same inst name more than once
for each call to one of those top-level procedures.
The previous algorithm lead to an exponential performance
blow-out.
Also change mode_list_contains_inst_var so that it does not
expand modes or defined_insts, but instead just returns the
inst_vars that the mode list contains directly.
tests/valid/Mmakefile:
tests/valid/inst_perf_bug_1.m:
tests/valid/inst_perf_bug_2.m:
Add a couple of regression tests, one for the performance bug
that this change fixes, one for a similar performance bug that
still remains even after this change. For now only the first
one is enabled.