Home / Function/ constantPropagationImpl() — react Function Reference

constantPropagationImpl() — react Function Reference

Architecture documentation for the constantPropagationImpl() function in ConstantPropagation.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  fbdc3953_3621_331c_a5b1_d3199bea5254["constantPropagationImpl()"]
  ee83ff7b_e532_0fd6_0eae_7fe885ffe129["ConstantPropagation.ts"]
  fbdc3953_3621_331c_a5b1_d3199bea5254 -->|defined in| ee83ff7b_e532_0fd6_0eae_7fe885ffe129
  2e35d5f1_9a0c_ffa0_1749_fb79ea43d847["constantPropagation()"]
  2e35d5f1_9a0c_ffa0_1749_fb79ea43d847 -->|calls| fbdc3953_3621_331c_a5b1_d3199bea5254
  7da3db63_9dcc_8c1f_be1f_66f4e99b59ea["evaluateInstruction()"]
  7da3db63_9dcc_8c1f_be1f_66f4e99b59ea -->|calls| fbdc3953_3621_331c_a5b1_d3199bea5254
  4419ef20_4b5f_b18c_6237_57b76d298666["applyConstantPropagation()"]
  fbdc3953_3621_331c_a5b1_d3199bea5254 -->|calls| 4419ef20_4b5f_b18c_6237_57b76d298666
  0ed953ae_5345_6a11_8ecf_c387365fdf84["reversePostorderBlocks()"]
  fbdc3953_3621_331c_a5b1_d3199bea5254 -->|calls| 0ed953ae_5345_6a11_8ecf_c387365fdf84
  4fd451a9_a7fd_9520_07fd_783e18d24c84["removeUnreachableForUpdates()"]
  fbdc3953_3621_331c_a5b1_d3199bea5254 -->|calls| 4fd451a9_a7fd_9520_07fd_783e18d24c84
  ba25d103_adb3_8e17_0348_cdf4b23496b5["removeDeadDoWhileStatements()"]
  fbdc3953_3621_331c_a5b1_d3199bea5254 -->|calls| ba25d103_adb3_8e17_0348_cdf4b23496b5
  c678dac0_f0b5_fd43_e8fe_97067c37de7d["removeUnnecessaryTryCatch()"]
  fbdc3953_3621_331c_a5b1_d3199bea5254 -->|calls| c678dac0_f0b5_fd43_e8fe_97067c37de7d
  0c09df5a_6c07_11e5_1a6b_9253007463b8["markInstructionIds()"]
  fbdc3953_3621_331c_a5b1_d3199bea5254 -->|calls| 0c09df5a_6c07_11e5_1a6b_9253007463b8
  6d209f7d_6d38_4dee_c66c_76af0358f508["markPredecessors()"]
  fbdc3953_3621_331c_a5b1_d3199bea5254 -->|calls| 6d209f7d_6d38_4dee_c66c_76af0358f508
  style fbdc3953_3621_331c_a5b1_d3199bea5254 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Optimization/ConstantPropagation.ts lines 64–105

function constantPropagationImpl(fn: HIRFunction, constants: Constants): void {
  while (true) {
    const haveTerminalsChanged = applyConstantPropagation(fn, constants);
    if (!haveTerminalsChanged) {
      break;
    }
    /*
     * 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);
    markPredecessors(fn.body);

    // Now that predecessors are updated, prune phi operands that can never be reached
    for (const [, block] of fn.body.blocks) {
      for (const phi of block.phis) {
        for (const [predecessor] of phi.operands) {
          if (!block.preds.has(predecessor)) {
            phi.operands.delete(predecessor);
          }
        }
      }
    }
    /*
     * By removing some phi operands, there may be phis that were not previously
     * redundant but now are
     */
    eliminateRedundantPhi(fn);
    /*
     * Finally, merge together any blocks that are now guaranteed to execute
     * consecutively
     */
    mergeConsecutiveBlocks(fn);

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

Domain

Subdomains

Frequently Asked Questions

What does constantPropagationImpl() do?
constantPropagationImpl() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/ConstantPropagation.ts.
Where is constantPropagationImpl() defined?
constantPropagationImpl() is defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/ConstantPropagation.ts at line 64.
What does constantPropagationImpl() call?
constantPropagationImpl() calls 7 function(s): applyConstantPropagation, markInstructionIds, markPredecessors, removeDeadDoWhileStatements, removeUnnecessaryTryCatch, removeUnreachableForUpdates, reversePostorderBlocks.
What calls constantPropagationImpl()?
constantPropagationImpl() is called by 2 function(s): constantPropagation, evaluateInstruction.

Analyze Your Own Codebase

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

Try Supermodel Free