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
addcx1developer committed Feb 1, 2025
1 parent 03d11bb commit ea9e061
Show file tree
Hide file tree
Showing 46 changed files with 8,604 additions and 6,543 deletions.
27 changes: 17 additions & 10 deletions compiled/facebook-www/JSXDEVRuntime-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ __DEV__ &&
_key2++
)
args[_key2 - 1] = arguments[_key2];
_len2 = format;
_key2 =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != _key2 &&
_key2.getCurrentStack &&
((_key2 = _key2.getCurrentStack()),
"" !== _key2 && ((_len2 += "%s"), args.push(_key2)));
args.unshift(_len2);
args.unshift(!1);
warningWWW.apply(null, args);
if (enableRemoveConsolePatches) {
var _console2;
(_console2 = console).error.apply(_console2, [format].concat(args));
} else
(_len2 = format),
enableRemoveConsolePatches ||
((_key2 =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE),
null != _key2 &&
_key2.getCurrentStack &&
((_key2 = _key2.getCurrentStack()),
"" !== _key2 && ((_len2 += "%s"), args.push(_key2))),
args.unshift(_len2),
args.unshift(!1),
warningWWW.apply(null, args));
}
function getComponentNameFromType(type) {
if (null == type) return null;
Expand Down Expand Up @@ -727,6 +732,8 @@ __DEV__ &&
REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"),
REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"),
MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
enableRemoveConsolePatches =
require("ReactFeatureFlags").enableRemoveConsolePatches,
warningWWW = require("warning"),
REACT_CLIENT_REFERENCE$2 = Symbol.for("react.client.reference"),
ReactSharedInternals =
Expand Down
27 changes: 17 additions & 10 deletions compiled/facebook-www/JSXDEVRuntime-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ __DEV__ &&
_key2++
)
args[_key2 - 1] = arguments[_key2];
_len2 = format;
_key2 =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != _key2 &&
_key2.getCurrentStack &&
((_key2 = _key2.getCurrentStack()),
"" !== _key2 && ((_len2 += "%s"), args.push(_key2)));
args.unshift(_len2);
args.unshift(!1);
warningWWW.apply(null, args);
if (enableRemoveConsolePatches) {
var _console2;
(_console2 = console).error.apply(_console2, [format].concat(args));
} else
(_len2 = format),
enableRemoveConsolePatches ||
((_key2 =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE),
null != _key2 &&
_key2.getCurrentStack &&
((_key2 = _key2.getCurrentStack()),
"" !== _key2 && ((_len2 += "%s"), args.push(_key2))),
args.unshift(_len2),
args.unshift(!1),
warningWWW.apply(null, args));
}
function getComponentNameFromType(type) {
if (null == type) return null;
Expand Down Expand Up @@ -727,6 +732,8 @@ __DEV__ &&
REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"),
REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"),
MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
enableRemoveConsolePatches =
require("ReactFeatureFlags").enableRemoveConsolePatches,
warningWWW = require("warning"),
REACT_CLIENT_REFERENCE$2 = Symbol.for("react.client.reference"),
ReactSharedInternals =
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0bf1f39ec6906c666011c0c57aa56aa34a262daf
152bfe3769f87e29c8d68cb87fdb608d2483b7f1
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0bf1f39ec6906c666011c0c57aa56aa34a262daf
152bfe3769f87e29c8d68cb87fdb608d2483b7f1
42 changes: 28 additions & 14 deletions compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ __DEV__ &&
_key++
)
args[_key - 1] = arguments[_key];
printWarning("warn", format, args);
if (enableRemoveConsolePatches) {
var _console;
(_console = console).warn.apply(_console, [format].concat(args));
} else printWarning("warn", format, args);
}
function error$jscomp$0(format) {
for (
Expand All @@ -52,18 +55,22 @@ __DEV__ &&
_key2++
)
args[_key2 - 1] = arguments[_key2];
printWarning("error", format, args);
if (enableRemoveConsolePatches) {
var _console2;
(_console2 = console).error.apply(_console2, [format].concat(args));
} else printWarning("error", format, args);
}
function printWarning(level, format, args) {
level =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != level &&
level.getCurrentStack &&
((level = level.getCurrentStack()),
"" !== level && ((format += "%s"), args.push(level)));
args.unshift(format);
args.unshift(!1);
warningWWW.apply(null, args);
enableRemoveConsolePatches ||
((level =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE),
null != level &&
level.getCurrentStack &&
((level = level.getCurrentStack()),
"" !== level && ((format += "%s"), args.push(level))),
args.unshift(format),
args.unshift(!1),
warningWWW.apply(null, args));
}
function warnNoop(publicInstance, callerName) {
publicInstance =
Expand Down Expand Up @@ -685,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 @@ -1139,6 +1147,8 @@ __DEV__ &&
REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"),
REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"),
MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
enableRemoveConsolePatches =
require("ReactFeatureFlags").enableRemoveConsolePatches,
warningWWW = require("warning"),
didWarnStateUpdateForUnmountedComponent = {},
ReactNoopUpdateQueue = {
Expand Down Expand Up @@ -1200,6 +1210,7 @@ __DEV__ &&
A: null,
T: null,
S: null,
V: null,
actQueue: null,
isBatchingLegacy: !1,
didScheduleLegacyUpdate: !1,
Expand Down Expand Up @@ -1280,7 +1291,10 @@ __DEV__ &&
});
}
: enqueueTask,
ReactCompilerRuntime = { c: useMemoCache },
ReactCompilerRuntime = Object.freeze({
__proto__: null,
c: useMemoCache
}),
Children = {
map: mapChildren,
forEach: function (children, forEachFunc, forEachContext) {
Expand Down Expand Up @@ -1944,7 +1958,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.1.0-www-classic-0bf1f39e-20250110";
exports.version = "19.1.0-www-classic-152bfe37-20250131";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
42 changes: 28 additions & 14 deletions compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ __DEV__ &&
_key++
)
args[_key - 1] = arguments[_key];
printWarning("warn", format, args);
if (enableRemoveConsolePatches) {
var _console;
(_console = console).warn.apply(_console, [format].concat(args));
} else printWarning("warn", format, args);
}
function error$jscomp$0(format) {
for (
Expand All @@ -52,18 +55,22 @@ __DEV__ &&
_key2++
)
args[_key2 - 1] = arguments[_key2];
printWarning("error", format, args);
if (enableRemoveConsolePatches) {
var _console2;
(_console2 = console).error.apply(_console2, [format].concat(args));
} else printWarning("error", format, args);
}
function printWarning(level, format, args) {
level =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
null != level &&
level.getCurrentStack &&
((level = level.getCurrentStack()),
"" !== level && ((format += "%s"), args.push(level)));
args.unshift(format);
args.unshift(!1);
warningWWW.apply(null, args);
enableRemoveConsolePatches ||
((level =
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE),
null != level &&
level.getCurrentStack &&
((level = level.getCurrentStack()),
"" !== level && ((format += "%s"), args.push(level))),
args.unshift(format),
args.unshift(!1),
warningWWW.apply(null, args));
}
function warnNoop(publicInstance, callerName) {
publicInstance =
Expand Down Expand Up @@ -685,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 @@ -1139,6 +1147,8 @@ __DEV__ &&
REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"),
REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"),
MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
enableRemoveConsolePatches =
require("ReactFeatureFlags").enableRemoveConsolePatches,
warningWWW = require("warning"),
didWarnStateUpdateForUnmountedComponent = {},
ReactNoopUpdateQueue = {
Expand Down Expand Up @@ -1200,6 +1210,7 @@ __DEV__ &&
A: null,
T: null,
S: null,
V: null,
actQueue: null,
isBatchingLegacy: !1,
didScheduleLegacyUpdate: !1,
Expand Down Expand Up @@ -1280,7 +1291,10 @@ __DEV__ &&
});
}
: enqueueTask,
ReactCompilerRuntime = { c: useMemoCache },
ReactCompilerRuntime = Object.freeze({
__proto__: null,
c: useMemoCache
}),
Children = {
map: mapChildren,
forEach: function (children, forEachFunc, forEachContext) {
Expand Down Expand Up @@ -1944,7 +1958,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.1.0-www-modern-0bf1f39e-20250110";
exports.version = "19.1.0-www-modern-152bfe37-20250131";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
6 changes: 3 additions & 3 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 @@ -364,7 +364,7 @@ var reportGlobalError =
console.error(error);
};
function noop() {}
var ReactCompilerRuntime = { c: useMemoCache },
var ReactCompilerRuntime = { __proto__: null, c: useMemoCache },
experimental_useResourceEffect = enableUseResourceEffectHook
? useResourceEffect
: void 0;
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-0bf1f39e-20250110";
exports.version = "19.1.0-www-classic-152bfe37-20250131";
6 changes: 3 additions & 3 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 @@ -364,7 +364,7 @@ var reportGlobalError =
console.error(error);
};
function noop() {}
var ReactCompilerRuntime = { c: useMemoCache },
var ReactCompilerRuntime = { __proto__: null, c: useMemoCache },
experimental_useResourceEffect = enableUseResourceEffectHook
? useResourceEffect
: void 0;
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-0bf1f39e-20250110";
exports.version = "19.1.0-www-modern-152bfe37-20250131";
6 changes: 3 additions & 3 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 @@ -368,7 +368,7 @@ var reportGlobalError =
console.error(error);
};
function noop() {}
var ReactCompilerRuntime = { c: useMemoCache },
var ReactCompilerRuntime = { __proto__: null, c: useMemoCache },
experimental_useResourceEffect = enableUseResourceEffectHook
? useResourceEffect
: void 0;
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-0bf1f39e-20250110";
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: 3 additions & 3 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 @@ -368,7 +368,7 @@ var reportGlobalError =
console.error(error);
};
function noop() {}
var ReactCompilerRuntime = { c: useMemoCache },
var ReactCompilerRuntime = { __proto__: null, c: useMemoCache },
experimental_useResourceEffect = enableUseResourceEffectHook
? useResourceEffect
: void 0;
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-0bf1f39e-20250110";
exports.version = "19.1.0-www-modern-152bfe37-20250131";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Loading

0 comments on commit ea9e061

Please sign in to comment.