@@ -19518,6 +19518,7 @@ function getFunctionName$2(instrValue, defaultValue) {
19518
19518
}
19519
19519
}
19520
19520
function printAliasingEffect(effect) {
19521
+ var _a;
19521
19522
switch (effect.kind) {
19522
19523
case 'Assign': {
19523
19524
return `Assign ${printPlaceForAliasEffect(effect.into)} = ${printPlaceForAliasEffect(effect.from)}`;
@@ -19576,7 +19577,7 @@ function printAliasingEffect(effect) {
19576
19577
case 'MutateConditionally':
19577
19578
case 'MutateTransitive':
19578
19579
case 'MutateTransitiveConditionally': {
19579
- return `${effect.kind} ${printPlaceForAliasEffect(effect.value)}`;
19580
+ return `${effect.kind} ${printPlaceForAliasEffect(effect.value)}${effect.kind === 'Mutate' && ((_a = effect.reason) === null || _a === void 0 ? void 0 : _a.kind) === 'AssignCurrentProperty' ? ' (assign `.current`)' : ''} `;
19580
19581
}
19581
19582
case 'MutateFrozen': {
19582
19583
return `MutateFrozen ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.reason)}`;
@@ -42313,7 +42314,7 @@ class RewriteBlockIds extends ReactiveFunctionVisitor {
42313
42314
}
42314
42315
42315
42316
function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42316
- var _a, _b, _c, _d, _e, _f;
42317
+ var _a, _b, _c, _d, _e, _f, _g ;
42317
42318
const functionEffects = [];
42318
42319
const state = new AliasingState();
42319
42320
const pendingPhis = new Map();
@@ -42380,6 +42381,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42380
42381
kind: effect.kind === 'MutateTransitive'
42381
42382
? MutationKind.Definite
42382
42383
: MutationKind.Conditional,
42384
+ reason: null,
42383
42385
place: effect.value,
42384
42386
});
42385
42387
}
@@ -42392,6 +42394,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42392
42394
kind: effect.kind === 'Mutate'
42393
42395
? MutationKind.Definite
42394
42396
: MutationKind.Conditional,
42397
+ reason: effect.kind === 'Mutate' ? ((_a = effect.reason) !== null && _a !== void 0 ? _a : null) : null,
42395
42398
place: effect.value,
42396
42399
});
42397
42400
}
@@ -42433,7 +42436,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42433
42436
}
42434
42437
}
42435
42438
for (const mutation of mutations) {
42436
- state.mutate(mutation.index, mutation.place.identifier, makeInstructionId(mutation.id + 1), mutation.transitive, mutation.kind, mutation.place.loc, errors);
42439
+ state.mutate(mutation.index, mutation.place.identifier, makeInstructionId(mutation.id + 1), mutation.transitive, mutation.kind, mutation.place.loc, mutation.reason, errors);
42437
42440
}
42438
42441
for (const render of renders) {
42439
42442
state.render(render.index, render.place.identifier, errors);
@@ -42458,6 +42461,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42458
42461
functionEffects.push({
42459
42462
kind: 'Mutate',
42460
42463
value: Object.assign(Object.assign({}, place), { loc: node.local.loc }),
42464
+ reason: node.mutationReason,
42461
42465
});
42462
42466
}
42463
42467
}
@@ -42485,15 +42489,15 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42485
42489
for (const phi of block.phis) {
42486
42490
phi.place.effect = Effect.Store;
42487
42491
const isPhiMutatedAfterCreation = phi.place.identifier.mutableRange.end >
42488
- ((_b = (_a = block.instructions.at(0)) === null || _a === void 0 ? void 0 : _a .id) !== null && _b !== void 0 ? _b : block.terminal.id);
42492
+ ((_c = (_b = block.instructions.at(0)) === null || _b === void 0 ? void 0 : _b .id) !== null && _c !== void 0 ? _c : block.terminal.id);
42489
42493
for (const operand of phi.operands.values()) {
42490
42494
operand.effect = isPhiMutatedAfterCreation
42491
42495
? Effect.Capture
42492
42496
: Effect.Read;
42493
42497
}
42494
42498
if (isPhiMutatedAfterCreation &&
42495
42499
phi.place.identifier.mutableRange.start === 0) {
42496
- const firstInstructionIdOfBlock = (_d = (_c = block.instructions.at(0)) === null || _c === void 0 ? void 0 : _c .id) !== null && _d !== void 0 ? _d : block.terminal.id;
42500
+ const firstInstructionIdOfBlock = (_e = (_d = block.instructions.at(0)) === null || _d === void 0 ? void 0 : _d .id) !== null && _e !== void 0 ? _e : block.terminal.id;
42497
42501
phi.place.identifier.mutableRange.start = makeInstructionId(firstInstructionIdOfBlock - 1);
42498
42502
}
42499
42503
}
@@ -42571,15 +42575,15 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42571
42575
}
42572
42576
}
42573
42577
for (const lvalue of eachInstructionLValue(instr)) {
42574
- const effect = (_e = operandEffects.get(lvalue.identifier.id)) !== null && _e !== void 0 ? _e : Effect.ConditionallyMutate;
42578
+ const effect = (_f = operandEffects.get(lvalue.identifier.id)) !== null && _f !== void 0 ? _f : Effect.ConditionallyMutate;
42575
42579
lvalue.effect = effect;
42576
42580
}
42577
42581
for (const operand of eachInstructionValueOperand(instr.value)) {
42578
42582
if (operand.identifier.mutableRange.end > instr.id &&
42579
42583
operand.identifier.mutableRange.start === 0) {
42580
42584
operand.identifier.mutableRange.start = instr.id;
42581
42585
}
42582
- const effect = (_f = operandEffects.get(operand.identifier.id)) !== null && _f !== void 0 ? _f : Effect.Read;
42586
+ const effect = (_g = operandEffects.get(operand.identifier.id)) !== null && _g !== void 0 ? _g : Effect.Read;
42583
42587
operand.effect = effect;
42584
42588
}
42585
42589
if (instr.value.kind === 'StoreContext' &&
@@ -42617,7 +42621,7 @@ function inferMutationAliasingRanges(fn, { isFunctionExpression }) {
42617
42621
}
42618
42622
for (const into of tracked) {
42619
42623
const mutationIndex = index++;
42620
- state.mutate(mutationIndex, into.identifier, null, true, MutationKind.Conditional, into.loc, ignoredErrors);
42624
+ state.mutate(mutationIndex, into.identifier, null, true, MutationKind.Conditional, into.loc, null, ignoredErrors);
42621
42625
for (const from of tracked) {
42622
42626
if (from.identifier.id === into.identifier.id ||
42623
42627
from.identifier.id === fn.returns.identifier.id) {
@@ -42685,6 +42689,7 @@ class AliasingState {
42685
42689
transitive: null,
42686
42690
local: null,
42687
42691
lastMutated: 0,
42692
+ mutationReason: null,
42688
42693
value,
42689
42694
});
42690
42695
}
@@ -42769,7 +42774,8 @@ class AliasingState {
42769
42774
}
42770
42775
}
42771
42776
}
42772
- mutate(index, start, end, transitive, startKind, loc, errors) {
42777
+ mutate(index, start, end, transitive, startKind, loc, reason, errors) {
42778
+ var _a;
42773
42779
const seen = new Map();
42774
42780
const queue = [{ place: start, transitive, direction: 'backwards', kind: startKind }];
42775
42781
while (queue.length !== 0) {
@@ -42783,6 +42789,7 @@ class AliasingState {
42783
42789
if (node == null) {
42784
42790
continue;
42785
42791
}
42792
+ (_a = node.mutationReason) !== null && _a !== void 0 ? _a : (node.mutationReason = reason);
42786
42793
node.lastMutated = Math.max(node.lastMutated, index);
42787
42794
if (end != null) {
42788
42795
node.id.mutableRange.end = makeInstructionId(Math.max(node.id.mutableRange.end, end));
0 commit comments