Annotate mutable range for each scope
Expands InferReactiveScopeVariables to update the mutableRange of all identifiers to be the range of its scope. The result is that all identifiers in a given scope will have the same range, whose start is the minimum of the identifiers range starts, and end is the maximum.
Joe Savona committed
Nov 17, 2022 at 15:13 UTC
70e7a632bb07ed1fa36c4cccc941ca4e6d89bbe3
34 files changed
+238
-192
compiler/forget/src/HIR/InferMutableLifetimes.ts
+14
-3
@@ -5,10 +5,11 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
+import invariant from "invariant";
9
import { assertExhaustive } from "../Common/utils";
10
import { Effect, HIRFunction, Instruction, Place } from "./HIR";
10
-import { eachInstructionOperand } from "./visitors";
11
import { printInstruction, printPlace } from "./PrintHIR";
12
+import { eachInstructionOperand } from "./visitors";
13
14
/**
15
* For each usage of a value in the given function, determines if the usage
@@ -77,9 +78,19 @@ function inferPlace(place: Place, instr: Instruction) {
78
export function inferMutableRanges(func: HIRFunction) {
79
for (const [_, block] of func.body.blocks) {
80
for (const phi of block.phis) {
81
+ let start = Number.MAX_SAFE_INTEGER;
82
+ let end = Number.MIN_SAFE_INTEGER;
83
+ for (const [_, operand] of phi.operands) {
84
+ start = Math.min(start, operand.mutableRange.start);
85
+ end = Math.max(end, operand.mutableRange.end);
86
+ }
87
+ invariant(
88
+ start !== Number.MAX_SAFE_INTEGER && end !== Number.MIN_SAFE_INTEGER,
89
+ "Expected phi to have set start/end range values"
90
+ );
91
phi.id.mutableRange = {
81
- start: -1, // TODO(gsn): This is a hack, we should assign proper ids to phis.
82
- end: -1,
92
+ start,
93
+ end,
94
};
95
}
96
compiler/forget/src/HIR/InferReactiveScopeVariables.ts
+38
-3
@@ -11,6 +11,7 @@ import {
11
Identifier,
12
Instruction,
13
makeScopeId,
14
+ MutableRange,
15
Place,
16
ScopeId,
17
} from "./HIR";
@@ -94,10 +95,20 @@ export function inferReactiveScopeVariables(fn: HIRFunction) {
95
96
// Maps each scope (by its identifying member) to a ScopeId value
97
const scopeIds: Map<Identifier, ScopeId> = new Map();
98
+ // Store the mutable range and set of identifiers for each scope
99
+ const scopeVariables: Map<
100
+ ScopeId,
101
+ { range: MutableRange; variables: Set<Identifier> }
102
+ > = new Map();
103
98
- // Iterate over all the identifiers in all scopes, and assign each
99
- // identifier to its group's scope id. The first identifier in each
100
- // group assigns the scope id for that group.
104
+ /**
105
+ * Iterate over all the identifiers and assign a unique ScopeId
106
+ * for each scope (based on the set identifier).
107
+ *
108
+ * At the same time, group the identifiers in each scope and
109
+ * build a MutableRange that describes the span of mutations
110
+ * across all identifiers in each scope.
111
+ */
112
scopes.forEach((identifier, groupIdentifier) => {
113
let scopeId = scopeIds.get(groupIdentifier);
114
if (scopeId == null) {
@@ -105,7 +116,31 @@ export function inferReactiveScopeVariables(fn: HIRFunction) {
116
scopeIds.set(groupIdentifier, scopeId);
117
}
118
identifier.scope = scopeId;
119
+
120
+ let scope = scopeVariables.get(scopeId);
121
+ if (scope === undefined) {
122
+ scope = {
123
+ range: { ...identifier.mutableRange },
124
+ variables: new Set(),
125
+ };
126
+ scopeVariables.set(scopeId, scope);
127
+ } else {
128
+ scope.range.start = Math.min(
129
+ scope.range.start,
130
+ identifier.mutableRange.start
131
+ );
132
+ scope.range.end = Math.max(scope.range.end, identifier.mutableRange.end);
133
+ }
134
+ scope.variables.add(identifier);
135
});
136
+
137
+ // Update all the identifiers for each scope now that we know
138
+ // the scope's full range.
139
+ for (const [_, scope] of scopeVariables) {
140
+ for (const identifier of scope.variables) {
141
+ identifier.mutableRange = scope.range;
142
+ }
143
+ }
144
}
145
146
// Is the operand mutable at this given instruction
compiler/forget/src/__tests__/fixtures/hir/call.expect.md
+4
-4
@@ -47,8 +47,8 @@ function foo$0() {
47
48
```
49
bb0:
50
- [1] Const mutate a$2_@0[1:3] = Array []
51
- [2] Const mutate b$3_@0[2:6] = Object { }
50
+ [1] Const mutate a$2_@0[0:6] = Array []
51
+ [2] Const mutate b$3_@0[0:6] = Object { }
52
[3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
53
[4] Const mutate $6_@1 = "div"
54
[5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
@@ -65,8 +65,8 @@ flowchart TB
65
%% Basic Blocks
66
subgraph bb0
67
bb0_instrs["
68
- [1] Const mutate a$2_@0[1:3] = Array []
69
- [2] Const mutate b$3_@0[2:6] = Object { }
68
+ [1] Const mutate a$2_@0[0:6] = Array []
69
+ [2] Const mutate b$3_@0[0:6] = Object { }
70
[3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
71
[4] Const mutate $6_@1 = 'div'
72
[5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
compiler/forget/src/__tests__/fixtures/hir/component.expect.md
+10
-10
@@ -38,9 +38,9 @@ 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:14] = Array []
41
- [4] Const mutate seen$5_@3[4:11] = New mutate Set$6_@3()
41
+ [4] Const mutate seen$5_@3[0:11] = New mutate Set$6_@3()
42
[5] Const mutate $9_@4 = 0
43
- [6] Const mutate max$7_@5 = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1)
43
+ [6] Const mutate max$7_@5[0:6] = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1)
44
Goto bb1
45
bb1:
46
predecessor blocks: bb0 bb5 bb10
@@ -48,15 +48,15 @@ bb1:
48
bb3:
49
predecessor blocks: bb1
50
[7] Const mutate $11_@6 = null
51
- [8] Const mutate $12_@3 = Binary read item$10_@3 == read $11_@6
51
+ [8] Const mutate $12_@3[0:11] = Binary read item$10_@3 == read $11_@6
52
If (read $12_@3) then:bb8 else:bb9
53
bb8:
54
predecessor blocks: bb3
55
- [9] Const mutate $13_@3 = read $12_@3
55
+ [9] Const mutate $13_@3[0:11] = read $12_@3
56
Goto bb7
57
bb9:
58
predecessor blocks: bb3
59
- [10] Const mutate $13_@3 = Call mutate seen$5_@3.has(mutate item$10_@3)
59
+ [10] Const mutate $13_@3[0:11] = Call mutate seen$5_@3.has(mutate item$10_@3)
60
Goto bb7
61
bb7:
62
predecessor blocks: bb8 bb9
@@ -99,9 +99,9 @@ flowchart TB
99
[1] Const mutate items$2_@0 = read props$1.items
100
[2] Const mutate maxItems$3_@1 = read props$1.maxItems
101
[3] Const mutate renderedItems$4_@2[3:14] = Array []
102
- [4] Const mutate seen$5_@3[4:11] = New mutate Set$6_@3()
102
+ [4] Const mutate seen$5_@3[0:11] = New mutate Set$6_@3()
103
[5] Const mutate $9_@4 = 0
104
- [6] Const mutate max$7_@5 = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1)
104
+ [6] Const mutate max$7_@5[0:6] = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1)
105
"]
106
bb0_instrs --> bb0_terminal(["Goto"])
107
end
@@ -111,19 +111,19 @@ flowchart TB
111
subgraph bb3
112
bb3_instrs["
113
[7] Const mutate $11_@6 = null
114
- [8] Const mutate $12_@3 = Binary read item$10_@3 == read $11_@6
114
+ [8] Const mutate $12_@3[0:11] = Binary read item$10_@3 == read $11_@6
115
"]
116
bb3_instrs --> bb3_terminal(["If (read $12_@3)"])
117
end
118
subgraph bb8
119
bb8_instrs["
120
- [9] Const mutate $13_@3 = read $12_@3
120
+ [9] Const mutate $13_@3[0:11] = read $12_@3
121
"]
122
bb8_instrs --> bb8_terminal(["Goto"])
123
end
124
subgraph bb9
125
bb9_instrs["
126
- [10] Const mutate $13_@3 = Call mutate seen$5_@3.has(mutate item$10_@3)
126
+ [10] Const mutate $13_@3[0:11] = Call mutate seen$5_@3.has(mutate item$10_@3)
127
"]
128
bb9_instrs --> bb9_terminal(["Goto"])
129
end
compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md
+4
-4
@@ -154,8 +154,8 @@ function Component$0(props$1) {
154
```
155
bb0:
156
[1] Const mutate a$2_@0[1:4] = Array []
157
- [2] Const mutate b$3_@1[2:5] = Array []
158
- [3] Const mutate $5_@1 = Call mutate mayMutate$4_@1(mutate b$3_@1)
157
+ [2] Const mutate b$3_@1[0:5] = Array []
158
+ [3] Const mutate $5_@1[0:5] = Call mutate mayMutate$4_@1(mutate b$3_@1)
159
If (read $5_@1) then:bb2 else:bb1
160
bb2:
161
predecessor blocks: bb0
@@ -182,8 +182,8 @@ flowchart TB
182
subgraph bb0
183
bb0_instrs["
184
[1] Const mutate a$2_@0[1:4] = Array []
185
- [2] Const mutate b$3_@1[2:5] = Array []
186
- [3] Const mutate $5_@1 = Call mutate mayMutate$4_@1(mutate b$3_@1)
185
+ [2] Const mutate b$3_@1[0:5] = Array []
186
+ [3] Const mutate $5_@1[0:5] = Call mutate mayMutate$4_@1(mutate b$3_@1)
187
"]
188
bb0_instrs --> bb0_terminal(["If (read $5_@1)"])
189
end
compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md
+4
-4
@@ -47,8 +47,8 @@ function Foo$0() {
47
48
```
49
bb0:
50
- [1] Const mutate a$2_@0[1:3] = Array []
51
- [2] Const mutate b$3_@0[2:6] = Object { }
50
+ [1] Const mutate a$2_@0[0:6] = Array []
51
+ [2] Const mutate b$3_@0[0:6] = Object { }
52
[3] New mutate Foo$4_@0(mutate a$2_@0, mutate b$3_@0)
53
[4] Const mutate $6_@1 = "div"
54
[5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
@@ -65,8 +65,8 @@ flowchart TB
65
%% Basic Blocks
66
subgraph bb0
67
bb0_instrs["
68
- [1] Const mutate a$2_@0[1:3] = Array []
69
- [2] Const mutate b$3_@0[2:6] = Object { }
68
+ [1] Const mutate a$2_@0[0:6] = Array []
69
+ [2] Const mutate b$3_@0[0:6] = Object { }
70
[3] New mutate Foo$4_@0(mutate a$2_@0, mutate b$3_@0)
71
[4] Const mutate $6_@1 = 'div'
72
[5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md
+4
-4
@@ -32,11 +32,11 @@ bb0:
32
If (read cond$2_@0) then:bb2 else:bb3
33
bb2:
34
predecessor blocks: bb0
35
- [4] Reassign mutate a$4_@3 = read x$3_@1
35
+ [4] Reassign mutate a$4_@3[4:5] = read x$3_@1
36
Goto bb1
37
bb3:
38
predecessor blocks: bb0
39
- [5] Reassign mutate a$4_@3 = Array []
39
+ [5] Reassign mutate a$4_@3[4:5] = Array []
40
Goto bb1
41
bb1:
42
predecessor blocks: bb2 bb3
@@ -61,13 +61,13 @@ flowchart TB
61
end
62
subgraph bb2
63
bb2_instrs["
64
- [4] Reassign mutate a$4_@3 = read x$3_@1
64
+ [4] Reassign mutate a$4_@3[4:5] = read x$3_@1
65
"]
66
bb2_instrs --> bb2_terminal(["Goto"])
67
end
68
subgraph bb3
69
bb3_instrs["
70
- [5] Reassign mutate a$4_@3 = Array []
70
+ [5] Reassign mutate a$4_@3[4:5] = Array []
71
"]
72
bb3_instrs --> bb3_terminal(["Goto"])
73
end
compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md
+4
-4
@@ -149,8 +149,8 @@ function Foo$0() {
149
150
```
151
bb0:
152
- [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
153
- [2] Const mutate b$4_@0[2:4] = Call mutate compute$3_@0(read props$1.b)
152
+ [1] Const mutate a$2_@0[0:4] = Call mutate compute$3_@0(read props$1.a)
153
+ [2] Const mutate b$4_@0[0:4] = Call mutate compute$3_@0(read props$1.b)
154
If (read props$1.c) then:bb2 else:bb1
155
bb2:
156
predecessor blocks: bb0
@@ -170,8 +170,8 @@ flowchart TB
170
%% Basic Blocks
171
subgraph bb0
172
bb0_instrs["
173
- [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
174
- [2] Const mutate b$4_@0[2:4] = Call mutate compute$3_@0(read props$1.b)
173
+ [1] Const mutate a$2_@0[0:4] = Call mutate compute$3_@0(read props$1.a)
174
+ [2] Const mutate b$4_@0[0:4] = Call mutate compute$3_@0(read props$1.b)
175
"]
176
bb0_instrs --> bb0_terminal(["If (read props$1.c)"])
177
end
compiler/forget/src/__tests__/fixtures/hir/independent.expect.md
+4
-4
@@ -28,8 +28,8 @@ function Foo() {}
28
29
```
30
bb0:
31
- [1] Const mutate a$2_@0 = Call mutate compute$3_@0(read props$1.a)
32
- [2] Const mutate b$4_@0 = Call mutate compute$3_@0(read props$1.b)
31
+ [1] Const mutate a$2_@0[0:2] = Call mutate compute$3_@0(read props$1.a)
32
+ [2] Const mutate b$4_@0[0:2] = Call mutate compute$3_@0(read props$1.b)
33
[3] Const mutate $6_@1 = JSX <read Foo$5 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$5>
34
Return read $6_@1
35
```
@@ -41,8 +41,8 @@ flowchart TB
41
%% Basic Blocks
42
subgraph bb0
43
bb0_instrs["
44
- [1] Const mutate a$2_@0 = Call mutate compute$3_@0(read props$1.a)
45
- [2] Const mutate b$4_@0 = Call mutate compute$3_@0(read props$1.b)
44
+ [1] Const mutate a$2_@0[0:2] = Call mutate compute$3_@0(read props$1.a)
45
+ [2] Const mutate b$4_@0[0:2] = Call mutate compute$3_@0(read props$1.b)
46
[3] Const mutate $6_@1 = JSX <read Foo$5 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$5>
47
"]
48
bb0_instrs --> bb0_terminal(["Return read $6_@1"])
compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md
+4
-4
@@ -115,8 +115,8 @@ function Foo$0() {
115
116
```
117
bb0:
118
- [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
119
- [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b)
118
+ [1] Const mutate a$2_@0[0:3] = Call mutate compute$3_@0(read props$1.a)
119
+ [2] Const mutate b$4_@0[0:3] = Call mutate compute$3_@0(read props$1.b)
120
If (read props$1.c) then:bb2 else:bb1
121
bb2:
122
predecessor blocks: bb0
@@ -135,8 +135,8 @@ flowchart TB
135
%% Basic Blocks
136
subgraph bb0
137
bb0_instrs["
138
- [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
139
- [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b)
138
+ [1] Const mutate a$2_@0[0:3] = Call mutate compute$3_@0(read props$1.a)
139
+ [2] Const mutate b$4_@0[0:3] = Call mutate compute$3_@0(read props$1.b)
140
"]
141
bb0_instrs --> bb0_terminal(["If (read props$1.c)"])
142
end
compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md
+4
-4
@@ -28,8 +28,8 @@ function Foo() {}
28
29
```
30
bb0:
31
- [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
32
- [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b)
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] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0)
34
[4] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
35
Return read $7_@1
@@ -42,8 +42,8 @@ flowchart TB
42
%% Basic Blocks
43
subgraph bb0
44
bb0_instrs["
45
- [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a)
46
- [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b)
45
+ [1] Const mutate a$2_@0[0:3] = Call mutate compute$3_@0(read props$1.a)
46
+ [2] Const mutate b$4_@0[0:3] = Call mutate compute$3_@0(read props$1.b)
47
[3] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0)
48
[4] Const mutate $7_@1 = JSX <read Foo$6 a={freeze a$2_@0} b={freeze b$4_@0} ></read Foo$6>
49
"]
compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md
+18
-18
@@ -23,15 +23,15 @@ function g() {}
23
24
```
25
bb0:
26
- [1] Const mutate $2_@0 = Call mutate f$1_@0()
26
+ [1] Const mutate $2_@0[0:1] = Call mutate f$1_@0()
27
If (read $2_@0) then:bb2 else:bb3
28
bb2:
29
predecessor blocks: bb0
30
- [2] Const mutate $3_@1 = Call mutate g$4_@1()
30
+ [2] Const mutate $3_@1[0:3] = Call mutate g$4_@1()
31
Goto bb1
32
bb3:
33
predecessor blocks: bb0
34
- [3] Const mutate $3_@1 = read $2_@0
34
+ [3] Const mutate $3_@1[0:3] = read $2_@0
35
Goto bb1
36
bb1:
37
predecessor blocks: bb2 bb3
@@ -45,19 +45,19 @@ flowchart TB
45
%% Basic Blocks
46
subgraph bb0
47
bb0_instrs["
48
- [1] Const mutate $2_@0 = Call mutate f$1_@0()
48
+ [1] Const mutate $2_@0[0:1] = Call mutate f$1_@0()
49
"]
50
bb0_instrs --> bb0_terminal(["If (read $2_@0)"])
51
end
52
subgraph bb2
53
bb2_instrs["
54
- [2] Const mutate $3_@1 = Call mutate g$4_@1()
54
+ [2] Const mutate $3_@1[0:3] = Call mutate g$4_@1()
55
"]
56
bb2_instrs --> bb2_terminal(["Goto"])
57
end
58
subgraph bb3
59
bb3_instrs["
60
- [3] Const mutate $3_@1 = read $2_@0
60
+ [3] Const mutate $3_@1[0:3] = read $2_@0
61
"]
62
bb3_instrs --> bb3_terminal(["Goto"])
63
end
@@ -89,15 +89,15 @@ function And$0() {
89
90
```
91
bb0:
92
- [1] Const mutate $2_@0 = Call mutate f$1_@0()
92
+ [1] Const mutate $2_@0[0:1] = Call mutate f$1_@0()
93
If (read $2_@0) then:bb2 else:bb3
94
bb2:
95
predecessor blocks: bb0
96
- [2] Const mutate $3_@1 = read $2_@0
96
+ [2] Const mutate $3_@1[0:3] = read $2_@0
97
Goto bb1
98
bb3:
99
predecessor blocks: bb0
100
- [3] Const mutate $3_@1 = Call mutate g$4_@1()
100
+ [3] Const mutate $3_@1[0:3] = Call mutate g$4_@1()
101
Goto bb1
102
bb1:
103
predecessor blocks: bb2 bb3
@@ -111,19 +111,19 @@ flowchart TB
111
%% Basic Blocks
112
subgraph bb0
113
bb0_instrs["
114
- [1] Const mutate $2_@0 = Call mutate f$1_@0()
114
+ [1] Const mutate $2_@0[0:1] = Call mutate f$1_@0()
115
"]
116
bb0_instrs --> bb0_terminal(["If (read $2_@0)"])
117
end
118
subgraph bb2
119
bb2_instrs["
120
- [2] Const mutate $3_@1 = read $2_@0
120
+ [2] Const mutate $3_@1[0:3] = read $2_@0
121
"]
122
bb2_instrs --> bb2_terminal(["Goto"])
123
end
124
subgraph bb3
125
bb3_instrs["
126
- [3] Const mutate $3_@1 = Call mutate g$4_@1()
126
+ [3] Const mutate $3_@1[0:3] = Call mutate g$4_@1()
127
"]
128
bb3_instrs --> bb3_terminal(["Goto"])
129
end
@@ -155,17 +155,17 @@ function Or$0() {
155
156
```
157
bb0:
158
- [1] Const mutate $3_@0 = Call mutate f$2_@0()
158
+ [1] Const mutate $3_@0[0:1] = Call mutate f$2_@0()
159
[2] Const mutate $4_@1 = null
160
[3] Const mutate $5_@2 = Binary read $3_@0 != read $4_@1
161
If (read $5_@2) then:bb2 else:bb3
162
bb2:
163
predecessor blocks: bb0
164
- [4] Const mutate $6_@3 = read $3_@0
164
+ [4] Const mutate $6_@3[0:5] = read $3_@0
165
Goto bb1
166
bb3:
167
predecessor blocks: bb0
168
- [5] Const mutate $6_@3 = Call mutate g$7_@3()
168
+ [5] Const mutate $6_@3[0:5] = Call mutate g$7_@3()
169
Goto bb1
170
bb1:
171
predecessor blocks: bb2 bb3
@@ -179,7 +179,7 @@ flowchart TB
179
%% Basic Blocks
180
subgraph bb0
181
bb0_instrs["
182
- [1] Const mutate $3_@0 = Call mutate f$2_@0()
182
+ [1] Const mutate $3_@0[0:1] = Call mutate f$2_@0()
183
[2] Const mutate $4_@1 = null
184
[3] Const mutate $5_@2 = Binary read $3_@0 != read $4_@1
185
"]
@@ -187,13 +187,13 @@ flowchart TB
187
end
188
subgraph bb2
189
bb2_instrs["
190
- [4] Const mutate $6_@3 = read $3_@0
190
+ [4] Const mutate $6_@3[0:5] = read $3_@0
191
"]
192
bb2_instrs --> bb2_terminal(["Goto"])
193
end
194
subgraph bb3
195
bb3_instrs["
196
- [5] Const mutate $6_@3 = Call mutate g$7_@3()
196
+ [5] Const mutate $6_@3[0:5] = Call mutate g$7_@3()
197
"]
198
bb3_instrs --> bb3_terminal(["Goto"])
199
end
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md
+18
-18
@@ -99,10 +99,10 @@ function cond$0(x$1) {
99
100
```
101
bb0:
102
- [1] Let mutate a$2_@0 = Object { }
103
- [2] Let mutate b$3_@0 = Object { }
104
- [3] Let mutate c$4_@1 = Object { }
105
- [4] Let mutate d$5_@0 = Object { }
102
+ [1] Let mutate a$2_@0[0:14] = Object { }
103
+ [2] Let mutate b$3_@0[0:14] = Object { }
104
+ [3] Let mutate c$4_@1[0:9] = Object { }
105
+ [4] Let mutate d$5_@0[0:14] = Object { }
106
While test=bb1 loop=bb3 fallthrough=bb2
107
bb1:
108
predecessor blocks: bb0 bb4
@@ -111,12 +111,12 @@ bb1:
111
bb3:
112
predecessor blocks: bb1
113
[6] Let mutate z$6_@3 = read a$2_@0
114
- [7] Reassign mutate a$2_@0[7:12] = read b$3_@0
115
- [8] Reassign mutate b$3_@0[8:11] = read c$4_@1
116
- [9] Reassign mutate c$4_@1 = read d$5_@0
117
- [10] Reassign mutate d$5_@0 = read z$6_@3
114
+ [7] Reassign mutate a$2_@0[0:14] = read b$3_@0
115
+ [8] Reassign mutate b$3_@0[0:14] = read c$4_@1
116
+ [9] Reassign mutate c$4_@1[0:9] = read d$5_@0
117
+ [10] Reassign mutate d$5_@0[0:14] = read z$6_@3
118
[11] Call mutate mutate$7_@0(mutate a$2_@0, mutate b$3_@0)
119
- [12] Const mutate $9_@0 = Call mutate cond$8_@0(mutate a$2_@0)
119
+ [12] Const mutate $9_@0[0:14] = Call mutate cond$8_@0(mutate a$2_@0)
120
If (read $9_@0) then:bb2 else:bb4
121
bb4:
122
predecessor blocks: bb3
@@ -147,10 +147,10 @@ flowchart TB
147
%% Basic Blocks
148
subgraph bb0
149
bb0_instrs["
150
- [1] Let mutate a$2_@0 = Object { }
151
- [2] Let mutate b$3_@0 = Object { }
152
- [3] Let mutate c$4_@1 = Object { }
153
- [4] Let mutate d$5_@0 = Object { }
150
+ [1] Let mutate a$2_@0[0:14] = Object { }
151
+ [2] Let mutate b$3_@0[0:14] = Object { }
152
+ [3] Let mutate c$4_@1[0:9] = Object { }
153
+ [4] Let mutate d$5_@0[0:14] = Object { }
154
"]
155
bb0_instrs --> bb0_terminal(["While"])
156
end
@@ -163,12 +163,12 @@ flowchart TB
163
subgraph bb3
164
bb3_instrs["
165
[6] Let mutate z$6_@3 = read a$2_@0
166
- [7] Reassign mutate a$2_@0[7:12] = read b$3_@0
167
- [8] Reassign mutate b$3_@0[8:11] = read c$4_@1
168
- [9] Reassign mutate c$4_@1 = read d$5_@0
169
- [10] Reassign mutate d$5_@0 = read z$6_@3
166
+ [7] Reassign mutate a$2_@0[0:14] = read b$3_@0
167
+ [8] Reassign mutate b$3_@0[0:14] = read c$4_@1
168
+ [9] Reassign mutate c$4_@1[0:9] = read d$5_@0
169
+ [10] Reassign mutate d$5_@0[0:14] = read z$6_@3
170
[11] Call mutate mutate$7_@0(mutate a$2_@0, mutate b$3_@0)
171
- [12] Const mutate $9_@0 = Call mutate cond$8_@0(mutate a$2_@0)
171
+ [12] Const mutate $9_@0[0:14] = Call mutate cond$8_@0(mutate a$2_@0)
172
"]
173
bb3_instrs --> bb3_terminal(["If (read $9_@0)"])
174
end
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md
+8
-8
@@ -70,10 +70,10 @@ bb0:
70
[1] Const mutate a$2_@0 = Object { }
71
[2] Const mutate b$3_@1 = Array [read a$2_@0]
72
[3] Const mutate c$4_@2 = Object { }
73
- [4] Const mutate d$5_@3[4:7] = Object { c: read c$4_@2 }
74
- [5] Const mutate x$6_@3[5:9] = Object { }
75
- [6] Reassign mutate x$6_@3.b[5:9] = read b$3_@1
76
- [7] Const mutate y$7_@3 = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3)
73
+ [4] Const mutate d$5_@3[0:9] = Object { c: read c$4_@2 }
74
+ [5] Const mutate x$6_@3[0:9] = Object { }
75
+ [6] Reassign mutate x$6_@3.b[0:9] = read b$3_@1
76
+ [7] Const mutate y$7_@3[0:9] = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3)
77
If (read a$2_@0) then:bb1 else:bb1
78
bb1:
79
predecessor blocks: bb0
@@ -104,10 +104,10 @@ flowchart TB
104
[1] Const mutate a$2_@0 = Object { }
105
[2] Const mutate b$3_@1 = Array [read a$2_@0]
106
[3] Const mutate c$4_@2 = Object { }
107
- [4] Const mutate d$5_@3[4:7] = Object { c: read c$4_@2 }
108
- [5] Const mutate x$6_@3[5:9] = Object { }
109
- [6] Reassign mutate x$6_@3.b[5:9] = read b$3_@1
110
- [7] Const mutate y$7_@3 = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3)
107
+ [4] Const mutate d$5_@3[0:9] = Object { c: read c$4_@2 }
108
+ [5] Const mutate x$6_@3[0:9] = Object { }
109
+ [6] Reassign mutate x$6_@3.b[0:9] = read b$3_@1
110
+ [7] Const mutate y$7_@3[0:9] = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3)
111
"]
112
bb0_instrs --> bb0_terminal(["If (read a$2_@0)"])
113
end
compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md
+8
-8
@@ -94,10 +94,10 @@ function cond$0() {
94
95
```
96
bb0:
97
- [1] Let mutate a$2_@0[1:7] = Object { }
98
- [2] Let mutate b$3_@0[2:6] = Object { }
97
+ [1] Let mutate a$2_@0[0:9] = Object { }
98
+ [2] Let mutate b$3_@0[0:9] = Object { }
99
[3] Let mutate c$4_@1 = Object { }
100
- [4] Let mutate d$5_@0[4:9] = Object { }
100
+ [4] Let mutate d$5_@0[0:9] = Object { }
101
While test=bb1 loop=bb3 fallthrough=bb2
102
bb1:
103
predecessor blocks: bb0 bb4
@@ -106,7 +106,7 @@ bb1:
106
bb3:
107
predecessor blocks: bb1
108
[6] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0)
109
- [7] Const mutate $8_@0 = Call mutate cond$7_@0(mutate a$2_@0)
109
+ [7] Const mutate $8_@0[0:9] = Call mutate cond$7_@0(mutate a$2_@0)
110
If (read $8_@0) then:bb2 else:bb4
111
bb4:
112
predecessor blocks: bb3
@@ -137,10 +137,10 @@ flowchart TB
137
%% Basic Blocks
138
subgraph bb0
139
bb0_instrs["
140
- [1] Let mutate a$2_@0[1:7] = Object { }
141
- [2] Let mutate b$3_@0[2:6] = Object { }
140
+ [1] Let mutate a$2_@0[0:9] = Object { }
141
+ [2] Let mutate b$3_@0[0:9] = Object { }
142
[3] Let mutate c$4_@1 = Object { }
143
- [4] Let mutate d$5_@0[4:9] = Object { }
143
+ [4] Let mutate d$5_@0[0:9] = Object { }
144
"]
145
bb0_instrs --> bb0_terminal(["While"])
146
end
@@ -153,7 +153,7 @@ flowchart TB
153
subgraph bb3
154
bb3_instrs["
155
[6] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0)
156
- [7] Const mutate $8_@0 = Call mutate cond$7_@0(mutate a$2_@0)
156
+ [7] Const mutate $8_@0[0:9] = Call mutate cond$7_@0(mutate a$2_@0)
157
"]
158
bb3_instrs --> bb3_terminal(["If (read $8_@0)"])
159
end
compiler/forget/src/__tests__/fixtures/hir/reactive-scope-grouping.expect.md
+2
-2
@@ -20,7 +20,7 @@ function foo() {
20
bb0:
21
[1] Let mutate x$1_@0[1:5] = Object { }
22
[2] Let mutate y$2_@1[2:4] = Array []
23
- [3] Let mutate z$3_@1[3:4] = Object { }
23
+ [3] Let mutate z$3_@1[2:4] = Object { }
24
[4] Call mutate y$2_@1.push(mutate z$3_@1)
25
[5] Reassign mutate x$1_@0.y[1:5] = read y$2_@1
26
Return freeze x$1_@0
@@ -35,7 +35,7 @@ flowchart TB
35
bb0_instrs["
36
[1] Let mutate x$1_@0[1:5] = Object { }
37
[2] Let mutate y$2_@1[2:4] = Array []
38
- [3] Let mutate z$3_@1[3:4] = Object { }
38
+ [3] Let mutate z$3_@1[2:4] = Object { }
39
[4] Call mutate y$2_@1.push(mutate z$3_@1)
40
[5] Reassign mutate x$1_@0.y[1:5] = read y$2_@1
41
"]
compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md
+4
-4
@@ -23,13 +23,13 @@ function Component(props) {
23
24
```
25
bb0:
26
- [1] Let mutate x$2_@0[1:2] = Array []
26
+ [1] Let mutate x$2_@0[1:4] = Array []
27
[2] Call mutate x$2_@0.push(read props$1.p0)
28
[3] Let mutate y$3_@1 = read x$2_@0
29
If (read props$1.p1) then:bb2 else:bb1
30
bb2:
31
predecessor blocks: bb0
32
- [4] Reassign mutate x$2_@0 = Array []
32
+ [4] Reassign mutate x$2_@0[1:4] = Array []
33
Goto bb1
34
bb1:
35
predecessor blocks: bb2 bb0
@@ -46,7 +46,7 @@ flowchart TB
46
%% Basic Blocks
47
subgraph bb0
48
bb0_instrs["
49
- [1] Let mutate x$2_@0[1:2] = Array []
49
+ [1] Let mutate x$2_@0[1:4] = Array []
50
[2] Call mutate x$2_@0.push(read props$1.p0)
51
[3] Let mutate y$3_@1 = read x$2_@0
52
"]
@@ -54,7 +54,7 @@ flowchart TB
54
end
55
subgraph bb2
56
bb2_instrs["
57
- [4] Reassign mutate x$2_@0 = Array []
57
+ [4] Reassign mutate x$2_@0[1:4] = Array []
58
"]
59
bb2_instrs --> bb2_terminal(["Goto"])
60
end
compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md
+10
-10
@@ -50,26 +50,26 @@ bb2:
50
Default: bb4
51
bb8:
52
predecessor blocks: bb2
53
- [5] Reassign mutate x$2_@4 = read props$1.v0
53
+ [5] Reassign mutate x$2_@4[5:9] = read props$1.v0
54
Goto bb1
55
bb6:
56
predecessor blocks: bb2
57
- [6] Reassign mutate x$2_@4 = read props$1.v1
57
+ [6] Reassign mutate x$2_@4[5:9] = read props$1.v1
58
Goto bb1
59
bb4:
60
predecessor blocks: bb2
61
- [7] Reassign mutate x$2_@4 = read props$1.v2
61
+ [7] Reassign mutate x$2_@4[5:9] = read props$1.v2
62
Goto bb1
63
bb10:
64
predecessor blocks: bb0
65
If (read props$1.cond2) then:bb12 else:bb13
66
bb12:
67
predecessor blocks: bb10
68
- [8] Reassign mutate x$2_@4 = read props$1.b
68
+ [8] Reassign mutate x$2_@4[5:9] = read props$1.b
69
Goto bb1
70
bb13:
71
predecessor blocks: bb10
72
- [9] Reassign mutate x$2_@4 = read props$1.c
72
+ [9] Reassign mutate x$2_@4[5:9] = read props$1.c
73
Goto bb1
74
bb1:
75
predecessor blocks: bb8 bb6 bb4 bb12 bb13
@@ -98,19 +98,19 @@ flowchart TB
98
end
99
subgraph bb8
100
bb8_instrs["
101
- [5] Reassign mutate x$2_@4 = read props$1.v0
101
+ [5] Reassign mutate x$2_@4[5:9] = read props$1.v0
102
"]
103
bb8_instrs --> bb8_terminal(["Goto"])
104
end
105
subgraph bb6
106
bb6_instrs["
107
- [6] Reassign mutate x$2_@4 = read props$1.v1
107
+ [6] Reassign mutate x$2_@4[5:9] = read props$1.v1
108
"]
109
bb6_instrs --> bb6_terminal(["Goto"])
110
end
111
subgraph bb4
112
bb4_instrs["
113
- [7] Reassign mutate x$2_@4 = read props$1.v2
113
+ [7] Reassign mutate x$2_@4[5:9] = read props$1.v2
114
"]
115
bb4_instrs --> bb4_terminal(["Goto"])
116
end
@@ -119,13 +119,13 @@ flowchart TB
119
end
120
subgraph bb12
121
bb12_instrs["
122
- [8] Reassign mutate x$2_@4 = read props$1.b
122
+ [8] Reassign mutate x$2_@4[5:9] = read props$1.b
123
"]
124
bb12_instrs --> bb12_terminal(["Goto"])
125
end
126
subgraph bb13
127
bb13_instrs["
128
- [9] Reassign mutate x$2_@4 = read props$1.c
128
+ [9] Reassign mutate x$2_@4[5:9] = read props$1.c
129
"]
130
bb13_instrs --> bb13_terminal(["Goto"])
131
end
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md
+6
-6
@@ -50,10 +50,10 @@ function foo$0() {
50
51
```
52
bb0:
53
- [1] Const mutate a$2_@0[1:3] = Array []
54
- [2] Const mutate b$3_@0[2:7] = Object { }
53
+ [1] Const mutate a$2_@0[0:7] = Array []
54
+ [2] Const mutate b$3_@0[0:7] = Object { }
55
[3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
56
- [4] Const mutate $7_@0 = Call mutate foo$4_@0()
56
+ [4] Const mutate $7_@0[0:7] = Call mutate foo$4_@0()
57
If (read $7_@0) then:bb2 else:bb1
58
bb2:
59
predecessor blocks: bb0
@@ -75,10 +75,10 @@ flowchart TB
75
%% Basic Blocks
76
subgraph bb0
77
bb0_instrs["
78
- [1] Const mutate a$2_@0[1:3] = Array []
79
- [2] Const mutate b$3_@0[2:7] = Object { }
78
+ [1] Const mutate a$2_@0[0:7] = Array []
79
+ [2] Const mutate b$3_@0[0:7] = Object { }
80
[3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
81
- [4] Const mutate $7_@0 = Call mutate foo$4_@0()
81
+ [4] Const mutate $7_@0[0:7] = Call mutate foo$4_@0()
82
"]
83
bb0_instrs --> bb0_terminal(["If (read $7_@0)"])
84
end
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md
+4
-4
@@ -47,8 +47,8 @@ function foo$0() {
47
48
```
49
bb0:
50
- [1] Const mutate a$2_@0[1:3] = Array []
51
- [2] Const mutate b$3_@0[2:6] = Object { }
50
+ [1] Const mutate a$2_@0[0:6] = Array []
51
+ [2] Const mutate b$3_@0[0:6] = Object { }
52
[3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
53
[4] Const mutate $6_@1 = "div"
54
[5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
@@ -65,8 +65,8 @@ flowchart TB
65
%% Basic Blocks
66
subgraph bb0
67
bb0_instrs["
68
- [1] Const mutate a$2_@0[1:3] = Array []
69
- [2] Const mutate b$3_@0[2:6] = Object { }
68
+ [1] Const mutate a$2_@0[0:6] = Array []
69
+ [2] Const mutate b$3_@0[0:6] = Object { }
70
[3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0)
71
[4] Const mutate $6_@1 = 'div'
72
[5] Let mutate _$5_@2 = JSX <read $6_@1 a={freeze a$2_@0} ></read $6_@1>
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md
+6
-6
@@ -21,14 +21,14 @@ function foo() {
21
22
```
23
bb0:
24
- [1] Let mutate x$1_@0 = 1
24
+ [1] Let mutate x$1_@0[1:8] = 1
25
[2] Let mutate y$2_@1 = 2
26
[3] Const mutate $3_@2 = 2
27
[4] Const mutate $4_@3 = Binary read y$2_@1 === read $3_@2
28
If (read $4_@3) then:bb2 else:bb1
29
bb2:
30
predecessor blocks: bb0
31
- [5] Reassign mutate x$1_@0 = 3
31
+ [5] Reassign mutate x$1_@0[1:8] = 3
32
Goto bb1
33
bb1:
34
predecessor blocks: bb2 bb0
@@ -37,7 +37,7 @@ bb1:
37
If (read $6_@5) then:bb4 else:bb3
38
bb4:
39
predecessor blocks: bb1
40
- [8] Reassign mutate x$1_@0 = 5
40
+ [8] Reassign mutate x$1_@0[1:8] = 5
41
Goto bb3
42
bb3:
43
predecessor blocks: bb4 bb1
@@ -52,7 +52,7 @@ flowchart TB
52
%% Basic Blocks
53
subgraph bb0
54
bb0_instrs["
55
- [1] Let mutate x$1_@0 = 1
55
+ [1] Let mutate x$1_@0[1:8] = 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
@@ -61,7 +61,7 @@ flowchart TB
61
end
62
subgraph bb2
63
bb2_instrs["
64
- [5] Reassign mutate x$1_@0 = 3
64
+ [5] Reassign mutate x$1_@0[1:8] = 3
65
"]
66
bb2_instrs --> bb2_terminal(["Goto"])
67
end
@@ -74,7 +74,7 @@ flowchart TB
74
end
75
subgraph bb4
76
bb4_instrs["
77
- [8] Reassign mutate x$1_@0 = 5
77
+ [8] Reassign mutate x$1_@0[1:8] = 5
78
"]
79
bb4_instrs --> bb4_terminal(["Goto"])
80
end
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md
+4
-4
@@ -18,14 +18,14 @@ function foo() {
18
19
```
20
bb0:
21
- [1] Let mutate x$1_@0 = 1
21
+ [1] Let mutate x$1_@0[1:5] = 1
22
[2] Let mutate y$2_@1 = 2
23
[3] Const mutate $3_@2 = 2
24
[4] Const mutate $4_@3 = Binary read y$2_@1 === read $3_@2
25
If (read $4_@3) then:bb2 else:bb1
26
bb2:
27
predecessor blocks: bb0
28
- [5] Reassign mutate x$1_@0 = 3
28
+ [5] Reassign mutate x$1_@0[1:5] = 3
29
Goto bb1
30
bb1:
31
predecessor blocks: bb2 bb0
@@ -40,7 +40,7 @@ flowchart TB
40
%% Basic Blocks
41
subgraph bb0
42
bb0_instrs["
43
- [1] Let mutate x$1_@0 = 1
43
+ [1] Let mutate x$1_@0[1:5] = 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
@@ -49,7 +49,7 @@ flowchart TB
49
end
50
subgraph bb2
51
bb2_instrs["
52
- [5] Reassign mutate x$1_@0 = 3
52
+ [5] Reassign mutate x$1_@0[1:5] = 3
53
"]
54
bb2_instrs --> bb2_terminal(["Goto"])
55
end
compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md
+4
-4
@@ -16,7 +16,7 @@ function foo() {
16
17
```
18
bb0:
19
- [1] Let mutate x$1_@0 = 0
19
+ [1] Let mutate x$1_@0[0:5] = 0
20
Goto bb1
21
bb1:
22
predecessor blocks: bb0 bb4
@@ -26,7 +26,7 @@ bb1:
26
bb4:
27
predecessor blocks: bb1
28
[4] Const mutate $2_@3 = 1
29
- [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3
29
+ [5] Reassign mutate x$1_@0[0:5] = Binary read x$1_@0 + read $2_@3
30
Goto(Continue) bb1
31
bb2:
32
predecessor blocks: bb1
@@ -40,7 +40,7 @@ flowchart TB
40
%% Basic Blocks
41
subgraph bb0
42
bb0_instrs["
43
- [1] Let mutate x$1_@0 = 0
43
+ [1] Let mutate x$1_@0[0:5] = 0
44
"]
45
bb0_instrs --> bb0_terminal(["Goto"])
46
end
@@ -54,7 +54,7 @@ flowchart TB
54
subgraph bb4
55
bb4_instrs["
56
[4] Const mutate $2_@3 = 1
57
- [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3
57
+ [5] Reassign mutate x$1_@0[0:5] = Binary read x$1_@0 + read $2_@3
58
"]
59
bb4_instrs --> bb4_terminal(["Goto"])
60
end
compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md
+6
-6
@@ -45,9 +45,9 @@ function Foo$0() {
45
46
```
47
bb0:
48
- [1] Const mutate a$2_@0[1:3] = Array []
49
- [2] Const mutate b$3_@0[2:3] = Object { }
50
- [3] Let mutate c$4_@0 = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0)
48
+ [1] Const mutate a$2_@0[0:3] = Array []
49
+ [2] Const mutate b$3_@0[0:3] = Object { }
50
+ [3] Let mutate c$4_@0[0:3] = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0)
51
Return freeze c$4_@0
52
```
53
@@ -58,9 +58,9 @@ flowchart TB
58
%% Basic Blocks
59
subgraph bb0
60
bb0_instrs["
61
- [1] Const mutate a$2_@0[1:3] = Array []
62
- [2] Const mutate b$3_@0[2:3] = Object { }
63
- [3] Let mutate c$4_@0 = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0)
61
+ [1] Const mutate a$2_@0[0:3] = Array []
62
+ [2] Const mutate b$3_@0[0:3] = Object { }
63
+ [3] Let mutate c$4_@0[0:3] = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0)
64
"]
65
bb0_instrs --> bb0_terminal(["Return freeze c$4_@0"])
66
end
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md
+8
-8
@@ -22,18 +22,18 @@ function foo() {
22
23
```
24
bb0:
25
- [1] Let mutate x$1_@0 = 1
26
- [2] Let mutate y$2_@1 = 2
25
+ [1] Let mutate x$1_@0[1:5] = 1
26
+ [2] Let mutate y$2_@1[2:6] = 2
27
[3] Const mutate $3_@2 = 1
28
[4] Const mutate $4_@3 = Binary read x$1_@0 > read $3_@2
29
If (read $4_@3) then:bb2 else:bb3
30
bb2:
31
predecessor blocks: bb0
32
- [5] Reassign mutate x$1_@0 = 2
32
+ [5] Reassign mutate x$1_@0[1:5] = 2
33
Goto bb1
34
bb3:
35
predecessor blocks: bb0
36
- [6] Reassign mutate y$2_@1 = 3
36
+ [6] Reassign mutate y$2_@1[2:6] = 3
37
Goto bb1
38
bb1:
39
predecessor blocks: bb2 bb3
@@ -48,8 +48,8 @@ flowchart TB
48
%% Basic Blocks
49
subgraph bb0
50
bb0_instrs["
51
- [1] Let mutate x$1_@0 = 1
52
- [2] Let mutate y$2_@1 = 2
51
+ [1] Let mutate x$1_@0[1:5] = 1
52
+ [2] Let mutate y$2_@1[2:6] = 2
53
[3] Const mutate $3_@2 = 1
54
[4] Const mutate $4_@3 = Binary read x$1_@0 > read $3_@2
55
"]
@@ -57,13 +57,13 @@ flowchart TB
57
end
58
subgraph bb2
59
bb2_instrs["
60
- [5] Reassign mutate x$1_@0 = 2
60
+ [5] Reassign mutate x$1_@0[1:5] = 2
61
"]
62
bb2_instrs --> bb2_terminal(["Goto"])
63
end
64
subgraph bb3
65
bb3_instrs["
66
- [6] Reassign mutate y$2_@1 = 3
66
+ [6] Reassign mutate y$2_@1[2:6] = 3
67
"]
68
bb3_instrs --> bb3_terminal(["Goto"])
69
end
compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md
+2
-2
@@ -17,7 +17,7 @@ function foo() {
17
bb0:
18
[1] Const mutate x$1_@0 = Array []
19
[2] Const mutate y$2_@1[2:4] = Object { x: read x$1_@0 }
20
- [3] Const mutate $3_@1[3:4] = Array []
20
+ [3] Const mutate $3_@1[2:4] = Array []
21
[4] Call mutate y$2_@1.x.push(mutate $3_@1)
22
Return freeze y$2_@1
23
```
@@ -31,7 +31,7 @@ flowchart TB
31
bb0_instrs["
32
[1] Const mutate x$1_@0 = Array []
33
[2] Const mutate y$2_@1[2:4] = Object { x: read x$1_@0 }
34
- [3] Const mutate $3_@1[3:4] = Array []
34
+ [3] Const mutate $3_@1[2:4] = Array []
35
[4] Call mutate y$2_@1.x.push(mutate $3_@1)
36
"]
37
bb0_instrs --> bb0_terminal(["Return freeze y$2_@1"])
compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md
+4
-4
@@ -17,13 +17,13 @@ function foo() {
17
18
```
19
bb0:
20
- [1] Let mutate x$1_@0 = 1
20
+ [1] Let mutate x$1_@0[1:4] = 1
21
[2] Const mutate $2_@1 = 1
22
[3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
23
If (read $3_@2) then:bb2 else:bb1
24
bb2:
25
predecessor blocks: bb0
26
- [4] Reassign mutate x$1_@0 = 2
26
+ [4] Reassign mutate x$1_@0[1:4] = 2
27
Goto bb1
28
bb1:
29
predecessor blocks: bb2 bb0
@@ -37,7 +37,7 @@ flowchart TB
37
%% Basic Blocks
38
subgraph bb0
39
bb0_instrs["
40
- [1] Let mutate x$1_@0 = 1
40
+ [1] Let mutate x$1_@0[1:4] = 1
41
[2] Const mutate $2_@1 = 1
42
[3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
43
"]
@@ -45,7 +45,7 @@ flowchart TB
45
end
46
subgraph bb2
47
bb2_instrs["
48
- [4] Reassign mutate x$1_@0 = 2
48
+ [4] Reassign mutate x$1_@0[1:4] = 2
49
"]
50
bb2_instrs --> bb2_terminal(["Goto"])
51
end
compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md
+4
-4
@@ -49,7 +49,7 @@ function log$0() {
49
50
```
51
bb0:
52
- [1] Let mutate str$2_@0 = ""
52
+ [1] Let mutate str$2_@0[1:4] = ""
53
If (read cond$1) then:bb2 else:bb3
54
bb2:
55
predecessor blocks: bb0
@@ -58,7 +58,7 @@ bb2:
58
Goto bb1
59
bb3:
60
predecessor blocks: bb0
61
- [4] Reassign mutate str$2_@0 = "fallthrough test"
61
+ [4] Reassign mutate str$2_@0[1:4] = "fallthrough test"
62
Goto bb1
63
bb1:
64
predecessor blocks: bb2 bb3
@@ -73,7 +73,7 @@ flowchart TB
73
%% Basic Blocks
74
subgraph bb0
75
bb0_instrs["
76
- [1] Let mutate str$2_@0 = ''
76
+ [1] Let mutate str$2_@0[1:4] = ''
77
"]
78
bb0_instrs --> bb0_terminal(["If (read cond$1)"])
79
end
@@ -86,7 +86,7 @@ flowchart TB
86
end
87
subgraph bb3
88
bb3_instrs["
89
- [4] Reassign mutate str$2_@0 = 'fallthrough test'
89
+ [4] Reassign mutate str$2_@0[1:4] = 'fallthrough test'
90
"]
91
bb3_instrs --> bb3_terminal(["Goto"])
92
end
compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md
+4
-4
@@ -26,11 +26,11 @@ bb0:
26
If (read $3_@2) then:bb2 else:bb3
27
bb2:
28
predecessor blocks: bb0
29
- [4] Reassign mutate y$1_@3 = 1
29
+ [4] Reassign mutate y$1_@3[4:5] = 1
30
Goto bb1
31
bb3:
32
predecessor blocks: bb0
33
- [5] Reassign mutate y$1_@3 = 2
33
+ [5] Reassign mutate y$1_@3[4:5] = 2
34
Goto bb1
35
bb1:
36
predecessor blocks: bb2 bb3
@@ -53,13 +53,13 @@ flowchart TB
53
end
54
subgraph bb2
55
bb2_instrs["
56
- [4] Reassign mutate y$1_@3 = 1
56
+ [4] Reassign mutate y$1_@3[4:5] = 1
57
"]
58
bb2_instrs --> bb2_terminal(["Goto"])
59
end
60
subgraph bb3
61
bb3_instrs["
62
- [5] Reassign mutate y$1_@3 = 2
62
+ [5] Reassign mutate y$1_@3[4:5] = 2
63
"]
64
bb3_instrs --> bb3_terminal(["Goto"])
65
end
compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md
+6
-6
@@ -40,17 +40,17 @@ bb0:
40
bb5:
41
predecessor blocks: bb0
42
[6] Const mutate $6_@5 = 1
43
- [7] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $6_@5
43
+ [7] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $6_@5
44
Goto bb1
45
bb3:
46
predecessor blocks: bb0
47
[8] Const mutate $3_@7 = 2
48
- [9] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $3_@7
48
+ [9] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $3_@7
49
Goto bb1
50
bb2:
51
predecessor blocks: bb0
52
[10] Const mutate $2_@8 = 3
53
- [11] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $2_@8
53
+ [11] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $2_@8
54
Goto bb1
55
bb1:
56
predecessor blocks: bb5 bb3 bb2
@@ -76,21 +76,21 @@ flowchart TB
76
subgraph bb5
77
bb5_instrs["
78
[6] Const mutate $6_@5 = 1
79
- [7] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $6_@5
79
+ [7] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $6_@5
80
"]
81
bb5_instrs --> bb5_terminal(["Goto"])
82
end
83
subgraph bb3
84
bb3_instrs["
85
[8] Const mutate $3_@7 = 2
86
- [9] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $3_@7
86
+ [9] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $3_@7
87
"]
88
bb3_instrs --> bb3_terminal(["Goto"])
89
end
90
subgraph bb2
91
bb2_instrs["
92
[10] Const mutate $2_@8 = 3
93
- [11] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $2_@8
93
+ [11] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $2_@8
94
"]
95
bb2_instrs --> bb2_terminal(["Goto"])
96
end
compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md
+4
-4
@@ -16,13 +16,13 @@ function foo() {
16
17
```
18
bb0:
19
- [1] Let mutate x$1_@0 = 1
19
+ [1] Let mutate x$1_@0[1:4] = 1
20
[2] Const mutate $2_@1 = 1
21
[3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
22
If (read $3_@2) then:bb2 else:bb1
23
bb2:
24
predecessor blocks: bb0
25
- [4] Reassign mutate x$1_@0 = 2
25
+ [4] Reassign mutate x$1_@0[1:4] = 2
26
Goto bb1
27
bb1:
28
predecessor blocks: bb2 bb0
@@ -36,7 +36,7 @@ flowchart TB
36
%% Basic Blocks
37
subgraph bb0
38
bb0_instrs["
39
- [1] Let mutate x$1_@0 = 1
39
+ [1] Let mutate x$1_@0[1:4] = 1
40
[2] Const mutate $2_@1 = 1
41
[3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1
42
"]
@@ -44,7 +44,7 @@ flowchart TB
44
end
45
subgraph bb2
46
bb2_instrs["
47
- [4] Reassign mutate x$1_@0 = 2
47
+ [4] Reassign mutate x$1_@0[1:4] = 2
48
"]
49
bb2_instrs --> bb2_terminal(["Goto"])
50
end
compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md
+4
-4
@@ -17,7 +17,7 @@ function foo() {
17
18
```
19
bb0:
20
- [1] Let mutate x$1_@0 = 1
20
+ [1] Let mutate x$1_@0[0:5] = 1
21
While test=bb1 loop=bb3 fallthrough=bb2
22
bb1:
23
predecessor blocks: bb0 bb3
@@ -27,7 +27,7 @@ bb1:
27
bb3:
28
predecessor blocks: bb1
29
[4] Const mutate $2_@3 = 1
30
- [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3
30
+ [5] Reassign mutate x$1_@0[0:5] = Binary read x$1_@0 + read $2_@3
31
Goto(Continue) bb1
32
bb2:
33
predecessor blocks: bb1
@@ -41,7 +41,7 @@ flowchart TB
41
%% Basic Blocks
42
subgraph bb0
43
bb0_instrs["
44
- [1] Let mutate x$1_@0 = 1
44
+ [1] Let mutate x$1_@0[0:5] = 1
45
"]
46
bb0_instrs --> bb0_terminal(["While"])
47
end
@@ -55,7 +55,7 @@ flowchart TB
55
subgraph bb3
56
bb3_instrs["
57
[4] Const mutate $2_@3 = 1
58
- [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3
58
+ [5] Reassign mutate x$1_@0[0:5] = Binary read x$1_@0 + read $2_@3
59
"]
60
bb3_instrs --> bb3_terminal(["Goto"])
61
end
compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md
+6
-6
@@ -33,7 +33,7 @@ function Component(props) {
33
```
34
bb0:
35
[1] Let mutate x$2_@0[1:6] = Array []
36
- [2] Let mutate y$3_@1 = undefined
36
+ [2] Let mutate y$3_@1[2:8] = undefined
37
[3] Const mutate $4_@2 = false
38
[4] Const mutate $5_@3 = true
39
[5] Const mutate $6_@4 = 1
@@ -45,11 +45,11 @@ bb0:
45
bb6:
46
predecessor blocks: bb0
47
[6] Call mutate x$2_@0.push(read props$1.p2)
48
- [7] Reassign mutate y$3_@1 = Array []
48
+ [7] Reassign mutate y$3_@1[2:8] = Array []
49
Goto bb1
50
bb2:
51
predecessor blocks: bb0
52
- [8] Reassign mutate y$3_@1 = read x$2_@0
52
+ [8] Reassign mutate y$3_@1[2:8] = read x$2_@0
53
Goto bb1
54
bb1:
55
predecessor blocks: bb0 bb6 bb2
@@ -67,7 +67,7 @@ flowchart TB
67
subgraph bb0
68
bb0_instrs["
69
[1] Let mutate x$2_@0[1:6] = Array []
70
- [2] Let mutate y$3_@1 = undefined
70
+ [2] Let mutate y$3_@1[2:8] = undefined
71
[3] Const mutate $4_@2 = false
72
[4] Const mutate $5_@3 = true
73
[5] Const mutate $6_@4 = 1
@@ -77,13 +77,13 @@ flowchart TB
77
subgraph bb6
78
bb6_instrs["
79
[6] Call mutate x$2_@0.push(read props$1.p2)
80
- [7] Reassign mutate y$3_@1 = Array []
80
+ [7] Reassign mutate y$3_@1[2:8] = Array []
81
"]
82
bb6_instrs --> bb6_terminal(["Goto"])
83
end
84
subgraph bb2
85
bb2_instrs["
86
- [8] Reassign mutate y$3_@1 = read x$2_@0
86
+ [8] Reassign mutate y$3_@1[2:8] = read x$2_@0
87
"]
88
bb2_instrs --> bb2_terminal(["Goto"])
89
end
compiler/forget/src/__tests__/fixtures/hir/switch.expect.md
+4
-4
@@ -29,7 +29,7 @@ function Component(props) {
29
```
30
bb0:
31
[1] Let mutate x$2_@0[1:6] = Array []
32
- [2] Let mutate y$3_@1 = undefined
32
+ [2] Let mutate y$3_@1[2:8] = undefined
33
[3] Const mutate $4_@2 = false
34
[4] Const mutate $5_@3 = true
35
Switch (read props$1.p0)
@@ -44,7 +44,7 @@ bb4:
44
Goto bb2
45
bb2:
46
predecessor blocks: bb4 bb0
47
- [8] Reassign mutate y$3_@1 = read x$2_@0
47
+ [8] Reassign mutate y$3_@1[2:8] = read x$2_@0
48
Goto bb1
49
bb1:
50
predecessor blocks: bb2 bb0
@@ -62,7 +62,7 @@ flowchart TB
62
subgraph bb0
63
bb0_instrs["
64
[1] Let mutate x$2_@0[1:6] = Array []
65
- [2] Let mutate y$3_@1 = undefined
65
+ [2] Let mutate y$3_@1[2:8] = undefined
66
[3] Const mutate $4_@2 = false
67
[4] Const mutate $5_@3 = true
68
"]
@@ -78,7 +78,7 @@ flowchart TB
78
end
79
subgraph bb2
80
bb2_instrs["
81
- [8] Reassign mutate y$3_@1 = read x$2_@0
81
+ [8] Reassign mutate y$3_@1[2:8] = read x$2_@0
82
"]
83
bb2_instrs --> bb2_terminal(["Goto"])
84
end