mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
4a21bb8856
Adds a new pass `InferReactiveScopeVariables` which determines the sets of variables (by Identifier) which "construct together" and belong in the same reactive scope. Concretely, `Identifier` gets a new property `scope: ScopeId`, and this pass assigns each identifier a ScopeId value. The algorithm iterates over all instructions in all blocks (in a single pass) and builds up disjoint sets of identifiers that appear as mutable operands in the same instruction. The algorithm is relatively simple (especially since I had already implemented a union-find data structure): however looking at some examples reinforced that other planned todos around alias analysis are really important. We also have to think more about what "mutable lifetime" means in the context of SSA: currently variables that are reassigned (but never "mutated", eg bc they're assigned a value type) never appear as mutable.