Module Flambda2_reaper.Traverse_env
Environment threaded through the downward traversal of a function body. Tracks the context needed to register dependencies at each expression.
Normal params carries the variables representing a continuation's parameters.
Controls whether the reaper preserves direct function calls when the code_id being called might otherwise be dead. The typical situation is a call to a code_id f, which has two newer versions f1 and f2, and the closure that is used could have either code_id f1 or f2, but never f.
Yes: always preserve direct calls: this has the consequence that it needs to keep old code_ids (fin this case) alive.No: never preserve direct calls to dead code_ids: the call will be replaced byIndirect_known_arityif the reaper isn't able to determine the possibly called code_ids.Auto: preserve only if the closure isany_source, preventing a determination of a set of possibly called code_ids. In this case, direct calls can never be completely degraded toIndirect_known_aritythat doesn't know the set of possibly called code_ids: if that were to happen, the direct call is instead kept.
val create :
parent:Rev_expr.rev_expr_holed ->
conts:cont_kind Flambda2_identifiers.Continuation.Map.t ->
current_code_id:Flambda2_identifiers.Code_id.t option ->
should_preserve_direct_calls:should_preserve_direct_calls ->
le_monde_exterieur:Flambda2_identifiers.Name.t ->
all_constants:Flambda2_identifiers.Name.t ->
tCreate a new downwards environment.
val parent : t -> Rev_expr.rev_expr_holedThe reversed expression context above the current point in the traversal.
val find_cont : t -> Flambda2_identifiers.Continuation.t -> cont_kindGet parameters of a given continuation
val add_cont : t -> Flambda2_identifiers.Continuation.t -> cont_kind -> tAdd new continuation in scope with given parameters.
val current_code_id : t -> Flambda2_identifiers.Code_id.t optionThe code id of the function currently being traversed, or None at the top level.
val should_preserve_direct_calls : t -> should_preserve_direct_callsWhether direct calls in the current function should be preserved by the reaper. Set per function body based on the reaper_preserve_direct_calls flag and whether zero-alloc checking is active.
val le_monde_exterieur : t -> Flambda2_identifiers.Name.tA distinguished any_source symbol representing the external world. Dependencies on this node model side effects.
val all_constants : t -> Flambda2_identifiers.Name.tA distinguished any_source symbol to which all compile-time constants are mapped.
val with_parent : t -> Rev_expr.rev_expr_holed -> tReturn a copy of the environment with a new parent context.