Skip to content

Commit dc2e914

Browse files
committed
[compiler] Remove now-unused FunctionEffect type (#34029)
The new mutation/aliasing model significantly expands on the idea of FunctionEffect. The type (and its usage in HIRFunction.effects) was only necessary for the now-deleted old inference model so we can clean up this code now. DiffTrain build for [5063b32](5063b32)
1 parent e69dea8 commit dc2e914

35 files changed

+96
-124
lines changed

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

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18823,7 +18823,7 @@ function printObjectPropertyKey(key) {
1882318823
}
1882418824
}
1882518825
function printInstructionValue(instrValue) {
18826-
var _a, _b, _c, _d, _e, _f, _g;
18826+
var _a, _b, _c, _d, _e;
1882718827
let value = '';
1882818828
switch (instrValue.kind) {
1882918829
case 'ArrayExpression': {
@@ -18996,18 +18996,8 @@ function printInstructionValue(instrValue) {
1899618996
const context = instrValue.loweredFunc.func.context
1899718997
.map(dep => printPlace(dep))
1899818998
.join(',');
18999-
const effects = (_b = (_a = instrValue.loweredFunc.func.effects) === null || _a === void 0 ? void 0 : _a.map(effect => {
19000-
if (effect.kind === 'ContextMutation') {
19001-
return `ContextMutation places=[${[...effect.places]
19002-
.map(place => printPlace(place))
19003-
.join(', ')}] effect=${effect.effect}`;
19004-
}
19005-
else {
19006-
return `GlobalMutation`;
19007-
}
19008-
}).join(', ')) !== null && _b !== void 0 ? _b : '';
19009-
const aliasingEffects = (_e = (_d = (_c = instrValue.loweredFunc.func.aliasingEffects) === null || _c === void 0 ? void 0 : _c.map(printAliasingEffect)) === null || _d === void 0 ? void 0 : _d.join(', ')) !== null && _e !== void 0 ? _e : '';
19010-
value = `${kind} ${name} @context[${context}] @effects[${effects}] @aliasingEffects=[${aliasingEffects}]\n${fn}`;
18999+
const aliasingEffects = (_c = (_b = (_a = instrValue.loweredFunc.func.aliasingEffects) === null || _a === void 0 ? void 0 : _a.map(printAliasingEffect)) === null || _b === void 0 ? void 0 : _b.join(', ')) !== null && _c !== void 0 ? _c : '';
19000+
value = `${kind} ${name} @context[${context}] @aliasingEffects=[${aliasingEffects}]\n${fn}`;
1901119001
break;
1901219002
}
1901319003
case 'TaggedTemplateExpression': {
@@ -19123,7 +19113,7 @@ function printInstructionValue(instrValue) {
1912319113
break;
1912419114
}
1912519115
case 'StartMemoize': {
19126-
value = `StartMemoize deps=${(_g = (_f = instrValue.deps) === null || _f === void 0 ? void 0 : _f.map(dep => printManualMemoDependency(dep, false))) !== null && _g !== void 0 ? _g : '(none)'}`;
19116+
value = `StartMemoize deps=${(_e = (_d = instrValue.deps) === null || _d === void 0 ? void 0 : _d.map(dep => printManualMemoDependency(dep, false))) !== null && _e !== void 0 ? _e : '(none)'}`;
1912719117
break;
1912819118
}
1912919119
case 'FinishMemoize': {
@@ -48505,14 +48495,14 @@ function emitSelectorFn(env, keys) {
4850548495
returnTypeAnnotation: null,
4850648496
returns: createTemporaryPlace(env, GeneratedSource),
4850748497
context: [],
48508-
effects: null,
4850948498
body: {
4851048499
entry: block.id,
4851148500
blocks: new Map([[block.id, block]]),
4851248501
},
4851348502
generator: false,
4851448503
async: false,
4851548504
directives: [],
48505+
aliasingEffects: [],
4851648506
};
4851748507
reversePostorderBlocks(fn.body);
4851848508
markInstructionIds(fn.body);
@@ -48937,14 +48927,14 @@ function emitOutlinedFn(env, jsx, oldProps, globals) {
4893748927
returnTypeAnnotation: null,
4893848928
returns: createTemporaryPlace(env, GeneratedSource),
4893948929
context: [],
48940-
effects: null,
4894148930
body: {
4894248931
entry: block.id,
4894348932
blocks: new Map([[block.id, block]]),
4894448933
},
4894548934
generator: false,
4894648935
async: false,
4894748936
directives: [],
48937+
aliasingEffects: [],
4894848938
};
4894948939
return fn;
4895048940
}
@@ -49601,14 +49591,13 @@ function validateStaticComponents(fn) {
4960149591
}
4960249592

4960349593
function validateNoFreezingKnownMutableFunctions(fn) {
49604-
var _a;
4960549594
const errors = new CompilerError();
4960649595
const contextMutationEffects = new Map();
4960749596
function visitOperand(operand) {
4960849597
if (operand.effect === Effect.Freeze) {
4960949598
const effect = contextMutationEffects.get(operand.identifier.id);
4961049599
if (effect != null) {
49611-
const place = [...effect.places][0];
49600+
const place = effect.value;
4961249601
const variable = place != null &&
4961349602
place.identifier.name != null &&
4961449603
place.identifier.name.kind === 'named'
@@ -49626,7 +49615,7 @@ function validateNoFreezingKnownMutableFunctions(fn) {
4962649615
})
4962749616
.withDetail({
4962849617
kind: 'error',
49629-
loc: effect.loc,
49618+
loc: effect.value.loc,
4963049619
message: `This modifies ${variable}`,
4963149620
}));
4963249621
}
@@ -49652,19 +49641,7 @@ function validateNoFreezingKnownMutableFunctions(fn) {
4965249641
break;
4965349642
}
4965449643
case 'FunctionExpression': {
49655-
const knownMutation = ((_a = value.loweredFunc.func.effects) !== null && _a !== void 0 ? _a : []).find(effect => {
49656-
return (effect.kind === 'ContextMutation' &&
49657-
(effect.effect === Effect.Store ||
49658-
effect.effect === Effect.Mutate) &&
49659-
Iterable_some(effect.places, place => {
49660-
return (isMutableEffect(place.effect, place.loc) &&
49661-
!isRefOrRefLikeMutableType(place.identifier.type));
49662-
}));
49663-
});
49664-
if (knownMutation && knownMutation.kind === 'ContextMutation') {
49665-
contextMutationEffects.set(lvalue.identifier.id, knownMutation);
49666-
}
49667-
else if (value.loweredFunc.func.aliasingEffects != null) {
49644+
if (value.loweredFunc.func.aliasingEffects != null) {
4966849645
const context = new Set(value.loweredFunc.func.context.map(p => p.identifier.id));
4966949646
effects: for (const effect of value.loweredFunc.func
4967049647
.aliasingEffects) {
@@ -49677,12 +49654,7 @@ function validateNoFreezingKnownMutableFunctions(fn) {
4967749654
}
4967849655
else if (context.has(effect.value.identifier.id) &&
4967949656
!isRefOrRefLikeMutableType(effect.value.identifier.type)) {
49680-
contextMutationEffects.set(lvalue.identifier.id, {
49681-
kind: 'ContextMutation',
49682-
effect: Effect.Mutate,
49683-
loc: effect.value.loc,
49684-
places: new Set([effect.value]),
49685-
});
49657+
contextMutationEffects.set(lvalue.identifier.id, effect);
4968649658
break effects;
4968749659
}
4968849660
break;

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
eaf6adb1277e4cb4f91d1b7f687f773657a5751b
1+
5063b3283fcae4bb43756d0d18d32008e3910bea
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
eaf6adb1277e4cb4f91d1b7f687f773657a5751b
1+
5063b3283fcae4bb43756d0d18d32008e3910bea

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ __DEV__ &&
14091409
exports.useTransition = function () {
14101410
return resolveDispatcher().useTransition();
14111411
};
1412-
exports.version = "19.2.0-www-classic-eaf6adb1-20250815";
1412+
exports.version = "19.2.0-www-classic-5063b328-20250815";
14131413
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14141414
"function" ===
14151415
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
@@ -1409,7 +1409,7 @@ __DEV__ &&
14091409
exports.useTransition = function () {
14101410
return resolveDispatcher().useTransition();
14111411
};
1412-
exports.version = "19.2.0-www-modern-eaf6adb1-20250815";
1412+
exports.version = "19.2.0-www-modern-5063b328-20250815";
14131413
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14141414
"function" ===
14151415
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
@@ -600,4 +600,4 @@ exports.useSyncExternalStore = function (
600600
exports.useTransition = function () {
601601
return ReactSharedInternals.H.useTransition();
602602
};
603-
exports.version = "19.2.0-www-classic-eaf6adb1-20250815";
603+
exports.version = "19.2.0-www-classic-5063b328-20250815";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,4 @@ exports.useSyncExternalStore = function (
600600
exports.useTransition = function () {
601601
return ReactSharedInternals.H.useTransition();
602602
};
603-
exports.version = "19.2.0-www-modern-eaf6adb1-20250815";
603+
exports.version = "19.2.0-www-modern-5063b328-20250815";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.2.0-www-classic-eaf6adb1-20250815";
607+
exports.version = "19.2.0-www-classic-5063b328-20250815";
608608
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
609609
"function" ===
610610
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
@@ -604,7 +604,7 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.2.0-www-modern-eaf6adb1-20250815";
607+
exports.version = "19.2.0-www-modern-5063b328-20250815";
608608
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
609609
"function" ===
610610
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
@@ -19588,10 +19588,10 @@ __DEV__ &&
1958819588
(function () {
1958919589
var internals = {
1959019590
bundleType: 1,
19591-
version: "19.2.0-www-classic-eaf6adb1-20250815",
19591+
version: "19.2.0-www-classic-5063b328-20250815",
1959219592
rendererPackageName: "react-art",
1959319593
currentDispatcherRef: ReactSharedInternals,
19594-
reconcilerVersion: "19.2.0-www-classic-eaf6adb1-20250815"
19594+
reconcilerVersion: "19.2.0-www-classic-5063b328-20250815"
1959519595
};
1959619596
internals.overrideHookState = overrideHookState;
1959719597
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19625,7 +19625,7 @@ __DEV__ &&
1962519625
exports.Shape = Shape;
1962619626
exports.Surface = Surface;
1962719627
exports.Text = Text;
19628-
exports.version = "19.2.0-www-classic-eaf6adb1-20250815";
19628+
exports.version = "19.2.0-www-classic-5063b328-20250815";
1962919629
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1963019630
"function" ===
1963119631
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)