Home / Function/ pruneMaybeThrows() — react Function Reference

pruneMaybeThrows() — react Function Reference

Architecture documentation for the pruneMaybeThrows() function in PruneMaybeThrows.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  82b1d221_48c8_7d34_669c_abce4ff71f21["pruneMaybeThrows()"]
  7b84c51c_1c0f_cc0c_c3be_9da73dc183aa["PruneMaybeThrows.ts"]
  82b1d221_48c8_7d34_669c_abce4ff71f21 -->|defined in| 7b84c51c_1c0f_cc0c_c3be_9da73dc183aa
  76aaa4bc_62ed_032d_e274_f5e5d6ced883["pruneMaybeThrowsImpl()"]
  82b1d221_48c8_7d34_669c_abce4ff71f21 -->|calls| 76aaa4bc_62ed_032d_e274_f5e5d6ced883
  0ed953ae_5345_6a11_8ecf_c387365fdf84["reversePostorderBlocks()"]
  82b1d221_48c8_7d34_669c_abce4ff71f21 -->|calls| 0ed953ae_5345_6a11_8ecf_c387365fdf84
  4fd451a9_a7fd_9520_07fd_783e18d24c84["removeUnreachableForUpdates()"]
  82b1d221_48c8_7d34_669c_abce4ff71f21 -->|calls| 4fd451a9_a7fd_9520_07fd_783e18d24c84
  ba25d103_adb3_8e17_0348_cdf4b23496b5["removeDeadDoWhileStatements()"]
  82b1d221_48c8_7d34_669c_abce4ff71f21 -->|calls| ba25d103_adb3_8e17_0348_cdf4b23496b5
  c678dac0_f0b5_fd43_e8fe_97067c37de7d["removeUnnecessaryTryCatch()"]
  82b1d221_48c8_7d34_669c_abce4ff71f21 -->|calls| c678dac0_f0b5_fd43_e8fe_97067c37de7d
  0c09df5a_6c07_11e5_1a6b_9253007463b8["markInstructionIds()"]
  82b1d221_48c8_7d34_669c_abce4ff71f21 -->|calls| 0c09df5a_6c07_11e5_1a6b_9253007463b8
  bf7f1cf7_fc0e_6bac_827c_8d36d98126da["printPlace()"]
  82b1d221_48c8_7d34_669c_abce4ff71f21 -->|calls| bf7f1cf7_fc0e_6bac_827c_8d36d98126da
  style 82b1d221_48c8_7d34_669c_abce4ff71f21 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Optimization/PruneMaybeThrows.ts lines 38–75

export function pruneMaybeThrows(fn: HIRFunction): void {
  const terminalMapping = pruneMaybeThrowsImpl(fn);
  if (terminalMapping) {
    /*
     * If terminals have changed then blocks may have become newly unreachable.
     * Re-run minification of the graph (incl reordering instruction ids)
     */
    reversePostorderBlocks(fn.body);
    removeUnreachableForUpdates(fn.body);
    removeDeadDoWhileStatements(fn.body);
    removeUnnecessaryTryCatch(fn.body);
    markInstructionIds(fn.body);
    mergeConsecutiveBlocks(fn);

    // Rewrite phi operands to reference the updated predecessor blocks
    for (const [, block] of fn.body.blocks) {
      for (const phi of block.phis) {
        for (const [predecessor, operand] of phi.operands) {
          if (!block.preds.has(predecessor)) {
            const mappedTerminal = terminalMapping.get(predecessor);
            CompilerError.invariant(mappedTerminal != null, {
              reason: `Expected non-existing phi operand's predecessor to have been mapped to a new terminal`,
              description: `Could not find mapping for predecessor bb${predecessor} in block bb${
                block.id
              } for phi ${printPlace(phi.place)}`,
              loc: GeneratedSource,
            });
            phi.operands.delete(predecessor);
            phi.operands.set(mappedTerminal, operand);
          }
        }
      }
    }

    assertConsistentIdentifiers(fn);
    assertTerminalSuccessorsExist(fn);
  }
}

Domain

Subdomains

Frequently Asked Questions

What does pruneMaybeThrows() do?
pruneMaybeThrows() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/PruneMaybeThrows.ts.
Where is pruneMaybeThrows() defined?
pruneMaybeThrows() is defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/PruneMaybeThrows.ts at line 38.
What does pruneMaybeThrows() call?
pruneMaybeThrows() calls 7 function(s): markInstructionIds, printPlace, pruneMaybeThrowsImpl, removeDeadDoWhileStatements, removeUnnecessaryTryCatch, removeUnreachableForUpdates, reversePostorderBlocks.

Analyze Your Own Codebase

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

Try Supermodel Free