Skip to content

Commit

Permalink
[compiler][rfc] Hacky retry pipeline for fire (facebook#32164)
Browse files Browse the repository at this point in the history
Hacky retry pipeline for when transforming `fire(...)` calls encounters
validation, todo, or memoization invariant bailouts. Would love feedback
on how we implement this to be extensible to other compiler
non-memoization features (e.g. inlineJSX)

Some observations:
- Compiler "front-end" passes (e.g. lower, type, effect, and mutability
inferences) should be shared for all compiler features -- memo and
otherwise
- Many passes (anything dealing with reactive scope ranges, scope blocks
/ dependencies, and optimizations such as ReactiveIR facebook#31974) can be left
out of the retry pipeline. This PR hackily skips memoization features by
removing reactive scope creation, but we probably should restructure the
pipeline to skip these entirely on a retry
- We should maintain a canonical set of "validation flags"

Note the newly added fixtures are prefixed with `bailout-...` when the
retry fire pipeline is used. These fixture outputs contain correctly
inserted `useFire` calls and no memoization.

DiffTrain build for [152bfe3](facebook@152bfe3)
  • Loading branch information
22388o committed Feb 1, 2025
1 parent 709b610 commit 0f0f8e9
Show file tree
Hide file tree
Showing 37 changed files with 4,301 additions and 3,915 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18eaf51bd51fed8dfed661d64c306759101d0bfd
152bfe3769f87e29c8d68cb87fdb608d2483b7f1
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18eaf51bd51fed8dfed661d64c306759101d0bfd
152bfe3769f87e29c8d68cb87fdb608d2483b7f1
6 changes: 4 additions & 2 deletions compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,8 @@ __DEV__ &&
enableOwnerStacks ? oldElement._debugStack : void 0,
enableOwnerStacks ? oldElement._debugTask : void 0
);
newKey._store.validated = oldElement._store.validated;
oldElement._store &&
(newKey._store.validated = oldElement._store.validated);
return newKey;
}
function validateChildKeys(node, parentType) {
Expand Down Expand Up @@ -1209,6 +1210,7 @@ __DEV__ &&
A: null,
T: null,
S: null,
V: null,
actQueue: null,
isBatchingLegacy: !1,
didScheduleLegacyUpdate: !1,
Expand Down Expand Up @@ -1956,7 +1958,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.1.0-www-classic-18eaf51b-20250118";
exports.version = "19.1.0-www-classic-152bfe37-20250131";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
6 changes: 4 additions & 2 deletions compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,8 @@ __DEV__ &&
enableOwnerStacks ? oldElement._debugStack : void 0,
enableOwnerStacks ? oldElement._debugTask : void 0
);
newKey._store.validated = oldElement._store.validated;
oldElement._store &&
(newKey._store.validated = oldElement._store.validated);
return newKey;
}
function validateChildKeys(node, parentType) {
Expand Down Expand Up @@ -1209,6 +1210,7 @@ __DEV__ &&
A: null,
T: null,
S: null,
V: null,
actQueue: null,
isBatchingLegacy: !1,
didScheduleLegacyUpdate: !1,
Expand Down Expand Up @@ -1956,7 +1958,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.1.0-www-modern-18eaf51b-20250118";
exports.version = "19.1.0-www-modern-152bfe37-20250131";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pureComponentPrototype.constructor = PureComponent;
assign(pureComponentPrototype, Component.prototype);
pureComponentPrototype.isPureReactComponent = !0;
var isArrayImpl = Array.isArray,
ReactSharedInternals = { H: null, A: null, T: null, S: null },
ReactSharedInternals = { H: null, A: null, T: null, S: null, V: null },
hasOwnProperty = Object.prototype.hasOwnProperty;
function ReactElement(type, key, self, source, owner, props) {
self = props.ref;
Expand Down Expand Up @@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-classic-18eaf51b-20250118";
exports.version = "19.1.0-www-classic-152bfe37-20250131";
4 changes: 2 additions & 2 deletions compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pureComponentPrototype.constructor = PureComponent;
assign(pureComponentPrototype, Component.prototype);
pureComponentPrototype.isPureReactComponent = !0;
var isArrayImpl = Array.isArray,
ReactSharedInternals = { H: null, A: null, T: null, S: null },
ReactSharedInternals = { H: null, A: null, T: null, S: null, V: null },
hasOwnProperty = Object.prototype.hasOwnProperty;
function ReactElement(type, key, self, source, owner, props) {
self = props.ref;
Expand Down Expand Up @@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-modern-18eaf51b-20250118";
exports.version = "19.1.0-www-modern-152bfe37-20250131";
4 changes: 2 additions & 2 deletions compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pureComponentPrototype.constructor = PureComponent;
assign(pureComponentPrototype, Component.prototype);
pureComponentPrototype.isPureReactComponent = !0;
var isArrayImpl = Array.isArray,
ReactSharedInternals = { H: null, A: null, T: null, S: null },
ReactSharedInternals = { H: null, A: null, T: null, S: null, V: null },
hasOwnProperty = Object.prototype.hasOwnProperty;
function ReactElement(type, key, self, source, owner, props) {
self = props.ref;
Expand Down Expand Up @@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-classic-18eaf51b-20250118";
exports.version = "19.1.0-www-classic-152bfe37-20250131";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pureComponentPrototype.constructor = PureComponent;
assign(pureComponentPrototype, Component.prototype);
pureComponentPrototype.isPureReactComponent = !0;
var isArrayImpl = Array.isArray,
ReactSharedInternals = { H: null, A: null, T: null, S: null },
ReactSharedInternals = { H: null, A: null, T: null, S: null, V: null },
hasOwnProperty = Object.prototype.hasOwnProperty;
function ReactElement(type, key, self, source, owner, props) {
self = props.ref;
Expand Down Expand Up @@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.1.0-www-modern-18eaf51b-20250118";
exports.version = "19.1.0-www-modern-152bfe37-20250131";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
42 changes: 12 additions & 30 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3922,7 +3922,7 @@ __DEV__ &&
),
node.isTransition ||
error$jscomp$0(
"An async function was passed to useActionState, but it was dispatched outside of an action context. This is likely not what you intended. Either pass the dispatch function to an `action` prop, or dispatch manually inside `startTransition`"
"An async function with useActionState was called outside of a transition. This is likely not what you intended (for example, isPending will not update correctly). Either call the returned function inside startTransition, or pass it to an `action` or `formAction` prop."
))
: onActionSuccess(actionQueue, node, returnValue);
}
Expand Down Expand Up @@ -10380,8 +10380,8 @@ __DEV__ &&
}
finishedRoot.effectDuration += popNestedEffectDurations(current);
break;
case 26:
case 27:
case 26:
case 5:
recursivelyTraverseLayoutEffects(finishedRoot, finishedWork);
null === current && flags & 4 && commitHostMount(finishedWork);
Expand Down Expand Up @@ -10917,9 +10917,6 @@ __DEV__ &&
hostParentIsContainer = !1;
break a;
case 3:
hostParent = parent.stateNode.containerInfo;
hostParentIsContainer = !0;
break a;
case 4:
hostParent = parent.stateNode.containerInfo;
hostParentIsContainer = !0;
Expand Down Expand Up @@ -11140,10 +11137,10 @@ __DEV__ &&
? root._visibility & -2
: root._visibility | 1),
suspenseCallback &&
((root = offscreenSubtreeIsHidden || offscreenSubtreeWasHidden),
null === current ||
(null === current ||
retryQueue ||
root ||
offscreenSubtreeIsHidden ||
offscreenSubtreeWasHidden ||
recursivelyTraverseDisappearLayoutEffects(finishedWork)),
null === finishedWork.memoizedProps ||
"manual" !== finishedWork.memoizedProps.mode)
Expand Down Expand Up @@ -11292,8 +11289,8 @@ __DEV__ &&
);
recursivelyTraverseDisappearLayoutEffects(finishedWork);
break;
case 26:
case 27:
case 26:
case 5:
safelyDetachRef(finishedWork, finishedWork.return);
recursivelyTraverseDisappearLayoutEffects(finishedWork);
Expand Down Expand Up @@ -11367,8 +11364,8 @@ __DEV__ &&
commitClassCallbacks(finishedWork);
safelyAttachRef(finishedWork, finishedWork.return);
break;
case 26:
case 27:
case 26:
case 5:
recursivelyTraverseReappearLayoutEffects(
finishedRoot,
Expand Down Expand Up @@ -12469,7 +12466,6 @@ __DEV__ &&
lanes,
workInProgressRootRecoverableErrors,
workInProgressTransitions,
workInProgressAppearingViewTransitions,
workInProgressRootDidIncludeRecursiveRenderUpdate,
workInProgressDeferredLane,
workInProgressRootInterleavedUpdatedLanes,
Expand Down Expand Up @@ -12499,7 +12495,6 @@ __DEV__ &&
forceSync,
workInProgressRootRecoverableErrors,
workInProgressTransitions,
workInProgressAppearingViewTransitions,
workInProgressRootDidIncludeRecursiveRenderUpdate,
lanes,
workInProgressDeferredLane,
Expand All @@ -12520,7 +12515,6 @@ __DEV__ &&
forceSync,
workInProgressRootRecoverableErrors,
workInProgressTransitions,
workInProgressAppearingViewTransitions,
workInProgressRootDidIncludeRecursiveRenderUpdate,
lanes,
workInProgressDeferredLane,
Expand All @@ -12544,7 +12538,6 @@ __DEV__ &&
finishedWork,
recoverableErrors,
transitions,
appearingViewTransitions,
didIncludeRenderPhaseUpdate,
lanes,
spawnedLane,
Expand All @@ -12553,17 +12546,14 @@ __DEV__ &&
) {
root.timeoutHandle = -1;
var subtreeFlags = finishedWork.subtreeFlags;
(subtreeFlags =
subtreeFlags & 8192 || 16785408 === (subtreeFlags & 16785408)) &&
subtreeFlags &&
(subtreeFlags & 8192 || 16785408 === (subtreeFlags & 16785408)) &&
accumulateSuspenseyCommitOnFiber(finishedWork);
commitRoot(
root,
finishedWork,
lanes,
recoverableErrors,
transitions,
appearingViewTransitions,
didIncludeRenderPhaseUpdate,
spawnedLane,
updatedLanes,
Expand Down Expand Up @@ -12688,7 +12678,6 @@ __DEV__ &&
workInProgressRootRecoverableErrors = workInProgressRootConcurrentErrors =
null;
workInProgressRootDidIncludeRecursiveRenderUpdate = !1;
workInProgressAppearingViewTransitions = null;
0 !== (lanes & 8) && (lanes |= lanes & 32);
var allEntangledLanes = root.entangledLanes;
if (0 !== allEntangledLanes)
Expand Down Expand Up @@ -13306,7 +13295,6 @@ __DEV__ &&
lanes,
recoverableErrors,
transitions,
appearingViewTransitions,
didIncludeRenderPhaseUpdate,
spawnedLane,
updatedLanes,
Expand Down Expand Up @@ -13375,12 +13363,7 @@ __DEV__ &&
didIncludeRenderPhaseUpdate = executionContext;
executionContext |= CommitContext;
try {
commitBeforeMutationEffects(
root,
finishedWork,
lanes,
appearingViewTransitions
);
commitBeforeMutationEffects(root, finishedWork, lanes);
} finally {
(executionContext = didIncludeRenderPhaseUpdate),
(currentUpdatePriority = transitions),
Expand Down Expand Up @@ -16691,7 +16674,6 @@ __DEV__ &&
workInProgressSuspendedRetryLanes = 0,
workInProgressRootConcurrentErrors = null,
workInProgressRootRecoverableErrors = null,
workInProgressAppearingViewTransitions = null,
workInProgressRootDidIncludeRecursiveRenderUpdate = !1,
didIncludeCommitPhaseUpdate = !1,
globalMostRecentFallbackTime = 0,
Expand Down Expand Up @@ -16950,10 +16932,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.1.0-www-classic-18eaf51b-20250118",
version: "19.1.0-www-classic-152bfe37-20250131",
rendererPackageName: "react-art",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.1.0-www-classic-18eaf51b-20250118"
reconcilerVersion: "19.1.0-www-classic-152bfe37-20250131"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -16987,7 +16969,7 @@ __DEV__ &&
exports.Shape = Shape;
exports.Surface = Surface;
exports.Text = Text;
exports.version = "19.1.0-www-classic-18eaf51b-20250118";
exports.version = "19.1.0-www-classic-152bfe37-20250131";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Loading

0 comments on commit 0f0f8e9

Please sign in to comment.