Skip to content

[compiler] Handle legacy mutableIfOperandsMutable signatures #33379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
126541b
[compiler] Handle legacy mutableIfOperandsMutable signatures
josephsavona May 30, 2025
a95eb74
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona May 30, 2025
15b5d7e
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona May 30, 2025
2f0b28e
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona May 30, 2025
a7e1b56
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 2, 2025
493bf2a
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 3, 2025
380557f
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 3, 2025
60454d2
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 4, 2025
c9d3132
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 4, 2025
55863d5
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 5, 2025
9d51990
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 5, 2025
89ce479
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 5, 2025
a71f99b
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 6, 2025
8c0f0c2
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 6, 2025
8531832
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 6, 2025
64fb773
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 6, 2025
f887873
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 7, 2025
e7be8e7
Update on "[compiler] Handle legacy mutableIfOperandsMutable signatures"
josephsavona Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions compiler/packages/babel-plugin-react-compiler/src/HIR/PrintHIR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import type {
} from './HIR';
import {GotoVariant, InstructionKind} from './HIR';
import {
AliasedPlace,
AliasingEffect,
AliasingSignature,
} from '../Inference/InferMutationAliasingEffects';
Expand Down Expand Up @@ -965,10 +964,27 @@ export function printAliasingEffect(effect: AliasingEffect): string {
return `Create ${printPlaceForAliasEffect(effect.into)} = kindOf(${printPlaceForAliasEffect(effect.from)})`;
}
case 'Apply': {
const params = effect.params.map(printAliasedPlace).join(', ');
const rest = effect.rest != null ? printAliasedPlace(effect.rest) : '';
const returns = printAliasedPlace(effect.returns);
return `Apply ${returns} = ${printAliasedPlace(effect.function)} as ${effect.receiver} ( ${params} ${params.length !== 0 && rest !== '' ? ', ...' : ''}${rest})`;
const receiverCallee =
effect.receiver.identifier.id === effect.function.identifier.id
? printPlaceForAliasEffect(effect.receiver)
: `${printPlaceForAliasEffect(effect.receiver)}.${printPlaceForAliasEffect(effect.function)}`;
const args = effect.args
.map(arg => {
if (arg.kind === 'Identifier') {
return printPlaceForAliasEffect(arg);
}
return `...${printPlaceForAliasEffect(arg.place)}`;
})
.join(', ');
let signature = '';
if (effect.signature != null) {
if (effect.signature.aliasing != null) {
signature = printAliasingSignature(effect.signature.aliasing);
} else {
signature = JSON.stringify(effect.signature, null, 2);
}
}
return `Apply ${printPlaceForAliasEffect(effect.into)} = ${receiverCallee}(${args})${signature != '' ? '\n ' : ''}${signature}`;
}
case 'Freeze': {
return `Freeze ${printPlaceForAliasEffect(effect.value)} ${effect.reason}`;
Expand All @@ -989,10 +1005,6 @@ function printPlaceForAliasEffect(place: Place): string {
return printIdentifier(place.identifier);
}

function printAliasedPlace(place: AliasedPlace): string {
return place.kind + ' ' + printPlaceForAliasEffect(place.place);
}

export function printAliasingSignature(signature: AliasingSignature): string {
const tokens: Array<string> = ['function '];
tokens.push('(');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ function lowerWithMutationAliasing(fn: HIRFunction): void {
break;
}
case 'Apply': {
capturedOrMutated.add(effect.function.place.identifier.id);
break;
CompilerError.invariant(false, {
reason: `[AnalyzeFunctions] Expected Apply effects to be replaced with more precise effects`,
loc: effect.function.loc,
});
}
case 'Mutate':
case 'MutateConditionally':
Expand Down
Loading
Loading