recordInstructionDerivations() — react Function Reference
Architecture documentation for the recordInstructionDerivations() function in ValidateNoDerivedComputationsInEffects_exp.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 23e95905_7740_9185_1ad6_1a529d6f88ad["recordInstructionDerivations()"] a38a9d1f_969c_8056_aa80_6cb5fedba226["ValidateNoDerivedComputationsInEffects_exp.ts"] 23e95905_7740_9185_1ad6_1a529d6f88ad -->|defined in| a38a9d1f_969c_8056_aa80_6cb5fedba226 f9f36408_8e51_961b_c26d_24ee285bd479["validateNoDerivedComputationsInEffects_exp()"] f9f36408_8e51_961b_c26d_24ee285bd479 -->|calls| 23e95905_7740_9185_1ad6_1a529d6f88ad d206b1f3_3227_c6ab_9a06_aa3ed56d36cf["maybeRecordSetState()"] 23e95905_7740_9185_1ad6_1a529d6f88ad -->|calls| d206b1f3_3227_c6ab_9a06_aa3ed56d36cf 2d80e3d3_eaf3_911b_9f07_e94ea4f8013f["recordPhiDerivations()"] 23e95905_7740_9185_1ad6_1a529d6f88ad -->|calls| 2d80e3d3_eaf3_911b_9f07_e94ea4f8013f d47181e1_cf8f_56cd_bdd7_4bce6f7d15d9["addDerivationEntry()"] 23e95905_7740_9185_1ad6_1a529d6f88ad -->|calls| d47181e1_cf8f_56cd_bdd7_4bce6f7d15d9 ccace1c3_85b7_a05e_c2a5_7eff8b3422ed["eachInstructionOperand()"] 23e95905_7740_9185_1ad6_1a529d6f88ad -->|calls| ccace1c3_85b7_a05e_c2a5_7eff8b3422ed 58133747_182e_d838_f59c_07fbac51ed59["getRootSetState()"] 23e95905_7740_9185_1ad6_1a529d6f88ad -->|calls| 58133747_182e_d838_f59c_07fbac51ed59 6184bf45_a975_a050_1701_b84d78f350c9["joinValue()"] 23e95905_7740_9185_1ad6_1a529d6f88ad -->|calls| 6184bf45_a975_a050_1701_b84d78f350c9 10043bf1_f7ee_9ed9_307a_fe3edfd02b09["eachInstructionLValue()"] 23e95905_7740_9185_1ad6_1a529d6f88ad -->|calls| 10043bf1_f7ee_9ed9_307a_fe3edfd02b09 11746e9a_2fdf_98bb_bb3c_a63d8b200df2["isMutable()"] 23e95905_7740_9185_1ad6_1a529d6f88ad -->|calls| 11746e9a_2fdf_98bb_bb3c_a63d8b200df2 041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"] 23e95905_7740_9185_1ad6_1a529d6f88ad -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"] 23e95905_7740_9185_1ad6_1a529d6f88ad -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6 style 23e95905_7740_9185_1ad6_1a529d6f88ad fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts lines 347–492
function recordInstructionDerivations(
instr: Instruction,
context: ValidationContext,
isFirstPass: boolean,
): void {
maybeRecordSetState(instr, context.setStateLoads, context.setStateUsages);
let typeOfValue: TypeOfValue = 'ignored';
let isSource: boolean = false;
const sources: Set<IdentifierId> = new Set();
const {lvalue, value} = instr;
if (value.kind === 'FunctionExpression') {
context.functions.set(lvalue.identifier.id, value);
for (const [, block] of value.loweredFunc.func.body.blocks) {
recordPhiDerivations(block, context);
for (const instr of block.instructions) {
recordInstructionDerivations(instr, context, isFirstPass);
}
}
} else if (value.kind === 'CallExpression' || value.kind === 'MethodCall') {
const callee =
value.kind === 'CallExpression' ? value.callee : value.property;
if (
isUseEffectHookType(callee.identifier) &&
value.args.length === 2 &&
value.args[0].kind === 'Identifier' &&
value.args[1].kind === 'Identifier'
) {
const effectFunction = context.functions.get(value.args[0].identifier.id);
const deps = context.candidateDependencies.get(
value.args[1].identifier.id,
);
if (effectFunction != null && deps != null) {
context.effectsCache.set(value.args[0].identifier.id, {
effect: effectFunction.loweredFunc.func,
dependencies: deps,
});
}
} else if (isUseStateType(lvalue.identifier)) {
typeOfValue = 'fromState';
context.derivationCache.addDerivationEntry(
lvalue,
new Set(),
typeOfValue,
true,
);
return;
}
} else if (value.kind === 'ArrayExpression') {
context.candidateDependencies.set(lvalue.identifier.id, value);
}
for (const operand of eachInstructionOperand(instr)) {
if (context.setStateLoads.has(operand.identifier.id)) {
const rootSetStateId = getRootSetState(
operand.identifier.id,
context.setStateLoads,
);
if (rootSetStateId !== null) {
context.setStateUsages.get(rootSetStateId)?.add(operand.loc);
}
}
const operandMetadata = context.derivationCache.cache.get(
operand.identifier.id,
);
if (operandMetadata === undefined) {
continue;
}
typeOfValue = joinValue(typeOfValue, operandMetadata.typeOfValue);
sources.add(operand.identifier.id);
}
if (typeOfValue === 'ignored') {
return;
}
for (const lvalue of eachInstructionLValue(instr)) {
context.derivationCache.addDerivationEntry(
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does recordInstructionDerivations() do?
recordInstructionDerivations() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts.
Where is recordInstructionDerivations() defined?
recordInstructionDerivations() is defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts at line 347.
What does recordInstructionDerivations() call?
recordInstructionDerivations() calls 10 function(s): addDerivationEntry, assertExhaustive, eachInstructionLValue, eachInstructionOperand, getRootSetState, invariant, isMutable, joinValue, and 2 more.
What calls recordInstructionDerivations()?
recordInstructionDerivations() is called by 1 function(s): validateNoDerivedComputationsInEffects_exp.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free