* module/language/cps/contification.scm (compute-contification):
Converge more quickly by using the information we compute within a
compute-contification pass.
* module/language/cps/contification.scm (compute-contification): If we
decide to contify, don't forget to visit the body. Should make
contification converge faster.
* module/language/cps/contification.scm (compute-contification): Fail as
soon as we see an arity with rest, optional, or keyword arguments.
Fixes ((case-lambda ((a . b) #t) ((a b) #f)) 1 2).
* module/language/cps.scm ($continue, $cont): Put source information on
the $continue, not on the $cont. Otherwise it is difficult for CPS
conversion to preserve source information.
($fun): Add a src member to $fun. Otherwise we might miss the source
info for the start of the function.
* .dir-locals.el:
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-rtl.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/dfg.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Update the whole CPS world
for this change.
* module/language/cps/contification.scm (compute-contification): When
eliding let-bound functions, also record the cont that declares the
function.
(apply-contification): Instead of reifying ($values ()) gotos instead
of the elided function, inline the body that binds the function
directly. This ensures that the function gets contified in its own
scope.
* module/language/cps/contification.scm: Returns from contified
functions should primcall to 'values, as in general the return
continuation is a multiple value context ($ktrunc or $ktail). A later
pass can elide the primcall if appropriate.
* module/language/cps/contification.scm (compute-contification): Rewrite
to avoid mutating the DFG and the function while we are rewriting.
Instead we compute a contification, and if it is not empty, we apply
it and loop.
* module/language/cps/contification.scm (contify): It could be that
visiting pending contifications could enqueue more contifications, so
iterate to a fixed point. Signal an error if there are any pending
contifications at the end of an iteration.
* module/language/cps/dfg.scm: Refactor so that we can think about
building a dominator tree. Split continuations out of use maps and
put them in a separate table, which will have more flow information.
(visit-fun): Mark clauses as using their bodies.
(lookup-predecessors, lookup-successors): New exports.
(find-defining-expression): Add an exception for clauses, now that
clauses are in the flow graph.
(continuation-bound-in?): Rename from variable-bound-in?, as it can
currently only be used for continuations.
* module/language/cps/contification.scm (contify): Adapt to use
lookup-predecessors and continuation-bound-in?.
* module/language/cps/contification.scm (contify): Exhaustively replace
contified tail continuations, to fix a bug in nested tail-recursive
contifications. Likewise, call lookup-return-cont when searching for
common return continuations.
* module/language/cps/dfg.scm (variable-free-in?): Rename from
variable-used-in?, to match CWCC language.
(variable-bound-in?): New interface.
* module/language/cps/contification.scm (contify): Adapt caller. Add
more comments.