MergeReactiveScopesThatInvalidateTogether.ts — react Source File
Architecture documentation for MergeReactiveScopesThatInvalidateTogether.ts, a typescript file in the react codebase. 15 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 006711fe_6949_9be8_4726_2031284f3328["MergeReactiveScopesThatInvalidateTogether.ts"] 0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"] 006711fe_6949_9be8_4726_2031284f3328 --> 0423f759_97e0_9101_4634_ed555abc5ca9 58f81300_7c82_5086_3e10_e46b5f3ab04d["ObjectShape.ts"] 006711fe_6949_9be8_4726_2031284f3328 --> 58f81300_7c82_5086_3e10_e46b5f3ab04d 2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"] 006711fe_6949_9be8_4726_2031284f3328 --> 2f3caf55_cc64_415c_55dd_9771ba7dc210 10043bf1_f7ee_9ed9_307a_fe3edfd02b09["eachInstructionLValue"] 006711fe_6949_9be8_4726_2031284f3328 --> 10043bf1_f7ee_9ed9_307a_fe3edfd02b09 eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"] 006711fe_6949_9be8_4726_2031284f3328 --> eb9d33f9_42c1_205c_93e6_8e1365a31839 d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive"] 006711fe_6949_9be8_4726_2031284f3328 --> d7fde76c_4fd9_feb3_299b_798689f05bc6 527555c0_9544_ae6b_5f83_952272d2caa1["Iterable_some"] 006711fe_6949_9be8_4726_2031284f3328 --> 527555c0_9544_ae6b_5f83_952272d2caa1 d77f9ffb_2d12_7d1f_126f_8c05214f0059["PrintReactiveFunction.ts"] 006711fe_6949_9be8_4726_2031284f3328 --> d77f9ffb_2d12_7d1f_126f_8c05214f0059 694a6a07_b3ca_4ab4_beba_18f4053a49f2["printReactiveScopeSummary"] 006711fe_6949_9be8_4726_2031284f3328 --> 694a6a07_b3ca_4ab4_beba_18f4053a49f2 21609915_b03a_fd75_b58a_4cb86ef9315b["visitors.ts"] 006711fe_6949_9be8_4726_2031284f3328 --> 21609915_b03a_fd75_b58a_4cb86ef9315b af3ace55_db6d_865e_92b9_81486f6af1e7["ReactiveFunctionTransform"] 006711fe_6949_9be8_4726_2031284f3328 --> af3ace55_db6d_865e_92b9_81486f6af1e7 171a5d22_bb6b_1c99_05a4_6ad897438a35["ReactiveFunctionVisitor"] 006711fe_6949_9be8_4726_2031284f3328 --> 171a5d22_bb6b_1c99_05a4_6ad897438a35 da7ad665_d709_433d_facd_dc3b2c4d34f5["Transformed"] 006711fe_6949_9be8_4726_2031284f3328 --> da7ad665_d709_433d_facd_dc3b2c4d34f5 2435b5f8_41a6_0458_ba88_4479b965455f["visitReactiveFunction"] 006711fe_6949_9be8_4726_2031284f3328 --> 2435b5f8_41a6_0458_ba88_4479b965455f style 006711fe_6949_9be8_4726_2031284f3328 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {CompilerError} from '..';
import {
DeclarationId,
GeneratedSource,
InstructionId,
InstructionKind,
Place,
ReactiveBlock,
ReactiveFunction,
ReactiveScope,
ReactiveScopeBlock,
ReactiveScopeDependencies,
ReactiveScopeDependency,
ReactiveStatement,
Type,
areEqualPaths,
makeInstructionId,
} from '../HIR';
import {
BuiltInArrayId,
BuiltInFunctionId,
BuiltInJsxId,
BuiltInObjectId,
} from '../HIR/ObjectShape';
import {eachInstructionLValue} from '../HIR/visitors';
import {assertExhaustive, Iterable_some} from '../Utils/utils';
import {printReactiveScopeSummary} from './PrintReactiveFunction';
import {
ReactiveFunctionTransform,
ReactiveFunctionVisitor,
Transformed,
visitReactiveFunction,
} from './visitors';
/*
* The primary goal of this pass is to reduce memoization overhead, specifically:
* - Use fewer memo slots
* - Reduce the number of comparisons and other memoization-related instructions
*
* The algorithm merges in two main cases: consecutive scopes that invalidate together
* or nested scopes that invalidate together
*
* ## Consecutive Scopes
*
* The idea is that if two consecutive scopes would always invalidate together,
* it's more efficient to group the scopes together to save on memoization overhead.
*
* This optimization is necessarily somewhat limited. First, we only merge
* scopes that are in the same (reactive) block, ie we don't merge across
* control-flow or block-scoping boundaries. Second, we can only merge scopes
* so long as any intermediate instructions are safe to memoize — specifically,
* as long as the values created by those instructions are only referenced by
* the second scope and not elsewhere. This is to avoid changing control-flow
// ... (511 more lines)
Domain
Subdomains
Functions
Classes
Types
Dependencies
Source
Frequently Asked Questions
What does MergeReactiveScopesThatInvalidateTogether.ts do?
MergeReactiveScopesThatInvalidateTogether.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in MergeReactiveScopesThatInvalidateTogether.ts?
MergeReactiveScopesThatInvalidateTogether.ts defines 8 function(s): areEqualDependencies, areLValuesLastUsedByScope, canMergeScopes, isAlwaysInvalidatingType, log, mergeReactiveScopesThatInvalidateTogether, scopeIsEligibleForMerging, updateScopeDeclarations.
What does MergeReactiveScopesThatInvalidateTogether.ts depend on?
MergeReactiveScopesThatInvalidateTogether.ts imports 15 module(s): .., Iterable_some, ObjectShape.ts, PrintReactiveFunction.ts, ReactiveFunctionTransform, ReactiveFunctionVisitor, Transformed, assertExhaustive, and 7 more.
Where is MergeReactiveScopesThatInvalidateTogether.ts in the architecture?
MergeReactiveScopesThatInvalidateTogether.ts is located at compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/MergeReactiveScopesThatInvalidateTogether.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free