Home / File/ ComputeUnconditionalBlocks.ts — react Source File

ComputeUnconditionalBlocks.ts — react Source File

Architecture documentation for ComputeUnconditionalBlocks.ts, a typescript file in the react codebase. 2 imports, 2 dependents.

File typescript MIRInfrastructure HIR 2 imports 2 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  c0d1dc03_8683_01ed_b02a_b10aae366514["ComputeUnconditionalBlocks.ts"]
  9dc3e5f8_0649_d981_e520_38c0ab672d18["."]
  c0d1dc03_8683_01ed_b02a_b10aae366514 --> 9dc3e5f8_0649_d981_e520_38c0ab672d18
  2ed45bcd_6c82_3ccd_0e20_fa96b5111055[".."]
  c0d1dc03_8683_01ed_b02a_b10aae366514 --> 2ed45bcd_6c82_3ccd_0e20_fa96b5111055
  0aa1377a_e69b_36ae_b83d_c842baa2ad42["ValidateHooksUsage.ts"]
  0aa1377a_e69b_36ae_b83d_c842baa2ad42 --> c0d1dc03_8683_01ed_b02a_b10aae366514
  b4e382c8_ed3f_36e3_497f_a485571ec5ea["ValidateNoSetStateInRender.ts"]
  b4e382c8_ed3f_36e3_497f_a485571ec5ea --> c0d1dc03_8683_01ed_b02a_b10aae366514
  style c0d1dc03_8683_01ed_b02a_b10aae366514 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 {
  BlockId,
  GeneratedSource,
  HIRFunction,
  computePostDominatorTree,
} from '.';
import {CompilerError} from '..';

export function computeUnconditionalBlocks(fn: HIRFunction): Set<BlockId> {
  // Construct the set of blocks that is always reachable from the entry block.
  const unconditionalBlocks = new Set<BlockId>();
  const dominators = computePostDominatorTree(fn, {
    /*
     * Hooks must only be in a consistent order for executions that return normally,
     * so we opt-in to viewing throw as a non-exit node.
     */
    includeThrowsAsExitNode: false,
  });
  const exit = dominators.exit;
  let current: BlockId | null = fn.body.entry;
  while (current !== null && current !== exit) {
    CompilerError.invariant(!unconditionalBlocks.has(current), {
      reason:
        'Internal error: non-terminating loop in ComputeUnconditionalBlocks',
      loc: GeneratedSource,
    });
    unconditionalBlocks.add(current);
    current = dominators.get(current);
  }
  return unconditionalBlocks;
}

Subdomains

Dependencies

  • .
  • ..

Frequently Asked Questions

What does ComputeUnconditionalBlocks.ts do?
ComputeUnconditionalBlocks.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 ComputeUnconditionalBlocks.ts?
ComputeUnconditionalBlocks.ts defines 1 function(s): computeUnconditionalBlocks.
What does ComputeUnconditionalBlocks.ts depend on?
ComputeUnconditionalBlocks.ts imports 2 module(s): ., ...
What files import ComputeUnconditionalBlocks.ts?
ComputeUnconditionalBlocks.ts is imported by 2 file(s): ValidateHooksUsage.ts, ValidateNoSetStateInRender.ts.
Where is ComputeUnconditionalBlocks.ts in the architecture?
ComputeUnconditionalBlocks.ts is located at compiler/packages/babel-plugin-react-compiler/src/HIR/ComputeUnconditionalBlocks.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