diff --git a/compiler/forget/src/HIR/InferReactiveScopeVariables.ts b/compiler/forget/src/HIR/InferReactiveScopeVariables.ts index f1aaaa42e2..854e765581 100644 --- a/compiler/forget/src/HIR/InferReactiveScopeVariables.ts +++ b/compiler/forget/src/HIR/InferReactiveScopeVariables.ts @@ -52,7 +52,7 @@ import { eachInstructionOperand } from "./visitors"; * * ## Other Issues Uncovered * - * 1. Mutable lifetimes need to account for aliasing. + * Mutable lifetimes need to account for aliasing (known todo, already described in InferMutableLifetimes.ts) * * ```javascript * let x = {}; @@ -60,24 +60,17 @@ import { eachInstructionOperand } from "./visitors"; * x.y = y; // RHS is not considered mutable here bc not further mutation * mutate(x); // bc y is aliased here, it should still be considered mutable above * ``` - * - * 2. Mutable lifetimes need to account for SSA reassignment. - * - * ```javascript - * // y is never considered mutable bc SSA treats subsequent assignments as distinct identifiers - * let y; - * if (cond) { - * y = ...; - * } else { - * y = ...; - * } - * ``` */ export function inferReactiveScopeVariables(fn: HIRFunction) { // Represents the set of reactive scopes as disjoint sets of identifiers // that mutate together. const scopes = new DisjointSet(); for (const [_, block] of fn.body.blocks) { + for (const phi of block.phis) { + const operands: Array = [phi.id, ...phi.operands.values()]; + scopes.union(operands); + } + for (const instr of block.instructions) { const operands: Array = []; if (instr.lvalue !== null) { diff --git a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md index fcf0d8a791..c69f71bf45 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md @@ -52,7 +52,7 @@ bb3: If (read $12_@3) then:bb8 else:bb9 bb8: predecessor blocks: bb3 - [9] Const mutate $13_@7 = read $12_@3 + [9] Const mutate $13_@3 = read $12_@3 Goto bb7 bb9: predecessor blocks: bb3 @@ -60,33 +60,33 @@ bb9: Goto bb7 bb7: predecessor blocks: bb8 bb9 - If (read $13) then:bb5 else:bb4 + If (read $13_@3) then:bb5 else:bb4 bb5: predecessor blocks: bb7 Goto(Continue) bb1 bb4: predecessor blocks: bb7 [11] Call mutate seen$5_@3.add(mutate item$10_@3) - [12] Const mutate $14_@8 = "div" - [13] Const mutate $15_@9 = JSX {read item$10_@3} - [14] Call mutate renderedItems$4_@2.push(read $15_@9) - [15] Const mutate $16_@10 = Binary read renderedItems$4_@2.length >= read max$7_@5 - If (read $16_@10) then:bb2 else:bb10 + [12] Const mutate $14_@7 = "div" + [13] Const mutate $15_@8 = JSX {read item$10_@3} + [14] Call mutate renderedItems$4_@2.push(read $15_@8) + [15] Const mutate $16_@9 = Binary read renderedItems$4_@2.length >= read max$7_@5 + If (read $16_@9) then:bb2 else:bb10 bb10: predecessor blocks: bb4 Goto(Continue) bb1 bb2: predecessor blocks: bb4 bb1 - [16] Const mutate count$17_@11 = read renderedItems$4_@2.length - [17] Const mutate $18_@12 = "div" - [18] Const mutate $19_@13 = "\n " - [19] Const mutate $20_@14 = "h1" - [20] Const mutate $21_@15 = " Items" - [21] Const mutate $22_@16 = JSX {freeze count$17_@11}{read $21_@15} - [22] Const mutate $23_@17 = "\n " - [23] Const mutate $24_@18 = "\n " - [24] Const mutate $25_@19 = JSX {read $19_@13}{read $22_@16}{read $23_@17}{freeze renderedItems$4_@2}{read $24_@18} - Return read $25_@19 + [16] Const mutate count$17_@10 = read renderedItems$4_@2.length + [17] Const mutate $18_@11 = "div" + [18] Const mutate $19_@12 = "\n " + [19] Const mutate $20_@13 = "h1" + [20] Const mutate $21_@14 = " Items" + [21] Const mutate $22_@15 = JSX {freeze count$17_@10}{read $21_@14} + [22] Const mutate $23_@16 = "\n " + [23] Const mutate $24_@17 = "\n " + [24] Const mutate $25_@18 = JSX {read $19_@12}{read $22_@15}{read $23_@16}{freeze renderedItems$4_@2}{read $24_@17} + Return read $25_@18 ``` ### CFG @@ -117,7 +117,7 @@ flowchart TB end subgraph bb8 bb8_instrs[" - [9] Const mutate $13_@7 = read $12_@3 + [9] Const mutate $13_@3 = read $12_@3 "] bb8_instrs --> bb8_terminal(["Goto"]) end @@ -128,7 +128,7 @@ flowchart TB bb9_instrs --> bb9_terminal(["Goto"]) end subgraph bb7 - bb7_terminal(["If (read $13)"]) + bb7_terminal(["If (read $13_@3)"]) end subgraph bb5 bb5_terminal(["Goto"]) @@ -136,29 +136,29 @@ flowchart TB subgraph bb4 bb4_instrs[" [11] Call mutate seen$5_@3.add(mutate item$10_@3) - [12] Const mutate $14_@8 = 'div' - [13] Const mutate $15_@9 = JSX {read item$10_@3} - [14] Call mutate renderedItems$4_@2.push(read $15_@9) - [15] Const mutate $16_@10 = Binary read renderedItems$4_@2.length >= read max$7_@5 + [12] Const mutate $14_@7 = 'div' + [13] Const mutate $15_@8 = JSX {read item$10_@3} + [14] Call mutate renderedItems$4_@2.push(read $15_@8) + [15] Const mutate $16_@9 = Binary read renderedItems$4_@2.length >= read max$7_@5 "] - bb4_instrs --> bb4_terminal(["If (read $16_@10)"]) + bb4_instrs --> bb4_terminal(["If (read $16_@9)"]) end subgraph bb10 bb10_terminal(["Goto"]) end subgraph bb2 bb2_instrs[" - [16] Const mutate count$17_@11 = read renderedItems$4_@2.length - [17] Const mutate $18_@12 = 'div' - [18] Const mutate $19_@13 = '\n ' - [19] Const mutate $20_@14 = 'h1' - [20] Const mutate $21_@15 = ' Items' - [21] Const mutate $22_@16 = JSX {freeze count$17_@11}{read $21_@15} - [22] Const mutate $23_@17 = '\n ' - [23] Const mutate $24_@18 = '\n ' - [24] Const mutate $25_@19 = JSX {read $19_@13}{read $22_@16}{read $23_@17}{freeze renderedItems$4_@2}{read $24_@18} + [16] Const mutate count$17_@10 = read renderedItems$4_@2.length + [17] Const mutate $18_@11 = 'div' + [18] Const mutate $19_@12 = '\n ' + [19] Const mutate $20_@13 = 'h1' + [20] Const mutate $21_@14 = ' Items' + [21] Const mutate $22_@15 = JSX {freeze count$17_@10}{read $21_@14} + [22] Const mutate $23_@16 = '\n ' + [23] Const mutate $24_@17 = '\n ' + [24] Const mutate $25_@18 = JSX {read $19_@12}{read $22_@15}{read $23_@16}{freeze renderedItems$4_@2}{read $24_@17} "] - bb2_instrs --> bb2_terminal(["Return read $25_@19"]) + bb2_instrs --> bb2_terminal(["Return read $25_@18"]) end %% Jumps 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 5f92a7f196..a71f744317 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 @@ -36,14 +36,14 @@ bb2: Goto bb1 bb3: predecessor blocks: bb0 - [5] Reassign mutate a$4_@4 = Array [] + [5] Reassign mutate a$4_@3 = Array [] Goto bb1 bb1: predecessor blocks: bb2 bb3 - [6] Call read useFreeze$5(freeze a$4) - [7] Call read useFreeze$5(read a$4) - [8] Call mutate call$6_@5(read a$4) - Return read a$4 + [6] Call read useFreeze$5(freeze a$4_@3) + [7] Call read useFreeze$5(read a$4_@3) + [8] Call mutate call$6_@4(read a$4_@3) + Return read a$4_@3 ``` ### CFG @@ -67,17 +67,17 @@ flowchart TB end subgraph bb3 bb3_instrs[" - [5] Reassign mutate a$4_@4 = Array [] + [5] Reassign mutate a$4_@3 = Array [] "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [6] Call read useFreeze$5(freeze a$4) - [7] Call read useFreeze$5(read a$4) - [8] Call mutate call$6_@5(read a$4) + [6] Call read useFreeze$5(freeze a$4_@3) + [7] Call read useFreeze$5(read a$4_@3) + [8] Call mutate call$6_@4(read a$4_@3) "] - bb1_instrs --> bb1_terminal(["Return read a$4"]) + bb1_instrs --> bb1_terminal(["Return read a$4_@3"]) end %% Jumps 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 f1e37de67a..a59714410a 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md @@ -31,11 +31,11 @@ bb2: Goto bb1 bb3: predecessor blocks: bb0 - [3] Const mutate $3_@2 = read $2_@0 + [3] Const mutate $3_@1 = read $2_@0 Goto bb1 bb1: predecessor blocks: bb2 bb3 - Return freeze $3 + Return freeze $3_@1 ``` ### CFG @@ -57,12 +57,12 @@ flowchart TB end subgraph bb3 bb3_instrs[" - [3] Const mutate $3_@2 = read $2_@0 + [3] Const mutate $3_@1 = read $2_@0 "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb1 - bb1_terminal(["Return freeze $3"]) + bb1_terminal(["Return freeze $3_@1"]) end %% Jumps @@ -97,11 +97,11 @@ bb2: Goto bb1 bb3: predecessor blocks: bb0 - [3] Const mutate $3_@2 = Call mutate g$4_@2() + [3] Const mutate $3_@1 = Call mutate g$4_@1() Goto bb1 bb1: predecessor blocks: bb2 bb3 - Return freeze $3 + Return freeze $3_@1 ``` ### CFG @@ -123,12 +123,12 @@ flowchart TB end subgraph bb3 bb3_instrs[" - [3] Const mutate $3_@2 = Call mutate g$4_@2() + [3] Const mutate $3_@1 = Call mutate g$4_@1() "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb1 - bb1_terminal(["Return freeze $3"]) + bb1_terminal(["Return freeze $3_@1"]) end %% Jumps @@ -165,11 +165,11 @@ bb2: Goto bb1 bb3: predecessor blocks: bb0 - [5] Const mutate $6_@4 = Call mutate g$7_@4() + [5] Const mutate $6_@3 = Call mutate g$7_@3() Goto bb1 bb1: predecessor blocks: bb2 bb3 - Return freeze $6 + Return freeze $6_@3 ``` ### CFG @@ -193,12 +193,12 @@ flowchart TB end subgraph bb3 bb3_instrs[" - [5] Const mutate $6_@4 = Call mutate g$7_@4() + [5] Const mutate $6_@3 = Call mutate g$7_@3() "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb1 - bb1_terminal(["Return freeze $6"]) + bb1_terminal(["Return freeze $6_@3"]) end %% Jumps 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 a8d6b557a1..fa3dc0e3a1 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 @@ -100,43 +100,43 @@ function cond$0(x$1) { ``` bb0: [1] Let mutate a$2_@0 = Object { } - [2] Let mutate b$3_@1 = Object { } - [3] Let mutate c$4_@2 = Object { } - [4] Let mutate d$5_@3 = Object { } + [2] Let mutate b$3_@0 = Object { } + [3] Let mutate c$4_@1 = Object { } + [4] Let mutate d$5_@0 = Object { } While test=bb1 loop=bb3 fallthrough=bb2 bb1: predecessor blocks: bb0 bb4 - [5] Const mutate $10_@4 = true - If (read $10_@4) then:bb3 else:bb2 + [5] Const mutate $10_@2 = true + If (read $10_@2) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - [6] Let mutate z$6_@5 = read a$2 - [7] Reassign mutate a$2_@6[7:12] = read b$3 - [8] Reassign mutate b$3_@6[8:11] = read c$4 - [9] Reassign mutate c$4_@7 = read d$5 - [10] Reassign mutate d$5_@8 = read z$6_@5 - [11] Call mutate mutate$7_@6(mutate a$2_@6, mutate b$3_@6) - [12] Const mutate $9_@6 = Call mutate cond$8_@6(mutate a$2_@6) - If (read $9_@6) then:bb2 else:bb4 + [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 + [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) + If (read $9_@0) then:bb2 else:bb4 bb4: predecessor blocks: bb3 Goto(Continue) bb1 bb2: predecessor blocks: bb3 bb1 - If (read a$2) then:bb7 else:bb7 + If (read a$2_@0) then:bb7 else:bb7 bb7: predecessor blocks: bb2 - If (read b$3) then:bb9 else:bb9 + If (read b$3_@0) then:bb9 else:bb9 bb9: predecessor blocks: bb7 - If (read c$4) then:bb11 else:bb11 + If (read c$4_@1) then:bb11 else:bb11 bb11: predecessor blocks: bb9 - If (read d$5_@6) then:bb13 else:bb13 + If (read d$5_@0) then:bb13 else:bb13 bb13: predecessor blocks: bb11 - [13] Const mutate $11_@9 = null - [14] Call mutate mutate$7_@6(mutate d$5_@6, read $11_@9) + [13] Const mutate $11_@4 = null + [14] Call mutate mutate$7_@0(mutate d$5_@0, read $11_@4) Return ``` @@ -148,49 +148,49 @@ flowchart TB subgraph bb0 bb0_instrs[" [1] Let mutate a$2_@0 = Object { } - [2] Let mutate b$3_@1 = Object { } - [3] Let mutate c$4_@2 = Object { } - [4] Let mutate d$5_@3 = Object { } + [2] Let mutate b$3_@0 = Object { } + [3] Let mutate c$4_@1 = Object { } + [4] Let mutate d$5_@0 = Object { } "] bb0_instrs --> bb0_terminal(["While"]) end subgraph bb1 bb1_instrs[" - [5] Const mutate $10_@4 = true + [5] Const mutate $10_@2 = true "] - bb1_instrs --> bb1_terminal(["If (read $10_@4)"]) + bb1_instrs --> bb1_terminal(["If (read $10_@2)"]) end subgraph bb3 bb3_instrs[" - [6] Let mutate z$6_@5 = read a$2 - [7] Reassign mutate a$2_@6[7:12] = read b$3 - [8] Reassign mutate b$3_@6[8:11] = read c$4 - [9] Reassign mutate c$4_@7 = read d$5 - [10] Reassign mutate d$5_@8 = read z$6_@5 - [11] Call mutate mutate$7_@6(mutate a$2_@6, mutate b$3_@6) - [12] Const mutate $9_@6 = Call mutate cond$8_@6(mutate a$2_@6) + [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 + [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) "] - bb3_instrs --> bb3_terminal(["If (read $9_@6)"]) + bb3_instrs --> bb3_terminal(["If (read $9_@0)"]) end subgraph bb4 bb4_terminal(["Goto"]) end subgraph bb2 - bb2_terminal(["If (read a$2)"]) + bb2_terminal(["If (read a$2_@0)"]) end subgraph bb7 - bb7_terminal(["If (read b$3)"]) + bb7_terminal(["If (read b$3_@0)"]) end subgraph bb9 - bb9_terminal(["If (read c$4)"]) + bb9_terminal(["If (read c$4_@1)"]) end subgraph bb11 - bb11_terminal(["If (read d$5_@6)"]) + bb11_terminal(["If (read d$5_@0)"]) end subgraph bb13 bb13_instrs[" - [13] Const mutate $11_@9 = null - [14] Call mutate mutate$7_@6(mutate d$5_@6, read $11_@9) + [13] Const mutate $11_@4 = null + [14] Call mutate mutate$7_@0(mutate d$5_@0, read $11_@4) "] bb13_instrs --> bb13_terminal(["Return"]) end 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 d58654d306..b1e9e0ce19 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md @@ -29,14 +29,14 @@ bb0: If (read props$1.p1) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [4] Reassign mutate x$2_@2 = Array [] + [4] Reassign mutate x$2_@0 = Array [] Goto bb1 bb1: predecessor blocks: bb2 bb0 - [5] Let mutate _$4_@3 = JSX + [5] Let mutate _$4_@2 = JSX [6] Call read y$3_@1.push(read props$1.p2) - [7] Const mutate $5_@4 = JSX - Return read $5_@4 + [7] Const mutate $5_@3 = JSX + Return read $5_@3 ``` ### CFG @@ -54,17 +54,17 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [4] Reassign mutate x$2_@2 = Array [] + [4] Reassign mutate x$2_@0 = Array [] "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [5] Let mutate _$4_@3 = JSX + [5] Let mutate _$4_@2 = JSX [6] Call read y$3_@1.push(read props$1.p2) - [7] Const mutate $5_@4 = JSX + [7] Const mutate $5_@3 = JSX "] - bb1_instrs --> bb1_terminal(["Return read $5_@4"]) + bb1_instrs --> bb1_terminal(["Return read $5_@3"]) end %% Jumps 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 ddac8203b2..c09610bbce 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md @@ -54,26 +54,26 @@ bb8: Goto bb1 bb6: predecessor blocks: bb2 - [6] Reassign mutate x$2_@5 = read props$1.v1 + [6] Reassign mutate x$2_@4 = read props$1.v1 Goto bb1 bb4: predecessor blocks: bb2 - [7] Reassign mutate x$2_@6 = read props$1.v2 + [7] Reassign mutate x$2_@4 = 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_@7 = read props$1.b + [8] Reassign mutate x$2_@4 = read props$1.b Goto bb1 bb13: predecessor blocks: bb10 - [9] Reassign mutate x$2_@8 = read props$1.c + [9] Reassign mutate x$2_@4 = read props$1.c Goto bb1 bb1: predecessor blocks: bb8 bb6 bb4 bb12 bb13 - [10] read x$2 + [10] read x$2_@4 Return ``` @@ -104,13 +104,13 @@ flowchart TB end subgraph bb6 bb6_instrs[" - [6] Reassign mutate x$2_@5 = read props$1.v1 + [6] Reassign mutate x$2_@4 = read props$1.v1 "] bb6_instrs --> bb6_terminal(["Goto"]) end subgraph bb4 bb4_instrs[" - [7] Reassign mutate x$2_@6 = read props$1.v2 + [7] Reassign mutate x$2_@4 = read props$1.v2 "] bb4_instrs --> bb4_terminal(["Goto"]) end @@ -119,19 +119,19 @@ flowchart TB end subgraph bb12 bb12_instrs[" - [8] Reassign mutate x$2_@7 = read props$1.b + [8] Reassign mutate x$2_@4 = read props$1.b "] bb12_instrs --> bb12_terminal(["Goto"]) end subgraph bb13 bb13_instrs[" - [9] Reassign mutate x$2_@8 = read props$1.c + [9] Reassign mutate x$2_@4 = read props$1.c "] bb13_instrs --> bb13_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [10] read x$2 + [10] read x$2_@4 "] bb1_instrs --> bb1_terminal(["Return"]) end 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 7db6d70a6c..4807737597 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 @@ -28,20 +28,20 @@ bb0: If (read $4_@3) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [5] Reassign mutate x$1_@4 = 3 + [5] Reassign mutate x$1_@0 = 3 Goto bb1 bb1: predecessor blocks: bb2 bb0 - [6] Const mutate $5_@5 = 3 - [7] Const mutate $6_@6 = Binary read y$2_@1 === read $5_@5 - If (read $6_@6) then:bb4 else:bb3 + [6] Const mutate $5_@4 = 3 + [7] Const mutate $6_@5 = Binary read y$2_@1 === read $5_@4 + If (read $6_@5) then:bb4 else:bb3 bb4: predecessor blocks: bb1 - [8] Reassign mutate x$1_@7 = 5 + [8] Reassign mutate x$1_@0 = 5 Goto bb3 bb3: predecessor blocks: bb4 bb1 - [9] Reassign mutate y$2_@8 = read x$1 + [9] Reassign mutate y$2_@6 = read x$1_@0 Return ``` @@ -61,26 +61,26 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [5] Reassign mutate x$1_@4 = 3 + [5] Reassign mutate x$1_@0 = 3 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [6] Const mutate $5_@5 = 3 - [7] Const mutate $6_@6 = Binary read y$2_@1 === read $5_@5 + [6] Const mutate $5_@4 = 3 + [7] Const mutate $6_@5 = Binary read y$2_@1 === read $5_@4 "] - bb1_instrs --> bb1_terminal(["If (read $6_@6)"]) + bb1_instrs --> bb1_terminal(["If (read $6_@5)"]) end subgraph bb4 bb4_instrs[" - [8] Reassign mutate x$1_@7 = 5 + [8] Reassign mutate x$1_@0 = 5 "] bb4_instrs --> bb4_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [9] Reassign mutate y$2_@8 = read x$1 + [9] Reassign mutate y$2_@6 = read x$1_@0 "] bb3_instrs --> bb3_terminal(["Return"]) 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 567d4d1781..53af4d4f12 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 @@ -25,11 +25,11 @@ bb0: If (read $4_@3) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [5] Reassign mutate x$1_@4 = 3 + [5] Reassign mutate x$1_@0 = 3 Goto bb1 bb1: predecessor blocks: bb2 bb0 - [6] Reassign mutate y$2_@5 = read x$1 + [6] Reassign mutate y$2_@4 = read x$1_@0 Return ``` @@ -49,13 +49,13 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [5] Reassign mutate x$1_@4 = 3 + [5] Reassign mutate x$1_@0 = 3 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [6] Reassign mutate y$2_@5 = read x$1 + [6] Reassign mutate y$2_@4 = read x$1_@0 "] bb1_instrs --> bb1_terminal(["Return"]) 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 484fadebd0..d750634c9a 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md @@ -21,16 +21,16 @@ bb0: bb1: predecessor blocks: bb0 bb4 [2] Const mutate $3_@1 = 10 - [3] Const mutate $4_@2 = Binary read x$1 < read $3_@1 + [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 If (read $4_@2) then:bb4 else:bb2 bb4: predecessor blocks: bb1 [4] Const mutate $2_@3 = 1 - [5] Reassign mutate x$1_@4 = Binary read x$1 + read $2_@3 + [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3 Goto(Continue) bb1 bb2: predecessor blocks: bb1 - Return read x$1 + Return read x$1_@0 ``` ### CFG @@ -47,19 +47,19 @@ flowchart TB subgraph bb1 bb1_instrs[" [2] Const mutate $3_@1 = 10 - [3] Const mutate $4_@2 = Binary read x$1 < read $3_@1 + [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 "] bb1_instrs --> bb1_terminal(["If (read $4_@2)"]) end subgraph bb4 bb4_instrs[" [4] Const mutate $2_@3 = 1 - [5] Reassign mutate x$1_@4 = Binary read x$1 + read $2_@3 + [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3 "] bb4_instrs --> bb4_terminal(["Goto"]) end subgraph bb2 - bb2_terminal(["Return read x$1"]) + bb2_terminal(["Return read x$1_@0"]) end %% Jumps 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 3ae6199c5b..4596a48ce1 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 @@ -29,16 +29,16 @@ bb0: If (read $4_@3) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [5] Reassign mutate x$1_@4 = 2 + [5] Reassign mutate x$1_@0 = 2 Goto bb1 bb3: predecessor blocks: bb0 - [6] Reassign mutate y$2_@5 = 3 + [6] Reassign mutate y$2_@1 = 3 Goto bb1 bb1: predecessor blocks: bb2 bb3 - [7] Let mutate t$5_@6 = Object { x: read x$1, y: read y$2 } - Return freeze t$5_@6 + [7] Let mutate t$5_@4 = Object { x: read x$1_@0, y: read y$2_@1 } + Return freeze t$5_@4 ``` ### CFG @@ -57,21 +57,21 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [5] Reassign mutate x$1_@4 = 2 + [5] Reassign mutate x$1_@0 = 2 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [6] Reassign mutate y$2_@5 = 3 + [6] Reassign mutate y$2_@1 = 3 "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [7] Let mutate t$5_@6 = Object { x: read x$1, y: read y$2 } + [7] Let mutate t$5_@4 = Object { x: read x$1_@0, y: read y$2_@1 } "] - bb1_instrs --> bb1_terminal(["Return freeze t$5_@6"]) + bb1_instrs --> bb1_terminal(["Return freeze t$5_@4"]) end %% Jumps 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 24899b88b8..ce8558cbb9 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md @@ -23,11 +23,11 @@ bb0: If (read $3_@2) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [4] Reassign mutate x$1_@3 = 2 + [4] Reassign mutate x$1_@0 = 2 Goto bb1 bb1: predecessor blocks: bb2 bb0 - Return read x$1 + Return read x$1_@0 ``` ### CFG @@ -45,12 +45,12 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [4] Reassign mutate x$1_@3 = 2 + [4] Reassign mutate x$1_@0 = 2 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 - bb1_terminal(["Return read x$1"]) + bb1_terminal(["Return read x$1_@0"]) end %% Jumps 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 884c435033..378af61469 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md @@ -58,11 +58,11 @@ bb2: Goto bb1 bb3: predecessor blocks: bb0 - [4] Reassign mutate str$2_@3 = "fallthrough test" + [4] Reassign mutate str$2_@0 = "fallthrough test" Goto bb1 bb1: predecessor blocks: bb2 bb3 - [5] Call mutate log$4_@2(read str$2) + [5] Call mutate log$4_@2(read str$2_@0) Return ``` @@ -86,13 +86,13 @@ flowchart TB end subgraph bb3 bb3_instrs[" - [4] Reassign mutate str$2_@3 = 'fallthrough test' + [4] Reassign mutate str$2_@0 = 'fallthrough test' "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [5] Call mutate log$4_@2(read str$2) + [5] Call mutate log$4_@2(read str$2_@0) "] bb1_instrs --> bb1_terminal(["Return"]) 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 8bf4a1c3ec..030f14e678 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 @@ -30,11 +30,11 @@ bb2: Goto bb1 bb3: predecessor blocks: bb0 - [5] Reassign mutate y$1_@4 = 2 + [5] Reassign mutate y$1_@3 = 2 Goto bb1 bb1: predecessor blocks: bb2 bb3 - [6] Let mutate x$4_@5 = read y$1 + [6] Let mutate x$4_@4 = read y$1_@3 Return ``` @@ -59,13 +59,13 @@ flowchart TB end subgraph bb3 bb3_instrs[" - [5] Reassign mutate y$1_@4 = 2 + [5] Reassign mutate y$1_@3 = 2 "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [6] Let mutate x$4_@5 = read y$1 + [6] Let mutate x$4_@4 = read y$1_@3 "] bb1_instrs --> bb1_terminal(["Return"]) 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 0ec6feb787..1713025598 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md @@ -45,16 +45,16 @@ bb5: bb3: predecessor blocks: bb0 [8] Const mutate $3_@7 = 2 - [9] Reassign mutate x$1_@8 = Binary read x$1_@0 + read $3_@7 + [9] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $3_@7 Goto bb1 bb2: predecessor blocks: bb0 - [10] Const mutate $2_@9 = 3 - [11] Reassign mutate x$1_@10 = Binary read x$1_@0 + read $2_@9 + [10] Const mutate $2_@8 = 3 + [11] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $2_@8 Goto bb1 bb1: predecessor blocks: bb5 bb3 bb2 - [12] Let mutate y$9_@11 = read x$1 + [12] Let mutate y$9_@9 = read x$1_@6 Return ``` @@ -83,20 +83,20 @@ flowchart TB subgraph bb3 bb3_instrs[" [8] Const mutate $3_@7 = 2 - [9] Reassign mutate x$1_@8 = Binary read x$1_@0 + read $3_@7 + [9] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $3_@7 "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb2 bb2_instrs[" - [10] Const mutate $2_@9 = 3 - [11] Reassign mutate x$1_@10 = Binary read x$1_@0 + read $2_@9 + [10] Const mutate $2_@8 = 3 + [11] Reassign mutate x$1_@6 = Binary read x$1_@0 + read $2_@8 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [12] Let mutate y$9_@11 = read x$1 + [12] Let mutate y$9_@9 = read x$1_@6 "] bb1_instrs --> bb1_terminal(["Return"]) 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 76a5aff98a..5d54773ea7 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md @@ -22,11 +22,11 @@ bb0: If (read $3_@2) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [4] Reassign mutate x$1_@3 = 2 + [4] Reassign mutate x$1_@0 = 2 Goto bb1 bb1: predecessor blocks: bb2 bb0 - Throw read x$1 + Throw read x$1_@0 ``` ### CFG @@ -44,12 +44,12 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [4] Reassign mutate x$1_@3 = 2 + [4] Reassign mutate x$1_@0 = 2 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 - bb1_terminal(["Throw read x$1"]) + bb1_terminal(["Throw read x$1_@0"]) end %% Jumps 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 16c2dce0b2..560f33325f 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md @@ -22,16 +22,16 @@ bb0: bb1: predecessor blocks: bb0 bb3 [2] Const mutate $3_@1 = 10 - [3] Const mutate $4_@2 = Binary read x$1 < read $3_@1 + [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 If (read $4_@2) then:bb3 else:bb2 bb3: predecessor blocks: bb1 [4] Const mutate $2_@3 = 1 - [5] Reassign mutate x$1_@4 = Binary read x$1 + read $2_@3 + [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3 Goto(Continue) bb1 bb2: predecessor blocks: bb1 - Return read x$1 + Return read x$1_@0 ``` ### CFG @@ -48,19 +48,19 @@ flowchart TB subgraph bb1 bb1_instrs[" [2] Const mutate $3_@1 = 10 - [3] Const mutate $4_@2 = Binary read x$1 < read $3_@1 + [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 "] bb1_instrs --> bb1_terminal(["If (read $4_@2)"]) end subgraph bb3 bb3_instrs[" [4] Const mutate $2_@3 = 1 - [5] Reassign mutate x$1_@4 = Binary read x$1 + read $2_@3 + [5] Reassign mutate x$1_@0 = Binary read x$1_@0 + read $2_@3 "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb2 - bb2_terminal(["Return read x$1"]) + bb2_terminal(["Return read x$1_@0"]) end %% Jumps 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 1580e97f38..0a860dd2f4 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 @@ -45,18 +45,18 @@ bb0: bb6: predecessor blocks: bb0 [6] Call mutate x$2_@0.push(read props$1.p2) - [7] Reassign mutate y$3_@5 = Array [] + [7] Reassign mutate y$3_@1 = Array [] Goto bb1 bb2: predecessor blocks: bb0 - [8] Reassign mutate y$3_@6 = read x$2_@0 + [8] Reassign mutate y$3_@1 = read x$2_@0 Goto bb1 bb1: predecessor blocks: bb0 bb6 bb2 - [9] Const mutate child$7_@7 = JSX - [10] Call read y$3.push(read props$1.p4) - [11] Const mutate $8_@8 = JSX {read child$7_@7} - Return read $8_@8 + [9] Const mutate child$7_@5 = JSX + [10] Call read y$3_@1.push(read props$1.p4) + [11] Const mutate $8_@6 = JSX {read child$7_@5} + Return read $8_@6 ``` ### CFG @@ -77,23 +77,23 @@ flowchart TB subgraph bb6 bb6_instrs[" [6] Call mutate x$2_@0.push(read props$1.p2) - [7] Reassign mutate y$3_@5 = Array [] + [7] Reassign mutate y$3_@1 = Array [] "] bb6_instrs --> bb6_terminal(["Goto"]) end subgraph bb2 bb2_instrs[" - [8] Reassign mutate y$3_@6 = read x$2_@0 + [8] Reassign mutate y$3_@1 = read x$2_@0 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [9] Const mutate child$7_@7 = JSX - [10] Call read y$3.push(read props$1.p4) - [11] Const mutate $8_@8 = JSX {read child$7_@7} + [9] Const mutate child$7_@5 = JSX + [10] Call read y$3_@1.push(read props$1.p4) + [11] Const mutate $8_@6 = JSX {read child$7_@5} "] - bb1_instrs --> bb1_terminal(["Return read $8_@8"]) + bb1_instrs --> bb1_terminal(["Return read $8_@6"]) end %% Jumps diff --git a/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md b/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md index 59793e9474..58a3ac0103 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md @@ -44,14 +44,14 @@ bb4: Goto bb2 bb2: predecessor blocks: bb4 bb0 - [8] Reassign mutate y$3_@5 = read x$2_@0 + [8] Reassign mutate y$3_@1 = read x$2_@0 Goto bb1 bb1: predecessor blocks: bb2 bb0 - [9] Const mutate child$6_@6 = JSX - [10] Call read y$3.push(read props$1.p4) - [11] Const mutate $7_@7 = JSX {read child$6_@6} - Return read $7_@7 + [9] Const mutate child$6_@5 = JSX + [10] Call read y$3_@1.push(read props$1.p4) + [11] Const mutate $7_@6 = JSX {read child$6_@5} + Return read $7_@6 ``` ### CFG @@ -78,17 +78,17 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [8] Reassign mutate y$3_@5 = read x$2_@0 + [8] Reassign mutate y$3_@1 = read x$2_@0 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [9] Const mutate child$6_@6 = JSX - [10] Call read y$3.push(read props$1.p4) - [11] Const mutate $7_@7 = JSX {read child$6_@6} + [9] Const mutate child$6_@5 = JSX + [10] Call read y$3_@1.push(read props$1.p4) + [11] Const mutate $7_@6 = JSX {read child$6_@5} "] - bb1_instrs --> bb1_terminal(["Return read $7_@7"]) + bb1_instrs --> bb1_terminal(["Return read $7_@6"]) end %% Jumps