Skip to content

Commit

Permalink
Remove execution context check from shouldProfile (#30971)
Browse files Browse the repository at this point in the history
I don't know why this is here since all these callsites are within the
CommitWork/CommitEffects helpers.

This should help with inlining.

DiffTrain build for commit 8152e5c.
  • Loading branch information
sebmarkbage committed Sep 16, 2024
1 parent 4c48f1f commit 52878f5
Show file tree
Hide file tree
Showing 14 changed files with 291 additions and 327 deletions.
2 changes: 1 addition & 1 deletion compiled-rn/VERSION_NATIVE_FB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.0.0-native-fb-26855e46-20240916
19.0.0-native-fb-8152e5cd-20240916
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<f8a96fa0f2e72cb61ce052e8a5718a5b>>
* @generated SignedSource<<13016889a9d577c3ebecd5eeb820686d>>
*/

"use strict";
Expand Down Expand Up @@ -8512,10 +8512,7 @@ __DEV__ &&
}
}
function shouldProfile$1(current) {
return (
0 !== (current.mode & 2) &&
(executionContext & CommitContext) !== NoContext
);
return 0 !== (current.mode & 2);
}
function commitHookLayoutEffects(finishedWork, hookFlags) {
shouldProfile$1(finishedWork)
Expand Down Expand Up @@ -8897,26 +8894,6 @@ __DEV__ &&
commitTime
);
}
function commitProfilerUpdate(
finishedWork,
current,
commitTime,
effectDuration
) {
if (executionContext & CommitContext)
try {
runWithFiberInDEV(
finishedWork,
commitProfiler,
finishedWork,
current,
commitTime,
effectDuration
);
} catch (error$20) {
captureCommitPhaseError(finishedWork, finishedWork.return, error$20);
}
}
function commitProfilerPostCommitImpl(
finishedWork,
current,
Expand Down Expand Up @@ -9046,12 +9023,6 @@ __DEV__ &&
);
}
}
function shouldProfile(current) {
return (
0 !== (current.mode & 2) &&
(executionContext & CommitContext) !== NoContext
);
}
function commitBeforeMutationEffects(root, firstChild) {
for (nextEffect = firstChild; null !== nextEffect; )
if (
Expand Down Expand Up @@ -9234,14 +9205,26 @@ __DEV__ &&
break;
case 12:
recursivelyTraverseLayoutEffects(finishedRoot, finishedWork);
if (flags & 4)
a: for (
flags = finishedWork.stateNode.effectDuration,
commitProfilerUpdate(finishedWork, current, commitTime, flags),
finishedWork = finishedWork.return;
null !== finishedWork;

) {
if (flags & 4) {
flags = finishedWork.stateNode.effectDuration;
try {
runWithFiberInDEV(
finishedWork,
commitProfiler,
finishedWork,
current,
commitTime,
flags
);
} catch (error$20) {
captureCommitPhaseError(
finishedWork,
finishedWork.return,
error$20
);
}
finishedWork = finishedWork.return;
a: for (; null !== finishedWork; ) {
switch (finishedWork.tag) {
case 3:
finishedWork.stateNode.effectDuration += flags;
Expand All @@ -9252,6 +9235,7 @@ __DEV__ &&
}
finishedWork = finishedWork.return;
}
}
break;
case 13:
recursivelyTraverseLayoutEffects(finishedRoot, finishedWork);
Expand Down Expand Up @@ -9438,7 +9422,7 @@ __DEV__ &&
: offscreenSubtreeWasHidden ||
(tag & Layout) === NoFlags ||
(markComponentLayoutEffectUnmountStarted(deletedFiber),
shouldProfile(deletedFiber)
0 !== (deletedFiber.mode & 2)
? (startLayoutEffectTimer(),
(inst.destroy = void 0),
runWithFiberInDEV(
Expand Down Expand Up @@ -9608,7 +9592,7 @@ __DEV__ &&
finishedWork.return
),
commitHookEffectListMount(Insertion | HasEffect, finishedWork),
shouldProfile(finishedWork)
0 !== (finishedWork.mode & 2)
? (startLayoutEffectTimer(),
commitHookEffectListUnmount(
Layout | HasEffect,
Expand Down Expand Up @@ -9895,7 +9879,7 @@ __DEV__ &&
case 11:
case 14:
case 15:
if (shouldProfile(finishedWork))
if (0 !== (finishedWork.mode & 2))
try {
startLayoutEffectTimer(),
commitHookEffectListUnmount(
Expand Down Expand Up @@ -10013,20 +9997,27 @@ __DEV__ &&
finishedWork,
includeWorkInProgressEffects
);
if (includeWorkInProgressEffects && flags & 4)
a: for (
includeWorkInProgressEffects =
finishedWork.stateNode.effectDuration,
commitProfilerUpdate(
finishedWork,
current,
commitTime,
includeWorkInProgressEffects
),
finishedWork = finishedWork.return;
null !== finishedWork;

) {
if (includeWorkInProgressEffects && flags & 4) {
includeWorkInProgressEffects =
finishedWork.stateNode.effectDuration;
try {
runWithFiberInDEV(
finishedWork,
commitProfiler,
finishedWork,
current,
commitTime,
includeWorkInProgressEffects
);
} catch (error$20) {
captureCommitPhaseError(
finishedWork,
finishedWork.return,
error$20
);
}
finishedWork = finishedWork.return;
a: for (; null !== finishedWork; ) {
switch (finishedWork.tag) {
case 3:
finishedWork.stateNode.effectDuration +=
Expand All @@ -10039,6 +10030,7 @@ __DEV__ &&
}
finishedWork = finishedWork.return;
}
}
break;
case 13:
recursivelyTraverseReappearLayoutEffects(
Expand Down Expand Up @@ -10161,7 +10153,7 @@ __DEV__ &&
committedLanes,
committedTransitions
);
if (flags & 2048 && executionContext & CommitContext) {
if (flags & 2048) {
finishedRoot = finishedWork.stateNode.passiveEffectDuration;
try {
runWithFiberInDEV(
Expand Down Expand Up @@ -15131,11 +15123,11 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.0.0-native-fb-26855e46-20240916",
version: "19.0.0-native-fb-8152e5cd-20240916",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-26855e46-20240916"
reconcilerVersion: "19.0.0-native-fb-8152e5cd-20240916"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -15280,5 +15272,5 @@ __DEV__ &&
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.0.0-native-fb-26855e46-20240916";
exports.version = "19.0.0-native-fb-8152e5cd-20240916";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<bc1eceaf1fd7b02a6c11ab1548ce65c8>>
* @generated SignedSource<<a43f354b5e521c320a4cf4fa89fe5295>>
*/

"use strict";
Expand Down Expand Up @@ -9494,14 +9494,14 @@ function wrapFiber(fiber) {
}
var internals$jscomp$inline_1266 = {
bundleType: 0,
version: "19.0.0-native-fb-26855e46-20240916",
version: "19.0.0-native-fb-8152e5cd-20240916",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: function (mockNode) {
mockNode = nodeToInstanceMap.get(mockNode);
return void 0 !== mockNode ? mockNode.internalInstanceHandle : null;
},
reconcilerVersion: "19.0.0-native-fb-26855e46-20240916"
reconcilerVersion: "19.0.0-native-fb-8152e5cd-20240916"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1267 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -9637,4 +9637,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.0.0-native-fb-26855e46-20240916";
exports.version = "19.0.0-native-fb-8152e5cd-20240916";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<dbe78fc2470626489c135a835a479928>>
* @generated SignedSource<<7fc82ac71e4522bb6e3dcfef512e6ba4>>
*/

"use strict";
Expand Down Expand Up @@ -6408,7 +6408,7 @@ function unwindInterruptedWork(current, interruptedWork) {
}
}
function shouldProfile$1(current) {
return 0 !== (current.mode & 2) && 0 !== (executionContext & 4);
return 0 !== (current.mode & 2);
}
function commitHookLayoutEffects(finishedWork, hookFlags) {
shouldProfile$1(finishedWork)
Expand Down Expand Up @@ -6641,33 +6641,32 @@ function commitProfilerUpdate(
commitTime,
effectDuration
) {
if (executionContext & 4)
try {
var _finishedWork$memoize = finishedWork.memoizedProps,
id = _finishedWork$memoize.id,
onCommit = _finishedWork$memoize.onCommit,
onRender = _finishedWork$memoize.onRender;
current = null === current ? "mount" : "update";
currentUpdateIsNested && (current = "nested-update");
"function" === typeof onRender &&
onRender(
id,
current,
finishedWork.actualDuration,
finishedWork.treeBaseDuration,
finishedWork.actualStartTime,
commitTime
);
"function" === typeof onCommit &&
onCommit(
finishedWork.memoizedProps.id,
current,
effectDuration,
commitTime
);
} catch (error) {
captureCommitPhaseError(finishedWork, finishedWork.return, error);
}
try {
var _finishedWork$memoize = finishedWork.memoizedProps,
id = _finishedWork$memoize.id,
onCommit = _finishedWork$memoize.onCommit,
onRender = _finishedWork$memoize.onRender;
current = null === current ? "mount" : "update";
currentUpdateIsNested && (current = "nested-update");
"function" === typeof onRender &&
onRender(
id,
current,
finishedWork.actualDuration,
finishedWork.treeBaseDuration,
finishedWork.actualStartTime,
commitTime
);
"function" === typeof onCommit &&
onCommit(
finishedWork.memoizedProps.id,
current,
effectDuration,
commitTime
);
} catch (error) {
captureCommitPhaseError(finishedWork, finishedWork.return, error);
}
}
function isHostParent(fiber) {
return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag;
Expand Down Expand Up @@ -6722,11 +6721,8 @@ function insertOrAppendPlacementNode(node, before, parent) {
var offscreenSubtreeIsHidden = !1,
offscreenSubtreeWasHidden = !1,
PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set,
nextEffect = null;
function shouldProfile(current) {
return 0 !== (current.mode & 2) && 0 !== (executionContext & 4);
}
var shouldFireAfterActiveInstanceBlur = !1;
nextEffect = null,
shouldFireAfterActiveInstanceBlur = !1;
function commitBeforeMutationEffects(root, firstChild) {
for (nextEffect = firstChild; null !== nextEffect; )
if (
Expand Down Expand Up @@ -7076,7 +7072,7 @@ function commitDeletionEffectsOnFiber(
: offscreenSubtreeWasHidden ||
0 === (prevHostParent & 4) ||
(markComponentLayoutEffectUnmountStarted(deletedFiber),
shouldProfile(deletedFiber)
0 !== (deletedFiber.mode & 2)
? (startLayoutEffectTimer(),
(prevHostParentIsContainer.destroy = void 0),
safelyCallDestroy(
Expand Down Expand Up @@ -7237,7 +7233,7 @@ function commitMutationEffectsOnFiber(finishedWork, root) {
flags & 4 &&
(commitHookEffectListUnmount(3, finishedWork, finishedWork.return),
commitHookEffectListMount(3, finishedWork),
shouldProfile(finishedWork)
0 !== (finishedWork.mode & 2)
? (startLayoutEffectTimer(),
commitHookEffectListUnmount(5, finishedWork, finishedWork.return),
recordLayoutEffectDuration(finishedWork))
Expand Down Expand Up @@ -7488,7 +7484,7 @@ function recursivelyTraverseDisappearLayoutEffects(parentFiber) {
case 11:
case 14:
case 15:
if (shouldProfile(finishedWork))
if (0 !== (finishedWork.mode & 2))
try {
startLayoutEffectTimer(),
commitHookEffectListUnmount(4, finishedWork, finishedWork.return);
Expand Down Expand Up @@ -7726,7 +7722,7 @@ function commitPassiveMountOnFiber(
committedLanes,
committedTransitions
);
if (flags & 2048 && executionContext & 4) {
if (flags & 2048) {
finishedRoot = finishedWork.stateNode.passiveEffectDuration;
try {
var _finishedWork$memoize2 = finishedWork.memoizedProps,
Expand Down Expand Up @@ -10066,14 +10062,14 @@ function wrapFiber(fiber) {
}
var internals$jscomp$inline_1144 = {
bundleType: 0,
version: "19.0.0-native-fb-26855e46-20240916",
version: "19.0.0-native-fb-8152e5cd-20240916",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: function (mockNode) {
mockNode = nodeToInstanceMap.get(mockNode);
return void 0 !== mockNode ? mockNode.internalInstanceHandle : null;
},
reconcilerVersion: "19.0.0-native-fb-26855e46-20240916",
reconcilerVersion: "19.0.0-native-fb-8152e5cd-20240916",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$137 = 0;
Expand Down Expand Up @@ -10224,4 +10220,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.0.0-native-fb-26855e46-20240916";
exports.version = "19.0.0-native-fb-8152e5cd-20240916";
Loading

0 comments on commit 52878f5

Please sign in to comment.