reorderBlock() — react Function Reference
Architecture documentation for the reorderBlock() function in InstructionReordering.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD c4483c48_7e67_41a0_1a7a_c6ca92a55123["reorderBlock()"] dc3f5251_a95c_3c77_5550_3882c13a37c9["InstructionReordering.ts"] c4483c48_7e67_41a0_1a7a_c6ca92a55123 -->|defined in| dc3f5251_a95c_3c77_5550_3882c13a37c9 06363a0e_405c_bfba_71c1_808efa86a089["instructionReordering()"] 06363a0e_405c_bfba_71c1_808efa86a089 -->|calls| c4483c48_7e67_41a0_1a7a_c6ca92a55123 31c9e602_0962_eeca_6bcc_07f1b49ca385["getReorderability()"] c4483c48_7e67_41a0_1a7a_c6ca92a55123 -->|calls| 31c9e602_0962_eeca_6bcc_07f1b49ca385 4663af75_e270_25e3_3415_1230be609d66["getOrInsertWith()"] c4483c48_7e67_41a0_1a7a_c6ca92a55123 -->|calls| 4663af75_e270_25e3_3415_1230be609d66 b2fc2985_a7ba_9865_c2a3_2a7531f27d44["eachInstructionValueOperand()"] c4483c48_7e67_41a0_1a7a_c6ca92a55123 -->|calls| b2fc2985_a7ba_9865_c2a3_2a7531f27d44 21b1eb1e_eaf5_5238_3a24_f56eb8ef7278["eachInstructionValueLValue()"] c4483c48_7e67_41a0_1a7a_c6ca92a55123 -->|calls| 21b1eb1e_eaf5_5238_3a24_f56eb8ef7278 7b9ee6ee_c43a_8594_2d2b_4347e2e623a4["print()"] c4483c48_7e67_41a0_1a7a_c6ca92a55123 -->|calls| 7b9ee6ee_c43a_8594_2d2b_4347e2e623a4 2d212850_94bf_e0bb_e10d_403ccfc88d1d["emit()"] c4483c48_7e67_41a0_1a7a_c6ca92a55123 -->|calls| 2d212850_94bf_e0bb_e10d_403ccfc88d1d 41232a25_deb6_6e83_05a8_ae9f961656f7["eachTerminalOperand()"] c4483c48_7e67_41a0_1a7a_c6ca92a55123 -->|calls| 41232a25_deb6_6e83_05a8_ae9f961656f7 style c4483c48_7e67_41a0_1a7a_c6ca92a55123 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Optimization/InstructionReordering.ts lines 163–370
function reorderBlock(
env: Environment,
block: BasicBlock,
shared: Nodes,
references: References,
): void {
const locals: Nodes = new Map();
const named: Map<string, IdentifierId> = new Map();
let previous: IdentifierId | null = null;
for (const instr of block.instructions) {
const {lvalue, value} = instr;
// Get or create a node for this lvalue
const reorderability = getReorderability(instr, references);
const node = getOrInsertWith(
locals,
lvalue.identifier.id,
() =>
({
instruction: instr,
dependencies: new Set(),
reorderability,
depth: null,
}) as Node,
);
/**
* Ensure non-reoderable instructions have their order retained by
* adding explicit dependencies to the previous such instruction.
*/
if (reorderability === Reorderability.Nonreorderable) {
if (previous !== null) {
node.dependencies.add(previous);
}
previous = lvalue.identifier.id;
}
/**
* Establish dependencies on operands
*/
for (const operand of eachInstructionValueOperand(value)) {
const {name, id} = operand.identifier;
if (name !== null && name.kind === 'named') {
// Serialize all accesses to named variables
const previous = named.get(name.value);
if (previous !== undefined) {
node.dependencies.add(previous);
}
named.set(name.value, lvalue.identifier.id);
} else if (locals.has(id) || shared.has(id)) {
node.dependencies.add(id);
}
}
/**
* Establish nodes for lvalues, with dependencies on the node
* for the instruction itself. This ensures that any consumers
* of the lvalue will take a dependency through to the original
* instruction.
*/
for (const lvalueOperand of eachInstructionValueLValue(value)) {
const lvalueNode = getOrInsertWith(
locals,
lvalueOperand.identifier.id,
() =>
({
instruction: null,
dependencies: new Set(),
depth: null,
}) as Node,
);
lvalueNode.dependencies.add(lvalue.identifier.id);
const name = lvalueOperand.identifier.name;
if (name !== null && name.kind === 'named') {
const previous = named.get(name.value);
if (previous !== undefined) {
node.dependencies.add(previous);
}
named.set(name.value, lvalue.identifier.id);
}
}
}
const nextInstructions: Array<Instruction> = [];
const seen = new Set<IdentifierId>();
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does reorderBlock() do?
reorderBlock() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/InstructionReordering.ts.
Where is reorderBlock() defined?
reorderBlock() is defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/InstructionReordering.ts at line 163.
What does reorderBlock() call?
reorderBlock() calls 7 function(s): eachInstructionValueLValue, eachInstructionValueOperand, eachTerminalOperand, emit, getOrInsertWith, getReorderability, print.
What calls reorderBlock()?
reorderBlock() 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