findReferencedRangeOfTemporaries() — react Function Reference
Architecture documentation for the findReferencedRangeOfTemporaries() function in InstructionReordering.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 8b5121a5_55ad_8904_6f4c_ab19201c32ee["findReferencedRangeOfTemporaries()"] dc3f5251_a95c_3c77_5550_3882c13a37c9["InstructionReordering.ts"] 8b5121a5_55ad_8904_6f4c_ab19201c32ee -->|defined in| dc3f5251_a95c_3c77_5550_3882c13a37c9 06363a0e_405c_bfba_71c1_808efa86a089["instructionReordering()"] 06363a0e_405c_bfba_71c1_808efa86a089 -->|calls| 8b5121a5_55ad_8904_6f4c_ab19201c32ee 21b1eb1e_eaf5_5238_3a24_f56eb8ef7278["eachInstructionValueLValue()"] 8b5121a5_55ad_8904_6f4c_ab19201c32ee -->|calls| 21b1eb1e_eaf5_5238_3a24_f56eb8ef7278 10043bf1_f7ee_9ed9_307a_fe3edfd02b09["eachInstructionLValue()"] 8b5121a5_55ad_8904_6f4c_ab19201c32ee -->|calls| 10043bf1_f7ee_9ed9_307a_fe3edfd02b09 41232a25_deb6_6e83_05a8_ae9f961656f7["eachTerminalOperand()"] 8b5121a5_55ad_8904_6f4c_ab19201c32ee -->|calls| 41232a25_deb6_6e83_05a8_ae9f961656f7 style 8b5121a5_55ad_8904_6f4c_ab19201c32ee fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Optimization/InstructionReordering.ts lines 110–161
function findReferencedRangeOfTemporaries(fn: HIRFunction): References {
const singleUseIdentifiers = new Map<IdentifierId, number>();
const lastAssignments: LastAssignments = new Map();
function reference(
instr: InstructionId,
place: Place,
kind: ReferenceKind,
): void {
if (
place.identifier.name !== null &&
place.identifier.name.kind === 'named'
) {
if (kind === ReferenceKind.Write) {
const name = place.identifier.name.value;
const previous = lastAssignments.get(name);
if (previous === undefined) {
lastAssignments.set(name, instr);
} else {
lastAssignments.set(
name,
makeInstructionId(Math.max(previous, instr)),
);
}
}
return;
} else if (kind === ReferenceKind.Read) {
const previousCount = singleUseIdentifiers.get(place.identifier.id) ?? 0;
singleUseIdentifiers.set(place.identifier.id, previousCount + 1);
}
}
for (const [, block] of fn.body.blocks) {
for (const instr of block.instructions) {
for (const operand of eachInstructionValueLValue(instr.value)) {
reference(instr.id, operand, ReferenceKind.Read);
}
for (const lvalue of eachInstructionLValue(instr)) {
reference(instr.id, lvalue, ReferenceKind.Write);
}
}
for (const operand of eachTerminalOperand(block.terminal)) {
reference(block.terminal.id, operand, ReferenceKind.Read);
}
}
return {
singleUseIdentifiers: new Set(
[...singleUseIdentifiers]
.filter(([, count]) => count === 1)
.map(([id]) => id),
),
lastAssignments,
};
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does findReferencedRangeOfTemporaries() do?
findReferencedRangeOfTemporaries() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/InstructionReordering.ts.
Where is findReferencedRangeOfTemporaries() defined?
findReferencedRangeOfTemporaries() is defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/InstructionReordering.ts at line 110.
What does findReferencedRangeOfTemporaries() call?
findReferencedRangeOfTemporaries() calls 3 function(s): eachInstructionLValue, eachInstructionValueLValue, eachTerminalOperand.
What calls findReferencedRangeOfTemporaries()?
findReferencedRangeOfTemporaries() is called by 1 function(s): instructionReordering.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free