Home / Function/ getIdAt() — react Function Reference

getIdAt() — react Function Reference

Architecture documentation for the getIdAt() function in EnterSSA.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  ab76c4b1_9d69_98c8_d44f_9505c6f4c84e["getIdAt()"]
  f11adc00_6af6_2575_4ee8_974e26f2a6ed["SSABuilder"]
  ab76c4b1_9d69_98c8_d44f_9505c6f4c84e -->|defined in| f11adc00_6af6_2575_4ee8_974e26f2a6ed
  9038f078_e688_0fe0_26fd_2eb655330c6f["getPlace()"]
  9038f078_e688_0fe0_26fd_2eb655330c6f -->|calls| ab76c4b1_9d69_98c8_d44f_9505c6f4c84e
  239be53b_dfd4_96c6_9550_ca5aa6b80da2["addPhi()"]
  239be53b_dfd4_96c6_9550_ca5aa6b80da2 -->|calls| ab76c4b1_9d69_98c8_d44f_9505c6f4c84e
  dde21261_8a25_cb71_4e56_b0eb6348704b["makeId()"]
  ab76c4b1_9d69_98c8_d44f_9505c6f4c84e -->|calls| dde21261_8a25_cb71_4e56_b0eb6348704b
  239be53b_dfd4_96c6_9550_ca5aa6b80da2["addPhi()"]
  ab76c4b1_9d69_98c8_d44f_9505c6f4c84e -->|calls| 239be53b_dfd4_96c6_9550_ca5aa6b80da2
  bf7f1cf7_fc0e_6bac_827c_8d36d98126da["printPlace()"]
  ab76c4b1_9d69_98c8_d44f_9505c6f4c84e -->|calls| bf7f1cf7_fc0e_6bac_827c_8d36d98126da
  073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"]
  ab76c4b1_9d69_98c8_d44f_9505c6f4c84e -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83
  style ab76c4b1_9d69_98c8_d44f_9505c6f4c84e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/SSA/EnterSSA.ts lines 131–184

  getIdAt(oldPlace: Place, blockId: BlockId): Identifier {
    // check if Place is defined locally
    const block = this.#blocks.get(blockId)!;
    const state = this.#states.get(block)!;

    if (state.defs.has(oldPlace.identifier)) {
      return state.defs.get(oldPlace.identifier)!;
    }

    if (block.preds.size == 0) {
      /*
       * We're at the entry block and haven't found our defintion yet.
       * console.log(
       *   `Unable to find "${printPlace(
       *     oldPlace
       *   )}" in bb${blockId}, assuming it's a global`
       * );
       */
      this.#unknown.add(oldPlace.identifier);
      return oldPlace.identifier;
    }

    if (this.unsealedPreds.get(block)! > 0) {
      /*
       * We haven't visited all our predecessors, let's place an incomplete phi
       * for now.
       */
      const newId = this.makeId(oldPlace.identifier);
      state.incompletePhis.push({
        oldPlace,
        newPlace: {...oldPlace, identifier: newId},
      });
      state.defs.set(oldPlace.identifier, newId);
      return newId;
    }

    // Only one predecessor, let's check there
    if (block.preds.size == 1) {
      const [pred] = block.preds;
      const newId = this.getIdAt(oldPlace, pred);
      state.defs.set(oldPlace.identifier, newId);
      return newId;
    }

    // There are multiple predecessors, we may need a phi.
    const newId = this.makeId(oldPlace.identifier);
    /*
     * Adding a phi may loop back to our block if there is a loop in the CFG.  We
     * update our defs before adding the phi to terminate the recursion rather than
     * looping infinitely.
     */
    state.defs.set(oldPlace.identifier, newId);
    return this.addPhi(block, oldPlace, {...oldPlace, identifier: newId});
  }

Subdomains

Called By

Frequently Asked Questions

What does getIdAt() do?
getIdAt() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/SSA/EnterSSA.ts.
Where is getIdAt() defined?
getIdAt() is defined in compiler/packages/babel-plugin-react-compiler/src/SSA/EnterSSA.ts at line 131.
What does getIdAt() call?
getIdAt() calls 4 function(s): addPhi, makeId, printPlace, push.
What calls getIdAt()?
getIdAt() is called by 2 function(s): addPhi, getPlace.

Analyze Your Own Codebase

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

Try Supermodel Free