@samitouri / QOS-React / commits / 4a21bb8856

Infer sets of variables in each reactive scope

Adds a new pass `InferReactiveScopeVariables` which determines the sets of variables (by Identifier) which "construct together" and belong in the same reactive scope. Concretely, `Identifier` gets a new property `scope: ScopeId`, and this pass assigns each identifier a ScopeId value. The algorithm iterates over all instructions in all blocks (in a single pass) and builds up disjoint sets of identifiers that appear as mutable operands in the same instruction. The algorithm is relatively simple (especially since I had already implemented a union-find data structure): however looking at some examples reinforced that other planned todos around alias analysis are really important. We also have to think more about what "mutable lifetime" means in the context of SSA: currently variables that are reassigned (but never "mutated", eg bc they're assigned a value type) never appear as mutable.

Joe Savona committed Nov 15, 2022 at 14:26 UTC 4a21bb8856097a21532406a4a2a5689763da2e29
61 files changed +1223 -909
compiler/forget/src/HIR/DisjointSet.ts
+7 -7
@@ -22,7 +22,7 @@ export default class DisjointSet<T> {
22 const first = items.shift();
23 invariant(first != null, "Expected set to be non-empty");
24 // determine an arbitrary "root" for this set: if the first
25 - // item already has a root use that, otherwise the first item
25 + // item already has a root then use that, otherwise the first item
26 // will be the new root.
27 let root = this.#entries.get(first);
28 if (root == null) {
@@ -31,19 +31,19 @@ export default class DisjointSet<T> {
31 }
32 // update remaining items (which may already be part of other sets)
33 for (const item of items) {
34 - let parent = this.#entries.get(item);
35 - if (parent == null) {
34 + let itemParent = this.#entries.get(item);
35 + if (itemParent == null) {
36 // new item, no existing set to update
37 this.#entries.set(item, root);
38 continue;
39 - } else if (parent === root) {
39 + } else if (itemParent === root) {
40 continue;
41 } else {
42 let current = item;
43 - while (parent !== root && parent !== current) {
43 + while (itemParent !== root) {
44 this.#entries.set(current, root);
45 - current = parent;
46 - parent = this.#entries.get(current)!;
45 + current = itemParent;
46 + itemParent = this.#entries.get(current)!;
47 }
48 }
49 }
compiler/forget/src/HIR/EnterSSA.ts
+1
@@ -56,6 +56,7 @@ class SSABuilder {
56 start: 0,
57 end: 0,
58 },
59 + scope: null, // reset along w the mutable range
60 };
61 }
62
compiler/forget/src/HIR/HIR.ts
+10 -3
@@ -277,10 +277,17 @@ export type MutableRange = {
277 * Represents a user-defined variable (has a name) or a temporary variable (no name).
278 */
279 export type Identifier = {
280 - preSsaId: IdentifierId | null; // the original `id` value prior to entering SSA form
281 - id: IdentifierId; // unique value to distinguish a variable, since name is not guaranteed to exist or be unique
282 - name: string | null; // null for temporaries. name is primarily used for debugging.
280 + // the original `id` value prior to entering SSA form
281 + preSsaId: IdentifierId | null;
282 + // unique value to distinguish a variable, since name is not guaranteed to exist or be unique
283 + id: IdentifierId;
284 + // null for temporaries. name is primarily used for debugging.
285 + name: string | null;
286 + // The range for which this variable is mutable
287 mutableRange: MutableRange;
288 + // The ID of the reactive scope which will compute this value. Multiple variables may have
289 + // the same scope id.
290 + scope: ScopeId | null;
291 };
292
293 /**
compiler/forget/src/HIR/HIRBuilder.ts
+2
@@ -113,6 +113,7 @@ export default class HIRBuilder {
113 id,
114 name: null,
115 mutableRange: { start: 0, end: 0 },
116 + scope: null,
117 };
118 }
119
@@ -125,6 +126,7 @@ export default class HIRBuilder {
126 id,
127 name: node.name,
128 mutableRange: { start: 0, end: 0 },
129 + scope: null,
130 };
131 this.#bindings.set(node, identifier);
132 }
compiler/forget/src/HIR/InferReactiveScopeVariables.ts new
+125
@@ -0,0 +1,125 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +
8 +import DisjointSet from "./DisjointSet";
9 +import {
10 + HIRFunction,
11 + Identifier,
12 + Instruction,
13 + makeScopeId,
14 + Place,
15 + ScopeId,
16 +} from "./HIR";
17 +import { eachInstructionOperand } from "./visitors";
18 +
19 +/**
20 + * For each mutable variable, infers a reactive scope which will construct that
21 + * variable. Variables that co-mutate are assigned to the same reactive scope.
22 + * This pass does *not* infer the set of instructions necessary to compute each
23 + * variable/scope, only the set of variables that will be computed by each scope.
24 + *
25 + * Examples:
26 + * ```javascript
27 + * // Mutable arguments
28 + * let x = {};
29 + * let y = [];
30 + * foo(x, y); // both args mutable, could alias each other
31 + * y.push(x); // y is part of callee, counts as operand
32 + *
33 + * let z = {};
34 + * y.push(z);
35 + *
36 + * // Mutable assignment
37 + * let x = {};
38 + * let y = [];
39 + * x.y = y; // trivial aliasing
40 + * ```
41 + *
42 + * More generally, all mutable operands (incl lvalue) of an instruction must go in the
43 + * same scope.
44 + *
45 + * ## Implementation
46 + *
47 + * 1. Iterate over all instructions in all blocks (order does not matter, single pass),
48 + * and create disjoint sets ({@link DisjointSet}) for each set of operands that
49 + * mutate together per above rules.
50 + * 2. Iterate the contents of each set, and assign a new {@link ScopeId} to each set,
51 + * and update the `scope` property of each item in that set to that scope id.
52 + *
53 + * ## Other Issues Uncovered
54 + *
55 + * 1. Mutable lifetimes need to account for aliasing.
56 + *
57 + * ```javascript
58 + * let x = {};
59 + * let y = [];
60 + * x.y = y; // RHS is not considered mutable here bc not further mutation
61 + * mutate(x); // bc y is aliased here, it should still be considered mutable above
62 + * ```
63 + *
64 + * 2. Mutable lifetimes need to account for SSA reassignment.
65 + *
66 + * ```javascript
67 + * // y is never considered mutable bc SSA treats subsequent assignments as distinct identifiers
68 + * let y;
69 + * if (cond) {
70 + * y = ...;
71 + * } else {
72 + * y = ...;
73 + * }
74 + * ```
75 + */
76 +export function inferReactiveScopeVariables(fn: HIRFunction) {
77 + // Represents the set of reactive scopes as disjoint sets of identifiers
78 + // that mutate together.
79 + const scopes = new DisjointSet<Identifier>();
80 + for (const [_, block] of fn.body.blocks) {
81 + for (const instr of block.instructions) {
82 + const operands: Array<Identifier> = [];
83 + if (instr.lvalue !== null) {
84 + // invariant(
85 + // isMutable(instr, instr.lvalue!.place),
86 + // "Assignment always means the value is mutable:\n" +
87 + // printMixedHIR(instr)
88 + // );
89 + operands.push(instr.lvalue!.place.identifier);
90 + }
91 + for (const operand of eachInstructionOperand(instr)) {
92 + if (isMutable(instr, operand)) {
93 + operands.push(operand.identifier);
94 + }
95 + }
96 + if (operands.length !== 0) {
97 + scopes.union(operands);
98 + }
99 + }
100 + }
101 +
102 + // Maps each scope (by its identifying member) to a ScopeId value
103 + const scopeIds: Map<Identifier, ScopeId> = new Map();
104 +
105 + // Iterate over all the identifiers in all scopes, and assign each
106 + // identifier to its group's scope id. The first identifier in each
107 + // group assigns the scope id for that group.
108 + scopes.forEach((identifier, groupIdentifier) => {
109 + let scopeId = scopeIds.get(groupIdentifier);
110 + if (scopeId == null) {
111 + scopeId = makeScopeId(scopeIds.size);
112 + scopeIds.set(groupIdentifier, scopeId);
113 + }
114 + identifier.scope = scopeId;
115 + });
116 +}
117 +
118 +// Is the operand mutable at this given instruction
119 +function isMutable(instr: Instruction, place: Place): boolean {
120 + return (
121 + // TODO: should start really be exclusive?
122 + instr.id > place.identifier.mutableRange.start &&
123 + instr.id <= place.identifier.mutableRange.end
124 + );
125 +}
compiler/forget/src/HIR/PrintHIR.ts
+3 -1
@@ -296,7 +296,9 @@ export function printPlace(place: Place): string {
296 }
297
298 export function printIdentifier(id: Identifier): string {
299 - return `${id.name ?? ""}\$${id.id}`;
299 + return `${id.name ?? ""}\$${id.id}${
300 + id.scope !== null ? `_@${id.scope}` : ""
301 + }`;
302 }
303
304 export function printSourceLocation(loc: SourceLocation): string {
compiler/forget/src/__tests__/fixtures/hir/assignment-variations.expect.md
+22 -22
@@ -20,13 +20,13 @@ function g(a) {
20
21 ```
22 bb0:
23 - [1] Let mutate x$1 = 1
24 - [2] Const mutate $2 = 1
25 - [3] Reassign mutate x$1 = Binary read x$1 + read $2
26 - [4] Const mutate $3 = 1
27 - [5] Reassign mutate x$1 = Binary read x$1 + read $3
28 - [6] Const mutate $4 = 1
29 - [7] Reassign mutate x$1 = Binary read x$1 >>> read $4
23 + [1] Let mutate x$1_@0 = 1
24 + [2] Const mutate $2_@1 = 1
25 + [3] Reassign mutate x$1_@2 = Binary read x$1_@0 + read $2_@1
26 + [4] Const mutate $3_@3 = 1
27 + [5] Reassign mutate x$1_@4 = Binary read x$1_@2 + read $3_@3
28 + [6] Const mutate $4_@5 = 1
29 + [7] Reassign mutate x$1_@6 = Binary read x$1_@4 >>> read $4_@5
30 Return
31 ```
32
@@ -37,13 +37,13 @@ flowchart TB
37 %% Basic Blocks
38 subgraph bb0
39 bb0_instrs["
40 - [1] Let mutate x$1 = 1
41 - [2] Const mutate $2 = 1
42 - [3] Reassign mutate x$1 = Binary read x$1 + read $2
43 - [4] Const mutate $3 = 1
44 - [5] Reassign mutate x$1 = Binary read x$1 + read $3
45 - [6] Const mutate $4 = 1
46 - [7] Reassign mutate x$1 = Binary read x$1 >>> read $4
40 + [1] Let mutate x$1_@0 = 1
41 + [2] Const mutate $2_@1 = 1
42 + [3] Reassign mutate x$1_@2 = Binary read x$1_@0 + read $2_@1
43 + [4] Const mutate $3_@3 = 1
44 + [5] Reassign mutate x$1_@4 = Binary read x$1_@2 + read $3_@3
45 + [6] Const mutate $4_@5 = 1
46 + [7] Reassign mutate x$1_@6 = Binary read x$1_@4 >>> read $4_@5
47 "]
48 bb0_instrs --> bb0_terminal(["Return"])
49 end
@@ -68,10 +68,10 @@ function f$0() {
68
69 ```
70 bb0:
71 - [1] Const mutate $2 = 1
72 - [2] Reassign mutate a$1.b.c[0:4] = Binary read a$1.b.c + read $2
73 - [3] Const mutate $3 = 2
74 - [4] Reassign mutate a$1.b.c[0:4] = Binary read a$1.b.c * read $3
71 + [1] Const mutate $2_@0 = 1
72 + [2] Reassign mutate a$1_@1.b.c[0:4] = Binary read a$1_@1.b.c + read $2_@0
73 + [3] Const mutate $3_@2 = 2
74 + [4] Reassign mutate a$1_@1.b.c[0:4] = Binary read a$1_@1.b.c * read $3_@2
75 Return
76 ```
77
@@ -82,10 +82,10 @@ flowchart TB
82 %% Basic Blocks
83 subgraph bb0
84 bb0_instrs["
85 - [1] Const mutate $2 = 1
86 - [2] Reassign mutate a$1.b.c[0:4] = Binary read a$1.b.c + read $2
87 - [3] Const mutate $3 = 2
88 - [4] Reassign mutate a$1.b.c[0:4] = Binary read a$1.b.c * read $3
85 + [1] Const mutate $2_@0 = 1
86 + [2] Reassign mutate a$1_@1.b.c[0:4] = Binary read a$1_@1.b.c + read $2_@0
87 + [3] Const mutate $3_@2 = 2
88 + [4] Reassign mutate a$1_@1.b.c[0:4] = Binary read a$1_@1.b.c * read $3_@2
89 "]
90 bb0_instrs --> bb0_terminal(["Return"])
91 end
compiler/forget/src/__tests__/fixtures/hir/call.expect.md
+18 -18
@@ -47,15 +47,15 @@ function foo$0() {
47
48 ```
49 bb0:
50 - [1] Const mutate a$2[1:3] = Array []
51 - [2] Const mutate b$3[2:6] = Object { }
52 - [3] Call mutate foo$4(mutate a$2, mutate b$3)
53 - [4] Const mutate $6 = "div"
54 - [5] Let mutate _$5 = JSX <read $6 a={freeze a$2} ></read $6>
55 - [6] Call mutate foo$4(mutate b$3)
56 - [7] Const mutate $7 = "div"
57 - [8] Const mutate $8 = JSX <read $7 a={read a$2} b={freeze b$3} ></read $7>
58 - Return read $8
50 + [1] Const mutate a$2_@0[1:3] = Array []
51 + [2] Const mutate b$3_@0[2:6] = Object { }
52 + [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
53 + [4] Const mutate $6_@1 = "div"
54 + [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
55 + [6] Call mutate foo$4_@0(mutate b$3_@0)
56 + [7] Const mutate $7_@3 = "div"
57 + [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
58 + Return read $8_@4
59 ```
60
61 ### CFG
@@ -65,16 +65,16 @@ flowchart TB
65 %% Basic Blocks
66 subgraph bb0
67 bb0_instrs["
68 - [1] Const mutate a$2[1:3] = Array []
69 - [2] Const mutate b$3[2:6] = Object { }
70 - [3] Call mutate foo$4(mutate a$2, mutate b$3)
71 - [4] Const mutate $6 = 'div'
72 - [5] Let mutate _$5 = JSX <read $6 a={freeze a$2} ></read $6>
73 - [6] Call mutate foo$4(mutate b$3)
74 - [7] Const mutate $7 = 'div'
75 - [8] Const mutate $8 = JSX <read $7 a={read a$2} b={freeze b$3} ></read $7>
68 + [1] Const mutate a$2_@0[1:3] = Array []
69 + [2] Const mutate b$3_@0[2:6] = Object { }
70 + [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
71 + [4] Const mutate $6_@1 = 'div'
72 + [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
73 + [6] Call mutate foo$4_@0(mutate b$3_@0)
74 + [7] Const mutate $7_@3 = 'div'
75 + [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
76 "]
77 - bb0_instrs --> bb0_terminal(["Return read $8"])
77 + bb0_instrs --> bb0_terminal(["Return read $8_@4"])
78 end
79
80 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/component.expect.md
+56 -56
@@ -35,28 +35,28 @@ function Component(props) {
35
36 ```
37 bb0:
38 - [1] Const mutate items$2 = read props$1.items
39 - [2] Const mutate maxItems$3 = read props$1.maxItems
40 - [3] Const mutate renderedItems$4[3:14] = Array []
41 - [4] Const mutate seen$5[4:11] = New mutate Set$6()
42 - [5] Const mutate $9 = 0
43 - [6] Const mutate max$7 = Call mutate Math$8.max(read $9, read maxItems$3)
38 + [1] Const mutate items$2_@0 = read props$1.items
39 + [2] Const mutate maxItems$3_@1 = read props$1.maxItems
40 + [3] Const mutate renderedItems$4_@2[3:14] = Array []
41 + [4] Const mutate seen$5_@3[4:11] = New mutate Set$6_@3()
42 + [5] Const mutate $9_@4 = 0
43 + [6] Const mutate max$7_@5 = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1)
44 Goto bb1
45 bb1:
46 predecessor blocks: bb0 bb5 bb10
47 - If (read items$2) then:bb3 else:bb2
47 + If (read items$2_@0) then:bb3 else:bb2
48 bb3:
49 predecessor blocks: bb1
50 - [7] Const mutate $11 = null
51 - [8] Const mutate $12 = Binary read item$10 == read $11
52 - If (read $12) then:bb8 else:bb9
50 + [7] Const mutate $11_@6 = null
51 + [8] Const mutate $12_@3 = Binary read item$10_@3 == read $11_@6
52 + If (read $12_@3) then:bb8 else:bb9
53 bb8:
54 predecessor blocks: bb3
55 - [9] Const mutate $13 = read $12
55 + [9] Const mutate $13_@7 = read $12_@3
56 Goto bb7
57 bb9:
58 predecessor blocks: bb3
59 - [10] Const mutate $13 = Call mutate seen$5.has(mutate item$10)
59 + [10] Const mutate $13_@3 = Call mutate seen$5_@3.has(mutate item$10_@3)
60 Goto bb7
61 bb7:
62 predecessor blocks: bb8 bb9
@@ -66,27 +66,27 @@ bb5:
66 Goto(Continue) bb1
67 bb4:
68 predecessor blocks: bb7
69 - [11] Call mutate seen$5.add(mutate item$10)
70 - [12] Const mutate $14 = "div"
71 - [13] Const mutate $15 = JSX <read $14>{read item$10}</read $14>
72 - [14] Call mutate renderedItems$4.push(read $15)
73 - [15] Const mutate $16 = Binary read renderedItems$4.length >= read max$7
74 - If (read $16) then:bb2 else:bb10
69 + [11] Call mutate seen$5_@3.add(mutate item$10_@3)
70 + [12] Const mutate $14_@8 = "div"
71 + [13] Const mutate $15_@9 = JSX <read $14_@8>{read item$10_@3}</read $14_@8>
72 + [14] Call mutate renderedItems$4_@2.push(read $15_@9)
73 + [15] Const mutate $16_@10 = Binary read renderedItems$4_@2.length >= read max$7_@5
74 + If (read $16_@10) then:bb2 else:bb10
75 bb10:
76 predecessor blocks: bb4
77 Goto(Continue) bb1
78 bb2:
79 predecessor blocks: bb4 bb1
80 - [16] Const mutate count$17 = read renderedItems$4.length
81 - [17] Const mutate $18 = "div"
82 - [18] Const mutate $19 = "\n "
83 - [19] Const mutate $20 = "h1"
84 - [20] Const mutate $21 = " Items"
85 - [21] Const mutate $22 = JSX <read $20>{freeze count$17}{read $21}</read $20>
86 - [22] Const mutate $23 = "\n "
87 - [23] Const mutate $24 = "\n "
88 - [24] Const mutate $25 = JSX <read $18>{read $19}{read $22}{read $23}{freeze renderedItems$4}{read $24}</read $18>
89 - Return read $25
80 + [16] Const mutate count$17_@11 = read renderedItems$4_@2.length
81 + [17] Const mutate $18_@12 = "div"
82 + [18] Const mutate $19_@13 = "\n "
83 + [19] Const mutate $20_@14 = "h1"
84 + [20] Const mutate $21_@15 = " Items"
85 + [21] Const mutate $22_@16 = JSX <read $20_@14>{freeze count$17_@11}{read $21_@15}</read $20_@14>
86 + [22] Const mutate $23_@17 = "\n "
87 + [23] Const mutate $24_@18 = "\n "
88 + [24] Const mutate $25_@19 = JSX <read $18_@12>{read $19_@13}{read $22_@16}{read $23_@17}{freeze renderedItems$4_@2}{read $24_@18}</read $18_@12>
89 + Return read $25_@19
90 ```
91
92 ### CFG
@@ -96,34 +96,34 @@ flowchart TB
96 %% Basic Blocks
97 subgraph bb0
98 bb0_instrs["
99 - [1] Const mutate items$2 = read props$1.items
100 - [2] Const mutate maxItems$3 = read props$1.maxItems
101 - [3] Const mutate renderedItems$4[3:14] = Array []
102 - [4] Const mutate seen$5[4:11] = New mutate Set$6()
103 - [5] Const mutate $9 = 0
104 - [6] Const mutate max$7 = Call mutate Math$8.max(read $9, read maxItems$3)
99 + [1] Const mutate items$2_@0 = read props$1.items
100 + [2] Const mutate maxItems$3_@1 = read props$1.maxItems
101 + [3] Const mutate renderedItems$4_@2[3:14] = Array []
102 + [4] Const mutate seen$5_@3[4:11] = New mutate Set$6_@3()
103 + [5] Const mutate $9_@4 = 0
104 + [6] Const mutate max$7_@5 = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1)
105 "]
106 bb0_instrs --> bb0_terminal(["Goto"])
107 end
108 subgraph bb1
109 - bb1_terminal(["If (read items$2)"])
109 + bb1_terminal(["If (read items$2_@0)"])
110 end
111 subgraph bb3
112 bb3_instrs["
113 - [7] Const mutate $11 = null
114 - [8] Const mutate $12 = Binary read item$10 == read $11
113 + [7] Const mutate $11_@6 = null
114 + [8] Const mutate $12_@3 = Binary read item$10_@3 == read $11_@6
115 "]
116 - bb3_instrs --> bb3_terminal(["If (read $12)"])
116 + bb3_instrs --> bb3_terminal(["If (read $12_@3)"])
117 end
118 subgraph bb8
119 bb8_instrs["
120 - [9] Const mutate $13 = read $12
120 + [9] Const mutate $13_@7 = read $12_@3
121 "]
122 bb8_instrs --> bb8_terminal(["Goto"])
123 end
124 subgraph bb9
125 bb9_instrs["
126 - [10] Const mutate $13 = Call mutate seen$5.has(mutate item$10)
126 + [10] Const mutate $13_@3 = Call mutate seen$5_@3.has(mutate item$10_@3)
127 "]
128 bb9_instrs --> bb9_terminal(["Goto"])
129 end
@@ -135,30 +135,30 @@ flowchart TB
135 end
136 subgraph bb4
137 bb4_instrs["
138 - [11] Call mutate seen$5.add(mutate item$10)
139 - [12] Const mutate $14 = 'div'
140 - [13] Const mutate $15 = JSX <read $14>{read item$10}</read $14>
141 - [14] Call mutate renderedItems$4.push(read $15)
142 - [15] Const mutate $16 = Binary read renderedItems$4.length >= read max$7
138 + [11] Call mutate seen$5_@3.add(mutate item$10_@3)
139 + [12] Const mutate $14_@8 = 'div'
140 + [13] Const mutate $15_@9 = JSX <read $14_@8>{read item$10_@3}</read $14_@8>
141 + [14] Call mutate renderedItems$4_@2.push(read $15_@9)
142 + [15] Const mutate $16_@10 = Binary read renderedItems$4_@2.length >= read max$7_@5
143 "]
144 - bb4_instrs --> bb4_terminal(["If (read $16)"])
144 + bb4_instrs --> bb4_terminal(["If (read $16_@10)"])
145 end
146 subgraph bb10
147 bb10_terminal(["Goto"])
148 end
149 subgraph bb2
150 bb2_instrs["
151 - [16] Const mutate count$17 = read renderedItems$4.length
152 - [17] Const mutate $18 = 'div'
153 - [18] Const mutate $19 = '\n '
154 - [19] Const mutate $20 = 'h1'
155 - [20] Const mutate $21 = ' Items'
156 - [21] Const mutate $22 = JSX <read $20>{freeze count$17}{read $21}</read $20>
157 - [22] Const mutate $23 = '\n '
158 - [23] Const mutate $24 = '\n '
159 - [24] Const mutate $25 = JSX <read $18>{read $19}{read $22}{read $23}{freeze renderedItems$4}{read $24}</read $18>
151 + [16] Const mutate count$17_@11 = read renderedItems$4_@2.length
152 + [17] Const mutate $18_@12 = 'div'
153 + [18] Const mutate $19_@13 = '\n '
154 + [19] Const mutate $20_@14 = 'h1'
155 + [20] Const mutate $21_@15 = ' Items'
156 + [21] Const mutate $22_@16 = JSX <read $20_@14>{freeze count$17_@11}{read $21_@15}</read $20_@14>
157 + [22] Const mutate $23_@17 = '\n '
158 + [23] Const mutate $24_@18 = '\n '
159 + [24] Const mutate $25_@19 = JSX <read $18_@12>{read $19_@13}{read $22_@16}{read $23_@17}{freeze renderedItems$4_@2}{read $24_@18}</read $18_@12>
160 "]
161 - bb2_instrs --> bb2_terminal(["Return read $25"])
161 + bb2_instrs --> bb2_terminal(["Return read $25_@19"])
162 end
163
164 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md
+58 -58
@@ -78,17 +78,17 @@ function Component(props) {
78
79 ```
80 bb0:
81 - [1] Const mutate a_DEBUG$2[1:4] = Array []
82 - [2] Call mutate a_DEBUG$2.push(read props$1.a)
81 + [1] Const mutate a_DEBUG$2_@0[1:4] = Array []
82 + [2] Call mutate a_DEBUG$2_@0.push(read props$1.a)
83 If (read props$1.b) then:bb2 else:bb1
84 bb2:
85 predecessor blocks: bb0
86 - [3] Const mutate $3 = null
87 - Return read $3
86 + [3] Const mutate $3_@1 = null
87 + Return read $3_@1
88 bb1:
89 predecessor blocks: bb0
90 - [4] Call mutate a_DEBUG$2.push(read props$1.d)
91 - Return freeze a_DEBUG$2
90 + [4] Call mutate a_DEBUG$2_@0.push(read props$1.d)
91 + Return freeze a_DEBUG$2_@0
92 ```
93
94 ### CFG
@@ -98,22 +98,22 @@ flowchart TB
98 %% Basic Blocks
99 subgraph bb0
100 bb0_instrs["
101 - [1] Const mutate a_DEBUG$2[1:4] = Array []
102 - [2] Call mutate a_DEBUG$2.push(read props$1.a)
101 + [1] Const mutate a_DEBUG$2_@0[1:4] = Array []
102 + [2] Call mutate a_DEBUG$2_@0.push(read props$1.a)
103 "]
104 bb0_instrs --> bb0_terminal(["If (read props$1.b)"])
105 end
106 subgraph bb2
107 bb2_instrs["
108 - [3] Const mutate $3 = null
108 + [3] Const mutate $3_@1 = null
109 "]
110 - bb2_instrs --> bb2_terminal(["Return read $3"])
110 + bb2_instrs --> bb2_terminal(["Return read $3_@1"])
111 end
112 subgraph bb1
113 bb1_instrs["
114 - [4] Call mutate a_DEBUG$2.push(read props$1.d)
114 + [4] Call mutate a_DEBUG$2_@0.push(read props$1.d)
115 "]
116 - bb1_instrs --> bb1_terminal(["Return freeze a_DEBUG$2"])
116 + bb1_instrs --> bb1_terminal(["Return freeze a_DEBUG$2_@0"])
117 end
118
119 %% Jumps
@@ -141,17 +141,17 @@ function Component$0(props$1) {
141
142 ```
143 bb0:
144 - [1] Const mutate a$2[1:4] = Array []
145 - [2] Call mutate a$2.push(read props$1.a)
144 + [1] Const mutate a$2_@0[1:4] = Array []
145 + [2] Call mutate a$2_@0.push(read props$1.a)
146 If (read props$1.b) then:bb2 else:bb1
147 bb2:
148 predecessor blocks: bb0
149 - [3] Call mutate a$2.push(read props$1.c)
149 + [3] Call mutate a$2_@0.push(read props$1.c)
150 Goto bb1
151 bb1:
152 predecessor blocks: bb2 bb0
153 - [4] Call mutate a$2.push(read props$1.d)
154 - Return freeze a$2
153 + [4] Call mutate a$2_@0.push(read props$1.d)
154 + Return freeze a$2_@0
155 ```
156
157 ### CFG
@@ -161,22 +161,22 @@ flowchart TB
161 %% Basic Blocks
162 subgraph bb0
163 bb0_instrs["
164 - [1] Const mutate a$2[1:4] = Array []
165 - [2] Call mutate a$2.push(read props$1.a)
164 + [1] Const mutate a$2_@0[1:4] = Array []
165 + [2] Call mutate a$2_@0.push(read props$1.a)
166 "]
167 bb0_instrs --> bb0_terminal(["If (read props$1.b)"])
168 end
169 subgraph bb2
170 bb2_instrs["
171 - [3] Call mutate a$2.push(read props$1.c)
171 + [3] Call mutate a$2_@0.push(read props$1.c)
172 "]
173 bb2_instrs --> bb2_terminal(["Goto"])
174 end
175 subgraph bb1
176 bb1_instrs["
177 - [4] Call mutate a$2.push(read props$1.d)
177 + [4] Call mutate a$2_@0.push(read props$1.d)
178 "]
179 - bb1_instrs --> bb1_terminal(["Return freeze a$2"])
179 + bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"])
180 end
181
182 %% Jumps
@@ -205,18 +205,18 @@ function Component$0(props$1) {
205
206 ```
207 bb0:
208 - [1] Const mutate a$2[1:5] = Array []
209 - [2] Call mutate a$2.push(read props$1.a)
208 + [1] Const mutate a$2_@0[1:5] = Array []
209 + [2] Call mutate a$2_@0.push(read props$1.a)
210 If (read props$1.b) then:bb2 else:bb1
211 bb2:
212 predecessor blocks: bb0
213 - [3] Call mutate a$2.push(read props$1.c)
214 - [4] Const mutate $3 = null
215 - Return read $3
213 + [3] Call mutate a$2_@0.push(read props$1.c)
214 + [4] Const mutate $3_@1 = null
215 + Return read $3_@1
216 bb1:
217 predecessor blocks: bb0
218 - [5] Call mutate a$2.push(read props$1.d)
219 - Return freeze a$2
218 + [5] Call mutate a$2_@0.push(read props$1.d)
219 + Return freeze a$2_@0
220 ```
221
222 ### CFG
@@ -226,23 +226,23 @@ flowchart TB
226 %% Basic Blocks
227 subgraph bb0
228 bb0_instrs["
229 - [1] Const mutate a$2[1:5] = Array []
230 - [2] Call mutate a$2.push(read props$1.a)
229 + [1] Const mutate a$2_@0[1:5] = Array []
230 + [2] Call mutate a$2_@0.push(read props$1.a)
231 "]
232 bb0_instrs --> bb0_terminal(["If (read props$1.b)"])
233 end
234 subgraph bb2
235 bb2_instrs["
236 - [3] Call mutate a$2.push(read props$1.c)
237 - [4] Const mutate $3 = null
236 + [3] Call mutate a$2_@0.push(read props$1.c)
237 + [4] Const mutate $3_@1 = null
238 "]
239 - bb2_instrs --> bb2_terminal(["Return read $3"])
239 + bb2_instrs --> bb2_terminal(["Return read $3_@1"])
240 end
241 subgraph bb1
242 bb1_instrs["
243 - [5] Call mutate a$2.push(read props$1.d)
243 + [5] Call mutate a$2_@0.push(read props$1.d)
244 "]
245 - bb1_instrs --> bb1_terminal(["Return freeze a$2"])
245 + bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"])
246 end
247
248 %% Jumps
@@ -271,17 +271,17 @@ function Component$0(props$1) {
271
272 ```
273 bb0:
274 - [1] Const mutate a$2[1:4] = Array []
275 - [2] Call mutate a$2.push(read props$1.a)
274 + [1] Const mutate a$2_@0[1:4] = Array []
275 + [2] Call mutate a$2_@0.push(read props$1.a)
276 If (read props$1.b) then:bb2 else:bb1
277 bb2:
278 predecessor blocks: bb0
279 - [3] Call mutate a$2.push(read props$1.c)
280 - Return freeze a$2
279 + [3] Call mutate a$2_@0.push(read props$1.c)
280 + Return freeze a$2_@0
281 bb1:
282 predecessor blocks: bb0
283 - [4] Call mutate a$2.push(read props$1.d)
284 - Return freeze a$2
283 + [4] Call mutate a$2_@0.push(read props$1.d)
284 + Return freeze a$2_@0
285 ```
286
287 ### CFG
@@ -291,22 +291,22 @@ flowchart TB
291 %% Basic Blocks
292 subgraph bb0
293 bb0_instrs["
294 - [1] Const mutate a$2[1:4] = Array []
295 - [2] Call mutate a$2.push(read props$1.a)
294 + [1] Const mutate a$2_@0[1:4] = Array []
295 + [2] Call mutate a$2_@0.push(read props$1.a)
296 "]
297 bb0_instrs --> bb0_terminal(["If (read props$1.b)"])
298 end
299 subgraph bb2
300 bb2_instrs["
301 - [3] Call mutate a$2.push(read props$1.c)
301 + [3] Call mutate a$2_@0.push(read props$1.c)
302 "]
303 - bb2_instrs --> bb2_terminal(["Return freeze a$2"])
303 + bb2_instrs --> bb2_terminal(["Return freeze a$2_@0"])
304 end
305 subgraph bb1
306 bb1_instrs["
307 - [4] Call mutate a$2.push(read props$1.d)
307 + [4] Call mutate a$2_@0.push(read props$1.d)
308 "]
309 - bb1_instrs --> bb1_terminal(["Return freeze a$2"])
309 + bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"])
310 end
311
312 %% Jumps
@@ -335,17 +335,17 @@ function Component$0(props$1) {
335
336 ```
337 bb0:
338 - [1] Const mutate a$2[1:4] = Array []
339 - [2] Call mutate a$2.push(read props$1.a)
338 + [1] Const mutate a$2_@0[1:4] = Array []
339 + [2] Call mutate a$2_@0.push(read props$1.a)
340 If (read props$1.b) then:bb1 else:bb2
341 bb2:
342 predecessor blocks: bb0
343 - [3] Call mutate a$2.push(read props$1.c)
343 + [3] Call mutate a$2_@0.push(read props$1.c)
344 Goto bb1
345 bb1:
346 predecessor blocks: bb0 bb2
347 - [4] Call mutate a$2.push(read props$1.d)
348 - Return freeze a$2
347 + [4] Call mutate a$2_@0.push(read props$1.d)
348 + Return freeze a$2_@0
349 ```
350
351 ### CFG
@@ -355,22 +355,22 @@ flowchart TB
355 %% Basic Blocks
356 subgraph bb0
357 bb0_instrs["
358 - [1] Const mutate a$2[1:4] = Array []
359 - [2] Call mutate a$2.push(read props$1.a)
358 + [1] Const mutate a$2_@0[1:4] = Array []
359 + [2] Call mutate a$2_@0.push(read props$1.a)
360 "]
361 bb0_instrs --> bb0_terminal(["If (read props$1.b)"])
362 end
363 subgraph bb2
364 bb2_instrs["
365 - [3] Call mutate a$2.push(read props$1.c)
365 + [3] Call mutate a$2_@0.push(read props$1.c)
366 "]
367 bb2_instrs --> bb2_terminal(["Goto"])
368 end
369 subgraph bb1
370 bb1_instrs["
371 - [4] Call mutate a$2.push(read props$1.d)
371 + [4] Call mutate a$2_@0.push(read props$1.d)
372 "]
373 - bb1_instrs --> bb1_terminal(["Return freeze a$2"])
373 + bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"])
374 end
375
376 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md
+30 -30
@@ -67,24 +67,24 @@ function mayMutate() {}
67
68 ```
69 bb0:
70 - [1] Const mutate a$2[1:3] = Array []
71 - [2] Const mutate b$3[2:4] = Array []
72 - If (read b$3) then:bb2 else:bb1
70 + [1] Const mutate a$2_@0[1:3] = Array []
71 + [2] Const mutate b$3_@1[2:4] = Array []
72 + If (read b$3_@1) then:bb2 else:bb1
73 bb2:
74 predecessor blocks: bb0
75 - [3] Call mutate a$2.push(read props$1.p0)
75 + [3] Call mutate a$2_@0.push(read props$1.p0)
76 Goto bb1
77 bb1:
78 predecessor blocks: bb2 bb0
79 If (read props$1.p1) then:bb4 else:bb3
80 bb4:
81 predecessor blocks: bb1
82 - [4] Call mutate b$3.push(read props$1.p2)
82 + [4] Call mutate b$3_@1.push(read props$1.p2)
83 Goto bb3
84 bb3:
85 predecessor blocks: bb4 bb1
86 - [5] Const mutate $5 = JSX <read Foo$4 a={freeze a$2} b={freeze b$3} ></read Foo$4>
87 - Return read $5
86 + [5] Const mutate $5_@2 = JSX <read Foo$4 a={freeze a$2_@0} b={freeze b$3_@1} ></read Foo$4>
87 + Return read $5_@2
88 ```
89
90 ### CFG
@@ -94,14 +94,14 @@ flowchart TB
94 %% Basic Blocks
95 subgraph bb0
96 bb0_instrs["
97 - [1] Const mutate a$2[1:3] = Array []
98 - [2] Const mutate b$3[2:4] = Array []
97 + [1] Const mutate a$2_@0[1:3] = Array []
98 + [2] Const mutate b$3_@1[2:4] = Array []
99 "]
100 - bb0_instrs --> bb0_terminal(["If (read b$3)"])
100 + bb0_instrs --> bb0_terminal(["If (read b$3_@1)"])
101 end
102 subgraph bb2
103 bb2_instrs["
104 - [3] Call mutate a$2.push(read props$1.p0)
104 + [3] Call mutate a$2_@0.push(read props$1.p0)
105 "]
106 bb2_instrs --> bb2_terminal(["Goto"])
107 end
@@ -110,15 +110,15 @@ flowchart TB
110 end
111 subgraph bb4
112 bb4_instrs["
113 - [4] Call mutate b$3.push(read props$1.p2)
113 + [4] Call mutate b$3_@1.push(read props$1.p2)
114 "]
115 bb4_instrs --> bb4_terminal(["Goto"])
116 end
117 subgraph bb3
118 bb3_instrs["
119 - [5] Const mutate $5 = JSX <read Foo$4 a={freeze a$2} b={freeze b$3} ></read Foo$4>
119 + [5] Const mutate $5_@2 = JSX <read Foo$4 a={freeze a$2_@0} b={freeze b$3_@1} ></read Foo$4>
120 "]
121 - bb3_instrs --> bb3_terminal(["Return read $5"])
121 + bb3_instrs --> bb3_terminal(["Return read $5_@2"])
122 end
123
124 %% Jumps
@@ -153,25 +153,25 @@ function Component$0(props$1) {
153
154 ```
155 bb0:
156 - [1] Const mutate a$2[1:4] = Array []
157 - [2] Const mutate b$3[2:5] = Array []
158 - [3] Const mutate $5 = Call mutate mayMutate$4(mutate b$3)
159 - If (read $5) then:bb2 else:bb1
156 + [1] Const mutate a$2_@0[1:4] = Array []
157 + [2] Const mutate b$3_@1[2:5] = Array []
158 + [3] Const mutate $5_@1 = Call mutate mayMutate$4_@1(mutate b$3_@1)
159 + If (read $5_@1) then:bb2 else:bb1
160 bb2:
161 predecessor blocks: bb0
162 - [4] Call mutate a$2.push(read props$1.p0)
162 + [4] Call mutate a$2_@0.push(read props$1.p0)
163 Goto bb1
164 bb1:
165 predecessor blocks: bb2 bb0
166 If (read props$1.p1) then:bb4 else:bb3
167 bb4:
168 predecessor blocks: bb1
169 - [5] Call mutate b$3.push(read props$1.p2)
169 + [5] Call mutate b$3_@1.push(read props$1.p2)
170 Goto bb3
171 bb3:
172 predecessor blocks: bb4 bb1
173 - [6] Const mutate $7 = JSX <read Foo$6 a={freeze a$2} b={freeze b$3} ></read Foo$6>
174 - Return read $7
173 + [6] Const mutate $7_@2 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$3_@1} ></read Foo$6>
174 + Return read $7_@2
175 ```
176
177 ### CFG
@@ -181,15 +181,15 @@ flowchart TB
181 %% Basic Blocks
182 subgraph bb0
183 bb0_instrs["
184 - [1] Const mutate a$2[1:4] = Array []
185 - [2] Const mutate b$3[2:5] = Array []
186 - [3] Const mutate $5 = Call mutate mayMutate$4(mutate b$3)
184 + [1] Const mutate a$2_@0[1:4] = Array []
185 + [2] Const mutate b$3_@1[2:5] = Array []
186 + [3] Const mutate $5_@1 = Call mutate mayMutate$4_@1(mutate b$3_@1)
187 "]
188 - bb0_instrs --> bb0_terminal(["If (read $5)"])
188 + bb0_instrs --> bb0_terminal(["If (read $5_@1)"])
189 end
190 subgraph bb2
191 bb2_instrs["
192 - [4] Call mutate a$2.push(read props$1.p0)
192 + [4] Call mutate a$2_@0.push(read props$1.p0)
193 "]
194 bb2_instrs --> bb2_terminal(["Goto"])
195 end
@@ -198,15 +198,15 @@ flowchart TB
198 end
199 subgraph bb4
200 bb4_instrs["
201 - [5] Call mutate b$3.push(read props$1.p2)
201 + [5] Call mutate b$3_@1.push(read props$1.p2)
202 "]
203 bb4_instrs --> bb4_terminal(["Goto"])
204 end
205 subgraph bb3
206 bb3_instrs["
207 - [6] Const mutate $7 = JSX <read Foo$6 a={freeze a$2} b={freeze b$3} ></read Foo$6>
207 + [6] Const mutate $7_@2 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$3_@1} ></read Foo$6>
208 "]
209 - bb3_instrs --> bb3_terminal(["Return read $7"])
209 + bb3_instrs --> bb3_terminal(["Return read $7_@2"])
210 end
211
212 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md
+18 -18
@@ -47,15 +47,15 @@ function Foo$0() {
47
48 ```
49 bb0:
50 - [1] Const mutate a$2[1:3] = Array []
51 - [2] Const mutate b$3[2:6] = Object { }
52 - [3] New mutate Foo$4(mutate a$2, mutate b$3)
53 - [4] Const mutate $6 = "div"
54 - [5] Let mutate _$5 = JSX <read $6 a={freeze a$2} ></read $6>
55 - [6] New mutate Foo$4(mutate b$3)
56 - [7] Const mutate $7 = "div"
57 - [8] Const mutate $8 = JSX <read $7 a={read a$2} b={freeze b$3} ></read $7>
58 - Return read $8
50 + [1] Const mutate a$2_@0[1:3] = Array []
51 + [2] Const mutate b$3_@0[2:6] = Object { }
52 + [3] New mutate Foo$4_@0(mutate a$2_@0, mutate b$3_@0)
53 + [4] Const mutate $6_@1 = "div"
54 + [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
55 + [6] New mutate Foo$4_@0(mutate b$3_@0)
56 + [7] Const mutate $7_@3 = "div"
57 + [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
58 + Return read $8_@4
59 ```
60
61 ### CFG
@@ -65,16 +65,16 @@ flowchart TB
65 %% Basic Blocks
66 subgraph bb0
67 bb0_instrs["
68 - [1] Const mutate a$2[1:3] = Array []
69 - [2] Const mutate b$3[2:6] = Object { }
70 - [3] New mutate Foo$4(mutate a$2, mutate b$3)
71 - [4] Const mutate $6 = 'div'
72 - [5] Let mutate _$5 = JSX <read $6 a={freeze a$2} ></read $6>
73 - [6] New mutate Foo$4(mutate b$3)
74 - [7] Const mutate $7 = 'div'
75 - [8] Const mutate $8 = JSX <read $7 a={read a$2} b={freeze b$3} ></read $7>
68 + [1] Const mutate a$2_@0[1:3] = Array []
69 + [2] Const mutate b$3_@0[2:6] = Object { }
70 + [3] New mutate Foo$4_@0(mutate a$2_@0, mutate b$3_@0)
71 + [4] Const mutate $6_@1 = 'div'
72 + [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
73 + [6] New mutate Foo$4_@0(mutate b$3_@0)
74 + [7] Const mutate $7_@3 = 'div'
75 + [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
76 "]
77 - bb0_instrs --> bb0_terminal(["Return read $8"])
77 + bb0_instrs --> bb0_terminal(["Return read $8_@4"])
78 end
79
80 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md
+8 -8
@@ -18,10 +18,10 @@ function foo(x) {}
18
19 ```
20 bb0:
21 - [1] Const mutate a$1 = Array []
22 - [2] Const mutate b$2 = read a$1
23 - [3] Call read useFreeze$3(freeze a$1)
24 - [4] Call mutate foo$4(read b$2)
21 + [1] Const mutate a$1_@0 = Array []
22 + [2] Const mutate b$2_@1 = read a$1_@0
23 + [3] Call read useFreeze$3(freeze a$1_@0)
24 + [4] Call mutate foo$4_@2(read b$2_@1)
25 Return
26 ```
27
@@ -32,10 +32,10 @@ flowchart TB
32 %% Basic Blocks
33 subgraph bb0
34 bb0_instrs["
35 - [1] Const mutate a$1 = Array []
36 - [2] Const mutate b$2 = read a$1
37 - [3] Call read useFreeze$3(freeze a$1)
38 - [4] Call mutate foo$4(read b$2)
35 + [1] Const mutate a$1_@0 = Array []
36 + [2] Const mutate b$2_@1 = read a$1_@0
37 + [3] Call read useFreeze$3(freeze a$1_@0)
38 + [4] Call mutate foo$4_@2(read b$2_@1)
39 "]
40 bb0_instrs --> bb0_terminal(["Return"])
41 end
compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md
+16 -16
@@ -79,14 +79,14 @@ function foo$0() {
79
80 ```
81 bb0:
82 - [1] Const mutate x$2 = Array []
83 - [2] Const mutate y$3 = Call read useFreeze$4(freeze x$2)
84 - [3] Call mutate foo$5(read y$3, read x$2)
85 - [4] Const mutate $6 = "\n "
86 - [5] Const mutate $7 = "\n "
87 - [6] Const mutate $8 = "\n "
88 - [7] Const mutate $9 = JSX <read Component$0>{read $6}{read x$2}{read $7}{read y$3}{read $8}</read Component$0>
89 - Return read $9
82 + [1] Const mutate x$2_@0 = Array []
83 + [2] Const mutate y$3_@1 = Call read useFreeze$4(freeze x$2_@0)
84 + [3] Call mutate foo$5_@2(read y$3_@1, read x$2_@0)
85 + [4] Const mutate $6_@3 = "\n "
86 + [5] Const mutate $7_@4 = "\n "
87 + [6] Const mutate $8_@5 = "\n "
88 + [7] Const mutate $9_@6 = JSX <read Component$0>{read $6_@3}{read x$2_@0}{read $7_@4}{read y$3_@1}{read $8_@5}</read Component$0>
89 + Return read $9_@6
90 ```
91
92 ### CFG
@@ -96,15 +96,15 @@ flowchart TB
96 %% Basic Blocks
97 subgraph bb0
98 bb0_instrs["
99 - [1] Const mutate x$2 = Array []
100 - [2] Const mutate y$3 = Call read useFreeze$4(freeze x$2)
101 - [3] Call mutate foo$5(read y$3, read x$2)
102 - [4] Const mutate $6 = '\n '
103 - [5] Const mutate $7 = '\n '
104 - [6] Const mutate $8 = '\n '
105 - [7] Const mutate $9 = JSX <read Component$0>{read $6}{read x$2}{read $7}{read y$3}{read $8}</read Component$0>
99 + [1] Const mutate x$2_@0 = Array []
100 + [2] Const mutate y$3_@1 = Call read useFreeze$4(freeze x$2_@0)
101 + [3] Call mutate foo$5_@2(read y$3_@1, read x$2_@0)
102 + [4] Const mutate $6_@3 = '\n '
103 + [5] Const mutate $7_@4 = '\n '
104 + [6] Const mutate $8_@5 = '\n '
105 + [7] Const mutate $9_@6 = JSX <read Component$0>{read $6_@3}{read x$2_@0}{read $7_@4}{read y$3_@1}{read $8_@5}</read Component$0>
106 "]
107 - bb0_instrs --> bb0_terminal(["Return read $9"])
107 + bb0_instrs --> bb0_terminal(["Return read $9_@6"])
108 end
109
110 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md
+10 -10
@@ -19,11 +19,11 @@ function call(x) {}
19
20 ```
21 bb0:
22 - [1] Const mutate a$1 = Array []
23 - [2] Call read useFreeze$2(freeze a$1)
24 - [3] Call read useFreeze$2(read a$1)
25 - [4] Call mutate call$3(read a$1)
26 - Return read a$1
22 + [1] Const mutate a$1_@0 = Array []
23 + [2] Call read useFreeze$2(freeze a$1_@0)
24 + [3] Call read useFreeze$2(read a$1_@0)
25 + [4] Call mutate call$3_@1(read a$1_@0)
26 + Return read a$1_@0
27 ```
28
29 ### CFG
@@ -33,12 +33,12 @@ flowchart TB
33 %% Basic Blocks
34 subgraph bb0
35 bb0_instrs["
36 - [1] Const mutate a$1 = Array []
37 - [2] Call read useFreeze$2(freeze a$1)
38 - [3] Call read useFreeze$2(read a$1)
39 - [4] Call mutate call$3(read a$1)
36 + [1] Const mutate a$1_@0 = Array []
37 + [2] Call read useFreeze$2(freeze a$1_@0)
38 + [3] Call read useFreeze$2(read a$1_@0)
39 + [4] Call mutate call$3_@1(read a$1_@0)
40 "]
41 - bb0_instrs --> bb0_terminal(["Return read a$1"])
41 + bb0_instrs --> bb0_terminal(["Return read a$1_@0"])
42 end
43
44 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md
+14 -14
@@ -26,23 +26,23 @@ function call(x) {}
26
27 ```
28 bb0:
29 - [1] Const mutate cond$2 = read props$1.cond
30 - [2] Const mutate x$3 = read props$1.x
31 - [3] Let mutate a$4 = undefined
32 - If (read cond$2) then:bb2 else:bb3
29 + [1] Const mutate cond$2_@0 = read props$1.cond
30 + [2] Const mutate x$3_@1 = read props$1.x
31 + [3] Let mutate a$4_@2 = undefined
32 + If (read cond$2_@0) then:bb2 else:bb3
33 bb2:
34 predecessor blocks: bb0
35 - [4] Reassign mutate a$4 = read x$3
35 + [4] Reassign mutate a$4_@3 = read x$3_@1
36 Goto bb1
37 bb3:
38 predecessor blocks: bb0
39 - [5] Reassign mutate a$4 = Array []
39 + [5] Reassign mutate a$4_@4 = Array []
40 Goto bb1
41 bb1:
42 predecessor blocks: bb2 bb3
43 [6] Call read useFreeze$5(freeze a$4)
44 [7] Call read useFreeze$5(read a$4)
45 - [8] Call mutate call$6(read a$4)
45 + [8] Call mutate call$6_@5(read a$4)
46 Return read a$4
47 ```
48
@@ -53,21 +53,21 @@ flowchart TB
53 %% Basic Blocks
54 subgraph bb0
55 bb0_instrs["
56 - [1] Const mutate cond$2 = read props$1.cond
57 - [2] Const mutate x$3 = read props$1.x
58 - [3] Let mutate a$4 = undefined
56 + [1] Const mutate cond$2_@0 = read props$1.cond
57 + [2] Const mutate x$3_@1 = read props$1.x
58 + [3] Let mutate a$4_@2 = undefined
59 "]
60 - bb0_instrs --> bb0_terminal(["If (read cond$2)"])
60 + bb0_instrs --> bb0_terminal(["If (read cond$2_@0)"])
61 end
62 subgraph bb2
63 bb2_instrs["
64 - [4] Reassign mutate a$4 = read x$3
64 + [4] Reassign mutate a$4_@3 = read x$3_@1
65 "]
66 bb2_instrs --> bb2_terminal(["Goto"])
67 end
68 subgraph bb3
69 bb3_instrs["
70 - [5] Reassign mutate a$4 = Array []
70 + [5] Reassign mutate a$4_@4 = Array []
71 "]
72 bb3_instrs --> bb3_terminal(["Goto"])
73 end
@@ -75,7 +75,7 @@ flowchart TB
75 bb1_instrs["
76 [6] Call read useFreeze$5(freeze a$4)
77 [7] Call read useFreeze$5(read a$4)
78 - [8] Call mutate call$6(read a$4)
78 + [8] Call mutate call$6_@5(read a$4)
79 "]
80 bb1_instrs --> bb1_terminal(["Return read a$4"])
81 end
compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md
+12 -12
@@ -149,18 +149,18 @@ function Foo$0() {
149
150 ```
151 bb0:
152 - [1] Const mutate a$2[1:3] = Call mutate compute$3(read props$1.a)
153 - [2] Const mutate b$4[2:4] = Call mutate compute$3(read props$1.b)
152 + [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
153 + [2] Const mutate b$4_@0[2:4] = Call mutate compute$3_@0(read props$1.b)
154 If (read props$1.c) then:bb2 else:bb1
155 bb2:
156 predecessor blocks: bb0
157 - [3] Call mutate mutate$5(mutate a$2)
158 - [4] Call mutate mutate$5(mutate b$4)
157 + [3] Call mutate mutate$5_@0(mutate a$2_@0)
158 + [4] Call mutate mutate$5_@0(mutate b$4_@0)
159 Goto bb1
160 bb1:
161 predecessor blocks: bb2 bb0
162 - [5] Const mutate $7 = JSX <read Foo$6 a={freeze a$2} b={freeze b$4} ></read Foo$6>
163 - Return read $7
162 + [5] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
163 + Return read $7_@1
164 ```
165
166 ### CFG
@@ -170,23 +170,23 @@ flowchart TB
170 %% Basic Blocks
171 subgraph bb0
172 bb0_instrs["
173 - [1] Const mutate a$2[1:3] = Call mutate compute$3(read props$1.a)
174 - [2] Const mutate b$4[2:4] = Call mutate compute$3(read props$1.b)
173 + [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
174 + [2] Const mutate b$4_@0[2:4] = Call mutate compute$3_@0(read props$1.b)
175 "]
176 bb0_instrs --> bb0_terminal(["If (read props$1.c)"])
177 end
178 subgraph bb2
179 bb2_instrs["
180 - [3] Call mutate mutate$5(mutate a$2)
181 - [4] Call mutate mutate$5(mutate b$4)
180 + [3] Call mutate mutate$5_@0(mutate a$2_@0)
181 + [4] Call mutate mutate$5_@0(mutate b$4_@0)
182 "]
183 bb2_instrs --> bb2_terminal(["Goto"])
184 end
185 subgraph bb1
186 bb1_instrs["
187 - [5] Const mutate $7 = JSX <read Foo$6 a={freeze a$2} b={freeze b$4} ></read Foo$6>
187 + [5] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
188 "]
189 - bb1_instrs --> bb1_terminal(["Return read $7"])
189 + bb1_instrs --> bb1_terminal(["Return read $7_@1"])
190 end
191
192 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/independent.expect.md
+8 -8
@@ -28,10 +28,10 @@ function Foo() {}
28
29 ```
30 bb0:
31 - [1] Const mutate a$2 = Call mutate compute$3(read props$1.a)
32 - [2] Const mutate b$4 = Call mutate compute$3(read props$1.b)
33 - [3] Const mutate $6 = JSX <read Foo$5 a={freeze a$2} b={freeze b$4} ></read Foo$5>
34 - Return read $6
31 + [1] Const mutate a$2_@0 = Call mutate compute$3_@0(read props$1.a)
32 + [2] Const mutate b$4_@0 = Call mutate compute$3_@0(read props$1.b)
33 + [3] Const mutate $6_@1 = JSX <read Foo$5 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$5>
34 + Return read $6_@1
35 ```
36
37 ### CFG
@@ -41,11 +41,11 @@ flowchart TB
41 %% Basic Blocks
42 subgraph bb0
43 bb0_instrs["
44 - [1] Const mutate a$2 = Call mutate compute$3(read props$1.a)
45 - [2] Const mutate b$4 = Call mutate compute$3(read props$1.b)
46 - [3] Const mutate $6 = JSX <read Foo$5 a={freeze a$2} b={freeze b$4} ></read Foo$5>
44 + [1] Const mutate a$2_@0 = Call mutate compute$3_@0(read props$1.a)
45 + [2] Const mutate b$4_@0 = Call mutate compute$3_@0(read props$1.b)
46 + [3] Const mutate $6_@1 = JSX <read Foo$5 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$5>
47 "]
48 - bb0_instrs --> bb0_terminal(["Return read $6"])
48 + bb0_instrs --> bb0_terminal(["Return read $6_@1"])
49 end
50
51 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md
+10 -10
@@ -115,17 +115,17 @@ function Foo$0() {
115
116 ```
117 bb0:
118 - [1] Const mutate a$2[1:3] = Call mutate compute$3(read props$1.a)
119 - [2] Const mutate b$4[2:3] = Call mutate compute$3(read props$1.b)
118 + [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
119 + [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b)
120 If (read props$1.c) then:bb2 else:bb1
121 bb2:
122 predecessor blocks: bb0
123 - [3] Call mutate foo$5(mutate a$2, mutate b$4)
123 + [3] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0)
124 Goto bb1
125 bb1:
126 predecessor blocks: bb2 bb0
127 - [4] Const mutate $7 = JSX <read Foo$6 a={freeze a$2} b={freeze b$4} ></read Foo$6>
128 - Return read $7
127 + [4] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
128 + Return read $7_@1
129 ```
130
131 ### CFG
@@ -135,22 +135,22 @@ flowchart TB
135 %% Basic Blocks
136 subgraph bb0
137 bb0_instrs["
138 - [1] Const mutate a$2[1:3] = Call mutate compute$3(read props$1.a)
139 - [2] Const mutate b$4[2:3] = Call mutate compute$3(read props$1.b)
138 + [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
139 + [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b)
140 "]
141 bb0_instrs --> bb0_terminal(["If (read props$1.c)"])
142 end
143 subgraph bb2
144 bb2_instrs["
145 - [3] Call mutate foo$5(mutate a$2, mutate b$4)
145 + [3] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0)
146 "]
147 bb2_instrs --> bb2_terminal(["Goto"])
148 end
149 subgraph bb1
150 bb1_instrs["
151 - [4] Const mutate $7 = JSX <read Foo$6 a={freeze a$2} b={freeze b$4} ></read Foo$6>
151 + [4] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
152 "]
153 - bb1_instrs --> bb1_terminal(["Return read $7"])
153 + bb1_instrs --> bb1_terminal(["Return read $7_@1"])
154 end
155
156 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md
+10 -10
@@ -28,11 +28,11 @@ function Foo() {}
28
29 ```
30 bb0:
31 - [1] Const mutate a$2[1:3] = Call mutate compute$3(read props$1.a)
32 - [2] Const mutate b$4[2:3] = Call mutate compute$3(read props$1.b)
33 - [3] Call mutate foo$5(mutate a$2, mutate b$4)
34 - [4] Const mutate $7 = JSX <read Foo$6 a={freeze a$2} b={freeze b$4} ></read Foo$6>
35 - Return read $7
31 + [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
32 + [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b)
33 + [3] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0)
34 + [4] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
35 + Return read $7_@1
36 ```
37
38 ### CFG
@@ -42,12 +42,12 @@ flowchart TB
42 %% Basic Blocks
43 subgraph bb0
44 bb0_instrs["
45 - [1] Const mutate a$2[1:3] = Call mutate compute$3(read props$1.a)
46 - [2] Const mutate b$4[2:3] = Call mutate compute$3(read props$1.b)
47 - [3] Call mutate foo$5(mutate a$2, mutate b$4)
48 - [4] Const mutate $7 = JSX <read Foo$6 a={freeze a$2} b={freeze b$4} ></read Foo$6>
45 + [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
46 + [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b)
47 + [3] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0)
48 + [4] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
49 "]
50 - bb0_instrs --> bb0_terminal(["Return read $7"])
50 + bb0_instrs --> bb0_terminal(["Return read $7_@1"])
51 end
52
53 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/jsx-fragment.expect.md
+24 -24
@@ -19,18 +19,18 @@ function Foo(props) {
19
20 ```
21 bb0:
22 - [1] Const mutate $2 = "\n Hello "
23 - [2] Const mutate $3 = " "
24 - [3] Const mutate $4 = "\n "
25 - [4] Const mutate $5 = "div"
26 - [5] Const mutate $6 = "\n "
27 - [6] Const mutate $7 = "Text"
28 - [7] Const mutate $8 = JsxFragment [read $7]
29 - [8] Const mutate $9 = "\n "
30 - [9] Const mutate $10 = JSX <read $5>{read $6}{read $8}{read $9}</read $5>
31 - [10] Const mutate $11 = "\n "
32 - [11] Const mutate $12 = JsxFragment [read $2, read props$1.greeting, read $3, read $4, read $10, read $11]
33 - Return read $12
22 + [1] Const mutate $2_@0 = "\n Hello "
23 + [2] Const mutate $3_@1 = " "
24 + [3] Const mutate $4_@2 = "\n "
25 + [4] Const mutate $5_@3 = "div"
26 + [5] Const mutate $6_@4 = "\n "
27 + [6] Const mutate $7_@5 = "Text"
28 + [7] Const mutate $8_@6 = JsxFragment [read $7_@5]
29 + [8] Const mutate $9_@7 = "\n "
30 + [9] Const mutate $10_@8 = JSX <read $5_@3>{read $6_@4}{read $8_@6}{read $9_@7}</read $5_@3>
31 + [10] Const mutate $11_@9 = "\n "
32 + [11] Const mutate $12_@10 = JsxFragment [read $2_@0, read props$1.greeting, read $3_@1, read $4_@2, read $10_@8, read $11_@9]
33 + Return read $12_@10
34 ```
35
36 ### CFG
@@ -40,19 +40,19 @@ flowchart TB
40 %% Basic Blocks
41 subgraph bb0
42 bb0_instrs["
43 - [1] Const mutate $2 = '\n Hello '
44 - [2] Const mutate $3 = ' '
45 - [3] Const mutate $4 = '\n '
46 - [4] Const mutate $5 = 'div'
47 - [5] Const mutate $6 = '\n '
48 - [6] Const mutate $7 = 'Text'
49 - [7] Const mutate $8 = JsxFragment [read $7]
50 - [8] Const mutate $9 = '\n '
51 - [9] Const mutate $10 = JSX <read $5>{read $6}{read $8}{read $9}</read $5>
52 - [10] Const mutate $11 = '\n '
53 - [11] Const mutate $12 = JsxFragment [read $2, read props$1.greeting, read $3, read $4, read $10, read $11]
43 + [1] Const mutate $2_@0 = '\n Hello '
44 + [2] Const mutate $3_@1 = ' '
45 + [3] Const mutate $4_@2 = '\n '
46 + [4] Const mutate $5_@3 = 'div'
47 + [5] Const mutate $6_@4 = '\n '
48 + [6] Const mutate $7_@5 = 'Text'
49 + [7] Const mutate $8_@6 = JsxFragment [read $7_@5]
50 + [8] Const mutate $9_@7 = '\n '
51 + [9] Const mutate $10_@8 = JSX <read $5_@3>{read $6_@4}{read $8_@6}{read $9_@7}</read $5_@3>
52 + [10] Const mutate $11_@9 = '\n '
53 + [11] Const mutate $12_@10 = JsxFragment [read $2_@0, read props$1.greeting, read $3_@1, read $4_@2, read $10_@8, read $11_@9]
54 "]
55 - bb0_instrs --> bb0_terminal(["Return read $12"])
55 + bb0_instrs --> bb0_terminal(["Return read $12_@10"])
56 end
57
58 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md
+28 -28
@@ -23,15 +23,15 @@ function g() {}
23
24 ```
25 bb0:
26 - [1] Const mutate $2 = Call mutate f$1()
27 - If (read $2) then:bb2 else:bb3
26 + [1] Const mutate $2_@0 = Call mutate f$1_@0()
27 + If (read $2_@0) then:bb2 else:bb3
28 bb2:
29 predecessor blocks: bb0
30 - [2] Const mutate $3 = Call mutate g$4()
30 + [2] Const mutate $3_@1 = Call mutate g$4_@1()
31 Goto bb1
32 bb3:
33 predecessor blocks: bb0
34 - [3] Const mutate $3 = read $2
34 + [3] Const mutate $3_@2 = read $2_@0
35 Goto bb1
36 bb1:
37 predecessor blocks: bb2 bb3
@@ -45,19 +45,19 @@ flowchart TB
45 %% Basic Blocks
46 subgraph bb0
47 bb0_instrs["
48 - [1] Const mutate $2 = Call mutate f$1()
48 + [1] Const mutate $2_@0 = Call mutate f$1_@0()
49 "]
50 - bb0_instrs --> bb0_terminal(["If (read $2)"])
50 + bb0_instrs --> bb0_terminal(["If (read $2_@0)"])
51 end
52 subgraph bb2
53 bb2_instrs["
54 - [2] Const mutate $3 = Call mutate g$4()
54 + [2] Const mutate $3_@1 = Call mutate g$4_@1()
55 "]
56 bb2_instrs --> bb2_terminal(["Goto"])
57 end
58 subgraph bb3
59 bb3_instrs["
60 - [3] Const mutate $3 = read $2
60 + [3] Const mutate $3_@2 = read $2_@0
61 "]
62 bb3_instrs --> bb3_terminal(["Goto"])
63 end
@@ -89,15 +89,15 @@ function And$0() {
89
90 ```
91 bb0:
92 - [1] Const mutate $2 = Call mutate f$1()
93 - If (read $2) then:bb2 else:bb3
92 + [1] Const mutate $2_@0 = Call mutate f$1_@0()
93 + If (read $2_@0) then:bb2 else:bb3
94 bb2:
95 predecessor blocks: bb0
96 - [2] Const mutate $3 = read $2
96 + [2] Const mutate $3_@1 = read $2_@0
97 Goto bb1
98 bb3:
99 predecessor blocks: bb0
100 - [3] Const mutate $3 = Call mutate g$4()
100 + [3] Const mutate $3_@2 = Call mutate g$4_@2()
101 Goto bb1
102 bb1:
103 predecessor blocks: bb2 bb3
@@ -111,19 +111,19 @@ flowchart TB
111 %% Basic Blocks
112 subgraph bb0
113 bb0_instrs["
114 - [1] Const mutate $2 = Call mutate f$1()
114 + [1] Const mutate $2_@0 = Call mutate f$1_@0()
115 "]
116 - bb0_instrs --> bb0_terminal(["If (read $2)"])
116 + bb0_instrs --> bb0_terminal(["If (read $2_@0)"])
117 end
118 subgraph bb2
119 bb2_instrs["
120 - [2] Const mutate $3 = read $2
120 + [2] Const mutate $3_@1 = read $2_@0
121 "]
122 bb2_instrs --> bb2_terminal(["Goto"])
123 end
124 subgraph bb3
125 bb3_instrs["
126 - [3] Const mutate $3 = Call mutate g$4()
126 + [3] Const mutate $3_@2 = Call mutate g$4_@2()
127 "]
128 bb3_instrs --> bb3_terminal(["Goto"])
129 end
@@ -155,17 +155,17 @@ function Or$0() {
155
156 ```
157 bb0:
158 - [1] Const mutate $3 = Call mutate f$2()
159 - [2] Const mutate $4 = null
160 - [3] Const mutate $5 = Binary read $3 != read $4
161 - If (read $5) then:bb2 else:bb3
158 + [1] Const mutate $3_@0 = Call mutate f$2_@0()
159 + [2] Const mutate $4_@1 = null
160 + [3] Const mutate $5_@2 = Binary read $3_@0 != read $4_@1
161 + If (read $5_@2) then:bb2 else:bb3
162 bb2:
163 predecessor blocks: bb0
164 - [4] Const mutate $6 = read $3
164 + [4] Const mutate $6_@3 = read $3_@0
165 Goto bb1
166 bb3:
167 predecessor blocks: bb0
168 - [5] Const mutate $6 = Call mutate g$7()
168 + [5] Const mutate $6_@4 = Call mutate g$7_@4()
169 Goto bb1
170 bb1:
171 predecessor blocks: bb2 bb3
@@ -179,21 +179,21 @@ flowchart TB
179 %% Basic Blocks
180 subgraph bb0
181 bb0_instrs["
182 - [1] Const mutate $3 = Call mutate f$2()
183 - [2] Const mutate $4 = null
184 - [3] Const mutate $5 = Binary read $3 != read $4
182 + [1] Const mutate $3_@0 = Call mutate f$2_@0()
183 + [2] Const mutate $4_@1 = null
184 + [3] Const mutate $5_@2 = Binary read $3_@0 != read $4_@1
185 "]
186 - bb0_instrs --> bb0_terminal(["If (read $5)"])
186 + bb0_instrs --> bb0_terminal(["If (read $5_@2)"])
187 end
188 subgraph bb2
189 bb2_instrs["
190 - [4] Const mutate $6 = read $3
190 + [4] Const mutate $6_@3 = read $3_@0
191 "]
192 bb2_instrs --> bb2_terminal(["Goto"])
193 end
194 subgraph bb3
195 bb3_instrs["
196 - [5] Const mutate $6 = Call mutate g$7()
196 + [5] Const mutate $6_@4 = Call mutate g$7_@4()
197 "]
198 bb3_instrs --> bb3_terminal(["Goto"])
199 end
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md
+34 -34
@@ -99,25 +99,25 @@ function cond$0(x$1) {
99
100 ```
101 bb0:
102 - [1] Let mutate a$2 = Object { }
103 - [2] Let mutate b$3 = Object { }
104 - [3] Let mutate c$4 = Object { }
105 - [4] Let mutate d$5 = Object { }
102 + [1] Let mutate a$2_@0 = Object { }
103 + [2] Let mutate b$3_@1 = Object { }
104 + [3] Let mutate c$4_@2 = Object { }
105 + [4] Let mutate d$5_@3 = Object { }
106 While test=bb1 loop=bb3 fallthrough=bb2
107 bb1:
108 predecessor blocks: bb0 bb4
109 - [5] Const mutate $10 = true
110 - If (read $10) then:bb3 else:bb2
109 + [5] Const mutate $10_@4 = true
110 + If (read $10_@4) then:bb3 else:bb2
111 bb3:
112 predecessor blocks: bb1
113 - [6] Let mutate z$6 = read a$2
114 - [7] Reassign mutate a$2[7:12] = read b$3
115 - [8] Reassign mutate b$3[8:11] = read c$4
116 - [9] Reassign mutate c$4 = read d$5
117 - [10] Reassign mutate d$5 = read z$6
118 - [11] Call mutate mutate$7(mutate a$2, mutate b$3)
119 - [12] Const mutate $9 = Call mutate cond$8(mutate a$2)
120 - If (read $9) then:bb2 else:bb4
113 + [6] Let mutate z$6_@5 = read a$2
114 + [7] Reassign mutate a$2_@6[7:12] = read b$3
115 + [8] Reassign mutate b$3_@6[8:11] = read c$4
116 + [9] Reassign mutate c$4_@7 = read d$5
117 + [10] Reassign mutate d$5_@8 = read z$6_@5
118 + [11] Call mutate mutate$7_@6(mutate a$2_@6, mutate b$3_@6)
119 + [12] Const mutate $9_@6 = Call mutate cond$8_@6(mutate a$2_@6)
120 + If (read $9_@6) then:bb2 else:bb4
121 bb4:
122 predecessor blocks: bb3
123 Goto(Continue) bb1
@@ -132,11 +132,11 @@ bb9:
132 If (read c$4) then:bb11 else:bb11
133 bb11:
134 predecessor blocks: bb9
135 - If (read d$5) then:bb13 else:bb13
135 + If (read d$5_@6) then:bb13 else:bb13
136 bb13:
137 predecessor blocks: bb11
138 - [13] Const mutate $11 = null
139 - [14] Call mutate mutate$7(mutate d$5, read $11)
138 + [13] Const mutate $11_@9 = null
139 + [14] Call mutate mutate$7_@6(mutate d$5_@6, read $11_@9)
140 Return
141 ```
142
@@ -147,30 +147,30 @@ flowchart TB
147 %% Basic Blocks
148 subgraph bb0
149 bb0_instrs["
150 - [1] Let mutate a$2 = Object { }
151 - [2] Let mutate b$3 = Object { }
152 - [3] Let mutate c$4 = Object { }
153 - [4] Let mutate d$5 = Object { }
150 + [1] Let mutate a$2_@0 = Object { }
151 + [2] Let mutate b$3_@1 = Object { }
152 + [3] Let mutate c$4_@2 = Object { }
153 + [4] Let mutate d$5_@3 = Object { }
154 "]
155 bb0_instrs --> bb0_terminal(["While"])
156 end
157 subgraph bb1
158 bb1_instrs["
159 - [5] Const mutate $10 = true
159 + [5] Const mutate $10_@4 = true
160 "]
161 - bb1_instrs --> bb1_terminal(["If (read $10)"])
161 + bb1_instrs --> bb1_terminal(["If (read $10_@4)"])
162 end
163 subgraph bb3
164 bb3_instrs["
165 - [6] Let mutate z$6 = read a$2
166 - [7] Reassign mutate a$2[7:12] = read b$3
167 - [8] Reassign mutate b$3[8:11] = read c$4
168 - [9] Reassign mutate c$4 = read d$5
169 - [10] Reassign mutate d$5 = read z$6
170 - [11] Call mutate mutate$7(mutate a$2, mutate b$3)
171 - [12] Const mutate $9 = Call mutate cond$8(mutate a$2)
165 + [6] Let mutate z$6_@5 = read a$2
166 + [7] Reassign mutate a$2_@6[7:12] = read b$3
167 + [8] Reassign mutate b$3_@6[8:11] = read c$4
168 + [9] Reassign mutate c$4_@7 = read d$5
169 + [10] Reassign mutate d$5_@8 = read z$6_@5
170 + [11] Call mutate mutate$7_@6(mutate a$2_@6, mutate b$3_@6)
171 + [12] Const mutate $9_@6 = Call mutate cond$8_@6(mutate a$2_@6)
172 "]
173 - bb3_instrs --> bb3_terminal(["If (read $9)"])
173 + bb3_instrs --> bb3_terminal(["If (read $9_@6)"])
174 end
175 subgraph bb4
176 bb4_terminal(["Goto"])
@@ -185,12 +185,12 @@ flowchart TB
185 bb9_terminal(["If (read c$4)"])
186 end
187 subgraph bb11
188 - bb11_terminal(["If (read d$5)"])
188 + bb11_terminal(["If (read d$5_@6)"])
189 end
190 subgraph bb13
191 bb13_instrs["
192 - [13] Const mutate $11 = null
193 - [14] Call mutate mutate$7(mutate d$5, read $11)
192 + [13] Const mutate $11_@9 = null
193 + [14] Call mutate mutate$7_@6(mutate d$5_@6, read $11_@9)
194 "]
195 bb13_instrs --> bb13_terminal(["Return"])
196 end
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md
+28 -28
@@ -67,30 +67,30 @@ function mutate$0(x$1, y$2) {
67
68 ```
69 bb0:
70 - [1] Const mutate a$2 = Object { }
71 - [2] Const mutate b$3 = Array [read a$2]
72 - [3] Const mutate c$4 = Object { }
73 - [4] Const mutate d$5[4:7] = Object { c: read c$4 }
74 - [5] Const mutate x$6[5:9] = Object { }
75 - [6] Reassign mutate x$6.b[5:9] = read b$3
76 - [7] Const mutate y$7 = Call mutate mutate$8(mutate x$6, mutate d$5)
77 - If (read a$2) then:bb1 else:bb1
70 + [1] Const mutate a$2_@0 = Object { }
71 + [2] Const mutate b$3_@1 = Array [read a$2_@0]
72 + [3] Const mutate c$4_@2 = Object { }
73 + [4] Const mutate d$5_@3[4:7] = Object { c: read c$4_@2 }
74 + [5] Const mutate x$6_@3[5:9] = Object { }
75 + [6] Reassign mutate x$6_@3.b[5:9] = read b$3_@1
76 + [7] Const mutate y$7_@3 = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3)
77 + If (read a$2_@0) then:bb1 else:bb1
78 bb1:
79 predecessor blocks: bb0
80 - If (read b$3) then:bb3 else:bb3
80 + If (read b$3_@1) then:bb3 else:bb3
81 bb3:
82 predecessor blocks: bb1
83 - If (read c$4) then:bb5 else:bb5
83 + If (read c$4_@2) then:bb5 else:bb5
84 bb5:
85 predecessor blocks: bb3
86 - If (read d$5) then:bb7 else:bb7
86 + If (read d$5_@3) then:bb7 else:bb7
87 bb7:
88 predecessor blocks: bb5
89 - If (read y$7) then:bb9 else:bb9
89 + If (read y$7_@3) then:bb9 else:bb9
90 bb9:
91 predecessor blocks: bb7
92 - [8] Const mutate $9 = null
93 - [9] Call mutate mutate$8(mutate x$6, read $9)
92 + [8] Const mutate $9_@4 = null
93 + [9] Call mutate mutate$8_@3(mutate x$6_@3, read $9_@4)
94 Return
95 ```
96
@@ -101,32 +101,32 @@ flowchart TB
101 %% Basic Blocks
102 subgraph bb0
103 bb0_instrs["
104 - [1] Const mutate a$2 = Object { }
105 - [2] Const mutate b$3 = Array [read a$2]
106 - [3] Const mutate c$4 = Object { }
107 - [4] Const mutate d$5[4:7] = Object { c: read c$4 }
108 - [5] Const mutate x$6[5:9] = Object { }
109 - [6] Reassign mutate x$6.b[5:9] = read b$3
110 - [7] Const mutate y$7 = Call mutate mutate$8(mutate x$6, mutate d$5)
104 + [1] Const mutate a$2_@0 = Object { }
105 + [2] Const mutate b$3_@1 = Array [read a$2_@0]
106 + [3] Const mutate c$4_@2 = Object { }
107 + [4] Const mutate d$5_@3[4:7] = Object { c: read c$4_@2 }
108 + [5] Const mutate x$6_@3[5:9] = Object { }
109 + [6] Reassign mutate x$6_@3.b[5:9] = read b$3_@1
110 + [7] Const mutate y$7_@3 = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3)
111 "]
112 - bb0_instrs --> bb0_terminal(["If (read a$2)"])
112 + bb0_instrs --> bb0_terminal(["If (read a$2_@0)"])
113 end
114 subgraph bb1
115 - bb1_terminal(["If (read b$3)"])
115 + bb1_terminal(["If (read b$3_@1)"])
116 end
117 subgraph bb3
118 - bb3_terminal(["If (read c$4)"])
118 + bb3_terminal(["If (read c$4_@2)"])
119 end
120 subgraph bb5
121 - bb5_terminal(["If (read d$5)"])
121 + bb5_terminal(["If (read d$5_@3)"])
122 end
123 subgraph bb7
124 - bb7_terminal(["If (read y$7)"])
124 + bb7_terminal(["If (read y$7_@3)"])
125 end
126 subgraph bb9
127 bb9_instrs["
128 - [8] Const mutate $9 = null
129 - [9] Call mutate mutate$8(mutate x$6, read $9)
128 + [8] Const mutate $9_@4 = null
129 + [9] Call mutate mutate$8_@3(mutate x$6_@3, read $9_@4)
130 "]
131 bb9_instrs --> bb9_terminal(["Return"])
132 end
compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md
+30 -30
@@ -94,39 +94,39 @@ function cond$0() {
94
95 ```
96 bb0:
97 - [1] Let mutate a$2[1:7] = Object { }
98 - [2] Let mutate b$3[2:6] = Object { }
99 - [3] Let mutate c$4 = Object { }
100 - [4] Let mutate d$5[4:9] = Object { }
97 + [1] Let mutate a$2_@0[1:7] = Object { }
98 + [2] Let mutate b$3_@0[2:6] = Object { }
99 + [3] Let mutate c$4_@1 = Object { }
100 + [4] Let mutate d$5_@0[4:9] = Object { }
101 While test=bb1 loop=bb3 fallthrough=bb2
102 bb1:
103 predecessor blocks: bb0 bb4
104 - [5] Const mutate $9 = true
105 - If (read $9) then:bb3 else:bb2
104 + [5] Const mutate $9_@2 = true
105 + If (read $9_@2) then:bb3 else:bb2
106 bb3:
107 predecessor blocks: bb1
108 - [6] Call mutate mutate$6(mutate a$2, mutate b$3)
109 - [7] Const mutate $8 = Call mutate cond$7(mutate a$2)
110 - If (read $8) then:bb2 else:bb4
108 + [6] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0)
109 + [7] Const mutate $8_@0 = Call mutate cond$7_@0(mutate a$2_@0)
110 + If (read $8_@0) then:bb2 else:bb4
111 bb4:
112 predecessor blocks: bb3
113 Goto(Continue) bb1
114 bb2:
115 predecessor blocks: bb3 bb1
116 - If (read a$2) then:bb7 else:bb7
116 + If (read a$2_@0) then:bb7 else:bb7
117 bb7:
118 predecessor blocks: bb2
119 - If (read b$3) then:bb9 else:bb9
119 + If (read b$3_@0) then:bb9 else:bb9
120 bb9:
121 predecessor blocks: bb7
122 - If (read c$4) then:bb11 else:bb11
122 + If (read c$4_@1) then:bb11 else:bb11
123 bb11:
124 predecessor blocks: bb9
125 - If (read d$5) then:bb13 else:bb13
125 + If (read d$5_@0) then:bb13 else:bb13
126 bb13:
127 predecessor blocks: bb11
128 - [8] Const mutate $10 = null
129 - [9] Call mutate mutate$6(mutate d$5, read $10)
128 + [8] Const mutate $10_@3 = null
129 + [9] Call mutate mutate$6_@0(mutate d$5_@0, read $10_@3)
130 Return
131 ```
132
@@ -137,45 +137,45 @@ flowchart TB
137 %% Basic Blocks
138 subgraph bb0
139 bb0_instrs["
140 - [1] Let mutate a$2[1:7] = Object { }
141 - [2] Let mutate b$3[2:6] = Object { }
142 - [3] Let mutate c$4 = Object { }
143 - [4] Let mutate d$5[4:9] = Object { }
140 + [1] Let mutate a$2_@0[1:7] = Object { }
141 + [2] Let mutate b$3_@0[2:6] = Object { }
142 + [3] Let mutate c$4_@1 = Object { }
143 + [4] Let mutate d$5_@0[4:9] = Object { }
144 "]
145 bb0_instrs --> bb0_terminal(["While"])
146 end
147 subgraph bb1
148 bb1_instrs["
149 - [5] Const mutate $9 = true
149 + [5] Const mutate $9_@2 = true
150 "]
151 - bb1_instrs --> bb1_terminal(["If (read $9)"])
151 + bb1_instrs --> bb1_terminal(["If (read $9_@2)"])
152 end
153 subgraph bb3
154 bb3_instrs["
155 - [6] Call mutate mutate$6(mutate a$2, mutate b$3)
156 - [7] Const mutate $8 = Call mutate cond$7(mutate a$2)
155 + [6] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0)
156 + [7] Const mutate $8_@0 = Call mutate cond$7_@0(mutate a$2_@0)
157 "]
158 - bb3_instrs --> bb3_terminal(["If (read $8)"])
158 + bb3_instrs --> bb3_terminal(["If (read $8_@0)"])
159 end
160 subgraph bb4
161 bb4_terminal(["Goto"])
162 end
163 subgraph bb2
164 - bb2_terminal(["If (read a$2)"])
164 + bb2_terminal(["If (read a$2_@0)"])
165 end
166 subgraph bb7
167 - bb7_terminal(["If (read b$3)"])
167 + bb7_terminal(["If (read b$3_@0)"])
168 end
169 subgraph bb9
170 - bb9_terminal(["If (read c$4)"])
170 + bb9_terminal(["If (read c$4_@1)"])
171 end
172 subgraph bb11
173 - bb11_terminal(["If (read d$5)"])
173 + bb11_terminal(["If (read d$5_@0)"])
174 end
175 subgraph bb13
176 bb13_instrs["
177 - [8] Const mutate $10 = null
178 - [9] Call mutate mutate$6(mutate d$5, read $10)
177 + [8] Const mutate $10_@3 = null
178 + [9] Call mutate mutate$6_@0(mutate d$5_@0, read $10_@3)
179 "]
180 bb13_instrs --> bb13_terminal(["Return"])
181 end
compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md
+14 -14
@@ -17,13 +17,13 @@ function Component(props) {
17
18 ```
19 bb0:
20 - [1] Const mutate x$2[1:5] = Object { }
21 - [2] Const mutate y$3 = Array []
22 - [3] Reassign mutate x$2.y[1:5] = read y$3
23 - [4] Const mutate child$4 = JSX <read Component$0 data={freeze y$3} ></read Component$0>
24 - [5] Call mutate x$2.y.push(read props$1.p0)
25 - [6] Const mutate $5 = JSX <read Component$0 data={freeze x$2} >{read child$4}</read Component$0>
26 - Return read $5
20 + [1] Const mutate x$2_@0[1:5] = Object { }
21 + [2] Const mutate y$3_@1 = Array []
22 + [3] Reassign mutate x$2_@0.y[1:5] = read y$3_@1
23 + [4] Const mutate child$4_@2 = JSX <read Component$0 data={freeze y$3_@1} ></read Component$0>
24 + [5] Call mutate x$2_@0.y.push(read props$1.p0)
25 + [6] Const mutate $5_@3 = JSX <read Component$0 data={freeze x$2_@0} >{read child$4_@2}</read Component$0>
26 + Return read $5_@3
27 ```
28
29 ### CFG
@@ -33,14 +33,14 @@ flowchart TB
33 %% Basic Blocks
34 subgraph bb0
35 bb0_instrs["
36 - [1] Const mutate x$2[1:5] = Object { }
37 - [2] Const mutate y$3 = Array []
38 - [3] Reassign mutate x$2.y[1:5] = read y$3
39 - [4] Const mutate child$4 = JSX <read Component$0 data={freeze y$3} ></read Component$0>
40 - [5] Call mutate x$2.y.push(read props$1.p0)
41 - [6] Const mutate $5 = JSX <read Component$0 data={freeze x$2} >{read child$4}</read Component$0>
36 + [1] Const mutate x$2_@0[1:5] = Object { }
37 + [2] Const mutate y$3_@1 = Array []
38 + [3] Reassign mutate x$2_@0.y[1:5] = read y$3_@1
39 + [4] Const mutate child$4_@2 = JSX <read Component$0 data={freeze y$3_@1} ></read Component$0>
40 + [5] Call mutate x$2_@0.y.push(read props$1.p0)
41 + [6] Const mutate $5_@3 = JSX <read Component$0 data={freeze x$2_@0} >{read child$4_@2}</read Component$0>
42 "]
43 - bb0_instrs --> bb0_terminal(["Return read $5"])
43 + bb0_instrs --> bb0_terminal(["Return read $5_@3"])
44 end
45
46 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/reactive-scope-grouping.expect.md new
+62
@@ -0,0 +1,62 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function foo() {
6 + let x = {};
7 + let y = [];
8 + let z = {};
9 + y.push(z);
10 + x.y = y;
11 +
12 + return x;
13 +}
14 +
15 +```
16 +
17 +## HIR
18 +
19 +```
20 +bb0:
21 + [1] Let mutate x$1_@0[1:5] = Object { }
22 + [2] Let mutate y$2_@1[2:4] = Array []
23 + [3] Let mutate z$3_@1[3:4] = Object { }
24 + [4] Call mutate y$2_@1.push(mutate z$3_@1)
25 + [5] Reassign mutate x$1_@0.y[1:5] = read y$2_@1
26 + Return freeze x$1_@0
27 +```
28 +
29 +### CFG
30 +
31 +```mermaid
32 +flowchart TB
33 + %% Basic Blocks
34 + subgraph bb0
35 + bb0_instrs["
36 + [1] Let mutate x$1_@0[1:5] = Object { }
37 + [2] Let mutate y$2_@1[2:4] = Array []
38 + [3] Let mutate z$3_@1[3:4] = Object { }
39 + [4] Call mutate y$2_@1.push(mutate z$3_@1)
40 + [5] Reassign mutate x$1_@0.y[1:5] = read y$2_@1
41 + "]
42 + bb0_instrs --> bb0_terminal(["Return freeze x$1_@0"])
43 + end
44 +
45 + %% Jumps
46 + %% empty
47 +```
48 +
49 +## Code
50 +
51 +```javascript
52 +function foo$0() {
53 + let x$1 = {};
54 + let y$2 = [];
55 + let z$3 = {};
56 + y$2.push(z$3);
57 + x$1.y = y$2;
58 + return x$1;
59 +}
60 +
61 +```
62 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/reactive-scope-grouping.js new
+9
@@ -0,0 +1,9 @@
1 +function foo() {
2 + let x = {};
3 + let y = [];
4 + let z = {};
5 + y.push(z);
6 + x.y = y;
7 +
8 + return x;
9 +}
compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md new
+94
@@ -0,0 +1,94 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function f(a, b) {
6 + let x = []; // <- x starts being mutable here.
7 + if (a.length === 1) {
8 + if (b) {
9 + x.push(b); // <- x stops being mutable here.
10 + }
11 + }
12 +
13 + return <div>{x}</div>;
14 +}
15 +
16 +```
17 +
18 +## HIR
19 +
20 +```
21 +bb0:
22 + [1] Let mutate x$3_@0[1:4] = Array []
23 + [2] Const mutate $4_@1 = 1
24 + [3] Const mutate $5_@2 = Binary read a$1.length === read $4_@1
25 + If (read $5_@2) then:bb2 else:bb1
26 +bb2:
27 + predecessor blocks: bb0
28 + If (read b$2) then:bb4 else:bb1
29 +bb4:
30 + predecessor blocks: bb2
31 + [4] Call mutate x$3_@0.push(read b$2)
32 + Goto bb1
33 +bb1:
34 + predecessor blocks: bb4 bb2 bb0
35 + [5] Const mutate $6_@3 = "div"
36 + [6] Const mutate $7_@4 = JSX <read $6_@3>{freeze x$3_@0}</read $6_@3>
37 + Return read $7_@4
38 +```
39 +
40 +### CFG
41 +
42 +```mermaid
43 +flowchart TB
44 + %% Basic Blocks
45 + subgraph bb0
46 + bb0_instrs["
47 + [1] Let mutate x$3_@0[1:4] = Array []
48 + [2] Const mutate $4_@1 = 1
49 + [3] Const mutate $5_@2 = Binary read a$1.length === read $4_@1
50 + "]
51 + bb0_instrs --> bb0_terminal(["If (read $5_@2)"])
52 + end
53 + subgraph bb2
54 + bb2_terminal(["If (read b$2)"])
55 + end
56 + subgraph bb4
57 + bb4_instrs["
58 + [4] Call mutate x$3_@0.push(read b$2)
59 + "]
60 + bb4_instrs --> bb4_terminal(["Goto"])
61 + end
62 + subgraph bb1
63 + bb1_instrs["
64 + [5] Const mutate $6_@3 = 'div'
65 + [6] Const mutate $7_@4 = JSX <read $6_@3>{freeze x$3_@0}</read $6_@3>
66 + "]
67 + bb1_instrs --> bb1_terminal(["Return read $7_@4"])
68 + end
69 +
70 + %% Jumps
71 + bb0_terminal -- then --> bb2
72 + bb0_terminal -- else --> bb1
73 + bb2_terminal -- then --> bb4
74 + bb2_terminal -- else --> bb1
75 + bb4_terminal --> bb1
76 +
77 +```
78 +
79 +## Code
80 +
81 +```javascript
82 +function f$0(a$1, b$2) {
83 + let x$3 = [];
84 + bb1: if (a$1.length === 1) {
85 + if (b$2) {
86 + x$3.push(b$2);
87 + }
88 + }
89 +
90 + return <div>{x$3}</div>;
91 +}
92 +
93 +```
94 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.js new
+10
@@ -0,0 +1,10 @@
1 +function f(a, b) {
2 + let x = []; // <- x starts being mutable here.
3 + if (a.length === 1) {
4 + if (b) {
5 + x.push(b); // <- x stops being mutable here.
6 + }
7 + }
8 +
9 + return <div>{x}</div>;
10 +}
compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md
+16 -16
@@ -23,20 +23,20 @@ function Component(props) {
23
24 ```
25 bb0:
26 - [1] Let mutate x$2[1:2] = Array []
27 - [2] Call mutate x$2.push(read props$1.p0)
28 - [3] Let mutate y$3 = read x$2
26 + [1] Let mutate x$2_@0[1:2] = Array []
27 + [2] Call mutate x$2_@0.push(read props$1.p0)
28 + [3] Let mutate y$3_@1 = read x$2_@0
29 If (read props$1.p1) then:bb2 else:bb1
30 bb2:
31 predecessor blocks: bb0
32 - [4] Reassign mutate x$2 = Array []
32 + [4] Reassign mutate x$2_@2 = Array []
33 Goto bb1
34 bb1:
35 predecessor blocks: bb2 bb0
36 - [5] Let mutate _$4 = JSX <read Component$0 x={freeze x$2} ></read Component$0>
37 - [6] Call read y$3.push(read props$1.p2)
38 - [7] Const mutate $5 = JSX <read Component$0 x={read x$2} y={read y$3} ></read Component$0>
39 - Return read $5
36 + [5] Let mutate _$4_@3 = JSX <read Component$0 x={freeze x$2} ></read Component$0>
37 + [6] Call read y$3_@1.push(read props$1.p2)
38 + [7] Const mutate $5_@4 = JSX <read Component$0 x={read x$2} y={read y$3_@1} ></read Component$0>
39 + Return read $5_@4
40 ```
41
42 ### CFG
@@ -46,25 +46,25 @@ flowchart TB
46 %% Basic Blocks
47 subgraph bb0
48 bb0_instrs["
49 - [1] Let mutate x$2[1:2] = Array []
50 - [2] Call mutate x$2.push(read props$1.p0)
51 - [3] Let mutate y$3 = read x$2
49 + [1] Let mutate x$2_@0[1:2] = Array []
50 + [2] Call mutate x$2_@0.push(read props$1.p0)
51 + [3] Let mutate y$3_@1 = read x$2_@0
52 "]
53 bb0_instrs --> bb0_terminal(["If (read props$1.p1)"])
54 end
55 subgraph bb2
56 bb2_instrs["
57 - [4] Reassign mutate x$2 = Array []
57 + [4] Reassign mutate x$2_@2 = Array []
58 "]
59 bb2_instrs --> bb2_terminal(["Goto"])
60 end
61 subgraph bb1
62 bb1_instrs["
63 - [5] Let mutate _$4 = JSX <read Component$0 x={freeze x$2} ></read Component$0>
64 - [6] Call read y$3.push(read props$1.p2)
65 - [7] Const mutate $5 = JSX <read Component$0 x={read x$2} y={read y$3} ></read Component$0>
63 + [5] Let mutate _$4_@3 = JSX <read Component$0 x={freeze x$2} ></read Component$0>
64 + [6] Call read y$3_@1.push(read props$1.p2)
65 + [7] Const mutate $5_@4 = JSX <read Component$0 x={read x$2} y={read y$3_@1} ></read Component$0>
66 "]
67 - bb1_instrs --> bb1_terminal(["Return read $5"])
67 + bb1_instrs --> bb1_terminal(["Return read $5_@4"])
68 end
69
70 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md
+16 -16
@@ -21,14 +21,14 @@ function Component(props) {
21
22 ```
23 bb0:
24 - [1] Let mutate x$2[1:2] = Array []
25 - [2] Call mutate x$2.push(read props$1.p0)
26 - [3] Let mutate y$3[3:6] = read x$2
27 - [4] Reassign mutate x$2 = Array []
28 - [5] Let mutate _$4 = JSX <read Component$0 x={freeze x$2} ></read Component$0>
29 - [6] Call mutate y$3.push(read props$1.p1)
30 - [7] Const mutate $5 = JSX <read Component$0 x={read x$2} y={freeze y$3} ></read Component$0>
31 - Return read $5
24 + [1] Let mutate x$2_@0[1:2] = Array []
25 + [2] Call mutate x$2_@0.push(read props$1.p0)
26 + [3] Let mutate y$3_@1[3:6] = read x$2_@0
27 + [4] Reassign mutate x$2_@2 = Array []
28 + [5] Let mutate _$4_@3 = JSX <read Component$0 x={freeze x$2_@2} ></read Component$0>
29 + [6] Call mutate y$3_@1.push(read props$1.p1)
30 + [7] Const mutate $5_@4 = JSX <read Component$0 x={read x$2_@2} y={freeze y$3_@1} ></read Component$0>
31 + Return read $5_@4
32 ```
33
34 ### CFG
@@ -38,15 +38,15 @@ flowchart TB
38 %% Basic Blocks
39 subgraph bb0
40 bb0_instrs["
41 - [1] Let mutate x$2[1:2] = Array []
42 - [2] Call mutate x$2.push(read props$1.p0)
43 - [3] Let mutate y$3[3:6] = read x$2
44 - [4] Reassign mutate x$2 = Array []
45 - [5] Let mutate _$4 = JSX <read Component$0 x={freeze x$2} ></read Component$0>
46 - [6] Call mutate y$3.push(read props$1.p1)
47 - [7] Const mutate $5 = JSX <read Component$0 x={read x$2} y={freeze y$3} ></read Component$0>
41 + [1] Let mutate x$2_@0[1:2] = Array []
42 + [2] Call mutate x$2_@0.push(read props$1.p0)
43 + [3] Let mutate y$3_@1[3:6] = read x$2_@0
44 + [4] Reassign mutate x$2_@2 = Array []
45 + [5] Let mutate _$4_@3 = JSX <read Component$0 x={freeze x$2_@2} ></read Component$0>
46 + [6] Call mutate y$3_@1.push(read props$1.p1)
47 + [7] Const mutate $5_@4 = JSX <read Component$0 x={read x$2_@2} y={freeze y$3_@1} ></read Component$0>
48 "]
49 - bb0_instrs --> bb0_terminal(["Return read $5"])
49 + bb0_instrs --> bb0_terminal(["Return read $5_@4"])
50 end
51
52 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md
+24 -24
@@ -36,40 +36,40 @@ function Component(props) {
36
37 ```
38 bb0:
39 - [1] Let mutate x$2 = undefined
39 + [1] Let mutate x$2_@0 = undefined
40 If (read props$1.cond) then:bb2 else:bb10
41 bb2:
42 predecessor blocks: bb0
43 - [2] Const mutate $3 = 2
44 - [3] Const mutate $4 = 1
45 - [4] Const mutate $5 = 0
43 + [2] Const mutate $3_@1 = 2
44 + [3] Const mutate $4_@2 = 1
45 + [4] Const mutate $5_@3 = 0
46 Switch (read props$1.test)
47 - Case read $5: bb8
48 - Case read $4: bb6
49 - Case read $3: bb4
47 + Case read $5_@3: bb8
48 + Case read $4_@2: bb6
49 + Case read $3_@1: bb4
50 Default: bb4
51 bb8:
52 predecessor blocks: bb2
53 - [5] Reassign mutate x$2 = read props$1.v0
53 + [5] Reassign mutate x$2_@4 = read props$1.v0
54 Goto bb1
55 bb6:
56 predecessor blocks: bb2
57 - [6] Reassign mutate x$2 = read props$1.v1
57 + [6] Reassign mutate x$2_@5 = read props$1.v1
58 Goto bb1
59 bb4:
60 predecessor blocks: bb2
61 - [7] Reassign mutate x$2 = read props$1.v2
61 + [7] Reassign mutate x$2_@6 = read props$1.v2
62 Goto bb1
63 bb10:
64 predecessor blocks: bb0
65 If (read props$1.cond2) then:bb12 else:bb13
66 bb12:
67 predecessor blocks: bb10
68 - [8] Reassign mutate x$2 = read props$1.b
68 + [8] Reassign mutate x$2_@7 = read props$1.b
69 Goto bb1
70 bb13:
71 predecessor blocks: bb10
72 - [9] Reassign mutate x$2 = read props$1.c
72 + [9] Reassign mutate x$2_@8 = read props$1.c
73 Goto bb1
74 bb1:
75 predecessor blocks: bb8 bb6 bb4 bb12 bb13
@@ -84,33 +84,33 @@ flowchart TB
84 %% Basic Blocks
85 subgraph bb0
86 bb0_instrs["
87 - [1] Let mutate x$2 = undefined
87 + [1] Let mutate x$2_@0 = undefined
88 "]
89 bb0_instrs --> bb0_terminal(["If (read props$1.cond)"])
90 end
91 subgraph bb2
92 bb2_instrs["
93 - [2] Const mutate $3 = 2
94 - [3] Const mutate $4 = 1
95 - [4] Const mutate $5 = 0
93 + [2] Const mutate $3_@1 = 2
94 + [3] Const mutate $4_@2 = 1
95 + [4] Const mutate $5_@3 = 0
96 "]
97 bb2_instrs --> bb2_terminal(["Switch (read props$1.test)"])
98 end
99 subgraph bb8
100 bb8_instrs["
101 - [5] Reassign mutate x$2 = read props$1.v0
101 + [5] Reassign mutate x$2_@4 = read props$1.v0
102 "]
103 bb8_instrs --> bb8_terminal(["Goto"])
104 end
105 subgraph bb6
106 bb6_instrs["
107 - [6] Reassign mutate x$2 = read props$1.v1
107 + [6] Reassign mutate x$2_@5 = read props$1.v1
108 "]
109 bb6_instrs --> bb6_terminal(["Goto"])
110 end
111 subgraph bb4
112 bb4_instrs["
113 - [7] Reassign mutate x$2 = read props$1.v2
113 + [7] Reassign mutate x$2_@6 = read props$1.v2
114 "]
115 bb4_instrs --> bb4_terminal(["Goto"])
116 end
@@ -119,13 +119,13 @@ flowchart TB
119 end
120 subgraph bb12
121 bb12_instrs["
122 - [8] Reassign mutate x$2 = read props$1.b
122 + [8] Reassign mutate x$2_@7 = read props$1.b
123 "]
124 bb12_instrs --> bb12_terminal(["Goto"])
125 end
126 subgraph bb13
127 bb13_instrs["
128 - [9] Reassign mutate x$2 = read props$1.c
128 + [9] Reassign mutate x$2_@8 = read props$1.c
129 "]
130 bb13_instrs --> bb13_terminal(["Goto"])
131 end
@@ -140,9 +140,9 @@ flowchart TB
140 bb0_terminal -- then --> bb2
141 bb0_terminal -- else --> bb10
142 bb0_terminal -- fallthrough --> bb1
143 - bb2_terminal -- read $5 --> bb8
144 - bb2_terminal -- read $4 --> bb6
145 - bb2_terminal -- read $3 --> bb4
143 + bb2_terminal -- read $5_@3 --> bb8
144 + bb2_terminal -- read $4_@2 --> bb6
145 + bb2_terminal -- read $3_@1 --> bb4
146 bb2_terminal -- default --> bb4
147 bb2_terminal -- fallthrough --> bb1
148 bb8_terminal --> bb1
compiler/forget/src/__tests__/fixtures/hir/simple.expect.md
+14 -14
@@ -18,15 +18,15 @@ bb0:
18 If (read x$1) then:bb2 else:bb1
19 bb2:
20 predecessor blocks: bb0
21 - [1] Const mutate $3 = false
22 - [2] Const mutate $4 = Call read foo$0(read $3, read y$2)
23 - Return freeze $4
21 + [1] Const mutate $3_@0 = false
22 + [2] Const mutate $4_@1 = Call read foo$0(read $3_@0, read y$2)
23 + Return freeze $4_@1
24 bb1:
25 predecessor blocks: bb0
26 - [3] Const mutate $5 = 10
27 - [4] Const mutate $6 = Binary read y$2 * read $5
28 - [5] Const mutate $7 = Array [read $6]
29 - Return freeze $7
26 + [3] Const mutate $5_@2 = 10
27 + [4] Const mutate $6_@3 = Binary read y$2 * read $5_@2
28 + [5] Const mutate $7_@4 = Array [read $6_@3]
29 + Return freeze $7_@4
30 ```
31
32 ### CFG
@@ -39,18 +39,18 @@ flowchart TB
39 end
40 subgraph bb2
41 bb2_instrs["
42 - [1] Const mutate $3 = false
43 - [2] Const mutate $4 = Call read foo$0(read $3, read y$2)
42 + [1] Const mutate $3_@0 = false
43 + [2] Const mutate $4_@1 = Call read foo$0(read $3_@0, read y$2)
44 "]
45 - bb2_instrs --> bb2_terminal(["Return freeze $4"])
45 + bb2_instrs --> bb2_terminal(["Return freeze $4_@1"])
46 end
47 subgraph bb1
48 bb1_instrs["
49 - [3] Const mutate $5 = 10
50 - [4] Const mutate $6 = Binary read y$2 * read $5
51 - [5] Const mutate $7 = Array [read $6]
49 + [3] Const mutate $5_@2 = 10
50 + [4] Const mutate $6_@3 = Binary read y$2 * read $5_@2
51 + [5] Const mutate $7_@4 = Array [read $6_@3]
52 "]
53 - bb1_instrs --> bb1_terminal(["Return freeze $7"])
53 + bb1_instrs --> bb1_terminal(["Return freeze $7_@4"])
54 end
55
56 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md
+8 -8
@@ -15,10 +15,10 @@ function Component(props) {
15
16 ```
17 bb0:
18 - [1] Const mutate a$2 = 1
19 - [2] Const mutate b$3 = 2
20 - [3] Const mutate x$4 = Array [read a$2, read b$3]
21 - Return freeze x$4
18 + [1] Const mutate a$2_@0 = 1
19 + [2] Const mutate b$3_@1 = 2
20 + [3] Const mutate x$4_@2 = Array [read a$2_@0, read b$3_@1]
21 + Return freeze x$4_@2
22 ```
23
24 ### CFG
@@ -28,11 +28,11 @@ flowchart TB
28 %% Basic Blocks
29 subgraph bb0
30 bb0_instrs["
31 - [1] Const mutate a$2 = 1
32 - [2] Const mutate b$3 = 2
33 - [3] Const mutate x$4 = Array [read a$2, read b$3]
31 + [1] Const mutate a$2_@0 = 1
32 + [2] Const mutate b$3_@1 = 2
33 + [3] Const mutate x$4_@2 = Array [read a$2_@0, read b$3_@1]
34 "]
35 - bb0_instrs --> bb0_terminal(["Return freeze x$4"])
35 + bb0_instrs --> bb0_terminal(["Return freeze x$4_@2"])
36 end
37
38 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md
+22 -22
@@ -50,22 +50,22 @@ function foo$0() {
50
51 ```
52 bb0:
53 - [1] Const mutate a$2[1:3] = Array []
54 - [2] Const mutate b$3[2:7] = Object { }
55 - [3] Call mutate foo$4(mutate a$2, mutate b$3)
56 - [4] Const mutate $7 = Call mutate foo$4()
57 - If (read $7) then:bb2 else:bb1
53 + [1] Const mutate a$2_@0[1:3] = Array []
54 + [2] Const mutate b$3_@0[2:7] = Object { }
55 + [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
56 + [4] Const mutate $7_@0 = Call mutate foo$4_@0()
57 + If (read $7_@0) then:bb2 else:bb1
58 bb2:
59 predecessor blocks: bb0
60 - [5] Const mutate $6 = "div"
61 - [6] Let mutate _$5 = JSX <read $6 a={freeze a$2} ></read $6>
60 + [5] Const mutate $6_@1 = "div"
61 + [6] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
62 Goto bb1
63 bb1:
64 predecessor blocks: bb2 bb0
65 - [7] Call mutate foo$4(read a$2, mutate b$3)
66 - [8] Const mutate $8 = "div"
67 - [9] Const mutate $9 = JSX <read $8 a={freeze a$2} b={freeze b$3} ></read $8>
68 - Return read $9
65 + [7] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0)
66 + [8] Const mutate $8_@3 = "div"
67 + [9] Const mutate $9_@4 = JSX <read $8_@3 a={freeze a$2_@0} b={freeze b$3_@0} ></read $8_@3>
68 + Return read $9_@4
69 ```
70
71 ### CFG
@@ -75,27 +75,27 @@ flowchart TB
75 %% Basic Blocks
76 subgraph bb0
77 bb0_instrs["
78 - [1] Const mutate a$2[1:3] = Array []
79 - [2] Const mutate b$3[2:7] = Object { }
80 - [3] Call mutate foo$4(mutate a$2, mutate b$3)
81 - [4] Const mutate $7 = Call mutate foo$4()
78 + [1] Const mutate a$2_@0[1:3] = Array []
79 + [2] Const mutate b$3_@0[2:7] = Object { }
80 + [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
81 + [4] Const mutate $7_@0 = Call mutate foo$4_@0()
82 "]
83 - bb0_instrs --> bb0_terminal(["If (read $7)"])
83 + bb0_instrs --> bb0_terminal(["If (read $7_@0)"])
84 end
85 subgraph bb2
86 bb2_instrs["
87 - [5] Const mutate $6 = 'div'
88 - [6] Let mutate _$5 = JSX <read $6 a={freeze a$2} ></read $6>
87 + [5] Const mutate $6_@1 = 'div'
88 + [6] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
89 "]
90 bb2_instrs --> bb2_terminal(["Goto"])
91 end
92 subgraph bb1
93 bb1_instrs["
94 - [7] Call mutate foo$4(read a$2, mutate b$3)
95 - [8] Const mutate $8 = 'div'
96 - [9] Const mutate $9 = JSX <read $8 a={freeze a$2} b={freeze b$3} ></read $8>
94 + [7] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0)
95 + [8] Const mutate $8_@3 = 'div'
96 + [9] Const mutate $9_@4 = JSX <read $8_@3 a={freeze a$2_@0} b={freeze b$3_@0} ></read $8_@3>
97 "]
98 - bb1_instrs --> bb1_terminal(["Return read $9"])
98 + bb1_instrs --> bb1_terminal(["Return read $9_@4"])
99 end
100
101 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md
+18 -18
@@ -47,15 +47,15 @@ function foo$0() {
47
48 ```
49 bb0:
50 - [1] Const mutate a$2[1:3] = Array []
51 - [2] Const mutate b$3[2:6] = Object { }
52 - [3] Call mutate foo$4(mutate a$2, mutate b$3)
53 - [4] Const mutate $6 = "div"
54 - [5] Let mutate _$5 = JSX <read $6 a={freeze a$2} ></read $6>
55 - [6] Call mutate foo$4(read a$2, mutate b$3)
56 - [7] Const mutate $7 = "div"
57 - [8] Const mutate $8 = JSX <read $7 a={read a$2} b={freeze b$3} ></read $7>
58 - Return read $8
50 + [1] Const mutate a$2_@0[1:3] = Array []
51 + [2] Const mutate b$3_@0[2:6] = Object { }
52 + [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
53 + [4] Const mutate $6_@1 = "div"
54 + [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
55 + [6] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0)
56 + [7] Const mutate $7_@3 = "div"
57 + [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
58 + Return read $8_@4
59 ```
60
61 ### CFG
@@ -65,16 +65,16 @@ flowchart TB
65 %% Basic Blocks
66 subgraph bb0
67 bb0_instrs["
68 - [1] Const mutate a$2[1:3] = Array []
69 - [2] Const mutate b$3[2:6] = Object { }
70 - [3] Call mutate foo$4(mutate a$2, mutate b$3)
71 - [4] Const mutate $6 = 'div'
72 - [5] Let mutate _$5 = JSX <read $6 a={freeze a$2} ></read $6>
73 - [6] Call mutate foo$4(read a$2, mutate b$3)
74 - [7] Const mutate $7 = 'div'
75 - [8] Const mutate $8 = JSX <read $7 a={read a$2} b={freeze b$3} ></read $7>
68 + [1] Const mutate a$2_@0[1:3] = Array []
69 + [2] Const mutate b$3_@0[2:6] = Object { }
70 + [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
71 + [4] Const mutate $6_@1 = 'div'
72 + [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
73 + [6] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0)
74 + [7] Const mutate $7_@3 = 'div'
75 + [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
76 "]
77 - bb0_instrs --> bb0_terminal(["Return read $8"])
77 + bb0_instrs --> bb0_terminal(["Return read $8_@4"])
78 end
79
80 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md
+22 -22
@@ -21,27 +21,27 @@ function foo() {
21
22 ```
23 bb0:
24 - [1] Let mutate x$1 = 1
25 - [2] Let mutate y$2 = 2
26 - [3] Const mutate $3 = 2
27 - [4] Const mutate $4 = Binary read y$2 === read $3
28 - If (read $4) then:bb2 else:bb1
24 + [1] Let mutate x$1_@0 = 1
25 + [2] Let mutate y$2_@1 = 2
26 + [3] Const mutate $3_@2 = 2
27 + [4] Const mutate $4_@3 = Binary read y$2_@1 === read $3_@2
28 + If (read $4_@3) then:bb2 else:bb1
29 bb2:
30 predecessor blocks: bb0
31 - [5] Reassign mutate x$1 = 3
31 + [5] Reassign mutate x$1_@4 = 3
32 Goto bb1
33 bb1:
34 predecessor blocks: bb2 bb0
35 - [6] Const mutate $5 = 3
36 - [7] Const mutate $6 = Binary read y$2 === read $5
37 - If (read $6) then:bb4 else:bb3
35 + [6] Const mutate $5_@5 = 3
36 + [7] Const mutate $6_@6 = Binary read y$2_@1 === read $5_@5
37 + If (read $6_@6) then:bb4 else:bb3
38 bb4:
39 predecessor blocks: bb1
40 - [8] Reassign mutate x$1 = 5
40 + [8] Reassign mutate x$1_@7 = 5
41 Goto bb3
42 bb3:
43 predecessor blocks: bb4 bb1
44 - [9] Reassign mutate y$2 = read x$1
44 + [9] Reassign mutate y$2_@8 = read x$1
45 Return
46 ```
47
@@ -52,35 +52,35 @@ flowchart TB
52 %% Basic Blocks
53 subgraph bb0
54 bb0_instrs["
55 - [1] Let mutate x$1 = 1
56 - [2] Let mutate y$2 = 2
57 - [3] Const mutate $3 = 2
58 - [4] Const mutate $4 = Binary read y$2 === read $3
55 + [1] Let mutate x$1_@0 = 1
56 + [2] Let mutate y$2_@1 = 2
57 + [3] Const mutate $3_@2 = 2
58 + [4] Const mutate $4_@3 = Binary read y$2_@1 === read $3_@2
59 "]
60 - bb0_instrs --> bb0_terminal(["If (read $4)"])
60 + bb0_instrs --> bb0_terminal(["If (read $4_@3)"])
61 end
62 subgraph bb2
63 bb2_instrs["
64 - [5] Reassign mutate x$1 = 3
64 + [5] Reassign mutate x$1_@4 = 3
65 "]
66 bb2_instrs --> bb2_terminal(["Goto"])
67 end
68 subgraph bb1
69 bb1_instrs["
70 - [6] Const mutate $5 = 3
71 - [7] Const mutate $6 = Binary read y$2 === read $5
70 + [6] Const mutate $5_@5 = 3
71 + [7] Const mutate $6_@6 = Binary read y$2_@1 === read $5_@5
72 "]
73 - bb1_instrs --> bb1_terminal(["If (read $6)"])
73 + bb1_instrs --> bb1_terminal(["If (read $6_@6)"])
74 end
75 subgraph bb4
76 bb4_instrs["
77 - [8] Reassign mutate x$1 = 5
77 + [8] Reassign mutate x$1_@7 = 5
78 "]
79 bb4_instrs --> bb4_terminal(["Goto"])
80 end
81 subgraph bb3
82 bb3_instrs["
83 - [9] Reassign mutate y$2 = read x$1
83 + [9] Reassign mutate y$2_@8 = read x$1
84 "]
85 bb3_instrs --> bb3_terminal(["Return"])
86 end
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md
+14 -14
@@ -18,18 +18,18 @@ function foo() {
18
19 ```
20 bb0:
21 - [1] Let mutate x$1 = 1
22 - [2] Let mutate y$2 = 2
23 - [3] Const mutate $3 = 2
24 - [4] Const mutate $4 = Binary read y$2 === read $3
25 - If (read $4) then:bb2 else:bb1
21 + [1] Let mutate x$1_@0 = 1
22 + [2] Let mutate y$2_@1 = 2
23 + [3] Const mutate $3_@2 = 2
24 + [4] Const mutate $4_@3 = Binary read y$2_@1 === read $3_@2
25 + If (read $4_@3) then:bb2 else:bb1
26 bb2:
27 predecessor blocks: bb0
28 - [5] Reassign mutate x$1 = 3
28 + [5] Reassign mutate x$1_@4 = 3
29 Goto bb1
30 bb1:
31 predecessor blocks: bb2 bb0
32 - [6] Reassign mutate y$2 = read x$1
32 + [6] Reassign mutate y$2_@5 = read x$1
33 Return
34 ```
35
@@ -40,22 +40,22 @@ flowchart TB
40 %% Basic Blocks
41 subgraph bb0
42 bb0_instrs["
43 - [1] Let mutate x$1 = 1
44 - [2] Let mutate y$2 = 2
45 - [3] Const mutate $3 = 2
46 - [4] Const mutate $4 = Binary read y$2 === read $3
43 + [1] Let mutate x$1_@0 = 1
44 + [2] Let mutate y$2_@1 = 2
45 + [3] Const mutate $3_@2 = 2
46 + [4] Const mutate $4_@3 = Binary read y$2_@1 === read $3_@2
47 "]
48 - bb0_instrs --> bb0_terminal(["If (read $4)"])
48 + bb0_instrs --> bb0_terminal(["If (read $4_@3)"])
49 end
50 subgraph bb2
51 bb2_instrs["
52 - [5] Reassign mutate x$1 = 3
52 + [5] Reassign mutate x$1_@4 = 3
53 "]
54 bb2_instrs --> bb2_terminal(["Goto"])
55 end
56 subgraph bb1
57 bb1_instrs["
58 - [6] Reassign mutate y$2 = read x$1
58 + [6] Reassign mutate y$2_@5 = read x$1
59 "]
60 bb1_instrs --> bb1_terminal(["Return"])
61 end
compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md
+10 -10
@@ -19,25 +19,25 @@ function foo(cond) {
19
20 ```
21 bb0:
22 - [1] Let mutate items$2 = Array []
22 + [1] Let mutate items$2_@0 = Array []
23 Goto bb1
24 bb1:
25 predecessor blocks: bb0 bb4
26 - If (read items$2) then:bb3 else:bb2
26 + If (read items$2_@0) then:bb3 else:bb2
27 bb3:
28 predecessor blocks: bb1
29 - [2] Let mutate y$3 = 0
29 + [2] Let mutate y$3_@1 = 0
30 If (read cond$1) then:bb5 else:bb4
31 bb5:
32 predecessor blocks: bb3
33 - [3] Reassign mutate y$3 = 1
33 + [3] Reassign mutate y$3_@2 = 1
34 Goto bb4
35 bb4:
36 predecessor blocks: bb5 bb3
37 Goto(Continue) bb1
38 bb2:
39 predecessor blocks: bb1
40 - Return freeze items$2
40 + Return freeze items$2_@0
41 ```
42
43 ### CFG
@@ -47,22 +47,22 @@ flowchart TB
47 %% Basic Blocks
48 subgraph bb0
49 bb0_instrs["
50 - [1] Let mutate items$2 = Array []
50 + [1] Let mutate items$2_@0 = Array []
51 "]
52 bb0_instrs --> bb0_terminal(["Goto"])
53 end
54 subgraph bb1
55 - bb1_terminal(["If (read items$2)"])
55 + bb1_terminal(["If (read items$2_@0)"])
56 end
57 subgraph bb3
58 bb3_instrs["
59 - [2] Let mutate y$3 = 0
59 + [2] Let mutate y$3_@1 = 0
60 "]
61 bb3_instrs --> bb3_terminal(["If (read cond$1)"])
62 end
63 subgraph bb5
64 bb5_instrs["
65 - [3] Reassign mutate y$3 = 1
65 + [3] Reassign mutate y$3_@2 = 1
66 "]
67 bb5_instrs --> bb5_terminal(["Goto"])
68 end
@@ -70,7 +70,7 @@ flowchart TB
70 bb4_terminal(["Goto"])
71 end
72 subgraph bb2
73 - bb2_terminal(["Return freeze items$2"])
73 + bb2_terminal(["Return freeze items$2_@0"])
74 end
75
76 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md
+12 -12
@@ -16,17 +16,17 @@ function foo() {
16
17 ```
18 bb0:
19 - [1] Let mutate x$1 = 0
19 + [1] Let mutate x$1_@0 = 0
20 Goto bb1
21 bb1:
22 predecessor blocks: bb0 bb4
23 - [2] Const mutate $3 = 10
24 - [3] Const mutate $4 = Binary read x$1 < read $3
25 - If (read $4) then:bb4 else:bb2
23 + [2] Const mutate $3_@1 = 10
24 + [3] Const mutate $4_@2 = Binary read x$1 < read $3_@1
25 + If (read $4_@2) then:bb4 else:bb2
26 bb4:
27 predecessor blocks: bb1
28 - [4] Const mutate $2 = 1
29 - [5] Reassign mutate x$1 = Binary read x$1 + read $2
28 + [4] Const mutate $2_@3 = 1
29 + [5] Reassign mutate x$1_@4 = Binary read x$1 + read $2_@3
30 Goto(Continue) bb1
31 bb2:
32 predecessor blocks: bb1
@@ -40,21 +40,21 @@ flowchart TB
40 %% Basic Blocks
41 subgraph bb0
42 bb0_instrs["
43 - [1] Let mutate x$1 = 0
43 + [1] Let mutate x$1_@0 = 0
44 "]
45 bb0_instrs --> bb0_terminal(["Goto"])
46 end
47 subgraph bb1
48 bb1_instrs["
49 - [2] Const mutate $3 = 10
50 - [3] Const mutate $4 = Binary read x$1 < read $3
49 + [2] Const mutate $3_@1 = 10
50 + [3] Const mutate $4_@2 = Binary read x$1 < read $3_@1
51 "]
52 - bb1_instrs --> bb1_terminal(["If (read $4)"])
52 + bb1_instrs --> bb1_terminal(["If (read $4_@2)"])
53 end
54 subgraph bb4
55 bb4_instrs["
56 - [4] Const mutate $2 = 1
57 - [5] Reassign mutate x$1 = Binary read x$1 + read $2
56 + [4] Const mutate $2_@3 = 1
57 + [5] Reassign mutate x$1_@4 = Binary read x$1 + read $2_@3
58 "]
59 bb4_instrs --> bb4_terminal(["Goto"])
60 end
compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md
+10 -10
@@ -19,16 +19,16 @@ function foo() {
19
20 ```
21 bb0:
22 - [1] Let mutate x$1 = 1
23 - [2] Let mutate y$2 = 2
24 - If (read y$2) then:bb2 else:bb3
22 + [1] Let mutate x$1_@0 = 1
23 + [2] Let mutate y$2_@1 = 2
24 + If (read y$2_@1) then:bb2 else:bb3
25 bb2:
26 predecessor blocks: bb0
27 - [3] Let mutate z$3 = Binary read x$1 + read y$2
27 + [3] Let mutate z$3_@2 = Binary read x$1_@0 + read y$2_@1
28 Goto bb1
29 bb3:
30 predecessor blocks: bb0
31 - [4] Let mutate z$4 = read x$1
31 + [4] Let mutate z$4_@3 = read x$1_@0
32 Goto bb1
33 bb1:
34 predecessor blocks: bb2 bb3
@@ -42,20 +42,20 @@ flowchart TB
42 %% Basic Blocks
43 subgraph bb0
44 bb0_instrs["
45 - [1] Let mutate x$1 = 1
46 - [2] Let mutate y$2 = 2
45 + [1] Let mutate x$1_@0 = 1
46 + [2] Let mutate y$2_@1 = 2
47 "]
48 - bb0_instrs --> bb0_terminal(["If (read y$2)"])
48 + bb0_instrs --> bb0_terminal(["If (read y$2_@1)"])
49 end
50 subgraph bb2
51 bb2_instrs["
52 - [3] Let mutate z$3 = Binary read x$1 + read y$2
52 + [3] Let mutate z$3_@2 = Binary read x$1_@0 + read y$2_@1
53 "]
54 bb2_instrs --> bb2_terminal(["Goto"])
55 end
56 subgraph bb3
57 bb3_instrs["
58 - [4] Let mutate z$4 = read x$1
58 + [4] Let mutate z$4_@3 = read x$1_@0
59 "]
60 bb3_instrs --> bb3_terminal(["Goto"])
61 end
compiler/forget/src/__tests__/fixtures/hir/ssa-nested-loops-no-reassign.expect.md
+8 -8
@@ -21,7 +21,7 @@ function foo(a, b, c) {
21
22 ```
23 bb0:
24 - [1] Let mutate x$4 = 0
24 + [1] Let mutate x$4_@0 = 0
25 While test=bb1 loop=bb3 fallthrough=bb2
26 bb1:
27 predecessor blocks: bb0 bb5
@@ -40,8 +40,8 @@ bb7:
40 If (read c$3) then:bb9 else:bb8
41 bb9:
42 predecessor blocks: bb7
43 - [2] Const mutate $5 = 1
44 - [3] Binary read x$4 + read $5
43 + [2] Const mutate $5_@1 = 1
44 + [3] Binary read x$4_@0 + read $5_@1
45 Goto(Continue) bb7
46 bb8:
47 predecessor blocks: bb7
@@ -51,7 +51,7 @@ bb5:
51 Goto(Continue) bb1
52 bb2:
53 predecessor blocks: bb1
54 - Return read x$4
54 + Return read x$4_@0
55 ```
56
57 ### CFG
@@ -61,7 +61,7 @@ flowchart TB
61 %% Basic Blocks
62 subgraph bb0
63 bb0_instrs["
64 - [1] Let mutate x$4 = 0
64 + [1] Let mutate x$4_@0 = 0
65 "]
66 bb0_instrs --> bb0_terminal(["While"])
67 end
@@ -82,8 +82,8 @@ flowchart TB
82 end
83 subgraph bb9
84 bb9_instrs["
85 - [2] Const mutate $5 = 1
86 - [3] Binary read x$4 + read $5
85 + [2] Const mutate $5_@1 = 1
86 + [3] Binary read x$4_@0 + read $5_@1
87 "]
88 bb9_instrs --> bb9_terminal(["Goto"])
89 end
@@ -94,7 +94,7 @@ flowchart TB
94 bb5_terminal(["Goto"])
95 end
96 subgraph bb2
97 - bb2_terminal(["Return read x$4"])
97 + bb2_terminal(["Return read x$4_@0"])
98 end
99
100 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md
+8 -8
@@ -45,10 +45,10 @@ function Foo$0() {
45
46 ```
47 bb0:
48 - [1] Const mutate a$2[1:3] = Array []
49 - [2] Const mutate b$3[2:3] = Object { }
50 - [3] Let mutate c$4 = New mutate Foo$5(mutate a$2, mutate b$3)
51 - Return freeze c$4
48 + [1] Const mutate a$2_@0[1:3] = Array []
49 + [2] Const mutate b$3_@0[2:3] = Object { }
50 + [3] Let mutate c$4_@0 = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0)
51 + Return freeze c$4_@0
52 ```
53
54 ### CFG
@@ -58,11 +58,11 @@ flowchart TB
58 %% Basic Blocks
59 subgraph bb0
60 bb0_instrs["
61 - [1] Const mutate a$2[1:3] = Array []
62 - [2] Const mutate b$3[2:3] = Object { }
63 - [3] Let mutate c$4 = New mutate Foo$5(mutate a$2, mutate b$3)
61 + [1] Const mutate a$2_@0[1:3] = Array []
62 + [2] Const mutate b$3_@0[2:3] = Object { }
63 + [3] Let mutate c$4_@0 = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0)
64 "]
65 - bb0_instrs --> bb0_terminal(["Return freeze c$4"])
65 + bb0_instrs --> bb0_terminal(["Return freeze c$4_@0"])
66 end
67
68 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md
+18 -18
@@ -22,23 +22,23 @@ function foo() {
22
23 ```
24 bb0:
25 - [1] Let mutate x$1 = 1
26 - [2] Let mutate y$2 = 2
27 - [3] Const mutate $3 = 1
28 - [4] Const mutate $4 = Binary read x$1 > read $3
29 - If (read $4) then:bb2 else:bb3
25 + [1] Let mutate x$1_@0 = 1
26 + [2] Let mutate y$2_@1 = 2
27 + [3] Const mutate $3_@2 = 1
28 + [4] Const mutate $4_@3 = Binary read x$1_@0 > read $3_@2
29 + If (read $4_@3) then:bb2 else:bb3
30 bb2:
31 predecessor blocks: bb0
32 - [5] Reassign mutate x$1 = 2
32 + [5] Reassign mutate x$1_@4 = 2
33 Goto bb1
34 bb3:
35 predecessor blocks: bb0
36 - [6] Reassign mutate y$2 = 3
36 + [6] Reassign mutate y$2_@5 = 3
37 Goto bb1
38 bb1:
39 predecessor blocks: bb2 bb3
40 - [7] Let mutate t$5 = Object { x: read x$1, y: read y$2 }
41 - Return freeze t$5
40 + [7] Let mutate t$5_@6 = Object { x: read x$1, y: read y$2 }
41 + Return freeze t$5_@6
42 ```
43
44 ### CFG
@@ -48,30 +48,30 @@ flowchart TB
48 %% Basic Blocks
49 subgraph bb0
50 bb0_instrs["
51 - [1] Let mutate x$1 = 1
52 - [2] Let mutate y$2 = 2
53 - [3] Const mutate $3 = 1
54 - [4] Const mutate $4 = Binary read x$1 > read $3
51 + [1] Let mutate x$1_@0 = 1
52 + [2] Let mutate y$2_@1 = 2
53 + [3] Const mutate $3_@2 = 1
54 + [4] Const mutate $4_@3 = Binary read x$1_@0 > read $3_@2
55 "]
56 - bb0_instrs --> bb0_terminal(["If (read $4)"])
56 + bb0_instrs --> bb0_terminal(["If (read $4_@3)"])
57 end
58 subgraph bb2
59 bb2_instrs["
60 - [5] Reassign mutate x$1 = 2
60 + [5] Reassign mutate x$1_@4 = 2
61 "]
62 bb2_instrs --> bb2_terminal(["Goto"])
63 end
64 subgraph bb3
65 bb3_instrs["
66 - [6] Reassign mutate y$2 = 3
66 + [6] Reassign mutate y$2_@5 = 3
67 "]
68 bb3_instrs --> bb3_terminal(["Goto"])
69 end
70 subgraph bb1
71 bb1_instrs["
72 - [7] Let mutate t$5 = Object { x: read x$1, y: read y$2 }
72 + [7] Let mutate t$5_@6 = Object { x: read x$1, y: read y$2 }
73 "]
74 - bb1_instrs --> bb1_terminal(["Return freeze t$5"])
74 + bb1_instrs --> bb1_terminal(["Return freeze t$5_@6"])
75 end
76
77 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md
+8 -8
@@ -15,10 +15,10 @@ function Component(props) {
15
16 ```
17 bb0:
18 - [1] Const mutate a$2 = 1
19 - [2] Const mutate b$3 = 2
20 - [3] Const mutate x$4 = Object { a: read a$2, b: read b$3 }
21 - Return freeze x$4
18 + [1] Const mutate a$2_@0 = 1
19 + [2] Const mutate b$3_@1 = 2
20 + [3] Const mutate x$4_@2 = Object { a: read a$2_@0, b: read b$3_@1 }
21 + Return freeze x$4_@2
22 ```
23
24 ### CFG
@@ -28,11 +28,11 @@ flowchart TB
28 %% Basic Blocks
29 subgraph bb0
30 bb0_instrs["
31 - [1] Const mutate a$2 = 1
32 - [2] Const mutate b$3 = 2
33 - [3] Const mutate x$4 = Object { a: read a$2, b: read b$3 }
31 + [1] Const mutate a$2_@0 = 1
32 + [2] Const mutate b$3_@1 = 2
33 + [3] Const mutate x$4_@2 = Object { a: read a$2_@0, b: read b$3_@1 }
34 "]
35 - bb0_instrs --> bb0_terminal(["Return freeze x$4"])
35 + bb0_instrs --> bb0_terminal(["Return freeze x$4_@2"])
36 end
37
38 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md
+10 -10
@@ -15,11 +15,11 @@ function foo() {
15
16 ```
17 bb0:
18 - [1] Const mutate x$1 = Array []
19 - [2] Const mutate y$2[2:4] = Object { x: read x$1 }
20 - [3] Const mutate $3[3:4] = Array []
21 - [4] Call mutate y$2.x.push(mutate $3)
22 - Return freeze y$2
18 + [1] Const mutate x$1_@0 = Array []
19 + [2] Const mutate y$2_@1[2:4] = Object { x: read x$1_@0 }
20 + [3] Const mutate $3_@1[3:4] = Array []
21 + [4] Call mutate y$2_@1.x.push(mutate $3_@1)
22 + Return freeze y$2_@1
23 ```
24
25 ### CFG
@@ -29,12 +29,12 @@ flowchart TB
29 %% Basic Blocks
30 subgraph bb0
31 bb0_instrs["
32 - [1] Const mutate x$1 = Array []
33 - [2] Const mutate y$2[2:4] = Object { x: read x$1 }
34 - [3] Const mutate $3[3:4] = Array []
35 - [4] Call mutate y$2.x.push(mutate $3)
32 + [1] Const mutate x$1_@0 = Array []
33 + [2] Const mutate y$2_@1[2:4] = Object { x: read x$1_@0 }
34 + [3] Const mutate $3_@1[3:4] = Array []
35 + [4] Call mutate y$2_@1.x.push(mutate $3_@1)
36 "]
37 - bb0_instrs --> bb0_terminal(["Return freeze y$2"])
37 + bb0_instrs --> bb0_terminal(["Return freeze y$2_@1"])
38 end
39
40 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md
+8 -8
@@ -15,10 +15,10 @@ function foo() {
15
16 ```
17 bb0:
18 - [1] Const mutate x$1 = Array []
19 - [2] Const mutate y$2[2:3] = Object { }
20 - [3] Reassign mutate y$2.x[2:3] = read x$1
21 - Return freeze y$2
18 + [1] Const mutate x$1_@0 = Array []
19 + [2] Const mutate y$2_@1[2:3] = Object { }
20 + [3] Reassign mutate y$2_@1.x[2:3] = read x$1_@0
21 + Return freeze y$2_@1
22 ```
23
24 ### CFG
@@ -28,11 +28,11 @@ flowchart TB
28 %% Basic Blocks
29 subgraph bb0
30 bb0_instrs["
31 - [1] Const mutate x$1 = Array []
32 - [2] Const mutate y$2[2:3] = Object { }
33 - [3] Reassign mutate y$2.x[2:3] = read x$1
31 + [1] Const mutate x$1_@0 = Array []
32 + [2] Const mutate y$2_@1[2:3] = Object { }
33 + [3] Reassign mutate y$2_@1.x[2:3] = read x$1_@0
34 "]
35 - bb0_instrs --> bb0_terminal(["Return freeze y$2"])
35 + bb0_instrs --> bb0_terminal(["Return freeze y$2_@1"])
36 end
37
38 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md
+10 -10
@@ -17,13 +17,13 @@ function foo() {
17
18 ```
19 bb0:
20 - [1] Let mutate x$1 = 1
21 - [2] Const mutate $2 = 1
22 - [3] Const mutate $3 = Binary read x$1 === read $2
23 - If (read $3) then:bb2 else:bb1
20 + [1] Let mutate x$1_@0 = 1
21 + [2] Const mutate $2_@1 = 1
22 + [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
23 + If (read $3_@2) then:bb2 else:bb1
24 bb2:
25 predecessor blocks: bb0
26 - [4] Reassign mutate x$1 = 2
26 + [4] Reassign mutate x$1_@3 = 2
27 Goto bb1
28 bb1:
29 predecessor blocks: bb2 bb0
@@ -37,15 +37,15 @@ flowchart TB
37 %% Basic Blocks
38 subgraph bb0
39 bb0_instrs["
40 - [1] Let mutate x$1 = 1
41 - [2] Const mutate $2 = 1
42 - [3] Const mutate $3 = Binary read x$1 === read $2
40 + [1] Let mutate x$1_@0 = 1
41 + [2] Const mutate $2_@1 = 1
42 + [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
43 "]
44 - bb0_instrs --> bb0_terminal(["If (read $3)"])
44 + bb0_instrs --> bb0_terminal(["If (read $3_@2)"])
45 end
46 subgraph bb2
47 bb2_instrs["
48 - [4] Reassign mutate x$1 = 2
48 + [4] Reassign mutate x$1_@3 = 2
49 "]
50 bb2_instrs --> bb2_terminal(["Goto"])
51 end
compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md
+10 -10
@@ -49,20 +49,20 @@ function log$0() {
49
50 ```
51 bb0:
52 - [1] Let mutate str$2 = ""
52 + [1] Let mutate str$2_@0 = ""
53 If (read cond$1) then:bb2 else:bb3
54 bb2:
55 predecessor blocks: bb0
56 - [2] Let mutate str$3 = "other test"
57 - [3] Call mutate log$4(read str$3)
56 + [2] Let mutate str$3_@1 = "other test"
57 + [3] Call mutate log$4_@2(read str$3_@1)
58 Goto bb1
59 bb3:
60 predecessor blocks: bb0
61 - [4] Reassign mutate str$2 = "fallthrough test"
61 + [4] Reassign mutate str$2_@3 = "fallthrough test"
62 Goto bb1
63 bb1:
64 predecessor blocks: bb2 bb3
65 - [5] Call mutate log$4(read str$2)
65 + [5] Call mutate log$4_@2(read str$2)
66 Return
67 ```
68
@@ -73,26 +73,26 @@ flowchart TB
73 %% Basic Blocks
74 subgraph bb0
75 bb0_instrs["
76 - [1] Let mutate str$2 = ''
76 + [1] Let mutate str$2_@0 = ''
77 "]
78 bb0_instrs --> bb0_terminal(["If (read cond$1)"])
79 end
80 subgraph bb2
81 bb2_instrs["
82 - [2] Let mutate str$3 = 'other test'
83 - [3] Call mutate log$4(read str$3)
82 + [2] Let mutate str$3_@1 = 'other test'
83 + [3] Call mutate log$4_@2(read str$3_@1)
84 "]
85 bb2_instrs --> bb2_terminal(["Goto"])
86 end
87 subgraph bb3
88 bb3_instrs["
89 - [4] Reassign mutate str$2 = 'fallthrough test'
89 + [4] Reassign mutate str$2_@3 = 'fallthrough test'
90 "]
91 bb3_instrs --> bb3_terminal(["Goto"])
92 end
93 subgraph bb1
94 bb1_instrs["
95 - [5] Call mutate log$4(read str$2)
95 + [5] Call mutate log$4_@2(read str$2)
96 "]
97 bb1_instrs --> bb1_terminal(["Return"])
98 end
compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md
+14 -14
@@ -20,21 +20,21 @@ function foo() {
20
21 ```
22 bb0:
23 - [1] Let mutate y$1 = 2
24 - [2] Const mutate $2 = 1
25 - [3] Const mutate $3 = Binary read y$1 > read $2
26 - If (read $3) then:bb2 else:bb3
23 + [1] Let mutate y$1_@0 = 2
24 + [2] Const mutate $2_@1 = 1
25 + [3] Const mutate $3_@2 = Binary read y$1_@0 > read $2_@1
26 + If (read $3_@2) then:bb2 else:bb3
27 bb2:
28 predecessor blocks: bb0
29 - [4] Reassign mutate y$1 = 1
29 + [4] Reassign mutate y$1_@3 = 1
30 Goto bb1
31 bb3:
32 predecessor blocks: bb0
33 - [5] Reassign mutate y$1 = 2
33 + [5] Reassign mutate y$1_@4 = 2
34 Goto bb1
35 bb1:
36 predecessor blocks: bb2 bb3
37 - [6] Let mutate x$4 = read y$1
37 + [6] Let mutate x$4_@5 = read y$1
38 Return
39 ```
40
@@ -45,27 +45,27 @@ flowchart TB
45 %% Basic Blocks
46 subgraph bb0
47 bb0_instrs["
48 - [1] Let mutate y$1 = 2
49 - [2] Const mutate $2 = 1
50 - [3] Const mutate $3 = Binary read y$1 > read $2
48 + [1] Let mutate y$1_@0 = 2
49 + [2] Const mutate $2_@1 = 1
50 + [3] Const mutate $3_@2 = Binary read y$1_@0 > read $2_@1
51 "]
52 - bb0_instrs --> bb0_terminal(["If (read $3)"])
52 + bb0_instrs --> bb0_terminal(["If (read $3_@2)"])
53 end
54 subgraph bb2
55 bb2_instrs["
56 - [4] Reassign mutate y$1 = 1
56 + [4] Reassign mutate y$1_@3 = 1
57 "]
58 bb2_instrs --> bb2_terminal(["Goto"])
59 end
60 subgraph bb3
61 bb3_instrs["
62 - [5] Reassign mutate y$1 = 2
62 + [5] Reassign mutate y$1_@4 = 2
63 "]
64 bb3_instrs --> bb3_terminal(["Goto"])
65 end
66 subgraph bb1
67 bb1_instrs["
68 - [6] Let mutate x$4 = read y$1
68 + [6] Let mutate x$4_@5 = read y$1
69 "]
70 bb1_instrs --> bb1_terminal(["Return"])
71 end
compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md
+4 -4
@@ -13,8 +13,8 @@ function foo() {
13
14 ```
15 bb0:
16 - [1] Let mutate x$1 = 1
17 - [2] Let mutate y$2 = 2
16 + [1] Let mutate x$1_@0 = 1
17 + [2] Let mutate y$2_@1 = 2
18 Return
19 ```
20
@@ -25,8 +25,8 @@ flowchart TB
25 %% Basic Blocks
26 subgraph bb0
27 bb0_instrs["
28 - [1] Let mutate x$1 = 1
29 - [2] Let mutate y$2 = 2
28 + [1] Let mutate x$1_@0 = 1
29 + [2] Let mutate y$2_@1 = 2
30 "]
31 bb0_instrs --> bb0_terminal(["Return"])
32 end
compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md
+8 -8
@@ -17,12 +17,12 @@ function foo() {
17
18 ```
19 bb0:
20 - [1] Let mutate x$1 = 1
21 - [2] Let mutate y$2 = 2
22 - If (read y$2) then:bb2 else:bb1
20 + [1] Let mutate x$1_@0 = 1
21 + [2] Let mutate y$2_@1 = 2
22 + If (read y$2_@1) then:bb2 else:bb1
23 bb2:
24 predecessor blocks: bb0
25 - [3] Let mutate z$3 = Binary read x$1 + read y$2
25 + [3] Let mutate z$3_@2 = Binary read x$1_@0 + read y$2_@1
26 Goto bb1
27 bb1:
28 predecessor blocks: bb2 bb0
@@ -36,14 +36,14 @@ flowchart TB
36 %% Basic Blocks
37 subgraph bb0
38 bb0_instrs["
39 - [1] Let mutate x$1 = 1
40 - [2] Let mutate y$2 = 2
39 + [1] Let mutate x$1_@0 = 1
40 + [2] Let mutate y$2_@1 = 2
41 "]
42 - bb0_instrs --> bb0_terminal(["If (read y$2)"])
42 + bb0_instrs --> bb0_terminal(["If (read y$2_@1)"])
43 end
44 subgraph bb2
45 bb2_instrs["
46 - [3] Let mutate z$3 = Binary read x$1 + read y$2
46 + [3] Let mutate z$3_@2 = Binary read x$1_@0 + read y$2_@1
47 "]
48 bb2_instrs --> bb2_terminal(["Goto"])
49 end
compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md
+30 -30
@@ -28,33 +28,33 @@ function foo() {
28
29 ```
30 bb0:
31 - [1] Let mutate x$1 = 1
32 - [2] Const mutate $4 = 2
33 - [3] Const mutate $5 = Binary read x$1 === read $4
34 - [4] Const mutate $7 = 1
35 - [5] Const mutate $8 = Binary read x$1 === read $7
36 - Switch (read x$1)
37 - Case read $8: bb5
38 - Case read $5: bb3
31 + [1] Let mutate x$1_@0 = 1
32 + [2] Const mutate $4_@1 = 2
33 + [3] Const mutate $5_@2 = Binary read x$1_@0 === read $4_@1
34 + [4] Const mutate $7_@3 = 1
35 + [5] Const mutate $8_@4 = Binary read x$1_@0 === read $7_@3
36 + Switch (read x$1_@0)
37 + Case read $8_@4: bb5
38 + Case read $5_@2: bb3
39 Default: bb2
40 bb5:
41 predecessor blocks: bb0
42 - [6] Const mutate $6 = 1
43 - [7] Reassign mutate x$1 = Binary read x$1 + read $6
42 + [6] Const mutate $6_@5 = 1
43 + [7] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $6_@5
44 Goto bb1
45 bb3:
46 predecessor blocks: bb0
47 - [8] Const mutate $3 = 2
48 - [9] Reassign mutate x$1 = Binary read x$1 + read $3
47 + [8] Const mutate $3_@7 = 2
48 + [9] Reassign mutate x$1_@8 = Binary read x$1_@0 + read $3_@7
49 Goto bb1
50 bb2:
51 predecessor blocks: bb0
52 - [10] Const mutate $2 = 3
53 - [11] Reassign mutate x$1 = Binary read x$1 + read $2
52 + [10] Const mutate $2_@9 = 3
53 + [11] Reassign mutate x$1_@10 = Binary read x$1_@0 + read $2_@9
54 Goto bb1
55 bb1:
56 predecessor blocks: bb5 bb3 bb2
57 - [12] Let mutate y$9 = read x$1
57 + [12] Let mutate y$9_@11 = read x$1
58 Return
59 ```
60
@@ -65,45 +65,45 @@ flowchart TB
65 %% Basic Blocks
66 subgraph bb0
67 bb0_instrs["
68 - [1] Let mutate x$1 = 1
69 - [2] Const mutate $4 = 2
70 - [3] Const mutate $5 = Binary read x$1 === read $4
71 - [4] Const mutate $7 = 1
72 - [5] Const mutate $8 = Binary read x$1 === read $7
68 + [1] Let mutate x$1_@0 = 1
69 + [2] Const mutate $4_@1 = 2
70 + [3] Const mutate $5_@2 = Binary read x$1_@0 === read $4_@1
71 + [4] Const mutate $7_@3 = 1
72 + [5] Const mutate $8_@4 = Binary read x$1_@0 === read $7_@3
73 "]
74 - bb0_instrs --> bb0_terminal(["Switch (read x$1)"])
74 + bb0_instrs --> bb0_terminal(["Switch (read x$1_@0)"])
75 end
76 subgraph bb5
77 bb5_instrs["
78 - [6] Const mutate $6 = 1
79 - [7] Reassign mutate x$1 = Binary read x$1 + read $6
78 + [6] Const mutate $6_@5 = 1
79 + [7] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $6_@5
80 "]
81 bb5_instrs --> bb5_terminal(["Goto"])
82 end
83 subgraph bb3
84 bb3_instrs["
85 - [8] Const mutate $3 = 2
86 - [9] Reassign mutate x$1 = Binary read x$1 + read $3
85 + [8] Const mutate $3_@7 = 2
86 + [9] Reassign mutate x$1_@8 = Binary read x$1_@0 + read $3_@7
87 "]
88 bb3_instrs --> bb3_terminal(["Goto"])
89 end
90 subgraph bb2
91 bb2_instrs["
92 - [10] Const mutate $2 = 3
93 - [11] Reassign mutate x$1 = Binary read x$1 + read $2
92 + [10] Const mutate $2_@9 = 3
93 + [11] Reassign mutate x$1_@10 = Binary read x$1_@0 + read $2_@9
94 "]
95 bb2_instrs --> bb2_terminal(["Goto"])
96 end
97 subgraph bb1
98 bb1_instrs["
99 - [12] Let mutate y$9 = read x$1
99 + [12] Let mutate y$9_@11 = read x$1
100 "]
101 bb1_instrs --> bb1_terminal(["Return"])
102 end
103
104 %% Jumps
105 - bb0_terminal -- read $8 --> bb5
106 - bb0_terminal -- read $5 --> bb3
105 + bb0_terminal -- read $8_@4 --> bb5
106 + bb0_terminal -- read $5_@2 --> bb3
107 bb0_terminal -- default --> bb2
108 bb0_terminal -- fallthrough --> bb1
109 bb5_terminal --> bb1
compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md
+10 -10
@@ -16,13 +16,13 @@ function foo() {
16
17 ```
18 bb0:
19 - [1] Let mutate x$1 = 1
20 - [2] Const mutate $2 = 1
21 - [3] Const mutate $3 = Binary read x$1 === read $2
22 - If (read $3) then:bb2 else:bb1
19 + [1] Let mutate x$1_@0 = 1
20 + [2] Const mutate $2_@1 = 1
21 + [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
22 + If (read $3_@2) then:bb2 else:bb1
23 bb2:
24 predecessor blocks: bb0
25 - [4] Reassign mutate x$1 = 2
25 + [4] Reassign mutate x$1_@3 = 2
26 Goto bb1
27 bb1:
28 predecessor blocks: bb2 bb0
@@ -36,15 +36,15 @@ flowchart TB
36 %% Basic Blocks
37 subgraph bb0
38 bb0_instrs["
39 - [1] Let mutate x$1 = 1
40 - [2] Const mutate $2 = 1
41 - [3] Const mutate $3 = Binary read x$1 === read $2
39 + [1] Let mutate x$1_@0 = 1
40 + [2] Const mutate $2_@1 = 1
41 + [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
42 "]
43 - bb0_instrs --> bb0_terminal(["If (read $3)"])
43 + bb0_instrs --> bb0_terminal(["If (read $3_@2)"])
44 end
45 subgraph bb2
46 bb2_instrs["
47 - [4] Reassign mutate x$1 = 2
47 + [4] Reassign mutate x$1_@3 = 2
48 "]
49 bb2_instrs --> bb2_terminal(["Goto"])
50 end
compiler/forget/src/__tests__/fixtures/hir/ssa-while-no-reassign.expect.md
+14 -14
@@ -17,21 +17,21 @@ function foo() {
17
18 ```
19 bb0:
20 - [1] Let mutate x$1 = 1
20 + [1] Let mutate x$1_@0 = 1
21 While test=bb1 loop=bb3 fallthrough=bb2
22 bb1:
23 predecessor blocks: bb0 bb3
24 - [2] Const mutate $3 = 10
25 - [3] Const mutate $4 = Binary read x$1 < read $3
26 - If (read $4) then:bb3 else:bb2
24 + [2] Const mutate $3_@1 = 10
25 + [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1
26 + If (read $4_@2) then:bb3 else:bb2
27 bb3:
28 predecessor blocks: bb1
29 - [4] Const mutate $2 = 1
30 - [5] Binary read x$1 + read $2
29 + [4] Const mutate $2_@3 = 1
30 + [5] Binary read x$1_@0 + read $2_@3
31 Goto(Continue) bb1
32 bb2:
33 predecessor blocks: bb1
34 - Return read x$1
34 + Return read x$1_@0
35 ```
36
37 ### CFG
@@ -41,26 +41,26 @@ flowchart TB
41 %% Basic Blocks
42 subgraph bb0
43 bb0_instrs["
44 - [1] Let mutate x$1 = 1
44 + [1] Let mutate x$1_@0 = 1
45 "]
46 bb0_instrs --> bb0_terminal(["While"])
47 end
48 subgraph bb1
49 bb1_instrs["
50 - [2] Const mutate $3 = 10
51 - [3] Const mutate $4 = Binary read x$1 < read $3
50 + [2] Const mutate $3_@1 = 10
51 + [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1
52 "]
53 - bb1_instrs --> bb1_terminal(["If (read $4)"])
53 + bb1_instrs --> bb1_terminal(["If (read $4_@2)"])
54 end
55 subgraph bb3
56 bb3_instrs["
57 - [4] Const mutate $2 = 1
58 - [5] Binary read x$1 + read $2
57 + [4] Const mutate $2_@3 = 1
58 + [5] Binary read x$1_@0 + read $2_@3
59 "]
60 bb3_instrs --> bb3_terminal(["Goto"])
61 end
62 subgraph bb2
63 - bb2_terminal(["Return read x$1"])
63 + bb2_terminal(["Return read x$1_@0"])
64 end
65
66 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md
+12 -12
@@ -17,17 +17,17 @@ function foo() {
17
18 ```
19 bb0:
20 - [1] Let mutate x$1 = 1
20 + [1] Let mutate x$1_@0 = 1
21 While test=bb1 loop=bb3 fallthrough=bb2
22 bb1:
23 predecessor blocks: bb0 bb3
24 - [2] Const mutate $3 = 10
25 - [3] Const mutate $4 = Binary read x$1 < read $3
26 - If (read $4) then:bb3 else:bb2
24 + [2] Const mutate $3_@1 = 10
25 + [3] Const mutate $4_@2 = Binary read x$1 < read $3_@1
26 + If (read $4_@2) then:bb3 else:bb2
27 bb3:
28 predecessor blocks: bb1
29 - [4] Const mutate $2 = 1
30 - [5] Reassign mutate x$1 = Binary read x$1 + read $2
29 + [4] Const mutate $2_@3 = 1
30 + [5] Reassign mutate x$1_@4 = Binary read x$1 + read $2_@3
31 Goto(Continue) bb1
32 bb2:
33 predecessor blocks: bb1
@@ -41,21 +41,21 @@ flowchart TB
41 %% Basic Blocks
42 subgraph bb0
43 bb0_instrs["
44 - [1] Let mutate x$1 = 1
44 + [1] Let mutate x$1_@0 = 1
45 "]
46 bb0_instrs --> bb0_terminal(["While"])
47 end
48 subgraph bb1
49 bb1_instrs["
50 - [2] Const mutate $3 = 10
51 - [3] Const mutate $4 = Binary read x$1 < read $3
50 + [2] Const mutate $3_@1 = 10
51 + [3] Const mutate $4_@2 = Binary read x$1 < read $3_@1
52 "]
53 - bb1_instrs --> bb1_terminal(["If (read $4)"])
53 + bb1_instrs --> bb1_terminal(["If (read $4_@2)"])
54 end
55 subgraph bb3
56 bb3_instrs["
57 - [4] Const mutate $2 = 1
58 - [5] Reassign mutate x$1 = Binary read x$1 + read $2
57 + [4] Const mutate $2_@3 = 1
58 + [5] Reassign mutate x$1_@4 = Binary read x$1 + read $2_@3
59 "]
60 bb3_instrs --> bb3_terminal(["Goto"])
61 end
compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md
+28 -28
@@ -32,31 +32,31 @@ function Component(props) {
32
33 ```
34 bb0:
35 - [1] Let mutate x$2[1:6] = Array []
36 - [2] Let mutate y$3 = undefined
37 - [3] Const mutate $4 = false
38 - [4] Const mutate $5 = true
39 - [5] Const mutate $6 = 1
35 + [1] Let mutate x$2_@0[1:6] = Array []
36 + [2] Let mutate y$3_@1 = undefined
37 + [3] Const mutate $4_@2 = false
38 + [4] Const mutate $5_@3 = true
39 + [5] Const mutate $6_@4 = 1
40 Switch (read props$1.p0)
41 - Case read $6: bb1
42 - Case read $5: bb6
41 + Case read $6_@4: bb1
42 + Case read $5_@3: bb6
43 Default: bb1
44 - Case read $4: bb2
44 + Case read $4_@2: bb2
45 bb6:
46 predecessor blocks: bb0
47 - [6] Call mutate x$2.push(read props$1.p2)
48 - [7] Reassign mutate y$3 = Array []
47 + [6] Call mutate x$2_@0.push(read props$1.p2)
48 + [7] Reassign mutate y$3_@5 = Array []
49 Goto bb1
50 bb2:
51 predecessor blocks: bb0
52 - [8] Reassign mutate y$3 = read x$2
52 + [8] Reassign mutate y$3_@6 = read x$2_@0
53 Goto bb1
54 bb1:
55 predecessor blocks: bb0 bb6 bb2
56 - [9] Const mutate child$7 = JSX <read Component$0 data={freeze x$2} ></read Component$0>
56 + [9] Const mutate child$7_@7 = JSX <read Component$0 data={freeze x$2_@0} ></read Component$0>
57 [10] Call read y$3.push(read props$1.p4)
58 - [11] Const mutate $8 = JSX <read Component$0 data={freeze y$3} >{read child$7}</read Component$0>
59 - Return read $8
58 + [11] Const mutate $8_@8 = JSX <read Component$0 data={freeze y$3} >{read child$7_@7}</read Component$0>
59 + Return read $8_@8
60 ```
61
62 ### CFG
@@ -66,41 +66,41 @@ flowchart TB
66 %% Basic Blocks
67 subgraph bb0
68 bb0_instrs["
69 - [1] Let mutate x$2[1:6] = Array []
70 - [2] Let mutate y$3 = undefined
71 - [3] Const mutate $4 = false
72 - [4] Const mutate $5 = true
73 - [5] Const mutate $6 = 1
69 + [1] Let mutate x$2_@0[1:6] = Array []
70 + [2] Let mutate y$3_@1 = undefined
71 + [3] Const mutate $4_@2 = false
72 + [4] Const mutate $5_@3 = true
73 + [5] Const mutate $6_@4 = 1
74 "]
75 bb0_instrs --> bb0_terminal(["Switch (read props$1.p0)"])
76 end
77 subgraph bb6
78 bb6_instrs["
79 - [6] Call mutate x$2.push(read props$1.p2)
80 - [7] Reassign mutate y$3 = Array []
79 + [6] Call mutate x$2_@0.push(read props$1.p2)
80 + [7] Reassign mutate y$3_@5 = Array []
81 "]
82 bb6_instrs --> bb6_terminal(["Goto"])
83 end
84 subgraph bb2
85 bb2_instrs["
86 - [8] Reassign mutate y$3 = read x$2
86 + [8] Reassign mutate y$3_@6 = read x$2_@0
87 "]
88 bb2_instrs --> bb2_terminal(["Goto"])
89 end
90 subgraph bb1
91 bb1_instrs["
92 - [9] Const mutate child$7 = JSX <read Component$0 data={freeze x$2} ></read Component$0>
92 + [9] Const mutate child$7_@7 = JSX <read Component$0 data={freeze x$2_@0} ></read Component$0>
93 [10] Call read y$3.push(read props$1.p4)
94 - [11] Const mutate $8 = JSX <read Component$0 data={freeze y$3} >{read child$7}</read Component$0>
94 + [11] Const mutate $8_@8 = JSX <read Component$0 data={freeze y$3} >{read child$7_@7}</read Component$0>
95 "]
96 - bb1_instrs --> bb1_terminal(["Return read $8"])
96 + bb1_instrs --> bb1_terminal(["Return read $8_@8"])
97 end
98
99 %% Jumps
100 - bb0_terminal -- read $6 --> bb1
101 - bb0_terminal -- read $5 --> bb6
100 + bb0_terminal -- read $6_@4 --> bb1
101 + bb0_terminal -- read $5_@3 --> bb6
102 bb0_terminal -- default --> bb1
103 - bb0_terminal -- read $4 --> bb2
103 + bb0_terminal -- read $4_@2 --> bb2
104 bb0_terminal -- fallthrough --> bb1
105 bb6_terminal --> bb1
106 bb2_terminal --> bb1
compiler/forget/src/__tests__/fixtures/hir/switch-with-fallthrough.expect.md
+38 -38
@@ -36,44 +36,44 @@ function foo(x) {
36
37 ```
38 bb0:
39 - [1] Let mutate y$2 = undefined
40 - [2] Const mutate $3 = 5
41 - [3] Const mutate $4 = 4
42 - [4] Const mutate $5 = 3
43 - [5] Const mutate $6 = 2
44 - [6] Const mutate $7 = 1
45 - [7] Const mutate $8 = 0
39 + [1] Let mutate y$2_@0 = undefined
40 + [2] Const mutate $3_@1 = 5
41 + [3] Const mutate $4_@2 = 4
42 + [4] Const mutate $5_@3 = 3
43 + [5] Const mutate $6_@4 = 2
44 + [6] Const mutate $7_@5 = 1
45 + [7] Const mutate $8_@6 = 0
46 Switch (read x$1)
47 - Case read $8: bb10
48 - Case read $7: bb9
49 - Case read $6: bb1
50 - Case read $5: bb5
51 - Case read $4: bb4
52 - Case read $3: bb3
47 + Case read $8_@6: bb10
48 + Case read $7_@5: bb9
49 + Case read $6_@4: bb1
50 + Case read $5_@3: bb5
51 + Case read $4_@2: bb4
52 + Case read $3_@1: bb3
53 Default: bb2
54 bb10:
55 predecessor blocks: bb0
56 - [8] Reassign mutate y$2 = 0
56 + [8] Reassign mutate y$2_@7 = 0
57 Goto bb9
58 bb9:
59 predecessor blocks: bb10 bb0
60 - [9] Reassign mutate y$2 = 1
60 + [9] Reassign mutate y$2_@8 = 1
61 Goto bb1
62 bb5:
63 predecessor blocks: bb0
64 - [10] Reassign mutate y$2 = 3
64 + [10] Reassign mutate y$2_@9 = 3
65 Goto bb1
66 bb4:
67 predecessor blocks: bb0
68 - [11] Reassign mutate y$2 = 4
68 + [11] Reassign mutate y$2_@10 = 4
69 Goto bb3
70 bb3:
71 predecessor blocks: bb4 bb0
72 - [12] Reassign mutate y$2 = 5
72 + [12] Reassign mutate y$2_@11 = 5
73 Goto bb2
74 bb2:
75 predecessor blocks: bb3 bb0
76 - [13] Reassign mutate y$2 = 0
76 + [13] Reassign mutate y$2_@12 = 0
77 Goto bb1
78 bb1:
79 predecessor blocks: bb9 bb0 bb5 bb2
@@ -87,49 +87,49 @@ flowchart TB
87 %% Basic Blocks
88 subgraph bb0
89 bb0_instrs["
90 - [1] Let mutate y$2 = undefined
91 - [2] Const mutate $3 = 5
92 - [3] Const mutate $4 = 4
93 - [4] Const mutate $5 = 3
94 - [5] Const mutate $6 = 2
95 - [6] Const mutate $7 = 1
96 - [7] Const mutate $8 = 0
90 + [1] Let mutate y$2_@0 = undefined
91 + [2] Const mutate $3_@1 = 5
92 + [3] Const mutate $4_@2 = 4
93 + [4] Const mutate $5_@3 = 3
94 + [5] Const mutate $6_@4 = 2
95 + [6] Const mutate $7_@5 = 1
96 + [7] Const mutate $8_@6 = 0
97 "]
98 bb0_instrs --> bb0_terminal(["Switch (read x$1)"])
99 end
100 subgraph bb10
101 bb10_instrs["
102 - [8] Reassign mutate y$2 = 0
102 + [8] Reassign mutate y$2_@7 = 0
103 "]
104 bb10_instrs --> bb10_terminal(["Goto"])
105 end
106 subgraph bb9
107 bb9_instrs["
108 - [9] Reassign mutate y$2 = 1
108 + [9] Reassign mutate y$2_@8 = 1
109 "]
110 bb9_instrs --> bb9_terminal(["Goto"])
111 end
112 subgraph bb5
113 bb5_instrs["
114 - [10] Reassign mutate y$2 = 3
114 + [10] Reassign mutate y$2_@9 = 3
115 "]
116 bb5_instrs --> bb5_terminal(["Goto"])
117 end
118 subgraph bb4
119 bb4_instrs["
120 - [11] Reassign mutate y$2 = 4
120 + [11] Reassign mutate y$2_@10 = 4
121 "]
122 bb4_instrs --> bb4_terminal(["Goto"])
123 end
124 subgraph bb3
125 bb3_instrs["
126 - [12] Reassign mutate y$2 = 5
126 + [12] Reassign mutate y$2_@11 = 5
127 "]
128 bb3_instrs --> bb3_terminal(["Goto"])
129 end
130 subgraph bb2
131 bb2_instrs["
132 - [13] Reassign mutate y$2 = 0
132 + [13] Reassign mutate y$2_@12 = 0
133 "]
134 bb2_instrs --> bb2_terminal(["Goto"])
135 end
@@ -138,12 +138,12 @@ flowchart TB
138 end
139
140 %% Jumps
141 - bb0_terminal -- read $8 --> bb10
142 - bb0_terminal -- read $7 --> bb9
143 - bb0_terminal -- read $6 --> bb1
144 - bb0_terminal -- read $5 --> bb5
145 - bb0_terminal -- read $4 --> bb4
146 - bb0_terminal -- read $3 --> bb3
141 + bb0_terminal -- read $8_@6 --> bb10
142 + bb0_terminal -- read $7_@5 --> bb9
143 + bb0_terminal -- read $6_@4 --> bb1
144 + bb0_terminal -- read $5_@3 --> bb5
145 + bb0_terminal -- read $4_@2 --> bb4
146 + bb0_terminal -- read $3_@1 --> bb3
147 bb0_terminal -- default --> bb2
148 bb0_terminal -- fallthrough --> bb1
149 bb10_terminal --> bb9
compiler/forget/src/__tests__/fixtures/hir/switch.expect.md
+26 -26
@@ -28,30 +28,30 @@ function Component(props) {
28
29 ```
30 bb0:
31 - [1] Let mutate x$2[1:6] = Array []
32 - [2] Let mutate y$3 = undefined
33 - [3] Const mutate $4 = false
34 - [4] Const mutate $5 = true
31 + [1] Let mutate x$2_@0[1:6] = Array []
32 + [2] Let mutate y$3_@1 = undefined
33 + [3] Const mutate $4_@2 = false
34 + [4] Const mutate $5_@3 = true
35 Switch (read props$1.p0)
36 - Case read $5: bb4
37 - Case read $4: bb2
36 + Case read $5_@3: bb4
37 + Case read $4_@2: bb2
38 Default: bb1
39 bb4:
40 predecessor blocks: bb0
41 - [5] Call mutate x$2.push(read props$1.p2)
42 - [6] Call mutate x$2.push(read props$1.p3)
43 - [7] Reassign mutate y$3 = Array []
41 + [5] Call mutate x$2_@0.push(read props$1.p2)
42 + [6] Call mutate x$2_@0.push(read props$1.p3)
43 + [7] Reassign mutate y$3_@4 = Array []
44 Goto bb2
45 bb2:
46 predecessor blocks: bb4 bb0
47 - [8] Reassign mutate y$3 = read x$2
47 + [8] Reassign mutate y$3_@5 = read x$2_@0
48 Goto bb1
49 bb1:
50 predecessor blocks: bb2 bb0
51 - [9] Const mutate child$6 = JSX <read Component$0 data={freeze x$2} ></read Component$0>
51 + [9] Const mutate child$6_@6 = JSX <read Component$0 data={freeze x$2_@0} ></read Component$0>
52 [10] Call read y$3.push(read props$1.p4)
53 - [11] Const mutate $7 = JSX <read Component$0 data={read y$3} >{read child$6}</read Component$0>
54 - Return read $7
53 + [11] Const mutate $7_@7 = JSX <read Component$0 data={read y$3} >{read child$6_@6}</read Component$0>
54 + Return read $7_@7
55 ```
56
57 ### CFG
@@ -61,39 +61,39 @@ flowchart TB
61 %% Basic Blocks
62 subgraph bb0
63 bb0_instrs["
64 - [1] Let mutate x$2[1:6] = Array []
65 - [2] Let mutate y$3 = undefined
66 - [3] Const mutate $4 = false
67 - [4] Const mutate $5 = true
64 + [1] Let mutate x$2_@0[1:6] = Array []
65 + [2] Let mutate y$3_@1 = undefined
66 + [3] Const mutate $4_@2 = false
67 + [4] Const mutate $5_@3 = true
68 "]
69 bb0_instrs --> bb0_terminal(["Switch (read props$1.p0)"])
70 end
71 subgraph bb4
72 bb4_instrs["
73 - [5] Call mutate x$2.push(read props$1.p2)
74 - [6] Call mutate x$2.push(read props$1.p3)
75 - [7] Reassign mutate y$3 = Array []
73 + [5] Call mutate x$2_@0.push(read props$1.p2)
74 + [6] Call mutate x$2_@0.push(read props$1.p3)
75 + [7] Reassign mutate y$3_@4 = Array []
76 "]
77 bb4_instrs --> bb4_terminal(["Goto"])
78 end
79 subgraph bb2
80 bb2_instrs["
81 - [8] Reassign mutate y$3 = read x$2
81 + [8] Reassign mutate y$3_@5 = read x$2_@0
82 "]
83 bb2_instrs --> bb2_terminal(["Goto"])
84 end
85 subgraph bb1
86 bb1_instrs["
87 - [9] Const mutate child$6 = JSX <read Component$0 data={freeze x$2} ></read Component$0>
87 + [9] Const mutate child$6_@6 = JSX <read Component$0 data={freeze x$2_@0} ></read Component$0>
88 [10] Call read y$3.push(read props$1.p4)
89 - [11] Const mutate $7 = JSX <read Component$0 data={read y$3} >{read child$6}</read Component$0>
89 + [11] Const mutate $7_@7 = JSX <read Component$0 data={read y$3} >{read child$6_@6}</read Component$0>
90 "]
91 - bb1_instrs --> bb1_terminal(["Return read $7"])
91 + bb1_instrs --> bb1_terminal(["Return read $7_@7"])
92 end
93
94 %% Jumps
95 - bb0_terminal -- read $5 --> bb4
96 - bb0_terminal -- read $4 --> bb2
95 + bb0_terminal -- read $5_@3 --> bb4
96 + bb0_terminal -- read $4_@2 --> bb2
97 bb0_terminal -- default --> bb1
98 bb0_terminal -- fallthrough --> bb1
99 bb4_terminal --> bb2
compiler/forget/src/__tests__/hir-test.ts
+2
@@ -21,6 +21,7 @@ import enterSSA from "../HIR/EnterSSA";
21 import { HIRFunction } from "../HIR/HIR";
22 import { Environment } from "../HIR/HIRBuilder";
23 import { inferMutableRanges } from "../HIR/InferMutableLifetimes";
24 +import { inferReactiveScopeVariables } from "../HIR/InferReactiveScopeVariables";
25 import inferReferenceEffects from "../HIR/InferReferenceEffects";
26 import leaveSSA from "../HIR/LeaveSSA";
27 import printHIR from "../HIR/PrintHIR";
@@ -70,6 +71,7 @@ describe("React Forget (HIR version)", () => {
71 eliminateRedundantPhi(ir);
72 inferReferenceEffects(ir);
73 inferMutableRanges(ir);
74 + inferReactiveScopeVariables(ir);
75 leaveSSA(ir);
76 const textHIR = printHIR(ir.body);
77 const visualization = visualizeHIRMermaid(ir);