Class CancelPointPlacement
java.lang.Object
org.ek9lang.compiler.phase9.CancelPointPlacement
- All Implemented Interfaces:
Consumer<Collection<IRConstruct>>
THE placement of
CANCEL_POINT (EK9_BACKEND_IR_CONTRACTS.md Contract 24): an IR_OPTIMISATION pass over the
ownership form, run after SafePointPlacement, which states which operations are
callback-reachable. Only those can run on an async task - a task runs a
function value's _call, and everything it calls is reached from that - so only they get cancel points, the
complement of the safe points:
- at the end of every loop body (
BackEdgePoints): a task looping in EK9 code stops within one iteration; - at the entry of an operation that may recur - one in a cycle of the program's calls
(
CallbackReachableOperations.callEdges(Collection),StronglyConnectedComponents): a task recursing without a loop stops within one call. An operation that neither loops nor recurs finishes in a bounded number of steps, so it needs none. Nor does an operator the runtime calls through a vtable (CallbackReachableOperations.PREFIX_OPERATORS:_eq,_cmp,_isSet, ...): it recurs only through the value it walks - a finite structure, a cyclic one bounded by the cycle guard (Contract 13) - and the call edges join a type's overloads, so its delegation to another overload (_eq(Animal)to_eq(Cat)) would read as recursion and put the check in the hottest code there is. Its loops keep theirs.
_c_init: a class initialiser the JVM runs lazily on a task must not be left half done. Both
positions hold no value in flight - the loop body's own scope has already dropped its values, and nothing is owned
yet at an entry - so a cancellation unwinding from one releases only what the open scopes register. A recursion the
runtime mediates (a function value handed to a runtime helper that calls it back) is not a cycle of the IR's calls;
it is reached through the helper's own bound or the close's bounded join. Stateless: hold one.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(Collection<IRConstruct> constructs) booleanisPlacedIn(OperationInstr operation) Does this operation get cancel points: one the runtime may call (so one an async task may run), with a body, and not a class initialiser.
-
Constructor Details
-
CancelPointPlacement
public CancelPointPlacement()
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceConsumer<Collection<IRConstruct>>
-
isPlacedIn
Does this operation get cancel points: one the runtime may call (so one an async task may run), with a body, and not a class initialiser.CancelPointVerifierasks the same question.
-