Estimated hours taken: 3
Fix some bugs in the optimization of indexed and sort joins.
compiler/rl_out.pp:
compiler/rl.m:
compiler/rl_dump.m:
compiler/rl_block_opt.m:
compiler/rl_stream.m:
compiler/rl_sort.m:
Avoid adding indexes to base relations during queries.
Change the code generated for an add_index instruction
to first test whether the input relation is a base
relation. If it is, the relation must be copied -- queries
should never modify base relations.
The add_index instruction now takes an input and returns
an output, rather than just modifying its argument.
compiler/rl_sort.m:
Fix the merging of sort and index information -- the code
was erroneously finding that some relations were definitely
sorted when they were only sorted on some of the branches leading
into a block.
Don't treat indexed relations as sorted when attempting
to generate a sort-merge join -- if a relation is indexed
an indexed join should be used.
compiler/rl_code.m:
Add a rl_PROC_is_permanent bytecode to test whether
a relation variable refers to a permanent relation.
Increment the version number.
Estimated hours taken: 25
More optimization of Aditi joins and subtracts.
compiler/rl.m:
Add predicates to detect trivial subtracts -- subtracts
for which the condition doesn't use one of the input tuples.
compiler/rl_sort.m:
Introduce index and hash subtract operations.
Improve the handling of trivial joins and subtracts
which can just pass one of their input relations
to the output, so that following instructions can make
use of any indexing on the passed through input relation.
compiler/rl_relops.m:
compiler/rl_block_opt.m:
Detect trivial- and semi-joins and trivial subtracts when
the instructions are generated in rl_relops.m, rather
than in rl_block_opt.m -- these should be detected regardless
of whether the more complex optimizations are being performed.
compiler/rl_code.m:
The indexed instructions now take a parameter describing
whether the key ranges are open or closed -- all key ranges
currently generated by the compiler are closed.
Increment the RL bytecode version number.
compiler/rl_block.m:
Don't assume the output of map__keys is sorted --
use map__sorted_keys instead.
compiler/rl_dump.m:
Write out information about trivial subtracts.
compiler/rl_key.m:
Fix the handling of unbounded key ranges.
compiler/rl_out.pp:
Generate trivial, index and hash subtracts.
Don't optimize away unneeded projects here --
they should be removed (or not generated) earlier.
compiler/rl_stream.m:
Fix the handling of trivial joins and subtracts
which can create aliases of one of their input
relations.
Estimated hours taken: 80
Improve the handling of joins in the Aditi back end.
- generate hash and sort-merge joins for equijoins.
- use the semi-join bytecodes for joins which
return one of the input tuples.
- optimize `trivial' joins where the join condition does not
depend on one of the input tuples.
compiler/rl.m:
Store information about whether a join is a semi-join
or a trivial join.
Add `hash' to the list of alternatives for `join_type'.
Remove `semi' from the list of alternatives for `join_type' --
semi-join is a modified implementation of one of the other
join types.
Remove `cross' from the list of alternatives for `join_type' --
a cross-product is just a modified nested-loop join.
All subtracts are done as semi-subtracts (no projection is performed
on the output by the subtract instruction) -- rename the
constructors of type `subtract_type' to reflect this.
Add more predicates to manipulate join conditions.
Add field labels to the `rl_goal' type.
compiler/rl_sort.m:
Introduce sort-merge and hash joins.
compiler/rl_key.m:
Add `rl_key__is_equijoin', to work out whether a join
condition tests whether attributes of the input tuples
are equal.
compiler/rl_block_opt.m:
Fill in the semi-join and trivial join fields of join
instructions.
compiler/rl_out.pp:
Handle sort-merge, hash, semi and trivial joins.
Use record syntax for the rl_out_info access predicates.
compiler/rl_exprn.m:
Generate RL expressions for use in sort-merge and
hash joins.
compiler/rl_relops.m:
Remove code to handle semi-joins -- they are
introduced later.
compiler/rl_*.m:
Handle the extra fields of join instructions.
Estimated hours taken: 3
Fix confusion over whether attributes are numbered starting from
zero or one.
compiler/prog_data.m:
compiler/rl.m:
compiler/rl_key.m:
compiler/rl_sort.m:
Attributes in sort and index specifications are
now numbered starting from 1, to be consistent with
argument numbering in the rest of the compiler, and for
error messages.
compiler/rl_exprn.m:
compiler/rl_out.pp:
Aditi numbers arguments starting from 0, so convert
the numbers here.
Estimated hours taken: 0.5
compiler/rl.m:
Add `semi' to the list of alternatives for `subtract_type'.
compiler/rl_out.pp:
Use `rl_PROC_semisubtract_nl' instead of `rl_PROC_subtract_nl'
because Aditi's definition of `rl_PROC_subtract_nl' has changed
to match its specification (it now performs a projection on
its output rather than just returning the left input tuple).
`semisubtract' implements the old behaviour.
compiler/rl*.m:
Handle semisubtract.
Estimated hours taken: 5
compiler/rl_out.pp:
Use the `one_reference' bytecode to avoid unnecessary copying.
Use the `has_index' bytecode to avoid adding indexes multiple times.
compiler/rl_sort.m:
Fix bugs in the rules describing how required and available
sorting and indexing are affected by the `make_unique' instruction.
compiler/rl.m:
Remove an obsolete comment.
Estimated hours taken: 1200
Aditi compilation.
compiler/options.m:
The documentation for these is commented out because the Aditi
system is not currently useful to the general public.
--aditi: enable Aditi compilation.
--dump-rl: write the intermediate RL to `<module>.rl_dump'.
--dump-rl-bytecode: write a text version of the bytecodes
to `<module>.rla'
--aditi-only: don't produce a `.c' file.
--filenames-from-stdin: accept a list of filenames to compile
from stdin. This is used by the query shell.
--optimize-rl, --optimize-rl-cse, --optimize-rl-invariants,
--optimize-rl-index, --detect-rl-streams:
Options to control RL optimization passes.
--aditi-user:
Default owner of any Aditi procedures,
defaults to $USER or "guest".
--generate-schemas:
write schemas for base relations to `<module>'.base_schema
and schemas for derived relations to `<module>'.derived_schema.
This is used by the query shell.
compiler/handle_options.m:
Handle the default for --aditi-user.
compiler/hlds_pred.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
Add some Aditi pragma declarations - `aditi', `supp_magic', `context',
`naive', `psn' (predicate semi-naive), `aditi_memo', `aditi_no_memo',
`base_relation', `owner' and `index'.
Separate out code to parse a predicate name and arity.
compiler/hlds_pred.m:
Add predicates to identify Aditi procedures.
Added markers `generate_inline' and `aditi_interface', which
are used internally for Aditi code generation.
Add an `owner' field to pred_infos, which is used for database
security checks.
Add a field to pred_infos to hold the list of indexes for a base
relation.
compiler/make_hlds.m:
Some pragmas must be exported if the corresponding predicates
are exported, check this.
Make sure stratification of Aditi procedures is checked.
Predicates with a mode declaration but no type declaration
are no longer assumed to be local.
Set the `do_aditi_compilation' field of the module_info if there
are any local Aditi procedures or base relations.
Check that `--aditi' is set if Aditi compilation is required.
compiler/post_typecheck.m:
Check that every Aditi predicate has an `aditi__state' argument,
which is used to ensure sequencing of updates and that Aditi
procedures are only called within transactions.
compiler/dnf.m:
Changed the definition of disjunctive normal form slightly
so that a call followed by some atomic goals not including
any database calls is considered atomic. magic.m can handle
this kind of goal, and it results in more efficient RL code.
compiler/hlds_module.m:
compiler/dependency_graph.m:
Added dependency_graph__get_scc_entry_points which finds
the procedures in an SCC which could be called from outside.
Added a new field to the dependency_info, the
aditi_dependency_ordering. This contains all Aditi SCCs of
the original program, with multiple SCCs merged where
possible to improve the effectiveness of differential evaluation
and the low level RL optimizations.
compiler/hlds_module.m:
Add a field to record whether there are any local Aditi procedures
in the current module.
Added versions of module_info_pred_proc_info and
module_info_set_pred_proc_info which take a pred_proc_id,
not a separate pred_id and proc_id.
compiler/polymorphism.m:
compiler/lambda.m:
Make sure that predicates created for closures in Aditi procedures
have the correct markers.
compiler/goal_util.m:
Added goal_util__switch_to_disjunction,
goal_util__case_to_disjunct (factored out from simplify.m)
and goal_util__if_then_else_to_disjunction. These are
require because supplementary magic sets can't handle
if-then-elses or switches.
compiler/type_util.m:
Added type_is_aditi_state/1.
compiler/mode_util.m:
Added partition_args/5 which partitions a list of arguments
into inputs and others.
compiler/inlining.m:
Don't inline memoed procedures.
Don't inline Aditi procedures into non-Aditi procedures.
compiler/intermod.m:
Handle Aditi markers.
Clean up handling of markers which should not appear in `.opt' files.
compiler/simplify.m:
Export a slightly different interface for use by magic.m.
Remove explicit quantifications where possible.
Merge multiple nested quantifications.
Don't report infinite recursion warnings for Aditi procedures.
compiler/prog_out.m:
Generalised the code to output a module list to write any list.
compiler/code_gen.m:
compiler/arg_info.m:
Don't process Aditi procedures.
compiler/mercury_compile.m:
Call magic.m and rl_gen.m.
Don't perform the low-level annotation passes on Aditi procedures.
Remove calls to constraint.m - sometime soon a rewritten version
will be called directly from deforestation.
compiler/passes_aux.m:
Add predicates to process only non-Aditi procedures.
compiler/llds.m:
compiler/llds_out.m:
Added new `code_addr' enum members, do_{det,semidet,nondet}_aditi_call,
which are defined in extras/aditi/aditi.m.
compiler/call_gen.m:
Handle generation of do_*_aditi_call.
compiler/llds_out.m:
Write the RL code for the module as a constant char array
in the `.c' file.
compiler/term_errors.m:
compiler/error_util.m:
Move code to describe predicates into error_util.m
Allow the caller to explicitly add line breaks.
Added error_util:list_to_pieces to format a list of
strings.
Reordered some arguments for currying.
compiler/hlds_out.m:
Don't try to print clauses if there are none.
runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
Added a function `mercury__load_aditi_rl_code()' to the generated
`<module>_init.c' file which throws all the RL code for the program
at the database. This should be called at connection time by
`aditi__connect'.
Added an option `--aditi' which controls the output
`mercury__load_aditi_rl_code()'.
compiler/notes/compiler_design.html:
Document the new files.
Mmakefile:
bindist/Mmakefile:
Don't distribute extras/aditi yet.
New files:
compiler/magic.m:
compiler/magic_util.m:
Supplementary magic sets transformation. Report errors
for constructs that Aditi can't handle.
compiler/context.m:
Supplementary context transformation.
compiler/rl_gen.m:
compiler/rl_relops.m:
Aditi code generation.
compiler/rl_info.m:
Code generator state.
compiler/rl.m:
Intermediate RL representation.
compiler/rl_util:
Predicates to collect information about RL instructions.
compiler/rl_dump.m:
Print out the representation in rl.m.
compiler/rl_opt.m:
Control low-level RL optimizations.
compiler/rl_block.m:
Break a procedure into basic blocks.
compiler/rl_analyse.m:
Generic dataflow analysis for RL procedures.
compiler/rl_liveness.m:
Make sure all relations are initialised before used, clear
references to relations that are no longer required.
compiler/rl_loop.m:
Loop invariant removal.
compiler/rl_block_opt.m:
CSE and instruction merging on basic blocks.
compiler/rl_key.m:
Detect upper/lower bounds for which a goal could succeed.
compiler/rl_sort.m:
Use indexing for joins and projections.
Optimize away unnecessary sorting and indexing.
compiler/rl_stream.m:
Detect relations which don't need to be materialised.
compiler/rl_code.m:
RL bytecode definitions. Automatically generated from the Aditi
header files.
compiler/rl_out.m:
compiler/rl_file.m:
Output the RL bytecodes in binary to <module>.rlo (for use by Aditi)
and in text to <module>.rla (for use by the RL interpreter).
Also output the schema information if --generate-schemas is set.
compiler/rl_exprn.m:
Generate bytecodes for join conditions.
extras/aditi/Mmakefile:
extras/aditi/aditi.m:
Definitions of some Aditi library predicates and the
interfacing and transaction processing code.