Dominator.ts — react Source File
Architecture documentation for Dominator.ts, a typescript file in the react codebase. 8 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa["Dominator.ts"] e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"] b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa --> e96f281e_f381_272d_2359_3e6a091c9a1d e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"] b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa --> e51fd0d2_bb38_cc97_7763_efe37f300a47 18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"] b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa --> 18a78965_f593_105b_e5e8_07001321c2ec 4a73a9b9_07eb_502f_14c1_2f045ba2666c["BlockId"] b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa --> 4a73a9b9_07eb_502f_14c1_2f045ba2666c 9241c5c1_a9a7_17bc_e41c_e967225008dd["HIRFunction"] b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa --> 9241c5c1_a9a7_17bc_e41c_e967225008dd 2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"] b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa --> 2f3caf55_cc64_415c_55dd_9771ba7dc210 d737cb4c_53f4_75b4_2d58_268e2f73fde4["eachTerminalSuccessor"] b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa --> d737cb4c_53f4_75b4_2d58_268e2f73fde4 e81931c0_5405_5b82_9cf3_d6fb6fe2fe65["pretty-format"] b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa --> e81931c0_5405_5b82_9cf3_d6fb6fe2fe65 5d62162e_5fa5_1488_29bf_5150b4be53a0["ControlDominators.ts"] 5d62162e_5fa5_1488_29bf_5150b4be53a0 --> b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa style b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa 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 prettyFormat from 'pretty-format';
import {CompilerError} from '../CompilerError';
import {BlockId, GeneratedSource, HIRFunction} from './HIR';
import {eachTerminalSuccessor} from './visitors';
/*
* Computes the dominator tree of the given function. The returned `Dominator` stores the immediate
* dominator of each node in the function, which can be retrieved with `Dominator.prototype.get()`.
*
* A block X dominates block Y in the CFG if all paths to Y must flow through X. Thus the entry
* block dominates all other blocks. See https://en.wikipedia.org/wiki/Dominator_(graph_theory)
* for more.
*/
export function computeDominatorTree(fn: HIRFunction): Dominator<BlockId> {
const graph = buildGraph(fn);
const nodes = computeImmediateDominators(graph);
return new Dominator(graph.entry, nodes);
}
/*
* Similar to `computeDominatorTree()` but computes the post dominators of the function. The returned
* `PostDominator` stores the immediate post-dominators of each node in the function.
*
* A block Y post-dominates block X in the CFG if all paths from X to the exit must flow through Y.
* The caller must specify whether to consider `throw` statements as exit nodes. If set to false,
* only return statements are considered exit nodes.
*/
export function computePostDominatorTree(
fn: HIRFunction,
options: {includeThrowsAsExitNode: boolean},
): PostDominator<BlockId> {
const graph = buildReverseGraph(fn, options.includeThrowsAsExitNode);
const nodes = computeImmediateDominators(graph);
/*
* When options.includeThrowsAsExitNode is false, nodes that flow into a throws
* terminal and don't reach the exit node won't be in the node map. Add them
* with themselves as dominator to reflect that they don't flow into the exit.
*/
if (!options.includeThrowsAsExitNode) {
for (const [id] of fn.body.blocks) {
if (!nodes.has(id)) {
nodes.set(id, id);
}
}
}
return new PostDominator(graph.entry, nodes);
}
type Node<T> = {
id: T;
index: number;
preds: Set<T>;
// ... (228 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
Source
Frequently Asked Questions
What does Dominator.ts do?
Dominator.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 Dominator.ts?
Dominator.ts defines 6 function(s): buildGraph, buildReverseGraph, computeDominatorTree, computeImmediateDominators, computePostDominatorTree, intersect.
What does Dominator.ts depend on?
Dominator.ts imports 8 module(s): BlockId, CompilerError, CompilerError.ts, HIR.ts, HIRFunction, eachTerminalSuccessor, pretty-format, visitors.ts.
What files import Dominator.ts?
Dominator.ts is imported by 1 file(s): ControlDominators.ts.
Where is Dominator.ts in the architecture?
Dominator.ts is located at compiler/packages/babel-plugin-react-compiler/src/HIR/Dominator.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