Skip to content

Commit 59b07a2

Browse files
committed
[compiler] Consolidate HIRFunction return information (#33640)
We now have `HIRFunction.returns: Place` as well as `returnType: Type`. I want to add additional return information, so as a first step i'm consolidating everything under an object at `HIRFunction.returns: {place: Place}`. We use the type of this place as the return type. Next step is to add more properties to this object to represent things like the return kind. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33640). * #33643 * #33642 * __->__ #33640 * #33625 * #33624 DiffTrain build for [123ff13](123ff13)
1 parent ab9cbb6 commit 59b07a2

35 files changed

+99
-99
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27076,6 +27076,9 @@ function printFunction(fn) {
2707627076
if (fn.id !== null) {
2707727077
definition += fn.id;
2707827078
}
27079+
else {
27080+
definition += '<<anonymous>>';
27081+
}
2707927082
if (fn.params.length !== 0) {
2708027083
definition +=
2708127084
'(' +
@@ -27094,10 +27097,8 @@ function printFunction(fn) {
2709427097
else {
2709527098
definition += '()';
2709627099
}
27097-
if (definition.length !== 0) {
27098-
output.push(definition);
27099-
}
27100-
output.push(`: ${printType(fn.returnType)} @ ${printPlace(fn.returns)}`);
27100+
definition += `: ${printPlace(fn.returns)}`;
27101+
output.push(definition);
2710127102
output.push(...fn.directives);
2710227103
output.push(printHIR(fn.body));
2710327104
return output.join('\n');
@@ -30922,7 +30923,6 @@ function lower$1(func, env, bindings = null, capturedRefs = new Map()) {
3092230923
params,
3092330924
fnType: bindings == null ? env.fnType : 'Other',
3092430925
returnTypeAnnotation: null,
30925-
returnType: makeType(),
3092630926
returns: createTemporaryPlace(env, (_b = func.node.loc) !== null && _b !== void 0 ? _b : GeneratedSource),
3092730927
body: builder.build(),
3092830928
context,
@@ -51683,12 +51683,13 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
5168351683
}
5168451684
}
5168551685
}
51686+
const returns = fn.returns.identifier;
5168651687
functionEffects.push({
5168751688
kind: 'Create',
5168851689
into: fn.returns,
51689-
value: fn.returnType.kind === 'Primitive'
51690+
value: isPrimitiveType(returns)
5169051691
? ValueKind.Primitive
51691-
: isJsxType(fn.returnType)
51692+
: isJsxType(returns.type)
5169251693
? ValueKind.Frozen
5169351694
: ValueKind.Mutable,
5169451695
reason: ValueReason.KnownReturnSignature,
@@ -55272,7 +55273,8 @@ function apply(func, unifier) {
5527255273
}
5527355274
}
5527455275
}
55275-
func.returnType = unifier.get(func.returnType);
55276+
const returns = func.returns.identifier;
55277+
returns.type = unifier.get(returns.type);
5527655278
}
5527755279
function equation(left, right) {
5527855280
return {
@@ -55314,13 +55316,13 @@ function* generate(func) {
5531455316
}
5531555317
}
5531655318
if (returnTypes.length > 1) {
55317-
yield equation(func.returnType, {
55319+
yield equation(func.returns.identifier.type, {
5531855320
kind: 'Phi',
5531955321
operands: returnTypes,
5532055322
});
5532155323
}
5532255324
else if (returnTypes.length === 1) {
55323-
yield equation(func.returnType, returnTypes[0]);
55325+
yield equation(func.returns.identifier.type, returnTypes[0]);
5532455326
}
5532555327
}
5532655328
function setName(names, id, name) {
@@ -55531,7 +55533,7 @@ function* generateInstructionTypes(env, names, instr) {
5553155533
yield equation(left, {
5553255534
kind: 'Function',
5553355535
shapeId: BuiltInFunctionId,
55534-
return: value.loweredFunc.func.returnType,
55536+
return: value.loweredFunc.func.returns.identifier.type,
5553555537
isConstructor: false,
5553655538
});
5553755539
break;
@@ -57674,7 +57676,6 @@ function emitSelectorFn(env, keys) {
5767457676
env,
5767557677
params: [obj],
5767657678
returnTypeAnnotation: null,
57677-
returnType: makeType(),
5767857679
returns: createTemporaryPlace(env, GeneratedSource),
5767957680
context: [],
5768057681
effects: null,
@@ -58092,7 +58093,6 @@ function emitOutlinedFn(env, jsx, oldProps, globals) {
5809258093
env,
5809358094
params: [propsObj],
5809458095
returnTypeAnnotation: null,
58095-
returnType: makeType(),
5809658096
returns: createTemporaryPlace(env, GeneratedSource),
5809758097
context: [],
5809858098
effects: null,

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e130c08b06470b5fc4ec8095310d19e782924427
1+
123ff13b193cd361a61b99056dd08f2decd7f55d
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e130c08b06470b5fc4ec8095310d19e782924427
1+
123ff13b193cd361a61b99056dd08f2decd7f55d

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-e130c08b-20250625";
1482+
exports.version = "19.2.0-www-classic-123ff13b-20250625";
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-e130c08b-20250625";
1482+
exports.version = "19.2.0-www-modern-123ff13b-20250625";
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-e130c08b-20250625";
633+
exports.version = "19.2.0-www-classic-123ff13b-20250625";

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-e130c08b-20250625";
633+
exports.version = "19.2.0-www-modern-123ff13b-20250625";

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-e130c08b-20250625";
637+
exports.version = "19.2.0-www-classic-123ff13b-20250625";
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-e130c08b-20250625";
637+
exports.version = "19.2.0-www-modern-123ff13b-20250625";
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
@@ -19073,10 +19073,10 @@ __DEV__ &&
1907319073
(function () {
1907419074
var internals = {
1907519075
bundleType: 1,
19076-
version: "19.2.0-www-classic-e130c08b-20250625",
19076+
version: "19.2.0-www-classic-123ff13b-20250625",
1907719077
rendererPackageName: "react-art",
1907819078
currentDispatcherRef: ReactSharedInternals,
19079-
reconcilerVersion: "19.2.0-www-classic-e130c08b-20250625"
19079+
reconcilerVersion: "19.2.0-www-classic-123ff13b-20250625"
1908019080
};
1908119081
internals.overrideHookState = overrideHookState;
1908219082
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19110,7 +19110,7 @@ __DEV__ &&
1911019110
exports.Shape = Shape;
1911119111
exports.Surface = Surface;
1911219112
exports.Text = Text;
19113-
exports.version = "19.2.0-www-classic-e130c08b-20250625";
19113+
exports.version = "19.2.0-www-classic-123ff13b-20250625";
1911419114
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1911519115
"function" ===
1911619116
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)