jon.recoil.org

Module Flambda2_simplify.Are_lifting_conts

Continuation Lifting Status

Continuation lifting is done in simplify on the way down. Considering a term of the form:

let_cont k x =
  let_cont k' y =
    ...
  in
  ..
in
..

The decision to lift continuations (e.g. k') out of another (e.g. k), is made once Simplify has reached the bottom of the handler of k **but** has not yet explored the handler of k'. The t type represente the current decision about lifting of continuations:

See occurrences of the constructors in simplify_let_cont_expr and the associated comments for more details.

1: typically when we simplify leafs of expressions, so mostly in simplify_switch because that will be the interesting case for the match-in-match optimisation.

type t = private
  1. | Not_lifting
  2. | Analyzing of {
    1. continuation : Flambda2_identifiers.Continuation.t;
    2. is_exn_handler : bool;
    3. uses : Continuation_uses.t;
    }
  3. | Lifting_out_of of {
    1. continuation : Flambda2_identifiers.Continuation.t;
    }

The current continuation lifting status, stored in the dacc.

val print : Format.formatter -> t -> unit

Printing function.

val no_lifting : t

Prevent any lifting of continuation.

val think_about_lifting_out_of : is_exn_handler:bool -> Flambda2_identifiers.Continuation.t -> Continuation_uses.t -> t

Delay the choice of lifting until the leaf of a continuation's handler.

val lift_continuations_out_of : Flambda2_identifiers.Continuation.t -> t

Instruct simplify_let_cont to lift continuations.