diff --git a/compiler/forget/src/HIR/InferMutableLifetimes.ts b/compiler/forget/src/HIR/InferMutableLifetimes.ts index 17c17c79fd..9a188b0bb8 100644 --- a/compiler/forget/src/HIR/InferMutableLifetimes.ts +++ b/compiler/forget/src/HIR/InferMutableLifetimes.ts @@ -5,10 +5,11 @@ * LICENSE file in the root directory of this source tree. */ +import invariant from "invariant"; import { assertExhaustive } from "../Common/utils"; import { Effect, HIRFunction, Instruction, Place } from "./HIR"; -import { eachInstructionOperand } from "./visitors"; import { printInstruction, printPlace } from "./PrintHIR"; +import { eachInstructionOperand } from "./visitors"; /** * For each usage of a value in the given function, determines if the usage @@ -77,9 +78,19 @@ function inferPlace(place: Place, instr: Instruction) { export function inferMutableRanges(func: HIRFunction) { for (const [_, block] of func.body.blocks) { for (const phi of block.phis) { + let start = Number.MAX_SAFE_INTEGER; + let end = Number.MIN_SAFE_INTEGER; + for (const [_, operand] of phi.operands) { + start = Math.min(start, operand.mutableRange.start); + end = Math.max(end, operand.mutableRange.end); + } + invariant( + start !== Number.MAX_SAFE_INTEGER && end !== Number.MIN_SAFE_INTEGER, + "Expected phi to have set start/end range values" + ); phi.id.mutableRange = { - start: -1, // TODO(gsn): This is a hack, we should assign proper ids to phis. - end: -1, + start, + end, }; } diff --git a/compiler/forget/src/HIR/InferReactiveScopeVariables.ts b/compiler/forget/src/HIR/InferReactiveScopeVariables.ts index 854e765581..0295a63a9b 100644 --- a/compiler/forget/src/HIR/InferReactiveScopeVariables.ts +++ b/compiler/forget/src/HIR/InferReactiveScopeVariables.ts @@ -11,6 +11,7 @@ import { Identifier, Instruction, makeScopeId, + MutableRange, Place, ScopeId, } from "./HIR"; @@ -94,10 +95,20 @@ export function inferReactiveScopeVariables(fn: HIRFunction) { // Maps each scope (by its identifying member) to a ScopeId value const scopeIds: Map = new Map(); + // Store the mutable range and set of identifiers for each scope + const scopeVariables: Map< + ScopeId, + { range: MutableRange; variables: Set } + > = new Map(); - // Iterate over all the identifiers in all scopes, and assign each - // identifier to its group's scope id. The first identifier in each - // group assigns the scope id for that group. + /** + * Iterate over all the identifiers and assign a unique ScopeId + * for each scope (based on the set identifier). + * + * At the same time, group the identifiers in each scope and + * build a MutableRange that describes the span of mutations + * across all identifiers in each scope. + */ scopes.forEach((identifier, groupIdentifier) => { let scopeId = scopeIds.get(groupIdentifier); if (scopeId == null) { @@ -105,7 +116,31 @@ export function inferReactiveScopeVariables(fn: HIRFunction) { scopeIds.set(groupIdentifier, scopeId); } identifier.scope = scopeId; + + let scope = scopeVariables.get(scopeId); + if (scope === undefined) { + scope = { + range: { ...identifier.mutableRange }, + variables: new Set(), + }; + scopeVariables.set(scopeId, scope); + } else { + scope.range.start = Math.min( + scope.range.start, + identifier.mutableRange.start + ); + scope.range.end = Math.max(scope.range.end, identifier.mutableRange.end); + } + scope.variables.add(identifier); }); + + // Update all the identifiers for each scope now that we know + // the scope's full range. + for (const [_, scope] of scopeVariables) { + for (const identifier of scope.variables) { + identifier.mutableRange = scope.range; + } + } } // Is the operand mutable at this given instruction diff --git a/compiler/forget/src/__tests__/fixtures/hir/call.expect.md b/compiler/forget/src/__tests__/fixtures/hir/call.expect.md index 56a9835c54..a2b8206209 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/call.expect.md @@ -47,8 +47,8 @@ function foo$0() { ``` bb0: - [1] Const mutate a$2_@0[1:3] = Array [] - [2] Const mutate b$3_@0[2:6] = Object { } + [1] Const mutate a$2_@0[0:6] = Array [] + [2] Const mutate b$3_@0[0:6] = Object { } [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0) [4] Const mutate $6_@1 = "div" [5] Let mutate _$5_@2 = JSX @@ -65,8 +65,8 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:3] = Array [] - [2] Const mutate b$3_@0[2:6] = Object { } + [1] Const mutate a$2_@0[0:6] = Array [] + [2] Const mutate b$3_@0[0:6] = Object { } [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0) [4] Const mutate $6_@1 = 'div' [5] Let mutate _$5_@2 = JSX diff --git a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md index c69f71bf45..372e0cb70b 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md @@ -38,9 +38,9 @@ bb0: [1] Const mutate items$2_@0 = read props$1.items [2] Const mutate maxItems$3_@1 = read props$1.maxItems [3] Const mutate renderedItems$4_@2[3:14] = Array [] - [4] Const mutate seen$5_@3[4:11] = New mutate Set$6_@3() + [4] Const mutate seen$5_@3[0:11] = New mutate Set$6_@3() [5] Const mutate $9_@4 = 0 - [6] Const mutate max$7_@5 = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1) + [6] Const mutate max$7_@5[0:6] = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1) Goto bb1 bb1: predecessor blocks: bb0 bb5 bb10 @@ -48,15 +48,15 @@ bb1: bb3: predecessor blocks: bb1 [7] Const mutate $11_@6 = null - [8] Const mutate $12_@3 = Binary read item$10_@3 == read $11_@6 + [8] Const mutate $12_@3[0:11] = Binary read item$10_@3 == read $11_@6 If (read $12_@3) then:bb8 else:bb9 bb8: predecessor blocks: bb3 - [9] Const mutate $13_@3 = read $12_@3 + [9] Const mutate $13_@3[0:11] = read $12_@3 Goto bb7 bb9: predecessor blocks: bb3 - [10] Const mutate $13_@3 = Call mutate seen$5_@3.has(mutate item$10_@3) + [10] Const mutate $13_@3[0:11] = Call mutate seen$5_@3.has(mutate item$10_@3) Goto bb7 bb7: predecessor blocks: bb8 bb9 @@ -99,9 +99,9 @@ flowchart TB [1] Const mutate items$2_@0 = read props$1.items [2] Const mutate maxItems$3_@1 = read props$1.maxItems [3] Const mutate renderedItems$4_@2[3:14] = Array [] - [4] Const mutate seen$5_@3[4:11] = New mutate Set$6_@3() + [4] Const mutate seen$5_@3[0:11] = New mutate Set$6_@3() [5] Const mutate $9_@4 = 0 - [6] Const mutate max$7_@5 = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1) + [6] Const mutate max$7_@5[0:6] = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1) "] bb0_instrs --> bb0_terminal(["Goto"]) end @@ -111,19 +111,19 @@ flowchart TB subgraph bb3 bb3_instrs[" [7] Const mutate $11_@6 = null - [8] Const mutate $12_@3 = Binary read item$10_@3 == read $11_@6 + [8] Const mutate $12_@3[0:11] = Binary read item$10_@3 == read $11_@6 "] bb3_instrs --> bb3_terminal(["If (read $12_@3)"]) end subgraph bb8 bb8_instrs[" - [9] Const mutate $13_@3 = read $12_@3 + [9] Const mutate $13_@3[0:11] = read $12_@3 "] bb8_instrs --> bb8_terminal(["Goto"]) end subgraph bb9 bb9_instrs[" - [10] Const mutate $13_@3 = Call mutate seen$5_@3.has(mutate item$10_@3) + [10] Const mutate $13_@3[0:11] = Call mutate seen$5_@3.has(mutate item$10_@3) "] bb9_instrs --> bb9_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md b/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md index ca992ca580..a653b86e6d 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md @@ -154,8 +154,8 @@ function Component$0(props$1) { ``` bb0: [1] Const mutate a$2_@0[1:4] = Array [] - [2] Const mutate b$3_@1[2:5] = Array [] - [3] Const mutate $5_@1 = Call mutate mayMutate$4_@1(mutate b$3_@1) + [2] Const mutate b$3_@1[0:5] = Array [] + [3] Const mutate $5_@1[0:5] = Call mutate mayMutate$4_@1(mutate b$3_@1) If (read $5_@1) then:bb2 else:bb1 bb2: predecessor blocks: bb0 @@ -182,8 +182,8 @@ flowchart TB subgraph bb0 bb0_instrs[" [1] Const mutate a$2_@0[1:4] = Array [] - [2] Const mutate b$3_@1[2:5] = Array [] - [3] Const mutate $5_@1 = Call mutate mayMutate$4_@1(mutate b$3_@1) + [2] Const mutate b$3_@1[0:5] = Array [] + [3] Const mutate $5_@1[0:5] = Call mutate mayMutate$4_@1(mutate b$3_@1) "] bb0_instrs --> bb0_terminal(["If (read $5_@1)"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md b/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md index 4911b0ee41..37d84e1536 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md @@ -47,8 +47,8 @@ function Foo$0() { ``` bb0: - [1] Const mutate a$2_@0[1:3] = Array [] - [2] Const mutate b$3_@0[2:6] = Object { } + [1] Const mutate a$2_@0[0:6] = Array [] + [2] Const mutate b$3_@0[0:6] = Object { } [3] New mutate Foo$4_@0(mutate a$2_@0, mutate b$3_@0) [4] Const mutate $6_@1 = "div" [5] Let mutate _$5_@2 = JSX @@ -65,8 +65,8 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:3] = Array [] - [2] Const mutate b$3_@0[2:6] = Object { } + [1] Const mutate a$2_@0[0:6] = Array [] + [2] Const mutate b$3_@0[0:6] = Object { } [3] New mutate Foo$4_@0(mutate a$2_@0, mutate b$3_@0) [4] Const mutate $6_@1 = 'div' [5] Let mutate _$5_@2 = JSX diff --git a/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md b/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md index a71f744317..0de74857d1 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md @@ -32,11 +32,11 @@ bb0: If (read cond$2_@0) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [4] Reassign mutate a$4_@3 = read x$3_@1 + [4] Reassign mutate a$4_@3[4:5] = read x$3_@1 Goto bb1 bb3: predecessor blocks: bb0 - [5] Reassign mutate a$4_@3 = Array [] + [5] Reassign mutate a$4_@3[4:5] = Array [] Goto bb1 bb1: predecessor blocks: bb2 bb3 @@ -61,13 +61,13 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [4] Reassign mutate a$4_@3 = read x$3_@1 + [4] Reassign mutate a$4_@3[4:5] = read x$3_@1 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [5] Reassign mutate a$4_@3 = Array [] + [5] Reassign mutate a$4_@3[4:5] = Array [] "] bb3_instrs --> bb3_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md index e2185eda83..7de35eb6a1 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md @@ -149,8 +149,8 @@ function Foo$0() { ``` bb0: - [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a) - [2] Const mutate b$4_@0[2:4] = Call mutate compute$3_@0(read props$1.b) + [1] Const mutate a$2_@0[0:4] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:4] = Call mutate compute$3_@0(read props$1.b) If (read props$1.c) then:bb2 else:bb1 bb2: predecessor blocks: bb0 @@ -170,8 +170,8 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a) - [2] Const mutate b$4_@0[2:4] = Call mutate compute$3_@0(read props$1.b) + [1] Const mutate a$2_@0[0:4] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:4] = Call mutate compute$3_@0(read props$1.b) "] bb0_instrs --> bb0_terminal(["If (read props$1.c)"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md b/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md index f8be029c6d..9205c2653c 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md @@ -28,8 +28,8 @@ function Foo() {} ``` bb0: - [1] Const mutate a$2_@0 = Call mutate compute$3_@0(read props$1.a) - [2] Const mutate b$4_@0 = Call mutate compute$3_@0(read props$1.b) + [1] Const mutate a$2_@0[0:2] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:2] = Call mutate compute$3_@0(read props$1.b) [3] Const mutate $6_@1 = JSX Return read $6_@1 ``` @@ -41,8 +41,8 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0 = Call mutate compute$3_@0(read props$1.a) - [2] Const mutate b$4_@0 = Call mutate compute$3_@0(read props$1.b) + [1] Const mutate a$2_@0[0:2] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:2] = Call mutate compute$3_@0(read props$1.b) [3] Const mutate $6_@1 = JSX "] bb0_instrs --> bb0_terminal(["Return read $6_@1"]) diff --git a/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md index 77555ebcba..1c97f779d6 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md @@ -115,8 +115,8 @@ function Foo$0() { ``` bb0: - [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a) - [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b) + [1] Const mutate a$2_@0[0:3] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:3] = Call mutate compute$3_@0(read props$1.b) If (read props$1.c) then:bb2 else:bb1 bb2: predecessor blocks: bb0 @@ -135,8 +135,8 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a) - [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b) + [1] Const mutate a$2_@0[0:3] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:3] = Call mutate compute$3_@0(read props$1.b) "] bb0_instrs --> bb0_terminal(["If (read props$1.c)"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md b/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md index 317a224450..061fe93e36 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md @@ -28,8 +28,8 @@ function Foo() {} ``` bb0: - [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a) - [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b) + [1] Const mutate a$2_@0[0:3] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:3] = Call mutate compute$3_@0(read props$1.b) [3] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0) [4] Const mutate $7_@1 = JSX Return read $7_@1 @@ -42,8 +42,8 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:3] = Call mutate compute$3_@0(read props$1.a) - [2] Const mutate b$4_@0[2:3] = Call mutate compute$3_@0(read props$1.b) + [1] Const mutate a$2_@0[0:3] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:3] = Call mutate compute$3_@0(read props$1.b) [3] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0) [4] Const mutate $7_@1 = JSX "] diff --git a/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md b/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md index a59714410a..c310f9173d 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md @@ -23,15 +23,15 @@ function g() {} ``` bb0: - [1] Const mutate $2_@0 = Call mutate f$1_@0() + [1] Const mutate $2_@0[0:1] = Call mutate f$1_@0() If (read $2_@0) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [2] Const mutate $3_@1 = Call mutate g$4_@1() + [2] Const mutate $3_@1[0:3] = Call mutate g$4_@1() Goto bb1 bb3: predecessor blocks: bb0 - [3] Const mutate $3_@1 = read $2_@0 + [3] Const mutate $3_@1[0:3] = read $2_@0 Goto bb1 bb1: predecessor blocks: bb2 bb3 @@ -45,19 +45,19 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate $2_@0 = Call mutate f$1_@0() + [1] Const mutate $2_@0[0:1] = Call mutate f$1_@0() "] bb0_instrs --> bb0_terminal(["If (read $2_@0)"]) end subgraph bb2 bb2_instrs[" - [2] Const mutate $3_@1 = Call mutate g$4_@1() + [2] Const mutate $3_@1[0:3] = Call mutate g$4_@1() "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [3] Const mutate $3_@1 = read $2_@0 + [3] Const mutate $3_@1[0:3] = read $2_@0 "] bb3_instrs --> bb3_terminal(["Goto"]) end @@ -89,15 +89,15 @@ function And$0() { ``` bb0: - [1] Const mutate $2_@0 = Call mutate f$1_@0() + [1] Const mutate $2_@0[0:1] = Call mutate f$1_@0() If (read $2_@0) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [2] Const mutate $3_@1 = read $2_@0 + [2] Const mutate $3_@1[0:3] = read $2_@0 Goto bb1 bb3: predecessor blocks: bb0 - [3] Const mutate $3_@1 = Call mutate g$4_@1() + [3] Const mutate $3_@1[0:3] = Call mutate g$4_@1() Goto bb1 bb1: predecessor blocks: bb2 bb3 @@ -111,19 +111,19 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate $2_@0 = Call mutate f$1_@0() + [1] Const mutate $2_@0[0:1] = Call mutate f$1_@0() "] bb0_instrs --> bb0_terminal(["If (read $2_@0)"]) end subgraph bb2 bb2_instrs[" - [2] Const mutate $3_@1 = read $2_@0 + [2] Const mutate $3_@1[0:3] = read $2_@0 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [3] Const mutate $3_@1 = Call mutate g$4_@1() + [3] Const mutate $3_@1[0:3] = Call mutate g$4_@1() "] bb3_instrs --> bb3_terminal(["Goto"]) end @@ -155,17 +155,17 @@ function Or$0() { ``` bb0: - [1] Const mutate $3_@0 = Call mutate f$2_@0() + [1] Const mutate $3_@0[0:1] = Call mutate f$2_@0() [2] Const mutate $4_@1 = null [3] Const mutate $5_@2 = Binary read $3_@0 != read $4_@1 If (read $5_@2) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [4] Const mutate $6_@3 = read $3_@0 + [4] Const mutate $6_@3[0:5] = read $3_@0 Goto bb1 bb3: predecessor blocks: bb0 - [5] Const mutate $6_@3 = Call mutate g$7_@3() + [5] Const mutate $6_@3[0:5] = Call mutate g$7_@3() Goto bb1 bb1: predecessor blocks: bb2 bb3 @@ -179,7 +179,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate $3_@0 = Call mutate f$2_@0() + [1] Const mutate $3_@0[0:1] = Call mutate f$2_@0() [2] Const mutate $4_@1 = null [3] Const mutate $5_@2 = Binary read $3_@0 != read $4_@1 "] @@ -187,13 +187,13 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [4] Const mutate $6_@3 = read $3_@0 + [4] Const mutate $6_@3[0:5] = read $3_@0 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [5] Const mutate $6_@3 = Call mutate g$7_@3() + [5] Const mutate $6_@3[0:5] = Call mutate g$7_@3() "] bb3_instrs --> bb3_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md b/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md index fa3dc0e3a1..b575a7d3d8 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md @@ -99,10 +99,10 @@ function cond$0(x$1) { ``` bb0: - [1] Let mutate a$2_@0 = Object { } - [2] Let mutate b$3_@0 = Object { } - [3] Let mutate c$4_@1 = Object { } - [4] Let mutate d$5_@0 = Object { } + [1] Let mutate a$2_@0[0:14] = Object { } + [2] Let mutate b$3_@0[0:14] = Object { } + [3] Let mutate c$4_@1[0:9] = Object { } + [4] Let mutate d$5_@0[0:14] = Object { } While test=bb1 loop=bb3 fallthrough=bb2 bb1: predecessor blocks: bb0 bb4 @@ -111,12 +111,12 @@ bb1: bb3: predecessor blocks: bb1 [6] Let mutate z$6_@3 = read a$2_@0 - [7] Reassign mutate a$2_@0[7:12] = read b$3_@0 - [8] Reassign mutate b$3_@0[8:11] = read c$4_@1 - [9] Reassign mutate c$4_@1 = read d$5_@0 - [10] Reassign mutate d$5_@0 = read z$6_@3 + [7] Reassign mutate a$2_@0[0:14] = read b$3_@0 + [8] Reassign mutate b$3_@0[0:14] = read c$4_@1 + [9] Reassign mutate c$4_@1[0:9] = read d$5_@0 + [10] Reassign mutate d$5_@0[0:14] = read z$6_@3 [11] Call mutate mutate$7_@0(mutate a$2_@0, mutate b$3_@0) - [12] Const mutate $9_@0 = Call mutate cond$8_@0(mutate a$2_@0) + [12] Const mutate $9_@0[0:14] = Call mutate cond$8_@0(mutate a$2_@0) If (read $9_@0) then:bb2 else:bb4 bb4: predecessor blocks: bb3 @@ -147,10 +147,10 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate a$2_@0 = Object { } - [2] Let mutate b$3_@0 = Object { } - [3] Let mutate c$4_@1 = Object { } - [4] Let mutate d$5_@0 = Object { } + [1] Let mutate a$2_@0[0:14] = Object { } + [2] Let mutate b$3_@0[0:14] = Object { } + [3] Let mutate c$4_@1[0:9] = Object { } + [4] Let mutate d$5_@0[0:14] = Object { } "] bb0_instrs --> bb0_terminal(["While"]) end @@ -163,12 +163,12 @@ flowchart TB subgraph bb3 bb3_instrs[" [6] Let mutate z$6_@3 = read a$2_@0 - [7] Reassign mutate a$2_@0[7:12] = read b$3_@0 - [8] Reassign mutate b$3_@0[8:11] = read c$4_@1 - [9] Reassign mutate c$4_@1 = read d$5_@0 - [10] Reassign mutate d$5_@0 = read z$6_@3 + [7] Reassign mutate a$2_@0[0:14] = read b$3_@0 + [8] Reassign mutate b$3_@0[0:14] = read c$4_@1 + [9] Reassign mutate c$4_@1[0:9] = read d$5_@0 + [10] Reassign mutate d$5_@0[0:14] = read z$6_@3 [11] Call mutate mutate$7_@0(mutate a$2_@0, mutate b$3_@0) - [12] Const mutate $9_@0 = Call mutate cond$8_@0(mutate a$2_@0) + [12] Const mutate $9_@0[0:14] = Call mutate cond$8_@0(mutate a$2_@0) "] bb3_instrs --> bb3_terminal(["If (read $9_@0)"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md b/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md index 17edc95bcb..08ef4d0d70 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md @@ -70,10 +70,10 @@ bb0: [1] Const mutate a$2_@0 = Object { } [2] Const mutate b$3_@1 = Array [read a$2_@0] [3] Const mutate c$4_@2 = Object { } - [4] Const mutate d$5_@3[4:7] = Object { c: read c$4_@2 } - [5] Const mutate x$6_@3[5:9] = Object { } - [6] Reassign mutate x$6_@3.b[5:9] = read b$3_@1 - [7] Const mutate y$7_@3 = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3) + [4] Const mutate d$5_@3[0:9] = Object { c: read c$4_@2 } + [5] Const mutate x$6_@3[0:9] = Object { } + [6] Reassign mutate x$6_@3.b[0:9] = read b$3_@1 + [7] Const mutate y$7_@3[0:9] = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3) If (read a$2_@0) then:bb1 else:bb1 bb1: predecessor blocks: bb0 @@ -104,10 +104,10 @@ flowchart TB [1] Const mutate a$2_@0 = Object { } [2] Const mutate b$3_@1 = Array [read a$2_@0] [3] Const mutate c$4_@2 = Object { } - [4] Const mutate d$5_@3[4:7] = Object { c: read c$4_@2 } - [5] Const mutate x$6_@3[5:9] = Object { } - [6] Reassign mutate x$6_@3.b[5:9] = read b$3_@1 - [7] Const mutate y$7_@3 = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3) + [4] Const mutate d$5_@3[0:9] = Object { c: read c$4_@2 } + [5] Const mutate x$6_@3[0:9] = Object { } + [6] Reassign mutate x$6_@3.b[0:9] = read b$3_@1 + [7] Const mutate y$7_@3[0:9] = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3) "] bb0_instrs --> bb0_terminal(["If (read a$2_@0)"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md b/compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md index f44edb3295..c507918163 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md @@ -94,10 +94,10 @@ function cond$0() { ``` bb0: - [1] Let mutate a$2_@0[1:7] = Object { } - [2] Let mutate b$3_@0[2:6] = Object { } + [1] Let mutate a$2_@0[0:9] = Object { } + [2] Let mutate b$3_@0[0:9] = Object { } [3] Let mutate c$4_@1 = Object { } - [4] Let mutate d$5_@0[4:9] = Object { } + [4] Let mutate d$5_@0[0:9] = Object { } While test=bb1 loop=bb3 fallthrough=bb2 bb1: predecessor blocks: bb0 bb4 @@ -106,7 +106,7 @@ bb1: bb3: predecessor blocks: bb1 [6] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0) - [7] Const mutate $8_@0 = Call mutate cond$7_@0(mutate a$2_@0) + [7] Const mutate $8_@0[0:9] = Call mutate cond$7_@0(mutate a$2_@0) If (read $8_@0) then:bb2 else:bb4 bb4: predecessor blocks: bb3 @@ -137,10 +137,10 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate a$2_@0[1:7] = Object { } - [2] Let mutate b$3_@0[2:6] = Object { } + [1] Let mutate a$2_@0[0:9] = Object { } + [2] Let mutate b$3_@0[0:9] = Object { } [3] Let mutate c$4_@1 = Object { } - [4] Let mutate d$5_@0[4:9] = Object { } + [4] Let mutate d$5_@0[0:9] = Object { } "] bb0_instrs --> bb0_terminal(["While"]) end @@ -153,7 +153,7 @@ flowchart TB subgraph bb3 bb3_instrs[" [6] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0) - [7] Const mutate $8_@0 = Call mutate cond$7_@0(mutate a$2_@0) + [7] Const mutate $8_@0[0:9] = Call mutate cond$7_@0(mutate a$2_@0) "] bb3_instrs --> bb3_terminal(["If (read $8_@0)"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/reactive-scope-grouping.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reactive-scope-grouping.expect.md index 7864105d7b..ec77ba9396 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reactive-scope-grouping.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reactive-scope-grouping.expect.md @@ -20,7 +20,7 @@ function foo() { bb0: [1] Let mutate x$1_@0[1:5] = Object { } [2] Let mutate y$2_@1[2:4] = Array [] - [3] Let mutate z$3_@1[3:4] = Object { } + [3] Let mutate z$3_@1[2:4] = Object { } [4] Call mutate y$2_@1.push(mutate z$3_@1) [5] Reassign mutate x$1_@0.y[1:5] = read y$2_@1 Return freeze x$1_@0 @@ -35,7 +35,7 @@ flowchart TB bb0_instrs[" [1] Let mutate x$1_@0[1:5] = Object { } [2] Let mutate y$2_@1[2:4] = Array [] - [3] Let mutate z$3_@1[3:4] = Object { } + [3] Let mutate z$3_@1[2:4] = Object { } [4] Call mutate y$2_@1.push(mutate z$3_@1) [5] Reassign mutate x$1_@0.y[1:5] = read y$2_@1 "] diff --git a/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md index b1e9e0ce19..ccd4b3dcfc 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md @@ -23,13 +23,13 @@ function Component(props) { ``` bb0: - [1] Let mutate x$2_@0[1:2] = Array [] + [1] Let mutate x$2_@0[1:4] = Array [] [2] Call mutate x$2_@0.push(read props$1.p0) [3] Let mutate y$3_@1 = read x$2_@0 If (read props$1.p1) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [4] Reassign mutate x$2_@0 = Array [] + [4] Reassign mutate x$2_@0[1:4] = Array [] Goto bb1 bb1: predecessor blocks: bb2 bb0 @@ -46,7 +46,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$2_@0[1:2] = Array [] + [1] Let mutate x$2_@0[1:4] = Array [] [2] Call mutate x$2_@0.push(read props$1.p0) [3] Let mutate y$3_@1 = read x$2_@0 "] @@ -54,7 +54,7 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [4] Reassign mutate x$2_@0 = Array [] + [4] Reassign mutate x$2_@0[1:4] = Array [] "] bb2_instrs --> bb2_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md index c09610bbce..2c2bb901a5 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md @@ -50,26 +50,26 @@ bb2: Default: bb4 bb8: predecessor blocks: bb2 - [5] Reassign mutate x$2_@4 = read props$1.v0 + [5] Reassign mutate x$2_@4[5:9] = read props$1.v0 Goto bb1 bb6: predecessor blocks: bb2 - [6] Reassign mutate x$2_@4 = read props$1.v1 + [6] Reassign mutate x$2_@4[5:9] = read props$1.v1 Goto bb1 bb4: predecessor blocks: bb2 - [7] Reassign mutate x$2_@4 = read props$1.v2 + [7] Reassign mutate x$2_@4[5:9] = read props$1.v2 Goto bb1 bb10: predecessor blocks: bb0 If (read props$1.cond2) then:bb12 else:bb13 bb12: predecessor blocks: bb10 - [8] Reassign mutate x$2_@4 = read props$1.b + [8] Reassign mutate x$2_@4[5:9] = read props$1.b Goto bb1 bb13: predecessor blocks: bb10 - [9] Reassign mutate x$2_@4 = read props$1.c + [9] Reassign mutate x$2_@4[5:9] = read props$1.c Goto bb1 bb1: predecessor blocks: bb8 bb6 bb4 bb12 bb13 @@ -98,19 +98,19 @@ flowchart TB end subgraph bb8 bb8_instrs[" - [5] Reassign mutate x$2_@4 = read props$1.v0 + [5] Reassign mutate x$2_@4[5:9] = read props$1.v0 "] bb8_instrs --> bb8_terminal(["Goto"]) end subgraph bb6 bb6_instrs[" - [6] Reassign mutate x$2_@4 = read props$1.v1 + [6] Reassign mutate x$2_@4[5:9] = read props$1.v1 "] bb6_instrs --> bb6_terminal(["Goto"]) end subgraph bb4 bb4_instrs[" - [7] Reassign mutate x$2_@4 = read props$1.v2 + [7] Reassign mutate x$2_@4[5:9] = read props$1.v2 "] bb4_instrs --> bb4_terminal(["Goto"]) end @@ -119,13 +119,13 @@ flowchart TB end subgraph bb12 bb12_instrs[" - [8] Reassign mutate x$2_@4 = read props$1.b + [8] Reassign mutate x$2_@4[5:9] = read props$1.b "] bb12_instrs --> bb12_terminal(["Goto"]) end subgraph bb13 bb13_instrs[" - [9] Reassign mutate x$2_@4 = read props$1.c + [9] Reassign mutate x$2_@4[5:9] = read props$1.c "] bb13_instrs --> bb13_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md index 3427e0efd4..507d15cbde 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md @@ -50,10 +50,10 @@ function foo$0() { ``` bb0: - [1] Const mutate a$2_@0[1:3] = Array [] - [2] Const mutate b$3_@0[2:7] = Object { } + [1] Const mutate a$2_@0[0:7] = Array [] + [2] Const mutate b$3_@0[0:7] = Object { } [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0) - [4] Const mutate $7_@0 = Call mutate foo$4_@0() + [4] Const mutate $7_@0[0:7] = Call mutate foo$4_@0() If (read $7_@0) then:bb2 else:bb1 bb2: predecessor blocks: bb0 @@ -75,10 +75,10 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:3] = Array [] - [2] Const mutate b$3_@0[2:7] = Object { } + [1] Const mutate a$2_@0[0:7] = Array [] + [2] Const mutate b$3_@0[0:7] = Object { } [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0) - [4] Const mutate $7_@0 = Call mutate foo$4_@0() + [4] Const mutate $7_@0[0:7] = Call mutate foo$4_@0() "] bb0_instrs --> bb0_terminal(["If (read $7_@0)"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md index 285a805d1a..beac169a6b 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md @@ -47,8 +47,8 @@ function foo$0() { ``` bb0: - [1] Const mutate a$2_@0[1:3] = Array [] - [2] Const mutate b$3_@0[2:6] = Object { } + [1] Const mutate a$2_@0[0:6] = Array [] + [2] Const mutate b$3_@0[0:6] = Object { } [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0) [4] Const mutate $6_@1 = "div" [5] Let mutate _$5_@2 = JSX @@ -65,8 +65,8 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:3] = Array [] - [2] Const mutate b$3_@0[2:6] = Object { } + [1] Const mutate a$2_@0[0:6] = Array [] + [2] Const mutate b$3_@0[0:6] = Object { } [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0) [4] Const mutate $6_@1 = 'div' [5] Let mutate _$5_@2 = JSX diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md index 4807737597..401618fad1 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md @@ -21,14 +21,14 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0 = 1 + [1] Let mutate x$1_@0[1:8] = 1 [2] Let mutate y$2_@1 = 2 [3] Const mutate $3_@2 = 2 [4] Const mutate $4_@3 = Binary read y$2_@1 === read $3_@2 If (read $4_@3) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [5] Reassign mutate x$1_@0 = 3 + [5] Reassign mutate x$1_@0[1:8] = 3 Goto bb1 bb1: predecessor blocks: bb2 bb0 @@ -37,7 +37,7 @@ bb1: If (read $6_@5) then:bb4 else:bb3 bb4: predecessor blocks: bb1 - [8] Reassign mutate x$1_@0 = 5 + [8] Reassign mutate x$1_@0[1:8] = 5 Goto bb3 bb3: predecessor blocks: bb4 bb1 @@ -52,7 +52,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0 = 1 + [1] Let mutate x$1_@0[1:8] = 1 [2] Let mutate y$2_@1 = 2 [3] Const mutate $3_@2 = 2 [4] Const mutate $4_@3 = Binary read y$2_@1 === read $3_@2 @@ -61,7 +61,7 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [5] Reassign mutate x$1_@0 = 3 + [5] Reassign mutate x$1_@0[1:8] = 3 "] bb2_instrs --> bb2_terminal(["Goto"]) end @@ -74,7 +74,7 @@ flowchart TB end subgraph bb4 bb4_instrs[" - [8] Reassign mutate x$1_@0 = 5 + [8] Reassign mutate x$1_@0[1:8] = 5 "] bb4_instrs --> bb4_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md index 53af4d4f12..49bf4281f6 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md @@ -18,14 +18,14 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0 = 1 + [1] Let mutate x$1_@0[1:5] = 1 [2] Let mutate y$2_@1 = 2 [3] Const mutate $3_@2 = 2 [4] Const mutate $4_@3 = Binary read y$2_@1 === read $3_@2 If (read $4_@3) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [5] Reassign mutate x$1_@0 = 3 + [5] Reassign mutate x$1_@0[1:5] = 3 Goto bb1 bb1: predecessor blocks: bb2 bb0 @@ -40,7 +40,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0 = 1 + [1] Let mutate x$1_@0[1:5] = 1 [2] Let mutate y$2_@1 = 2 [3] Const mutate $3_@2 = 2 [4] Const mutate $4_@3 = Binary read y$2_@1 === read $3_@2 @@ -49,7 +49,7 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [5] Reassign mutate x$1_@0 = 3 + [5] Reassign mutate x$1_@0[1:5] = 3 "] bb2_instrs --> bb2_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md index d750634c9a..a3a3846dde 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md @@ -16,7 +16,7 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0 = 0 + [1] Let mutate x$1_@0[0:5] = 0 Goto bb1 bb1: predecessor blocks: bb0 bb4 @@ -26,7 +26,7 @@ bb1: bb4: predecessor blocks: bb1 [4] Const mutate $2_@3 = 1 - [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3 + [5] Reassign mutate x$1_@0[0:5] = Binary read x$1_@0 + read $2_@3 Goto(Continue) bb1 bb2: predecessor blocks: bb1 @@ -40,7 +40,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0 = 0 + [1] Let mutate x$1_@0[0:5] = 0 "] bb0_instrs --> bb0_terminal(["Goto"]) end @@ -54,7 +54,7 @@ flowchart TB subgraph bb4 bb4_instrs[" [4] Const mutate $2_@3 = 1 - [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3 + [5] Reassign mutate x$1_@0[0:5] = Binary read x$1_@0 + read $2_@3 "] bb4_instrs --> bb4_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md index 40550e4071..62e8e181bd 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md @@ -45,9 +45,9 @@ function Foo$0() { ``` bb0: - [1] Const mutate a$2_@0[1:3] = Array [] - [2] Const mutate b$3_@0[2:3] = Object { } - [3] Let mutate c$4_@0 = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0) + [1] Const mutate a$2_@0[0:3] = Array [] + [2] Const mutate b$3_@0[0:3] = Object { } + [3] Let mutate c$4_@0[0:3] = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0) Return freeze c$4_@0 ``` @@ -58,9 +58,9 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:3] = Array [] - [2] Const mutate b$3_@0[2:3] = Object { } - [3] Let mutate c$4_@0 = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0) + [1] Const mutate a$2_@0[0:3] = Array [] + [2] Const mutate b$3_@0[0:3] = Object { } + [3] Let mutate c$4_@0[0:3] = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0) "] bb0_instrs --> bb0_terminal(["Return freeze c$4_@0"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md index 4596a48ce1..eab076d40f 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md @@ -22,18 +22,18 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0 = 1 - [2] Let mutate y$2_@1 = 2 + [1] Let mutate x$1_@0[1:5] = 1 + [2] Let mutate y$2_@1[2:6] = 2 [3] Const mutate $3_@2 = 1 [4] Const mutate $4_@3 = Binary read x$1_@0 > read $3_@2 If (read $4_@3) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [5] Reassign mutate x$1_@0 = 2 + [5] Reassign mutate x$1_@0[1:5] = 2 Goto bb1 bb3: predecessor blocks: bb0 - [6] Reassign mutate y$2_@1 = 3 + [6] Reassign mutate y$2_@1[2:6] = 3 Goto bb1 bb1: predecessor blocks: bb2 bb3 @@ -48,8 +48,8 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0 = 1 - [2] Let mutate y$2_@1 = 2 + [1] Let mutate x$1_@0[1:5] = 1 + [2] Let mutate y$2_@1[2:6] = 2 [3] Const mutate $3_@2 = 1 [4] Const mutate $4_@3 = Binary read x$1_@0 > read $3_@2 "] @@ -57,13 +57,13 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [5] Reassign mutate x$1_@0 = 2 + [5] Reassign mutate x$1_@0[1:5] = 2 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [6] Reassign mutate y$2_@1 = 3 + [6] Reassign mutate y$2_@1[2:6] = 3 "] bb3_instrs --> bb3_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md index 5aefad393a..f05cb7ce88 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-property-call.expect.md @@ -17,7 +17,7 @@ function foo() { bb0: [1] Const mutate x$1_@0 = Array [] [2] Const mutate y$2_@1[2:4] = Object { x: read x$1_@0 } - [3] Const mutate $3_@1[3:4] = Array [] + [3] Const mutate $3_@1[2:4] = Array [] [4] Call mutate y$2_@1.x.push(mutate $3_@1) Return freeze y$2_@1 ``` @@ -31,7 +31,7 @@ flowchart TB bb0_instrs[" [1] Const mutate x$1_@0 = Array [] [2] Const mutate y$2_@1[2:4] = Object { x: read x$1_@0 } - [3] Const mutate $3_@1[3:4] = Array [] + [3] Const mutate $3_@1[2:4] = Array [] [4] Call mutate y$2_@1.x.push(mutate $3_@1) "] bb0_instrs --> bb0_terminal(["Return freeze y$2_@1"]) diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md index ce8558cbb9..e4831fe2dc 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md @@ -17,13 +17,13 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0 = 1 + [1] Let mutate x$1_@0[1:4] = 1 [2] Const mutate $2_@1 = 1 [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1 If (read $3_@2) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [4] Reassign mutate x$1_@0 = 2 + [4] Reassign mutate x$1_@0[1:4] = 2 Goto bb1 bb1: predecessor blocks: bb2 bb0 @@ -37,7 +37,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0 = 1 + [1] Let mutate x$1_@0[1:4] = 1 [2] Const mutate $2_@1 = 1 [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1 "] @@ -45,7 +45,7 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [4] Reassign mutate x$1_@0 = 2 + [4] Reassign mutate x$1_@0[1:4] = 2 "] bb2_instrs --> bb2_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md index 378af61469..699e72e7b2 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md @@ -49,7 +49,7 @@ function log$0() { ``` bb0: - [1] Let mutate str$2_@0 = "" + [1] Let mutate str$2_@0[1:4] = "" If (read cond$1) then:bb2 else:bb3 bb2: predecessor blocks: bb0 @@ -58,7 +58,7 @@ bb2: Goto bb1 bb3: predecessor blocks: bb0 - [4] Reassign mutate str$2_@0 = "fallthrough test" + [4] Reassign mutate str$2_@0[1:4] = "fallthrough test" Goto bb1 bb1: predecessor blocks: bb2 bb3 @@ -73,7 +73,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate str$2_@0 = '' + [1] Let mutate str$2_@0[1:4] = '' "] bb0_instrs --> bb0_terminal(["If (read cond$1)"]) end @@ -86,7 +86,7 @@ flowchart TB end subgraph bb3 bb3_instrs[" - [4] Reassign mutate str$2_@0 = 'fallthrough test' + [4] Reassign mutate str$2_@0[1:4] = 'fallthrough test' "] bb3_instrs --> bb3_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md index 030f14e678..fefd8c4465 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md @@ -26,11 +26,11 @@ bb0: If (read $3_@2) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [4] Reassign mutate y$1_@3 = 1 + [4] Reassign mutate y$1_@3[4:5] = 1 Goto bb1 bb3: predecessor blocks: bb0 - [5] Reassign mutate y$1_@3 = 2 + [5] Reassign mutate y$1_@3[4:5] = 2 Goto bb1 bb1: predecessor blocks: bb2 bb3 @@ -53,13 +53,13 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [4] Reassign mutate y$1_@3 = 1 + [4] Reassign mutate y$1_@3[4:5] = 1 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [5] Reassign mutate y$1_@3 = 2 + [5] Reassign mutate y$1_@3[4:5] = 2 "] bb3_instrs --> bb3_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md index 1713025598..a796c43905 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md @@ -40,17 +40,17 @@ bb0: bb5: predecessor blocks: bb0 [6] Const mutate $6_@5 = 1 - [7] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $6_@5 + [7] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $6_@5 Goto bb1 bb3: predecessor blocks: bb0 [8] Const mutate $3_@7 = 2 - [9] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $3_@7 + [9] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $3_@7 Goto bb1 bb2: predecessor blocks: bb0 [10] Const mutate $2_@8 = 3 - [11] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $2_@8 + [11] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $2_@8 Goto bb1 bb1: predecessor blocks: bb5 bb3 bb2 @@ -76,21 +76,21 @@ flowchart TB subgraph bb5 bb5_instrs[" [6] Const mutate $6_@5 = 1 - [7] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $6_@5 + [7] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $6_@5 "] bb5_instrs --> bb5_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" [8] Const mutate $3_@7 = 2 - [9] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $3_@7 + [9] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $3_@7 "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb2 bb2_instrs[" [10] Const mutate $2_@8 = 3 - [11] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $2_@8 + [11] Reassign mutate x$1_@6[7:11] = Binary read x$1_@0 + read $2_@8 "] bb2_instrs --> bb2_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md index 5d54773ea7..16b0784ec2 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md @@ -16,13 +16,13 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0 = 1 + [1] Let mutate x$1_@0[1:4] = 1 [2] Const mutate $2_@1 = 1 [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1 If (read $3_@2) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [4] Reassign mutate x$1_@0 = 2 + [4] Reassign mutate x$1_@0[1:4] = 2 Goto bb1 bb1: predecessor blocks: bb2 bb0 @@ -36,7 +36,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0 = 1 + [1] Let mutate x$1_@0[1:4] = 1 [2] Const mutate $2_@1 = 1 [3] Const mutate $3_@2 = Binary read x$1_@0 === read $2_@1 "] @@ -44,7 +44,7 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [4] Reassign mutate x$1_@0 = 2 + [4] Reassign mutate x$1_@0[1:4] = 2 "] bb2_instrs --> bb2_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md index 560f33325f..c16a101817 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md @@ -17,7 +17,7 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0 = 1 + [1] Let mutate x$1_@0[0:5] = 1 While test=bb1 loop=bb3 fallthrough=bb2 bb1: predecessor blocks: bb0 bb3 @@ -27,7 +27,7 @@ bb1: bb3: predecessor blocks: bb1 [4] Const mutate $2_@3 = 1 - [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3 + [5] Reassign mutate x$1_@0[0:5] = Binary read x$1_@0 + read $2_@3 Goto(Continue) bb1 bb2: predecessor blocks: bb1 @@ -41,7 +41,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0 = 1 + [1] Let mutate x$1_@0[0:5] = 1 "] bb0_instrs --> bb0_terminal(["While"]) end @@ -55,7 +55,7 @@ flowchart TB subgraph bb3 bb3_instrs[" [4] Const mutate $2_@3 = 1 - [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3 + [5] Reassign mutate x$1_@0[0:5] = Binary read x$1_@0 + read $2_@3 "] bb3_instrs --> bb3_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md b/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md index 0a860dd2f4..7a2375b0c1 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md @@ -33,7 +33,7 @@ function Component(props) { ``` bb0: [1] Let mutate x$2_@0[1:6] = Array [] - [2] Let mutate y$3_@1 = undefined + [2] Let mutate y$3_@1[2:8] = undefined [3] Const mutate $4_@2 = false [4] Const mutate $5_@3 = true [5] Const mutate $6_@4 = 1 @@ -45,11 +45,11 @@ bb0: bb6: predecessor blocks: bb0 [6] Call mutate x$2_@0.push(read props$1.p2) - [7] Reassign mutate y$3_@1 = Array [] + [7] Reassign mutate y$3_@1[2:8] = Array [] Goto bb1 bb2: predecessor blocks: bb0 - [8] Reassign mutate y$3_@1 = read x$2_@0 + [8] Reassign mutate y$3_@1[2:8] = read x$2_@0 Goto bb1 bb1: predecessor blocks: bb0 bb6 bb2 @@ -67,7 +67,7 @@ flowchart TB subgraph bb0 bb0_instrs[" [1] Let mutate x$2_@0[1:6] = Array [] - [2] Let mutate y$3_@1 = undefined + [2] Let mutate y$3_@1[2:8] = undefined [3] Const mutate $4_@2 = false [4] Const mutate $5_@3 = true [5] Const mutate $6_@4 = 1 @@ -77,13 +77,13 @@ flowchart TB subgraph bb6 bb6_instrs[" [6] Call mutate x$2_@0.push(read props$1.p2) - [7] Reassign mutate y$3_@1 = Array [] + [7] Reassign mutate y$3_@1[2:8] = Array [] "] bb6_instrs --> bb6_terminal(["Goto"]) end subgraph bb2 bb2_instrs[" - [8] Reassign mutate y$3_@1 = read x$2_@0 + [8] Reassign mutate y$3_@1[2:8] = read x$2_@0 "] bb2_instrs --> bb2_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md b/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md index 58a3ac0103..65eec56240 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md @@ -29,7 +29,7 @@ function Component(props) { ``` bb0: [1] Let mutate x$2_@0[1:6] = Array [] - [2] Let mutate y$3_@1 = undefined + [2] Let mutate y$3_@1[2:8] = undefined [3] Const mutate $4_@2 = false [4] Const mutate $5_@3 = true Switch (read props$1.p0) @@ -44,7 +44,7 @@ bb4: Goto bb2 bb2: predecessor blocks: bb4 bb0 - [8] Reassign mutate y$3_@1 = read x$2_@0 + [8] Reassign mutate y$3_@1[2:8] = read x$2_@0 Goto bb1 bb1: predecessor blocks: bb2 bb0 @@ -62,7 +62,7 @@ flowchart TB subgraph bb0 bb0_instrs[" [1] Let mutate x$2_@0[1:6] = Array [] - [2] Let mutate y$3_@1 = undefined + [2] Let mutate y$3_@1[2:8] = undefined [3] Const mutate $4_@2 = false [4] Const mutate $5_@3 = true "] @@ -78,7 +78,7 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [8] Reassign mutate y$3_@1 = read x$2_@0 + [8] Reassign mutate y$3_@1[2:8] = read x$2_@0 "] bb2_instrs --> bb2_terminal(["Goto"]) end