Skip to content

Commit e4c6e4a

Browse files
committed
(Land #28798) Move Current Owner (and Cache) to an Async Dispatcher (#28912)
Rebasing and landing #28798 This PR was approved already but held back to give time for the sync. Rebased and landing here without pushing to seb's remote to avoid possibility of lost updates --------- Co-authored-by: Sebastian Markbage <sebastian@calyptus.eu> DiffTrain build for commit 94eed63.
1 parent 3a8adbf commit e4c6e4a

File tree

17 files changed

+425
-339
lines changed

17 files changed

+425
-339
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<c3ec935f7569a8a6d52e0966b2837ffe>>
10+
* @generated SignedSource<<000c06a477839c734ee52d10d49394b6>>
1111
*/
1212

1313
'use strict';
@@ -562,6 +562,11 @@ var PassiveMask = Passive$1 | Visibility | ChildDeletion; // Union of tags that
562562

563563
var StaticMask = LayoutStatic | PassiveStatic | RefStatic | MaySuspendCommit;
564564

565+
var currentOwner = null;
566+
function setCurrentOwner(fiber) {
567+
currentOwner = fiber;
568+
}
569+
565570
function getNearestMountedFiber(fiber) {
566571
var node = fiber;
567572
var nearestMounted = fiber;
@@ -605,7 +610,7 @@ function isFiberMounted(fiber) {
605610
}
606611
function isMounted(component) {
607612
{
608-
var owner = ReactSharedInternals.owner;
613+
var owner = currentOwner;
609614

610615
if (owner !== null && owner.tag === ClassComponent) {
611616
var ownerFiber = owner;
@@ -11897,7 +11902,7 @@ function updateForwardRef(current, workInProgress, Component, nextProps, renderL
1189711902
}
1189811903

1189911904
{
11900-
ReactSharedInternals.owner = workInProgress;
11905+
setCurrentOwner(workInProgress);
1190111906
setIsRendering(true);
1190211907
nextChildren = renderWithHooks(current, workInProgress, render, propsWithoutRef, ref, renderLanes);
1190311908
setIsRendering(false);
@@ -12380,7 +12385,7 @@ function updateFunctionComponent(current, workInProgress, Component, nextProps,
1238012385
}
1238112386

1238212387
{
12383-
ReactSharedInternals.owner = workInProgress;
12388+
setCurrentOwner(workInProgress);
1238412389
setIsRendering(true);
1238512390
nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes);
1238612391
setIsRendering(false);
@@ -12532,7 +12537,7 @@ function finishClassComponent(current, workInProgress, Component, shouldUpdate,
1253212537
var instance = workInProgress.stateNode; // Rerender
1253312538

1253412539
{
12535-
ReactSharedInternals.owner = workInProgress;
12540+
setCurrentOwner(workInProgress);
1253612541
}
1253712542

1253812543
var nextChildren;
@@ -13851,7 +13856,7 @@ function updateContextConsumer(current, workInProgress, renderLanes) {
1385113856
var newChildren;
1385213857

1385313858
{
13854-
ReactSharedInternals.owner = workInProgress;
13859+
setCurrentOwner(workInProgress);
1385513860
setIsRendering(true);
1385613861
newChildren = render(newValue);
1385713862
setIsRendering(false);
@@ -19158,10 +19163,16 @@ function getCacheForType(resourceType) {
1915819163
return cacheForType;
1915919164
}
1916019165

19161-
var DefaultCacheDispatcher = {
19166+
var DefaultAsyncDispatcher = {
1916219167
getCacheForType: getCacheForType
1916319168
};
1916419169

19170+
{
19171+
DefaultAsyncDispatcher.getOwner = function () {
19172+
return currentOwner;
19173+
};
19174+
}
19175+
1916519176
if (typeof Symbol === 'function' && Symbol.for) {
1916619177
var symbolFor = Symbol.for;
1916719178
symbolFor('selector.component');
@@ -20114,7 +20125,7 @@ function handleThrow(root, thrownValue) {
2011420125
resetCurrentFiber();
2011520126

2011620127
{
20117-
ReactSharedInternals.owner = null;
20128+
setCurrentOwner(null);
2011820129
}
2011920130

2012020131
if (thrownValue === SuspenseException) {
@@ -20270,17 +20281,17 @@ function popDispatcher(prevDispatcher) {
2027020281
ReactSharedInternals.H = prevDispatcher;
2027120282
}
2027220283

20273-
function pushCacheDispatcher() {
20284+
function pushAsyncDispatcher() {
2027420285
{
20275-
var prevCacheDispatcher = ReactSharedInternals.C;
20276-
ReactSharedInternals.C = DefaultCacheDispatcher;
20277-
return prevCacheDispatcher;
20286+
var prevAsyncDispatcher = ReactSharedInternals.A;
20287+
ReactSharedInternals.A = DefaultAsyncDispatcher;
20288+
return prevAsyncDispatcher;
2027820289
}
2027920290
}
2028020291

20281-
function popCacheDispatcher(prevCacheDispatcher) {
20292+
function popAsyncDispatcher(prevAsyncDispatcher) {
2028220293
{
20283-
ReactSharedInternals.C = prevCacheDispatcher;
20294+
ReactSharedInternals.A = prevAsyncDispatcher;
2028420295
}
2028520296
}
2028620297

@@ -20338,7 +20349,7 @@ function renderRootSync(root, lanes) {
2033820349
var prevExecutionContext = executionContext;
2033920350
executionContext |= RenderContext;
2034020351
var prevDispatcher = pushDispatcher();
20341-
var prevCacheDispatcher = pushCacheDispatcher(); // If the root or lanes have changed, throw out the existing stack
20352+
var prevAsyncDispatcher = pushAsyncDispatcher(); // If the root or lanes have changed, throw out the existing stack
2034220353
// and prepare a fresh one. Otherwise we'll continue where we left off.
2034320354

2034420355
if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
@@ -20418,7 +20429,7 @@ function renderRootSync(root, lanes) {
2041820429
resetContextDependencies();
2041920430
executionContext = prevExecutionContext;
2042020431
popDispatcher(prevDispatcher);
20421-
popCacheDispatcher(prevCacheDispatcher);
20432+
popAsyncDispatcher(prevAsyncDispatcher);
2042220433

2042320434
if (workInProgress !== null) {
2042420435
// This is a sync render, so we should have finished the whole tree.
@@ -20451,7 +20462,7 @@ function renderRootConcurrent(root, lanes) {
2045120462
var prevExecutionContext = executionContext;
2045220463
executionContext |= RenderContext;
2045320464
var prevDispatcher = pushDispatcher();
20454-
var prevCacheDispatcher = pushCacheDispatcher(); // If the root or lanes have changed, throw out the existing stack
20465+
var prevAsyncDispatcher = pushAsyncDispatcher(); // If the root or lanes have changed, throw out the existing stack
2045520466
// and prepare a fresh one. Otherwise we'll continue where we left off.
2045620467

2045720468
if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
@@ -20664,7 +20675,7 @@ function renderRootConcurrent(root, lanes) {
2066420675

2066520676
resetContextDependencies();
2066620677
popDispatcher(prevDispatcher);
20667-
popCacheDispatcher(prevCacheDispatcher);
20678+
popAsyncDispatcher(prevAsyncDispatcher);
2066820679
executionContext = prevExecutionContext;
2066920680

2067020681

@@ -20728,7 +20739,7 @@ function performUnitOfWork(unitOfWork) {
2072820739
}
2072920740

2073020741
{
20731-
ReactSharedInternals.owner = null;
20742+
setCurrentOwner(null);
2073220743
}
2073320744
}
2073420745

@@ -20828,7 +20839,7 @@ function replaySuspendedUnitOfWork(unitOfWork) {
2082820839
}
2082920840

2083020841
{
20831-
ReactSharedInternals.owner = null;
20842+
setCurrentOwner(null);
2083220843
}
2083320844
}
2083420845

@@ -21156,7 +21167,7 @@ function commitRootImpl(root, recoverableErrors, transitions, didIncludeRenderPh
2115621167
executionContext |= CommitContext; // Reset this to null before calling lifecycles
2115721168

2115821169
{
21159-
ReactSharedInternals.owner = null;
21170+
setCurrentOwner(null);
2116021171
} // The commit phase is broken into several sub-phases. We do a separate pass
2116121172
// of the effect list for each phase: all mutation effects come before all
2116221173
// layout effects, and so on.
@@ -22978,7 +22989,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
2297822989
return root;
2297922990
}
2298022991

22981-
var ReactVersion = '19.0.0-beta-6e32de0b';
22992+
var ReactVersion = '19.0.0-beta-fd8f46d6';
2298222993

2298322994
/*
2298422995
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol

0 commit comments

Comments
 (0)