mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
59cd1ca569
This PR clarifies the logic for adjust mutable ranges of phis and their operands during LeaveSSA. Previously we had logic in several places to determine whether/how to extend the ranges of each phi and its operands: this occurred while traversing reassignmentPhis (in 2+ places) and rewritePhis, as well as in rewritePlace(). This was kind of a band-aid to make things work, but the logic was imprecise. The actual rules are as follows: If there is a back-edge, or the phi id is unnamed, then were extend the ranges of the phi and its operands to min(starts) and max(ends). This ensures that the operands are computed as one unit, ie put into a single reactive scope. For loops this is necessary because...looping! For unnamed values this is necessary because of the way we collapse logical and ternary expressions back to a hierarchical ReactiveFunction — we need to make sure the final mutable range extends from the start of the final instruction up to the end of the logical/ternaries value blocks. Otherwise this is a phi where operands come from predecessors and are named. If the phi is mutated later, then we have to extend the end of each operand's range to account for the fact that they can be mutated later. Else, we leave the operands alone. Behavior doesn't change, but we consolidate all of the mutable range logic in one place.