Skip to content

Commit 5ff280d

Browse files
committed
[Perf Tracks] Prevent crash when accessing $$typeof (facebook#35679)
DiffTrain build for [6853d7a](facebook@6853d7a)
1 parent 1ae28fa commit 5ff280d

35 files changed

+193
-123
lines changed

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

Lines changed: 107 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19127,8 +19127,7 @@ function printTerminal(terminal) {
1912719127
break;
1912819128
}
1912919129
case 'maybe-throw': {
19130-
const handlerStr = terminal.handler !== null ? `bb${terminal.handler}` : '(none)';
19131-
value = `[${terminal.id}] MaybeThrow continuation=bb${terminal.continuation} handler=${handlerStr}`;
19130+
value = `[${terminal.id}] MaybeThrow continuation=bb${terminal.continuation} handler=bb${terminal.handler}`;
1913219131
if (terminal.effects != null) {
1913319132
value += `\n ${terminal.effects.map(printAliasingEffect).join('\n ')}`;
1913419133
}
@@ -20530,7 +20529,7 @@ function mapTerminalSuccessors(terminal, fn) {
2053020529
}
2053120530
case 'maybe-throw': {
2053220531
const continuation = fn(terminal.continuation);
20533-
const handler = terminal.handler !== null ? fn(terminal.handler) : null;
20532+
const handler = fn(terminal.handler);
2053420533
return {
2053520534
kind: 'maybe-throw',
2053620535
continuation,
@@ -20681,9 +20680,7 @@ function* eachTerminalSuccessor(terminal) {
2068120680
}
2068220681
case 'maybe-throw': {
2068320682
yield terminal.continuation;
20684-
if (terminal.handler !== null) {
20685-
yield terminal.handler;
20686-
}
20683+
yield terminal.handler;
2068720684
break;
2068820685
}
2068920686
case 'try': {
@@ -34224,7 +34221,13 @@ function pruneMaybeThrowsImpl(fn) {
3422434221
if (!canThrow) {
3422534222
const source = (_a = terminalMapping.get(block.id)) !== null && _a !== void 0 ? _a : block.id;
3422634223
terminalMapping.set(terminal.continuation, source);
34227-
terminal.handler = null;
34224+
block.terminal = {
34225+
kind: 'goto',
34226+
block: terminal.continuation,
34227+
variant: GotoVariant.Break,
34228+
id: terminal.id,
34229+
loc: terminal.loc,
34230+
};
3422834231
}
3422934232
}
3423034233
return terminalMapping.size > 0 ? terminalMapping : null;
@@ -35418,31 +35421,6 @@ class Driver {
3541835421
};
3541935422
return { block: blockId, place, value: sequence, id: instr.id };
3542035423
}
35421-
valueBlockResultToSequence(result, loc) {
35422-
const instructions = [];
35423-
let innerValue = result.value;
35424-
while (innerValue.kind === 'SequenceExpression') {
35425-
instructions.push(...innerValue.instructions);
35426-
innerValue = innerValue.value;
35427-
}
35428-
const isLoadOfSamePlace = innerValue.kind === 'LoadLocal' &&
35429-
innerValue.place.identifier.id === result.place.identifier.id;
35430-
if (!isLoadOfSamePlace) {
35431-
instructions.push({
35432-
id: result.id,
35433-
lvalue: result.place,
35434-
value: innerValue,
35435-
loc,
35436-
});
35437-
}
35438-
return {
35439-
kind: 'SequenceExpression',
35440-
instructions,
35441-
id: result.id,
35442-
value: { kind: 'Primitive', value: undefined, loc },
35443-
loc,
35444-
};
35445-
}
3544635424
traverseBlock(block) {
3544735425
const blockValue = [];
3544835426
this.visitBlock(block, blockValue);
@@ -35695,7 +35673,30 @@ class Driver {
3569535673
const scheduleId = this.cx.scheduleLoop(terminal.fallthrough, (_a = terminal.update) !== null && _a !== void 0 ? _a : terminal.test, terminal.loop);
3569635674
scheduleIds.push(scheduleId);
3569735675
const init = this.visitValueBlock(terminal.init, terminal.loc);
35698-
const initValue = this.valueBlockResultToSequence(init, terminal.loc);
35676+
const initBlock = this.cx.ir.blocks.get(init.block);
35677+
let initValue = init.value;
35678+
if (initValue.kind === 'SequenceExpression') {
35679+
const last = initBlock.instructions.at(-1);
35680+
initValue.instructions.push(last);
35681+
initValue.value = {
35682+
kind: 'Primitive',
35683+
value: undefined,
35684+
loc: terminal.loc,
35685+
};
35686+
}
35687+
else {
35688+
initValue = {
35689+
kind: 'SequenceExpression',
35690+
instructions: [initBlock.instructions.at(-1)],
35691+
id: terminal.id,
35692+
loc: terminal.loc,
35693+
value: {
35694+
kind: 'Primitive',
35695+
value: undefined,
35696+
loc: terminal.loc,
35697+
},
35698+
};
35699+
}
3569935700
const testValue = this.visitValueBlock(terminal.test, terminal.loc).value;
3570035701
const updateValue = terminal.update !== null
3570135702
? this.visitValueBlock(terminal.update, terminal.loc).value
@@ -35740,9 +35741,55 @@ class Driver {
3574035741
const scheduleId = this.cx.scheduleLoop(terminal.fallthrough, terminal.init, terminal.loop);
3574135742
scheduleIds.push(scheduleId);
3574235743
const init = this.visitValueBlock(terminal.init, terminal.loc);
35743-
const initValue = this.valueBlockResultToSequence(init, terminal.loc);
35744+
const initBlock = this.cx.ir.blocks.get(init.block);
35745+
let initValue = init.value;
35746+
if (initValue.kind === 'SequenceExpression') {
35747+
const last = initBlock.instructions.at(-1);
35748+
initValue.instructions.push(last);
35749+
initValue.value = {
35750+
kind: 'Primitive',
35751+
value: undefined,
35752+
loc: terminal.loc,
35753+
};
35754+
}
35755+
else {
35756+
initValue = {
35757+
kind: 'SequenceExpression',
35758+
instructions: [initBlock.instructions.at(-1)],
35759+
id: terminal.id,
35760+
loc: terminal.loc,
35761+
value: {
35762+
kind: 'Primitive',
35763+
value: undefined,
35764+
loc: terminal.loc,
35765+
},
35766+
};
35767+
}
3574435768
const test = this.visitValueBlock(terminal.test, terminal.loc);
35745-
const testValue = this.valueBlockResultToSequence(test, terminal.loc);
35769+
const testBlock = this.cx.ir.blocks.get(test.block);
35770+
let testValue = test.value;
35771+
if (testValue.kind === 'SequenceExpression') {
35772+
const last = testBlock.instructions.at(-1);
35773+
testValue.instructions.push(last);
35774+
testValue.value = {
35775+
kind: 'Primitive',
35776+
value: undefined,
35777+
loc: terminal.loc,
35778+
};
35779+
}
35780+
else {
35781+
testValue = {
35782+
kind: 'SequenceExpression',
35783+
instructions: [testBlock.instructions.at(-1)],
35784+
id: terminal.id,
35785+
loc: terminal.loc,
35786+
value: {
35787+
kind: 'Primitive',
35788+
value: undefined,
35789+
loc: terminal.loc,
35790+
},
35791+
};
35792+
}
3574635793
let loopBody;
3574735794
if (loopId) {
3574835795
loopBody = this.traverseBlock(this.cx.ir.blocks.get(loopId));
@@ -35782,7 +35829,30 @@ class Driver {
3578235829
const scheduleId = this.cx.scheduleLoop(terminal.fallthrough, terminal.init, terminal.loop);
3578335830
scheduleIds.push(scheduleId);
3578435831
const init = this.visitValueBlock(terminal.init, terminal.loc);
35785-
const initValue = this.valueBlockResultToSequence(init, terminal.loc);
35832+
const initBlock = this.cx.ir.blocks.get(init.block);
35833+
let initValue = init.value;
35834+
if (initValue.kind === 'SequenceExpression') {
35835+
const last = initBlock.instructions.at(-1);
35836+
initValue.instructions.push(last);
35837+
initValue.value = {
35838+
kind: 'Primitive',
35839+
value: undefined,
35840+
loc: terminal.loc,
35841+
};
35842+
}
35843+
else {
35844+
initValue = {
35845+
kind: 'SequenceExpression',
35846+
instructions: [initBlock.instructions.at(-1)],
35847+
id: terminal.id,
35848+
loc: terminal.loc,
35849+
value: {
35850+
kind: 'Primitive',
35851+
value: undefined,
35852+
loc: terminal.loc,
35853+
},
35854+
};
35855+
}
3578635856
let loopBody;
3578735857
if (loopId) {
3578835858
loopBody = this.traverseBlock(this.cx.ir.blocks.get(loopId));
@@ -39651,7 +39721,7 @@ function inferBlock(context, state, block) {
3965139721
if (terminal.kind === 'try' && terminal.handlerBinding != null) {
3965239722
context.catchHandlers.set(terminal.handler, terminal.handlerBinding);
3965339723
}
39654-
else if (terminal.kind === 'maybe-throw' && terminal.handler !== null) {
39724+
else if (terminal.kind === 'maybe-throw') {
3965539725
const handlerParam = context.catchHandlers.get(terminal.handler);
3965639726
if (handlerParam != null) {
3965739727
CompilerError.invariant(state.kind(handlerParam) != null, {

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3ce1316b05968d2a8cffe42a110f2726f2c44c3e
1+
6853d7ab2f73989f31fb5a8ed652bd58225ead26
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3ce1316b05968d2a8cffe42a110f2726f2c44c3e
1+
6853d7ab2f73989f31fb5a8ed652bd58225ead26

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ __DEV__ &&
14821482
exports.useTransition = function () {
14831483
return resolveDispatcher().useTransition();
14841484
};
1485-
exports.version = "19.3.0-www-classic-3ce1316b-20260203";
1485+
exports.version = "19.3.0-www-classic-6853d7ab-20260203";
14861486
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14871487
"function" ===
14881488
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
@@ -1482,7 +1482,7 @@ __DEV__ &&
14821482
exports.useTransition = function () {
14831483
return resolveDispatcher().useTransition();
14841484
};
1485-
exports.version = "19.3.0-www-modern-3ce1316b-20260203";
1485+
exports.version = "19.3.0-www-modern-6853d7ab-20260203";
14861486
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14871487
"function" ===
14881488
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
@@ -610,4 +610,4 @@ exports.useSyncExternalStore = function (
610610
exports.useTransition = function () {
611611
return ReactSharedInternals.H.useTransition();
612612
};
613-
exports.version = "19.3.0-www-classic-3ce1316b-20260203";
613+
exports.version = "19.3.0-www-classic-6853d7ab-20260203";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,4 +610,4 @@ exports.useSyncExternalStore = function (
610610
exports.useTransition = function () {
611611
return ReactSharedInternals.H.useTransition();
612612
};
613-
exports.version = "19.3.0-www-modern-3ce1316b-20260203";
613+
exports.version = "19.3.0-www-modern-6853d7ab-20260203";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ exports.useSyncExternalStore = function (
614614
exports.useTransition = function () {
615615
return ReactSharedInternals.H.useTransition();
616616
};
617-
exports.version = "19.3.0-www-classic-3ce1316b-20260203";
617+
exports.version = "19.3.0-www-classic-6853d7ab-20260203";
618618
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
619619
"function" ===
620620
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
@@ -614,7 +614,7 @@ exports.useSyncExternalStore = function (
614614
exports.useTransition = function () {
615615
return ReactSharedInternals.H.useTransition();
616616
};
617-
exports.version = "19.3.0-www-modern-3ce1316b-20260203";
617+
exports.version = "19.3.0-www-modern-6853d7ab-20260203";
618618
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
619619
"function" ===
620620
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
@@ -20375,10 +20375,10 @@ __DEV__ &&
2037520375
(function () {
2037620376
var internals = {
2037720377
bundleType: 1,
20378-
version: "19.3.0-www-classic-3ce1316b-20260203",
20378+
version: "19.3.0-www-classic-6853d7ab-20260203",
2037920379
rendererPackageName: "react-art",
2038020380
currentDispatcherRef: ReactSharedInternals,
20381-
reconcilerVersion: "19.3.0-www-classic-3ce1316b-20260203"
20381+
reconcilerVersion: "19.3.0-www-classic-6853d7ab-20260203"
2038220382
};
2038320383
internals.overrideHookState = overrideHookState;
2038420384
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -20413,7 +20413,7 @@ __DEV__ &&
2041320413
exports.Shape = Shape;
2041420414
exports.Surface = Surface;
2041520415
exports.Text = Text;
20416-
exports.version = "19.3.0-www-classic-3ce1316b-20260203";
20416+
exports.version = "19.3.0-www-classic-6853d7ab-20260203";
2041720417
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2041820418
"function" ===
2041920419
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)