Class OperationEscapes

java.lang.Object
org.ek9lang.compiler.phase9.OperationEscapes
All Implemented Interfaces:
BiFunction<IRConstruct, OperationInstr, Map<IRInstr, EscapeMetaDataDetails>>

final class OperationEscapes extends Object implements BiFunction<IRConstruct, OperationInstr, Map<IRInstr, EscapeMetaDataDetails>>
THE escape walk of one operation (E1.1, 2026-11-12; EK9_IR_ESCAPE_LIFETIME_AND_SHARING_FACTS.md §3): one pass over IRStructureWalk classifying every instruction by OPCODE in a switch with no default - an opcode this walk does not classify does not compile until someone says what it does with a reference - then a monotone fixpoint over the holders. The result is the EscapeMetaDataDetails of every value the operation makes or is given, keyed by the instruction that defines it (an allocation site, an owned call result, a parameter's SLOT_DECLARE), which EscapeFacts stamps.

The model is flow-insensitive and field-insensitive, as the facts document decides (§3: the verdict is the join over all sinks; NV §2.1 slice 1: an interior view belongs to its object's graph): names are joined into alias classes by STORE, SLOT_ASSIGN, LOAD, LOAD_FIELD (a view), CAST, a chain's arm results and a call result the callee may hand back; a class's level is the join of its own sinks and of the levels of the classes that HOLD it (a field of an object, an element of a literal, an object a constructor or a callee keeps it in, a capture); the pre-existing names carry their base: this and its properties reach this, a parameter reaches itself, rtn the return, a static, a caught exception and a function instance the world. A capture is a reach as well as a holder (the capturing construct's body is not followed - N-V review 2026-11-13, F2), and the operand of a content operator (:=:, :~:, :^:) is kept by the receiver through the operator's RETAINS (F5; a defaulted :=: declares receiver <- other where the front end makes it, the derivation audit's M4, 2026-11-15).

Because a VIEW of a holder is aliased with the holder (NV §2.1 slice 1) and may, at run time, be any one of the holder's contents, a value kept into the view may be kept into a content that reaches further than the holder. So the fixpoint runs both ways (F1): a value reaches what its holder reaches (direct), and a holder MAY reach what a non-childless content of it reaches (mayReach, kept apart in the record so the proven routes of a value stay readable by the derivation cross-checks); a childless content (IsChildlessTypeName - a String, an Integer) can hold nothing, so it lifts no holder. The static type of a name comes from the instruction that defines it (DefinedTypeName, a slot's declared type for a LOAD, the construct's field for a property slot); a name with no known type is read as one that may hold anything - fail closed.

Callee facts are the RETAINS - declared by the built-ins, derived by phase 5 for user code and already unioned over every override and dispatched handler (D61) - read through CalleeRetention on the symbol CalleeOfCall resolves; never a second solver. The trust boundary is as R0 set it: an un-annotated extern keeps NOTHING of its parameters (the audited side) and its RESULT may alias anything it was given (D7'). A callee the program cannot resolve, a plumbing helper with no EK9 symbol (Ek9Async, Ek9Sort, ...), a callee's ambient/unknown/unimplemented rule, a throw, a static store, a runtime-thread hand-over (HandsValuesToRuntimeThreads) and a lock's payload are all ESCAPES - fail closed, counted by kind, never assumed. A DISPATCH_TABLE's entries are call edges: the dispatched parameters are given to each handler.

Deterministic: the walk order is the IR's, every set is rendered sorted, and the first reach in walk order is the provenance. One instance per compile; nothing is shared between operations but the memoised callee facts.