Home / Function/ computeSignatureForInstruction() — react Function Reference

computeSignatureForInstruction() — react Function Reference

Architecture documentation for the computeSignatureForInstruction() function in InferMutationAliasingEffects.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  a00426de_5aa3_d680_a1fe_29201ff58984["computeSignatureForInstruction()"]
  d24875c3_c045_4414_2cc9_16f96d59c629["InferMutationAliasingEffects.ts"]
  a00426de_5aa3_d680_a1fe_29201ff58984 -->|defined in| d24875c3_c045_4414_2cc9_16f96d59c629
  ac82e9ee_09bc_b58c_f2ac_86bf2d552540["inferBlock()"]
  ac82e9ee_09bc_b58c_f2ac_86bf2d552540 -->|calls| a00426de_5aa3_d680_a1fe_29201ff58984
  e29ee9ee_fc58_c34d_6913_1e7baa76e702["conditionallyMutateIterator()"]
  a00426de_5aa3_d680_a1fe_29201ff58984 -->|calls| e29ee9ee_fc58_c34d_6913_1e7baa76e702
  d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"]
  a00426de_5aa3_d680_a1fe_29201ff58984 -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6
  d2c89465_144e_76da_505e_4a2de182f6f4["getFunctionCallSignature()"]
  a00426de_5aa3_d680_a1fe_29201ff58984 -->|calls| d2c89465_144e_76da_505e_4a2de182f6f4
  b2fc2985_a7ba_9865_c2a3_2a7531f27d44["eachInstructionValueOperand()"]
  a00426de_5aa3_d680_a1fe_29201ff58984 -->|calls| b2fc2985_a7ba_9865_c2a3_2a7531f27d44
  13924a9d_e73a_6d54_de57_dd59bb471df1["eachPatternItem()"]
  a00426de_5aa3_d680_a1fe_29201ff58984 -->|calls| 13924a9d_e73a_6d54_de57_dd59bb471df1
  ac13f5c1_be17_dd7a_6bd3_66d91c46aadf["create()"]
  a00426de_5aa3_d680_a1fe_29201ff58984 -->|calls| ac13f5c1_be17_dd7a_6bd3_66d91c46aadf
  1a2b7047_24c8_62d6_b328_5f07307d27ab["withDetails()"]
  a00426de_5aa3_d680_a1fe_29201ff58984 -->|calls| 1a2b7047_24c8_62d6_b328_5f07307d27ab
  53244187_914c_cc90_5880_7bfc1fc9c0bb["push()"]
  a00426de_5aa3_d680_a1fe_29201ff58984 -->|calls| 53244187_914c_cc90_5880_7bfc1fc9c0bb
  style a00426de_5aa3_d680_a1fe_29201ff58984 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts lines 1724–2305

function computeSignatureForInstruction(
  context: Context,
  env: Environment,
  instr: Instruction,
): InstructionSignature {
  const {lvalue, value} = instr;
  const effects: Array<AliasingEffect> = [];
  switch (value.kind) {
    case 'ArrayExpression': {
      effects.push({
        kind: 'Create',
        into: lvalue,
        value: ValueKind.Mutable,
        reason: ValueReason.Other,
      });
      // All elements are captured into part of the output value
      for (const element of value.elements) {
        if (element.kind === 'Identifier') {
          effects.push({
            kind: 'Capture',
            from: element,
            into: lvalue,
          });
        } else if (element.kind === 'Spread') {
          const mutateIterator = conditionallyMutateIterator(element.place);
          if (mutateIterator != null) {
            effects.push(mutateIterator);
          }
          effects.push({
            kind: 'Capture',
            from: element.place,
            into: lvalue,
          });
        } else {
          continue;
        }
      }
      break;
    }
    case 'ObjectExpression': {
      effects.push({
        kind: 'Create',
        into: lvalue,
        value: ValueKind.Mutable,
        reason: ValueReason.Other,
      });
      for (const property of value.properties) {
        if (property.kind === 'ObjectProperty') {
          effects.push({
            kind: 'Capture',
            from: property.place,
            into: lvalue,
          });
        } else {
          effects.push({
            kind: 'Capture',
            from: property.place,
            into: lvalue,
          });
        }
      }
      break;
    }
    case 'Await': {
      effects.push({
        kind: 'Create',
        into: lvalue,
        value: ValueKind.Mutable,
        reason: ValueReason.Other,
      });
      // Potentially mutates the receiver (awaiting it changes its state and can run side effects)
      effects.push({kind: 'MutateTransitiveConditionally', value: value.value});
      /**
       * Data from the promise may be returned into the result, but await does not directly return
       * the promise itself
       */
      effects.push({
        kind: 'Capture',
        from: value.value,
        into: lvalue,
      });

Domain

Subdomains

Called By

Frequently Asked Questions

What does computeSignatureForInstruction() do?
computeSignatureForInstruction() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts.
Where is computeSignatureForInstruction() defined?
computeSignatureForInstruction() is defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts at line 1724.
What does computeSignatureForInstruction() call?
computeSignatureForInstruction() calls 8 function(s): assertExhaustive, conditionallyMutateIterator, create, eachInstructionValueOperand, eachPatternItem, getFunctionCallSignature, push, withDetails.
What calls computeSignatureForInstruction()?
computeSignatureForInstruction() is called by 1 function(s): inferBlock.

Analyze Your Own Codebase

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

Try Supermodel Free