Skip to content

Commit

Permalink
[Fiber] Replace setCurrentDebugFiberInDEV with runWithFiberInDEV (#29221
Browse files Browse the repository at this point in the history
)

Stacked on #29044.

To work with `console.createTask(...).run(...)` we need to be able to
run a function in the scope of the task.

The main concern with this, other than general performance, is that it
might add more stack frames on very deep stacks that hit the stack
limit. Such as with the commit phase where we recursively go down the
tree. These callbacks aren't really necessary in the recursive part but
only in the shallow invocation of the commit phase for each tag. So we
could refactor the commit phase so that only the shallow part at each
level is covered this way.

DiffTrain build for commit b078c81.
  • Loading branch information
sebmarkbage committed May 25, 2024
1 parent 43adf5d commit 15d1dee
Show file tree
Hide file tree
Showing 10 changed files with 710 additions and 888 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<e2dd990512e58f23e127175cf13f6c55>>
* @generated SignedSource<<c50a413ebb22fd09d88e5c0cbdee55c9>>
*/

"use strict";
Expand Down Expand Up @@ -8193,57 +8193,56 @@ function performUnitOfWork(unitOfWork) {
null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next);
}
function replaySuspendedUnitOfWork(unitOfWork) {
var current = unitOfWork.alternate;
switch (unitOfWork.tag) {
var next = unitOfWork;
var current = next.alternate;
switch (next.tag) {
case 15:
case 0:
var Component = unitOfWork.type,
unresolvedProps = unitOfWork.pendingProps;
var Component = next.type,
unresolvedProps = next.pendingProps;
unresolvedProps =
unitOfWork.elementType === Component
next.elementType === Component
? unresolvedProps
: resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps);
var context = isContextProvider(Component)
? previousContext
: contextStackCursor$1.current;
context = getMaskedContext(unitOfWork, context);
current = replayFunctionComponent(
context = getMaskedContext(next, context);
next = replayFunctionComponent(
current,
unitOfWork,
next,
unresolvedProps,
Component,
context,
workInProgressRootRenderLanes
);
break;
case 11:
Component = unitOfWork.type.render;
unresolvedProps = unitOfWork.pendingProps;
Component = next.type.render;
unresolvedProps = next.pendingProps;
unresolvedProps =
unitOfWork.elementType === Component
next.elementType === Component
? unresolvedProps
: resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps);
current = replayFunctionComponent(
next = replayFunctionComponent(
current,
unitOfWork,
next,
unresolvedProps,
Component,
unitOfWork.ref,
next.ref,
workInProgressRootRenderLanes
);
break;
case 5:
resetHooksOnUnwind(unitOfWork);
resetHooksOnUnwind(next);
default:
unwindInterruptedWork(current, unitOfWork),
(unitOfWork = workInProgress =
resetWorkInProgress(unitOfWork, entangledRenderLanes)),
(current = beginWork(current, unitOfWork, entangledRenderLanes));
unwindInterruptedWork(current, next),
(next = workInProgress =
resetWorkInProgress(next, entangledRenderLanes)),
(next = beginWork(current, next, entangledRenderLanes));
}
unitOfWork.memoizedProps = unitOfWork.pendingProps;
null === current
? completeUnitOfWork(unitOfWork)
: (workInProgress = current);
null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next);
}
function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) {
resetContextDependencies();
Expand Down Expand Up @@ -9298,19 +9297,19 @@ function wrapFiber(fiber) {
fiberToWrapper.set(fiber, wrapper));
return wrapper;
}
var devToolsConfig$jscomp$inline_1042 = {
var devToolsConfig$jscomp$inline_1047 = {
findFiberByHostInstance: function () {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-rc-c9fc27c4",
version: "19.0.0-rc-96bb2a1a",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1229 = {
bundleType: devToolsConfig$jscomp$inline_1042.bundleType,
version: devToolsConfig$jscomp$inline_1042.version,
rendererPackageName: devToolsConfig$jscomp$inline_1042.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_1042.rendererConfig,
var internals$jscomp$inline_1234 = {
bundleType: devToolsConfig$jscomp$inline_1047.bundleType,
version: devToolsConfig$jscomp$inline_1047.version,
rendererPackageName: devToolsConfig$jscomp$inline_1047.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_1047.rendererConfig,
overrideHookState: null,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
Expand All @@ -9327,26 +9326,26 @@ var internals$jscomp$inline_1229 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
devToolsConfig$jscomp$inline_1042.findFiberByHostInstance ||
devToolsConfig$jscomp$inline_1047.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-rc-c9fc27c4"
reconcilerVersion: "19.0.0-rc-96bb2a1a"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1230 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
var hook$jscomp$inline_1235 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
!hook$jscomp$inline_1230.isDisabled &&
hook$jscomp$inline_1230.supportsFiber
!hook$jscomp$inline_1235.isDisabled &&
hook$jscomp$inline_1235.supportsFiber
)
try {
(rendererID = hook$jscomp$inline_1230.inject(
internals$jscomp$inline_1229
(rendererID = hook$jscomp$inline_1235.inject(
internals$jscomp$inline_1234
)),
(injectedHook = hook$jscomp$inline_1230);
(injectedHook = hook$jscomp$inline_1235);
} catch (err) {}
}
exports._Scheduler = Scheduler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<f18d6d4dff134392d4dfcaa89af16bb0>>
* @generated SignedSource<<9c5c6f7a7a130bf71d8398c6f3e8e036>>
*/

"use strict";
Expand Down Expand Up @@ -8735,60 +8735,60 @@ function performUnitOfWork(unitOfWork) {
: (workInProgress = current);
}
function replaySuspendedUnitOfWork(unitOfWork) {
var current = unitOfWork.alternate,
isProfilingMode = 0 !== (unitOfWork.mode & 2);
isProfilingMode && startProfilerTimer(unitOfWork);
switch (unitOfWork.tag) {
var next = unitOfWork;
var current = next.alternate,
isProfilingMode = 0 !== (next.mode & 2);
isProfilingMode && startProfilerTimer(next);
switch (next.tag) {
case 15:
case 0:
var Component = unitOfWork.type,
unresolvedProps = unitOfWork.pendingProps;
var Component = next.type,
unresolvedProps = next.pendingProps;
unresolvedProps =
unitOfWork.elementType === Component
next.elementType === Component
? unresolvedProps
: resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps);
var context = isContextProvider(Component)
? previousContext
: contextStackCursor$1.current;
context = getMaskedContext(unitOfWork, context);
context = getMaskedContext(next, context);
current = replayFunctionComponent(
current,
unitOfWork,
next,
unresolvedProps,
Component,
context,
workInProgressRootRenderLanes
);
break;
case 11:
Component = unitOfWork.type.render;
unresolvedProps = unitOfWork.pendingProps;
Component = next.type.render;
unresolvedProps = next.pendingProps;
unresolvedProps =
unitOfWork.elementType === Component
next.elementType === Component
? unresolvedProps
: resolveDefaultPropsOnNonClassComponent(Component, unresolvedProps);
current = replayFunctionComponent(
current,
unitOfWork,
next,
unresolvedProps,
Component,
unitOfWork.ref,
next.ref,
workInProgressRootRenderLanes
);
break;
case 5:
resetHooksOnUnwind(unitOfWork);
resetHooksOnUnwind(next);
default:
unwindInterruptedWork(current, unitOfWork),
(unitOfWork = workInProgress =
resetWorkInProgress(unitOfWork, entangledRenderLanes)),
(current = beginWork(current, unitOfWork, entangledRenderLanes));
unwindInterruptedWork(current, next),
(next = workInProgress =
resetWorkInProgress(next, entangledRenderLanes)),
(current = beginWork(current, next, entangledRenderLanes));
}
isProfilingMode && stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0);
isProfilingMode && stopProfilerTimerIfRunningAndRecordDelta(next, !0);
next = current;
unitOfWork.memoizedProps = unitOfWork.pendingProps;
null === current
? completeUnitOfWork(unitOfWork)
: (workInProgress = current);
null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next);
}
function throwAndUnwindWorkLoop(root, unitOfWork, thrownValue) {
resetContextDependencies();
Expand Down Expand Up @@ -9941,12 +9941,12 @@ function wrapFiber(fiber) {
fiberToWrapper.set(fiber, wrapper));
return wrapper;
}
var devToolsConfig$jscomp$inline_1105 = {
var devToolsConfig$jscomp$inline_1111 = {
findFiberByHostInstance: function () {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-rc-77c04414",
version: "19.0.0-rc-6d8ae8ad",
rendererPackageName: "react-test-renderer"
};
(function (internals) {
Expand All @@ -9963,10 +9963,10 @@ var devToolsConfig$jscomp$inline_1105 = {
} catch (err) {}
return hook.checkDCE ? !0 : !1;
})({
bundleType: devToolsConfig$jscomp$inline_1105.bundleType,
version: devToolsConfig$jscomp$inline_1105.version,
rendererPackageName: devToolsConfig$jscomp$inline_1105.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_1105.rendererConfig,
bundleType: devToolsConfig$jscomp$inline_1111.bundleType,
version: devToolsConfig$jscomp$inline_1111.version,
rendererPackageName: devToolsConfig$jscomp$inline_1111.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_1111.rendererConfig,
overrideHookState: null,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
Expand All @@ -9983,14 +9983,14 @@ var devToolsConfig$jscomp$inline_1105 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
devToolsConfig$jscomp$inline_1105.findFiberByHostInstance ||
devToolsConfig$jscomp$inline_1111.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-rc-77c04414"
reconcilerVersion: "19.0.0-rc-6d8ae8ad"
});
exports._Scheduler = Scheduler;
exports.act = act;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d6cfa0f295f4c8b366af15fd20c84e27cdd1fab7
b078c810c787cf13d9bd1958f083b4e3a162a720
Loading

0 comments on commit 15d1dee

Please sign in to comment.