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:
- The Owned PCG of is joined into the Owned PCG of (this may also change the capabilities of )
- The capabilities of are joined into the capabilities of .
- 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 .
- For each local in the MIR body:
- If is allocated in both and :
- Join the place expansions rooted at into
- Otherwise, if is allocated in , it should be deallocated in
- If is allocated in both and :
The algorithm joins a set of place expansions into a set of place expansions , and makes corresponding changes to capabilities .
- Let be an ordered list of the expansions in sorted in order of ascending length of the projections of their base place
- For each in :
- Let be the base of .
- If there exists a where the base of is :
- If
- Perform collapse(, , )
- Otherwise do nothing (go back to the top of the loop)
- If
- Otherwise, if contains an expansion and
:
- Add to
- If :
- Assign capability to in
- Otherwise, remove capability to in
- For each :
- If :
- Assign capability to in
- Otherwise, remove capability to in
- If :
Place Capabilitiies Join
The algorithm join() is defined as:
- For each
p: c
in :- If :
- Remove capability to in
- Otherwise:
- If is defined:
- Assign capability to in
- Otherwise, remove capability to in
- If is defined:
- If :
Borrow State Join
- The borrow graphs are joined
- The latest maps are joined
- 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
- If is a loop head perform the loop join algorithm as described here.
- Otherwise:
- For each edge in :
- If there exists an edge of the same kind in
- Join the validity conditions associated with in to the validity conditions associated with in
- Otherwise, add to
- If there exists an edge of the same kind in
- For all placeholder lifetime projections in :
- Label all lifetime projection nodes of the form in with
- For each edge in :