Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Join Operation

The join algorithm on PCGs takes as input PCGs and and mutates to join in .

We define the join in this manner because this is similar to how the implementation works.

The algorithm proceeds in the follow steps:

  1. The Owned PCG of is joined into the Owned PCG of (this may also change the capabilities of )
  2. The capabilities of are joined into the capabilities of .
  3. The Borrow State of is joined into the Borrow State of

We now describe each step in detail:

Owned PCG Join

Let be the owned PCG of and the PCG of .

  1. For each local in the MIR body:
    1. If is allocated in both and :
      1. Join the place expansions rooted at into
    2. Otherwise, if is allocated in , it should be deallocated in

The algorithm joins a set of place expansions into a set of place expansions , and makes corresponding changes to capabilities .

  1. Let be an ordered list of the expansions in sorted in order of ascending length of the projections of their base place
  2. For each in :
    1. Let be the base of .
    2. If there exists a where the base of is :
      1. If
        1. Perform collapse(, , )
        2. Otherwise do nothing (go back to the top of the loop)
    3. Otherwise, if contains an expansion and :
      1. Add to
      2. If :
        1. Assign capability to in
        2. Otherwise, remove capability to in
      3. For each :
        1. If :
          1. Assign capability to in
        2. Otherwise, remove capability to in

Place Capabilitiies Join

The algorithm join() is defined as:

  1. For each p: c in :
    1. If :
      1. Remove capability to in
    2. Otherwise:
      1. If is defined:
        1. Assign capability to in
      2. Otherwise, remove capability to in

Borrow State Join

  1. The borrow graphs are joined
  2. The latest maps are joined
  3. The validity conditions are joined

Borrow PCG Join

Joining into , where is the block for and is the block for .

Update the validity conditions for each edge in to require the branch condition .

Update the validity

  1. If is a loop head perform the loop join algorithm as described here.
  2. Otherwise:
    1. For each edge in :
      1. If there exists an edge of the same kind in
        1. Join the validity conditions associated with in to the validity conditions associated with in
      2. Otherwise, add to
    2. For all placeholder lifetime projections in :
      1. Label all lifetime projection nodes of the form in with