Skip to content

Commit 2a7850d

Browse files
committed
[compiler] clean up retry pipeline: fireRetry flag -> compileMode (#32511)
Removes `EnvironmentConfig.enableMinimalTransformsForRetry` in favor of `run` parameters. This is a minimal difference but lets us explicitly opt out certain compiler passes based on mode parameters, instead of environment configurations Retry flags don't really make sense to have in `EnvironmentConfig` anyways as the config is user-facing API, while retrying is a compiler implementation detail. (per @josephsavona's feedback #32164 (comment)) > Re the "hacky" framing of this in the PR title: I think this is fine. I can see having something like a compilation or output mode that we use when running the pipeline. Rather than changing environment settings when we re-run, various passes could take effect based on the combination of the mode + env flags. The modes might be: > > * Full: transform, validate, memoize. This is the default today. > * Transform: Along the lines of the backup mode in this PR. Only applies transforms that do not require following the rules of React, like `fire()`. > * Validate: This could be used for ESLint. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32511). * #32512 * __->__ #32511 DiffTrain build for [7939d92](7939d92)
1 parent 4a62ea8 commit 2a7850d

35 files changed

+162
-153
lines changed

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

Lines changed: 76 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -43544,7 +43544,6 @@ PERFORMANCE OF THIS SOFTWARE.
4354443544
enableTreatFunctionDepsAsConditional:
4354543545
zod.z["boolean"]()["default"](false),
4354643546
disableMemoizationForDebugging: zod.z["boolean"]()["default"](false),
43547-
enableMinimalTransformsForRetry: zod.z["boolean"]()["default"](false),
4354843547
enableChangeDetectionForDebugging:
4354943548
ExternalFunctionSchema.nullable()["default"](null),
4355043549
enableCustomTypeDefinitionForReanimated:
@@ -43553,21 +43552,11 @@ PERFORMANCE OF THIS SOFTWARE.
4355343552
enableTreatRefLikeIdentifiersAsRefs: zod.z["boolean"]()["default"](false),
4355443553
lowerContextAccess: ExternalFunctionSchema.nullable()["default"](null)
4355543554
});
43556-
var MINIMAL_RETRY_CONFIG = {
43557-
validateHooksUsage: false,
43558-
validateRefAccessDuringRender: false,
43559-
validateNoSetStateInRender: false,
43560-
validateNoSetStateInPassiveEffects: false,
43561-
validateNoJSXInTryStatements: false,
43562-
validateMemoizedEffectDependencies: false,
43563-
validateNoCapitalizedCalls: null,
43564-
validateBlocklistedImports: null,
43565-
enableMinimalTransformsForRetry: true
43566-
};
4356743555
var Environment = /*#__PURE__*/ (function () {
4356843556
function Environment(
4356943557
scope,
4357043558
fnType,
43559+
compilerMode,
4357143560
config,
4357243561
contextIdentifiers,
4357343562
logger,
@@ -43589,6 +43578,7 @@ PERFORMANCE OF THIS SOFTWARE.
4358943578
_Environment_hoistedIdentifiers.set(this, void 0);
4359043579
__classPrivateFieldSet(this, _Environment_scope, scope, "f");
4359143580
this.fnType = fnType;
43581+
this.compilerMode = compilerMode;
4359243582
this.config = config;
4359343583
this.filename = filename;
4359443584
this.code = code;
@@ -43684,6 +43674,12 @@ PERFORMANCE OF THIS SOFTWARE.
4368443674
);
4368543675
}
4368643676
return _createClass(Environment, [
43677+
{
43678+
key: "isInferredMemoEnabled",
43679+
get: function get() {
43680+
return this.compilerMode !== "no_inferred_memo";
43681+
}
43682+
},
4368743683
{
4368843684
key: "nextIdentifierId",
4368943685
get: function get() {
@@ -56116,20 +56112,20 @@ PERFORMANCE OF THIS SOFTWARE.
5611656112
}
5611756113
return functionEffects;
5611856114
}
56119-
function raiseFunctionEffectErrors(functionEffects) {
56120-
functionEffects.forEach(function (eff) {
56115+
function transformFunctionEffectErrors(functionEffects) {
56116+
return functionEffects.map(function (eff) {
5612156117
switch (eff.kind) {
5612256118
case "ReactMutation":
5612356119
case "GlobalMutation": {
56124-
CompilerError["throw"](eff.error);
56120+
return eff.error;
5612556121
}
5612656122
case "ContextMutation": {
56127-
CompilerError["throw"]({
56123+
return {
5612856124
severity: ErrorSeverity.Invariant,
5612956125
reason:
5613056126
"Unexpected ContextMutation in top-level function effects",
5613156127
loc: eff.loc
56132-
});
56128+
};
5613356129
}
5613456130
default:
5613556131
assertExhaustive$1(
@@ -56329,8 +56325,9 @@ PERFORMANCE OF THIS SOFTWARE.
5632956325
}
5633056326
if (options.isFunctionExpression) {
5633156327
fn.effects = functionEffects;
56332-
} else if (!fn.env.config.enableMinimalTransformsForRetry) {
56333-
raiseFunctionEffectErrors(functionEffects);
56328+
return [];
56329+
} else {
56330+
return transformFunctionEffectErrors(functionEffects);
5633456331
}
5633556332
}
5633656333
var InferenceState = /*#__PURE__*/ (function () {
@@ -71650,6 +71647,7 @@ PERFORMANCE OF THIS SOFTWARE.
7165071647
func,
7165171648
config,
7165271649
fnType,
71650+
mode,
7165371651
useMemoCacheIdentifier,
7165471652
logger,
7165571653
filename,
@@ -71660,6 +71658,7 @@ PERFORMANCE OF THIS SOFTWARE.
7166071658
var env = new Environment(
7166171659
func.scope,
7166271660
fnType,
71661+
mode,
7166371662
config,
7166471663
contextIdentifiers,
7166571664
logger,
@@ -71696,10 +71695,10 @@ PERFORMANCE OF THIS SOFTWARE.
7169671695
validateContextVariableLValues(hir);
7169771696
validateUseMemo(hir);
7169871697
if (
71698+
env.isInferredMemoEnabled &&
7169971699
!env.config.enablePreserveExistingManualUseMemo &&
7170071700
!env.config.disableMemoizationForDebugging &&
71701-
!env.config.enableChangeDetectionForDebugging &&
71702-
!env.config.enableMinimalTransformsForRetry
71701+
!env.config.enableChangeDetectionForDebugging
7170371702
) {
7170471703
dropManualMemoization(hir);
7170571704
log({ kind: "hir", name: "DropManualMemoization", value: hir });
@@ -71723,24 +71722,31 @@ PERFORMANCE OF THIS SOFTWARE.
7172371722
log({ kind: "hir", name: "ConstantPropagation", value: hir });
7172471723
inferTypes(hir);
7172571724
log({ kind: "hir", name: "InferTypes", value: hir });
71726-
if (env.config.validateHooksUsage) {
71727-
validateHooksUsage(hir);
71725+
if (env.isInferredMemoEnabled) {
71726+
if (env.config.validateHooksUsage) {
71727+
validateHooksUsage(hir);
71728+
}
71729+
if (env.config.validateNoCapitalizedCalls) {
71730+
validateNoCapitalizedCalls(hir);
71731+
}
7172871732
}
7172971733
if (env.config.enableFire) {
7173071734
transformFire(hir);
7173171735
log({ kind: "hir", name: "TransformFire", value: hir });
7173271736
}
71733-
if (env.config.validateNoCapitalizedCalls) {
71734-
validateNoCapitalizedCalls(hir);
71735-
}
7173671737
if (env.config.lowerContextAccess) {
7173771738
lowerContextAccess(hir, env.config.lowerContextAccess);
7173871739
}
7173971740
optimizePropsMethodCalls(hir);
7174071741
log({ kind: "hir", name: "OptimizePropsMethodCalls", value: hir });
7174171742
analyseFunctions(hir);
7174271743
log({ kind: "hir", name: "AnalyseFunctions", value: hir });
71743-
inferReferenceEffects(hir);
71744+
var fnEffectErrors = inferReferenceEffects(hir);
71745+
if (env.isInferredMemoEnabled) {
71746+
if (fnEffectErrors.length > 0) {
71747+
CompilerError["throw"](fnEffectErrors[0]);
71748+
}
71749+
}
7174471750
log({ kind: "hir", name: "InferReferenceEffects", value: hir });
7174571751
validateLocalsNotReassignedAfterRender(hir);
7174671752
deadCodeElimination(hir);
@@ -71753,23 +71759,25 @@ PERFORMANCE OF THIS SOFTWARE.
7175371759
log({ kind: "hir", name: "PruneMaybeThrows", value: hir });
7175471760
inferMutableRanges(hir);
7175571761
log({ kind: "hir", name: "InferMutableRanges", value: hir });
71756-
if (env.config.assertValidMutableRanges) {
71757-
assertValidMutableRanges(hir);
71758-
}
71759-
if (env.config.validateRefAccessDuringRender) {
71760-
validateNoRefAccessInRender(hir);
71761-
}
71762-
if (env.config.validateNoSetStateInRender) {
71763-
validateNoSetStateInRender(hir);
71764-
}
71765-
if (env.config.validateNoSetStateInPassiveEffects) {
71766-
validateNoSetStateInPassiveEffects(hir);
71767-
}
71768-
if (env.config.validateNoJSXInTryStatements) {
71769-
validateNoJSXInTryStatement(hir);
71770-
}
71771-
if (env.config.validateNoImpureFunctionsInRender) {
71772-
validateNoImpureFunctionsInRender(hir);
71762+
if (env.isInferredMemoEnabled) {
71763+
if (env.config.assertValidMutableRanges) {
71764+
assertValidMutableRanges(hir);
71765+
}
71766+
if (env.config.validateRefAccessDuringRender) {
71767+
validateNoRefAccessInRender(hir);
71768+
}
71769+
if (env.config.validateNoSetStateInRender) {
71770+
validateNoSetStateInRender(hir);
71771+
}
71772+
if (env.config.validateNoSetStateInPassiveEffects) {
71773+
validateNoSetStateInPassiveEffects(hir);
71774+
}
71775+
if (env.config.validateNoJSXInTryStatements) {
71776+
validateNoJSXInTryStatement(hir);
71777+
}
71778+
if (env.config.validateNoImpureFunctionsInRender) {
71779+
validateNoImpureFunctionsInRender(hir);
71780+
}
7177371781
}
7177471782
inferReactivePlaces(hir);
7177571783
log({ kind: "hir", name: "InferReactivePlaces", value: hir });
@@ -71781,7 +71789,7 @@ PERFORMANCE OF THIS SOFTWARE.
7178171789
});
7178271790
propagatePhiTypes(hir);
7178371791
log({ kind: "hir", name: "PropagatePhiTypes", value: hir });
71784-
if (!env.config.enableMinimalTransformsForRetry) {
71792+
if (env.isInferredMemoEnabled) {
7178571793
inferReactiveScopeVariables(hir);
7178671794
log({ kind: "hir", name: "InferReactiveScopeVariables", value: hir });
7178771795
}
@@ -71964,6 +71972,7 @@ PERFORMANCE OF THIS SOFTWARE.
7196471972
func,
7196571973
config,
7196671974
fnType,
71975+
mode,
7196771976
useMemoCacheIdentifier,
7196871977
logger,
7196971978
filename,
@@ -71973,6 +71982,7 @@ PERFORMANCE OF THIS SOFTWARE.
7197371982
func,
7197471983
config,
7197571984
fnType,
71985+
mode,
7197671986
useMemoCacheIdentifier,
7197771987
logger,
7197871988
filename,
@@ -72449,27 +72459,7 @@ PERFORMANCE OF THIS SOFTWARE.
7244972459
fn,
7245072460
environment,
7245172461
fnType,
72452-
useMemoCacheIdentifier.name,
72453-
pass.opts.logger,
72454-
pass.filename,
72455-
pass.code
72456-
)
72457-
};
72458-
} catch (err) {
72459-
compileResult = { kind: "error", error: err };
72460-
}
72461-
}
72462-
if (compileResult.kind === "error" && environment.enableFire) {
72463-
try {
72464-
compileResult = {
72465-
kind: "compile",
72466-
compiledFn: compileFn(
72467-
fn,
72468-
Object.assign(
72469-
Object.assign({}, environment),
72470-
MINIMAL_RETRY_CONFIG
72471-
),
72472-
fnType,
72462+
"all_features",
7247372463
useMemoCacheIdentifier.name,
7247472464
pass.opts.logger,
7247572465
pass.filename,
@@ -72494,7 +72484,26 @@ PERFORMANCE OF THIS SOFTWARE.
7249472484
(_b = fn.node.loc) !== null && _b !== void 0 ? _b : null
7249572485
);
7249672486
}
72497-
return null;
72487+
if (!environment.enableFire) {
72488+
return null;
72489+
}
72490+
try {
72491+
compileResult = {
72492+
kind: "compile",
72493+
compiledFn: compileFn(
72494+
fn,
72495+
environment,
72496+
fnType,
72497+
"no_inferred_memo",
72498+
useMemoCacheIdentifier.name,
72499+
pass.opts.logger,
72500+
pass.filename,
72501+
pass.code
72502+
)
72503+
};
72504+
} catch (err) {
72505+
return null;
72506+
}
7249872507
}
7249972508
(_c = pass.opts.logger) === null || _c === void 0
7250072509
? void 0

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d92e5713be2dc78f467c31fce4a1e5c84a74e4e6
1+
7939d92fcc95ad5ee719c38272eaef14a3750fc0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d92e5713be2dc78f467c31fce4a1e5c84a74e4e6
1+
7939d92fcc95ad5ee719c38272eaef14a3750fc0

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ __DEV__ &&
15321532
exports.useTransition = function () {
15331533
return resolveDispatcher().useTransition();
15341534
};
1535-
exports.version = "19.1.0-www-classic-d92e5713-20250313";
1535+
exports.version = "19.1.0-www-classic-7939d92f-20250313";
15361536
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15371537
"function" ===
15381538
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
@@ -1532,7 +1532,7 @@ __DEV__ &&
15321532
exports.useTransition = function () {
15331533
return resolveDispatcher().useTransition();
15341534
};
1535-
exports.version = "19.1.0-www-modern-d92e5713-20250313";
1535+
exports.version = "19.1.0-www-modern-7939d92f-20250313";
15361536
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15371537
"function" ===
15381538
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
@@ -641,4 +641,4 @@ exports.useSyncExternalStore = function (
641641
exports.useTransition = function () {
642642
return ReactSharedInternals.H.useTransition();
643643
};
644-
exports.version = "19.1.0-www-classic-d92e5713-20250313";
644+
exports.version = "19.1.0-www-classic-7939d92f-20250313";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,4 +641,4 @@ exports.useSyncExternalStore = function (
641641
exports.useTransition = function () {
642642
return ReactSharedInternals.H.useTransition();
643643
};
644-
exports.version = "19.1.0-www-modern-d92e5713-20250313";
644+
exports.version = "19.1.0-www-modern-7939d92f-20250313";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ exports.useSyncExternalStore = function (
645645
exports.useTransition = function () {
646646
return ReactSharedInternals.H.useTransition();
647647
};
648-
exports.version = "19.1.0-www-classic-d92e5713-20250313";
648+
exports.version = "19.1.0-www-classic-7939d92f-20250313";
649649
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
650650
"function" ===
651651
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
@@ -645,7 +645,7 @@ exports.useSyncExternalStore = function (
645645
exports.useTransition = function () {
646646
return ReactSharedInternals.H.useTransition();
647647
};
648-
exports.version = "19.1.0-www-modern-d92e5713-20250313";
648+
exports.version = "19.1.0-www-modern-7939d92f-20250313";
649649
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
650650
"function" ===
651651
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
@@ -18546,10 +18546,10 @@ __DEV__ &&
1854618546
(function () {
1854718547
var internals = {
1854818548
bundleType: 1,
18549-
version: "19.1.0-www-classic-d92e5713-20250313",
18549+
version: "19.1.0-www-classic-7939d92f-20250313",
1855018550
rendererPackageName: "react-art",
1855118551
currentDispatcherRef: ReactSharedInternals,
18552-
reconcilerVersion: "19.1.0-www-classic-d92e5713-20250313"
18552+
reconcilerVersion: "19.1.0-www-classic-7939d92f-20250313"
1855318553
};
1855418554
internals.overrideHookState = overrideHookState;
1855518555
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -18583,7 +18583,7 @@ __DEV__ &&
1858318583
exports.Shape = Shape;
1858418584
exports.Surface = Surface;
1858518585
exports.Text = Text;
18586-
exports.version = "19.1.0-www-classic-d92e5713-20250313";
18586+
exports.version = "19.1.0-www-classic-7939d92f-20250313";
1858718587
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1858818588
"function" ===
1858918589
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)