buildReverseGraph() — react Function Reference
Architecture documentation for the buildReverseGraph() function in Dominator.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 1701b18d_6c73_7c36_a402_f71529487c3e["buildReverseGraph()"] b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa["Dominator.ts"] 1701b18d_6c73_7c36_a402_f71529487c3e -->|defined in| b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa 7703f432_520f_80d2_69d8_201d9cb9eb55["computePostDominatorTree()"] 7703f432_520f_80d2_69d8_201d9cb9eb55 -->|calls| 1701b18d_6c73_7c36_a402_f71529487c3e d737cb4c_53f4_75b4_2d58_268e2f73fde4["eachTerminalSuccessor()"] 1701b18d_6c73_7c36_a402_f71529487c3e -->|calls| d737cb4c_53f4_75b4_2d58_268e2f73fde4 073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"] 1701b18d_6c73_7c36_a402_f71529487c3e -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83 style 1701b18d_6c73_7c36_a402_f71529487c3e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/HIR/Dominator.ts lines 232–287
function buildReverseGraph(
fn: HIRFunction,
includeThrowsAsExitNode: boolean,
): Graph<BlockId> {
const nodes: Map<BlockId, Node<BlockId>> = new Map();
const exitId = fn.env.nextBlockId;
const exit: Node<BlockId> = {
id: exitId,
index: 0,
preds: new Set(),
succs: new Set(),
};
nodes.set(exitId, exit);
for (const [id, block] of fn.body.blocks) {
const node: Node<BlockId> = {
id,
index: 0,
preds: new Set(eachTerminalSuccessor(block.terminal)),
succs: new Set(block.preds),
};
if (block.terminal.kind === 'return') {
node.preds.add(exitId);
exit.succs.add(id);
} else if (block.terminal.kind === 'throw' && includeThrowsAsExitNode) {
node.preds.add(exitId);
exit.succs.add(id);
}
nodes.set(id, node);
}
// Put nodes into RPO form
const visited = new Set<BlockId>();
const postorder: Array<BlockId> = [];
function visit(id: BlockId): void {
if (visited.has(id)) {
return;
}
visited.add(id);
const node = nodes.get(id)!;
for (const successor of node.succs) {
visit(successor);
}
postorder.push(id);
}
visit(exitId);
const rpo: Graph<BlockId> = {entry: exitId, nodes: new Map()};
let index = 0;
for (const id of postorder.reverse()) {
const node = nodes.get(id)!;
node.index = index++;
rpo.nodes.set(id, node);
}
return rpo;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does buildReverseGraph() do?
buildReverseGraph() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/Dominator.ts.
Where is buildReverseGraph() defined?
buildReverseGraph() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/Dominator.ts at line 232.
What does buildReverseGraph() call?
buildReverseGraph() calls 2 function(s): eachTerminalSuccessor, push.
What calls buildReverseGraph()?
buildReverseGraph() is called by 1 function(s): computePostDominatorTree.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free