You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our current escape analysis currently works by determing values which are returned, finding the scope those values are produced in, and then walking the dependencies of those scopes. Notably, when we traverse into scopes, we _force_ their values to be memoized — even in cases where we can prove it isn't necessary.
The idea of this PR is to change escape analysis to be purely based on the flow of values. So rather than assume all scope deps need to be force-memoized, we look at how those values are used.
Note: the main motivation for this PR is the follow-up, which allows us to infer dependencies for pruned scopes. Without this change, inferring deps for pruned scopes causes the escape analysis pass to consider values as escaping which shouldn't be.
[ghstack-poisoned]
Copy file name to clipboardExpand all lines: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-mutate.expect.md
Copy file name to clipboardExpand all lines: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/method-call-computed.expect.md
+10-18Lines changed: 10 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ function foo(a, b, c) {
23
23
```javascript
24
24
import { cas_c } from"react/compiler-runtime";
25
25
functionfoo(a, b, c) {
26
-
const$=_c(8);
26
+
const$=_c(6);
27
27
let t0;
28
28
if ($[0] !== a) {
29
29
t0 =makeObject(a);
@@ -33,26 +33,18 @@ function foo(a, b, c) {
33
33
t0 = $[1];
34
34
}
35
35
constx= t0;
36
+
consty=makeObject(a);
36
37
let t1;
37
-
if ($[2] !== a) {
38
-
t1 =makeObject(a);
39
-
$[2] = a;
40
-
$[3] = t1;
41
-
} else {
42
-
t1 = $[3];
43
-
}
44
-
consty= t1;
45
-
let t2;
46
-
if ($[4] !== x || $[5] !==y.method|| $[6] !== b) {
47
-
t2 = x[y.method](b);
48
-
$[4] = x;
49
-
$[5] =y.method;
50
-
$[6] = b;
51
-
$[7] = t2;
38
+
if ($[2] !== x || $[3] !==y.method|| $[4] !== b) {
Copy file name to clipboardExpand all lines: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/original-reactive-scopes-fork/mutate-outer-scope-within-value-block.expect.md
0 commit comments