Class ConfinePlacement

java.lang.Object
org.ek9lang.compiler.phase9.ConfinePlacement
All Implemented Interfaces:
Consumer<Collection<IRConstruct>>

public final class ConfinePlacement extends Object implements Consumer<Collection<IRConstruct>>
THE placement of CONFINE (N-V V1 and V3; NV_PER_SITE_CONFINEMENT.md ยง3.3): an IR_OPTIMISATION pass after SafePointPlacement and CancelPointPlacement and BEFORE PublishPlacement, over the ownership form, before the lowering. Over the whole program it puts a CONFINE v, site immediately after each allocation site whose object the record proves this thread's own, and a CONFINE v, with, h after each whose one holder outside the frame the IR can name (ConfinedSites.decide(IRConstruct, OperationInstr) decides which, once per operation). ConfineVerifier (V-N) checks the result. It rewrites no ownership: a confined value is still counted, owned and dropped as before, and a garbage-collected back end emits nothing for it.

Beside the publish pass, in either order: a PUBLISH goes immediately BEFORE the instruction that shares a value and a CONFINE immediately AFTER the one that makes one, each inserted beside its own anchor by the per-instruction rewrite, so a site directly followed by a publishing instruction comes out site, CONFINE, PUBLISH, instruction whichever pass runs first - V-N sees the CONFINE right after its site, V-P sees the PUBLISH right before its instruction (ConfinePlacementTest pins the shape). Under the confine pass switch (PassSwitches.CONFINE) with V-N.

  • Constructor Details

    • ConfinePlacement

      public ConfinePlacement(ConfinedSites confinedSites)
  • Method Details

    • accept

      public void accept(Collection<IRConstruct> constructs)
      Specified by:
      accept in interface Consumer<Collection<IRConstruct>>
    • placed

      public int placed()
      How many CONFINEs this placement has put in, over everything it was given - both forms.
    • placedWith

      public int placedWith()
      How many of those are the conditional form, CONFINE v, with, h.
    • placedByType

      public Map<String,Integer> placedByType()
      The same, by the allocated type's fully qualified name (the census the -v line and the ledger quote).