Consolidate {Property,Computed}Call into MethodCall
Now that we model the method resolution via a PropertyLoad or ComputedLoad, we don't need to distinguish between PropertyCall and ComputedCall. These two call variants are now combined into a single MethodCall variant.
Joe Savona committed
Mar 22, 2023 at 14:36 UTC
14c03b897f49fb29c9e6ea6cf605be2744fa44e2
23 files changed
+76
-165
compiler/forget/src/HIR/BuildHIR.ts
+7
-17
@@ -935,23 +935,13 @@ function lowerExpression(
935
loc: GeneratedSource,
936
});
937
const args = lowerArguments(builder, expr.get("arguments"));
938
- if (typeof memberExpr.property === "string") {
939
- return {
940
- kind: "PropertyCall",
941
- receiver: memberExpr.object,
942
- property: { ...propertyPlace },
943
- args,
944
- loc: exprLoc,
945
- };
946
- } else {
947
- return {
948
- kind: "ComputedCall",
949
- receiver: memberExpr.object,
950
- property: { ...propertyPlace },
951
- args,
952
- loc: exprLoc,
953
- };
954
- }
938
+ return {
939
+ kind: "MethodCall",
940
+ receiver: memberExpr.object,
941
+ property: { ...propertyPlace },
942
+ args,
943
+ loc: exprLoc,
944
+ };
945
} else {
946
const callee = lowerExpressionToTemporary(builder, calleePath);
947
const args = lowerArguments(builder, expr.get("arguments"));
compiler/forget/src/HIR/HIR.ts
+8
-16
@@ -433,24 +433,23 @@ export type Phi = {
433
};
434
435
/**
436
- * Forget currently does not handle PropertyCall / ComputedCall correctly in
436
+ * Forget currently does not handle MethodCall correctly in
437
* all cases. Specifically, we do not bind the receiver and method property
438
* before calling to args. Until we add a SequenceExpression to inline all
439
* instructions generated when lowering args, we have a limited representation
440
* with some constraints.
441
*
442
* Forget currently makes these assumptions (checked in codegen):
443
- * - {@link PropertyCall.property} is a temporary produced by a PropertyLoad on {@link PropertyCall.receiver}
444
- * - this is always true for PropertyCall, but property.object and receiver
445
- * may be different for ComputedCalls
446
- * - {@link PropertyCall.property} remains an rval (i.e. never promoted to a
443
+ * - {@link MethodCall.property} is a temporary produced by a PropertyLoad or ComputedLoad
444
+ * on {@link MethodCall.receiver}
445
+ * - {@link MethodCall.property} remains an rval (i.e. never promoted to a
446
* named identifier). We currently rely on this for codegen.
447
*
449
- * Type inference does not currently guarantee that {@link PropertyCall.property}
448
+ * Type inference does not currently guarantee that {@link MethodCall.property}
449
* is a FunctionType.
450
*/
452
-export type PropertyCall = {
453
- kind: "PropertyCall";
451
+export type MethodCall = {
452
+ kind: "MethodCall";
453
receiver: Place;
454
property: Place;
455
args: Array<Place | SpreadPattern>;
@@ -513,14 +512,7 @@ export type InstructionValue =
512
args: Array<Place | SpreadPattern>;
513
loc: SourceLocation;
514
}
516
- | PropertyCall
517
- | {
518
- kind: "ComputedCall";
519
- receiver: Place;
520
- property: Place;
521
- args: Array<Place | SpreadPattern>;
522
- loc: SourceLocation;
523
- }
515
+ | MethodCall
516
| {
517
kind: "UnaryExpression";
518
operator: string;
compiler/forget/src/HIR/PrintHIR.ts
+2
-8
@@ -268,18 +268,12 @@ export function printInstructionValue(instrValue: ReactiveValue): string {
268
.join(", ")})`;
269
break;
270
}
271
- case "PropertyCall": {
272
- value = `PropertyCall ${printPlace(instrValue.receiver)}.${printPlace(
271
+ case "MethodCall": {
272
+ value = `MethodCall ${printPlace(instrValue.receiver)}.${printPlace(
273
instrValue.property
274
)}(${instrValue.args.map((arg) => printPattern(arg)).join(", ")})`;
275
break;
276
}
277
- case "ComputedCall": {
278
- value = `ComputedCall ${printPlace(instrValue.receiver)}[${printPlace(
279
- instrValue.property
280
- )}](${instrValue.args.map((arg) => printPattern(arg)).join(", ")})`;
281
- break;
282
- }
277
case "JSXText":
278
case "Primitive": {
279
value = JSON.stringify(instrValue.value);
compiler/forget/src/HIR/visitors.ts
+2
-14
@@ -55,13 +55,7 @@ export function* eachInstructionValueOperand(
55
yield instrValue.right;
56
break;
57
}
58
- case "PropertyCall": {
59
- yield instrValue.receiver;
60
- yield instrValue.property;
61
- yield* eachCallArgument(instrValue.args);
62
- break;
63
- }
64
- case "ComputedCall": {
58
+ case "MethodCall": {
59
yield instrValue.receiver;
60
yield instrValue.property;
61
yield* eachCallArgument(instrValue.args);
@@ -356,13 +350,7 @@ export function mapInstructionOperands(
350
instrValue.args = mapCallArguments(instrValue.args, fn);
351
break;
352
}
359
- case "PropertyCall": {
360
- instrValue.receiver = fn(instrValue.receiver);
361
- instrValue.property = fn(instrValue.property);
362
- instrValue.args = mapCallArguments(instrValue.args, fn);
363
- break;
364
- }
365
- case "ComputedCall": {
353
+ case "MethodCall": {
354
instrValue.receiver = fn(instrValue.receiver);
355
instrValue.property = fn(instrValue.property);
356
instrValue.args = mapCallArguments(instrValue.args, fn);
compiler/forget/src/Inference/InferReferenceEffects.ts
+3
-29
@@ -16,9 +16,9 @@ import {
16
IdentifierId,
17
InstructionValue,
18
isObjectType,
19
+ MethodCall,
20
Phi,
21
Place,
21
- PropertyCall,
22
Type,
23
ValueKind,
24
} from "../HIR/HIR";
@@ -684,7 +684,7 @@ function inferBlock(
684
instr.lvalue.effect = Effect.Store;
685
continue;
686
}
687
- case "PropertyCall": {
687
+ case "MethodCall": {
688
invariant(
689
state.isDefined(instrValue.receiver),
690
"[InferReferenceEffects] Internal error: receiver of PropertyCall should have been defined by corresponding PropertyLoad"
@@ -724,32 +724,6 @@ function inferBlock(
724
instr.lvalue.effect = Effect.Mutate;
725
continue;
726
}
727
- case "ComputedCall": {
728
- if (!state.isDefined(instrValue.receiver)) {
729
- // TODO @josephsavona: improve handling of globals
730
- const value: InstructionValue = {
731
- kind: "Primitive",
732
- loc: instrValue.loc,
733
- value: undefined,
734
- };
735
- state.initialize(value, ValueKind.Frozen);
736
- state.define(instrValue.receiver, value);
737
- }
738
-
739
- state.reference(instrValue.receiver, Effect.Mutate);
740
- state.reference(instrValue.property, Effect.Read);
741
- for (const arg of instrValue.args) {
742
- if (arg.kind === "Identifier") {
743
- state.reference(arg, Effect.Mutate);
744
- } else {
745
- state.reference(arg.place, Effect.Mutate);
746
- }
747
- }
748
- state.initialize(instrValue, ValueKind.Mutable);
749
- state.define(instr.lvalue, instrValue);
750
- instr.lvalue.effect = Effect.Mutate;
751
- continue;
752
- }
727
case "PropertyStore": {
728
const effect =
729
state.kind(instrValue.object) === ValueKind.Context
@@ -965,7 +939,7 @@ function getFunctionCallSignature(
939
* @returns Inferred effects of function arguments
940
*/
941
function getFunctionCallEffects(
968
- fn: PropertyCall,
942
+ fn: MethodCall,
943
sig: FunctionSignature,
944
defaultEffect: Effect
945
): Array<[Place, Effect]> {
compiler/forget/src/Optimization/DeadCodeElimination.ts
+1
-2
@@ -192,10 +192,9 @@ function pruneableValue(value: InstructionValue, state: State): boolean {
192
}
193
case "CallExpression":
194
case "ComputedDelete":
195
- case "ComputedCall":
195
case "ComputedStore":
196
case "PropertyDelete":
198
- case "PropertyCall":
197
+ case "MethodCall":
198
case "PropertyStore": {
199
// Mutating instructions are not safe to prune.
200
// TODO: we could be more precise and make this conditional on whether
compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts
+4
-28
@@ -589,44 +589,20 @@ function codegenInstructionValue(
589
value = createCallExpression(instrValue.loc, callee, args);
590
break;
591
}
592
- case "PropertyCall": {
592
+ case "MethodCall": {
593
const memberExpr = codegenPlace(cx, instrValue.property);
594
invariant(
595
t.isMemberExpression(memberExpr) ||
596
t.isOptionalMemberExpression(memberExpr),
597
- "[Codegen] Internal error: PropertyCall::property must be an unpromoted + unmemoized MemberExpression."
598
- );
599
- invariant(
600
- memberExpr.computed === false,
601
- "[Codegen] Internal error: PropertyCall::property must be a non-computed MemberExpression."
602
- );
603
- invariant(
604
- t.isNodesEquivalent(
605
- memberExpr.object,
606
- codegenPlace(cx, instrValue.receiver)
607
- ),
608
- "[Codegen] Internal error: Forget should always generate PropertyCall::property " +
609
- "as a MemberExpression of PropertyCall::receiver"
610
- );
611
- const args = instrValue.args.map((arg) => codegenArgument(cx, arg));
612
- value = createCallExpression(instrValue.loc, memberExpr, args);
613
- break;
614
- }
615
- case "ComputedCall": {
616
- const memberExpr = codegenPlace(cx, instrValue.property);
617
- invariant(
618
- t.isMemberExpression(memberExpr) ||
619
- t.isOptionalMemberExpression(memberExpr),
620
- "[Codegen] Internal error: ComputedCall::property must be an unpromoted + unmemoized MemberExpression, was %s.",
621
- memberExpr.type
597
+ "[Codegen] Internal error: MethodCall::property must be an unpromoted + unmemoized MemberExpression."
598
);
599
invariant(
600
t.isNodesEquivalent(
601
memberExpr.object,
602
codegenPlace(cx, instrValue.receiver)
603
),
628
- "[Codegen] Internal error: Forget should always generate ComputedCall::property " +
629
- "as a MemberExpression of ComputedCall::receiver"
604
+ "[Codegen] Internal error: Forget should always generate MethodCall::property " +
605
+ "as a MemberExpression of MethodCall::receiver"
606
);
607
const args = instrValue.args.map((arg) => codegenArgument(cx, arg));
608
value = createCallExpression(instrValue.loc, memberExpr, args);
compiler/forget/src/ReactiveScopes/InferReactiveScopeVariables.ts
+2
-3
@@ -134,7 +134,7 @@ export function inferReactiveScopeVariables(fn: HIRFunction): void {
134
) {
135
operands.push(instr.value.value.identifier);
136
}
137
- } else if (instr.value.kind === "ComputedCall") {
137
+ } else if (instr.value.kind === "MethodCall") {
138
for (const operand of eachInstructionOperand(instr)) {
139
if (
140
isMutable(instr, operand) &&
@@ -235,8 +235,7 @@ function mayAllocate(value: InstructionValue): boolean {
235
case "Primitive": {
236
return false;
237
}
238
- case "PropertyCall":
239
- case "ComputedCall":
238
+ case "MethodCall":
239
case "PropertyStore":
240
case "ComputedStore":
241
case "ArrayExpression":
compiler/forget/src/ReactiveScopes/PruneNonEscapingScopes.ts
+1
-2
@@ -514,8 +514,7 @@ function computeMemoizationInputs(
514
case "ArrayExpression":
515
case "NewExpression":
516
case "ObjectExpression":
517
- case "ComputedCall":
518
- case "PropertyCall":
517
+ case "MethodCall":
518
case "PropertyStore": {
519
// All of these instructions may produce new values which must be memoized if
520
// reachable from a return value. Any mutable rvalue may alias any other rvalue
compiler/forget/src/TypeInference/InferTypes.ts
+1
-1
@@ -195,7 +195,7 @@ function* generateInstructionTypes(
195
break;
196
}
197
198
- case "PropertyCall": {
198
+ case "MethodCall": {
199
const returnType = makeType();
200
yield equation(value.property.identifier.type, {
201
kind: "FunctionCall",
compiler/forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md
+15
-15
@@ -43,24 +43,24 @@ function ArrayAtTest(props) {
43
}
44
const arr = t1;
45
const c_4 = $[4] !== props.y;
46
- let t2;
47
- if (c_4) {
48
- t2 = bar(props.y);
49
- $[4] = props.y;
50
- $[5] = t2;
51
- } else {
52
- t2 = $[5];
53
- }
54
- const c_6 = $[6] !== arr;
55
- const c_7 = $[7] !== t2;
46
+ const c_5 = $[5] !== arr;
47
let t3;
57
- if (c_6 || c_7) {
48
+ if (c_4 || c_5) {
49
+ const c_7 = $[7] !== props.y;
50
+ let t2;
51
+ if (c_7) {
52
+ t2 = bar(props.y);
53
+ $[7] = props.y;
54
+ $[8] = t2;
55
+ } else {
56
+ t2 = $[8];
57
+ }
58
t3 = arr.at(t2);
59
- $[6] = arr;
60
- $[7] = t2;
61
- $[8] = t3;
59
+ $[4] = props.y;
60
+ $[5] = arr;
61
+ $[6] = t3;
62
} else {
63
- t3 = $[8];
63
+ t3 = $[6];
64
}
65
const result = t3;
66
return result;
compiler/forget/src/__tests__/fixtures/hir/array-at-closure.expect.md
+1
-1
@@ -35,7 +35,7 @@ bb0 (block):
35
[6] mutate $55:TObject<Array> = LoadLocal capture arr$53:TObject<Array>
36
[7] mutate $56:TFunction<<generated_0>> = PropertyLoad read $55:TObject<Array>.at
37
[8] mutate $57 = LoadLocal capture x$48
38
- [9] mutate $58 = PropertyCall read $55:TObject<Array>.read $56:TFunction<<generated_0>>(read $57)
38
+ [9] mutate $58 = MethodCall read $55:TObject<Array>.read $56:TFunction<<generated_0>>(read $57)
39
[10] Return freeze $58
40
[9] store $41[9:12]:TFunction = StoreLocal Const mutate fn$40[9:12]:TFunction = capture $39[8:12]:TFunction
41
[10] mutate $42[10:12]:TFunction = LoadLocal capture fn$40[9:12]:TFunction
compiler/forget/src/__tests__/fixtures/hir/array-at-effect.expect.md
+1
-1
@@ -30,7 +30,7 @@ bb0 (block):
30
[10] mutate $30 = LoadLocal read props$19
31
[11] mutate $31 = PropertyLoad read $30.y
32
[12] mutate $32 = Call read $29:TFunction(read $31)
33
- [13] mutate $33 = PropertyCall read $27:TObject<Array>.read $28:TFunction<<generated_0>>(read $32)
33
+ [13] mutate $33 = MethodCall read $27:TObject<Array>.read $28:TFunction<<generated_0>>(read $32)
34
[14] store $35 = StoreLocal Const mutate result$34 = capture $33
35
[15] mutate $36 = LoadLocal capture result$34
36
[16] Return freeze $36
compiler/forget/src/__tests__/fixtures/hir/array-property-call.expect.md
+2
-2
@@ -26,13 +26,13 @@ bb0 (block):
26
[8] mutate $36[8:12]:TObject<Array> = LoadLocal capture a$34[7:12]:TObject<Array>
27
[9] mutate $37[9:12]:TFunction<<generated_2>> = PropertyLoad read $36[8:12]:TObject<Array>.push
28
[10] mutate $38:TPrimitive = 42
29
- [11] mutate $39:TPrimitive = PropertyCall mutate $36[8:12]:TObject<Array>.read $37[9:12]:TFunction<<generated_2>>(read $38:TPrimitive)
29
+ [11] mutate $39:TPrimitive = MethodCall mutate $36[8:12]:TObject<Array>.read $37[9:12]:TFunction<<generated_2>>(read $38:TPrimitive)
30
[12] store $41:TPrimitive = StoreLocal Const mutate x$40:TPrimitive = capture $39:TPrimitive
31
[13] mutate $42:TObject<Array> = LoadLocal capture a$34[7:12]:TObject<Array>
32
[14] mutate $43:TFunction<<generated_0>> = PropertyLoad read $42:TObject<Array>.at
33
[15] mutate $44 = LoadLocal read props$27
34
[16] mutate $45 = PropertyLoad read $44.c
35
- [17] mutate $46 = PropertyCall read $42:TObject<Array>.read $43:TFunction<<generated_0>>(read $45)
35
+ [17] mutate $46 = MethodCall read $42:TObject<Array>.read $43:TFunction<<generated_0>>(read $45)
36
[18] store $48 = StoreLocal Const mutate y$47 = capture $46
37
[19] mutate $49:TObject<Array> = LoadLocal capture a$34[7:12]:TObject<Array>
38
[20] mutate $50:TPrimitive = LoadLocal capture x$40:TPrimitive
compiler/forget/src/__tests__/fixtures/hir/array-push-effect.expect.md
+2
-2
@@ -34,12 +34,12 @@ bb0 (block):
34
[12] mutate $41[12:21]:TObject<Array> = LoadLocal capture arr$39[11:21]:TObject<Array>
35
[13] mutate $42[13:21]:TFunction<<generated_2>> = PropertyLoad read $41[12:21]:TObject<Array>.push
36
[14] store $43:TObject<Object> = Object { }
37
- [15] mutate $44:TPrimitive = PropertyCall mutate $41[12:21]:TObject<Array>.read $42[13:21]:TFunction<<generated_2>>(capture $43:TObject<Object>)
37
+ [15] mutate $44:TPrimitive = MethodCall mutate $41[12:21]:TObject<Array>.read $42[13:21]:TFunction<<generated_2>>(capture $43:TObject<Object>)
38
[16] mutate $45[16:21]:TObject<Array> = LoadLocal capture arr$39[11:21]:TObject<Array>
39
[17] mutate $46[17:21]:TFunction<<generated_2>> = PropertyLoad read $45[16:21]:TObject<Array>.push
40
[18] mutate $47 = LoadLocal capture x$31
41
[19] mutate $48:TObject<Object> = LoadLocal capture y$36:TObject<Object>
42
- [20] mutate $49:TPrimitive = PropertyCall mutate $45[16:21]:TObject<Array>.read $46[17:21]:TFunction<<generated_2>>(capture $47, capture $48:TObject<Object>)
42
+ [20] mutate $49:TPrimitive = MethodCall mutate $45[16:21]:TObject<Array>.read $46[17:21]:TFunction<<generated_2>>(capture $47, capture $48:TObject<Object>)
43
[21] mutate $50:TObject<Array> = LoadLocal capture arr$39[11:21]:TObject<Array>
44
[22] Return freeze $50:TObject<Array>
45
```
compiler/forget/src/__tests__/fixtures/hir/infer-call-array-length.expect.md
+1
-1
@@ -18,7 +18,7 @@ bb0 (block):
18
[2] store $12[2:6]:TObject<Array> = StoreLocal Const store x$11[2:6]:TObject<Array> = capture $10[1:6]:TObject<Array>
19
[3] mutate $13[3:6]:TObject<Array> = LoadLocal capture x$11[2:6]:TObject<Array>
20
[4] mutate $14[4:6]:TPrimitive = PropertyLoad read $13[3:6]:TObject<Array>.length
21
- [5] mutate $15 = PropertyCall mutate $13[3:6]:TObject<Array>.read $14[4:6]:TPrimitive()
21
+ [5] mutate $15 = MethodCall mutate $13[3:6]:TObject<Array>.read $14[4:6]:TPrimitive()
22
[6] store $17 = StoreLocal Const mutate y$16 = capture $15
23
[7] mutate $18 = LoadLocal capture y$16
24
[8] Return freeze $18
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-destruction-with-mutation.expect.md
+3
-3
@@ -25,7 +25,7 @@ bb0 (block):
25
[4] mutate $42[4:36]:TFunction<<generated_2>> = PropertyLoad read $41[3:36]:TObject<Array>.push
26
[5] mutate $43 = LoadLocal read props$37
27
[6] mutate $44 = PropertyLoad read $43.bar
28
- [7] mutate $45:TPrimitive = PropertyCall mutate $41[3:36]:TObject<Array>.read $42[4:36]:TFunction<<generated_2>>(read $44)
28
+ [7] mutate $45:TPrimitive = MethodCall mutate $41[3:36]:TObject<Array>.read $42[4:36]:TFunction<<generated_2>>(read $44)
29
[8] Ternary test:bb2 fallthrough=bb1
30
bb2 (value):
31
predecessor blocks: bb0
@@ -41,7 +41,7 @@ bb3 (value):
41
[19] mutate $57[19:36] = PropertyLoad read $56[18:36].push
42
[20] mutate $58 = LoadLocal read props$37
43
[21] mutate $59 = PropertyLoad read $58.foo
44
- [22] mutate $60[22:33] = PropertyCall mutate $56[18:36].read $57[19:36](read $59)
44
+ [22] mutate $60[22:33] = MethodCall mutate $56[18:36].read $57[19:36](read $59)
45
[23] store $62[23:33] = StoreLocal Const mutate $61[8:33] = capture $60[22:33]
46
[24] Goto bb1
47
bb4 (value):
@@ -57,7 +57,7 @@ bb1 (block):
57
[29] mutate $69 = Global console
58
[30] mutate $70 = PropertyLoad read $69.log
59
[31] mutate $71[31:33] = LoadLocal capture _$66[28:33]
60
- [32] mutate $72 = PropertyCall read $69.read $70(mutate $71[31:33])
60
+ [32] mutate $72 = MethodCall read $69.read $70(mutate $71[31:33])
61
[33] mutate $73:TFunction = Global mut
62
[34] mutate $74[34:36] = LoadLocal capture x$39[2:36]
63
[35] mutate $76 = Call read $73:TFunction(mutate $74[34:36])
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-destruction.expect.md
+3
-3
@@ -24,7 +24,7 @@ bb0 (block):
24
[4] mutate $39[4:8]:TFunction<<generated_2>> = PropertyLoad read $38[3:8]:TObject<Array>.push
25
[5] mutate $40 = LoadLocal read props$34
26
[6] mutate $41 = PropertyLoad read $40.bar
27
- [7] mutate $42:TPrimitive = PropertyCall mutate $38[3:8]:TObject<Array>.read $39[4:8]:TFunction<<generated_2>>(read $41)
27
+ [7] mutate $42:TPrimitive = MethodCall mutate $38[3:8]:TObject<Array>.read $39[4:8]:TFunction<<generated_2>>(read $41)
28
[8] Ternary test:bb2 fallthrough=bb1
29
bb2 (value):
30
predecessor blocks: bb0
@@ -40,7 +40,7 @@ bb3 (value):
40
[19] mutate $54[19:23] = PropertyLoad read $53[18:23].push
41
[20] mutate $55 = LoadLocal read props$34
42
[21] mutate $56 = PropertyLoad read $55.foo
43
- [22] mutate $57[22:33] = PropertyCall mutate $53[18:23].read $54[19:23](read $56)
43
+ [22] mutate $57[22:33] = MethodCall mutate $53[18:23].read $54[19:23](read $56)
44
[23] store $59[23:33] = StoreLocal Const mutate $58[8:33] = capture $57[22:33]
45
[24] Goto bb1
46
bb4 (value):
@@ -56,7 +56,7 @@ bb1 (block):
56
[29] mutate $66 = Global console
57
[30] mutate $67 = PropertyLoad read $66.log
58
[31] mutate $68[31:33] = LoadLocal capture _$63[28:33]
59
- [32] mutate $69 = PropertyCall read $66.read $67(mutate $68[31:33])
59
+ [32] mutate $69 = MethodCall read $66.read $67(mutate $68[31:33])
60
[33] mutate $70 = LoadLocal capture x$36
61
[34] Return freeze $70
62
```
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-with-mutation.expect.md
+3
-3
@@ -23,7 +23,7 @@ bb0 (block):
23
[4] mutate $40[4:34]:TFunction<<generated_2>> = PropertyLoad read $39[3:34]:TObject<Array>.push
24
[5] mutate $41 = LoadLocal read props$35
25
[6] mutate $42 = PropertyLoad read $41.bar
26
- [7] mutate $43:TPrimitive = PropertyCall mutate $39[3:34]:TObject<Array>.read $40[4:34]:TFunction<<generated_2>>(read $42)
26
+ [7] mutate $43:TPrimitive = MethodCall mutate $39[3:34]:TObject<Array>.read $40[4:34]:TFunction<<generated_2>>(read $42)
27
[8] Ternary test:bb2 fallthrough=bb1
28
bb2 (value):
29
predecessor blocks: bb0
@@ -38,7 +38,7 @@ bb3 (value):
38
[17] mutate $53[17:34]:TFunction<<generated_2>> = PropertyLoad read $52[16:34]:TObject<Array>.push
39
[18] mutate $54 = LoadLocal read props$35
40
[19] mutate $55 = PropertyLoad read $54.foo
41
- [20] mutate $56[20:31]:TPrimitive = PropertyCall mutate $52[16:34]:TObject<Array>.read $53[17:34]:TFunction<<generated_2>>(read $55)
41
+ [20] mutate $56[20:31]:TPrimitive = MethodCall mutate $52[16:34]:TObject<Array>.read $53[17:34]:TFunction<<generated_2>>(read $55)
42
[21] store $58[21:31]:TPrimitive = StoreLocal Const mutate $57[8:31]:TPrimitive = capture $56[20:31]:TPrimitive
43
[22] Goto bb1
44
bb4 (value):
@@ -54,7 +54,7 @@ bb1 (block):
54
[27] mutate $65 = Global console
55
[28] mutate $66 = PropertyLoad read $65.log
56
[29] mutate $67[29:31] = LoadLocal capture _$62[26:31]
57
- [30] mutate $68 = PropertyCall read $65.read $66(mutate $67[29:31])
57
+ [30] mutate $68 = MethodCall read $65.read $66(mutate $67[29:31])
58
[31] mutate $69:TFunction = Global mut
59
[32] mutate $70[32:34] = LoadLocal capture x$37[2:34]
60
[33] mutate $72 = Call read $69:TFunction(mutate $70[32:34])
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary.expect.md
+3
-3
@@ -22,7 +22,7 @@ bb0 (block):
22
[4] mutate $37[4:8]:TFunction<<generated_2>> = PropertyLoad read $36[3:8]:TObject<Array>.push
23
[5] mutate $38 = LoadLocal read props$32
24
[6] mutate $39 = PropertyLoad read $38.bar
25
- [7] mutate $40:TPrimitive = PropertyCall mutate $36[3:8]:TObject<Array>.read $37[4:8]:TFunction<<generated_2>>(read $39)
25
+ [7] mutate $40:TPrimitive = MethodCall mutate $36[3:8]:TObject<Array>.read $37[4:8]:TFunction<<generated_2>>(read $39)
26
[8] Ternary test:bb2 fallthrough=bb1
27
bb2 (value):
28
predecessor blocks: bb0
@@ -37,7 +37,7 @@ bb3 (value):
37
[17] mutate $50[17:21]:TFunction<<generated_2>> = PropertyLoad read $49[16:21]:TObject<Array>.push
38
[18] mutate $51 = LoadLocal read props$32
39
[19] mutate $52 = PropertyLoad read $51.foo
40
- [20] mutate $53[20:31]:TPrimitive = PropertyCall mutate $49[16:21]:TObject<Array>.read $50[17:21]:TFunction<<generated_2>>(read $52)
40
+ [20] mutate $53[20:31]:TPrimitive = MethodCall mutate $49[16:21]:TObject<Array>.read $50[17:21]:TFunction<<generated_2>>(read $52)
41
[21] store $55[21:31]:TPrimitive = StoreLocal Const mutate $54[8:31]:TPrimitive = capture $53[20:31]:TPrimitive
42
[22] Goto bb1
43
bb4 (value):
@@ -53,7 +53,7 @@ bb1 (block):
53
[27] mutate $62 = Global console
54
[28] mutate $63 = PropertyLoad read $62.log
55
[29] mutate $64[29:31] = LoadLocal capture _$59[26:31]
56
- [30] mutate $65 = PropertyCall read $62.read $63(mutate $64[29:31])
56
+ [30] mutate $65 = MethodCall read $62.read $63(mutate $64[29:31])
57
[31] mutate $66 = LoadLocal capture x$34
58
[32] Return freeze $66
59
```
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-ternary-with-mutation.expect.md
+4
-4
@@ -25,7 +25,7 @@ bb0 (block):
25
[4] mutate $48[4:8]:TFunction<<generated_2>> = PropertyLoad read $47[3:8]:TObject<Array>.push
26
[5] mutate $49 = LoadLocal read props$43
27
[6] mutate $50 = PropertyLoad read $49.bar
28
- [7] mutate $51:TPrimitive = PropertyCall mutate $47[3:8]:TObject<Array>.read $48[4:8]:TFunction<<generated_2>>(read $50)
28
+ [7] mutate $51:TPrimitive = MethodCall mutate $47[3:8]:TObject<Array>.read $48[4:8]:TFunction<<generated_2>>(read $50)
29
[8] Ternary test:bb2 fallthrough=bb1
30
bb2 (value):
31
predecessor blocks: bb0
@@ -40,7 +40,7 @@ bb3 (value):
40
[17] mutate $61[17:42]:TFunction<<generated_2>> = PropertyLoad read $60[16:42]:TObject<Array>.push
41
[18] mutate $62 = LoadLocal read props$43
42
[19] mutate $63 = PropertyLoad read $62.foo
43
- [20] mutate $64[20:39]:TPrimitive = PropertyCall mutate $60[16:42]:TObject<Array>.read $61[17:42]:TFunction<<generated_2>>(read $63)
43
+ [20] mutate $64[20:39]:TPrimitive = MethodCall mutate $60[16:42]:TObject<Array>.read $61[17:42]:TFunction<<generated_2>>(read $63)
44
[21] store $66[21:39]:TPrimitive = StoreLocal Const mutate $65[8:39]:TPrimitive = capture $64[20:39]:TPrimitive
45
[22] Goto bb1
46
bb4 (value):
@@ -51,7 +51,7 @@ bb4 (value):
51
[28] mutate $74[28:42]:TFunction<<generated_2>> = PropertyLoad read $73[27:42]:TObject<Array>.push
52
[29] mutate $75 = LoadLocal read props$43
53
[30] mutate $76 = PropertyLoad read $75.bar
54
- [31] mutate $77[31:39]:TPrimitive = PropertyCall mutate $73[27:42]:TObject<Array>.read $74[28:42]:TFunction<<generated_2>>(read $76)
54
+ [31] mutate $77[31:39]:TPrimitive = MethodCall mutate $73[27:42]:TObject<Array>.read $74[28:42]:TFunction<<generated_2>>(read $76)
55
[32] store $79[32:39]:TPrimitive = StoreLocal Const mutate $65[8:39]:TPrimitive = capture $77[31:39]:TPrimitive
56
[33] Goto bb1
57
bb1 (block):
@@ -62,7 +62,7 @@ bb1 (block):
62
[35] mutate $83 = Global console
63
[36] mutate $84 = PropertyLoad read $83.log
64
[37] mutate $85[37:39] = LoadLocal capture _$80[34:39]
65
- [38] mutate $86 = PropertyCall read $83.read $84(mutate $85[37:39])
65
+ [38] mutate $86 = MethodCall read $83.read $84(mutate $85[37:39])
66
[39] mutate $87:TFunction = Global mut
67
[40] mutate $88[40:42] = LoadLocal capture x$45[15:42]
68
[41] mutate $90 = Call read $87:TFunction(mutate $88[40:42])
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-ternary.expect.md
+4
-4
@@ -24,7 +24,7 @@ bb0 (block):
24
[4] mutate $45[4:8]:TFunction<<generated_2>> = PropertyLoad read $44[3:8]:TObject<Array>.push
25
[5] mutate $46 = LoadLocal read props$40
26
[6] mutate $47 = PropertyLoad read $46.bar
27
- [7] mutate $48:TPrimitive = PropertyCall mutate $44[3:8]:TObject<Array>.read $45[4:8]:TFunction<<generated_2>>(read $47)
27
+ [7] mutate $48:TPrimitive = MethodCall mutate $44[3:8]:TObject<Array>.read $45[4:8]:TFunction<<generated_2>>(read $47)
28
[8] Ternary test:bb2 fallthrough=bb1
29
bb2 (value):
30
predecessor blocks: bb0
@@ -39,7 +39,7 @@ bb3 (value):
39
[17] mutate $58[17:21]:TFunction<<generated_2>> = PropertyLoad read $57[16:21]:TObject<Array>.push
40
[18] mutate $59 = LoadLocal read props$40
41
[19] mutate $60 = PropertyLoad read $59.foo
42
- [20] mutate $61[20:39]:TPrimitive = PropertyCall mutate $57[16:21]:TObject<Array>.read $58[17:21]:TFunction<<generated_2>>(read $60)
42
+ [20] mutate $61[20:39]:TPrimitive = MethodCall mutate $57[16:21]:TObject<Array>.read $58[17:21]:TFunction<<generated_2>>(read $60)
43
[21] store $63[21:39]:TPrimitive = StoreLocal Const mutate $62[8:39]:TPrimitive = capture $61[20:39]:TPrimitive
44
[22] Goto bb1
45
bb4 (value):
@@ -50,7 +50,7 @@ bb4 (value):
50
[28] mutate $71[28:32]:TFunction<<generated_2>> = PropertyLoad read $70[27:32]:TObject<Array>.push
51
[29] mutate $72 = LoadLocal read props$40
52
[30] mutate $73 = PropertyLoad read $72.bar
53
- [31] mutate $74[31:39]:TPrimitive = PropertyCall mutate $70[27:32]:TObject<Array>.read $71[28:32]:TFunction<<generated_2>>(read $73)
53
+ [31] mutate $74[31:39]:TPrimitive = MethodCall mutate $70[27:32]:TObject<Array>.read $71[28:32]:TFunction<<generated_2>>(read $73)
54
[32] store $76[32:39]:TPrimitive = StoreLocal Const mutate $62[8:39]:TPrimitive = capture $74[31:39]:TPrimitive
55
[33] Goto bb1
56
bb1 (block):
@@ -61,7 +61,7 @@ bb1 (block):
61
[35] mutate $80 = Global console
62
[36] mutate $81 = PropertyLoad read $80.log
63
[37] mutate $82[37:39] = LoadLocal capture _$77[34:39]
64
- [38] mutate $83 = PropertyCall read $80.read $81(mutate $82[37:39])
64
+ [38] mutate $83 = MethodCall read $80.read $81(mutate $82[37:39])
65
[39] mutate $84 = LoadLocal capture x$42
66
[40] Return freeze $84
67
```
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-with-mutation.expect.md
+3
-3
@@ -30,7 +30,7 @@ bb0 (block):
30
[4] mutate $39[4:8]:TFunction<<generated_2>> = PropertyLoad read $38[3:8]:TObject<Array>.push
31
[5] mutate $40 = LoadLocal read props$34
32
[6] mutate $41 = PropertyLoad read $40.bar
33
- [7] mutate $42:TPrimitive = PropertyCall mutate $38[3:8]:TObject<Array>.read $39[4:8]:TFunction<<generated_2>>(read $41)
33
+ [7] mutate $42:TPrimitive = MethodCall mutate $38[3:8]:TObject<Array>.read $39[4:8]:TFunction<<generated_2>>(read $41)
34
[8] mutate $43 = LoadLocal read props$34
35
[9] mutate $44 = PropertyLoad read $43.cond
36
[10] If (read $44) then:bb2 else:bb3 fallthrough=bb1
@@ -42,7 +42,7 @@ bb2 (block):
42
[16] mutate $52[16:34]:TFunction<<generated_2>> = PropertyLoad read $51[15:34]:TObject<Array>.push
43
[17] mutate $53 = LoadLocal read props$34
44
[18] mutate $54 = PropertyLoad read $53.foo
45
- [19] mutate $55:TPrimitive = PropertyCall mutate $51[15:34]:TObject<Array>.read $52[16:34]:TFunction<<generated_2>>(read $54)
45
+ [19] mutate $55:TPrimitive = MethodCall mutate $51[15:34]:TObject<Array>.read $52[16:34]:TFunction<<generated_2>>(read $54)
46
[20] Goto bb1
47
bb3 (block):
48
predecessor blocks: bb0
@@ -52,7 +52,7 @@ bb3 (block):
52
[26] mutate $63[26:34]:TFunction<<generated_2>> = PropertyLoad read $62[25:34]:TObject<Array>.push
53
[27] mutate $64 = LoadLocal read props$34
54
[28] mutate $65 = PropertyLoad read $64.bar
55
- [29] mutate $66:TPrimitive = PropertyCall mutate $62[25:34]:TObject<Array>.read $63[26:34]:TFunction<<generated_2>>(read $65)
55
+ [29] mutate $66:TPrimitive = MethodCall mutate $62[25:34]:TObject<Array>.read $63[26:34]:TFunction<<generated_2>>(read $65)
56
[30] Goto bb1
57
bb1 (block):
58
predecessor blocks: bb2 bb3