Skip to content

Commit

Permalink
Move Mutation/Persistence fork inline into the functions (#26206)
Browse files Browse the repository at this point in the history
We should never use any logic beyond declarations in the module scope,
including conditions, because in a cycle that can lead to problems.

More importantly, the compiler can't safely reorder statements between
these points which limits the optimizations we can do.

DiffTrain build for commit 62e6c46.
  • Loading branch information
sebmarkbage committed Feb 20, 2023
1 parent ac6f055 commit 3484cc2
Show file tree
Hide file tree
Showing 34 changed files with 31,308 additions and 829 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
80cf4a099e99bbd4ed13e02d30136f669f2868b9
62e6c4612ec704cf07c99b318bc8f26d3ec3f588
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
80cf4a099e99bbd4ed13e02d30136f669f2868b9
62e6c4612ec704cf07c99b318bc8f26d3ec3f588
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-classic-80cf4a099-20230220";
var ReactVersion = "18.3.0-www-classic-62e6c4612-20230220";

// ATTENTION
// When adding new symbols to this file,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-modern-80cf4a099-20230220";
var ReactVersion = "18.3.0-www-modern-62e6c4612-20230220";

// ATTENTION
// When adding new symbols to this file,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,4 +646,4 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-classic-80cf4a099-20230220";
exports.version = "18.3.0-www-classic-62e6c4612-20230220";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,4 +638,4 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-modern-80cf4a099-20230220";
exports.version = "18.3.0-www-modern-62e6c4612-20230220";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-classic-80cf4a099-20230220";
exports.version = "18.3.0-www-classic-62e6c4612-20230220";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-modern-80cf4a099-20230220";
exports.version = "18.3.0-www-modern-62e6c4612-20230220";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
45 changes: 18 additions & 27 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-classic-80cf4a099-20230220";
var ReactVersion = "18.3.0-www-classic-62e6c4612-20230220";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -17350,19 +17350,13 @@ function markRef(workInProgress) {
workInProgress.flags |= Ref | RefStatic;
}

var appendAllChildren;
var updateHostContainer;
var updateHostComponent;
var updateHostText;

{
// Mutation mode
appendAllChildren = function (
parent,
workInProgress,
needsVisibilityToggle,
isHidden
) {
function appendAllChildren(
parent,
workInProgress,
needsVisibilityToggle,
isHidden
) {
{
// We only have the top Fiber that was created but we need recurse down its
// children to find all the terminal nodes.
var node = workInProgress.child;
Expand Down Expand Up @@ -17393,13 +17387,11 @@ var updateHostText;
node.sibling.return = node.return;
node = node.sibling;
}
};

updateHostContainer = function (current, workInProgress) {
// Noop
};
}
} // An unfortunate fork of appendAllChildren because we have two different parent types.

updateHostComponent = function (current, workInProgress, type, newProps) {
function updateHostComponent(current, workInProgress, type, newProps) {
{
// If we have an alternate, that means this is an update and we need to
// schedule a side-effect to do the updates.
var oldProps = current.memoizedProps;
Expand All @@ -17421,14 +17413,16 @@ var updateHostText;
if (updatePayload) {
markUpdate(workInProgress);
}
};
}
}

updateHostText = function (current, workInProgress, oldText, newText) {
function updateHostText(current, workInProgress, oldText, newText) {
{
// If the text differs, mark it as an update. All the work in done in commitWork.
if (oldText !== newText) {
markUpdate(workInProgress);
}
};
}
}

function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
Expand Down Expand Up @@ -17800,8 +17794,6 @@ function completeWork(current, workInProgress, renderLanes) {
}
}
}

updateHostContainer(current, workInProgress);
bubbleProperties(workInProgress);

if (enableTransitionTracing) {
Expand Down Expand Up @@ -17864,7 +17856,7 @@ function completeWork(current, workInProgress, renderLanes) {
getRootHostContainer();

var instance = createInstance(_type, newProps);
appendAllChildren(instance, workInProgress, false, false);
appendAllChildren(instance, workInProgress);
workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount.
}

Expand Down Expand Up @@ -18052,7 +18044,6 @@ function completeWork(current, workInProgress, renderLanes) {

case HostPortal:
popHostContainer(workInProgress);
updateHostContainer(current, workInProgress);

bubbleProperties(workInProgress);
return null;
Expand Down
45 changes: 18 additions & 27 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-modern-80cf4a099-20230220";
var ReactVersion = "18.3.0-www-modern-62e6c4612-20230220";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -17039,19 +17039,13 @@ function markRef(workInProgress) {
workInProgress.flags |= Ref | RefStatic;
}

var appendAllChildren;
var updateHostContainer;
var updateHostComponent;
var updateHostText;

{
// Mutation mode
appendAllChildren = function (
parent,
workInProgress,
needsVisibilityToggle,
isHidden
) {
function appendAllChildren(
parent,
workInProgress,
needsVisibilityToggle,
isHidden
) {
{
// We only have the top Fiber that was created but we need recurse down its
// children to find all the terminal nodes.
var node = workInProgress.child;
Expand Down Expand Up @@ -17082,13 +17076,11 @@ var updateHostText;
node.sibling.return = node.return;
node = node.sibling;
}
};

updateHostContainer = function (current, workInProgress) {
// Noop
};
}
} // An unfortunate fork of appendAllChildren because we have two different parent types.

updateHostComponent = function (current, workInProgress, type, newProps) {
function updateHostComponent(current, workInProgress, type, newProps) {
{
// If we have an alternate, that means this is an update and we need to
// schedule a side-effect to do the updates.
var oldProps = current.memoizedProps;
Expand All @@ -17110,14 +17102,16 @@ var updateHostText;
if (updatePayload) {
markUpdate(workInProgress);
}
};
}
}

updateHostText = function (current, workInProgress, oldText, newText) {
function updateHostText(current, workInProgress, oldText, newText) {
{
// If the text differs, mark it as an update. All the work in done in commitWork.
if (oldText !== newText) {
markUpdate(workInProgress);
}
};
}
}

function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
Expand Down Expand Up @@ -17482,8 +17476,6 @@ function completeWork(current, workInProgress, renderLanes) {
}
}
}

updateHostContainer(current, workInProgress);
bubbleProperties(workInProgress);

if (enableTransitionTracing) {
Expand Down Expand Up @@ -17546,7 +17538,7 @@ function completeWork(current, workInProgress, renderLanes) {
getRootHostContainer();

var instance = createInstance(_type, newProps);
appendAllChildren(instance, workInProgress, false, false);
appendAllChildren(instance, workInProgress);
workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount.
}

Expand Down Expand Up @@ -17734,7 +17726,6 @@ function completeWork(current, workInProgress, renderLanes) {

case HostPortal:
popHostContainer(workInProgress);
updateHostContainer(current, workInProgress);

bubbleProperties(workInProgress);
return null;
Expand Down
Loading

0 comments on commit 3484cc2

Please sign in to comment.