Class OwnershipLowering
java.lang.Object
org.ek9lang.compiler.phase9.OwnershipLowering
THE ownership lowering (EK9_IR_OWNERSHIP_MODEL.md ยง11.1): rewrites every ownership-form instruction into today's
opcodes, so both back ends keep consuming exactly what they consume now. Today's instructions pass through untouched
(the mixed form, D-O9). Runs as the last step of IR_OPTIMISATION, after which no ownership opcode exists.
| ownership form | today's form |
|---|---|
OWN v | RETAIN v |
DROP v | RELEASE v |
DROP_AT_EXIT v, s | SCOPE_REGISTER v, s |
SLOT_DECLARE x, T, s [typed] | REFERENCE x, T (TYPED_REFERENCE when
typed), and SCOPE_REGISTER x, s straight after the slot's first [init] assignment, wherever in
the operation that is (a declaration can be hoisted out of the list that initialises it) - or straight after the
declaration when nothing initialises it; nothing for a CALLER slot |
SLOT_ASSIGN x, v [consume] | RELEASE x; STORE x, v (no RELEASE under
[init]) |
SLOT_ASSIGN x, v [copy] | the same, then RETAIN x |
FIELD_ASSIGN o.f, v [consume] | RELEASE_FIELD; STORE_FIELD (no
RELEASE_FIELD under [init]) |
FIELD_ASSIGN o.f, v [copy] | the same, then RETAIN v |
STATIC_FIELD_ASSIGN f, v [consume|copy, init] | STORE_STATIC_FIELD (then
RETAIN v when [copy]) |
r = STATIC_FIELD_TAKE f | r = LOAD_STATIC_FIELD f |
The lowering checks its output: every construct it lowers must be ARC-balanced in the lowered form
(RetainReleaseBalanceVerifier, model rule V-L), or compilation stops - a wrong lowering is a compiler
defect, never a silent leak. The ownership form it started from was IR_ANALYSIS's (OwnershipVerifier).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidlower(IRConstruct construct) Lower every operation of a construct, then verify the lowered construct (V-L).Lower an instruction list and every list nested in it, as one operation body.
-
Constructor Details
-
OwnershipLowering
public OwnershipLowering()
-
-
Method Details
-
lower
Lower every operation of a construct, then verify the lowered construct (V-L). -
lowerList
-