Commit f83fc00
committed
[compiler][newinference] Impure/Render effects
Adds two new effects:
- `Impure` is for builtin functions that are known to be impure and not safe to call during render. This is already implemented via an optional `impure` flag on function declarations and ValidateNoImpureFunctionsInRender. That validation still exists, but we can avoid the need for the special validation pass by relying on the function effect.
- `Render` is an effect that indicates a value is assumed to be called at render time, even if it would not normally appear to be called. Examples are JSX tags and children — if these values are functions, they are definitely called at render (tag) or almost certainly called in render (children). Any function that transitively flows into a Render effect must not have MutateGlobal or Impure effects. We can also extend this to include other APIs that should be pure, for example we could consider adding it to `useReducer()` callbacks or `useState()` initializers.
ghstack-source-id: 8367f46
Pull Request resolved: #334881 parent 42e1039 commit f83fc00
File tree
13 files changed
+185
-55
lines changed- compiler/packages/babel-plugin-react-compiler/src
- HIR
- Inference
- __tests__/fixtures/compiler
- new-mutability
13 files changed
+185
-55
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| 419 | + | |
419 | 420 | | |
420 | 421 | | |
421 | 422 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1015 | 1015 | | |
1016 | 1016 | | |
1017 | 1017 | | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
1018 | 1024 | | |
1019 | 1025 | | |
1020 | 1026 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
Lines changed: 76 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
380 | 381 | | |
381 | 382 | | |
382 | 383 | | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
| 384 | + | |
387 | 385 | | |
388 | 386 | | |
389 | 387 | | |
| |||
546 | 544 | | |
547 | 545 | | |
548 | 546 | | |
549 | | - | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
550 | 551 | | |
551 | 552 | | |
552 | 553 | | |
| |||
721 | 722 | | |
722 | 723 | | |
723 | 724 | | |
| 725 | + | |
724 | 726 | | |
725 | 727 | | |
726 | 728 | | |
| |||
747 | 749 | | |
748 | 750 | | |
749 | 751 | | |
| 752 | + | |
| 753 | + | |
750 | 754 | | |
751 | 755 | | |
752 | 756 | | |
| |||
766 | 770 | | |
767 | 771 | | |
768 | 772 | | |
| 773 | + | |
769 | 774 | | |
770 | 775 | | |
771 | 776 | | |
| |||
899 | 904 | | |
900 | 905 | | |
901 | 906 | | |
| 907 | + | |
| 908 | + | |
902 | 909 | | |
903 | 910 | | |
904 | 911 | | |
| |||
1452 | 1459 | | |
1453 | 1460 | | |
1454 | 1461 | | |
| 1462 | + | |
1455 | 1463 | | |
1456 | 1464 | | |
1457 | 1465 | | |
| |||
1631 | 1639 | | |
1632 | 1640 | | |
1633 | 1641 | | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
1634 | 1660 | | |
1635 | 1661 | | |
1636 | 1662 | | |
| |||
1861 | 1887 | | |
1862 | 1888 | | |
1863 | 1889 | | |
| 1890 | + | |
1864 | 1891 | | |
1865 | 1892 | | |
1866 | 1893 | | |
| |||
1870 | 1897 | | |
1871 | 1898 | | |
1872 | 1899 | | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
1873 | 1917 | | |
1874 | 1918 | | |
1875 | 1919 | | |
| |||
2083 | 2127 | | |
2084 | 2128 | | |
2085 | 2129 | | |
| 2130 | + | |
2086 | 2131 | | |
2087 | 2132 | | |
2088 | 2133 | | |
| |||
2163 | 2208 | | |
2164 | 2209 | | |
2165 | 2210 | | |
| 2211 | + | |
2166 | 2212 | | |
2167 | 2213 | | |
2168 | 2214 | | |
| |||
2171 | 2217 | | |
2172 | 2218 | | |
2173 | 2219 | | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
2174 | 2227 | | |
2175 | 2228 | | |
2176 | 2229 | | |
| |||
2254 | 2307 | | |
2255 | 2308 | | |
2256 | 2309 | | |
| 2310 | + | |
2257 | 2311 | | |
2258 | 2312 | | |
2259 | 2313 | | |
| |||
2468 | 2522 | | |
2469 | 2523 | | |
2470 | 2524 | | |
| 2525 | + | |
2471 | 2526 | | |
2472 | 2527 | | |
2473 | 2528 | | |
| |||
2490 | 2545 | | |
2491 | 2546 | | |
2492 | 2547 | | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
2493 | 2562 | | |
2494 | 2563 | | |
2495 | 2564 | | |
| |||
2536 | 2605 | | |
2537 | 2606 | | |
2538 | 2607 | | |
| 2608 | + | |
| 2609 | + | |
2539 | 2610 | | |
2540 | 2611 | | |
2541 | 2612 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| |||
Lines changed: 48 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
163 | | - | |
| 164 | + | |
| 165 | + | |
164 | 166 | | |
165 | 167 | | |
| 168 | + | |
| 169 | + | |
166 | 170 | | |
167 | 171 | | |
168 | 172 | | |
| |||
209 | 213 | | |
210 | 214 | | |
211 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
212 | 219 | | |
213 | 220 | | |
214 | 221 | | |
| |||
357 | 364 | | |
358 | 365 | | |
359 | 366 | | |
| 367 | + | |
| 368 | + | |
360 | 369 | | |
361 | 370 | | |
362 | 371 | | |
| |||
440 | 449 | | |
441 | 450 | | |
442 | 451 | | |
| 452 | + | |
443 | 453 | | |
444 | 454 | | |
445 | 455 | | |
| |||
530 | 540 | | |
531 | 541 | | |
532 | 542 | | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
533 | 580 | | |
534 | 581 | | |
535 | 582 | | |
| |||
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
0 commit comments