AnalyseFunctions.ts — react Source File
Architecture documentation for AnalyseFunctions.ts, a typescript file in the react codebase. 12 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 212338a1_d579_40dc_af88_824802fa3262["AnalyseFunctions.ts"] e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"] 212338a1_d579_40dc_af88_824802fa3262 --> e96f281e_f381_272d_2359_3e6a091c9a1d e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"] 212338a1_d579_40dc_af88_824802fa3262 --> e51fd0d2_bb38_cc97_7763_efe37f300a47 0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"] 212338a1_d579_40dc_af88_824802fa3262 --> 0423f759_97e0_9101_4634_ed555abc5ca9 7a9070da_3bae_1b79_d180_2d833344884a["index.ts"] 212338a1_d579_40dc_af88_824802fa3262 --> 7a9070da_3bae_1b79_d180_2d833344884a 0291e079_1c14_3cf3_45da_30767ab28e42["index.ts"] 212338a1_d579_40dc_af88_824802fa3262 --> 0291e079_1c14_3cf3_45da_30767ab28e42 d2425665_ca9d_6abf_459e_d86a6540ef14["index.ts"] 212338a1_d579_40dc_af88_824802fa3262 --> d2425665_ca9d_6abf_459e_d86a6540ef14 eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"] 212338a1_d579_40dc_af88_824802fa3262 --> eb9d33f9_42c1_205c_93e6_8e1365a31839 d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive"] 212338a1_d579_40dc_af88_824802fa3262 --> d7fde76c_4fd9_feb3_299b_798689f05bc6 d24875c3_c045_4414_2cc9_16f96d59c629["InferMutationAliasingEffects.ts"] 212338a1_d579_40dc_af88_824802fa3262 --> d24875c3_c045_4414_2cc9_16f96d59c629 1f2853c7_05e1_f3c4_b9d5_1f5ca0f648ea["inferMutationAliasingEffects"] 212338a1_d579_40dc_af88_824802fa3262 --> 1f2853c7_05e1_f3c4_b9d5_1f5ca0f648ea 99c95040_9e14_265b_aae3_b58b12a70d8d["InferMutationAliasingRanges.ts"] 212338a1_d579_40dc_af88_824802fa3262 --> 99c95040_9e14_265b_aae3_b58b12a70d8d f3815d1a_36a1_3e3d_92f2_dbbe88f01fe3["inferMutationAliasingRanges"] 212338a1_d579_40dc_af88_824802fa3262 --> f3815d1a_36a1_3e3d_92f2_dbbe88f01fe3 style 212338a1_d579_40dc_af88_824802fa3262 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {CompilerError} from '../CompilerError';
import {Effect, HIRFunction, IdentifierId, makeInstructionId} from '../HIR';
import {deadCodeElimination} from '../Optimization';
import {inferReactiveScopeVariables} from '../ReactiveScopes';
import {rewriteInstructionKindsBasedOnReassignment} from '../SSA';
import {assertExhaustive} from '../Utils/utils';
import {inferMutationAliasingEffects} from './InferMutationAliasingEffects';
import {inferMutationAliasingRanges} from './InferMutationAliasingRanges';
export default function analyseFunctions(func: HIRFunction): void {
for (const [_, block] of func.body.blocks) {
for (const instr of block.instructions) {
switch (instr.value.kind) {
case 'ObjectMethod':
case 'FunctionExpression': {
lowerWithMutationAliasing(instr.value.loweredFunc.func);
/**
* Reset mutable range for outer inferReferenceEffects
*/
for (const operand of instr.value.loweredFunc.func.context) {
/**
* NOTE: inferReactiveScopeVariables makes identifiers in the scope
* point to the *same* mutableRange instance. Resetting start/end
* here is insufficient, because a later mutation of the range
* for any one identifier could affect the range for other identifiers.
*/
operand.identifier.mutableRange = {
start: makeInstructionId(0),
end: makeInstructionId(0),
};
operand.identifier.scope = null;
}
break;
}
}
}
}
}
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;
// ... (68 more lines)
Domain
Subdomains
Dependencies
Source
Frequently Asked Questions
What does AnalyseFunctions.ts do?
AnalyseFunctions.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in AnalyseFunctions.ts?
AnalyseFunctions.ts defines 2 function(s): analyseFunctions, lowerWithMutationAliasing.
What does AnalyseFunctions.ts depend on?
AnalyseFunctions.ts imports 12 module(s): CompilerError, CompilerError.ts, InferMutationAliasingEffects.ts, InferMutationAliasingRanges.ts, assertExhaustive, index.ts, index.ts, index.ts, and 4 more.
Where is AnalyseFunctions.ts in the architecture?
AnalyseFunctions.ts is located at compiler/packages/babel-plugin-react-compiler/src/Inference/AnalyseFunctions.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/Inference).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free