@samitouri / QOS-React-2 / commits / 5f1bebbeae

ComputedCall modeled as ComputedLoad + Call for order-of-evaluation semantics

This is the version of @mofeiZ's change for PropertyLoad, but made to work on ComputedCall. We force the method to be evaluated in the same scope as the call in InferReactiveScopeVariables.

Joe Savona committed Mar 22, 2023 at 14:36 UTC 5f1bebbeaeff4985b27173f6807c77aedc60b40e
16 files changed +149 -123
compiler/forget/src/HIR/BuildHIR.ts
+8 -8
@@ -927,15 +927,15 @@ function lowerExpression(
927 }
928 if (calleePath.isMemberExpression()) {
929 const memberExpr = lowerMemberExpression(builder, calleePath);
930 + const propertyPlace = buildTemporaryPlace(builder, GeneratedSource);
931 + builder.push({
932 + id: makeInstructionId(0),
933 + lvalue: { ...propertyPlace },
934 + value: memberExpr.value,
935 + loc: GeneratedSource,
936 + });
937 const args = lowerArguments(builder, expr.get("arguments"));
938 if (typeof memberExpr.property === "string") {
932 - const propertyPlace = buildTemporaryPlace(builder, GeneratedSource);
933 - builder.push({
934 - id: makeInstructionId(0),
935 - lvalue: { ...propertyPlace },
936 - value: memberExpr.value,
937 - loc: GeneratedSource,
938 - });
939 return {
940 kind: "PropertyCall",
941 receiver: memberExpr.object,
@@ -947,7 +947,7 @@ function lowerExpression(
947 return {
948 kind: "ComputedCall",
949 receiver: memberExpr.object,
950 - property: memberExpr.property,
950 + property: { ...propertyPlace },
951 args,
952 loc: exprLoc,
953 };
compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts
+16 -4
@@ -613,11 +613,23 @@ function codegenInstructionValue(
613 break;
614 }
615 case "ComputedCall": {
616 - const receiver = codegenPlace(cx, instrValue.receiver);
617 - const property = codegenPlace(cx, instrValue.property);
618 - const callee = t.memberExpression(receiver, property, true);
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
622 + );
623 + invariant(
624 + t.isNodesEquivalent(
625 + memberExpr.object,
626 + codegenPlace(cx, instrValue.receiver)
627 + ),
628 + "[Codegen] Internal error: Forget should always generate ComputedCall::property " +
629 + "as a MemberExpression of ComputedCall::receiver"
630 + );
631 const args = instrValue.args.map((arg) => codegenArgument(cx, arg));
620 - value = createCallExpression(instrValue.loc, callee, args);
632 + value = createCallExpression(instrValue.loc, memberExpr, args);
633 break;
634 }
635 case "NewExpression": {
compiler/forget/src/ReactiveScopes/InferReactiveScopeVariables.ts
+14
@@ -134,6 +134,20 @@ export function inferReactiveScopeVariables(fn: HIRFunction): void {
134 ) {
135 operands.push(instr.value.value.identifier);
136 }
137 + } else if (instr.value.kind === "ComputedCall") {
138 + for (const operand of eachInstructionOperand(instr)) {
139 + if (
140 + isMutable(instr, operand) &&
141 + // exclude global variables from being added to scopes, we can't recreate them!
142 + // TODO: improve handling of module-scoped variables and globals
143 + operand.identifier.mutableRange.start > 0
144 + ) {
145 + operands.push(operand.identifier);
146 + }
147 + }
148 + // Ensure that the ComputedLoad to resolve the method is in the same scope as the
149 + // call itself
150 + operands.push(instr.value.property.identifier);
151 } else {
152 for (const operand of eachInstructionOperand(instr)) {
153 if (
compiler/forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md
+1 -1
@@ -38,7 +38,7 @@ function Component() {
38 console.log("B");
39 changeF(x);
40 console.log("arg");
41 - x["f"](1);
41 + x.f(1);
42 $[0] = x;
43 } else {
44 x = $[0];
compiler/forget/src/__tests__/fixtures/compiler/constant-computed.expect.md
+1 -1
@@ -22,7 +22,7 @@ function Component(props) {
22 if (c_0) {
23 x = {};
24 x.foo = x.foo + x.bar;
25 - x["foo"](props.foo);
25 + x.foo(props.foo);
26 $[0] = props.foo;
27 $[1] = x;
28 } else {
compiler/forget/src/__tests__/fixtures/hir/array-at-closure.expect.md
+3 -3
@@ -33,9 +33,9 @@ bb0 (block):
33 [4] store $52:TObject<Array> = Array [...capture $51]
34 [5] store $54:TObject<Array> = StoreLocal Const store arr$53:TObject<Array> = capture $52:TObject<Array>
35 [6] mutate $55:TObject<Array> = LoadLocal capture arr$53:TObject<Array>
36 - [7] mutate $56 = LoadLocal capture x$48
37 - [8] mutate $57:TFunction<<generated_0>> = PropertyLoad read $55:TObject<Array>.at
38 - [9] mutate $58 = PropertyCall read $55:TObject<Array>.read $57:TFunction<<generated_0>>(read $56)
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)
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
+6 -6
@@ -25,12 +25,12 @@ bb0 (block):
25 [5] store $24:TObject<Array> = Array [capture $23]
26 [6] store $26:TObject<Array> = StoreLocal Const store arr$25:TObject<Array> = capture $24:TObject<Array>
27 [7] mutate $27:TObject<Array> = LoadLocal capture arr$25:TObject<Array>
28 - [8] mutate $28:TFunction = Global bar
29 - [9] mutate $29 = LoadLocal read props$19
30 - [10] mutate $30 = PropertyLoad read $29.y
31 - [11] mutate $31 = Call read $28:TFunction(read $30)
32 - [12] mutate $32:TFunction<<generated_0>> = PropertyLoad read $27:TObject<Array>.at
33 - [13] mutate $33 = PropertyCall read $27:TObject<Array>.read $32:TFunction<<generated_0>>(read $31)
28 + [8] mutate $28:TFunction<<generated_0>> = PropertyLoad read $27:TObject<Array>.at
29 + [9] mutate $29:TFunction = Global bar
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)
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
+7 -7
@@ -24,15 +24,15 @@ bb0 (block):
24 [6] store $33[6:12]:TObject<Array> = Array [read $29, read $31, read $32:TPrimitive]
25 [7] store $35[7:12]:TObject<Array> = StoreLocal Const store a$34[7:12]:TObject<Array> = capture $33[6:12]:TObject<Array>
26 [8] mutate $36[8:12]:TObject<Array> = LoadLocal capture a$34[7:12]:TObject<Array>
27 - [9] mutate $37:TPrimitive = 42
28 - [10] mutate $38[10:12]:TFunction<<generated_2>> = PropertyLoad read $36[8:12]:TObject<Array>.push
29 - [11] mutate $39:TPrimitive = PropertyCall mutate $36[8:12]:TObject<Array>.read $38[10:12]:TFunction<<generated_2>>(read $37:TPrimitive)
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)
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 = LoadLocal read props$27
33 - [15] mutate $44 = PropertyLoad read $43.c
34 - [16] mutate $45:TFunction<<generated_0>> = PropertyLoad read $42:TObject<Array>.at
35 - [17] mutate $46 = PropertyCall read $42:TObject<Array>.read $45:TFunction<<generated_0>>(read $44)
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)
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
+7 -7
@@ -32,14 +32,14 @@ bb0 (block):
32 [10] store $38[10:21]:TObject<Array> = Array []
33 [11] store $40[11:21]:TObject<Array> = StoreLocal Const store arr$39[11:21]:TObject<Array> = capture $38[10:21]:TObject<Array>
34 [12] mutate $41[12:21]:TObject<Array> = LoadLocal capture arr$39[11:21]:TObject<Array>
35 - [13] store $42:TObject<Object> = Object { }
36 - [14] mutate $43[14:21]:TFunction<<generated_2>> = PropertyLoad read $41[12:21]:TObject<Array>.push
37 - [15] mutate $44:TPrimitive = PropertyCall mutate $41[12:21]:TObject<Array>.read $43[14:21]:TFunction<<generated_2>>(capture $42:TObject<Object>)
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>)
38 [16] mutate $45[16:21]:TObject<Array> = LoadLocal capture arr$39[11:21]:TObject<Array>
39 - [17] mutate $46 = LoadLocal capture x$31
40 - [18] mutate $47:TObject<Object> = LoadLocal capture y$36:TObject<Object>
41 - [19] mutate $48[19:21]:TFunction<<generated_2>> = PropertyLoad read $45[16:21]:TObject<Array>.push
42 - [20] mutate $49:TPrimitive = PropertyCall mutate $45[16:21]:TObject<Array>.read $48[19:21]:TFunction<<generated_2>>(capture $46, capture $47:TObject<Object>)
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>)
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/ssa-renaming-ternary-destruction-with-mutation.expect.md
+11 -11
@@ -22,10 +22,10 @@ bb0 (block):
22 [1] store $38[1:36]:TObject<Array> = Array []
23 [2] store $40[2:36]:TObject<Array> = StoreLocal Let store x$39[2:36]:TObject<Array> = capture $38[1:36]:TObject<Array>
24 [3] mutate $41[3:36]:TObject<Array> = LoadLocal capture x$39[2:36]:TObject<Array>
25 - [4] mutate $42 = LoadLocal read props$37
26 - [5] mutate $43 = PropertyLoad read $42.bar
27 - [6] mutate $44[6:36]:TFunction<<generated_2>> = PropertyLoad read $41[3:36]:TObject<Array>.push
28 - [7] mutate $45:TPrimitive = PropertyCall mutate $41[3:36]:TObject<Array>.read $44[6:36]:TFunction<<generated_2>>(read $43)
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)
29 [8] Ternary test:bb2 fallthrough=bb1
30 bb2 (value):
31 predecessor blocks: bb0
@@ -38,10 +38,10 @@ bb3 (value):
38 [16] store $53[16:36]:TObject<Array> = Array [capture $52[15:36]:TObject<Array>]
39 [17] store $55[17:36] = Destructure Reassign [ mutate x$39[17:36] ] = capture $53[16:36]:TObject<Array>
40 [18] mutate $56[18:36] = LoadLocal capture x$39[17:36]
41 - [19] mutate $57 = LoadLocal read props$37
42 - [20] mutate $58 = PropertyLoad read $57.foo
43 - [21] mutate $59[21:36] = PropertyLoad read $56[18:36].push
44 - [22] mutate $60[22:33] = PropertyCall mutate $56[18:36].read $59[21:36](read $58)
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)
45 [23] store $62[23:33] = StoreLocal Const mutate $61[8:33] = capture $60[22:33]
46 [24] Goto bb1
47 bb4 (value):
@@ -55,9 +55,9 @@ bb1 (block):
55 x$39[2:36]:TPhi: phi(bb3: x$39, bb4: x$39)
56 [28] store $67[28:33] = StoreLocal Const mutate _$66[28:33] = capture $61[8:33]
57 [29] mutate $69 = Global console
58 - [30] mutate $70[30:33] = LoadLocal capture _$66[28:33]
59 - [31] mutate $71 = PropertyLoad read $69.log
60 - [32] mutate $72 = PropertyCall read $69.read $71(mutate $70[30:33])
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])
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
+11 -11
@@ -21,10 +21,10 @@ bb0 (block):
21 [1] store $35[1:8]:TObject<Array> = Array []
22 [2] store $37[2:8]:TObject<Array> = StoreLocal Let store x$36[2:8]:TObject<Array> = capture $35[1:8]:TObject<Array>
23 [3] mutate $38[3:8]:TObject<Array> = LoadLocal capture x$36[2:8]:TObject<Array>
24 - [4] mutate $39 = LoadLocal read props$34
25 - [5] mutate $40 = PropertyLoad read $39.bar
26 - [6] mutate $41[6:8]:TFunction<<generated_2>> = PropertyLoad read $38[3:8]:TObject<Array>.push
27 - [7] mutate $42:TPrimitive = PropertyCall mutate $38[3:8]:TObject<Array>.read $41[6:8]:TFunction<<generated_2>>(read $40)
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)
28 [8] Ternary test:bb2 fallthrough=bb1
29 bb2 (value):
30 predecessor blocks: bb0
@@ -37,10 +37,10 @@ bb3 (value):
37 [16] store $50[16:23]:TObject<Array> = Array [capture $49[15:23]:TObject<Array>]
38 [17] store $52[17:23] = Destructure Reassign [ mutate x$36[17:23] ] = capture $50[16:23]:TObject<Array>
39 [18] mutate $53[18:23] = LoadLocal capture x$36[17:23]
40 - [19] mutate $54 = LoadLocal read props$34
41 - [20] mutate $55 = PropertyLoad read $54.foo
42 - [21] mutate $56[21:23] = PropertyLoad read $53[18:23].push
43 - [22] mutate $57[22:33] = PropertyCall mutate $53[18:23].read $56[21:23](read $55)
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)
44 [23] store $59[23:33] = StoreLocal Const mutate $58[8:33] = capture $57[22:33]
45 [24] Goto bb1
46 bb4 (value):
@@ -54,9 +54,9 @@ bb1 (block):
54 x$36:TPhi: phi(bb3: x$36, bb4: x$36)
55 [28] store $64[28:33] = StoreLocal Const mutate _$63[28:33] = capture $58[8:33]
56 [29] mutate $66 = Global console
57 - [30] mutate $67[30:33] = LoadLocal capture _$63[28:33]
58 - [31] mutate $68 = PropertyLoad read $66.log
59 - [32] mutate $69 = PropertyCall read $66.read $68(mutate $67[30:33])
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])
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
+11 -11
@@ -20,10 +20,10 @@ bb0 (block):
20 [1] store $36[1:34]:TObject<Array> = Array []
21 [2] store $38[2:34]:TObject<Array> = StoreLocal Let store x$37[2:34]:TObject<Array> = capture $36[1:34]:TObject<Array>
22 [3] mutate $39[3:34]:TObject<Array> = LoadLocal capture x$37[2:34]:TObject<Array>
23 - [4] mutate $40 = LoadLocal read props$35
24 - [5] mutate $41 = PropertyLoad read $40.bar
25 - [6] mutate $42[6:34]:TFunction<<generated_2>> = PropertyLoad read $39[3:34]:TObject<Array>.push
26 - [7] mutate $43:TPrimitive = PropertyCall mutate $39[3:34]:TObject<Array>.read $42[6:34]:TFunction<<generated_2>>(read $41)
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)
27 [8] Ternary test:bb2 fallthrough=bb1
28 bb2 (value):
29 predecessor blocks: bb0
@@ -35,10 +35,10 @@ bb3 (value):
35 [14] store $49[14:34]:TObject<Array> = Array []
36 [15] store $51[15:34]:TObject<Array> = StoreLocal Reassign store x$37[15:34]:TObject<Array> = capture $49[14:34]:TObject<Array>
37 [16] mutate $52[16:34]:TObject<Array> = LoadLocal capture x$37[15:34]:TObject<Array>
38 - [17] mutate $53 = LoadLocal read props$35
39 - [18] mutate $54 = PropertyLoad read $53.foo
40 - [19] mutate $55[19:34]:TFunction<<generated_2>> = PropertyLoad read $52[16:34]:TObject<Array>.push
41 - [20] mutate $56[20:31]:TPrimitive = PropertyCall mutate $52[16:34]:TObject<Array>.read $55[19:34]:TFunction<<generated_2>>(read $54)
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)
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):
@@ -52,9 +52,9 @@ bb1 (block):
52 x$37[2:34]:TObject<Array>: phi(bb3: x$37, bb4: x$37)
53 [26] store $63[26:31] = StoreLocal Const mutate _$62[26:31] = capture $57[8:31]:TPrimitive
54 [27] mutate $65 = Global console
55 - [28] mutate $66[28:31] = LoadLocal capture _$62[26:31]
56 - [29] mutate $67 = PropertyLoad read $65.log
57 - [30] mutate $68 = PropertyCall read $65.read $67(mutate $66[28:31])
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])
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
+11 -11
@@ -19,10 +19,10 @@ bb0 (block):
19 [1] store $33[1:8]:TObject<Array> = Array []
20 [2] store $35[2:8]:TObject<Array> = StoreLocal Let store x$34[2:8]:TObject<Array> = capture $33[1:8]:TObject<Array>
21 [3] mutate $36[3:8]:TObject<Array> = LoadLocal capture x$34[2:8]:TObject<Array>
22 - [4] mutate $37 = LoadLocal read props$32
23 - [5] mutate $38 = PropertyLoad read $37.bar
24 - [6] mutate $39[6:8]:TFunction<<generated_2>> = PropertyLoad read $36[3:8]:TObject<Array>.push
25 - [7] mutate $40:TPrimitive = PropertyCall mutate $36[3:8]:TObject<Array>.read $39[6:8]:TFunction<<generated_2>>(read $38)
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)
26 [8] Ternary test:bb2 fallthrough=bb1
27 bb2 (value):
28 predecessor blocks: bb0
@@ -34,10 +34,10 @@ bb3 (value):
34 [14] store $46[14:21]:TObject<Array> = Array []
35 [15] store $48[15:21]:TObject<Array> = StoreLocal Reassign store x$34[15:21]:TObject<Array> = capture $46[14:21]:TObject<Array>
36 [16] mutate $49[16:21]:TObject<Array> = LoadLocal capture x$34[15:21]:TObject<Array>
37 - [17] mutate $50 = LoadLocal read props$32
38 - [18] mutate $51 = PropertyLoad read $50.foo
39 - [19] mutate $52[19:21]:TFunction<<generated_2>> = PropertyLoad read $49[16:21]:TObject<Array>.push
40 - [20] mutate $53[20:31]:TPrimitive = PropertyCall mutate $49[16:21]:TObject<Array>.read $52[19:21]:TFunction<<generated_2>>(read $51)
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)
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):
@@ -51,9 +51,9 @@ bb1 (block):
51 x$34:TObject<Array>: phi(bb3: x$34, bb4: x$34)
52 [26] store $60[26:31] = StoreLocal Const mutate _$59[26:31] = capture $54[8:31]:TPrimitive
53 [27] mutate $62 = Global console
54 - [28] mutate $63[28:31] = LoadLocal capture _$59[26:31]
55 - [29] mutate $64 = PropertyLoad read $62.log
56 - [30] mutate $65 = PropertyCall read $62.read $64(mutate $63[28:31])
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])
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
+15 -15
@@ -22,10 +22,10 @@ bb0 (block):
22 [1] store $44[1:8]:TObject<Array> = Array []
23 [2] store $46[2:8]:TObject<Array> = StoreLocal Let store x$45[2:42]:TObject<Array> = capture $44[1:8]:TObject<Array>
24 [3] mutate $47[3:8]:TObject<Array> = LoadLocal capture x$45[2:42]:TObject<Array>
25 - [4] mutate $48 = LoadLocal read props$43
26 - [5] mutate $49 = PropertyLoad read $48.bar
27 - [6] mutate $50[6:8]:TFunction<<generated_2>> = PropertyLoad read $47[3:8]:TObject<Array>.push
28 - [7] mutate $51:TPrimitive = PropertyCall mutate $47[3:8]:TObject<Array>.read $50[6:8]:TFunction<<generated_2>>(read $49)
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)
29 [8] Ternary test:bb2 fallthrough=bb1
30 bb2 (value):
31 predecessor blocks: bb0
@@ -37,10 +37,10 @@ bb3 (value):
37 [14] store $57[14:42]:TObject<Array> = Array []
38 [15] store $59[15:42]:TObject<Array> = StoreLocal Reassign store x$45[15:42]:TObject<Array> = capture $57[14:42]:TObject<Array>
39 [16] mutate $60[16:42]:TObject<Array> = LoadLocal capture x$45[15:42]:TObject<Array>
40 - [17] mutate $61 = LoadLocal read props$43
41 - [18] mutate $62 = PropertyLoad read $61.foo
42 - [19] mutate $63[19:42]:TFunction<<generated_2>> = PropertyLoad read $60[16:42]:TObject<Array>.push
43 - [20] mutate $64[20:39]:TPrimitive = PropertyCall mutate $60[16:42]:TObject<Array>.read $63[19:42]:TFunction<<generated_2>>(read $62)
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)
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):
@@ -48,10 +48,10 @@ bb4 (value):
48 [25] store $70[25:42]:TObject<Array> = Array []
49 [26] store $72[26:42]:TObject<Array> = StoreLocal Reassign store x$45[26:42]:TObject<Array> = capture $70[25:42]:TObject<Array>
50 [27] mutate $73[27:42]:TObject<Array> = LoadLocal capture x$45[26:42]:TObject<Array>
51 - [28] mutate $74 = LoadLocal read props$43
52 - [29] mutate $75 = PropertyLoad read $74.bar
53 - [30] mutate $76[30:42]:TFunction<<generated_2>> = PropertyLoad read $73[27:42]:TObject<Array>.push
54 - [31] mutate $77[31:39]:TPrimitive = PropertyCall mutate $73[27:42]:TObject<Array>.read $76[30:42]:TFunction<<generated_2>>(read $75)
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)
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):
@@ -60,9 +60,9 @@ bb1 (block):
60 x$45[15:42]:TObject<Array>: phi(bb3: x$45, bb4: x$45)
61 [34] store $81[34:39] = StoreLocal Const mutate _$80[34:39] = capture $65[8:39]:TPrimitive
62 [35] mutate $83 = Global console
63 - [36] mutate $84[36:39] = LoadLocal capture _$80[34:39]
64 - [37] mutate $85 = PropertyLoad read $83.log
65 - [38] mutate $86 = PropertyCall read $83.read $85(mutate $84[36:39])
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])
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
+15 -15
@@ -21,10 +21,10 @@ bb0 (block):
21 [1] store $41[1:8]:TObject<Array> = Array []
22 [2] store $43[2:8]:TObject<Array> = StoreLocal Let store x$42[2:8]:TObject<Array> = capture $41[1:8]:TObject<Array>
23 [3] mutate $44[3:8]:TObject<Array> = LoadLocal capture x$42[2:8]:TObject<Array>
24 - [4] mutate $45 = LoadLocal read props$40
25 - [5] mutate $46 = PropertyLoad read $45.bar
26 - [6] mutate $47[6:8]:TFunction<<generated_2>> = PropertyLoad read $44[3:8]:TObject<Array>.push
27 - [7] mutate $48:TPrimitive = PropertyCall mutate $44[3:8]:TObject<Array>.read $47[6:8]:TFunction<<generated_2>>(read $46)
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)
28 [8] Ternary test:bb2 fallthrough=bb1
29 bb2 (value):
30 predecessor blocks: bb0
@@ -36,10 +36,10 @@ bb3 (value):
36 [14] store $54[14:21]:TObject<Array> = Array []
37 [15] store $56[15:21]:TObject<Array> = StoreLocal Reassign store x$42[15:21]:TObject<Array> = capture $54[14:21]:TObject<Array>
38 [16] mutate $57[16:21]:TObject<Array> = LoadLocal capture x$42[15:21]:TObject<Array>
39 - [17] mutate $58 = LoadLocal read props$40
40 - [18] mutate $59 = PropertyLoad read $58.foo
41 - [19] mutate $60[19:21]:TFunction<<generated_2>> = PropertyLoad read $57[16:21]:TObject<Array>.push
42 - [20] mutate $61[20:39]:TPrimitive = PropertyCall mutate $57[16:21]:TObject<Array>.read $60[19:21]:TFunction<<generated_2>>(read $59)
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)
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):
@@ -47,10 +47,10 @@ bb4 (value):
47 [25] store $67[25:32]:TObject<Array> = Array []
48 [26] store $69[26:32]:TObject<Array> = StoreLocal Reassign store x$42[26:32]:TObject<Array> = capture $67[25:32]:TObject<Array>
49 [27] mutate $70[27:32]:TObject<Array> = LoadLocal capture x$42[26:32]:TObject<Array>
50 - [28] mutate $71 = LoadLocal read props$40
51 - [29] mutate $72 = PropertyLoad read $71.bar
52 - [30] mutate $73[30:32]:TFunction<<generated_2>> = PropertyLoad read $70[27:32]:TObject<Array>.push
53 - [31] mutate $74[31:39]:TPrimitive = PropertyCall mutate $70[27:32]:TObject<Array>.read $73[30:32]:TFunction<<generated_2>>(read $72)
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)
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):
@@ -59,9 +59,9 @@ bb1 (block):
59 x$42:TObject<Array>: phi(bb3: x$42, bb4: x$42)
60 [34] store $78[34:39] = StoreLocal Const mutate _$77[34:39] = capture $62[8:39]:TPrimitive
61 [35] mutate $80 = Global console
62 - [36] mutate $81[36:39] = LoadLocal capture _$77[34:39]
63 - [37] mutate $82 = PropertyLoad read $80.log
64 - [38] mutate $83 = PropertyCall read $80.read $82(mutate $81[36:39])
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])
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
+12 -12
@@ -27,10 +27,10 @@ bb0 (block):
27 [1] store $35[1:8]:TObject<Array> = Array []
28 [2] store $37[2:8]:TObject<Array> = StoreLocal Let store x$36[2:34]:TObject<Array> = capture $35[1:8]:TObject<Array>
29 [3] mutate $38[3:8]:TObject<Array> = LoadLocal capture x$36[2:34]:TObject<Array>
30 - [4] mutate $39 = LoadLocal read props$34
31 - [5] mutate $40 = PropertyLoad read $39.bar
32 - [6] mutate $41[6:8]:TFunction<<generated_2>> = PropertyLoad read $38[3:8]:TObject<Array>.push
33 - [7] mutate $42:TPrimitive = PropertyCall mutate $38[3:8]:TObject<Array>.read $41[6:8]:TFunction<<generated_2>>(read $40)
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)
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
@@ -39,20 +39,20 @@ bb2 (block):
39 [13] store $48[13:34]:TObject<Array> = Array []
40 [14] store $50[14:34]:TObject<Array> = StoreLocal Reassign store x$36[14:34]:TObject<Array> = capture $48[13:34]:TObject<Array>
41 [15] mutate $51[15:34]:TObject<Array> = LoadLocal capture x$36[14:34]:TObject<Array>
42 - [16] mutate $52 = LoadLocal read props$34
43 - [17] mutate $53 = PropertyLoad read $52.foo
44 - [18] mutate $54[18:34]:TFunction<<generated_2>> = PropertyLoad read $51[15:34]:TObject<Array>.push
45 - [19] mutate $55:TPrimitive = PropertyCall mutate $51[15:34]:TObject<Array>.read $54[18:34]:TFunction<<generated_2>>(read $53)
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)
46 [20] Goto bb1
47 bb3 (block):
48 predecessor blocks: bb0
49 [23] store $59[23:34]:TObject<Array> = Array []
50 [24] store $61[24:34]:TObject<Array> = StoreLocal Reassign store x$36[24:34]:TObject<Array> = capture $59[23:34]:TObject<Array>
51 [25] mutate $62[25:34]:TObject<Array> = LoadLocal capture x$36[24:34]:TObject<Array>
52 - [26] mutate $63 = LoadLocal read props$34
53 - [27] mutate $64 = PropertyLoad read $63.bar
54 - [28] mutate $65[28:34]:TFunction<<generated_2>> = PropertyLoad read $62[25:34]:TObject<Array>.push
55 - [29] mutate $66:TPrimitive = PropertyCall mutate $62[25:34]:TObject<Array>.read $65[28:34]:TFunction<<generated_2>>(read $64)
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)
56 [30] Goto bb1
57 bb1 (block):
58 predecessor blocks: bb2 bb3