Home / Function/ findHoistedContextDeclarations() — react Function Reference

findHoistedContextDeclarations() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  a434dd08_0de3_17ca_8d4f_08a598a9c73e["findHoistedContextDeclarations()"]
  d24875c3_c045_4414_2cc9_16f96d59c629["InferMutationAliasingEffects.ts"]
  a434dd08_0de3_17ca_8d4f_08a598a9c73e -->|defined in| d24875c3_c045_4414_2cc9_16f96d59c629
  1f2853c7_05e1_f3c4_b9d5_1f5ca0f648ea["inferMutationAliasingEffects()"]
  1f2853c7_05e1_f3c4_b9d5_1f5ca0f648ea -->|calls| a434dd08_0de3_17ca_8d4f_08a598a9c73e
  bcbdcfbc_a2a4_dd2d_09f6_b6643e95eb6e["values()"]
  a434dd08_0de3_17ca_8d4f_08a598a9c73e -->|calls| bcbdcfbc_a2a4_dd2d_09f6_b6643e95eb6e
  b2fc2985_a7ba_9865_c2a3_2a7531f27d44["eachInstructionValueOperand()"]
  a434dd08_0de3_17ca_8d4f_08a598a9c73e -->|calls| b2fc2985_a7ba_9865_c2a3_2a7531f27d44
  41232a25_deb6_6e83_05a8_ae9f961656f7["eachTerminalOperand()"]
  a434dd08_0de3_17ca_8d4f_08a598a9c73e -->|calls| 41232a25_deb6_6e83_05a8_ae9f961656f7
  style a434dd08_0de3_17ca_8d4f_08a598a9c73e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts lines 226–261

function findHoistedContextDeclarations(
  fn: HIRFunction,
): Map<DeclarationId, Place | null> {
  const hoisted = new Map<DeclarationId, Place | null>();
  function visit(place: Place): void {
    if (
      hoisted.has(place.identifier.declarationId) &&
      hoisted.get(place.identifier.declarationId) == null
    ) {
      // If this is the first load of the value, store the location
      hoisted.set(place.identifier.declarationId, place);
    }
  }
  for (const block of fn.body.blocks.values()) {
    for (const instr of block.instructions) {
      if (instr.value.kind === 'DeclareContext') {
        const kind = instr.value.lvalue.kind;
        if (
          kind == InstructionKind.HoistedConst ||
          kind == InstructionKind.HoistedFunction ||
          kind == InstructionKind.HoistedLet
        ) {
          hoisted.set(instr.value.lvalue.place.identifier.declarationId, null);
        }
      } else {
        for (const operand of eachInstructionValueOperand(instr.value)) {
          visit(operand);
        }
      }
    }
    for (const operand of eachTerminalOperand(block.terminal)) {
      visit(operand);
    }
  }
  return hoisted;
}

Domain

Subdomains

Frequently Asked Questions

What does findHoistedContextDeclarations() do?
findHoistedContextDeclarations() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts.
Where is findHoistedContextDeclarations() defined?
findHoistedContextDeclarations() is defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts at line 226.
What does findHoistedContextDeclarations() call?
findHoistedContextDeclarations() calls 3 function(s): eachInstructionValueOperand, eachTerminalOperand, values.
What calls findHoistedContextDeclarations()?
findHoistedContextDeclarations() is called by 1 function(s): inferMutationAliasingEffects.

Analyze Your Own Codebase

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

Try Supermodel Free