Commit a78bbf9
authored
[compiler] Context variables as dependencies (facebook#31582)
We previously didn't track context variables in the hoistable values
sidemap of `propagateScopeDependencies`. This was overly conservative as
we *do* track the mutable range of context variables, and it is safe to
hoist accesses to context variables after their last direct / aliased
maybe-assignment.
```js
function Component({value}) {
// start of mutable range for `x`
let x = DEFAULT;
const setX = () => x = value;
const aliasedSet = maybeAlias(setX);
maybeCall(aliasedSet);
// end of mutable range for `x`
// here, we should be able to take x (and property reads
// off of x) as dependencies
return <Jsx value={x} />
}
```
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31582).
* facebook#31583
* __->__ facebook#315821 parent c869063 commit a78bbf9
File tree
20 files changed
+447
-194
lines changed- compiler/packages
- babel-plugin-react-compiler/src
- HIR
- __tests__/fixtures/compiler
- preserve-memo-validation
- propagate-scope-deps-hir-fork
- reduce-reactive-deps
- snap/src/sprout
20 files changed
+447
-194
lines changedLines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
840 | 840 | | |
841 | 841 | | |
842 | 842 | | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
843 | 848 | | |
844 | 849 | | |
845 | 850 | | |
| |||
852 | 857 | | |
853 | 858 | | |
854 | 859 | | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
| 860 | + | |
860 | 861 | | |
861 | 862 | | |
862 | 863 | | |
| |||
Lines changed: 48 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
223 | 228 | | |
224 | 229 | | |
225 | 230 | | |
226 | | - | |
| 231 | + | |
227 | 232 | | |
228 | 233 | | |
229 | 234 | | |
230 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
231 | 250 | | |
232 | 251 | | |
233 | 252 | | |
| |||
239 | 258 | | |
240 | 259 | | |
241 | 260 | | |
242 | | - | |
| 261 | + | |
243 | 262 | | |
244 | 263 | | |
245 | | - | |
246 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
247 | 267 | | |
248 | 268 | | |
249 | 269 | | |
250 | 270 | | |
251 | 271 | | |
252 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
253 | 276 | | |
254 | 277 | | |
255 | 278 | | |
| |||
265 | 288 | | |
266 | 289 | | |
267 | 290 | | |
268 | | - | |
| 291 | + | |
269 | 292 | | |
270 | 293 | | |
271 | 294 | | |
272 | 295 | | |
273 | 296 | | |
274 | | - | |
| 297 | + | |
275 | 298 | | |
276 | 299 | | |
277 | 300 | | |
| |||
289 | 312 | | |
290 | 313 | | |
291 | 314 | | |
292 | | - | |
| 315 | + | |
293 | 316 | | |
294 | 317 | | |
295 | 318 | | |
| |||
364 | 387 | | |
365 | 388 | | |
366 | 389 | | |
367 | | - | |
| 390 | + | |
368 | 391 | | |
369 | 392 | | |
370 | 393 | | |
| |||
434 | 457 | | |
435 | 458 | | |
436 | 459 | | |
437 | | - | |
| 460 | + | |
438 | 461 | | |
439 | 462 | | |
440 | 463 | | |
| |||
577 | 600 | | |
578 | 601 | | |
579 | 602 | | |
580 | | - | |
581 | | - | |
582 | | - | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
583 | 609 | | |
584 | | - | |
| 610 | + | |
585 | 611 | | |
586 | 612 | | |
587 | 613 | | |
| |||
724 | 750 | | |
725 | 751 | | |
726 | 752 | | |
727 | | - | |
728 | | - | |
729 | | - | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
730 | 761 | | |
731 | 762 | | |
732 | 763 | | |
| |||
Lines changed: 8 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
69 | 67 | | |
70 | | - | |
| 68 | + | |
71 | 69 | | |
72 | | - | |
| 70 | + | |
73 | 71 | | |
74 | 72 | | |
75 | 73 | | |
| |||
Lines changed: 7 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
52 | 51 | | |
53 | | - | |
| 52 | + | |
54 | 53 | | |
55 | | - | |
| 54 | + | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
| |||
Lines changed: 7 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
51 | 50 | | |
52 | | - | |
| 51 | + | |
53 | 52 | | |
54 | | - | |
| 53 | + | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
| |||
Lines changed: 7 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
52 | 51 | | |
53 | | - | |
| 52 | + | |
54 | 53 | | |
55 | | - | |
| 54 | + | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
| |||
Lines changed: 7 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
51 | 50 | | |
52 | | - | |
| 51 | + | |
53 | 52 | | |
54 | | - | |
| 53 | + | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
| |||
Lines changed: 7 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
43 | 41 | | |
44 | | - | |
| 42 | + | |
45 | 43 | | |
46 | | - | |
| 44 | + | |
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
| |||
This file was deleted.
0 commit comments