Skip to content

[compiler] Fix for PropertyStore object effect #33164

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

Open
wants to merge 24 commits into
base: gh/josephsavona/84/base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
90ed7e8
[compiler] Fix for PropertyStore object effect
josephsavona May 9, 2025
5bf3eb6
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 9, 2025
98b02b9
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 9, 2025
45a889c
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 9, 2025
4afa39d
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 12, 2025
53a90a5
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 13, 2025
191bcb3
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 22, 2025
a975293
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 23, 2025
5cf534a
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 27, 2025
d841841
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 27, 2025
13ae117
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 28, 2025
3f87a69
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 28, 2025
afa861a
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 29, 2025
f7726c0
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 29, 2025
5a611e9
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 30, 2025
cc8314b
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 30, 2025
e92440a
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 30, 2025
ddc53a0
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona May 30, 2025
0eb5e1d
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona Jun 2, 2025
facde52
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona Jun 3, 2025
38febfe
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona Jun 3, 2025
0180598
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona Jun 3, 2025
c260d45
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona Jun 4, 2025
0854665
Update on "[compiler] Fix for PropertyStore object effect"
josephsavona Jun 5, 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
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ function inferAliasesForCapturing(
for (const block of fn.body.blocks.values()) {
for (const instr of block.instructions) {
const {lvalue, value} = instr;
const hasStore =
const hasCapture =
lvalue.effect === Effect.Store ||
Iterable_some(
eachInstructionValueOperand(value),
operand => operand.effect === Effect.Store,
operand => operand.effect === Effect.Capture,
);
if (!hasStore) {
if (!hasCapture) {
continue;
}
const operands: Array<Identifier> = [];
Expand All @@ -101,6 +101,7 @@ function inferAliasesForCapturing(
for (const operand of eachInstructionValueOperand(instr.value)) {
if (
operand.effect === Effect.Store ||
operand.effect === Effect.Mutate ||
operand.effect === Effect.Capture
) {
operands.push(operand.identifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
isMapType,
isMutableEffect,
isSetType,
isObjectType,
} from '../HIR/HIR';
import {FunctionSignature} from '../HIR/ObjectShape';
import {
Expand Down Expand Up @@ -1313,7 +1314,7 @@ function inferBlock(
state.referenceAndRecordEffects(
freezeActions,
instrValue.object,
typeof instrValue.property === 'string'
isObjectType(instrValue.object.identifier)
? Effect.Store
: Effect.Mutate,
ValueReason.Other,
Expand Down Expand Up @@ -1342,25 +1343,21 @@ function inferBlock(
state.referenceAndRecordEffects(
freezeActions,
instrValue.object,
Effect.Read,
Effect.Capture,
ValueReason.Other,
);
const lvalue = instr.lvalue;
lvalue.effect = Effect.ConditionallyMutate;
lvalue.effect = Effect.Store;
state.initialize(instrValue, state.kind(instrValue.object));
state.define(lvalue, instrValue);
continuation = {kind: 'funeffects'};
break;
}
case 'ComputedStore': {
const effect =
state.kind(instrValue.object).kind === ValueKind.Context
? Effect.ConditionallyMutate
: Effect.Capture;
state.referenceAndRecordEffects(
freezeActions,
instrValue.value,
effect,
Effect.Capture,
ValueReason.Other,
);
state.referenceAndRecordEffects(
Expand All @@ -1372,7 +1369,9 @@ function inferBlock(
state.referenceAndRecordEffects(
freezeActions,
instrValue.object,
Effect.Store,
isObjectType(instrValue.object.identifier)
? Effect.Store
: Effect.Mutate,
ValueReason.Other,
);

Expand Down Expand Up @@ -1409,7 +1408,7 @@ function inferBlock(
state.referenceAndRecordEffects(
freezeActions,
instrValue.object,
Effect.Read,
Effect.Capture,
ValueReason.Other,
);
state.referenceAndRecordEffects(
Expand All @@ -1419,7 +1418,7 @@ function inferBlock(
ValueReason.Other,
);
const lvalue = instr.lvalue;
lvalue.effect = Effect.ConditionallyMutate;
lvalue.effect = Effect.Store;
state.initialize(instrValue, state.kind(instrValue.object));
state.define(lvalue, instrValue);
continuation = {kind: 'funeffects'};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
import { c as _c } from "react/compiler-runtime";
function Component(t0) {
const $ = _c(10);
const $ = _c(6);
const { a, b, c } = t0;
let t1;
if ($[0] !== a || $[1] !== b || $[2] !== c) {
Expand All @@ -47,26 +47,7 @@ function Component(t0) {
t2 = $[5];
}
const y = t2;
let t3;
let t4;
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
t3 = {};
t4 = {};
$[6] = t3;
$[7] = t4;
} else {
t3 = $[6];
t4 = $[7];
}
let t5;
if ($[8] !== c) {
t5 = { zero: c };
$[8] = c;
$[9] = t5;
} else {
t5 = $[9];
}
const z = { zero: t3, one: t4, two: t5 };
const z = { zero: {}, one: {}, two: { zero: c } };
x.zero = y.one;
z.zero.zero = x.zero;
t1 = { zero: x, one: z };
Expand Down
Loading