@samitouri / QOS-React-2 / commits / d9c6d61192

[test] Print HIR before leaving SSA

Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react-forget/pull/812). * __->__ #812 [test] Print HIR before leaving SSA Looking at the HIR before it leaves SSA helps debugging better.

Sathya Gunasekaran committed Nov 22, 2022 at 17:59 UTC d9c6d611921b252a539872e9640d04c00e51a82b
60 files changed +1144 -1103
compiler/forget/src/__tests__/fixtures/hir/alias-while.expect.md
+29 -26
@@ -27,27 +27,30 @@ function mutate(x, y) {}
27
28 ```
29 bb0:
30 - [1] Let mutate a$2_@0[0:12] = Object { }
31 - [2] Let mutate b$3_@0[0:11] = Object { }
32 - [3] Let mutate c$4_@0[0:11] = Object { }
30 + [1] Let mutate a$8_@0[0:12] = Object { }
31 + [2] Let mutate b$9_@0[0:11] = Object { }
32 + [3] Let mutate c$10_@0[0:11] = Object { }
33 [4] While test=bb1 loop=bb3 fallthrough=bb2
34 bb1:
35 predecessor blocks: bb0 bb3
36 - [5] If (read cond$1) then:bb3 else:bb2
36 + a$12_@0[0:11]: phi(bb0: a$8_@0, bb3: a$15_@0)
37 + b$14_@0[0:11]: phi(bb0: b$9_@0, bb3: b$17_@0)
38 + c$16_@0[0:11]: phi(bb0: c$10_@0, bb3: c$18_@0)
39 + [5] If (read cond$7) then:bb3 else:bb2
40 bb3:
41 predecessor blocks: bb1
39 - [6] Let mutate z$5_@0[0:11] = read a$2_@0
40 - [7] Reassign mutate a$2_@0[0:11] = read b$3_@0
41 - [8] Reassign mutate b$3_@0[0:11] = read c$4_@0
42 - [9] Reassign mutate c$4_@0[0:11] = read z$5_@0
43 - [10] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0)
42 + [6] Let mutate z$13_@0[0:11] = read a$12_@0
43 + [7] Reassign mutate a$15_@0[0:11] = read b$14_@0
44 + [8] Reassign mutate b$17_@0[0:11] = read c$16_@0
45 + [9] Reassign mutate c$18_@0[0:11] = read z$13_@0
46 + [10] Call mutate mutate$6_@0(mutate a$15_@0, mutate b$17_@0)
47 [11] Goto(Continue) bb1
48 bb2:
49 predecessor blocks: bb1
47 - [12] read a$2_@0
48 - [13] read b$3_@0
49 - [14] read c$4_@0
50 - [15] Return freeze a$2_@0
50 + [12] read a$12_@0
51 + [13] read b$14_@0
52 + [14] read c$16_@0
53 + [15] Return freeze a$12_@0
54 ```
55
56 ### CFG
@@ -57,32 +60,32 @@ flowchart TB
60 %% Basic Blocks
61 subgraph bb0
62 bb0_instrs["
60 - [1] Let mutate a$2_@0[0:12] = Object { }
61 - [2] Let mutate b$3_@0[0:11] = Object { }
62 - [3] Let mutate c$4_@0[0:11] = Object { }
63 + [1] Let mutate a$8_@0[0:12] = Object { }
64 + [2] Let mutate b$9_@0[0:11] = Object { }
65 + [3] Let mutate c$10_@0[0:11] = Object { }
66 "]
67 bb0_instrs --> bb0_terminal(["While"])
68 end
69 subgraph bb1
67 - bb1_terminal(["If (read cond$1)"])
70 + bb1_terminal(["If (read cond$7)"])
71 end
72 subgraph bb3
73 bb3_instrs["
71 - [6] Let mutate z$5_@0[0:11] = read a$2_@0
72 - [7] Reassign mutate a$2_@0[0:11] = read b$3_@0
73 - [8] Reassign mutate b$3_@0[0:11] = read c$4_@0
74 - [9] Reassign mutate c$4_@0[0:11] = read z$5_@0
75 - [10] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0)
74 + [6] Let mutate z$13_@0[0:11] = read a$12_@0
75 + [7] Reassign mutate a$15_@0[0:11] = read b$14_@0
76 + [8] Reassign mutate b$17_@0[0:11] = read c$16_@0
77 + [9] Reassign mutate c$18_@0[0:11] = read z$13_@0
78 + [10] Call mutate mutate$6_@0(mutate a$15_@0, mutate b$17_@0)
79 "]
80 bb3_instrs --> bb3_terminal(["Goto"])
81 end
82 subgraph bb2
83 bb2_instrs["
81 - [12] read a$2_@0
82 - [13] read b$3_@0
83 - [14] read c$4_@0
84 + [12] read a$12_@0
85 + [13] read b$14_@0
86 + [14] read c$16_@0
87 "]
85 - bb2_instrs --> bb2_terminal(["Return freeze a$2_@0"])
88 + bb2_instrs --> bb2_terminal(["Return freeze a$12_@0"])
89 end
90
91 %% Jumps
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_@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
23 + [1] Let mutate x$5_@0 = 1
24 + [2] Const mutate $6_@1 = 1
25 + [3] Reassign mutate x$7_@2 = Binary read x$5_@0 + read $6_@1
26 + [4] Const mutate $8_@3 = 1
27 + [5] Reassign mutate x$9_@4 = Binary read x$7_@2 + read $8_@3
28 + [6] Const mutate $10_@5 = 1
29 + [7] Reassign mutate x$11_@6 = Binary read x$9_@4 >>> read $10_@5
30 [8] Return
31 ```
32
@@ -37,13 +37,13 @@ flowchart TB
37 %% Basic Blocks
38 subgraph bb0
39 bb0_instrs["
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
40 + [1] Let mutate x$5_@0 = 1
41 + [2] Const mutate $6_@1 = 1
42 + [3] Reassign mutate x$7_@2 = Binary read x$5_@0 + read $6_@1
43 + [4] Const mutate $8_@3 = 1
44 + [5] Reassign mutate x$9_@4 = Binary read x$7_@2 + read $8_@3
45 + [6] Const mutate $10_@5 = 1
46 + [7] Reassign mutate x$11_@6 = Binary read x$9_@4 >>> read $10_@5
47 "]
48 bb0_instrs --> bb0_terminal(["Return"])
49 end
@@ -67,10 +67,10 @@ function f$0() {
67
68 ```
69 bb0:
70 - [1] Const mutate $2_@0 = 1
71 - [2] Reassign mutate a$1_@1.b.c[0:5] = Binary read a$1_@1.b.c + read $2_@0
72 - [3] Const mutate $3_@2 = 2
73 - [4] Reassign mutate a$1_@1.b.c[0:5] = Binary read a$1_@1.b.c * read $3_@2
70 + [1] Const mutate $5_@0 = 1
71 + [2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0
72 + [3] Const mutate $6_@2 = 2
73 + [4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2
74 [5] Return
75 ```
76
@@ -81,10 +81,10 @@ flowchart TB
81 %% Basic Blocks
82 subgraph bb0
83 bb0_instrs["
84 - [1] Const mutate $2_@0 = 1
85 - [2] Reassign mutate a$1_@1.b.c[0:5] = Binary read a$1_@1.b.c + read $2_@0
86 - [3] Const mutate $3_@2 = 2
87 - [4] Reassign mutate a$1_@1.b.c[0:5] = Binary read a$1_@1.b.c * read $3_@2
84 + [1] Const mutate $5_@0 = 1
85 + [2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0
86 + [3] Const mutate $6_@2 = 2
87 + [4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2
88 "]
89 bb0_instrs --> bb0_terminal(["Return"])
90 end
compiler/forget/src/__tests__/fixtures/hir/call.expect.md
+18 -18
@@ -45,15 +45,15 @@ function foo$0() {}
45
46 ```
47 bb0:
48 - [1] Const mutate a$2_@0[0:7] = Array []
49 - [2] Const mutate b$3_@0[0:7] = Object { }
50 - [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
51 - [4] Const mutate $6_@1 = "div"
52 - [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
53 - [6] Call mutate foo$4_@0(mutate b$3_@0)
54 - [7] Const mutate $7_@3 = "div"
55 - [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
56 - [9] Return read $8_@4
48 + [1] Const mutate a$10_@0[0:7] = Array []
49 + [2] Const mutate b$11_@0[0:7] = Object { }
50 + [3] Call mutate foo$4_@0(mutate a$10_@0, mutate b$11_@0)
51 + [4] Const mutate $12_@1 = "div"
52 + [5] Let mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
53 + [6] Call mutate foo$4_@0(mutate b$11_@0)
54 + [7] Const mutate $14_@3 = "div"
55 + [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
56 + [9] Return read $15_@4
57 ```
58
59 ### CFG
@@ -63,16 +63,16 @@ flowchart TB
63 %% Basic Blocks
64 subgraph bb0
65 bb0_instrs["
66 - [1] Const mutate a$2_@0[0:7] = Array []
67 - [2] Const mutate b$3_@0[0:7] = Object { }
68 - [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
69 - [4] Const mutate $6_@1 = 'div'
70 - [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
71 - [6] Call mutate foo$4_@0(mutate b$3_@0)
72 - [7] Const mutate $7_@3 = 'div'
73 - [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
66 + [1] Const mutate a$10_@0[0:7] = Array []
67 + [2] Const mutate b$11_@0[0:7] = Object { }
68 + [3] Call mutate foo$4_@0(mutate a$10_@0, mutate b$11_@0)
69 + [4] Const mutate $12_@1 = 'div'
70 + [5] Let mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
71 + [6] Call mutate foo$4_@0(mutate b$11_@0)
72 + [7] Const mutate $14_@3 = 'div'
73 + [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
74 "]
75 - bb0_instrs --> bb0_terminal(["Return read $8_@4"])
75 + bb0_instrs --> bb0_terminal(["Return read $15_@4"])
76 end
77
78 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/complex-while.expect.md
+6 -6
@@ -18,16 +18,16 @@ function foo(a, b, c) {
18
19 ```
20 bb0:
21 - [1] If (read a$1) then:bb3 else:bb1
21 + [1] If (read a$4) then:bb3 else:bb1
22 bb3:
23 predecessor blocks: bb0
24 [2] While test=bb4 loop=bb6 fallthrough=bb1
25 bb4:
26 predecessor blocks: bb3 bb7
27 - [3] If (read b$2) then:bb6 else:bb1
27 + [3] If (read b$5) then:bb6 else:bb1
28 bb6:
29 predecessor blocks: bb4
30 - [4] If (read c$3) then:bb1 else:bb7
30 + [4] If (read c$6) then:bb1 else:bb7
31 bb7:
32 predecessor blocks: bb6
33 [5] Goto(Continue) bb4
@@ -42,16 +42,16 @@ bb1:
42 flowchart TB
43 %% Basic Blocks
44 subgraph bb0
45 - bb0_terminal(["If (read a$1)"])
45 + bb0_terminal(["If (read a$4)"])
46 end
47 subgraph bb3
48 bb3_terminal(["While"])
49 end
50 subgraph bb4
51 - bb4_terminal(["If (read b$2)"])
51 + bb4_terminal(["If (read b$5)"])
52 end
53 subgraph bb6
54 - bb6_terminal(["If (read c$3)"])
54 + bb6_terminal(["If (read c$6)"])
55 end
56 subgraph bb7
57 bb7_terminal(["Goto"])
compiler/forget/src/__tests__/fixtures/hir/component.expect.md
+59 -58
@@ -35,58 +35,59 @@ function Component(props) {
35
36 ```
37 bb0:
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:22] = Array []
41 - [4] Const mutate seen$5_@3[0:19] = New mutate Set$6_@3()
42 - [5] Const mutate $9_@4 = 0
43 - [6] Const mutate max$7_@5[0:7] = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1)
38 + [1] Const mutate items$27_@0 = read props$26.items
39 + [2] Const mutate maxItems$28_@1 = read props$26.maxItems
40 + [3] Const mutate renderedItems$29_@2[3:22] = Array []
41 + [4] Const mutate seen$30_@3[0:19] = New mutate Set$6_@3()
42 + [5] Const mutate $31_@4 = 0
43 + [6] Const mutate max$32_@5[0:7] = Call mutate Math$8_@5.max(read $31_@4, read maxItems$28_@1)
44 [7] Goto bb1
45 bb1:
46 predecessor blocks: bb0 bb5 bb10
47 - [8] If (read items$2_@0) then:bb3 else:bb2
47 + [8] If (read items$27_@0) then:bb3 else:bb2
48 bb3:
49 predecessor blocks: bb1
50 - [9] Const mutate $11_@6 = null
51 - [10] Const mutate $12_@3[0:19] = Binary read item$10_@3 == read $11_@6
52 - [11] If (read $12_@3) then:bb8 else:bb9
50 + [9] Const mutate $34_@6 = null
51 + [10] Const mutate $36_@3[0:19] = Binary read item$10_@3 == read $34_@6
52 + [11] If (read $36_@3) then:bb8 else:bb9
53 bb8:
54 predecessor blocks: bb3
55 - [12] Const mutate $13_@3[0:19] = read $12_@3
55 + [12] Const mutate $37_@3[0:19] = read $36_@3
56 [13] Goto bb7
57 bb9:
58 predecessor blocks: bb3
59 - [14] Const mutate $13_@3[0:19] = Call mutate seen$5_@3.has(mutate item$10_@3)
59 + [14] Const mutate $39_@3[0:19] = Call mutate seen$30_@3.has(mutate item$10_@3)
60 [15] Goto bb7
61 bb7:
62 predecessor blocks: bb8 bb9
63 - [16] If (read $13_@3) then:bb5 else:bb4
63 + $40_@3[0:19]: phi(bb8: $37_@3, bb9: $39_@3)
64 + [16] If (read $40_@3) then:bb5 else:bb4
65 bb5:
66 predecessor blocks: bb7
67 [17] Goto(Continue) bb1
68 bb4:
69 predecessor blocks: bb7
69 - [18] Call mutate seen$5_@3.add(mutate item$10_@3)
70 - [19] Const mutate $14_@7 = "div"
71 - [20] Const mutate $15_@8 = JSX <read $14_@7>{read item$10_@3}</read $14_@7>
72 - [21] Call mutate renderedItems$4_@2.push(read $15_@8)
73 - [22] Const mutate $16_@9 = Binary read renderedItems$4_@2.length >= read max$7_@5
74 - [23] If (read $16_@9) then:bb2 else:bb10
70 + [18] Call mutate seen$30_@3.add(mutate item$10_@3)
71 + [19] Const mutate $43_@7 = "div"
72 + [20] Const mutate $44_@8 = JSX <read $43_@7>{read item$10_@3}</read $43_@7>
73 + [21] Call mutate renderedItems$29_@2.push(read $44_@8)
74 + [22] Const mutate $49_@9 = Binary read renderedItems$29_@2.length >= read max$32_@5
75 + [23] If (read $49_@9) then:bb2 else:bb10
76 bb10:
77 predecessor blocks: bb4
78 [24] Goto(Continue) bb1
79 bb2:
80 predecessor blocks: bb4 bb1
80 - [25] Const mutate count$17_@10 = read renderedItems$4_@2.length
81 - [26] Const mutate $18_@11 = "div"
82 - [27] Const mutate $19_@12 = "\n "
83 - [28] Const mutate $20_@13 = "h1"
84 - [29] Const mutate $21_@14 = " Items"
85 - [30] Const mutate $22_@15 = JSX <read $20_@13>{freeze count$17_@10}{read $21_@14}</read $20_@13>
86 - [31] Const mutate $23_@16 = "\n "
87 - [32] Const mutate $24_@17 = "\n "
88 - [33] Const mutate $25_@18 = JSX <read $18_@11>{read $19_@12}{read $22_@15}{read $23_@16}{freeze renderedItems$4_@2}{read $24_@17}</read $18_@11>
89 - [34] Return read $25_@18
81 + [25] Const mutate count$52_@10 = read renderedItems$29_@2.length
82 + [26] Const mutate $53_@11 = "div"
83 + [27] Const mutate $54_@12 = "\n "
84 + [28] Const mutate $55_@13 = "h1"
85 + [29] Const mutate $56_@14 = " Items"
86 + [30] Const mutate $57_@15 = JSX <read $55_@13>{freeze count$52_@10}{read $56_@14}</read $55_@13>
87 + [31] Const mutate $58_@16 = "\n "
88 + [32] Const mutate $59_@17 = "\n "
89 + [33] Const mutate $60_@18 = JSX <read $53_@11>{read $54_@12}{read $57_@15}{read $58_@16}{freeze renderedItems$29_@2}{read $59_@17}</read $53_@11>
90 + [34] Return read $60_@18
91 ```
92
93 ### CFG
@@ -96,69 +97,69 @@ flowchart TB
97 %% Basic Blocks
98 subgraph bb0
99 bb0_instrs["
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:22] = Array []
102 - [4] Const mutate seen$5_@3[0:19] = New mutate Set$6_@3()
103 - [5] Const mutate $9_@4 = 0
104 - [6] Const mutate max$7_@5[0:7] = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1)
100 + [1] Const mutate items$27_@0 = read props$26.items
101 + [2] Const mutate maxItems$28_@1 = read props$26.maxItems
102 + [3] Const mutate renderedItems$29_@2[3:22] = Array []
103 + [4] Const mutate seen$30_@3[0:19] = New mutate Set$6_@3()
104 + [5] Const mutate $31_@4 = 0
105 + [6] Const mutate max$32_@5[0:7] = Call mutate Math$8_@5.max(read $31_@4, read maxItems$28_@1)
106 "]
107 bb0_instrs --> bb0_terminal(["Goto"])
108 end
109 subgraph bb1
109 - bb1_terminal(["If (read items$2_@0)"])
110 + bb1_terminal(["If (read items$27_@0)"])
111 end
112 subgraph bb3
113 bb3_instrs["
113 - [9] Const mutate $11_@6 = null
114 - [10] Const mutate $12_@3[0:19] = Binary read item$10_@3 == read $11_@6
114 + [9] Const mutate $34_@6 = null
115 + [10] Const mutate $36_@3[0:19] = Binary read item$10_@3 == read $34_@6
116 "]
116 - bb3_instrs --> bb3_terminal(["If (read $12_@3)"])
117 + bb3_instrs --> bb3_terminal(["If (read $36_@3)"])
118 end
119 subgraph bb8
120 bb8_instrs["
120 - [12] Const mutate $13_@3[0:19] = read $12_@3
121 + [12] Const mutate $37_@3[0:19] = read $36_@3
122 "]
123 bb8_instrs --> bb8_terminal(["Goto"])
124 end
125 subgraph bb9
126 bb9_instrs["
126 - [14] Const mutate $13_@3[0:19] = Call mutate seen$5_@3.has(mutate item$10_@3)
127 + [14] Const mutate $39_@3[0:19] = Call mutate seen$30_@3.has(mutate item$10_@3)
128 "]
129 bb9_instrs --> bb9_terminal(["Goto"])
130 end
131 subgraph bb7
131 - bb7_terminal(["If (read $13_@3)"])
132 + bb7_terminal(["If (read $40_@3)"])
133 end
134 subgraph bb5
135 bb5_terminal(["Goto"])
136 end
137 subgraph bb4
138 bb4_instrs["
138 - [18] Call mutate seen$5_@3.add(mutate item$10_@3)
139 - [19] Const mutate $14_@7 = 'div'
140 - [20] Const mutate $15_@8 = JSX <read $14_@7>{read item$10_@3}</read $14_@7>
141 - [21] Call mutate renderedItems$4_@2.push(read $15_@8)
142 - [22] Const mutate $16_@9 = Binary read renderedItems$4_@2.length >= read max$7_@5
139 + [18] Call mutate seen$30_@3.add(mutate item$10_@3)
140 + [19] Const mutate $43_@7 = 'div'
141 + [20] Const mutate $44_@8 = JSX <read $43_@7>{read item$10_@3}</read $43_@7>
142 + [21] Call mutate renderedItems$29_@2.push(read $44_@8)
143 + [22] Const mutate $49_@9 = Binary read renderedItems$29_@2.length >= read max$32_@5
144 "]
144 - bb4_instrs --> bb4_terminal(["If (read $16_@9)"])
145 + bb4_instrs --> bb4_terminal(["If (read $49_@9)"])
146 end
147 subgraph bb10
148 bb10_terminal(["Goto"])
149 end
150 subgraph bb2
151 bb2_instrs["
151 - [25] Const mutate count$17_@10 = read renderedItems$4_@2.length
152 - [26] Const mutate $18_@11 = 'div'
153 - [27] Const mutate $19_@12 = '\n '
154 - [28] Const mutate $20_@13 = 'h1'
155 - [29] Const mutate $21_@14 = ' Items'
156 - [30] Const mutate $22_@15 = JSX <read $20_@13>{freeze count$17_@10}{read $21_@14}</read $20_@13>
157 - [31] Const mutate $23_@16 = '\n '
158 - [32] Const mutate $24_@17 = '\n '
159 - [33] Const mutate $25_@18 = JSX <read $18_@11>{read $19_@12}{read $22_@15}{read $23_@16}{freeze renderedItems$4_@2}{read $24_@17}</read $18_@11>
152 + [25] Const mutate count$52_@10 = read renderedItems$29_@2.length
153 + [26] Const mutate $53_@11 = 'div'
154 + [27] Const mutate $54_@12 = '\n '
155 + [28] Const mutate $55_@13 = 'h1'
156 + [29] Const mutate $56_@14 = ' Items'
157 + [30] Const mutate $57_@15 = JSX <read $55_@13>{freeze count$52_@10}{read $56_@14}</read $55_@13>
158 + [31] Const mutate $58_@16 = '\n '
159 + [32] Const mutate $59_@17 = '\n '
160 + [33] Const mutate $60_@18 = JSX <read $53_@11>{read $54_@12}{read $57_@15}{read $58_@16}{freeze renderedItems$29_@2}{read $59_@17}</read $53_@11>
161 "]
161 - bb2_instrs --> bb2_terminal(["Return read $25_@18"])
162 + bb2_instrs --> bb2_terminal(["Return read $60_@18"])
163 end
164
165 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md
+68 -68
@@ -78,17 +78,17 @@ function Component(props) {
78
79 ```
80 bb0:
81 - [1] Const mutate a_DEBUG$2_@0[1:7] = Array []
82 - [2] Call mutate a_DEBUG$2_@0.push(read props$1.a)
83 - [3] If (read props$1.b) then:bb2 else:bb1
81 + [1] Const mutate a_DEBUG$5_@0[1:7] = Array []
82 + [2] Call mutate a_DEBUG$5_@0.push(read props$4.a)
83 + [3] If (read props$4.b) then:bb2 else:bb1
84 bb2:
85 predecessor blocks: bb0
86 - [4] Const mutate $3_@1 = null
87 - [5] Return read $3_@1
86 + [4] Const mutate $6_@1 = null
87 + [5] Return read $6_@1
88 bb1:
89 predecessor blocks: bb0
90 - [6] Call mutate a_DEBUG$2_@0.push(read props$1.d)
91 - [7] Return freeze a_DEBUG$2_@0
90 + [6] Call mutate a_DEBUG$5_@0.push(read props$4.d)
91 + [7] Return freeze a_DEBUG$5_@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_@0[1:7] = Array []
102 - [2] Call mutate a_DEBUG$2_@0.push(read props$1.a)
101 + [1] Const mutate a_DEBUG$5_@0[1:7] = Array []
102 + [2] Call mutate a_DEBUG$5_@0.push(read props$4.a)
103 "]
104 - bb0_instrs --> bb0_terminal(["If (read props$1.b)"])
104 + bb0_instrs --> bb0_terminal(["If (read props$4.b)"])
105 end
106 subgraph bb2
107 bb2_instrs["
108 - [4] Const mutate $3_@1 = null
108 + [4] Const mutate $6_@1 = null
109 "]
110 - bb2_instrs --> bb2_terminal(["Return read $3_@1"])
110 + bb2_instrs --> bb2_terminal(["Return read $6_@1"])
111 end
112 subgraph bb1
113 bb1_instrs["
114 - [6] Call mutate a_DEBUG$2_@0.push(read props$1.d)
114 + [6] Call mutate a_DEBUG$5_@0.push(read props$4.d)
115 "]
116 - bb1_instrs --> bb1_terminal(["Return freeze a_DEBUG$2_@0"])
116 + bb1_instrs --> bb1_terminal(["Return freeze a_DEBUG$5_@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_@0[1:7] = Array []
145 - [2] Call mutate a$2_@0.push(read props$1.a)
146 - [3] If (read props$1.b) then:bb2 else:bb1
144 + [1] Const mutate a$4_@0[1:7] = Array []
145 + [2] Call mutate a$4_@0.push(read props$3.a)
146 + [3] If (read props$3.b) then:bb2 else:bb1
147 bb2:
148 predecessor blocks: bb0
149 - [4] Call mutate a$2_@0.push(read props$1.c)
149 + [4] Call mutate a$4_@0.push(read props$3.c)
150 [5] Goto bb1
151 bb1:
152 predecessor blocks: bb2 bb0
153 - [6] Call mutate a$2_@0.push(read props$1.d)
154 - [7] Return freeze a$2_@0
153 + [6] Call mutate a$4_@0.push(read props$3.d)
154 + [7] Return freeze a$4_@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_@0[1:7] = Array []
165 - [2] Call mutate a$2_@0.push(read props$1.a)
164 + [1] Const mutate a$4_@0[1:7] = Array []
165 + [2] Call mutate a$4_@0.push(read props$3.a)
166 "]
167 - bb0_instrs --> bb0_terminal(["If (read props$1.b)"])
167 + bb0_instrs --> bb0_terminal(["If (read props$3.b)"])
168 end
169 subgraph bb2
170 bb2_instrs["
171 - [4] Call mutate a$2_@0.push(read props$1.c)
171 + [4] Call mutate a$4_@0.push(read props$3.c)
172 "]
173 bb2_instrs --> bb2_terminal(["Goto"])
174 end
175 subgraph bb1
176 bb1_instrs["
177 - [6] Call mutate a$2_@0.push(read props$1.d)
177 + [6] Call mutate a$4_@0.push(read props$3.d)
178 "]
179 - bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"])
179 + bb1_instrs --> bb1_terminal(["Return freeze a$4_@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_@0[1:8] = Array []
209 - [2] Call mutate a$2_@0.push(read props$1.a)
210 - [3] If (read props$1.b) then:bb2 else:bb1
208 + [1] Const mutate a$5_@0[1:8] = Array []
209 + [2] Call mutate a$5_@0.push(read props$4.a)
210 + [3] If (read props$4.b) then:bb2 else:bb1
211 bb2:
212 predecessor blocks: bb0
213 - [4] Call mutate a$2_@0.push(read props$1.c)
214 - [5] Const mutate $3_@1 = null
215 - [6] Return read $3_@1
213 + [4] Call mutate a$5_@0.push(read props$4.c)
214 + [5] Const mutate $6_@1 = null
215 + [6] Return read $6_@1
216 bb1:
217 predecessor blocks: bb0
218 - [7] Call mutate a$2_@0.push(read props$1.d)
219 - [8] Return freeze a$2_@0
218 + [7] Call mutate a$5_@0.push(read props$4.d)
219 + [8] Return freeze a$5_@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_@0[1:8] = Array []
230 - [2] Call mutate a$2_@0.push(read props$1.a)
229 + [1] Const mutate a$5_@0[1:8] = Array []
230 + [2] Call mutate a$5_@0.push(read props$4.a)
231 "]
232 - bb0_instrs --> bb0_terminal(["If (read props$1.b)"])
232 + bb0_instrs --> bb0_terminal(["If (read props$4.b)"])
233 end
234 subgraph bb2
235 bb2_instrs["
236 - [4] Call mutate a$2_@0.push(read props$1.c)
237 - [5] Const mutate $3_@1 = null
236 + [4] Call mutate a$5_@0.push(read props$4.c)
237 + [5] Const mutate $6_@1 = null
238 "]
239 - bb2_instrs --> bb2_terminal(["Return read $3_@1"])
239 + bb2_instrs --> bb2_terminal(["Return read $6_@1"])
240 end
241 subgraph bb1
242 bb1_instrs["
243 - [7] Call mutate a$2_@0.push(read props$1.d)
243 + [7] Call mutate a$5_@0.push(read props$4.d)
244 "]
245 - bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"])
245 + bb1_instrs --> bb1_terminal(["Return freeze a$5_@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_@0[1:7] = Array []
275 - [2] Call mutate a$2_@0.push(read props$1.a)
276 - [3] If (read props$1.b) then:bb2 else:bb1
274 + [1] Const mutate a$4_@0[1:7] = Array []
275 + [2] Call mutate a$4_@0.push(read props$3.a)
276 + [3] If (read props$3.b) then:bb2 else:bb1
277 bb2:
278 predecessor blocks: bb0
279 - [4] Call mutate a$2_@0.push(read props$1.c)
280 - [5] Return freeze a$2_@0
279 + [4] Call mutate a$4_@0.push(read props$3.c)
280 + [5] Return freeze a$4_@0
281 bb1:
282 predecessor blocks: bb0
283 - [6] Call mutate a$2_@0.push(read props$1.d)
284 - [7] Return freeze a$2_@0
283 + [6] Call mutate a$4_@0.push(read props$3.d)
284 + [7] Return freeze a$4_@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_@0[1:7] = Array []
295 - [2] Call mutate a$2_@0.push(read props$1.a)
294 + [1] Const mutate a$4_@0[1:7] = Array []
295 + [2] Call mutate a$4_@0.push(read props$3.a)
296 "]
297 - bb0_instrs --> bb0_terminal(["If (read props$1.b)"])
297 + bb0_instrs --> bb0_terminal(["If (read props$3.b)"])
298 end
299 subgraph bb2
300 bb2_instrs["
301 - [4] Call mutate a$2_@0.push(read props$1.c)
301 + [4] Call mutate a$4_@0.push(read props$3.c)
302 "]
303 - bb2_instrs --> bb2_terminal(["Return freeze a$2_@0"])
303 + bb2_instrs --> bb2_terminal(["Return freeze a$4_@0"])
304 end
305 subgraph bb1
306 bb1_instrs["
307 - [6] Call mutate a$2_@0.push(read props$1.d)
307 + [6] Call mutate a$4_@0.push(read props$3.d)
308 "]
309 - bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"])
309 + bb1_instrs --> bb1_terminal(["Return freeze a$4_@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_@0[1:7] = Array []
339 - [2] Call mutate a$2_@0.push(read props$1.a)
340 - [3] If (read props$1.b) then:bb1 else:bb2
338 + [1] Const mutate a$4_@0[1:7] = Array []
339 + [2] Call mutate a$4_@0.push(read props$3.a)
340 + [3] If (read props$3.b) then:bb1 else:bb2
341 bb2:
342 predecessor blocks: bb0
343 - [4] Call mutate a$2_@0.push(read props$1.c)
343 + [4] Call mutate a$4_@0.push(read props$3.c)
344 [5] Goto bb1
345 bb1:
346 predecessor blocks: bb0 bb2
347 - [6] Call mutate a$2_@0.push(read props$1.d)
348 - [7] Return freeze a$2_@0
347 + [6] Call mutate a$4_@0.push(read props$3.d)
348 + [7] Return freeze a$4_@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_@0[1:7] = Array []
359 - [2] Call mutate a$2_@0.push(read props$1.a)
358 + [1] Const mutate a$4_@0[1:7] = Array []
359 + [2] Call mutate a$4_@0.push(read props$3.a)
360 "]
361 - bb0_instrs --> bb0_terminal(["If (read props$1.b)"])
361 + bb0_instrs --> bb0_terminal(["If (read props$3.b)"])
362 end
363 subgraph bb2
364 bb2_instrs["
365 - [4] Call mutate a$2_@0.push(read props$1.c)
365 + [4] Call mutate a$4_@0.push(read props$3.c)
366 "]
367 bb2_instrs --> bb2_terminal(["Goto"])
368 end
369 subgraph bb1
370 bb1_instrs["
371 - [6] Call mutate a$2_@0.push(read props$1.d)
371 + [6] Call mutate a$4_@0.push(read props$3.d)
372 "]
373 - bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"])
373 + bb1_instrs --> bb1_terminal(["Return freeze a$4_@0"])
374 end
375
376 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md
+34 -34
@@ -67,24 +67,24 @@ function mayMutate() {}
67
68 ```
69 bb0:
70 - [1] Const mutate a$2_@0[1:6] = Array []
71 - [2] Const mutate b$3_@1[2:9] = Array []
72 - [3] If (read b$3_@1) then:bb2 else:bb1
70 + [1] Const mutate a$7_@0[1:6] = Array []
71 + [2] Const mutate b$8_@1[2:9] = Array []
72 + [3] If (read b$8_@1) then:bb2 else:bb1
73 bb2:
74 predecessor blocks: bb0
75 - [4] Call mutate a$2_@0.push(read props$1.p0)
75 + [4] Call mutate a$7_@0.push(read props$6.p0)
76 [5] Goto bb1
77 bb1:
78 predecessor blocks: bb2 bb0
79 - [6] If (read props$1.p1) then:bb4 else:bb3
79 + [6] If (read props$6.p1) then:bb4 else:bb3
80 bb4:
81 predecessor blocks: bb1
82 - [7] Call mutate b$3_@1.push(read props$1.p2)
82 + [7] Call mutate b$8_@1.push(read props$6.p2)
83 [8] Goto bb3
84 bb3:
85 predecessor blocks: bb4 bb1
86 - [9] Const mutate $5_@2 = JSX <read Foo$4 a={freeze a$2_@0} b={freeze b$3_@1} ></read Foo$4>
87 - [10] Return read $5_@2
86 + [9] Const mutate $16_@2 = JSX <read Foo$4 a={freeze a$7_@0} b={freeze b$8_@1} ></read Foo$4>
87 + [10] Return read $16_@2
88 ```
89
90 ### CFG
@@ -94,31 +94,31 @@ flowchart TB
94 %% Basic Blocks
95 subgraph bb0
96 bb0_instrs["
97 - [1] Const mutate a$2_@0[1:6] = Array []
98 - [2] Const mutate b$3_@1[2:9] = Array []
97 + [1] Const mutate a$7_@0[1:6] = Array []
98 + [2] Const mutate b$8_@1[2:9] = Array []
99 "]
100 - bb0_instrs --> bb0_terminal(["If (read b$3_@1)"])
100 + bb0_instrs --> bb0_terminal(["If (read b$8_@1)"])
101 end
102 subgraph bb2
103 bb2_instrs["
104 - [4] Call mutate a$2_@0.push(read props$1.p0)
104 + [4] Call mutate a$7_@0.push(read props$6.p0)
105 "]
106 bb2_instrs --> bb2_terminal(["Goto"])
107 end
108 subgraph bb1
109 - bb1_terminal(["If (read props$1.p1)"])
109 + bb1_terminal(["If (read props$6.p1)"])
110 end
111 subgraph bb4
112 bb4_instrs["
113 - [7] Call mutate b$3_@1.push(read props$1.p2)
113 + [7] Call mutate b$8_@1.push(read props$6.p2)
114 "]
115 bb4_instrs --> bb4_terminal(["Goto"])
116 end
117 subgraph bb3
118 bb3_instrs["
119 - [9] Const mutate $5_@2 = JSX <read Foo$4 a={freeze a$2_@0} b={freeze b$3_@1} ></read Foo$4>
119 + [9] Const mutate $16_@2 = JSX <read Foo$4 a={freeze a$7_@0} b={freeze b$8_@1} ></read Foo$4>
120 "]
121 - bb3_instrs --> bb3_terminal(["Return read $5_@2"])
121 + bb3_instrs --> bb3_terminal(["Return read $16_@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_@0[1:7] = Array []
157 - [2] Const mutate b$3_@1[0:10] = Array []
158 - [3] Const mutate $5_@1[0:9] = Call mutate mayMutate$4_@1(mutate b$3_@1)
159 - [4] If (read $5_@1) then:bb2 else:bb1
156 + [1] Const mutate a$9_@0[1:7] = Array []
157 + [2] Const mutate b$10_@1[0:10] = Array []
158 + [3] Const mutate $11_@1[0:9] = Call mutate mayMutate$4_@1(mutate b$10_@1)
159 + [4] If (read $11_@1) then:bb2 else:bb1
160 bb2:
161 predecessor blocks: bb0
162 - [5] Call mutate a$2_@0.push(read props$1.p0)
162 + [5] Call mutate a$9_@0.push(read props$8.p0)
163 [6] Goto bb1
164 bb1:
165 predecessor blocks: bb2 bb0
166 - [7] If (read props$1.p1) then:bb4 else:bb3
166 + [7] If (read props$8.p1) then:bb4 else:bb3
167 bb4:
168 predecessor blocks: bb1
169 - [8] Call mutate b$3_@1.push(read props$1.p2)
169 + [8] Call mutate b$10_@1.push(read props$8.p2)
170 [9] Goto bb3
171 bb3:
172 predecessor blocks: bb4 bb1
173 - [10] Const mutate $7_@2 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$3_@1} ></read Foo$6>
174 - [11] Return read $7_@2
173 + [10] Const mutate $19_@2 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@1} ></read Foo$6>
174 + [11] Return read $19_@2
175 ```
176
177 ### CFG
@@ -181,32 +181,32 @@ flowchart TB
181 %% Basic Blocks
182 subgraph bb0
183 bb0_instrs["
184 - [1] Const mutate a$2_@0[1:7] = Array []
185 - [2] Const mutate b$3_@1[0:10] = Array []
186 - [3] Const mutate $5_@1[0:9] = Call mutate mayMutate$4_@1(mutate b$3_@1)
184 + [1] Const mutate a$9_@0[1:7] = Array []
185 + [2] Const mutate b$10_@1[0:10] = Array []
186 + [3] Const mutate $11_@1[0:9] = Call mutate mayMutate$4_@1(mutate b$10_@1)
187 "]
188 - bb0_instrs --> bb0_terminal(["If (read $5_@1)"])
188 + bb0_instrs --> bb0_terminal(["If (read $11_@1)"])
189 end
190 subgraph bb2
191 bb2_instrs["
192 - [5] Call mutate a$2_@0.push(read props$1.p0)
192 + [5] Call mutate a$9_@0.push(read props$8.p0)
193 "]
194 bb2_instrs --> bb2_terminal(["Goto"])
195 end
196 subgraph bb1
197 - bb1_terminal(["If (read props$1.p1)"])
197 + bb1_terminal(["If (read props$8.p1)"])
198 end
199 subgraph bb4
200 bb4_instrs["
201 - [8] Call mutate b$3_@1.push(read props$1.p2)
201 + [8] Call mutate b$10_@1.push(read props$8.p2)
202 "]
203 bb4_instrs --> bb4_terminal(["Goto"])
204 end
205 subgraph bb3
206 bb3_instrs["
207 - [10] Const mutate $7_@2 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$3_@1} ></read Foo$6>
207 + [10] Const mutate $19_@2 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@1} ></read Foo$6>
208 "]
209 - bb3_instrs --> bb3_terminal(["Return read $7_@2"])
209 + bb3_instrs --> bb3_terminal(["Return read $19_@2"])
210 end
211
212 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md
+18 -18
@@ -45,15 +45,15 @@ function Foo$0() {}
45
46 ```
47 bb0:
48 - [1] Const mutate a$2_@0[0:7] = Array []
49 - [2] Const mutate b$3_@0[0:7] = Object { }
50 - [3] New mutate Foo$4_@0(mutate a$2_@0, mutate b$3_@0)
51 - [4] Const mutate $6_@1 = "div"
52 - [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
53 - [6] New mutate Foo$4_@0(mutate b$3_@0)
54 - [7] Const mutate $7_@3 = "div"
55 - [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
56 - [9] Return read $8_@4
48 + [1] Const mutate a$10_@0[0:7] = Array []
49 + [2] Const mutate b$11_@0[0:7] = Object { }
50 + [3] New mutate Foo$4_@0(mutate a$10_@0, mutate b$11_@0)
51 + [4] Const mutate $12_@1 = "div"
52 + [5] Let mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
53 + [6] New mutate Foo$4_@0(mutate b$11_@0)
54 + [7] Const mutate $14_@3 = "div"
55 + [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
56 + [9] Return read $15_@4
57 ```
58
59 ### CFG
@@ -63,16 +63,16 @@ flowchart TB
63 %% Basic Blocks
64 subgraph bb0
65 bb0_instrs["
66 - [1] Const mutate a$2_@0[0:7] = Array []
67 - [2] Const mutate b$3_@0[0:7] = Object { }
68 - [3] New mutate Foo$4_@0(mutate a$2_@0, mutate b$3_@0)
69 - [4] Const mutate $6_@1 = 'div'
70 - [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
71 - [6] New mutate Foo$4_@0(mutate b$3_@0)
72 - [7] Const mutate $7_@3 = 'div'
73 - [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
66 + [1] Const mutate a$10_@0[0:7] = Array []
67 + [2] Const mutate b$11_@0[0:7] = Object { }
68 + [3] New mutate Foo$4_@0(mutate a$10_@0, mutate b$11_@0)
69 + [4] Const mutate $12_@1 = 'div'
70 + [5] Let mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
71 + [6] New mutate Foo$4_@0(mutate b$11_@0)
72 + [7] Const mutate $14_@3 = 'div'
73 + [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
74 "]
75 - bb0_instrs --> bb0_terminal(["Return read $8_@4"])
75 + bb0_instrs --> bb0_terminal(["Return read $15_@4"])
76 end
77
78 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/extend-scopes-if.expect.md
+20 -20
@@ -23,29 +23,29 @@ function foo(a, b, c) {
23
24 ```
25 bb0:
26 - [1] Let mutate x$4_@0[1:8] = Array []
27 - [2] If (read a$1) then:bb2 else:bb1
26 + [1] Let mutate x$10_@0[1:8] = Array []
27 + [2] If (read a$7) then:bb2 else:bb1
28 bb2:
29 predecessor blocks: bb0
30 - [3] If (read b$2) then:bb4 else:bb1
30 + [3] If (read b$8) then:bb4 else:bb1
31 bb4:
32 predecessor blocks: bb2
33 - [4] If (read c$3) then:bb6 else:bb1
33 + [4] If (read c$9) then:bb6 else:bb1
34 bb6:
35 predecessor blocks: bb4
36 - [5] Const mutate $5_@1 = 0
37 - [6] Call mutate x$4_@0.push(read $5_@1)
36 + [5] Const mutate $11_@1 = 0
37 + [6] Call mutate x$10_@0.push(read $11_@1)
38 [7] Goto bb1
39 bb1:
40 predecessor blocks: bb6 bb4 bb2 bb0
41 - [8] If (read a$1.length) then:bb8 else:bb7
41 + [8] If (read a$7.length) then:bb8 else:bb7
42 bb8:
43 predecessor blocks: bb1
44 - [9] Return read a$1
44 + [9] Return read a$7
45 bb7:
46 predecessor blocks: bb1
47 - [10] Const mutate $6_@2 = null
48 - [11] Return read $6_@2
47 + [10] Const mutate $13_@2 = null
48 + [11] Return read $13_@2
49 ```
50
51 ### CFG
@@ -55,34 +55,34 @@ flowchart TB
55 %% Basic Blocks
56 subgraph bb0
57 bb0_instrs["
58 - [1] Let mutate x$4_@0[1:8] = Array []
58 + [1] Let mutate x$10_@0[1:8] = Array []
59 "]
60 - bb0_instrs --> bb0_terminal(["If (read a$1)"])
60 + bb0_instrs --> bb0_terminal(["If (read a$7)"])
61 end
62 subgraph bb2
63 - bb2_terminal(["If (read b$2)"])
63 + bb2_terminal(["If (read b$8)"])
64 end
65 subgraph bb4
66 - bb4_terminal(["If (read c$3)"])
66 + bb4_terminal(["If (read c$9)"])
67 end
68 subgraph bb6
69 bb6_instrs["
70 - [5] Const mutate $5_@1 = 0
71 - [6] Call mutate x$4_@0.push(read $5_@1)
70 + [5] Const mutate $11_@1 = 0
71 + [6] Call mutate x$10_@0.push(read $11_@1)
72 "]
73 bb6_instrs --> bb6_terminal(["Goto"])
74 end
75 subgraph bb1
76 - bb1_terminal(["If (read a$1.length)"])
76 + bb1_terminal(["If (read a$7.length)"])
77 end
78 subgraph bb8
79 - bb8_terminal(["Return read a$1"])
79 + bb8_terminal(["Return read a$7"])
80 end
81 subgraph bb7
82 bb7_instrs["
83 - [10] Const mutate $6_@2 = null
83 + [10] Const mutate $13_@2 = null
84 "]
85 - bb7_instrs --> bb7_terminal(["Return read $6_@2"])
85 + bb7_instrs --> bb7_terminal(["Return read $13_@2"])
86 end
87
88 %% 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_@0[1:3] = Array []
22 - [2] Const mutate b$2_@0[1:3] = read a$1_@0
23 - [3] Call read useFreeze$3(freeze a$1_@0)
24 - [4] Call mutate foo$4_@1(read b$2_@0)
21 + [1] Const mutate a$5_@0[1:3] = Array []
22 + [2] Const mutate b$6_@0[1:3] = read a$5_@0
23 + [3] Call read useFreeze$3(freeze a$5_@0)
24 + [4] Call mutate foo$4_@1(read b$6_@0)
25 [5] Return
26 ```
27
@@ -32,10 +32,10 @@ flowchart TB
32 %% Basic Blocks
33 subgraph bb0
34 bb0_instrs["
35 - [1] Const mutate a$1_@0[1:3] = Array []
36 - [2] Const mutate b$2_@0[1:3] = read a$1_@0
37 - [3] Call read useFreeze$3(freeze a$1_@0)
38 - [4] Call mutate foo$4_@1(read b$2_@0)
35 + [1] Const mutate a$5_@0[1:3] = Array []
36 + [2] Const mutate b$6_@0[1:3] = read a$5_@0
37 + [3] Call read useFreeze$3(freeze a$5_@0)
38 + [4] Call mutate foo$4_@1(read b$6_@0)
39 "]
40 bb0_instrs --> bb0_terminal(["Return"])
41 end
compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md
+16 -16
@@ -75,14 +75,14 @@ function foo$0() {}
75
76 ```
77 bb0:
78 - [1] Const mutate x$2_@0 = Array []
79 - [2] Const mutate y$3_@1 = Call read useFreeze$4(freeze x$2_@0)
80 - [3] Call mutate foo$5_@2(read y$3_@1, read x$2_@0)
81 - [4] Const mutate $6_@3 = "\n "
82 - [5] Const mutate $7_@4 = "\n "
83 - [6] Const mutate $8_@5 = "\n "
84 - [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>
85 - [8] Return read $9_@6
78 + [1] Const mutate x$11_@0 = Array []
79 + [2] Const mutate y$12_@1 = Call read useFreeze$4(freeze x$11_@0)
80 + [3] Call mutate foo$5_@2(read y$12_@1, read x$11_@0)
81 + [4] Const mutate $13_@3 = "\n "
82 + [5] Const mutate $14_@4 = "\n "
83 + [6] Const mutate $15_@5 = "\n "
84 + [7] Const mutate $16_@6 = JSX <read Component$0>{read $13_@3}{read x$11_@0}{read $14_@4}{read y$12_@1}{read $15_@5}</read Component$0>
85 + [8] Return read $16_@6
86 ```
87
88 ### CFG
@@ -92,15 +92,15 @@ flowchart TB
92 %% Basic Blocks
93 subgraph bb0
94 bb0_instrs["
95 - [1] Const mutate x$2_@0 = Array []
96 - [2] Const mutate y$3_@1 = Call read useFreeze$4(freeze x$2_@0)
97 - [3] Call mutate foo$5_@2(read y$3_@1, read x$2_@0)
98 - [4] Const mutate $6_@3 = '\n '
99 - [5] Const mutate $7_@4 = '\n '
100 - [6] Const mutate $8_@5 = '\n '
101 - [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>
95 + [1] Const mutate x$11_@0 = Array []
96 + [2] Const mutate y$12_@1 = Call read useFreeze$4(freeze x$11_@0)
97 + [3] Call mutate foo$5_@2(read y$12_@1, read x$11_@0)
98 + [4] Const mutate $13_@3 = '\n '
99 + [5] Const mutate $14_@4 = '\n '
100 + [6] Const mutate $15_@5 = '\n '
101 + [7] Const mutate $16_@6 = JSX <read Component$0>{read $13_@3}{read x$11_@0}{read $14_@4}{read y$12_@1}{read $15_@5}</read Component$0>
102 "]
103 - bb0_instrs --> bb0_terminal(["Return read $9_@6"])
103 + bb0_instrs --> bb0_terminal(["Return read $16_@6"])
104 end
105
106 %% 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_@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 - [5] Return read a$1_@0
22 + [1] Const mutate a$4_@0 = Array []
23 + [2] Call read useFreeze$2(freeze a$4_@0)
24 + [3] Call read useFreeze$2(read a$4_@0)
25 + [4] Call mutate call$3_@1(read a$4_@0)
26 + [5] Return read a$4_@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_@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)
36 + [1] Const mutate a$4_@0 = Array []
37 + [2] Call read useFreeze$2(freeze a$4_@0)
38 + [3] Call read useFreeze$2(read a$4_@0)
39 + [4] Call mutate call$3_@1(read a$4_@0)
40 "]
41 - bb0_instrs --> bb0_terminal(["Return read a$1_@0"])
41 + bb0_instrs --> bb0_terminal(["Return read a$4_@0"])
42 end
43
44 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md
+21 -20
@@ -26,24 +26,25 @@ function call(x) {}
26
27 ```
28 bb0:
29 - [1] Const mutate cond$2_@0 = read props$1.cond
30 - [2] Const mutate x$3_@1[2:9] = read props$1.x
31 - [3] Let mutate a$4_@2 = undefined
32 - [4] If (read cond$2_@0) then:bb2 else:bb3
29 + [1] Const mutate cond$8_@0 = read props$7.cond
30 + [2] Const mutate x$9_@1[2:9] = read props$7.x
31 + [3] Let mutate a$10_@2 = undefined
32 + [4] If (read cond$8_@0) then:bb2 else:bb3
33 bb2:
34 predecessor blocks: bb0
35 - [5] Reassign mutate a$4_@1[2:8] = read x$3_@1
35 + [5] Reassign mutate a$11_@1[2:8] = read x$9_@1
36 [6] Goto bb1
37 bb3:
38 predecessor blocks: bb0
39 - [7] Reassign mutate a$4_@1[2:8] = Array []
39 + [7] Reassign mutate a$12_@1[2:8] = Array []
40 [8] Goto bb1
41 bb1:
42 predecessor blocks: bb2 bb3
43 - [9] Call read useFreeze$5(freeze a$4_@1)
44 - [10] Call read useFreeze$5(read a$4_@1)
45 - [11] Call mutate call$6_@3(read a$4_@1)
46 - [12] Return read a$4_@1
43 + a$14_@1[2:8]: phi(bb2: a$11_@1, bb3: a$12_@1)
44 + [9] Call read useFreeze$5(freeze a$14_@1)
45 + [10] Call read useFreeze$5(read a$14_@1)
46 + [11] Call mutate call$6_@3(read a$14_@1)
47 + [12] Return read a$14_@1
48 ```
49
50 ### CFG
@@ -53,31 +54,31 @@ flowchart TB
54 %% Basic Blocks
55 subgraph bb0
56 bb0_instrs["
56 - [1] Const mutate cond$2_@0 = read props$1.cond
57 - [2] Const mutate x$3_@1[2:9] = read props$1.x
58 - [3] Let mutate a$4_@2 = undefined
57 + [1] Const mutate cond$8_@0 = read props$7.cond
58 + [2] Const mutate x$9_@1[2:9] = read props$7.x
59 + [3] Let mutate a$10_@2 = undefined
60 "]
60 - bb0_instrs --> bb0_terminal(["If (read cond$2_@0)"])
61 + bb0_instrs --> bb0_terminal(["If (read cond$8_@0)"])
62 end
63 subgraph bb2
64 bb2_instrs["
64 - [5] Reassign mutate a$4_@1[2:8] = read x$3_@1
65 + [5] Reassign mutate a$11_@1[2:8] = read x$9_@1
66 "]
67 bb2_instrs --> bb2_terminal(["Goto"])
68 end
69 subgraph bb3
70 bb3_instrs["
70 - [7] Reassign mutate a$4_@1[2:8] = Array []
71 + [7] Reassign mutate a$12_@1[2:8] = Array []
72 "]
73 bb3_instrs --> bb3_terminal(["Goto"])
74 end
75 subgraph bb1
76 bb1_instrs["
76 - [9] Call read useFreeze$5(freeze a$4_@1)
77 - [10] Call read useFreeze$5(read a$4_@1)
78 - [11] Call mutate call$6_@3(read a$4_@1)
77 + [9] Call read useFreeze$5(freeze a$14_@1)
78 + [10] Call read useFreeze$5(read a$14_@1)
79 + [11] Call mutate call$6_@3(read a$14_@1)
80 "]
80 - bb1_instrs --> bb1_terminal(["Return read a$4_@1"])
81 + bb1_instrs --> bb1_terminal(["Return read a$14_@1"])
82 end
83
84 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md
+14 -14
@@ -141,18 +141,18 @@ function Foo$0() {}
141
142 ```
143 bb0:
144 - [1] Const mutate a$2_@0[0:7] = Call mutate compute$3_@0(read props$1.a)
145 - [2] Const mutate b$4_@0[0:6] = Call mutate compute$3_@0(read props$1.b)
146 - [3] If (read props$1.c) then:bb2 else:bb1
144 + [1] Const mutate a$9_@0[0:7] = Call mutate compute$3_@0(read props$8.a)
145 + [2] Const mutate b$10_@0[0:6] = Call mutate compute$3_@0(read props$8.b)
146 + [3] If (read props$8.c) then:bb2 else:bb1
147 bb2:
148 predecessor blocks: bb0
149 - [4] Call mutate mutate$5_@0(mutate a$2_@0)
150 - [5] Call mutate mutate$5_@0(mutate b$4_@0)
149 + [4] Call mutate mutate$5_@0(mutate a$9_@0)
150 + [5] Call mutate mutate$5_@0(mutate b$10_@0)
151 [6] Goto bb1
152 bb1:
153 predecessor blocks: bb2 bb0
154 - [7] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
155 - [8] Return read $7_@1
154 + [7] Const mutate $14_@1 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
155 + [8] Return read $14_@1
156 ```
157
158 ### CFG
@@ -162,23 +162,23 @@ flowchart TB
162 %% Basic Blocks
163 subgraph bb0
164 bb0_instrs["
165 - [1] Const mutate a$2_@0[0:7] = Call mutate compute$3_@0(read props$1.a)
166 - [2] Const mutate b$4_@0[0:6] = Call mutate compute$3_@0(read props$1.b)
165 + [1] Const mutate a$9_@0[0:7] = Call mutate compute$3_@0(read props$8.a)
166 + [2] Const mutate b$10_@0[0:6] = Call mutate compute$3_@0(read props$8.b)
167 "]
168 - bb0_instrs --> bb0_terminal(["If (read props$1.c)"])
168 + bb0_instrs --> bb0_terminal(["If (read props$8.c)"])
169 end
170 subgraph bb2
171 bb2_instrs["
172 - [4] Call mutate mutate$5_@0(mutate a$2_@0)
173 - [5] Call mutate mutate$5_@0(mutate b$4_@0)
172 + [4] Call mutate mutate$5_@0(mutate a$9_@0)
173 + [5] Call mutate mutate$5_@0(mutate b$10_@0)
174 "]
175 bb2_instrs --> bb2_terminal(["Goto"])
176 end
177 subgraph bb1
178 bb1_instrs["
179 - [7] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
179 + [7] Const mutate $14_@1 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
180 "]
181 - bb1_instrs --> bb1_terminal(["Return read $7_@1"])
181 + bb1_instrs --> bb1_terminal(["Return read $14_@1"])
182 end
183
184 %% 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_@0[0:3] = Call mutate compute$3_@0(read props$1.a)
32 - [2] Const mutate b$4_@0[0:3] = 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 - [4] Return read $6_@1
31 + [1] Const mutate a$8_@0[0:3] = Call mutate compute$3_@0(read props$7.a)
32 + [2] Const mutate b$9_@0[0:3] = Call mutate compute$3_@0(read props$7.b)
33 + [3] Const mutate $10_@1 = JSX <read Foo$5 a={freeze a$8_@0} b={freeze b$9_@0} ></read Foo$5>
34 + [4] Return read $10_@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_@0[0:3] = Call mutate compute$3_@0(read props$1.a)
45 - [2] Const mutate b$4_@0[0:3] = 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>
44 + [1] Const mutate a$8_@0[0:3] = Call mutate compute$3_@0(read props$7.a)
45 + [2] Const mutate b$9_@0[0:3] = Call mutate compute$3_@0(read props$7.b)
46 + [3] Const mutate $10_@1 = JSX <read Foo$5 a={freeze a$8_@0} b={freeze b$9_@0} ></read Foo$5>
47 "]
48 - bb0_instrs --> bb0_terminal(["Return read $6_@1"])
48 + bb0_instrs --> bb0_terminal(["Return read $10_@1"])
49 end
50
51 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md
+12 -12
@@ -109,17 +109,17 @@ function Foo$0() {}
109
110 ```
111 bb0:
112 - [1] Const mutate a$2_@0[0:6] = Call mutate compute$3_@0(read props$1.a)
113 - [2] Const mutate b$4_@0[0:5] = Call mutate compute$3_@0(read props$1.b)
114 - [3] If (read props$1.c) then:bb2 else:bb1
112 + [1] Const mutate a$9_@0[0:6] = Call mutate compute$3_@0(read props$8.a)
113 + [2] Const mutate b$10_@0[0:5] = Call mutate compute$3_@0(read props$8.b)
114 + [3] If (read props$8.c) then:bb2 else:bb1
115 bb2:
116 predecessor blocks: bb0
117 - [4] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0)
117 + [4] Call mutate foo$5_@0(mutate a$9_@0, mutate b$10_@0)
118 [5] Goto bb1
119 bb1:
120 predecessor blocks: bb2 bb0
121 - [6] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
122 - [7] Return read $7_@1
121 + [6] Const mutate $14_@1 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
122 + [7] Return read $14_@1
123 ```
124
125 ### CFG
@@ -129,22 +129,22 @@ flowchart TB
129 %% Basic Blocks
130 subgraph bb0
131 bb0_instrs["
132 - [1] Const mutate a$2_@0[0:6] = Call mutate compute$3_@0(read props$1.a)
133 - [2] Const mutate b$4_@0[0:5] = Call mutate compute$3_@0(read props$1.b)
132 + [1] Const mutate a$9_@0[0:6] = Call mutate compute$3_@0(read props$8.a)
133 + [2] Const mutate b$10_@0[0:5] = Call mutate compute$3_@0(read props$8.b)
134 "]
135 - bb0_instrs --> bb0_terminal(["If (read props$1.c)"])
135 + bb0_instrs --> bb0_terminal(["If (read props$8.c)"])
136 end
137 subgraph bb2
138 bb2_instrs["
139 - [4] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0)
139 + [4] Call mutate foo$5_@0(mutate a$9_@0, mutate b$10_@0)
140 "]
141 bb2_instrs --> bb2_terminal(["Goto"])
142 end
143 subgraph bb1
144 bb1_instrs["
145 - [6] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
145 + [6] Const mutate $14_@1 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
146 "]
147 - bb1_instrs --> bb1_terminal(["Return read $7_@1"])
147 + bb1_instrs --> bb1_terminal(["Return read $14_@1"])
148 end
149
150 %% 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_@0[0:4] = Call mutate compute$3_@0(read props$1.a)
32 - [2] Const mutate b$4_@0[0:4] = 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 - [5] Return read $7_@1
31 + [1] Const mutate a$9_@0[0:4] = Call mutate compute$3_@0(read props$8.a)
32 + [2] Const mutate b$10_@0[0:4] = Call mutate compute$3_@0(read props$8.b)
33 + [3] Call mutate foo$5_@0(mutate a$9_@0, mutate b$10_@0)
34 + [4] Const mutate $11_@1 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
35 + [5] Return read $11_@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_@0[0:4] = Call mutate compute$3_@0(read props$1.a)
46 - [2] Const mutate b$4_@0[0:4] = 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>
45 + [1] Const mutate a$9_@0[0:4] = Call mutate compute$3_@0(read props$8.a)
46 + [2] Const mutate b$10_@0[0:4] = Call mutate compute$3_@0(read props$8.b)
47 + [3] Call mutate foo$5_@0(mutate a$9_@0, mutate b$10_@0)
48 + [4] Const mutate $11_@1 = JSX <read Foo$6 a={freeze a$9_@0} b={freeze b$10_@0} ></read Foo$6>
49 "]
50 - bb0_instrs --> bb0_terminal(["Return read $7_@1"])
50 + bb0_instrs --> bb0_terminal(["Return read $11_@1"])
51 end
52
53 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/inverted-if.expect.md
+8 -8
@@ -18,14 +18,14 @@ function foo(a, b, c) {
18
19 ```
20 bb0:
21 - [1] Let mutate y$4_@0[1:6] = Array []
22 - [2] If (read a$1) then:bb3 else:bb1
21 + [1] Let mutate y$8_@0[1:6] = Array []
22 + [2] If (read a$5) then:bb3 else:bb1
23 bb3:
24 predecessor blocks: bb0
25 - [3] If (read b$2) then:bb5 else:bb1
25 + [3] If (read b$6) then:bb5 else:bb1
26 bb5:
27 predecessor blocks: bb3
28 - [4] Call mutate y$4_@0.push(read c$3)
28 + [4] Call mutate y$8_@0.push(read c$7)
29 [5] Goto bb1
30 bb1:
31 predecessor blocks: bb5 bb3 bb0
@@ -39,16 +39,16 @@ flowchart TB
39 %% Basic Blocks
40 subgraph bb0
41 bb0_instrs["
42 - [1] Let mutate y$4_@0[1:6] = Array []
42 + [1] Let mutate y$8_@0[1:6] = Array []
43 "]
44 - bb0_instrs --> bb0_terminal(["If (read a$1)"])
44 + bb0_instrs --> bb0_terminal(["If (read a$5)"])
45 end
46 subgraph bb3
47 - bb3_terminal(["If (read b$2)"])
47 + bb3_terminal(["If (read b$6)"])
48 end
49 subgraph bb5
50 bb5_instrs["
51 - [4] Call mutate y$4_@0.push(read c$3)
51 + [4] Call mutate y$8_@0.push(read c$7)
52 "]
53 bb5_instrs --> bb5_terminal(["Goto"])
54 end
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_@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 - [12] Return read $12_@10
22 + [1] Const mutate $14_@0 = "\n Hello "
23 + [2] Const mutate $15_@1 = " "
24 + [3] Const mutate $16_@2 = "\n "
25 + [4] Const mutate $17_@3 = "div"
26 + [5] Const mutate $18_@4 = "\n "
27 + [6] Const mutate $19_@5 = "Text"
28 + [7] Const mutate $20_@6 = JsxFragment [read $19_@5]
29 + [8] Const mutate $21_@7 = "\n "
30 + [9] Const mutate $22_@8 = JSX <read $17_@3>{read $18_@4}{read $20_@6}{read $21_@7}</read $17_@3>
31 + [10] Const mutate $23_@9 = "\n "
32 + [11] Const mutate $24_@10 = JsxFragment [read $14_@0, read props$13.greeting, read $15_@1, read $16_@2, read $22_@8, read $23_@9]
33 + [12] Return read $24_@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_@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]
43 + [1] Const mutate $14_@0 = '\n Hello '
44 + [2] Const mutate $15_@1 = ' '
45 + [3] Const mutate $16_@2 = '\n '
46 + [4] Const mutate $17_@3 = 'div'
47 + [5] Const mutate $18_@4 = '\n '
48 + [6] Const mutate $19_@5 = 'Text'
49 + [7] Const mutate $20_@6 = JsxFragment [read $19_@5]
50 + [8] Const mutate $21_@7 = '\n '
51 + [9] Const mutate $22_@8 = JSX <read $17_@3>{read $18_@4}{read $20_@6}{read $21_@7}</read $17_@3>
52 + [10] Const mutate $23_@9 = '\n '
53 + [11] Const mutate $24_@10 = JsxFragment [read $14_@0, read props$13.greeting, read $15_@1, read $16_@2, read $22_@8, read $23_@9]
54 "]
55 - bb0_instrs --> bb0_terminal(["Return read $12_@10"])
55 + bb0_instrs --> bb0_terminal(["Return read $24_@10"])
56 end
57
58 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md
+37 -34
@@ -23,19 +23,20 @@ function g() {}
23
24 ```
25 bb0:
26 - [1] Const mutate $2_@0[0:7] = Call mutate f$1_@0()
27 - [2] If (read $2_@0) then:bb2 else:bb3
26 + [1] Const mutate $5_@0[0:7] = Call mutate f$1_@0()
27 + [2] If (read $5_@0) then:bb2 else:bb3
28 bb2:
29 predecessor blocks: bb0
30 - [3] Const mutate $3_@0[0:6] = Call mutate g$4_@0()
30 + [3] Const mutate $6_@0[0:6] = Call mutate g$4_@0()
31 [4] Goto bb1
32 bb3:
33 predecessor blocks: bb0
34 - [5] Const mutate $3_@0[0:6] = read $2_@0
34 + [5] Const mutate $7_@0[0:6] = read $5_@0
35 [6] Goto bb1
36 bb1:
37 predecessor blocks: bb2 bb3
38 - [7] Return freeze $3_@0
38 + $8_@0[0:6]: phi(bb2: $6_@0, bb3: $7_@0)
39 + [7] Return freeze $8_@0
40 ```
41
42 ### CFG
@@ -45,24 +46,24 @@ flowchart TB
46 %% Basic Blocks
47 subgraph bb0
48 bb0_instrs["
48 - [1] Const mutate $2_@0[0:7] = Call mutate f$1_@0()
49 + [1] Const mutate $5_@0[0:7] = Call mutate f$1_@0()
50 "]
50 - bb0_instrs --> bb0_terminal(["If (read $2_@0)"])
51 + bb0_instrs --> bb0_terminal(["If (read $5_@0)"])
52 end
53 subgraph bb2
54 bb2_instrs["
54 - [3] Const mutate $3_@0[0:6] = Call mutate g$4_@0()
55 + [3] Const mutate $6_@0[0:6] = Call mutate g$4_@0()
56 "]
57 bb2_instrs --> bb2_terminal(["Goto"])
58 end
59 subgraph bb3
60 bb3_instrs["
60 - [5] Const mutate $3_@0[0:6] = read $2_@0
61 + [5] Const mutate $7_@0[0:6] = read $5_@0
62 "]
63 bb3_instrs --> bb3_terminal(["Goto"])
64 end
65 subgraph bb1
65 - bb1_terminal(["Return freeze $3_@0"])
66 + bb1_terminal(["Return freeze $8_@0"])
67 end
68
69 %% Jumps
@@ -89,19 +90,20 @@ function And$0() {
90
91 ```
92 bb0:
92 - [1] Const mutate $2_@0[0:7] = Call mutate f$1_@0()
93 - [2] If (read $2_@0) then:bb2 else:bb3
93 + [1] Const mutate $5_@0[0:7] = Call mutate f$1_@0()
94 + [2] If (read $5_@0) then:bb2 else:bb3
95 bb2:
96 predecessor blocks: bb0
96 - [3] Const mutate $3_@0[0:6] = read $2_@0
97 + [3] Const mutate $6_@0[0:6] = read $5_@0
98 [4] Goto bb1
99 bb3:
100 predecessor blocks: bb0
100 - [5] Const mutate $3_@0[0:6] = Call mutate g$4_@0()
101 + [5] Const mutate $7_@0[0:6] = Call mutate g$4_@0()
102 [6] Goto bb1
103 bb1:
104 predecessor blocks: bb2 bb3
104 - [7] Return freeze $3_@0
105 + $8_@0[0:6]: phi(bb2: $6_@0, bb3: $7_@0)
106 + [7] Return freeze $8_@0
107 ```
108
109 ### CFG
@@ -111,24 +113,24 @@ flowchart TB
113 %% Basic Blocks
114 subgraph bb0
115 bb0_instrs["
114 - [1] Const mutate $2_@0[0:7] = Call mutate f$1_@0()
116 + [1] Const mutate $5_@0[0:7] = Call mutate f$1_@0()
117 "]
116 - bb0_instrs --> bb0_terminal(["If (read $2_@0)"])
118 + bb0_instrs --> bb0_terminal(["If (read $5_@0)"])
119 end
120 subgraph bb2
121 bb2_instrs["
120 - [3] Const mutate $3_@0[0:6] = read $2_@0
122 + [3] Const mutate $6_@0[0:6] = read $5_@0
123 "]
124 bb2_instrs --> bb2_terminal(["Goto"])
125 end
126 subgraph bb3
127 bb3_instrs["
126 - [5] Const mutate $3_@0[0:6] = Call mutate g$4_@0()
128 + [5] Const mutate $7_@0[0:6] = Call mutate g$4_@0()
129 "]
130 bb3_instrs --> bb3_terminal(["Goto"])
131 end
132 subgraph bb1
131 - bb1_terminal(["Return freeze $3_@0"])
133 + bb1_terminal(["Return freeze $8_@0"])
134 end
135
136 %% Jumps
@@ -155,21 +157,22 @@ function Or$0() {
157
158 ```
159 bb0:
158 - [1] Const mutate $3_@0[0:9] = Call mutate f$2_@0()
159 - [2] Const mutate $4_@1 = null
160 - [3] Const mutate $5_@0[0:8] = Binary read $3_@0 != read $4_@1
161 - [4] If (read $5_@0) then:bb2 else:bb3
160 + [1] Const mutate $9_@0[0:9] = Call mutate f$2_@0()
161 + [2] Const mutate $10_@1 = null
162 + [3] Const mutate $11_@0[0:8] = Binary read $9_@0 != read $10_@1
163 + [4] If (read $11_@0) then:bb2 else:bb3
164 bb2:
165 predecessor blocks: bb0
164 - [5] Const mutate $6_@0[0:8] = read $3_@0
166 + [5] Const mutate $12_@0[0:8] = read $9_@0
167 [6] Goto bb1
168 bb3:
169 predecessor blocks: bb0
168 - [7] Const mutate $6_@0[0:8] = Call mutate g$7_@0()
170 + [7] Const mutate $13_@0[0:8] = Call mutate g$7_@0()
171 [8] Goto bb1
172 bb1:
173 predecessor blocks: bb2 bb3
172 - [9] Return freeze $6_@0
174 + $14_@0[0:8]: phi(bb2: $12_@0, bb3: $13_@0)
175 + [9] Return freeze $14_@0
176 ```
177
178 ### CFG
@@ -179,26 +182,26 @@ flowchart TB
182 %% Basic Blocks
183 subgraph bb0
184 bb0_instrs["
182 - [1] Const mutate $3_@0[0:9] = Call mutate f$2_@0()
183 - [2] Const mutate $4_@1 = null
184 - [3] Const mutate $5_@0[0:8] = Binary read $3_@0 != read $4_@1
185 + [1] Const mutate $9_@0[0:9] = Call mutate f$2_@0()
186 + [2] Const mutate $10_@1 = null
187 + [3] Const mutate $11_@0[0:8] = Binary read $9_@0 != read $10_@1
188 "]
186 - bb0_instrs --> bb0_terminal(["If (read $5_@0)"])
189 + bb0_instrs --> bb0_terminal(["If (read $11_@0)"])
190 end
191 subgraph bb2
192 bb2_instrs["
190 - [5] Const mutate $6_@0[0:8] = read $3_@0
193 + [5] Const mutate $12_@0[0:8] = read $9_@0
194 "]
195 bb2_instrs --> bb2_terminal(["Goto"])
196 end
197 subgraph bb3
198 bb3_instrs["
196 - [7] Const mutate $6_@0[0:8] = Call mutate g$7_@0()
199 + [7] Const mutate $13_@0[0:8] = Call mutate g$7_@0()
200 "]
201 bb3_instrs --> bb3_terminal(["Goto"])
202 end
203 subgraph bb1
201 - bb1_terminal(["Return freeze $6_@0"])
204 + bb1_terminal(["Return freeze $14_@0"])
205 end
206
207 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md
+48 -40
@@ -95,44 +95,52 @@ function cond$0(x$1) {}
95
96 ```
97 bb0:
98 - [1] Let mutate a$2_@0[0:23] = Object { }
99 - [2] Let mutate b$3_@0[0:23] = Object { }
100 - [3] Let mutate c$4_@0[0:23] = Object { }
101 - [4] Let mutate d$5_@0[0:23] = Object { }
98 + [1] Let mutate a$13_@0[0:23] = Object { }
99 + [2] Let mutate b$14_@0[0:23] = Object { }
100 + [3] Let mutate c$15_@0[0:23] = Object { }
101 + [4] Let mutate d$16_@0[0:23] = Object { }
102 [5] While test=bb1 loop=bb3 fallthrough=bb2
103 bb1:
104 predecessor blocks: bb0 bb4
105 - [6] Const mutate $10_@1[6:17] = true
106 - [7] If (read $10_@1) then:bb3 else:bb2
105 + a$18_@0[0:23]: phi(bb0: a$13_@0, bb4: a$21_@0)
106 + b$20_@0[0:23]: phi(bb0: b$14_@0, bb4: b$23_@0)
107 + c$22_@0[0:23]: phi(bb0: c$15_@0, bb4: c$25_@0)
108 + d$24_@0[0:23]: phi(bb0: d$16_@0, bb4: d$26_@0)
109 + [6] Const mutate $17_@1[6:17] = true
110 + [7] If (read $17_@1) then:bb3 else:bb2
111 bb3:
112 predecessor blocks: bb1
109 - [8] Let mutate z$6_@0[0:23] = read a$2_@0
110 - [9] Reassign mutate a$2_@0[0:23] = read b$3_@0
111 - [10] Reassign mutate b$3_@0[0:23] = read c$4_@0
112 - [11] Reassign mutate c$4_@0[0:23] = read d$5_@0
113 - [12] Reassign mutate d$5_@0[0:23] = read z$6_@0
114 - [13] Call mutate mutate$7_@0(mutate a$2_@0, mutate b$3_@0)
115 - [14] Const mutate $9_@0[0:23] = Call mutate cond$8_@0(mutate a$2_@0)
116 - [15] If (read $9_@0) then:bb2 else:bb4
113 + [8] Let mutate z$19_@0[0:23] = read a$18_@0
114 + [9] Reassign mutate a$21_@0[0:23] = read b$20_@0
115 + [10] Reassign mutate b$23_@0[0:23] = read c$22_@0
116 + [11] Reassign mutate c$25_@0[0:23] = read d$24_@0
117 + [12] Reassign mutate d$26_@0[0:23] = read z$19_@0
118 + [13] Call mutate mutate$7_@0(mutate a$21_@0, mutate b$23_@0)
119 + [14] Const mutate $29_@0[0:23] = Call mutate cond$8_@0(mutate a$21_@0)
120 + [15] If (read $29_@0) then:bb2 else:bb4
121 bb4:
122 predecessor blocks: bb3
123 [16] Goto(Continue) bb1
124 bb2:
125 predecessor blocks: bb3 bb1
122 - [17] If (read a$2_@0) then:bb7 else:bb7
126 + a$30_@0[0:23]: phi(bb3: a$21_@0, bb1: a$18_@0)
127 + b$31_@0[0:23]: phi(bb3: b$23_@0, bb1: b$20_@0)
128 + c$32_@0[0:23]: phi(bb3: c$25_@0, bb1: c$22_@0)
129 + d$33_@0[0:23]: phi(bb3: d$26_@0, bb1: d$24_@0)
130 + [17] If (read a$30_@0) then:bb7 else:bb7
131 bb7:
132 predecessor blocks: bb2
125 - [18] If (read b$3_@0) then:bb9 else:bb9
133 + [18] If (read b$31_@0) then:bb9 else:bb9
134 bb9:
135 predecessor blocks: bb7
128 - [19] If (read c$4_@0) then:bb11 else:bb11
136 + [19] If (read c$32_@0) then:bb11 else:bb11
137 bb11:
138 predecessor blocks: bb9
131 - [20] If (read d$5_@0) then:bb13 else:bb13
139 + [20] If (read d$33_@0) then:bb13 else:bb13
140 bb13:
141 predecessor blocks: bb11
134 - [21] Const mutate $11_@2 = null
135 - [22] Call mutate mutate$7_@0(mutate d$5_@0, read $11_@2)
142 + [21] Const mutate $34_@2 = null
143 + [22] Call mutate mutate$7_@0(mutate d$33_@0, read $34_@2)
144 [23] Return
145 ```
146
@@ -143,50 +151,50 @@ flowchart TB
151 %% Basic Blocks
152 subgraph bb0
153 bb0_instrs["
146 - [1] Let mutate a$2_@0[0:23] = Object { }
147 - [2] Let mutate b$3_@0[0:23] = Object { }
148 - [3] Let mutate c$4_@0[0:23] = Object { }
149 - [4] Let mutate d$5_@0[0:23] = Object { }
154 + [1] Let mutate a$13_@0[0:23] = Object { }
155 + [2] Let mutate b$14_@0[0:23] = Object { }
156 + [3] Let mutate c$15_@0[0:23] = Object { }
157 + [4] Let mutate d$16_@0[0:23] = Object { }
158 "]
159 bb0_instrs --> bb0_terminal(["While"])
160 end
161 subgraph bb1
162 bb1_instrs["
155 - [6] Const mutate $10_@1[6:17] = true
163 + [6] Const mutate $17_@1[6:17] = true
164 "]
157 - bb1_instrs --> bb1_terminal(["If (read $10_@1)"])
165 + bb1_instrs --> bb1_terminal(["If (read $17_@1)"])
166 end
167 subgraph bb3
168 bb3_instrs["
161 - [8] Let mutate z$6_@0[0:23] = read a$2_@0
162 - [9] Reassign mutate a$2_@0[0:23] = read b$3_@0
163 - [10] Reassign mutate b$3_@0[0:23] = read c$4_@0
164 - [11] Reassign mutate c$4_@0[0:23] = read d$5_@0
165 - [12] Reassign mutate d$5_@0[0:23] = read z$6_@0
166 - [13] Call mutate mutate$7_@0(mutate a$2_@0, mutate b$3_@0)
167 - [14] Const mutate $9_@0[0:23] = Call mutate cond$8_@0(mutate a$2_@0)
169 + [8] Let mutate z$19_@0[0:23] = read a$18_@0
170 + [9] Reassign mutate a$21_@0[0:23] = read b$20_@0
171 + [10] Reassign mutate b$23_@0[0:23] = read c$22_@0
172 + [11] Reassign mutate c$25_@0[0:23] = read d$24_@0
173 + [12] Reassign mutate d$26_@0[0:23] = read z$19_@0
174 + [13] Call mutate mutate$7_@0(mutate a$21_@0, mutate b$23_@0)
175 + [14] Const mutate $29_@0[0:23] = Call mutate cond$8_@0(mutate a$21_@0)
176 "]
169 - bb3_instrs --> bb3_terminal(["If (read $9_@0)"])
177 + bb3_instrs --> bb3_terminal(["If (read $29_@0)"])
178 end
179 subgraph bb4
180 bb4_terminal(["Goto"])
181 end
182 subgraph bb2
175 - bb2_terminal(["If (read a$2_@0)"])
183 + bb2_terminal(["If (read a$30_@0)"])
184 end
185 subgraph bb7
178 - bb7_terminal(["If (read b$3_@0)"])
186 + bb7_terminal(["If (read b$31_@0)"])
187 end
188 subgraph bb9
181 - bb9_terminal(["If (read c$4_@0)"])
189 + bb9_terminal(["If (read c$32_@0)"])
190 end
191 subgraph bb11
184 - bb11_terminal(["If (read d$5_@0)"])
192 + bb11_terminal(["If (read d$33_@0)"])
193 end
194 subgraph bb13
195 bb13_instrs["
188 - [21] Const mutate $11_@2 = null
189 - [22] Call mutate mutate$7_@0(mutate d$5_@0, read $11_@2)
196 + [21] Const mutate $34_@2 = null
197 + [22] Call mutate mutate$7_@0(mutate d$33_@0, read $34_@2)
198 "]
199 bb13_instrs --> bb13_terminal(["Return"])
200 end
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md
+28 -28
@@ -65,30 +65,30 @@ function mutate$0(x$1, y$2) {}
65
66 ```
67 bb0:
68 - [1] Const mutate a$2_@0 = Object { }
69 - [2] Const mutate b$3_@1 = Array [read a$2_@0]
70 - [3] Const mutate c$4_@2 = Object { }
71 - [4] Const mutate d$5_@3[0:15] = Object { c: read c$4_@2 }
72 - [5] Const mutate x$6_@3[0:15] = Object { }
73 - [6] Reassign mutate x$6_@3.b[0:15] = read b$3_@1
74 - [7] Const mutate y$7_@3[0:15] = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3)
75 - [8] If (read a$2_@0) then:bb1 else:bb1
68 + [1] Const mutate a$11_@0 = Object { }
69 + [2] Const mutate b$12_@1 = Array [read a$11_@0]
70 + [3] Const mutate c$13_@2 = Object { }
71 + [4] Const mutate d$14_@3[0:15] = Object { c: read c$13_@2 }
72 + [5] Const mutate x$15_@3[0:15] = Object { }
73 + [6] Reassign mutate x$15_@3.b[0:15] = read b$12_@1
74 + [7] Const mutate y$16_@3[0:15] = Call mutate mutate$8_@3(mutate x$15_@3, mutate d$14_@3)
75 + [8] If (read a$11_@0) then:bb1 else:bb1
76 bb1:
77 predecessor blocks: bb0
78 - [9] If (read b$3_@1) then:bb3 else:bb3
78 + [9] If (read b$12_@1) then:bb3 else:bb3
79 bb3:
80 predecessor blocks: bb1
81 - [10] If (read c$4_@2) then:bb5 else:bb5
81 + [10] If (read c$13_@2) then:bb5 else:bb5
82 bb5:
83 predecessor blocks: bb3
84 - [11] If (read d$5_@3) then:bb7 else:bb7
84 + [11] If (read d$14_@3) then:bb7 else:bb7
85 bb7:
86 predecessor blocks: bb5
87 - [12] If (read y$7_@3) then:bb9 else:bb9
87 + [12] If (read y$16_@3) then:bb9 else:bb9
88 bb9:
89 predecessor blocks: bb7
90 - [13] Const mutate $9_@4 = null
91 - [14] Call mutate mutate$8_@3(mutate x$6_@3, read $9_@4)
90 + [13] Const mutate $17_@4 = null
91 + [14] Call mutate mutate$8_@3(mutate x$15_@3, read $17_@4)
92 [15] Return
93 ```
94
@@ -99,32 +99,32 @@ flowchart TB
99 %% Basic Blocks
100 subgraph bb0
101 bb0_instrs["
102 - [1] Const mutate a$2_@0 = Object { }
103 - [2] Const mutate b$3_@1 = Array [read a$2_@0]
104 - [3] Const mutate c$4_@2 = Object { }
105 - [4] Const mutate d$5_@3[0:15] = Object { c: read c$4_@2 }
106 - [5] Const mutate x$6_@3[0:15] = Object { }
107 - [6] Reassign mutate x$6_@3.b[0:15] = read b$3_@1
108 - [7] Const mutate y$7_@3[0:15] = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3)
102 + [1] Const mutate a$11_@0 = Object { }
103 + [2] Const mutate b$12_@1 = Array [read a$11_@0]
104 + [3] Const mutate c$13_@2 = Object { }
105 + [4] Const mutate d$14_@3[0:15] = Object { c: read c$13_@2 }
106 + [5] Const mutate x$15_@3[0:15] = Object { }
107 + [6] Reassign mutate x$15_@3.b[0:15] = read b$12_@1
108 + [7] Const mutate y$16_@3[0:15] = Call mutate mutate$8_@3(mutate x$15_@3, mutate d$14_@3)
109 "]
110 - bb0_instrs --> bb0_terminal(["If (read a$2_@0)"])
110 + bb0_instrs --> bb0_terminal(["If (read a$11_@0)"])
111 end
112 subgraph bb1
113 - bb1_terminal(["If (read b$3_@1)"])
113 + bb1_terminal(["If (read b$12_@1)"])
114 end
115 subgraph bb3
116 - bb3_terminal(["If (read c$4_@2)"])
116 + bb3_terminal(["If (read c$13_@2)"])
117 end
118 subgraph bb5
119 - bb5_terminal(["If (read d$5_@3)"])
119 + bb5_terminal(["If (read d$14_@3)"])
120 end
121 subgraph bb7
122 - bb7_terminal(["If (read y$7_@3)"])
122 + bb7_terminal(["If (read y$16_@3)"])
123 end
124 subgraph bb9
125 bb9_instrs["
126 - [13] Const mutate $9_@4 = null
127 - [14] Call mutate mutate$8_@3(mutate x$6_@3, read $9_@4)
126 + [13] Const mutate $17_@4 = null
127 + [14] Call mutate mutate$8_@3(mutate x$15_@3, read $17_@4)
128 "]
129 bb9_instrs --> bb9_terminal(["Return"])
130 end
compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md
+30 -30
@@ -90,39 +90,39 @@ function cond$0() {}
90
91 ```
92 bb0:
93 - [1] Let mutate a$2_@0[0:18] = Object { }
94 - [2] Let mutate b$3_@0[0:18] = Object { }
95 - [3] Let mutate c$4_@1 = Object { }
96 - [4] Let mutate d$5_@0[0:18] = Object { }
93 + [1] Let mutate a$12_@0[0:18] = Object { }
94 + [2] Let mutate b$13_@0[0:18] = Object { }
95 + [3] Let mutate c$14_@1 = Object { }
96 + [4] Let mutate d$15_@0[0:18] = Object { }
97 [5] While test=bb1 loop=bb3 fallthrough=bb2
98 bb1:
99 predecessor blocks: bb0 bb4
100 - [6] Const mutate $9_@2[6:12] = true
101 - [7] If (read $9_@2) then:bb3 else:bb2
100 + [6] Const mutate $16_@2[6:12] = true
101 + [7] If (read $16_@2) then:bb3 else:bb2
102 bb3:
103 predecessor blocks: bb1
104 - [8] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0)
105 - [9] Const mutate $8_@0[0:18] = Call mutate cond$7_@0(mutate a$2_@0)
106 - [10] If (read $8_@0) then:bb2 else:bb4
104 + [8] Call mutate mutate$6_@0(mutate a$12_@0, mutate b$13_@0)
105 + [9] Const mutate $21_@0[0:18] = Call mutate cond$7_@0(mutate a$12_@0)
106 + [10] If (read $21_@0) then:bb2 else:bb4
107 bb4:
108 predecessor blocks: bb3
109 [11] Goto(Continue) bb1
110 bb2:
111 predecessor blocks: bb3 bb1
112 - [12] If (read a$2_@0) then:bb7 else:bb7
112 + [12] If (read a$12_@0) then:bb7 else:bb7
113 bb7:
114 predecessor blocks: bb2
115 - [13] If (read b$3_@0) then:bb9 else:bb9
115 + [13] If (read b$13_@0) then:bb9 else:bb9
116 bb9:
117 predecessor blocks: bb7
118 - [14] If (read c$4_@1) then:bb11 else:bb11
118 + [14] If (read c$14_@1) then:bb11 else:bb11
119 bb11:
120 predecessor blocks: bb9
121 - [15] If (read d$5_@0) then:bb13 else:bb13
121 + [15] If (read d$15_@0) then:bb13 else:bb13
122 bb13:
123 predecessor blocks: bb11
124 - [16] Const mutate $10_@3 = null
125 - [17] Call mutate mutate$6_@0(mutate d$5_@0, read $10_@3)
124 + [16] Const mutate $28_@3 = null
125 + [17] Call mutate mutate$6_@0(mutate d$15_@0, read $28_@3)
126 [18] Return
127 ```
128
@@ -133,45 +133,45 @@ flowchart TB
133 %% Basic Blocks
134 subgraph bb0
135 bb0_instrs["
136 - [1] Let mutate a$2_@0[0:18] = Object { }
137 - [2] Let mutate b$3_@0[0:18] = Object { }
138 - [3] Let mutate c$4_@1 = Object { }
139 - [4] Let mutate d$5_@0[0:18] = Object { }
136 + [1] Let mutate a$12_@0[0:18] = Object { }
137 + [2] Let mutate b$13_@0[0:18] = Object { }
138 + [3] Let mutate c$14_@1 = Object { }
139 + [4] Let mutate d$15_@0[0:18] = Object { }
140 "]
141 bb0_instrs --> bb0_terminal(["While"])
142 end
143 subgraph bb1
144 bb1_instrs["
145 - [6] Const mutate $9_@2[6:12] = true
145 + [6] Const mutate $16_@2[6:12] = true
146 "]
147 - bb1_instrs --> bb1_terminal(["If (read $9_@2)"])
147 + bb1_instrs --> bb1_terminal(["If (read $16_@2)"])
148 end
149 subgraph bb3
150 bb3_instrs["
151 - [8] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0)
152 - [9] Const mutate $8_@0[0:18] = Call mutate cond$7_@0(mutate a$2_@0)
151 + [8] Call mutate mutate$6_@0(mutate a$12_@0, mutate b$13_@0)
152 + [9] Const mutate $21_@0[0:18] = Call mutate cond$7_@0(mutate a$12_@0)
153 "]
154 - bb3_instrs --> bb3_terminal(["If (read $8_@0)"])
154 + bb3_instrs --> bb3_terminal(["If (read $21_@0)"])
155 end
156 subgraph bb4
157 bb4_terminal(["Goto"])
158 end
159 subgraph bb2
160 - bb2_terminal(["If (read a$2_@0)"])
160 + bb2_terminal(["If (read a$12_@0)"])
161 end
162 subgraph bb7
163 - bb7_terminal(["If (read b$3_@0)"])
163 + bb7_terminal(["If (read b$13_@0)"])
164 end
165 subgraph bb9
166 - bb9_terminal(["If (read c$4_@1)"])
166 + bb9_terminal(["If (read c$14_@1)"])
167 end
168 subgraph bb11
169 - bb11_terminal(["If (read d$5_@0)"])
169 + bb11_terminal(["If (read d$15_@0)"])
170 end
171 subgraph bb13
172 bb13_instrs["
173 - [16] Const mutate $10_@3 = null
174 - [17] Call mutate mutate$6_@0(mutate d$5_@0, read $10_@3)
173 + [16] Const mutate $28_@3 = null
174 + [17] Call mutate mutate$6_@0(mutate d$15_@0, read $28_@3)
175 "]
176 bb13_instrs --> bb13_terminal(["Return"])
177 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_@0[1:6] = Object { }
21 - [2] Const mutate y$3_@1 = Array []
22 - [3] Reassign mutate x$2_@0.y[1:6] = 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 - [7] Return read $5_@3
20 + [1] Const mutate x$7_@0[1:6] = Object { }
21 + [2] Const mutate y$8_@1 = Array []
22 + [3] Reassign mutate x$7_@0.y[1:6] = read y$8_@1
23 + [4] Const mutate child$9_@2 = JSX <read Component$0 data={freeze y$8_@1} ></read Component$0>
24 + [5] Call mutate x$7_@0.y.push(read props$6.p0)
25 + [6] Const mutate $10_@3 = JSX <read Component$0 data={freeze x$7_@0} >{read child$9_@2}</read Component$0>
26 + [7] Return read $10_@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_@0[1:6] = Object { }
37 - [2] Const mutate y$3_@1 = Array []
38 - [3] Reassign mutate x$2_@0.y[1:6] = 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>
36 + [1] Const mutate x$7_@0[1:6] = Object { }
37 + [2] Const mutate y$8_@1 = Array []
38 + [3] Reassign mutate x$7_@0.y[1:6] = read y$8_@1
39 + [4] Const mutate child$9_@2 = JSX <read Component$0 data={freeze y$8_@1} ></read Component$0>
40 + [5] Call mutate x$7_@0.y.push(read props$6.p0)
41 + [6] Const mutate $10_@3 = JSX <read Component$0 data={freeze x$7_@0} >{read child$9_@2}</read Component$0>
42 "]
43 - bb0_instrs --> bb0_terminal(["Return read $5_@3"])
43 + bb0_instrs --> bb0_terminal(["Return read $10_@3"])
44 end
45
46 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/reactive-scope-grouping.expect.md
+12 -12
@@ -18,12 +18,12 @@ function foo() {
18
19 ```
20 bb0:
21 - [1] Let mutate x$1_@0[1:6] = Object { }
22 - [2] Let mutate y$2_@1[2:5] = Array []
23 - [3] Let mutate z$3_@1[2:5] = Object { }
24 - [4] Call mutate y$2_@1.push(mutate z$3_@1)
25 - [5] Reassign mutate x$1_@0.y[1:6] = read y$2_@1
26 - [6] Return freeze x$1_@0
21 + [1] Let mutate x$4_@0[1:6] = Object { }
22 + [2] Let mutate y$5_@1[2:5] = Array []
23 + [3] Let mutate z$6_@1[2:5] = Object { }
24 + [4] Call mutate y$5_@1.push(mutate z$6_@1)
25 + [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1
26 + [6] Return freeze x$4_@0
27 ```
28
29 ### CFG
@@ -33,13 +33,13 @@ flowchart TB
33 %% Basic Blocks
34 subgraph bb0
35 bb0_instrs["
36 - [1] Let mutate x$1_@0[1:6] = Object { }
37 - [2] Let mutate y$2_@1[2:5] = Array []
38 - [3] Let mutate z$3_@1[2:5] = Object { }
39 - [4] Call mutate y$2_@1.push(mutate z$3_@1)
40 - [5] Reassign mutate x$1_@0.y[1:6] = read y$2_@1
36 + [1] Let mutate x$4_@0[1:6] = Object { }
37 + [2] Let mutate y$5_@1[2:5] = Array []
38 + [3] Let mutate z$6_@1[2:5] = Object { }
39 + [4] Call mutate y$5_@1.push(mutate z$6_@1)
40 + [5] Reassign mutate x$4_@0.y[1:6] = read y$5_@1
41 "]
42 - bb0_instrs --> bb0_terminal(["Return freeze x$1_@0"])
42 + bb0_instrs --> bb0_terminal(["Return freeze x$4_@0"])
43 end
44
45 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md
+18 -18
@@ -19,22 +19,22 @@ function f(a, b) {
19
20 ```
21 bb0:
22 - [1] Let mutate x$3_@0[1:8] = Array []
23 - [2] Const mutate $4_@1 = 1
24 - [3] Const mutate $5_@2 = Binary read a$1.length === read $4_@1
25 - [4] If (read $5_@2) then:bb2 else:bb1
22 + [1] Let mutate x$10_@0[1:8] = Array []
23 + [2] Const mutate $11_@1 = 1
24 + [3] Const mutate $12_@2 = Binary read a$8.length === read $11_@1
25 + [4] If (read $12_@2) then:bb2 else:bb1
26 bb2:
27 predecessor blocks: bb0
28 - [5] If (read b$2) then:bb4 else:bb1
28 + [5] If (read b$9) then:bb4 else:bb1
29 bb4:
30 predecessor blocks: bb2
31 - [6] Call mutate x$3_@0.push(read b$2)
31 + [6] Call mutate x$10_@0.push(read b$9)
32 [7] Goto bb1
33 bb1:
34 predecessor blocks: bb4 bb2 bb0
35 - [8] Const mutate $6_@3 = "div"
36 - [9] Const mutate $7_@4 = JSX <read $6_@3>{freeze x$3_@0}</read $6_@3>
37 - [10] Return read $7_@4
35 + [8] Const mutate $13_@3 = "div"
36 + [9] Const mutate $15_@4 = JSX <read $13_@3>{freeze x$10_@0}</read $13_@3>
37 + [10] Return read $15_@4
38 ```
39
40 ### CFG
@@ -44,27 +44,27 @@ flowchart TB
44 %% Basic Blocks
45 subgraph bb0
46 bb0_instrs["
47 - [1] Let mutate x$3_@0[1:8] = Array []
48 - [2] Const mutate $4_@1 = 1
49 - [3] Const mutate $5_@2 = Binary read a$1.length === read $4_@1
47 + [1] Let mutate x$10_@0[1:8] = Array []
48 + [2] Const mutate $11_@1 = 1
49 + [3] Const mutate $12_@2 = Binary read a$8.length === read $11_@1
50 "]
51 - bb0_instrs --> bb0_terminal(["If (read $5_@2)"])
51 + bb0_instrs --> bb0_terminal(["If (read $12_@2)"])
52 end
53 subgraph bb2
54 - bb2_terminal(["If (read b$2)"])
54 + bb2_terminal(["If (read b$9)"])
55 end
56 subgraph bb4
57 bb4_instrs["
58 - [6] Call mutate x$3_@0.push(read b$2)
58 + [6] Call mutate x$10_@0.push(read b$9)
59 "]
60 bb4_instrs --> bb4_terminal(["Goto"])
61 end
62 subgraph bb1
63 bb1_instrs["
64 - [8] Const mutate $6_@3 = 'div'
65 - [9] Const mutate $7_@4 = JSX <read $6_@3>{freeze x$3_@0}</read $6_@3>
64 + [8] Const mutate $13_@3 = 'div'
65 + [9] Const mutate $15_@4 = JSX <read $13_@3>{freeze x$10_@0}</read $13_@3>
66 "]
67 - bb1_instrs --> bb1_terminal(["Return read $7_@4"])
67 + bb1_instrs --> bb1_terminal(["Return read $15_@4"])
68 end
69
70 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md
+19 -18
@@ -23,20 +23,21 @@ function Component(props) {
23
24 ```
25 bb0:
26 - [1] Let mutate x$2_@0[1:7] = Array []
27 - [2] Call mutate x$2_@0.push(read props$1.p0)
28 - [3] Let mutate y$3_@0[1:6] = read x$2_@0
29 - [4] If (read props$1.p1) then:bb2 else:bb1
26 + [1] Let mutate x$7_@0[1:7] = Array []
27 + [2] Call mutate x$7_@0.push(read props$6.p0)
28 + [3] Let mutate y$8_@0[1:6] = read x$7_@0
29 + [4] If (read props$6.p1) then:bb2 else:bb1
30 bb2:
31 predecessor blocks: bb0
32 - [5] Reassign mutate x$2_@0[1:6] = Array []
32 + [5] Reassign mutate x$9_@0[1:6] = Array []
33 [6] Goto bb1
34 bb1:
35 predecessor blocks: bb2 bb0
36 - [7] Let mutate _$4_@1 = JSX <read Component$0 x={freeze x$2_@0} ></read Component$0>
37 - [8] Call read y$3_@0.push(read props$1.p2)
38 - [9] Const mutate $5_@2 = JSX <read Component$0 x={read x$2_@0} y={read y$3_@0} ></read Component$0>
39 - [10] Return read $5_@2
36 + x$11_@0[1:6]: phi(bb2: x$9_@0, bb0: x$7_@0)
37 + [7] Let mutate _$12_@1 = JSX <read Component$0 x={freeze x$11_@0} ></read Component$0>
38 + [8] Call read y$8_@0.push(read props$6.p2)
39 + [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$11_@0} y={read y$8_@0} ></read Component$0>
40 + [10] Return read $15_@2
41 ```
42
43 ### CFG
@@ -46,25 +47,25 @@ flowchart TB
47 %% Basic Blocks
48 subgraph bb0
49 bb0_instrs["
49 - [1] Let mutate x$2_@0[1:7] = Array []
50 - [2] Call mutate x$2_@0.push(read props$1.p0)
51 - [3] Let mutate y$3_@0[1:6] = read x$2_@0
50 + [1] Let mutate x$7_@0[1:7] = Array []
51 + [2] Call mutate x$7_@0.push(read props$6.p0)
52 + [3] Let mutate y$8_@0[1:6] = read x$7_@0
53 "]
53 - bb0_instrs --> bb0_terminal(["If (read props$1.p1)"])
54 + bb0_instrs --> bb0_terminal(["If (read props$6.p1)"])
55 end
56 subgraph bb2
57 bb2_instrs["
57 - [5] Reassign mutate x$2_@0[1:6] = Array []
58 + [5] Reassign mutate x$9_@0[1:6] = Array []
59 "]
60 bb2_instrs --> bb2_terminal(["Goto"])
61 end
62 subgraph bb1
63 bb1_instrs["
63 - [7] Let mutate _$4_@1 = JSX <read Component$0 x={freeze x$2_@0} ></read Component$0>
64 - [8] Call read y$3_@0.push(read props$1.p2)
65 - [9] Const mutate $5_@2 = JSX <read Component$0 x={read x$2_@0} y={read y$3_@0} ></read Component$0>
64 + [7] Let mutate _$12_@1 = JSX <read Component$0 x={freeze x$11_@0} ></read Component$0>
65 + [8] Call read y$8_@0.push(read props$6.p2)
66 + [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$11_@0} y={read y$8_@0} ></read Component$0>
67 "]
67 - bb1_instrs --> bb1_terminal(["Return read $5_@2"])
68 + bb1_instrs --> bb1_terminal(["Return read $15_@2"])
69 end
70
71 %% 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_@0[1:7] = Array []
25 - [2] Call mutate x$2_@0.push(read props$1.p0)
26 - [3] Let mutate y$3_@0[1:7] = read x$2_@0
27 - [4] Reassign mutate x$2_@1 = Array []
28 - [5] Let mutate _$4_@2 = JSX <read Component$0 x={freeze x$2_@1} ></read Component$0>
29 - [6] Call mutate y$3_@0.push(read props$1.p1)
30 - [7] Const mutate $5_@3 = JSX <read Component$0 x={read x$2_@1} y={freeze y$3_@0} ></read Component$0>
31 - [8] Return read $5_@3
24 + [1] Let mutate x$7_@0[1:7] = Array []
25 + [2] Call mutate x$7_@0.push(read props$6.p0)
26 + [3] Let mutate y$8_@0[1:7] = read x$7_@0
27 + [4] Reassign mutate x$9_@1 = Array []
28 + [5] Let mutate _$10_@2 = JSX <read Component$0 x={freeze x$9_@1} ></read Component$0>
29 + [6] Call mutate y$8_@0.push(read props$6.p1)
30 + [7] Const mutate $11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0} ></read Component$0>
31 + [8] Return read $11_@3
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_@0[1:7] = Array []
42 - [2] Call mutate x$2_@0.push(read props$1.p0)
43 - [3] Let mutate y$3_@0[1:7] = read x$2_@0
44 - [4] Reassign mutate x$2_@1 = Array []
45 - [5] Let mutate _$4_@2 = JSX <read Component$0 x={freeze x$2_@1} ></read Component$0>
46 - [6] Call mutate y$3_@0.push(read props$1.p1)
47 - [7] Const mutate $5_@3 = JSX <read Component$0 x={read x$2_@1} y={freeze y$3_@0} ></read Component$0>
41 + [1] Let mutate x$7_@0[1:7] = Array []
42 + [2] Call mutate x$7_@0.push(read props$6.p0)
43 + [3] Let mutate y$8_@0[1:7] = read x$7_@0
44 + [4] Reassign mutate x$9_@1 = Array []
45 + [5] Let mutate _$10_@2 = JSX <read Component$0 x={freeze x$9_@1} ></read Component$0>
46 + [6] Call mutate y$8_@0.push(read props$6.p1)
47 + [7] Const mutate $11_@3 = JSX <read Component$0 x={read x$9_@1} y={freeze y$8_@0} ></read Component$0>
48 "]
49 - bb0_instrs --> bb0_terminal(["Return read $5_@3"])
49 + bb0_instrs --> bb0_terminal(["Return read $11_@3"])
50 end
51
52 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md
+33 -32
@@ -36,44 +36,45 @@ function Component(props) {
36
37 ```
38 bb0:
39 - [1] Let mutate x$2_@0 = undefined
40 - [2] If (read props$1.cond) then:bb2 else:bb10
39 + [1] Let mutate x$7_@0 = undefined
40 + [2] If (read props$6.cond) then:bb2 else:bb10
41 bb2:
42 predecessor blocks: bb0
43 - [3] Const mutate $3_@1 = 2
44 - [4] Const mutate $4_@2 = 1
45 - [5] Const mutate $5_@3 = 0
46 - [6] Switch (read props$1.test)
47 - Case read $5_@3: bb8
48 - Case read $4_@2: bb6
49 - Case read $3_@1: bb4
43 + [3] Const mutate $8_@1 = 2
44 + [4] Const mutate $9_@2 = 1
45 + [5] Const mutate $10_@3 = 0
46 + [6] Switch (read props$6.test)
47 + Case read $10_@3: bb8
48 + Case read $9_@2: bb6
49 + Case read $8_@1: bb4
50 Default: bb4
51 bb8:
52 predecessor blocks: bb2
53 - [7] Reassign mutate x$2_@4[7:17] = read props$1.v0
53 + [7] Reassign mutate x$11_@4[7:17] = read props$6.v0
54 [8] Goto bb1
55 bb6:
56 predecessor blocks: bb2
57 - [9] Reassign mutate x$2_@4[7:17] = read props$1.v1
57 + [9] Reassign mutate x$12_@4[7:17] = read props$6.v1
58 [10] Goto bb1
59 bb4:
60 predecessor blocks: bb2
61 - [11] Reassign mutate x$2_@4[7:17] = read props$1.v2
61 + [11] Reassign mutate x$13_@4[7:17] = read props$6.v2
62 [12] Goto bb1
63 bb10:
64 predecessor blocks: bb0
65 - [13] If (read props$1.cond2) then:bb12 else:bb13
65 + [13] If (read props$6.cond2) then:bb12 else:bb13
66 bb12:
67 predecessor blocks: bb10
68 - [14] Reassign mutate x$2_@4[7:17] = read props$1.b
68 + [14] Reassign mutate x$14_@4[7:17] = read props$6.b
69 [15] Goto bb1
70 bb13:
71 predecessor blocks: bb10
72 - [16] Reassign mutate x$2_@4[7:17] = read props$1.c
72 + [16] Reassign mutate x$15_@4[7:17] = read props$6.c
73 [17] Goto bb1
74 bb1:
75 predecessor blocks: bb8 bb6 bb4 bb12 bb13
76 - [18] read x$2_@4
76 + x$16_@4[7:17]: phi(bb8: x$11_@4, bb6: x$12_@4, bb4: x$13_@4, bb12: x$14_@4, bb13: x$15_@4)
77 + [18] read x$16_@4
78 [19] Return
79 ```
80
@@ -84,54 +85,54 @@ flowchart TB
85 %% Basic Blocks
86 subgraph bb0
87 bb0_instrs["
87 - [1] Let mutate x$2_@0 = undefined
88 + [1] Let mutate x$7_@0 = undefined
89 "]
89 - bb0_instrs --> bb0_terminal(["If (read props$1.cond)"])
90 + bb0_instrs --> bb0_terminal(["If (read props$6.cond)"])
91 end
92 subgraph bb2
93 bb2_instrs["
93 - [3] Const mutate $3_@1 = 2
94 - [4] Const mutate $4_@2 = 1
95 - [5] Const mutate $5_@3 = 0
94 + [3] Const mutate $8_@1 = 2
95 + [4] Const mutate $9_@2 = 1
96 + [5] Const mutate $10_@3 = 0
97 "]
97 - bb2_instrs --> bb2_terminal(["Switch (read props$1.test)"])
98 + bb2_instrs --> bb2_terminal(["Switch (read props$6.test)"])
99 end
100 subgraph bb8
101 bb8_instrs["
101 - [7] Reassign mutate x$2_@4[7:17] = read props$1.v0
102 + [7] Reassign mutate x$11_@4[7:17] = read props$6.v0
103 "]
104 bb8_instrs --> bb8_terminal(["Goto"])
105 end
106 subgraph bb6
107 bb6_instrs["
107 - [9] Reassign mutate x$2_@4[7:17] = read props$1.v1
108 + [9] Reassign mutate x$12_@4[7:17] = read props$6.v1
109 "]
110 bb6_instrs --> bb6_terminal(["Goto"])
111 end
112 subgraph bb4
113 bb4_instrs["
113 - [11] Reassign mutate x$2_@4[7:17] = read props$1.v2
114 + [11] Reassign mutate x$13_@4[7:17] = read props$6.v2
115 "]
116 bb4_instrs --> bb4_terminal(["Goto"])
117 end
118 subgraph bb10
118 - bb10_terminal(["If (read props$1.cond2)"])
119 + bb10_terminal(["If (read props$6.cond2)"])
120 end
121 subgraph bb12
122 bb12_instrs["
122 - [14] Reassign mutate x$2_@4[7:17] = read props$1.b
123 + [14] Reassign mutate x$14_@4[7:17] = read props$6.b
124 "]
125 bb12_instrs --> bb12_terminal(["Goto"])
126 end
127 subgraph bb13
128 bb13_instrs["
128 - [16] Reassign mutate x$2_@4[7:17] = read props$1.c
129 + [16] Reassign mutate x$15_@4[7:17] = read props$6.c
130 "]
131 bb13_instrs --> bb13_terminal(["Goto"])
132 end
133 subgraph bb1
134 bb1_instrs["
134 - [18] read x$2_@4
135 + [18] read x$16_@4
136 "]
137 bb1_instrs --> bb1_terminal(["Return"])
138 end
@@ -140,9 +141,9 @@ flowchart TB
141 bb0_terminal -- "then" --> bb2
142 bb0_terminal -- "else" --> bb10
143 bb0_terminal -- "fallthrough" --> bb1
143 - bb2_terminal -- "read $5_@3" --> bb8
144 - bb2_terminal -- "read $4_@2" --> bb6
145 - bb2_terminal -- "read $3_@1" --> bb4
144 + bb2_terminal -- "read $10_@3" --> bb8
145 + bb2_terminal -- "read $9_@2" --> bb6
146 + bb2_terminal -- "read $8_@1" --> bb4
147 bb2_terminal -- "default" --> bb4
148 bb2_terminal -- "fallthrough" --> bb1
149 bb8_terminal --> bb1
compiler/forget/src/__tests__/fixtures/hir/simple-alias.expect.md
+16 -16
@@ -46,14 +46,14 @@ function mutate$0() {}
46
47 ```
48 bb0:
49 - [1] Let mutate a$1_@0 = Object { }
50 - [2] Let mutate b$2_@1[0:8] = Object { }
51 - [3] Let mutate c$3_@1[0:8] = Object { }
52 - [4] Reassign mutate a$1_@1[0:8] = read b$2_@1
53 - [5] Reassign mutate b$2_@1[0:8] = read c$3_@1
54 - [6] Reassign mutate c$3_@1[0:8] = read a$1_@1
55 - [7] Call mutate mutate$4_@1(mutate a$1_@1, mutate b$2_@1)
56 - [8] Return freeze c$3_@1
49 + [1] Let mutate a$5_@0 = Object { }
50 + [2] Let mutate b$6_@1[0:8] = Object { }
51 + [3] Let mutate c$7_@1[0:8] = Object { }
52 + [4] Reassign mutate a$8_@1[0:8] = read b$6_@1
53 + [5] Reassign mutate b$9_@1[0:8] = read c$7_@1
54 + [6] Reassign mutate c$10_@1[0:8] = read a$8_@1
55 + [7] Call mutate mutate$4_@1(mutate a$8_@1, mutate b$9_@1)
56 + [8] Return freeze c$10_@1
57 ```
58
59 ### CFG
@@ -63,15 +63,15 @@ flowchart TB
63 %% Basic Blocks
64 subgraph bb0
65 bb0_instrs["
66 - [1] Let mutate a$1_@0 = Object { }
67 - [2] Let mutate b$2_@1[0:8] = Object { }
68 - [3] Let mutate c$3_@1[0:8] = Object { }
69 - [4] Reassign mutate a$1_@1[0:8] = read b$2_@1
70 - [5] Reassign mutate b$2_@1[0:8] = read c$3_@1
71 - [6] Reassign mutate c$3_@1[0:8] = read a$1_@1
72 - [7] Call mutate mutate$4_@1(mutate a$1_@1, mutate b$2_@1)
66 + [1] Let mutate a$5_@0 = Object { }
67 + [2] Let mutate b$6_@1[0:8] = Object { }
68 + [3] Let mutate c$7_@1[0:8] = Object { }
69 + [4] Reassign mutate a$8_@1[0:8] = read b$6_@1
70 + [5] Reassign mutate b$9_@1[0:8] = read c$7_@1
71 + [6] Reassign mutate c$10_@1[0:8] = read a$8_@1
72 + [7] Call mutate mutate$4_@1(mutate a$8_@1, mutate b$9_@1)
73 "]
74 - bb0_instrs --> bb0_terminal(["Return freeze c$3_@1"])
74 + bb0_instrs --> bb0_terminal(["Return freeze c$10_@1"])
75 end
76
77 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/simple.expect.md
+16 -16
@@ -15,18 +15,18 @@ function foo(x, y) {
15
16 ```
17 bb0:
18 - [1] If (read x$1) then:bb2 else:bb1
18 + [1] If (read x$8) then:bb2 else:bb1
19 bb2:
20 predecessor blocks: bb0
21 - [2] Const mutate $3_@0 = false
22 - [3] Const mutate $4_@1 = Call read foo$0(read $3_@0, read y$2)
23 - [4] Return freeze $4_@1
21 + [2] Const mutate $10_@0 = false
22 + [3] Const mutate $11_@1 = Call read foo$0(read $10_@0, read y$9)
23 + [4] Return freeze $11_@1
24 bb1:
25 predecessor blocks: bb0
26 - [5] Const mutate $5_@2 = 10
27 - [6] Const mutate $6_@3 = Binary read y$2 * read $5_@2
28 - [7] Const mutate $7_@4 = Array [read $6_@3]
29 - [8] Return freeze $7_@4
26 + [5] Const mutate $12_@2 = 10
27 + [6] Const mutate $13_@3 = Binary read y$9 * read $12_@2
28 + [7] Const mutate $14_@4 = Array [read $13_@3]
29 + [8] Return freeze $14_@4
30 ```
31
32 ### CFG
@@ -35,22 +35,22 @@ bb1:
35 flowchart TB
36 %% Basic Blocks
37 subgraph bb0
38 - bb0_terminal(["If (read x$1)"])
38 + bb0_terminal(["If (read x$8)"])
39 end
40 subgraph bb2
41 bb2_instrs["
42 - [2] Const mutate $3_@0 = false
43 - [3] Const mutate $4_@1 = Call read foo$0(read $3_@0, read y$2)
42 + [2] Const mutate $10_@0 = false
43 + [3] Const mutate $11_@1 = Call read foo$0(read $10_@0, read y$9)
44 "]
45 - bb2_instrs --> bb2_terminal(["Return freeze $4_@1"])
45 + bb2_instrs --> bb2_terminal(["Return freeze $11_@1"])
46 end
47 subgraph bb1
48 bb1_instrs["
49 - [5] Const mutate $5_@2 = 10
50 - [6] Const mutate $6_@3 = Binary read y$2 * read $5_@2
51 - [7] Const mutate $7_@4 = Array [read $6_@3]
49 + [5] Const mutate $12_@2 = 10
50 + [6] Const mutate $13_@3 = Binary read y$9 * read $12_@2
51 + [7] Const mutate $14_@4 = Array [read $13_@3]
52 "]
53 - bb1_instrs --> bb1_terminal(["Return freeze $7_@4"])
53 + bb1_instrs --> bb1_terminal(["Return freeze $14_@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_@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 - [4] Return freeze x$4_@2
18 + [1] Const mutate a$6_@0 = 1
19 + [2] Const mutate b$7_@1 = 2
20 + [3] Const mutate x$8_@2 = Array [read a$6_@0, read b$7_@1]
21 + [4] Return freeze x$8_@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_@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]
31 + [1] Const mutate a$6_@0 = 1
32 + [2] Const mutate b$7_@1 = 2
33 + [3] Const mutate x$8_@2 = Array [read a$6_@0, read b$7_@1]
34 "]
35 - bb0_instrs --> bb0_terminal(["Return freeze x$4_@2"])
35 + bb0_instrs --> bb0_terminal(["Return freeze x$8_@2"])
36 end
37
38 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md
+22 -22
@@ -48,22 +48,22 @@ function foo$0() {}
48
49 ```
50 bb0:
51 - [1] Const mutate a$2_@0[0:10] = Array []
52 - [2] Const mutate b$3_@0[0:10] = Object { }
53 - [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
54 - [4] Const mutate $7_@0[0:10] = Call mutate foo$4_@0()
55 - [5] If (read $7_@0) then:bb2 else:bb1
51 + [1] Const mutate a$11_@0[0:10] = Array []
52 + [2] Const mutate b$12_@0[0:10] = Object { }
53 + [3] Call mutate foo$4_@0(mutate a$11_@0, mutate b$12_@0)
54 + [4] Const mutate $13_@0[0:10] = Call mutate foo$4_@0()
55 + [5] If (read $13_@0) then:bb2 else:bb1
56 bb2:
57 predecessor blocks: bb0
58 - [6] Const mutate $6_@1 = "div"
59 - [7] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
58 + [6] Const mutate $14_@1 = "div"
59 + [7] Let mutate _$15_@2 = JSX <read $14_@1 a={freeze a$11_@0} ></read $14_@1>
60 [8] Goto bb1
61 bb1:
62 predecessor blocks: bb2 bb0
63 - [9] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0)
64 - [10] Const mutate $8_@3 = "div"
65 - [11] Const mutate $9_@4 = JSX <read $8_@3 a={freeze a$2_@0} b={freeze b$3_@0} ></read $8_@3>
66 - [12] Return read $9_@4
63 + [9] Call mutate foo$4_@0(read a$11_@0, mutate b$12_@0)
64 + [10] Const mutate $19_@3 = "div"
65 + [11] Const mutate $20_@4 = JSX <read $19_@3 a={freeze a$11_@0} b={freeze b$12_@0} ></read $19_@3>
66 + [12] Return read $20_@4
67 ```
68
69 ### CFG
@@ -73,27 +73,27 @@ flowchart TB
73 %% Basic Blocks
74 subgraph bb0
75 bb0_instrs["
76 - [1] Const mutate a$2_@0[0:10] = Array []
77 - [2] Const mutate b$3_@0[0:10] = Object { }
78 - [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
79 - [4] Const mutate $7_@0[0:10] = Call mutate foo$4_@0()
76 + [1] Const mutate a$11_@0[0:10] = Array []
77 + [2] Const mutate b$12_@0[0:10] = Object { }
78 + [3] Call mutate foo$4_@0(mutate a$11_@0, mutate b$12_@0)
79 + [4] Const mutate $13_@0[0:10] = Call mutate foo$4_@0()
80 "]
81 - bb0_instrs --> bb0_terminal(["If (read $7_@0)"])
81 + bb0_instrs --> bb0_terminal(["If (read $13_@0)"])
82 end
83 subgraph bb2
84 bb2_instrs["
85 - [6] Const mutate $6_@1 = 'div'
86 - [7] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
85 + [6] Const mutate $14_@1 = 'div'
86 + [7] Let mutate _$15_@2 = JSX <read $14_@1 a={freeze a$11_@0} ></read $14_@1>
87 "]
88 bb2_instrs --> bb2_terminal(["Goto"])
89 end
90 subgraph bb1
91 bb1_instrs["
92 - [9] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0)
93 - [10] Const mutate $8_@3 = 'div'
94 - [11] Const mutate $9_@4 = JSX <read $8_@3 a={freeze a$2_@0} b={freeze b$3_@0} ></read $8_@3>
92 + [9] Call mutate foo$4_@0(read a$11_@0, mutate b$12_@0)
93 + [10] Const mutate $19_@3 = 'div'
94 + [11] Const mutate $20_@4 = JSX <read $19_@3 a={freeze a$11_@0} b={freeze b$12_@0} ></read $19_@3>
95 "]
96 - bb1_instrs --> bb1_terminal(["Return read $9_@4"])
96 + bb1_instrs --> bb1_terminal(["Return read $20_@4"])
97 end
98
99 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md
+18 -18
@@ -45,15 +45,15 @@ function foo$0() {}
45
46 ```
47 bb0:
48 - [1] Const mutate a$2_@0[0:7] = Array []
49 - [2] Const mutate b$3_@0[0:7] = Object { }
50 - [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
51 - [4] Const mutate $6_@1 = "div"
52 - [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
53 - [6] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0)
54 - [7] Const mutate $7_@3 = "div"
55 - [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
56 - [9] Return read $8_@4
48 + [1] Const mutate a$10_@0[0:7] = Array []
49 + [2] Const mutate b$11_@0[0:7] = Object { }
50 + [3] Call mutate foo$4_@0(mutate a$10_@0, mutate b$11_@0)
51 + [4] Const mutate $12_@1 = "div"
52 + [5] Let mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
53 + [6] Call mutate foo$4_@0(read a$10_@0, mutate b$11_@0)
54 + [7] Const mutate $14_@3 = "div"
55 + [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
56 + [9] Return read $15_@4
57 ```
58
59 ### CFG
@@ -63,16 +63,16 @@ flowchart TB
63 %% Basic Blocks
64 subgraph bb0
65 bb0_instrs["
66 - [1] Const mutate a$2_@0[0:7] = Array []
67 - [2] Const mutate b$3_@0[0:7] = Object { }
68 - [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
69 - [4] Const mutate $6_@1 = 'div'
70 - [5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
71 - [6] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0)
72 - [7] Const mutate $7_@3 = 'div'
73 - [8] Const mutate $8_@4 = JSX <read $7_@3 a={read a$2_@0} b={freeze b$3_@0} ></read $7_@3>
66 + [1] Const mutate a$10_@0[0:7] = Array []
67 + [2] Const mutate b$11_@0[0:7] = Object { }
68 + [3] Call mutate foo$4_@0(mutate a$10_@0, mutate b$11_@0)
69 + [4] Const mutate $12_@1 = 'div'
70 + [5] Let mutate _$13_@2 = JSX <read $12_@1 a={freeze a$10_@0} ></read $12_@1>
71 + [6] Call mutate foo$4_@0(read a$10_@0, mutate b$11_@0)
72 + [7] Const mutate $14_@3 = 'div'
73 + [8] Const mutate $15_@4 = JSX <read $14_@3 a={read a$10_@0} b={freeze b$11_@0} ></read $14_@3>
74 "]
75 - bb0_instrs --> bb0_terminal(["Return read $8_@4"])
75 + bb0_instrs --> bb0_terminal(["Return read $15_@4"])
76 end
77
78 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md
+24 -22
@@ -21,27 +21,29 @@ function foo() {
21
22 ```
23 bb0:
24 - [1] Let mutate x$1_@0[1:14] = 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 - [5] If (read $4_@3) then:bb2 else:bb1
24 + [1] Let mutate x$7_@0[1:14] = 1
25 + [2] Let mutate y$8_@1 = 2
26 + [3] Const mutate $9_@2 = 2
27 + [4] Const mutate $10_@3 = Binary read y$8_@1 === read $9_@2
28 + [5] If (read $10_@3) then:bb2 else:bb1
29 bb2:
30 predecessor blocks: bb0
31 - [6] Reassign mutate x$1_@0[1:14] = 3
31 + [6] Reassign mutate x$11_@0[1:14] = 3
32 [7] Goto bb1
33 bb1:
34 predecessor blocks: bb2 bb0
35 - [8] Const mutate $5_@4 = 3
36 - [9] Const mutate $6_@5 = Binary read y$2_@1 === read $5_@4
37 - [10] If (read $6_@5) then:bb4 else:bb3
35 + x$17_@0[1:14]: phi(bb2: x$11_@0, bb0: x$7_@0)
36 + [8] Const mutate $12_@4 = 3
37 + [9] Const mutate $14_@5 = Binary read y$8_@1 === read $12_@4
38 + [10] If (read $14_@5) then:bb4 else:bb3
39 bb4:
40 predecessor blocks: bb1
40 - [11] Reassign mutate x$1_@0[1:14] = 5
41 + [11] Reassign mutate x$15_@0[1:14] = 5
42 [12] Goto bb3
43 bb3:
44 predecessor blocks: bb4 bb1
44 - [13] Reassign mutate y$2_@0[1:14] = read x$1_@0
45 + x$16_@0[1:14]: phi(bb4: x$15_@0, bb1: x$17_@0)
46 + [13] Reassign mutate y$18_@0[1:14] = read x$16_@0
47 [14] Return
48 ```
49
@@ -52,35 +54,35 @@ flowchart TB
54 %% Basic Blocks
55 subgraph bb0
56 bb0_instrs["
55 - [1] Let mutate x$1_@0[1:14] = 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
57 + [1] Let mutate x$7_@0[1:14] = 1
58 + [2] Let mutate y$8_@1 = 2
59 + [3] Const mutate $9_@2 = 2
60 + [4] Const mutate $10_@3 = Binary read y$8_@1 === read $9_@2
61 "]
60 - bb0_instrs --> bb0_terminal(["If (read $4_@3)"])
62 + bb0_instrs --> bb0_terminal(["If (read $10_@3)"])
63 end
64 subgraph bb2
65 bb2_instrs["
64 - [6] Reassign mutate x$1_@0[1:14] = 3
66 + [6] Reassign mutate x$11_@0[1:14] = 3
67 "]
68 bb2_instrs --> bb2_terminal(["Goto"])
69 end
70 subgraph bb1
71 bb1_instrs["
70 - [8] Const mutate $5_@4 = 3
71 - [9] Const mutate $6_@5 = Binary read y$2_@1 === read $5_@4
72 + [8] Const mutate $12_@4 = 3
73 + [9] Const mutate $14_@5 = Binary read y$8_@1 === read $12_@4
74 "]
73 - bb1_instrs --> bb1_terminal(["If (read $6_@5)"])
75 + bb1_instrs --> bb1_terminal(["If (read $14_@5)"])
76 end
77 subgraph bb4
78 bb4_instrs["
77 - [11] Reassign mutate x$1_@0[1:14] = 5
79 + [11] Reassign mutate x$15_@0[1:14] = 5
80 "]
81 bb4_instrs --> bb4_terminal(["Goto"])
82 end
83 subgraph bb3
84 bb3_instrs["
83 - [13] Reassign mutate y$2_@0[1:14] = read x$1_@0
85 + [13] Reassign mutate y$18_@0[1:14] = read x$16_@0
86 "]
87 bb3_instrs --> bb3_terminal(["Return"])
88 end
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md
+15 -14
@@ -18,18 +18,19 @@ function foo() {
18
19 ```
20 bb0:
21 - [1] Let mutate x$1_@0[1:9] = 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 - [5] If (read $4_@3) then:bb2 else:bb1
21 + [1] Let mutate x$5_@0[1:9] = 1
22 + [2] Let mutate y$6_@1 = 2
23 + [3] Const mutate $7_@2 = 2
24 + [4] Const mutate $8_@3 = Binary read y$6_@1 === read $7_@2
25 + [5] If (read $8_@3) then:bb2 else:bb1
26 bb2:
27 predecessor blocks: bb0
28 - [6] Reassign mutate x$1_@0[1:9] = 3
28 + [6] Reassign mutate x$9_@0[1:9] = 3
29 [7] Goto bb1
30 bb1:
31 predecessor blocks: bb2 bb0
32 - [8] Reassign mutate y$2_@0[1:9] = read x$1_@0
32 + x$10_@0[1:9]: phi(bb2: x$9_@0, bb0: x$5_@0)
33 + [8] Reassign mutate y$11_@0[1:9] = read x$10_@0
34 [9] Return
35 ```
36
@@ -40,22 +41,22 @@ flowchart TB
41 %% Basic Blocks
42 subgraph bb0
43 bb0_instrs["
43 - [1] Let mutate x$1_@0[1:9] = 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
44 + [1] Let mutate x$5_@0[1:9] = 1
45 + [2] Let mutate y$6_@1 = 2
46 + [3] Const mutate $7_@2 = 2
47 + [4] Const mutate $8_@3 = Binary read y$6_@1 === read $7_@2
48 "]
48 - bb0_instrs --> bb0_terminal(["If (read $4_@3)"])
49 + bb0_instrs --> bb0_terminal(["If (read $8_@3)"])
50 end
51 subgraph bb2
52 bb2_instrs["
52 - [6] Reassign mutate x$1_@0[1:9] = 3
53 + [6] Reassign mutate x$9_@0[1:9] = 3
54 "]
55 bb2_instrs --> bb2_terminal(["Goto"])
56 end
57 subgraph bb1
58 bb1_instrs["
58 - [8] Reassign mutate y$2_@0[1:9] = read x$1_@0
59 + [8] Reassign mutate y$11_@0[1:9] = read x$10_@0
60 "]
61 bb1_instrs --> bb1_terminal(["Return"])
62 end
compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md
+12 -12
@@ -19,25 +19,25 @@ function foo(cond) {
19
20 ```
21 bb0:
22 - [1] Let mutate items$2_@0 = Array []
22 + [1] Let mutate items$5_@0 = Array []
23 [2] Goto bb1
24 bb1:
25 predecessor blocks: bb0 bb4
26 - [3] If (read items$2_@0) then:bb3 else:bb2
26 + [3] If (read items$5_@0) then:bb3 else:bb2
27 bb3:
28 predecessor blocks: bb1
29 - [4] Let mutate y$3_@1 = 0
30 - [5] If (read cond$1) then:bb5 else:bb4
29 + [4] Let mutate y$7_@1 = 0
30 + [5] If (read cond$4) then:bb5 else:bb4
31 bb5:
32 predecessor blocks: bb3
33 - [6] Reassign mutate y$3_@2 = 1
33 + [6] Reassign mutate y$9_@2 = 1
34 [7] Goto bb4
35 bb4:
36 predecessor blocks: bb5 bb3
37 [8] Goto(Continue) bb1
38 bb2:
39 predecessor blocks: bb1
40 - [9] Return freeze items$2_@0
40 + [9] Return freeze items$5_@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_@0 = Array []
50 + [1] Let mutate items$5_@0 = Array []
51 "]
52 bb0_instrs --> bb0_terminal(["Goto"])
53 end
54 subgraph bb1
55 - bb1_terminal(["If (read items$2_@0)"])
55 + bb1_terminal(["If (read items$5_@0)"])
56 end
57 subgraph bb3
58 bb3_instrs["
59 - [4] Let mutate y$3_@1 = 0
59 + [4] Let mutate y$7_@1 = 0
60 "]
61 - bb3_instrs --> bb3_terminal(["If (read cond$1)"])
61 + bb3_instrs --> bb3_terminal(["If (read cond$4)"])
62 end
63 subgraph bb5
64 bb5_instrs["
65 - [6] Reassign mutate y$3_@2 = 1
65 + [6] Reassign mutate y$9_@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_@0"])
73 + bb2_terminal(["Return freeze items$5_@0"])
74 end
75
76 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md
+15 -14
@@ -16,21 +16,22 @@ function foo() {
16
17 ```
18 bb0:
19 - [1] Let mutate x$1_@0[0:8] = 0
19 + [1] Let mutate x$5_@0[0:8] = 0
20 [2] Goto bb1
21 bb1:
22 predecessor blocks: bb0 bb4
23 - [3] Const mutate $3_@1 = 10
24 - [4] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1
25 - [5] If (read $4_@2) then:bb4 else:bb2
23 + x$7_@0[0:8]: phi(bb0: x$5_@0, bb4: x$10_@0)
24 + [3] Const mutate $6_@1 = 10
25 + [4] Const mutate $8_@2 = Binary read x$7_@0 < read $6_@1
26 + [5] If (read $8_@2) then:bb4 else:bb2
27 bb4:
28 predecessor blocks: bb1
28 - [6] Const mutate $2_@3 = 1
29 - [7] Reassign mutate x$1_@0[0:8] = Binary read x$1_@0 + read $2_@3
29 + [6] Const mutate $9_@3 = 1
30 + [7] Reassign mutate x$10_@0[0:8] = Binary read x$7_@0 + read $9_@3
31 [8] Goto(Continue) bb1
32 bb2:
33 predecessor blocks: bb1
33 - [9] Return read x$1_@0
34 + [9] Return read x$7_@0
35 ```
36
37 ### CFG
@@ -40,26 +41,26 @@ flowchart TB
41 %% Basic Blocks
42 subgraph bb0
43 bb0_instrs["
43 - [1] Let mutate x$1_@0[0:8] = 0
44 + [1] Let mutate x$5_@0[0:8] = 0
45 "]
46 bb0_instrs --> bb0_terminal(["Goto"])
47 end
48 subgraph bb1
49 bb1_instrs["
49 - [3] Const mutate $3_@1 = 10
50 - [4] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1
50 + [3] Const mutate $6_@1 = 10
51 + [4] Const mutate $8_@2 = Binary read x$7_@0 < read $6_@1
52 "]
52 - bb1_instrs --> bb1_terminal(["If (read $4_@2)"])
53 + bb1_instrs --> bb1_terminal(["If (read $8_@2)"])
54 end
55 subgraph bb4
56 bb4_instrs["
56 - [6] Const mutate $2_@3 = 1
57 - [7] Reassign mutate x$1_@0[0:8] = Binary read x$1_@0 + read $2_@3
57 + [6] Const mutate $9_@3 = 1
58 + [7] Reassign mutate x$10_@0[0:8] = Binary read x$7_@0 + read $9_@3
59 "]
60 bb4_instrs --> bb4_terminal(["Goto"])
61 end
62 subgraph bb2
62 - bb2_terminal(["Return read x$1_@0"])
63 + bb2_terminal(["Return read x$7_@0"])
64 end
65
66 %% Jumps
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_@0[1:8] = 1
23 - [2] Let mutate y$2_@1 = 2
24 - [3] If (read y$2_@1) then:bb2 else:bb3
22 + [1] Let mutate x$5_@0[1:8] = 1
23 + [2] Let mutate y$6_@1 = 2
24 + [3] If (read y$6_@1) then:bb2 else:bb3
25 bb2:
26 predecessor blocks: bb0
27 - [4] Let mutate z$3_@0[1:7] = Binary read x$1_@0 + read y$2_@1
27 + [4] Let mutate z$7_@0[1:7] = Binary read x$5_@0 + read y$6_@1
28 [5] Goto bb1
29 bb3:
30 predecessor blocks: bb0
31 - [6] Let mutate z$4_@0[1:7] = read x$1_@0
31 + [6] Let mutate z$8_@0[1:7] = read x$5_@0
32 [7] 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_@0[1:8] = 1
46 - [2] Let mutate y$2_@1 = 2
45 + [1] Let mutate x$5_@0[1:8] = 1
46 + [2] Let mutate y$6_@1 = 2
47 "]
48 - bb0_instrs --> bb0_terminal(["If (read y$2_@1)"])
48 + bb0_instrs --> bb0_terminal(["If (read y$6_@1)"])
49 end
50 subgraph bb2
51 bb2_instrs["
52 - [4] Let mutate z$3_@0[1:7] = Binary read x$1_@0 + read y$2_@1
52 + [4] Let mutate z$7_@0[1:7] = Binary read x$5_@0 + read y$6_@1
53 "]
54 bb2_instrs --> bb2_terminal(["Goto"])
55 end
56 subgraph bb3
57 bb3_instrs["
58 - [6] Let mutate z$4_@0[1:7] = read x$1_@0
58 + [6] Let mutate z$8_@0[1:7] = read x$5_@0
59 "]
60 bb3_instrs --> bb3_terminal(["Goto"])
61 end
compiler/forget/src/__tests__/fixtures/hir/ssa-nested-loops-no-reassign.expect.md
+14 -14
@@ -21,27 +21,27 @@ function foo(a, b, c) {
21
22 ```
23 bb0:
24 - [1] Let mutate x$4_@0 = 0
24 + [1] Let mutate x$9_@0 = 0
25 [2] While test=bb1 loop=bb3 fallthrough=bb2
26 bb1:
27 predecessor blocks: bb0 bb5
28 - [3] If (read a$1) then:bb3 else:bb2
28 + [3] If (read a$6) then:bb3 else:bb2
29 bb3:
30 predecessor blocks: bb1
31 [4] While test=bb4 loop=bb6 fallthrough=bb5
32 bb4:
33 predecessor blocks: bb3 bb8
34 - [5] If (read b$2) then:bb6 else:bb5
34 + [5] If (read b$7) then:bb6 else:bb5
35 bb6:
36 predecessor blocks: bb4
37 [6] While test=bb7 loop=bb9 fallthrough=bb8
38 bb7:
39 predecessor blocks: bb6 bb9
40 - [7] If (read c$3) then:bb9 else:bb8
40 + [7] If (read c$8) then:bb9 else:bb8
41 bb9:
42 predecessor blocks: bb7
43 - [8] Const mutate $5_@1 = 1
44 - [9] Binary read x$4_@0 + read $5_@1
43 + [8] Const mutate $13_@1 = 1
44 + [9] Binary read x$9_@0 + read $13_@1
45 [10] Goto(Continue) bb7
46 bb8:
47 predecessor blocks: bb7
@@ -51,7 +51,7 @@ bb5:
51 [12] Goto(Continue) bb1
52 bb2:
53 predecessor blocks: bb1
54 - [13] Return read x$4_@0
54 + [13] Return read x$9_@0
55 ```
56
57 ### CFG
@@ -61,29 +61,29 @@ flowchart TB
61 %% Basic Blocks
62 subgraph bb0
63 bb0_instrs["
64 - [1] Let mutate x$4_@0 = 0
64 + [1] Let mutate x$9_@0 = 0
65 "]
66 bb0_instrs --> bb0_terminal(["While"])
67 end
68 subgraph bb1
69 - bb1_terminal(["If (read a$1)"])
69 + bb1_terminal(["If (read a$6)"])
70 end
71 subgraph bb3
72 bb3_terminal(["While"])
73 end
74 subgraph bb4
75 - bb4_terminal(["If (read b$2)"])
75 + bb4_terminal(["If (read b$7)"])
76 end
77 subgraph bb6
78 bb6_terminal(["While"])
79 end
80 subgraph bb7
81 - bb7_terminal(["If (read c$3)"])
81 + bb7_terminal(["If (read c$8)"])
82 end
83 subgraph bb9
84 bb9_instrs["
85 - [8] Const mutate $5_@1 = 1
86 - [9] Binary read x$4_@0 + read $5_@1
85 + [8] Const mutate $13_@1 = 1
86 + [9] Binary read x$9_@0 + read $13_@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_@0"])
97 + bb2_terminal(["Return read x$9_@0"])
98 end
99
100 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md
+8 -8
@@ -43,10 +43,10 @@ function Foo$0() {}
43
44 ```
45 bb0:
46 - [1] Const mutate a$2_@0[0:4] = Array []
47 - [2] Const mutate b$3_@0[0:4] = Object { }
48 - [3] Let mutate c$4_@0[0:4] = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0)
49 - [4] Return freeze c$4_@0
46 + [1] Const mutate a$7_@0[0:4] = Array []
47 + [2] Const mutate b$8_@0[0:4] = Object { }
48 + [3] Let mutate c$9_@0[0:4] = New mutate Foo$5_@0(mutate a$7_@0, mutate b$8_@0)
49 + [4] Return freeze c$9_@0
50 ```
51
52 ### CFG
@@ -56,11 +56,11 @@ flowchart TB
56 %% Basic Blocks
57 subgraph bb0
58 bb0_instrs["
59 - [1] Const mutate a$2_@0[0:4] = Array []
60 - [2] Const mutate b$3_@0[0:4] = Object { }
61 - [3] Let mutate c$4_@0[0:4] = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0)
59 + [1] Const mutate a$7_@0[0:4] = Array []
60 + [2] Const mutate b$8_@0[0:4] = Object { }
61 + [3] Let mutate c$9_@0[0:4] = New mutate Foo$5_@0(mutate a$7_@0, mutate b$8_@0)
62 "]
63 - bb0_instrs --> bb0_terminal(["Return freeze c$4_@0"])
63 + bb0_instrs --> bb0_terminal(["Return freeze c$9_@0"])
64 end
65
66 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md
+20 -18
@@ -22,23 +22,25 @@ function foo() {
22
23 ```
24 bb0:
25 - [1] Let mutate x$1_@0[1:10] = 1
26 - [2] Let mutate y$2_@1[2:10] = 2
27 - [3] Const mutate $3_@2 = 1
28 - [4] Const mutate $4_@3 = Binary read x$1_@0 > read $3_@2
29 - [5] If (read $4_@3) then:bb2 else:bb3
25 + [1] Let mutate x$6_@0[1:10] = 1
26 + [2] Let mutate y$7_@1[2:10] = 2
27 + [3] Const mutate $8_@2 = 1
28 + [4] Const mutate $9_@3 = Binary read x$6_@0 > read $8_@2
29 + [5] If (read $9_@3) then:bb2 else:bb3
30 bb2:
31 predecessor blocks: bb0
32 - [6] Reassign mutate x$1_@0[1:7] = 2
32 + [6] Reassign mutate x$10_@0[1:7] = 2
33 [7] Goto bb1
34 bb3:
35 predecessor blocks: bb0
36 - [8] Reassign mutate y$2_@1[2:9] = 3
36 + [8] Reassign mutate y$11_@1[2:9] = 3
37 [9] Goto bb1
38 bb1:
39 predecessor blocks: bb2 bb3
40 - [10] Let mutate t$5_@4 = Object { x: read x$1_@0, y: read y$2_@1 }
41 - [11] Return freeze t$5_@4
40 + x$12_@0[1:7]: phi(bb2: x$10_@0, bb3: x$6_@0)
41 + y$13_@1[2:9]: phi(bb2: y$7_@1, bb3: y$11_@1)
42 + [10] Let mutate t$14_@4 = Object { x: read x$12_@0, y: read y$13_@1 }
43 + [11] Return freeze t$14_@4
44 ```
45
46 ### CFG
@@ -48,30 +50,30 @@ flowchart TB
50 %% Basic Blocks
51 subgraph bb0
52 bb0_instrs["
51 - [1] Let mutate x$1_@0[1:10] = 1
52 - [2] Let mutate y$2_@1[2:10] = 2
53 - [3] Const mutate $3_@2 = 1
54 - [4] Const mutate $4_@3 = Binary read x$1_@0 > read $3_@2
53 + [1] Let mutate x$6_@0[1:10] = 1
54 + [2] Let mutate y$7_@1[2:10] = 2
55 + [3] Const mutate $8_@2 = 1
56 + [4] Const mutate $9_@3 = Binary read x$6_@0 > read $8_@2
57 "]
56 - bb0_instrs --> bb0_terminal(["If (read $4_@3)"])
58 + bb0_instrs --> bb0_terminal(["If (read $9_@3)"])
59 end
60 subgraph bb2
61 bb2_instrs["
60 - [6] Reassign mutate x$1_@0[1:7] = 2
62 + [6] Reassign mutate x$10_@0[1:7] = 2
63 "]
64 bb2_instrs --> bb2_terminal(["Goto"])
65 end
66 subgraph bb3
67 bb3_instrs["
66 - [8] Reassign mutate y$2_@1[2:9] = 3
68 + [8] Reassign mutate y$11_@1[2:9] = 3
69 "]
70 bb3_instrs --> bb3_terminal(["Goto"])
71 end
72 subgraph bb1
73 bb1_instrs["
72 - [10] Let mutate t$5_@4 = Object { x: read x$1_@0, y: read y$2_@1 }
74 + [10] Let mutate t$14_@4 = Object { x: read x$12_@0, y: read y$13_@1 }
75 "]
74 - bb1_instrs --> bb1_terminal(["Return freeze t$5_@4"])
76 + bb1_instrs --> bb1_terminal(["Return freeze t$14_@4"])
77 end
78
79 %% 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_@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 - [4] Return freeze x$4_@2
18 + [1] Const mutate a$6_@0 = 1
19 + [2] Const mutate b$7_@1 = 2
20 + [3] Const mutate x$8_@2 = Object { a: read a$6_@0, b: read b$7_@1 }
21 + [4] Return freeze x$8_@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_@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 }
31 + [1] Const mutate a$6_@0 = 1
32 + [2] Const mutate b$7_@1 = 2
33 + [3] Const mutate x$8_@2 = Object { a: read a$6_@0, b: read b$7_@1 }
34 "]
35 - bb0_instrs --> bb0_terminal(["Return freeze x$4_@2"])
35 + bb0_instrs --> bb0_terminal(["Return freeze x$8_@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_@0 = Array []
19 - [2] Const mutate y$2_@1[2:5] = Object { x: read x$1_@0 }
20 - [3] Const mutate $3_@1[2:5] = Array []
21 - [4] Call mutate y$2_@1.x.push(mutate $3_@1)
22 - [5] Return freeze y$2_@1
18 + [1] Const mutate x$4_@0 = Array []
19 + [2] Const mutate y$5_@1[2:5] = Object { x: read x$4_@0 }
20 + [3] Const mutate $6_@1[2:5] = Array []
21 + [4] Call mutate y$5_@1.x.push(mutate $6_@1)
22 + [5] Return freeze y$5_@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_@0 = Array []
33 - [2] Const mutate y$2_@1[2:5] = Object { x: read x$1_@0 }
34 - [3] Const mutate $3_@1[2:5] = Array []
35 - [4] Call mutate y$2_@1.x.push(mutate $3_@1)
32 + [1] Const mutate x$4_@0 = Array []
33 + [2] Const mutate y$5_@1[2:5] = Object { x: read x$4_@0 }
34 + [3] Const mutate $6_@1[2:5] = Array []
35 + [4] Call mutate y$5_@1.x.push(mutate $6_@1)
36 "]
37 - bb0_instrs --> bb0_terminal(["Return freeze y$2_@1"])
37 + bb0_instrs --> bb0_terminal(["Return freeze y$5_@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_@0 = Array []
19 - [2] Const mutate y$2_@1[2:4] = Object { }
20 - [3] Reassign mutate y$2_@1.x[2:4] = read x$1_@0
21 - [4] Return freeze y$2_@1
18 + [1] Const mutate x$3_@0 = Array []
19 + [2] Const mutate y$4_@1[2:4] = Object { }
20 + [3] Reassign mutate y$4_@1.x[2:4] = read x$3_@0
21 + [4] Return freeze y$4_@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_@0 = Array []
32 - [2] Const mutate y$2_@1[2:4] = Object { }
33 - [3] Reassign mutate y$2_@1.x[2:4] = read x$1_@0
31 + [1] Const mutate x$3_@0 = Array []
32 + [2] Const mutate y$4_@1[2:4] = Object { }
33 + [3] Reassign mutate y$4_@1.x[2:4] = read x$3_@0
34 "]
35 - bb0_instrs --> bb0_terminal(["Return freeze y$2_@1"])
35 + bb0_instrs --> bb0_terminal(["Return freeze y$4_@1"])
36 end
37
38 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md
+13 -12
@@ -17,17 +17,18 @@ function foo() {
17
18 ```
19 bb0:
20 - [1] Let mutate x$1_@0[1:7] = 1
21 - [2] Const mutate $2_@1 = 1
22 - [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
23 - [4] If (read $3_@2) then:bb2 else:bb1
20 + [1] Let mutate x$4_@0[1:7] = 1
21 + [2] Const mutate $5_@1 = 1
22 + [3] Const mutate $6_@2 = Binary read x$4_@0 === read $5_@1
23 + [4] If (read $6_@2) then:bb2 else:bb1
24 bb2:
25 predecessor blocks: bb0
26 - [5] Reassign mutate x$1_@0[1:6] = 2
26 + [5] Reassign mutate x$7_@0[1:6] = 2
27 [6] Goto bb1
28 bb1:
29 predecessor blocks: bb2 bb0
30 - [7] Return read x$1_@0
30 + x$8_@0[1:6]: phi(bb2: x$7_@0, bb0: x$4_@0)
31 + [7] Return read x$8_@0
32 ```
33
34 ### CFG
@@ -37,20 +38,20 @@ flowchart TB
38 %% Basic Blocks
39 subgraph bb0
40 bb0_instrs["
40 - [1] Let mutate x$1_@0[1:7] = 1
41 - [2] Const mutate $2_@1 = 1
42 - [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
41 + [1] Let mutate x$4_@0[1:7] = 1
42 + [2] Const mutate $5_@1 = 1
43 + [3] Const mutate $6_@2 = Binary read x$4_@0 === read $5_@1
44 "]
44 - bb0_instrs --> bb0_terminal(["If (read $3_@2)"])
45 + bb0_instrs --> bb0_terminal(["If (read $6_@2)"])
46 end
47 subgraph bb2
48 bb2_instrs["
48 - [5] Reassign mutate x$1_@0[1:6] = 2
49 + [5] Reassign mutate x$7_@0[1:6] = 2
50 "]
51 bb2_instrs --> bb2_terminal(["Goto"])
52 end
53 subgraph bb1
53 - bb1_terminal(["Return read x$1_@0"])
54 + bb1_terminal(["Return read x$8_@0"])
55 end
56
57 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md
+13 -12
@@ -47,20 +47,21 @@ function log$0() {}
47
48 ```
49 bb0:
50 - [1] Let mutate str$2_@0[1:8] = ""
51 - [2] If (read cond$1) then:bb2 else:bb3
50 + [1] Let mutate str$6_@0[1:8] = ""
51 + [2] If (read cond$5) then:bb2 else:bb3
52 bb2:
53 predecessor blocks: bb0
54 - [3] Let mutate str$3_@1 = "other test"
55 - [4] Call mutate log$4_@2(read str$3_@1)
54 + [3] Let mutate str$7_@1 = "other test"
55 + [4] Call mutate log$4_@2(read str$7_@1)
56 [5] Goto bb1
57 bb3:
58 predecessor blocks: bb0
59 - [6] Reassign mutate str$2_@0[1:7] = "fallthrough test"
59 + [6] Reassign mutate str$8_@0[1:7] = "fallthrough test"
60 [7] Goto bb1
61 bb1:
62 predecessor blocks: bb2 bb3
63 - [8] Call mutate log$4_@2(read str$2_@0)
63 + str$10_@0[1:7]: phi(bb2: str$6_@0, bb3: str$8_@0)
64 + [8] Call mutate log$4_@2(read str$10_@0)
65 [9] Return
66 ```
67
@@ -71,26 +72,26 @@ flowchart TB
72 %% Basic Blocks
73 subgraph bb0
74 bb0_instrs["
74 - [1] Let mutate str$2_@0[1:8] = ''
75 + [1] Let mutate str$6_@0[1:8] = ''
76 "]
76 - bb0_instrs --> bb0_terminal(["If (read cond$1)"])
77 + bb0_instrs --> bb0_terminal(["If (read cond$5)"])
78 end
79 subgraph bb2
80 bb2_instrs["
80 - [3] Let mutate str$3_@1 = 'other test'
81 - [4] Call mutate log$4_@2(read str$3_@1)
81 + [3] Let mutate str$7_@1 = 'other test'
82 + [4] Call mutate log$4_@2(read str$7_@1)
83 "]
84 bb2_instrs --> bb2_terminal(["Goto"])
85 end
86 subgraph bb3
87 bb3_instrs["
87 - [6] Reassign mutate str$2_@0[1:7] = 'fallthrough test'
88 + [6] Reassign mutate str$8_@0[1:7] = 'fallthrough test'
89 "]
90 bb3_instrs --> bb3_terminal(["Goto"])
91 end
92 subgraph bb1
93 bb1_instrs["
93 - [8] Call mutate log$4_@2(read str$2_@0)
94 + [8] Call mutate log$4_@2(read str$10_@0)
95 "]
96 bb1_instrs --> bb1_terminal(["Return"])
97 end
compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md
+15 -14
@@ -20,21 +20,22 @@ function foo() {
20
21 ```
22 bb0:
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 - [4] If (read $3_@2) then:bb2 else:bb3
23 + [1] Let mutate y$5_@0 = 2
24 + [2] Const mutate $6_@1 = 1
25 + [3] Const mutate $7_@2 = Binary read y$5_@0 > read $6_@1
26 + [4] If (read $7_@2) then:bb2 else:bb3
27 bb2:
28 predecessor blocks: bb0
29 - [5] Reassign mutate y$1_@3[5:10] = 1
29 + [5] Reassign mutate y$8_@3[5:10] = 1
30 [6] Goto bb1
31 bb3:
32 predecessor blocks: bb0
33 - [7] Reassign mutate y$1_@3[5:10] = 2
33 + [7] Reassign mutate y$9_@3[5:10] = 2
34 [8] Goto bb1
35 bb1:
36 predecessor blocks: bb2 bb3
37 - [9] Let mutate x$4_@3[5:10] = read y$1_@3
37 + y$10_@3[5:10]: phi(bb2: y$8_@3, bb3: y$9_@3)
38 + [9] Let mutate x$11_@3[5:10] = read y$10_@3
39 [10] Return
40 ```
41
@@ -45,27 +46,27 @@ flowchart TB
46 %% Basic Blocks
47 subgraph bb0
48 bb0_instrs["
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
49 + [1] Let mutate y$5_@0 = 2
50 + [2] Const mutate $6_@1 = 1
51 + [3] Const mutate $7_@2 = Binary read y$5_@0 > read $6_@1
52 "]
52 - bb0_instrs --> bb0_terminal(["If (read $3_@2)"])
53 + bb0_instrs --> bb0_terminal(["If (read $7_@2)"])
54 end
55 subgraph bb2
56 bb2_instrs["
56 - [5] Reassign mutate y$1_@3[5:10] = 1
57 + [5] Reassign mutate y$8_@3[5:10] = 1
58 "]
59 bb2_instrs --> bb2_terminal(["Goto"])
60 end
61 subgraph bb3
62 bb3_instrs["
62 - [7] Reassign mutate y$1_@3[5:10] = 2
63 + [7] Reassign mutate y$9_@3[5:10] = 2
64 "]
65 bb3_instrs --> bb3_terminal(["Goto"])
66 end
67 subgraph bb1
68 bb1_instrs["
68 - [9] Let mutate x$4_@3[5:10] = read y$1_@3
69 + [9] Let mutate x$11_@3[5:10] = read y$10_@3
70 "]
71 bb1_instrs --> bb1_terminal(["Return"])
72 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_@0 = 1
17 - [2] Let mutate y$2_@1 = 2
16 + [1] Let mutate x$3_@0 = 1
17 + [2] Let mutate y$4_@1 = 2
18 [3] Return
19 ```
20
@@ -25,8 +25,8 @@ flowchart TB
25 %% Basic Blocks
26 subgraph bb0
27 bb0_instrs["
28 - [1] Let mutate x$1_@0 = 1
29 - [2] Let mutate y$2_@1 = 2
28 + [1] Let mutate x$3_@0 = 1
29 + [2] Let mutate y$4_@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_@0 = 1
21 - [2] Let mutate y$2_@1 = 2
22 - [3] If (read y$2_@1) then:bb2 else:bb1
20 + [1] Let mutate x$4_@0 = 1
21 + [2] Let mutate y$5_@1 = 2
22 + [3] If (read y$5_@1) then:bb2 else:bb1
23 bb2:
24 predecessor blocks: bb0
25 - [4] Let mutate z$3_@2 = Binary read x$1_@0 + read y$2_@1
25 + [4] Let mutate z$6_@2 = Binary read x$4_@0 + read y$5_@1
26 [5] 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_@0 = 1
40 - [2] Let mutate y$2_@1 = 2
39 + [1] Let mutate x$4_@0 = 1
40 + [2] Let mutate y$5_@1 = 2
41 "]
42 - bb0_instrs --> bb0_terminal(["If (read y$2_@1)"])
42 + bb0_instrs --> bb0_terminal(["If (read y$5_@1)"])
43 end
44 subgraph bb2
45 bb2_instrs["
46 - [4] Let mutate z$3_@2 = Binary read x$1_@0 + read y$2_@1
46 + [4] Let mutate z$6_@2 = Binary read x$4_@0 + read y$5_@1
47 "]
48 bb2_instrs --> bb2_terminal(["Goto"])
49 end
compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md
+31 -30
@@ -28,33 +28,34 @@ function foo() {
28
29 ```
30 bb0:
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 - [6] Switch (read x$1_@0)
37 - Case read $8_@4: bb5
38 - Case read $5_@2: bb3
31 + [1] Let mutate x$10_@0 = 1
32 + [2] Const mutate $11_@1 = 2
33 + [3] Const mutate $12_@2 = Binary read x$10_@0 === read $11_@1
34 + [4] Const mutate $13_@3 = 1
35 + [5] Const mutate $14_@4 = Binary read x$10_@0 === read $13_@3
36 + [6] Switch (read x$10_@0)
37 + Case read $14_@4: bb5
38 + Case read $12_@2: bb3
39 Default: bb2
40 bb5:
41 predecessor blocks: bb0
42 - [7] Const mutate $6_@5 = 1
43 - [8] Reassign mutate x$1_@6[8:17] = Binary read x$1_@0 + read $6_@5
42 + [7] Const mutate $15_@5 = 1
43 + [8] Reassign mutate x$16_@6[8:17] = Binary read x$10_@0 + read $15_@5
44 [9] Goto bb1
45 bb3:
46 predecessor blocks: bb0
47 - [10] Const mutate $3_@7 = 2
48 - [11] Reassign mutate x$1_@6[8:17] = Binary read x$1_@0 + read $3_@7
47 + [10] Const mutate $17_@7 = 2
48 + [11] Reassign mutate x$18_@6[8:17] = Binary read x$10_@0 + read $17_@7
49 [12] Goto bb1
50 bb2:
51 predecessor blocks: bb0
52 - [13] Const mutate $2_@8 = 3
53 - [14] Reassign mutate x$1_@6[8:17] = Binary read x$1_@0 + read $2_@8
52 + [13] Const mutate $19_@8 = 3
53 + [14] Reassign mutate x$20_@6[8:17] = Binary read x$10_@0 + read $19_@8
54 [15] Goto bb1
55 bb1:
56 predecessor blocks: bb5 bb3 bb2
57 - [16] Let mutate y$9_@6[8:17] = read x$1_@6
57 + x$21_@6[8:17]: phi(bb5: x$16_@6, bb3: x$18_@6, bb2: x$20_@6)
58 + [16] Let mutate y$22_@6[8:17] = read x$21_@6
59 [17] Return
60 ```
61
@@ -65,45 +66,45 @@ flowchart TB
66 %% Basic Blocks
67 subgraph bb0
68 bb0_instrs["
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
69 + [1] Let mutate x$10_@0 = 1
70 + [2] Const mutate $11_@1 = 2
71 + [3] Const mutate $12_@2 = Binary read x$10_@0 === read $11_@1
72 + [4] Const mutate $13_@3 = 1
73 + [5] Const mutate $14_@4 = Binary read x$10_@0 === read $13_@3
74 "]
74 - bb0_instrs --> bb0_terminal(["Switch (read x$1_@0)"])
75 + bb0_instrs --> bb0_terminal(["Switch (read x$10_@0)"])
76 end
77 subgraph bb5
78 bb5_instrs["
78 - [7] Const mutate $6_@5 = 1
79 - [8] Reassign mutate x$1_@6[8:17] = Binary read x$1_@0 + read $6_@5
79 + [7] Const mutate $15_@5 = 1
80 + [8] Reassign mutate x$16_@6[8:17] = Binary read x$10_@0 + read $15_@5
81 "]
82 bb5_instrs --> bb5_terminal(["Goto"])
83 end
84 subgraph bb3
85 bb3_instrs["
85 - [10] Const mutate $3_@7 = 2
86 - [11] Reassign mutate x$1_@6[8:17] = Binary read x$1_@0 + read $3_@7
86 + [10] Const mutate $17_@7 = 2
87 + [11] Reassign mutate x$18_@6[8:17] = Binary read x$10_@0 + read $17_@7
88 "]
89 bb3_instrs --> bb3_terminal(["Goto"])
90 end
91 subgraph bb2
92 bb2_instrs["
92 - [13] Const mutate $2_@8 = 3
93 - [14] Reassign mutate x$1_@6[8:17] = Binary read x$1_@0 + read $2_@8
93 + [13] Const mutate $19_@8 = 3
94 + [14] Reassign mutate x$20_@6[8:17] = Binary read x$10_@0 + read $19_@8
95 "]
96 bb2_instrs --> bb2_terminal(["Goto"])
97 end
98 subgraph bb1
99 bb1_instrs["
99 - [16] Let mutate y$9_@6[8:17] = read x$1_@6
100 + [16] Let mutate y$22_@6[8:17] = read x$21_@6
101 "]
102 bb1_instrs --> bb1_terminal(["Return"])
103 end
104
105 %% Jumps
105 - bb0_terminal -- "read $8_@4" --> bb5
106 - bb0_terminal -- "read $5_@2" --> bb3
106 + bb0_terminal -- "read $14_@4" --> bb5
107 + bb0_terminal -- "read $12_@2" --> bb3
108 bb0_terminal -- "default" --> bb2
109 bb0_terminal -- "fallthrough" --> bb1
110 bb5_terminal --> bb1
compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md
+13 -12
@@ -16,17 +16,18 @@ function foo() {
16
17 ```
18 bb0:
19 - [1] Let mutate x$1_@0[1:7] = 1
20 - [2] Const mutate $2_@1 = 1
21 - [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
22 - [4] If (read $3_@2) then:bb2 else:bb1
19 + [1] Let mutate x$4_@0[1:7] = 1
20 + [2] Const mutate $5_@1 = 1
21 + [3] Const mutate $6_@2 = Binary read x$4_@0 === read $5_@1
22 + [4] If (read $6_@2) then:bb2 else:bb1
23 bb2:
24 predecessor blocks: bb0
25 - [5] Reassign mutate x$1_@0[1:6] = 2
25 + [5] Reassign mutate x$7_@0[1:6] = 2
26 [6] Goto bb1
27 bb1:
28 predecessor blocks: bb2 bb0
29 - [7] Throw read x$1_@0
29 + x$8_@0[1:6]: phi(bb2: x$7_@0, bb0: x$4_@0)
30 + [7] Throw read x$8_@0
31 ```
32
33 ### CFG
@@ -36,20 +37,20 @@ flowchart TB
37 %% Basic Blocks
38 subgraph bb0
39 bb0_instrs["
39 - [1] Let mutate x$1_@0[1:7] = 1
40 - [2] Const mutate $2_@1 = 1
41 - [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
40 + [1] Let mutate x$4_@0[1:7] = 1
41 + [2] Const mutate $5_@1 = 1
42 + [3] Const mutate $6_@2 = Binary read x$4_@0 === read $5_@1
43 "]
43 - bb0_instrs --> bb0_terminal(["If (read $3_@2)"])
44 + bb0_instrs --> bb0_terminal(["If (read $6_@2)"])
45 end
46 subgraph bb2
47 bb2_instrs["
47 - [5] Reassign mutate x$1_@0[1:6] = 2
48 + [5] Reassign mutate x$7_@0[1:6] = 2
49 "]
50 bb2_instrs --> bb2_terminal(["Goto"])
51 end
52 subgraph bb1
52 - bb1_terminal(["Throw read x$1_@0"])
53 + bb1_terminal(["Throw read x$8_@0"])
54 end
55
56 %% Jumps
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_@0[1:3] = 1
20 + [1] Let mutate x$5_@0[1:3] = 1
21 [2] While test=bb1 loop=bb3 fallthrough=bb2
22 bb1:
23 predecessor blocks: bb0 bb3
24 - [3] Const mutate $3_@1 = 10
25 - [4] Const mutate $4_@2[4:9] = Binary read x$1_@0 < read $3_@1
26 - [5] If (read $4_@2) then:bb3 else:bb2
24 + [3] Const mutate $6_@1 = 10
25 + [4] Const mutate $8_@2[4:9] = Binary read x$5_@0 < read $6_@1
26 + [5] If (read $8_@2) then:bb3 else:bb2
27 bb3:
28 predecessor blocks: bb1
29 - [6] Const mutate $2_@3 = 1
30 - [7] Binary read x$1_@0 + read $2_@3
29 + [6] Const mutate $9_@3 = 1
30 + [7] Binary read x$5_@0 + read $9_@3
31 [8] Goto(Continue) bb1
32 bb2:
33 predecessor blocks: bb1
34 - [9] Return read x$1_@0
34 + [9] Return read x$5_@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_@0[1:3] = 1
44 + [1] Let mutate x$5_@0[1:3] = 1
45 "]
46 bb0_instrs --> bb0_terminal(["While"])
47 end
48 subgraph bb1
49 bb1_instrs["
50 - [3] Const mutate $3_@1 = 10
51 - [4] Const mutate $4_@2[4:9] = Binary read x$1_@0 < read $3_@1
50 + [3] Const mutate $6_@1 = 10
51 + [4] Const mutate $8_@2[4:9] = Binary read x$5_@0 < read $6_@1
52 "]
53 - bb1_instrs --> bb1_terminal(["If (read $4_@2)"])
53 + bb1_instrs --> bb1_terminal(["If (read $8_@2)"])
54 end
55 subgraph bb3
56 bb3_instrs["
57 - [6] Const mutate $2_@3 = 1
58 - [7] Binary read x$1_@0 + read $2_@3
57 + [6] Const mutate $9_@3 = 1
58 + [7] Binary read x$5_@0 + read $9_@3
59 "]
60 bb3_instrs --> bb3_terminal(["Goto"])
61 end
62 subgraph bb2
63 - bb2_terminal(["Return read x$1_@0"])
63 + bb2_terminal(["Return read x$5_@0"])
64 end
65
66 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md
+15 -14
@@ -17,21 +17,22 @@ function foo() {
17
18 ```
19 bb0:
20 - [1] Let mutate x$1_@0[0:9] = 1
20 + [1] Let mutate x$5_@0[0:9] = 1
21 [2] While test=bb1 loop=bb3 fallthrough=bb2
22 bb1:
23 predecessor blocks: bb0 bb3
24 - [3] Const mutate $3_@1 = 10
25 - [4] Const mutate $4_@2[4:9] = Binary read x$1_@0 < read $3_@1
26 - [5] If (read $4_@2) then:bb3 else:bb2
24 + x$7_@0[0:8]: phi(bb0: x$5_@0, bb3: x$10_@0)
25 + [3] Const mutate $6_@1 = 10
26 + [4] Const mutate $8_@2[4:9] = Binary read x$7_@0 < read $6_@1
27 + [5] If (read $8_@2) then:bb3 else:bb2
28 bb3:
29 predecessor blocks: bb1
29 - [6] Const mutate $2_@3 = 1
30 - [7] Reassign mutate x$1_@0[0:8] = Binary read x$1_@0 + read $2_@3
30 + [6] Const mutate $9_@3 = 1
31 + [7] Reassign mutate x$10_@0[0:8] = Binary read x$7_@0 + read $9_@3
32 [8] Goto(Continue) bb1
33 bb2:
34 predecessor blocks: bb1
34 - [9] Return read x$1_@0
35 + [9] Return read x$7_@0
36 ```
37
38 ### CFG
@@ -41,26 +42,26 @@ flowchart TB
42 %% Basic Blocks
43 subgraph bb0
44 bb0_instrs["
44 - [1] Let mutate x$1_@0[0:9] = 1
45 + [1] Let mutate x$5_@0[0:9] = 1
46 "]
47 bb0_instrs --> bb0_terminal(["While"])
48 end
49 subgraph bb1
50 bb1_instrs["
50 - [3] Const mutate $3_@1 = 10
51 - [4] Const mutate $4_@2[4:9] = Binary read x$1_@0 < read $3_@1
51 + [3] Const mutate $6_@1 = 10
52 + [4] Const mutate $8_@2[4:9] = Binary read x$7_@0 < read $6_@1
53 "]
53 - bb1_instrs --> bb1_terminal(["If (read $4_@2)"])
54 + bb1_instrs --> bb1_terminal(["If (read $8_@2)"])
55 end
56 subgraph bb3
57 bb3_instrs["
57 - [6] Const mutate $2_@3 = 1
58 - [7] Reassign mutate x$1_@0[0:8] = Binary read x$1_@0 + read $2_@3
58 + [6] Const mutate $9_@3 = 1
59 + [7] Reassign mutate x$10_@0[0:8] = Binary read x$7_@0 + read $9_@3
60 "]
61 bb3_instrs --> bb3_terminal(["Goto"])
62 end
63 subgraph bb2
63 - bb2_terminal(["Return read x$1_@0"])
64 + bb2_terminal(["Return read x$7_@0"])
65 end
66
67 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md
+33 -32
@@ -32,31 +32,32 @@ function Component(props) {
32
33 ```
34 bb0:
35 - [1] Let mutate x$2_@0[1:12] = Array []
36 - [2] Let mutate y$3_@0[1:11] = undefined
37 - [3] Const mutate $4_@1 = false
38 - [4] Const mutate $5_@2 = true
39 - [5] Const mutate $6_@3 = 1
40 - [6] Switch (read props$1.p0)
41 - Case read $6_@3: bb1
42 - Case read $5_@2: bb6
35 + [1] Let mutate x$10_@0[1:12] = Array []
36 + [2] Let mutate y$11_@0[1:11] = undefined
37 + [3] Const mutate $12_@1 = false
38 + [4] Const mutate $13_@2 = true
39 + [5] Const mutate $14_@3 = 1
40 + [6] Switch (read props$9.p0)
41 + Case read $14_@3: bb1
42 + Case read $13_@2: bb6
43 Default: bb1
44 - Case read $4_@1: bb2
44 + Case read $12_@1: bb2
45 bb6:
46 predecessor blocks: bb0
47 - [7] Call mutate x$2_@0.push(read props$1.p2)
48 - [8] Reassign mutate y$3_@0[1:11] = Array []
47 + [7] Call mutate x$10_@0.push(read props$9.p2)
48 + [8] Reassign mutate y$15_@0[1:11] = Array []
49 [9] Goto bb1
50 bb2:
51 predecessor blocks: bb0
52 - [10] Reassign mutate y$3_@0[1:11] = read x$2_@0
52 + [10] Reassign mutate y$16_@0[1:11] = read x$10_@0
53 [11] Goto bb1
54 bb1:
55 predecessor blocks: bb0 bb6 bb2
56 - [12] Const mutate child$7_@4 = JSX <read Component$0 data={freeze x$2_@0} ></read Component$0>
57 - [13] Call read y$3_@0.push(read props$1.p4)
58 - [14] Const mutate $8_@5 = JSX <read Component$0 data={freeze y$3_@0} >{read child$7_@4}</read Component$0>
59 - [15] Return read $8_@5
56 + y$20_@0[1:11]: phi(bb0: y$11_@0, bb6: y$15_@0, bb2: y$16_@0)
57 + [12] Const mutate child$19_@4 = JSX <read Component$0 data={freeze x$10_@0} ></read Component$0>
58 + [13] Call read y$20_@0.push(read props$9.p4)
59 + [14] Const mutate $22_@5 = JSX <read Component$0 data={freeze y$20_@0} >{read child$19_@4}</read Component$0>
60 + [15] Return read $22_@5
61 ```
62
63 ### CFG
@@ -66,41 +67,41 @@ flowchart TB
67 %% Basic Blocks
68 subgraph bb0
69 bb0_instrs["
69 - [1] Let mutate x$2_@0[1:12] = Array []
70 - [2] Let mutate y$3_@0[1:11] = undefined
71 - [3] Const mutate $4_@1 = false
72 - [4] Const mutate $5_@2 = true
73 - [5] Const mutate $6_@3 = 1
70 + [1] Let mutate x$10_@0[1:12] = Array []
71 + [2] Let mutate y$11_@0[1:11] = undefined
72 + [3] Const mutate $12_@1 = false
73 + [4] Const mutate $13_@2 = true
74 + [5] Const mutate $14_@3 = 1
75 "]
75 - bb0_instrs --> bb0_terminal(["Switch (read props$1.p0)"])
76 + bb0_instrs --> bb0_terminal(["Switch (read props$9.p0)"])
77 end
78 subgraph bb6
79 bb6_instrs["
79 - [7] Call mutate x$2_@0.push(read props$1.p2)
80 - [8] Reassign mutate y$3_@0[1:11] = Array []
80 + [7] Call mutate x$10_@0.push(read props$9.p2)
81 + [8] Reassign mutate y$15_@0[1:11] = Array []
82 "]
83 bb6_instrs --> bb6_terminal(["Goto"])
84 end
85 subgraph bb2
86 bb2_instrs["
86 - [10] Reassign mutate y$3_@0[1:11] = read x$2_@0
87 + [10] Reassign mutate y$16_@0[1:11] = read x$10_@0
88 "]
89 bb2_instrs --> bb2_terminal(["Goto"])
90 end
91 subgraph bb1
92 bb1_instrs["
92 - [12] Const mutate child$7_@4 = JSX <read Component$0 data={freeze x$2_@0} ></read Component$0>
93 - [13] Call read y$3_@0.push(read props$1.p4)
94 - [14] Const mutate $8_@5 = JSX <read Component$0 data={freeze y$3_@0} >{read child$7_@4}</read Component$0>
93 + [12] Const mutate child$19_@4 = JSX <read Component$0 data={freeze x$10_@0} ></read Component$0>
94 + [13] Call read y$20_@0.push(read props$9.p4)
95 + [14] Const mutate $22_@5 = JSX <read Component$0 data={freeze y$20_@0} >{read child$19_@4}</read Component$0>
96 "]
96 - bb1_instrs --> bb1_terminal(["Return read $8_@5"])
97 + bb1_instrs --> bb1_terminal(["Return read $22_@5"])
98 end
99
100 %% Jumps
100 - bb0_terminal -- "read $6_@3" --> bb1
101 - bb0_terminal -- "read $5_@2" --> bb6
101 + bb0_terminal -- "read $14_@3" --> bb1
102 + bb0_terminal -- "read $13_@2" --> bb6
103 bb0_terminal -- "default" --> bb1
103 - bb0_terminal -- "read $4_@1" --> bb2
104 + bb0_terminal -- "read $12_@1" --> bb2
105 bb0_terminal -- "fallthrough" --> bb1
106 bb6_terminal --> bb1
107 bb2_terminal --> bb1
compiler/forget/src/__tests__/fixtures/hir/switch-with-fallthrough.expect.md
+40 -40
@@ -36,44 +36,44 @@ function foo(x) {
36
37 ```
38 bb0:
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 - [8] Switch (read x$1)
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
39 + [1] Let mutate y$10_@0 = undefined
40 + [2] Const mutate $11_@1 = 5
41 + [3] Const mutate $12_@2 = 4
42 + [4] Const mutate $13_@3 = 3
43 + [5] Const mutate $14_@4 = 2
44 + [6] Const mutate $15_@5 = 1
45 + [7] Const mutate $16_@6 = 0
46 + [8] Switch (read x$9)
47 + Case read $16_@6: bb10
48 + Case read $15_@5: bb9
49 + Case read $14_@4: bb1
50 + Case read $13_@3: bb5
51 + Case read $12_@2: bb4
52 + Case read $11_@1: bb3
53 Default: bb2
54 bb10:
55 predecessor blocks: bb0
56 - [9] Reassign mutate y$2_@7 = 0
56 + [9] Reassign mutate y$17_@7 = 0
57 [10] Goto bb9
58 bb9:
59 predecessor blocks: bb10 bb0
60 - [11] Reassign mutate y$2_@8 = 1
60 + [11] Reassign mutate y$18_@8 = 1
61 [12] Goto bb1
62 bb5:
63 predecessor blocks: bb0
64 - [13] Reassign mutate y$2_@9 = 3
64 + [13] Reassign mutate y$19_@9 = 3
65 [14] Goto bb1
66 bb4:
67 predecessor blocks: bb0
68 - [15] Reassign mutate y$2_@10 = 4
68 + [15] Reassign mutate y$20_@10 = 4
69 [16] Goto bb3
70 bb3:
71 predecessor blocks: bb4 bb0
72 - [17] Reassign mutate y$2_@11 = 5
72 + [17] Reassign mutate y$21_@11 = 5
73 [18] Goto bb2
74 bb2:
75 predecessor blocks: bb3 bb0
76 - [19] Reassign mutate y$2_@12 = 0
76 + [19] Reassign mutate y$22_@12 = 0
77 [20] 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_@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
90 + [1] Let mutate y$10_@0 = undefined
91 + [2] Const mutate $11_@1 = 5
92 + [3] Const mutate $12_@2 = 4
93 + [4] Const mutate $13_@3 = 3
94 + [5] Const mutate $14_@4 = 2
95 + [6] Const mutate $15_@5 = 1
96 + [7] Const mutate $16_@6 = 0
97 "]
98 - bb0_instrs --> bb0_terminal(["Switch (read x$1)"])
98 + bb0_instrs --> bb0_terminal(["Switch (read x$9)"])
99 end
100 subgraph bb10
101 bb10_instrs["
102 - [9] Reassign mutate y$2_@7 = 0
102 + [9] Reassign mutate y$17_@7 = 0
103 "]
104 bb10_instrs --> bb10_terminal(["Goto"])
105 end
106 subgraph bb9
107 bb9_instrs["
108 - [11] Reassign mutate y$2_@8 = 1
108 + [11] Reassign mutate y$18_@8 = 1
109 "]
110 bb9_instrs --> bb9_terminal(["Goto"])
111 end
112 subgraph bb5
113 bb5_instrs["
114 - [13] Reassign mutate y$2_@9 = 3
114 + [13] Reassign mutate y$19_@9 = 3
115 "]
116 bb5_instrs --> bb5_terminal(["Goto"])
117 end
118 subgraph bb4
119 bb4_instrs["
120 - [15] Reassign mutate y$2_@10 = 4
120 + [15] Reassign mutate y$20_@10 = 4
121 "]
122 bb4_instrs --> bb4_terminal(["Goto"])
123 end
124 subgraph bb3
125 bb3_instrs["
126 - [17] Reassign mutate y$2_@11 = 5
126 + [17] Reassign mutate y$21_@11 = 5
127 "]
128 bb3_instrs --> bb3_terminal(["Goto"])
129 end
130 subgraph bb2
131 bb2_instrs["
132 - [19] Reassign mutate y$2_@12 = 0
132 + [19] Reassign mutate y$22_@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_@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
141 + bb0_terminal -- "read $16_@6" --> bb10
142 + bb0_terminal -- "read $15_@5" --> bb9
143 + bb0_terminal -- "read $14_@4" --> bb1
144 + bb0_terminal -- "read $13_@3" --> bb5
145 + bb0_terminal -- "read $12_@2" --> bb4
146 + bb0_terminal -- "read $11_@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
+31 -30
@@ -28,30 +28,31 @@ function Component(props) {
28
29 ```
30 bb0:
31 - [1] Let mutate x$2_@0[1:12] = Array []
32 - [2] Let mutate y$3_@0[1:11] = undefined
33 - [3] Const mutate $4_@1 = false
34 - [4] Const mutate $5_@2 = true
35 - [5] Switch (read props$1.p0)
36 - Case read $5_@2: bb4
37 - Case read $4_@1: bb2
31 + [1] Let mutate x$9_@0[1:12] = Array []
32 + [2] Let mutate y$10_@0[1:11] = undefined
33 + [3] Const mutate $11_@1 = false
34 + [4] Const mutate $12_@2 = true
35 + [5] Switch (read props$8.p0)
36 + Case read $12_@2: bb4
37 + Case read $11_@1: bb2
38 Default: bb1
39 bb4:
40 predecessor blocks: bb0
41 - [6] Call mutate x$2_@0.push(read props$1.p2)
42 - [7] Call mutate x$2_@0.push(read props$1.p3)
43 - [8] Reassign mutate y$3_@3 = Array []
41 + [6] Call mutate x$9_@0.push(read props$8.p2)
42 + [7] Call mutate x$9_@0.push(read props$8.p3)
43 + [8] Reassign mutate y$13_@3 = Array []
44 [9] Goto bb2
45 bb2:
46 predecessor blocks: bb4 bb0
47 - [10] Reassign mutate y$3_@0[1:11] = read x$2_@0
47 + [10] Reassign mutate y$15_@0[1:11] = read x$9_@0
48 [11] Goto bb1
49 bb1:
50 predecessor blocks: bb2 bb0
51 - [12] Const mutate child$6_@4 = JSX <read Component$0 data={freeze x$2_@0} ></read Component$0>
52 - [13] Call read y$3_@0.push(read props$1.p4)
53 - [14] Const mutate $7_@5 = JSX <read Component$0 data={read y$3_@0} >{read child$6_@4}</read Component$0>
54 - [15] Return read $7_@5
51 + y$20_@0[1:11]: phi(bb2: y$15_@0, bb0: y$10_@0)
52 + [12] Const mutate child$19_@4 = JSX <read Component$0 data={freeze x$9_@0} ></read Component$0>
53 + [13] Call read y$20_@0.push(read props$8.p4)
54 + [14] Const mutate $23_@5 = JSX <read Component$0 data={read y$20_@0} >{read child$19_@4}</read Component$0>
55 + [15] Return read $23_@5
56 ```
57
58 ### CFG
@@ -61,39 +62,39 @@ flowchart TB
62 %% Basic Blocks
63 subgraph bb0
64 bb0_instrs["
64 - [1] Let mutate x$2_@0[1:12] = Array []
65 - [2] Let mutate y$3_@0[1:11] = undefined
66 - [3] Const mutate $4_@1 = false
67 - [4] Const mutate $5_@2 = true
65 + [1] Let mutate x$9_@0[1:12] = Array []
66 + [2] Let mutate y$10_@0[1:11] = undefined
67 + [3] Const mutate $11_@1 = false
68 + [4] Const mutate $12_@2 = true
69 "]
69 - bb0_instrs --> bb0_terminal(["Switch (read props$1.p0)"])
70 + bb0_instrs --> bb0_terminal(["Switch (read props$8.p0)"])
71 end
72 subgraph bb4
73 bb4_instrs["
73 - [6] Call mutate x$2_@0.push(read props$1.p2)
74 - [7] Call mutate x$2_@0.push(read props$1.p3)
75 - [8] Reassign mutate y$3_@3 = Array []
74 + [6] Call mutate x$9_@0.push(read props$8.p2)
75 + [7] Call mutate x$9_@0.push(read props$8.p3)
76 + [8] Reassign mutate y$13_@3 = Array []
77 "]
78 bb4_instrs --> bb4_terminal(["Goto"])
79 end
80 subgraph bb2
81 bb2_instrs["
81 - [10] Reassign mutate y$3_@0[1:11] = read x$2_@0
82 + [10] Reassign mutate y$15_@0[1:11] = read x$9_@0
83 "]
84 bb2_instrs --> bb2_terminal(["Goto"])
85 end
86 subgraph bb1
87 bb1_instrs["
87 - [12] Const mutate child$6_@4 = JSX <read Component$0 data={freeze x$2_@0} ></read Component$0>
88 - [13] Call read y$3_@0.push(read props$1.p4)
89 - [14] Const mutate $7_@5 = JSX <read Component$0 data={read y$3_@0} >{read child$6_@4}</read Component$0>
88 + [12] Const mutate child$19_@4 = JSX <read Component$0 data={freeze x$9_@0} ></read Component$0>
89 + [13] Call read y$20_@0.push(read props$8.p4)
90 + [14] Const mutate $23_@5 = JSX <read Component$0 data={read y$20_@0} >{read child$19_@4}</read Component$0>
91 "]
91 - bb1_instrs --> bb1_terminal(["Return read $7_@5"])
92 + bb1_instrs --> bb1_terminal(["Return read $23_@5"])
93 end
94
95 %% Jumps
95 - bb0_terminal -- "read $5_@2" --> bb4
96 - bb0_terminal -- "read $4_@1" --> bb2
96 + bb0_terminal -- "read $12_@2" --> bb4
97 + bb0_terminal -- "read $11_@1" --> bb2
98 bb0_terminal -- "default" --> bb1
99 bb0_terminal -- "fallthrough" --> bb1
100 bb4_terminal --> bb2
compiler/forget/src/__tests__/fixtures/hir/while-break.expect.md
+4 -4
@@ -18,10 +18,10 @@ bb0:
18 [1] While test=bb1 loop=bb2 fallthrough=bb2
19 bb1:
20 predecessor blocks: bb0
21 - [2] If (read a$1) then:bb2 else:bb2
21 + [2] If (read a$3) then:bb2 else:bb2
22 bb2:
23 predecessor blocks: bb1
24 - [3] Return read b$2
24 + [3] Return read b$4
25 ```
26
27 ### CFG
@@ -33,10 +33,10 @@ flowchart TB
33 bb0_terminal(["While"])
34 end
35 subgraph bb1
36 - bb1_terminal(["If (read a$1)"])
36 + bb1_terminal(["If (read a$3)"])
37 end
38 subgraph bb2
39 - bb2_terminal(["Return read b$2"])
39 + bb2_terminal(["Return read b$4"])
40 end
41
42 %% Jumps
compiler/forget/src/__tests__/fixtures/hir/while-conditional-continue.expect.md
+8 -8
@@ -22,20 +22,20 @@ bb0:
22 [1] While test=bb1 loop=bb3 fallthrough=bb2
23 bb1:
24 predecessor blocks: bb0 bb5 bb4
25 - [2] If (read a$1) then:bb3 else:bb2
25 + [2] If (read a$5) then:bb3 else:bb2
26 bb3:
27 predecessor blocks: bb1
28 - [3] If (read b$2) then:bb5 else:bb4
28 + [3] If (read b$6) then:bb5 else:bb4
29 bb5:
30 predecessor blocks: bb3
31 [4] Goto(Continue) bb1
32 bb4:
33 predecessor blocks: bb3
34 - [5] Call read c$3()
34 + [5] Call read c$7()
35 [6] Goto(Continue) bb1
36 bb2:
37 predecessor blocks: bb1
38 - [7] Call read d$4()
38 + [7] Call read d$8()
39 [8] Return
40 ```
41
@@ -48,23 +48,23 @@ flowchart TB
48 bb0_terminal(["While"])
49 end
50 subgraph bb1
51 - bb1_terminal(["If (read a$1)"])
51 + bb1_terminal(["If (read a$5)"])
52 end
53 subgraph bb3
54 - bb3_terminal(["If (read b$2)"])
54 + bb3_terminal(["If (read b$6)"])
55 end
56 subgraph bb5
57 bb5_terminal(["Goto"])
58 end
59 subgraph bb4
60 bb4_instrs["
61 - [5] Call read c$3()
61 + [5] Call read c$7()
62 "]
63 bb4_instrs --> bb4_terminal(["Goto"])
64 end
65 subgraph bb2
66 bb2_instrs["
67 - [7] Call read d$4()
67 + [7] Call read d$8()
68 "]
69 bb2_instrs --> bb2_terminal(["Return"])
70 end
compiler/forget/src/__tests__/hir-test.ts
+18 -9
@@ -14,9 +14,9 @@ import { wasmFolder } from "@hpcc-js/wasm";
14 import invariant from "invariant";
15 import path from "path";
16 import prettier from "prettier";
17 +import run from "../HIR/Pipeline";
18 import printHIR from "../HIR/PrintHIR";
19 import visualizeHIRMermaid from "../HIR/VisualizeHIRMermaid";
19 -import run from "./../HIR/Pipeline";
20 import generateTestsFromFixtures from "./test-utils/generateTestsFromFixtures";
21
22 function wrapWithTripleBackticks(s: string, ext?: string) {
@@ -56,25 +56,34 @@ describe("React Forget (HIR version)", () => {
56 traverse(ast, {
57 FunctionDeclaration: {
58 enter(nodePath) {
59 - const compilerFlags = {
59 + const { ir } = run(nodePath, {
60 + eliminateRedundantPhi: true,
61 + inferReferenceEffects: true,
62 + inferMutableRanges: true,
63 + inferReactiveScopeVariables: true,
64 + inferReactiveScopes: true,
65 + leaveSSA: false,
66 + codegen: false,
67 + });
68 +
69 + // Print the HIR before leaving SSA.
70 + const textHIR = printHIR(ir.body);
71 + const visualization = visualizeHIRMermaid(ir);
72 +
73 + const { ast } = run(nodePath, {
74 eliminateRedundantPhi: true,
75 inferReferenceEffects: true,
76 inferMutableRanges: true,
63 - leaveSSA: true,
77 inferReactiveScopeVariables: true,
78 inferReactiveScopes: true,
79 + leaveSSA: true,
80 codegen: true,
67 - };
81 + });
82
69 - const { ast, ir } = run(nodePath, compilerFlags);
83 invariant(
84 ast !== null,
85 "ast is null when codegen option is enabled"
86 );
74 -
75 - const textHIR = printHIR(ir.body);
76 - // const textHIR = visitTree(ir, new PrintVisitor());
77 - const visualization = visualizeHIRMermaid(ir);
87 const text = prettier.format(
88 generate(ast).code.replace("\n\n", "\n"),
89 {