Home / Function/ isImmutableAtInstr() — react Function Reference

isImmutableAtInstr() — react Function Reference

Architecture documentation for the isImmutableAtInstr() function in CollectHoistablePropertyLoads.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  cac490a6_2858_f9b4_a7b9_507c998b97b7["isImmutableAtInstr()"]
  53e05ed1_ffb1_8db2_8573_ef5a3fb99c72["CollectHoistablePropertyLoads.ts"]
  cac490a6_2858_f9b4_a7b9_507c998b97b7 -->|defined in| 53e05ed1_ffb1_8db2_8573_ef5a3fb99c72
  bdf8cdce_736e_1a2d_6a67_5dacbcb1d645["collectHoistablePropertyLoadsInInnerFn()"]
  bdf8cdce_736e_1a2d_6a67_5dacbcb1d645 -->|calls| cac490a6_2858_f9b4_a7b9_507c998b97b7
  2c85e7b5_d003_b439_dc7b_cb881996ea23["collectNonNullsInBlocks()"]
  2c85e7b5_d003_b439_dc7b_cb881996ea23 -->|calls| cac490a6_2858_f9b4_a7b9_507c998b97b7
  77f6c8f4_9a10_4ed4_40d4_5d5f7009db30["inRange()"]
  cac490a6_2858_f9b4_a7b9_507c998b97b7 -->|calls| 77f6c8f4_9a10_4ed4_40d4_5d5f7009db30
  style cac490a6_2858_f9b4_a7b9_507c998b97b7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts lines 344–378

function isImmutableAtInstr(
  identifier: Identifier,
  instr: InstructionId,
  context: CollectHoistablePropertyLoadsContext,
): boolean {
  if (context.nestedFnImmutableContext != null) {
    /**
     * Comparing instructions ids across inner-outer function bodies is not valid, as they are numbered
     */
    return context.nestedFnImmutableContext.has(identifier.id);
  } else {
    /**
     * Since this runs *after* buildReactiveScopeTerminals, identifier mutable ranges
     * are not valid with respect to current instruction id numbering.
     * We use attached reactive scope ranges as a proxy for mutable range, but this
     * is an overestimate as (1) scope ranges merge and align to form valid program
     * blocks and (2) passes like MemoizeFbtAndMacroOperands may assign scopes to
     * non-mutable identifiers.
     *
     * See comment in exported function for why we track known immutable identifiers.
     */
    const mutableAtInstr =
      identifier.mutableRange.end > identifier.mutableRange.start + 1 &&
      identifier.scope != null &&
      inRange(
        {
          id: instr,
        },
        identifier.scope.range,
      );
    return (
      !mutableAtInstr || context.knownImmutableIdentifiers.has(identifier.id)
    );
  }
}

Subdomains

Calls

Frequently Asked Questions

What does isImmutableAtInstr() do?
isImmutableAtInstr() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts.
Where is isImmutableAtInstr() defined?
isImmutableAtInstr() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts at line 344.
What does isImmutableAtInstr() call?
isImmutableAtInstr() calls 1 function(s): inRange.
What calls isImmutableAtInstr()?
isImmutableAtInstr() is called by 2 function(s): collectHoistablePropertyLoadsInInnerFn, collectNonNullsInBlocks.

Analyze Your Own Codebase

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

Try Supermodel Free