Home / File/ MergeOverlappingReactiveScopesHIR.ts — react Source File

MergeOverlappingReactiveScopesHIR.ts — react Source File

Architecture documentation for MergeOverlappingReactiveScopesHIR.ts, a typescript file in the react codebase. 13 imports, 0 dependents.

File typescript MIRInfrastructure HIR 13 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  78244170_3d42_f86a_ea59_bce3e065fcfd["MergeOverlappingReactiveScopesHIR.ts"]
  18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> 18a78965_f593_105b_e5e8_07001321c2ec
  7107ba22_4065_0956_1ec3_286f637d0d22["getPlaceScope"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> 7107ba22_4065_0956_1ec3_286f637d0d22
  f041318d_301f_daad_4198_91d141b3039d["InferReactiveScopeVariables.ts"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> f041318d_301f_daad_4198_91d141b3039d
  11746e9a_2fdf_98bb_bb3c_a63d8b200df2["isMutable"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> 11746e9a_2fdf_98bb_bb3c_a63d8b200df2
  edec7689_7b1d_03c9_9cbb_bb9b0552bc30["DisjointSet.ts"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> edec7689_7b1d_03c9_9cbb_bb9b0552bc30
  1765a682_3028_4441_b26f_c712ca2597d5["DisjointSet"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> 1765a682_3028_4441_b26f_c712ca2597d5
  eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> eb9d33f9_42c1_205c_93e6_8e1365a31839
  14f2e51a_d755_814e_2f56_72d3ed119459["getOrInsertDefault"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> 14f2e51a_d755_814e_2f56_72d3ed119459
  2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> 2f3caf55_cc64_415c_55dd_9771ba7dc210
  10043bf1_f7ee_9ed9_307a_fe3edfd02b09["eachInstructionLValue"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> 10043bf1_f7ee_9ed9_307a_fe3edfd02b09
  ccace1c3_85b7_a05e_c2a5_7eff8b3422ed["eachInstructionOperand"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> ccace1c3_85b7_a05e_c2a5_7eff8b3422ed
  41232a25_deb6_6e83_05a8_ae9f961656f7["eachTerminalOperand"]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> 41232a25_deb6_6e83_05a8_ae9f961656f7
  9dc3e5f8_0649_d981_e520_38c0ab672d18["."]
  78244170_3d42_f86a_ea59_bce3e065fcfd --> 9dc3e5f8_0649_d981_e520_38c0ab672d18
  style 78244170_3d42_f86a_ea59_bce3e065fcfd 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 {
  HIRFunction,
  InstructionId,
  Place,
  ReactiveScope,
  makeInstructionId,
} from '.';
import {getPlaceScope} from '../HIR/HIR';
import {isMutable} from '../ReactiveScopes/InferReactiveScopeVariables';
import DisjointSet from '../Utils/DisjointSet';
import {getOrInsertDefault} from '../Utils/utils';
import {
  eachInstructionLValue,
  eachInstructionOperand,
  eachTerminalOperand,
} from './visitors';

/**
 * While previous passes ensure that reactive scopes span valid sets of program
 * blocks, pairs of reactive scopes may still be inconsistent with respect to
 * each other.
 *
 * (a) Reactive scopes ranges must form valid blocks in the resulting javascript
 * program. Any two scopes must either be entirely disjoint or one scope must be
 * nested within the other.
 *   ```js
 *   // Scopes 1:3 and 3:5 are valid because they contain no common instructions
 *   [1] ⌝
 *   [2] ⌟
 *   [3] ⌝
 *   [4] ⌟
 *   // Scopes 1:3 and 1:5 are valid because the former is nested within the other
 *   [1] ⌝  ⌝
 *   [2] ⌟  |
 *   [3]    |
 *   [4]    ⌟
 *   // Scopes 1:4 and 2:5 are invalid because we cannot produce if-else memo
 *   // blocks representing these scopes in the output program.
 *   [1] ⌝
 *   [2] |  ⌝
 *   [3] ⌟  |
 *   [4]    ⌟
 *   ```
 *
 * (b) A scope's own instructions may only mutate that scope.
 * For each reactive scope, we currently produce exactly one if-block which
 * spans the instruction range of the scope. In this simple example, instr [2]
 * does not mutate any values but is included within scope @0.
 * ```js
 *   // IR instructions
 *   [1] (writes to scope @0's values)
 *   [2] (does not mutate anything)
 *   [3] (writes to scope @0's values)
// ... (254 more lines)

Subdomains

Frequently Asked Questions

What does MergeOverlappingReactiveScopesHIR.ts do?
MergeOverlappingReactiveScopesHIR.ts is a source file in the react codebase, written in typescript. It belongs to the MIRInfrastructure domain, HIR subdomain.
What functions are defined in MergeOverlappingReactiveScopesHIR.ts?
MergeOverlappingReactiveScopesHIR.ts defines 5 function(s): collectScopeInfo, getOverlappingReactiveScopes, mergeOverlappingReactiveScopesHIR, visitInstructionId, visitPlace.
What does MergeOverlappingReactiveScopesHIR.ts depend on?
MergeOverlappingReactiveScopesHIR.ts imports 13 module(s): ., DisjointSet, DisjointSet.ts, HIR.ts, InferReactiveScopeVariables.ts, eachInstructionLValue, eachInstructionOperand, eachTerminalOperand, and 5 more.
Where is MergeOverlappingReactiveScopesHIR.ts in the architecture?
MergeOverlappingReactiveScopesHIR.ts is located at compiler/packages/babel-plugin-react-compiler/src/HIR/MergeOverlappingReactiveScopesHIR.ts (domain: MIRInfrastructure, subdomain: HIR, directory: compiler/packages/babel-plugin-react-compiler/src/HIR).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free