Skip to content

Commit 57e4b48

Browse files
committed
[compiler] New inference repros/fixes (#33584)
Substantially improves the last major known issue with the new inference model's implementation: inferring effects of function expressions. I knowingly used a really simple (dumb) approach in InferFunctionExpressionAliasingEffects but it worked surprisingly well on a ton of code. However, investigating during the sync I saw that we the algorithm was literally running out of memory, or crashing from arrays that exceeded the maximum capacity. We were accumluating data flow in a way that could lead to lists of data flow captures compounding on themselves and growing very large very quickly. Plus, we were incorrectly recording some data flow, leading to cases where we reported false positive "can't mutate frozen value" for example. So I went back to the drawing board. InferMutationAliasingRanges already builds up a data flow graph which it uses to figure out what values would be affected by mutations of other values, and update mutable ranges. Well, the key question that we really want to answer for inferring a function expression's aliasing effects is which values alias/capture where. Per the docs I wrote up, we only have to record such aliasing _if they are observable via mutations_. So, lightbulb: simulate mutations of the params, free variables, and return of the function expression and see which params/free-vars would be affected! That's what we do now, giving us precise information about which such values alias/capture where. When the "into" is a param/context-var we use Capture, iwhen the destination is the return we use Alias to be conservative. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33584). * #33626 * #33625 * #33624 * __->__ #33584 DiffTrain build for [94cf60b](94cf60b)
1 parent 7ac4ad8 commit 57e4b48

35 files changed

+176
-248
lines changed

compiled/eslint-plugin-react-hooks/index.js

Lines changed: 90 additions & 162 deletions
Large diffs are not rendered by default.

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12eaef7ef5fbf6c9d7ec6e16a04bc207a1a68b91
1+
94cf60bede7cd6685e07a4374d1e3aa90445130b
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12eaef7ef5fbf6c9d7ec6e16a04bc207a1a68b91
1+
94cf60bede7cd6685e07a4374d1e3aa90445130b

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ __DEV__ &&
14791479
exports.useTransition = function () {
14801480
return resolveDispatcher().useTransition();
14811481
};
1482-
exports.version = "19.2.0-www-classic-12eaef7e-20250623";
1482+
exports.version = "19.2.0-www-classic-94cf60be-20250624";
14831483
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14841484
"function" ===
14851485
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ __DEV__ &&
14791479
exports.useTransition = function () {
14801480
return resolveDispatcher().useTransition();
14811481
};
1482-
exports.version = "19.2.0-www-modern-12eaef7e-20250623";
1482+
exports.version = "19.2.0-www-modern-94cf60be-20250624";
14831483
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14841484
"function" ===
14851485
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.2.0-www-classic-12eaef7e-20250623";
633+
exports.version = "19.2.0-www-classic-94cf60be-20250624";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.2.0-www-modern-12eaef7e-20250623";
633+
exports.version = "19.2.0-www-modern-94cf60be-20250624";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.2.0-www-classic-12eaef7e-20250623";
637+
exports.version = "19.2.0-www-classic-94cf60be-20250624";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.2.0-www-modern-12eaef7e-20250623";
637+
exports.version = "19.2.0-www-modern-94cf60be-20250624";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19059,10 +19059,10 @@ __DEV__ &&
1905919059
(function () {
1906019060
var internals = {
1906119061
bundleType: 1,
19062-
version: "19.2.0-www-classic-12eaef7e-20250623",
19062+
version: "19.2.0-www-classic-94cf60be-20250624",
1906319063
rendererPackageName: "react-art",
1906419064
currentDispatcherRef: ReactSharedInternals,
19065-
reconcilerVersion: "19.2.0-www-classic-12eaef7e-20250623"
19065+
reconcilerVersion: "19.2.0-www-classic-94cf60be-20250624"
1906619066
};
1906719067
internals.overrideHookState = overrideHookState;
1906819068
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19096,7 +19096,7 @@ __DEV__ &&
1909619096
exports.Shape = Shape;
1909719097
exports.Surface = Surface;
1909819098
exports.Text = Text;
19099-
exports.version = "19.2.0-www-classic-12eaef7e-20250623";
19099+
exports.version = "19.2.0-www-classic-94cf60be-20250624";
1910019100
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1910119101
"function" ===
1910219102
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)