Home / Function/ handleInstruction() — react Function Reference

handleInstruction() — react Function Reference

Architecture documentation for the handleInstruction() function in InferReactivePlaces.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  0f37c797_b04e_2552_16c2_13b03579eacc["handleInstruction()"]
  24d977c1_0b75_d998_4952_173d24efaaea["StableSidemap"]
  0f37c797_b04e_2552_16c2_13b03579eacc -->|defined in| 24d977c1_0b75_d998_4952_173d24efaaea
  fddc4da2_1151_8052_c771_8b67085ebeca["inferReactivePlaces()"]
  fddc4da2_1151_8052_c771_8b67085ebeca -->|calls| 0f37c797_b04e_2552_16c2_13b03579eacc
  10043bf1_f7ee_9ed9_307a_fe3edfd02b09["eachInstructionLValue()"]
  0f37c797_b04e_2552_16c2_13b03579eacc -->|calls| 10043bf1_f7ee_9ed9_307a_fe3edfd02b09
  style 0f37c797_b04e_2552_16c2_13b03579eacc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Inference/InferReactivePlaces.ts lines 51–120

  handleInstruction(instr: Instruction): void {
    const {value, lvalue} = instr;

    switch (value.kind) {
      case 'CallExpression':
      case 'MethodCall': {
        /**
         * Sources of stability are known hook calls
         */
        if (evaluatesToStableTypeOrContainer(this.env, instr)) {
          if (isStableType(lvalue.identifier)) {
            this.map.set(lvalue.identifier.id, {
              isStable: true,
            });
          } else {
            this.map.set(lvalue.identifier.id, {
              isStable: false,
            });
          }
        }
        break;
      }

      case 'Destructure':
      case 'PropertyLoad': {
        /**
         * PropertyLoads may from stable containers may also produce stable
         * values. ComputedLoads are technically safe for now (as all stable
         * containers have differently-typed elements), but are not handled as
         * they should be rare anyways.
         */
        const source =
          value.kind === 'Destructure'
            ? value.value.identifier.id
            : value.object.identifier.id;
        const entry = this.map.get(source);
        if (entry) {
          for (const lvalue of eachInstructionLValue(instr)) {
            if (isStableTypeContainer(lvalue.identifier)) {
              this.map.set(lvalue.identifier.id, {
                isStable: false,
              });
            } else if (isStableType(lvalue.identifier)) {
              this.map.set(lvalue.identifier.id, {
                isStable: true,
              });
            }
          }
        }
        break;
      }

      case 'StoreLocal': {
        const entry = this.map.get(value.value.identifier.id);
        if (entry) {
          this.map.set(lvalue.identifier.id, entry);
          this.map.set(value.lvalue.place.identifier.id, entry);
        }
        break;
      }

      case 'LoadLocal': {
        const entry = this.map.get(value.place.identifier.id);
        if (entry) {
          this.map.set(lvalue.identifier.id, entry);
        }
        break;
      }
    }
  }

Domain

Subdomains

Frequently Asked Questions

What does handleInstruction() do?
handleInstruction() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferReactivePlaces.ts.
Where is handleInstruction() defined?
handleInstruction() is defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferReactivePlaces.ts at line 51.
What does handleInstruction() call?
handleInstruction() calls 1 function(s): eachInstructionLValue.
What calls handleInstruction()?
handleInstruction() is called by 1 function(s): inferReactivePlaces.

Analyze Your Own Codebase

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

Try Supermodel Free