lowerWithMutationAliasing() — react Function Reference
Architecture documentation for the lowerWithMutationAliasing() function in AnalyseFunctions.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 549ab0df_dde0_c1fc_591d_a1d683921f55["lowerWithMutationAliasing()"] 212338a1_d579_40dc_af88_824802fa3262["AnalyseFunctions.ts"] 549ab0df_dde0_c1fc_591d_a1d683921f55 -->|defined in| 212338a1_d579_40dc_af88_824802fa3262 ce023a8c_3a25_5d00_7cf2_2a9d39a7abfa["analyseFunctions()"] ce023a8c_3a25_5d00_7cf2_2a9d39a7abfa -->|calls| 549ab0df_dde0_c1fc_591d_a1d683921f55 ce023a8c_3a25_5d00_7cf2_2a9d39a7abfa["analyseFunctions()"] 549ab0df_dde0_c1fc_591d_a1d683921f55 -->|calls| ce023a8c_3a25_5d00_7cf2_2a9d39a7abfa 1f2853c7_05e1_f3c4_b9d5_1f5ca0f648ea["inferMutationAliasingEffects()"] 549ab0df_dde0_c1fc_591d_a1d683921f55 -->|calls| 1f2853c7_05e1_f3c4_b9d5_1f5ca0f648ea f3815d1a_36a1_3e3d_92f2_dbbe88f01fe3["inferMutationAliasingRanges()"] 549ab0df_dde0_c1fc_591d_a1d683921f55 -->|calls| f3815d1a_36a1_3e3d_92f2_dbbe88f01fe3 041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"] 549ab0df_dde0_c1fc_591d_a1d683921f55 -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"] 549ab0df_dde0_c1fc_591d_a1d683921f55 -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6 style 549ab0df_dde0_c1fc_591d_a1d683921f55 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Inference/AnalyseFunctions.ts lines 48–127
function lowerWithMutationAliasing(fn: HIRFunction): void {
/**
* Phase 1: similar to lower(), but using the new mutation/aliasing inference
*/
analyseFunctions(fn);
inferMutationAliasingEffects(fn, {isFunctionExpression: true});
deadCodeElimination(fn);
const functionEffects = inferMutationAliasingRanges(fn, {
isFunctionExpression: true,
}).unwrap();
rewriteInstructionKindsBasedOnReassignment(fn);
inferReactiveScopeVariables(fn);
fn.aliasingEffects = functionEffects;
/**
* Phase 2: populate the Effect of each context variable to use in inferring
* the outer function. For example, InferMutationAliasingEffects uses context variable
* effects to decide if the function may be mutable or not.
*/
const capturedOrMutated = new Set<IdentifierId>();
for (const effect of functionEffects) {
switch (effect.kind) {
case 'Assign':
case 'Alias':
case 'Capture':
case 'CreateFrom':
case 'MaybeAlias': {
capturedOrMutated.add(effect.from.identifier.id);
break;
}
case 'Apply': {
CompilerError.invariant(false, {
reason: `[AnalyzeFunctions] Expected Apply effects to be replaced with more precise effects`,
loc: effect.function.loc,
});
}
case 'Mutate':
case 'MutateConditionally':
case 'MutateTransitive':
case 'MutateTransitiveConditionally': {
capturedOrMutated.add(effect.value.identifier.id);
break;
}
case 'Impure':
case 'Render':
case 'MutateFrozen':
case 'MutateGlobal':
case 'CreateFunction':
case 'Create':
case 'Freeze':
case 'ImmutableCapture': {
// no-op
break;
}
default: {
assertExhaustive(
effect,
`Unexpected effect kind ${(effect as any).kind}`,
);
}
}
}
for (const operand of fn.context) {
if (
capturedOrMutated.has(operand.identifier.id) ||
operand.effect === Effect.Capture
) {
operand.effect = Effect.Capture;
} else {
operand.effect = Effect.Read;
}
}
fn.env.logger?.debugLogIRs?.({
kind: 'hir',
name: 'AnalyseFunction (inner)',
value: fn,
});
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does lowerWithMutationAliasing() do?
lowerWithMutationAliasing() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Inference/AnalyseFunctions.ts.
Where is lowerWithMutationAliasing() defined?
lowerWithMutationAliasing() is defined in compiler/packages/babel-plugin-react-compiler/src/Inference/AnalyseFunctions.ts at line 48.
What does lowerWithMutationAliasing() call?
lowerWithMutationAliasing() calls 5 function(s): analyseFunctions, assertExhaustive, inferMutationAliasingEffects, inferMutationAliasingRanges, invariant.
What calls lowerWithMutationAliasing()?
lowerWithMutationAliasing() is called by 1 function(s): analyseFunctions.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free