Home / Function/ rewriteSplices() — react Function Reference

rewriteSplices() — react Function Reference

Architecture documentation for the rewriteSplices() function in InferEffectDependencies.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  289382ca_3f09_e2a4_102d_6227edb1872f["rewriteSplices()"]
  3393f920_76eb_7dd5_b95f_ab92de6cecce["InferEffectDependencies.ts"]
  289382ca_3f09_e2a4_102d_6227edb1872f -->|defined in| 3393f920_76eb_7dd5_b95f_ab92de6cecce
  3522f83b_2dff_3c9f_920f_3e428eb62b31["inferEffectDependencies()"]
  3522f83b_2dff_3c9f_920f_3e428eb62b31 -->|calls| 289382ca_3f09_e2a4_102d_6227edb1872f
  127c19ef_021e_5644_a84e_da0d0ed84999["terminalFallthrough()"]
  289382ca_3f09_e2a4_102d_6227edb1872f -->|calls| 127c19ef_021e_5644_a84e_da0d0ed84999
  53244187_914c_cc90_5880_7bfc1fc9c0bb["push()"]
  289382ca_3f09_e2a4_102d_6227edb1872f -->|calls| 53244187_914c_cc90_5880_7bfc1fc9c0bb
  style 289382ca_3f09_e2a4_102d_6227edb1872f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts lines 373–490

function rewriteSplices(
  originalBlock: BasicBlock,
  splices: Array<SpliceInfo>,
  rewriteBlocks: Array<BasicBlock>,
): void {
  if (splices.length === 0) {
    return;
  }
  /**
   * Splice instructions or value blocks into the original block.
   * --- original block ---
   * bb_original
   *   instr1
   *   ...
   *   instr2 <-- splice location
   *   instr3
   *   ...
   *   <original terminal>
   *
   * If there is more than one block in the splice, this means that we're
   * splicing in a set of value-blocks of the following structure:
   * --- blocks we're splicing in ---
   * bb_entry:
   *   instrEntry
   *   ...
   *   <splice terminal> fallthrough=bb_exit
   *
   * bb1(value):
   *   ...
   *
   * bb_exit:
   *   instrExit
   *   ...
   *   <synthetic terminal>
   *
   *
   * --- rewritten blocks ---
   * bb_original
   *   instr1
   *   ... (original instructions)
   *   instr2
   *   instrEntry
   *   ... (spliced instructions)
   *   <splice terminal> fallthrough=bb_exit
   *
   * bb1(value):
   *   ...
   *
   * bb_exit:
   *   instrExit
   *   ... (spliced instructions)
   *   instr3
   *   ... (original instructions)
   *   <original terminal>
   */
  const originalInstrs = originalBlock.instructions;
  let currBlock: BasicBlock = {...originalBlock, instructions: []};
  rewriteBlocks.push(currBlock);

  let cursor = 0;

  for (const rewrite of splices) {
    while (originalInstrs[cursor].id < rewrite.location) {
      CompilerError.invariant(
        originalInstrs[cursor].id < originalInstrs[cursor + 1].id,
        {
          reason:
            '[InferEffectDependencies] Internal invariant broken: expected block instructions to be sorted',
          loc: originalInstrs[cursor].loc,
        },
      );
      currBlock.instructions.push(originalInstrs[cursor]);
      cursor++;
    }
    CompilerError.invariant(originalInstrs[cursor].id === rewrite.location, {
      reason:
        '[InferEffectDependencies] Internal invariant broken: splice location not found',
      loc: originalInstrs[cursor].loc,
    });

    if (rewrite.kind === 'instr') {

Domain

Subdomains

Frequently Asked Questions

What does rewriteSplices() do?
rewriteSplices() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts.
Where is rewriteSplices() defined?
rewriteSplices() is defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts at line 373.
What does rewriteSplices() call?
rewriteSplices() calls 2 function(s): push, terminalFallthrough.
What calls rewriteSplices()?
rewriteSplices() is called by 1 function(s): inferEffectDependencies.

Analyze Your Own Codebase

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

Try Supermodel Free