diff --git a/compiler/forget/src/HIR/BuildHIR.ts b/compiler/forget/src/HIR/BuildHIR.ts index f6b4444d28..bea08b63b2 100644 --- a/compiler/forget/src/HIR/BuildHIR.ts +++ b/compiler/forget/src/HIR/BuildHIR.ts @@ -119,7 +119,11 @@ function lowerStatement( case "ThrowStatement": { const stmt = stmtPath as NodePath; const value = lowerExpressionToPlace(builder, stmt.get("argument")); - const terminal: ThrowTerminal = { kind: "throw", value }; + const terminal: ThrowTerminal = { + kind: "throw", + value, + id: makeInstructionId(0), + }; builder.terminate(terminal); return; } @@ -133,6 +137,7 @@ function lowerStatement( const terminal: ReturnTerminal = { kind: "return", value, + id: makeInstructionId(0), }; builder.terminateWithContinuation(terminal, fallthrough); return; @@ -148,6 +153,7 @@ function lowerStatement( kind: "goto", block: continuationBlock.id, variant: GotoVariant.Break, + id: makeInstructionId(0), }; }); // Block for the alternate (if the test is not truthy) @@ -160,6 +166,7 @@ function lowerStatement( kind: "goto", block: continuationBlock.id, variant: GotoVariant.Break, + id: makeInstructionId(0), }; }); } else { @@ -173,6 +180,7 @@ function lowerStatement( consequent: consequentBlock, alternate: alternateBlock, fallthrough: continuationBlock.id, + id: makeInstructionId(0), }; builder.terminateWithContinuation(terminal, continuationBlock); return; @@ -189,6 +197,7 @@ function lowerStatement( kind: "goto", block, variant: GotoVariant.Break, + id: makeInstructionId(0), }); return; } @@ -199,6 +208,7 @@ function lowerStatement( kind: "goto", block, variant: GotoVariant.Continue, + id: makeInstructionId(0), }); return; } @@ -219,6 +229,7 @@ function lowerStatement( kind: "goto", block: conditionalBlock.id, variant: GotoVariant.Continue, + id: makeInstructionId(0), }; } ); @@ -229,6 +240,7 @@ function lowerStatement( kind: "goto", block: conditionalBlock.id, variant: GotoVariant.Break, + id: makeInstructionId(0), }, conditionalBlock ); @@ -244,6 +256,7 @@ function lowerStatement( consequent: loopBlock, alternate: continuationBlock.id, fallthrough: continuationBlock.id, + id: makeInstructionId(0), }; builder.terminateWithContinuation(terminal, continuationBlock); return; @@ -269,6 +282,7 @@ function lowerStatement( kind: "goto", block: conditionalBlock.id, variant: GotoVariant.Continue, + id: makeInstructionId(0), }; } ); @@ -279,6 +293,7 @@ function lowerStatement( kind: "goto", block: conditionalBlock.id, variant: GotoVariant.Break, + id: makeInstructionId(0), }, conditionalBlock ); @@ -294,6 +309,7 @@ function lowerStatement( consequent: loopBlock, alternate: continuationBlock.id, fallthrough: continuationBlock.id, + id: makeInstructionId(0), }; builder.terminateWithContinuation(terminal, continuationBlock); return; @@ -328,6 +344,7 @@ function lowerStatement( kind: "goto", block: conditionalBlock.id, variant: GotoVariant.Break, + id: makeInstructionId(0), }); /** * Construct the loop itself: the loop body wraps around to the update block @@ -340,6 +357,7 @@ function lowerStatement( kind: "goto", block: updateBlock.id, variant: GotoVariant.Continue, + id: makeInstructionId(0), }; }); }); @@ -349,6 +367,7 @@ function lowerStatement( kind: "goto", block: conditionalBlock.id, variant: GotoVariant.Break, + id: makeInstructionId(0), }, conditionalBlock ); @@ -366,6 +385,7 @@ function lowerStatement( consequent: loopBlock, alternate: continuationBlock.id, fallthrough: continuationBlock.id, + id: makeInstructionId(0), }; } else { /** @@ -376,6 +396,7 @@ function lowerStatement( kind: "goto", block: loopBlock, variant: GotoVariant.Break, + id: makeInstructionId(0), }; } builder.terminateWithContinuation(terminal, continuationBlock); @@ -400,13 +421,19 @@ function lowerStatement( consequent: loopBlock, alternate: continuationBlock.id, fallthrough: continuationBlock.id, + id: makeInstructionId(0), }; return terminal; }); }); // do-while unconditionally enters the loop builder.terminateWithContinuation( - { kind: "goto", block: loopBlock, variant: GotoVariant.Break }, + { + kind: "goto", + block: loopBlock, + variant: GotoVariant.Break, + id: makeInstructionId(0), + }, continuationBlock ); return; @@ -429,6 +456,7 @@ function lowerStatement( kind: "goto", block: conditionalBlock.id, variant: GotoVariant.Continue, + id: makeInstructionId(0), }; } ); @@ -443,6 +471,7 @@ function lowerStatement( test: conditionalBlock.id, loop: loopBlock, fallthrough: continuationBlock.id, + id: makeInstructionId(0), }, conditionalBlock ); @@ -457,6 +486,7 @@ function lowerStatement( consequent: loopBlock, alternate: continuationBlock.id, fallthrough: continuationBlock.id, + id: makeInstructionId(0), }; // Complete the conditional and continue with code after the loop builder.terminateWithContinuation(terminal, continuationBlock); @@ -489,6 +519,7 @@ function lowerStatement( kind: "goto", block: continuationBlock.id, variant: GotoVariant.Break, + id: makeInstructionId(0), }, continuationBlock ); @@ -535,6 +566,7 @@ function lowerStatement( kind: "goto", block: fallthrough, variant: GotoVariant.Break, + id: makeInstructionId(0), }; }); }); @@ -559,7 +591,13 @@ function lowerStatement( const test = lowerExpressionToPlace(builder, stmt.get("discriminant")); builder.terminateWithContinuation( - { kind: "switch", test, cases, fallthrough: continuationBlock.id }, + { + kind: "switch", + test, + cases, + fallthrough: continuationBlock.id, + id: makeInstructionId(0), + }, continuationBlock ); return; @@ -1069,6 +1107,7 @@ function lowerConditional( kind: "goto", block: continuationBlock.id, variant: GotoVariant.Break, + id: makeInstructionId(0), }; }); // Block for the alternate (if the test is not truthy) @@ -1084,6 +1123,7 @@ function lowerConditional( kind: "goto", block: continuationBlock.id, variant: GotoVariant.Break, + id: makeInstructionId(0), }; }); const terminal: IfTerminal = { @@ -1092,6 +1132,7 @@ function lowerConditional( consequent: consequentBlock, alternate: alternateBlock, fallthrough: continuationBlock.id, + id: makeInstructionId(0), }; builder.terminateWithContinuation(terminal, continuationBlock); return place; diff --git a/compiler/forget/src/HIR/HIR.ts b/compiler/forget/src/HIR/HIR.ts index 5305048b1d..bc172b53b1 100644 --- a/compiler/forget/src/HIR/HIR.ts +++ b/compiler/forget/src/HIR/HIR.ts @@ -121,14 +121,19 @@ export type Terminal = | SwitchTerminal | WhileTerminal; -export type ThrowTerminal = { kind: "throw"; value: Place }; +export type ThrowTerminal = { kind: "throw"; value: Place; id: InstructionId }; -export type ReturnTerminal = { kind: "return"; value: Place | null }; +export type ReturnTerminal = { + kind: "return"; + value: Place | null; + id: InstructionId; +}; export type GotoTerminal = { kind: "goto"; block: BlockId; variant: GotoVariant; + id: InstructionId; }; export enum GotoVariant { @@ -142,6 +147,7 @@ export type IfTerminal = { consequent: BlockId; alternate: BlockId; fallthrough: BlockId | null; + id: InstructionId; }; export type SwitchTerminal = { @@ -149,6 +155,7 @@ export type SwitchTerminal = { test: Place; cases: Array<{ test: Place | null; block: BlockId }>; fallthrough: BlockId | null; + id: InstructionId; }; export type WhileTerminal = { @@ -156,6 +163,7 @@ export type WhileTerminal = { test: BlockId; loop: BlockId; fallthrough: BlockId; + id: InstructionId; }; /** diff --git a/compiler/forget/src/HIR/HIRBuilder.ts b/compiler/forget/src/HIR/HIRBuilder.ts index 976c6b8ad2..6de0673dd8 100644 --- a/compiler/forget/src/HIR/HIRBuilder.ts +++ b/compiler/forget/src/HIR/HIRBuilder.ts @@ -145,7 +145,7 @@ export default class HIRBuilder { this.#completed.set(blockId, { id: blockId, instructions, - terminal: { kind: "return", value: null }, + terminal: { kind: "return", value: null, id: makeInstructionId(0) }, preds: new Set(), phis: new Set(), }); @@ -508,6 +508,7 @@ function markInstructionIds(func: HIR) { invariant(instr.id === 0, `${printInstruction(instr)} already visited!`); instr.id = makeInstructionId(++id); } + block.terminal.id = makeInstructionId(++id); } } diff --git a/compiler/forget/src/HIR/PrintHIR.ts b/compiler/forget/src/HIR/PrintHIR.ts index 476444b84e..6db64aa41f 100644 --- a/compiler/forget/src/HIR/PrintHIR.ts +++ b/compiler/forget/src/HIR/PrintHIR.ts @@ -115,30 +115,30 @@ function printTerminal(terminal: Terminal): Array | string { let value; switch (terminal.kind) { case "if": { - value = `If (${printPlace(terminal.test)}) then:bb${ + value = `[${terminal.id}] If (${printPlace(terminal.test)}) then:bb${ terminal.consequent } else:bb${terminal.alternate}`; break; } case "throw": { - value = `Throw ${printPlace(terminal.value)}`; + value = `[${terminal.id}] Throw ${printPlace(terminal.value)}`; break; } case "return": { - value = `Return${ + value = `[${terminal.id}] Return${ terminal.value != null ? " " + printPlace(terminal.value) : "" }`; break; } case "goto": { - value = `Goto${ + value = `[${terminal.id}] Goto${ terminal.variant === GotoVariant.Continue ? "(Continue)" : "" } bb${terminal.block}`; break; } case "switch": { const output = []; - output.push(`Switch (${printPlace(terminal.test)})`); + output.push(`[${terminal.id}] Switch (${printPlace(terminal.test)})`); terminal.cases.forEach((case_) => { if (case_.test !== null) { output.push(` Case ${printPlace(case_.test)}: bb${case_.block}`); @@ -150,7 +150,7 @@ function printTerminal(terminal: Terminal): Array | string { break; } case "while": { - value = `While test=bb${terminal.test} loop=${ + value = `[${terminal.id}] While test=bb${terminal.test} loop=${ terminal.loop !== null ? `bb${terminal.loop}` : "" } fallthrough=${terminal.fallthrough ? `bb${terminal.fallthrough}` : ""}`; break; diff --git a/compiler/forget/src/HIR/visitors.ts b/compiler/forget/src/HIR/visitors.ts index a00d36f25c..fbadc7c04a 100644 --- a/compiler/forget/src/HIR/visitors.ts +++ b/compiler/forget/src/HIR/visitors.ts @@ -6,7 +6,14 @@ */ import { assertExhaustive } from "../Common/utils"; -import { BasicBlock, BlockId, Instruction, Place, Terminal } from "./HIR"; +import { + BasicBlock, + BlockId, + Instruction, + makeInstructionId, + Place, + Terminal, +} from "./HIR"; export function* eachInstructionOperand(instr: Instruction): Iterable { const instrValue = instr.value; @@ -143,6 +150,7 @@ export function mapTerminalSuccessors( kind: "goto", block: target, variant: terminal.variant, + id: makeInstructionId(0), }; } case "if": { @@ -156,6 +164,7 @@ export function mapTerminalSuccessors( consequent, alternate, fallthrough, + id: makeInstructionId(0), }; } case "switch": { @@ -173,12 +182,14 @@ export function mapTerminalSuccessors( test: terminal.test, cases, fallthrough, + id: makeInstructionId(0), }; } case "return": { return { kind: "return", value: terminal.value, + id: makeInstructionId(0), }; } case "throw": { @@ -193,6 +204,7 @@ export function mapTerminalSuccessors( test, loop, fallthrough, + id: makeInstructionId(0), }; } default: { diff --git a/compiler/forget/src/__tests__/fixtures/hir/alias-while.expect.md b/compiler/forget/src/__tests__/fixtures/hir/alias-while.expect.md index d538ef0e59..c178718689 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/alias-while.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/alias-while.expect.md @@ -27,27 +27,27 @@ function mutate(x, y) {} ``` bb0: - [1] Let mutate a$2_@0[0:9] = Object { } - [2] Let mutate b$3_@0[0:9] = Object { } - [3] Let mutate c$4_@0[0:9] = Object { } - While test=bb1 loop=bb3 fallthrough=bb2 + [1] Let mutate a$2_@0[0:11] = Object { } + [2] Let mutate b$3_@0[0:11] = Object { } + [3] Let mutate c$4_@0[0:11] = Object { } + [4] While test=bb1 loop=bb3 fallthrough=bb2 bb1: predecessor blocks: bb0 bb3 - If (read cond$1) then:bb3 else:bb2 + [5] If (read cond$1) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - [4] Let mutate z$5_@0[0:9] = read a$2_@0 - [5] Reassign mutate a$2_@0[0:9] = read b$3_@0 - [6] Reassign mutate b$3_@0[0:9] = read c$4_@0 - [7] Reassign mutate c$4_@0[0:9] = read z$5_@0 - [8] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0) - Goto(Continue) bb1 + [6] Let mutate z$5_@0[0:11] = read a$2_@0 + [7] Reassign mutate a$2_@0[0:11] = read b$3_@0 + [8] Reassign mutate b$3_@0[0:11] = read c$4_@0 + [9] Reassign mutate c$4_@0[0:11] = read z$5_@0 + [10] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0) + [11] Goto(Continue) bb1 bb2: predecessor blocks: bb1 - [9] read a$2_@0 - [10] read b$3_@0 - [11] read c$4_@0 - Return freeze a$2_@0 + [12] read a$2_@0 + [13] read b$3_@0 + [14] read c$4_@0 + [15] Return freeze a$2_@0 ``` ### CFG @@ -57,9 +57,9 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate a$2_@0[0:9] = Object { } - [2] Let mutate b$3_@0[0:9] = Object { } - [3] Let mutate c$4_@0[0:9] = Object { } + [1] Let mutate a$2_@0[0:11] = Object { } + [2] Let mutate b$3_@0[0:11] = Object { } + [3] Let mutate c$4_@0[0:11] = Object { } "] bb0_instrs --> bb0_terminal(["While"]) end @@ -68,19 +68,19 @@ flowchart TB end subgraph bb3 bb3_instrs[" - [4] Let mutate z$5_@0[0:9] = read a$2_@0 - [5] Reassign mutate a$2_@0[0:9] = read b$3_@0 - [6] Reassign mutate b$3_@0[0:9] = read c$4_@0 - [7] Reassign mutate c$4_@0[0:9] = read z$5_@0 - [8] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0) + [6] Let mutate z$5_@0[0:11] = read a$2_@0 + [7] Reassign mutate a$2_@0[0:11] = read b$3_@0 + [8] Reassign mutate b$3_@0[0:11] = read c$4_@0 + [9] Reassign mutate c$4_@0[0:11] = read z$5_@0 + [10] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0) "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb2 bb2_instrs[" - [9] read a$2_@0 - [10] read b$3_@0 - [11] read c$4_@0 + [12] read a$2_@0 + [13] read b$3_@0 + [14] read c$4_@0 "] bb2_instrs --> bb2_terminal(["Return freeze a$2_@0"]) end @@ -121,7 +121,7 @@ function foo$0(cond$1) { ``` bb0: - Return + [1] Return ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/assignment-variations.expect.md b/compiler/forget/src/__tests__/fixtures/hir/assignment-variations.expect.md index 8da05a5455..369e7f9992 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/assignment-variations.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/assignment-variations.expect.md @@ -27,7 +27,7 @@ bb0: [5] Reassign mutate x$1_@4 = Binary read x$1_@2 + read $3_@3 [6] Const mutate $4_@5 = 1 [7] Reassign mutate x$1_@6 = Binary read x$1_@4 >>> read $4_@5 - Return + [8] Return ``` ### CFG @@ -72,7 +72,7 @@ bb0: [2] Reassign mutate a$1_@1.b.c[0:5] = Binary read a$1_@1.b.c + read $2_@0 [3] Const mutate $3_@2 = 2 [4] Reassign mutate a$1_@1.b.c[0:5] = Binary read a$1_@1.b.c * read $3_@2 - Return + [5] Return ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/call.expect.md b/compiler/forget/src/__tests__/fixtures/hir/call.expect.md index a248fcbbf4..f03d6b1af4 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/call.expect.md @@ -19,7 +19,7 @@ function Component(props) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -55,7 +55,7 @@ bb0: [6] Call mutate foo$4_@0(mutate b$3_@0) [7] Const mutate $7_@3 = "div" [8] Const mutate $8_@4 = JSX - Return read $8_@4 + [9] Return read $8_@4 ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/complex-while.expect.md b/compiler/forget/src/__tests__/fixtures/hir/complex-while.expect.md index 2ab72bf2ff..1c4a6595e6 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/complex-while.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/complex-while.expect.md @@ -18,22 +18,22 @@ function foo(a, b, c) { ``` bb0: - If (read a$1) then:bb3 else:bb1 + [1] If (read a$1) then:bb3 else:bb1 bb3: predecessor blocks: bb0 - While test=bb4 loop=bb6 fallthrough=bb1 + [2] While test=bb4 loop=bb6 fallthrough=bb1 bb4: predecessor blocks: bb3 bb7 - If (read b$2) then:bb6 else:bb1 + [3] If (read b$2) then:bb6 else:bb1 bb6: predecessor blocks: bb4 - If (read c$3) then:bb1 else:bb7 + [4] If (read c$3) then:bb1 else:bb7 bb7: predecessor blocks: bb6 - Goto(Continue) bb4 + [5] Goto(Continue) bb4 bb1: predecessor blocks: bb6 bb4 bb0 - Return + [6] Return ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md index bf87d77f8f..2b43e8f0b7 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md @@ -37,56 +37,56 @@ function Component(props) { 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:15] = Array [] - [4] Const mutate seen$5_@3[0:12] = New mutate Set$6_@3() + [3] Const mutate renderedItems$4_@2[3:22] = Array [] + [4] Const mutate seen$5_@3[0:19] = New mutate Set$6_@3() [5] Const mutate $9_@4 = 0 [6] Const mutate max$7_@5[0:7] = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1) - Goto bb1 + [7] Goto bb1 bb1: predecessor blocks: bb0 bb5 bb10 - If (read items$2_@0) then:bb3 else:bb2 + [8] If (read items$2_@0) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - [7] Const mutate $11_@6 = null - [8] Const mutate $12_@3[0:12] = Binary read item$10_@3 == read $11_@6 - If (read $12_@3) then:bb8 else:bb9 + [9] Const mutate $11_@6 = null + [10] Const mutate $12_@3[0:19] = Binary read item$10_@3 == read $11_@6 + [11] If (read $12_@3) then:bb8 else:bb9 bb8: predecessor blocks: bb3 - [9] Const mutate $13_@3[0:12] = read $12_@3 - Goto bb7 + [12] Const mutate $13_@3[0:19] = read $12_@3 + [13] Goto bb7 bb9: predecessor blocks: bb3 - [10] Const mutate $13_@3[0:12] = Call mutate seen$5_@3.has(mutate item$10_@3) - Goto bb7 + [14] Const mutate $13_@3[0:19] = Call mutate seen$5_@3.has(mutate item$10_@3) + [15] Goto bb7 bb7: predecessor blocks: bb8 bb9 - If (read $13_@3) then:bb5 else:bb4 + [16] If (read $13_@3) then:bb5 else:bb4 bb5: predecessor blocks: bb7 - Goto(Continue) bb1 + [17] Goto(Continue) bb1 bb4: predecessor blocks: bb7 - [11] Call mutate seen$5_@3.add(mutate item$10_@3) - [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 + [18] Call mutate seen$5_@3.add(mutate item$10_@3) + [19] Const mutate $14_@7 = "div" + [20] Const mutate $15_@8 = JSX {read item$10_@3} + [21] Call mutate renderedItems$4_@2.push(read $15_@8) + [22] Const mutate $16_@9 = Binary read renderedItems$4_@2.length >= read max$7_@5 + [23] If (read $16_@9) then:bb2 else:bb10 bb10: predecessor blocks: bb4 - Goto(Continue) bb1 + [24] Goto(Continue) bb1 bb2: predecessor blocks: bb4 bb1 - [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 + [25] Const mutate count$17_@10 = read renderedItems$4_@2.length + [26] Const mutate $18_@11 = "div" + [27] Const mutate $19_@12 = "\n " + [28] Const mutate $20_@13 = "h1" + [29] Const mutate $21_@14 = " Items" + [30] Const mutate $22_@15 = JSX {freeze count$17_@10}{read $21_@14} + [31] Const mutate $23_@16 = "\n " + [32] Const mutate $24_@17 = "\n " + [33] Const mutate $25_@18 = JSX {read $19_@12}{read $22_@15}{read $23_@16}{freeze renderedItems$4_@2}{read $24_@17} + [34] Return read $25_@18 ``` ### CFG @@ -98,8 +98,8 @@ flowchart TB bb0_instrs[" [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:15] = Array [] - [4] Const mutate seen$5_@3[0:12] = New mutate Set$6_@3() + [3] Const mutate renderedItems$4_@2[3:22] = Array [] + [4] Const mutate seen$5_@3[0:19] = New mutate Set$6_@3() [5] Const mutate $9_@4 = 0 [6] Const mutate max$7_@5[0:7] = Call mutate Math$8_@5.max(read $9_@4, read maxItems$3_@1) "] @@ -110,20 +110,20 @@ flowchart TB end subgraph bb3 bb3_instrs[" - [7] Const mutate $11_@6 = null - [8] Const mutate $12_@3[0:12] = Binary read item$10_@3 == read $11_@6 + [9] Const mutate $11_@6 = null + [10] Const mutate $12_@3[0:19] = 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[0:12] = read $12_@3 + [12] Const mutate $13_@3[0:19] = read $12_@3 "] bb8_instrs --> bb8_terminal(["Goto"]) end subgraph bb9 bb9_instrs[" - [10] Const mutate $13_@3[0:12] = Call mutate seen$5_@3.has(mutate item$10_@3) + [14] Const mutate $13_@3[0:19] = Call mutate seen$5_@3.has(mutate item$10_@3) "] bb9_instrs --> bb9_terminal(["Goto"]) end @@ -135,11 +135,11 @@ flowchart TB end subgraph bb4 bb4_instrs[" - [11] Call mutate seen$5_@3.add(mutate item$10_@3) - [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 + [18] Call mutate seen$5_@3.add(mutate item$10_@3) + [19] Const mutate $14_@7 = 'div' + [20] Const mutate $15_@8 = JSX {read item$10_@3} + [21] Call mutate renderedItems$4_@2.push(read $15_@8) + [22] Const mutate $16_@9 = Binary read renderedItems$4_@2.length >= read max$7_@5 "] bb4_instrs --> bb4_terminal(["If (read $16_@9)"]) end @@ -148,15 +148,15 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [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} + [25] Const mutate count$17_@10 = read renderedItems$4_@2.length + [26] Const mutate $18_@11 = 'div' + [27] Const mutate $19_@12 = '\n ' + [28] Const mutate $20_@13 = 'h1' + [29] Const mutate $21_@14 = ' Items' + [30] Const mutate $22_@15 = JSX {freeze count$17_@10}{read $21_@14} + [31] Const mutate $23_@16 = '\n ' + [32] Const mutate $24_@17 = '\n ' + [33] 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_@18"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md b/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md index 65a4c91905..39ca744054 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md @@ -78,17 +78,17 @@ function Component(props) { ``` bb0: - [1] Const mutate a_DEBUG$2_@0[1:5] = Array [] + [1] Const mutate a_DEBUG$2_@0[1:7] = Array [] [2] Call mutate a_DEBUG$2_@0.push(read props$1.a) - If (read props$1.b) then:bb2 else:bb1 + [3] If (read props$1.b) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [3] Const mutate $3_@1 = null - Return read $3_@1 + [4] Const mutate $3_@1 = null + [5] Return read $3_@1 bb1: predecessor blocks: bb0 - [4] Call mutate a_DEBUG$2_@0.push(read props$1.d) - Return freeze a_DEBUG$2_@0 + [6] Call mutate a_DEBUG$2_@0.push(read props$1.d) + [7] Return freeze a_DEBUG$2_@0 ``` ### CFG @@ -98,20 +98,20 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a_DEBUG$2_@0[1:5] = Array [] + [1] Const mutate a_DEBUG$2_@0[1:7] = Array [] [2] Call mutate a_DEBUG$2_@0.push(read props$1.a) "] bb0_instrs --> bb0_terminal(["If (read props$1.b)"]) end subgraph bb2 bb2_instrs[" - [3] Const mutate $3_@1 = null + [4] Const mutate $3_@1 = null "] bb2_instrs --> bb2_terminal(["Return read $3_@1"]) end subgraph bb1 bb1_instrs[" - [4] Call mutate a_DEBUG$2_@0.push(read props$1.d) + [6] Call mutate a_DEBUG$2_@0.push(read props$1.d) "] bb1_instrs --> bb1_terminal(["Return freeze a_DEBUG$2_@0"]) end @@ -141,17 +141,17 @@ function Component$0(props$1) { ``` bb0: - [1] Const mutate a$2_@0[1:5] = Array [] + [1] Const mutate a$2_@0[1:7] = Array [] [2] Call mutate a$2_@0.push(read props$1.a) - If (read props$1.b) then:bb2 else:bb1 + [3] If (read props$1.b) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [3] Call mutate a$2_@0.push(read props$1.c) - Goto bb1 + [4] Call mutate a$2_@0.push(read props$1.c) + [5] Goto bb1 bb1: predecessor blocks: bb2 bb0 - [4] Call mutate a$2_@0.push(read props$1.d) - Return freeze a$2_@0 + [6] Call mutate a$2_@0.push(read props$1.d) + [7] Return freeze a$2_@0 ``` ### CFG @@ -161,20 +161,20 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:5] = Array [] + [1] Const mutate a$2_@0[1:7] = Array [] [2] Call mutate a$2_@0.push(read props$1.a) "] bb0_instrs --> bb0_terminal(["If (read props$1.b)"]) end subgraph bb2 bb2_instrs[" - [3] Call mutate a$2_@0.push(read props$1.c) + [4] Call mutate a$2_@0.push(read props$1.c) "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [4] Call mutate a$2_@0.push(read props$1.d) + [6] Call mutate a$2_@0.push(read props$1.d) "] bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"]) end @@ -205,18 +205,18 @@ function Component$0(props$1) { ``` bb0: - [1] Const mutate a$2_@0[1:6] = Array [] + [1] Const mutate a$2_@0[1:8] = Array [] [2] Call mutate a$2_@0.push(read props$1.a) - If (read props$1.b) then:bb2 else:bb1 + [3] If (read props$1.b) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [3] Call mutate a$2_@0.push(read props$1.c) - [4] Const mutate $3_@1 = null - Return read $3_@1 + [4] Call mutate a$2_@0.push(read props$1.c) + [5] Const mutate $3_@1 = null + [6] Return read $3_@1 bb1: predecessor blocks: bb0 - [5] Call mutate a$2_@0.push(read props$1.d) - Return freeze a$2_@0 + [7] Call mutate a$2_@0.push(read props$1.d) + [8] Return freeze a$2_@0 ``` ### CFG @@ -226,21 +226,21 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:6] = Array [] + [1] Const mutate a$2_@0[1:8] = Array [] [2] Call mutate a$2_@0.push(read props$1.a) "] bb0_instrs --> bb0_terminal(["If (read props$1.b)"]) end subgraph bb2 bb2_instrs[" - [3] Call mutate a$2_@0.push(read props$1.c) - [4] Const mutate $3_@1 = null + [4] Call mutate a$2_@0.push(read props$1.c) + [5] Const mutate $3_@1 = null "] bb2_instrs --> bb2_terminal(["Return read $3_@1"]) end subgraph bb1 bb1_instrs[" - [5] Call mutate a$2_@0.push(read props$1.d) + [7] Call mutate a$2_@0.push(read props$1.d) "] bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"]) end @@ -271,17 +271,17 @@ function Component$0(props$1) { ``` bb0: - [1] Const mutate a$2_@0[1:5] = Array [] + [1] Const mutate a$2_@0[1:7] = Array [] [2] Call mutate a$2_@0.push(read props$1.a) - If (read props$1.b) then:bb2 else:bb1 + [3] If (read props$1.b) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [3] Call mutate a$2_@0.push(read props$1.c) - Return freeze a$2_@0 + [4] Call mutate a$2_@0.push(read props$1.c) + [5] Return freeze a$2_@0 bb1: predecessor blocks: bb0 - [4] Call mutate a$2_@0.push(read props$1.d) - Return freeze a$2_@0 + [6] Call mutate a$2_@0.push(read props$1.d) + [7] Return freeze a$2_@0 ``` ### CFG @@ -291,20 +291,20 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:5] = Array [] + [1] Const mutate a$2_@0[1:7] = Array [] [2] Call mutate a$2_@0.push(read props$1.a) "] bb0_instrs --> bb0_terminal(["If (read props$1.b)"]) end subgraph bb2 bb2_instrs[" - [3] Call mutate a$2_@0.push(read props$1.c) + [4] Call mutate a$2_@0.push(read props$1.c) "] bb2_instrs --> bb2_terminal(["Return freeze a$2_@0"]) end subgraph bb1 bb1_instrs[" - [4] Call mutate a$2_@0.push(read props$1.d) + [6] Call mutate a$2_@0.push(read props$1.d) "] bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"]) end @@ -335,17 +335,17 @@ function Component$0(props$1) { ``` bb0: - [1] Const mutate a$2_@0[1:5] = Array [] + [1] Const mutate a$2_@0[1:7] = Array [] [2] Call mutate a$2_@0.push(read props$1.a) - If (read props$1.b) then:bb1 else:bb2 + [3] If (read props$1.b) then:bb1 else:bb2 bb2: predecessor blocks: bb0 - [3] Call mutate a$2_@0.push(read props$1.c) - Goto bb1 + [4] Call mutate a$2_@0.push(read props$1.c) + [5] Goto bb1 bb1: predecessor blocks: bb0 bb2 - [4] Call mutate a$2_@0.push(read props$1.d) - Return freeze a$2_@0 + [6] Call mutate a$2_@0.push(read props$1.d) + [7] Return freeze a$2_@0 ``` ### CFG @@ -355,20 +355,20 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:5] = Array [] + [1] Const mutate a$2_@0[1:7] = Array [] [2] Call mutate a$2_@0.push(read props$1.a) "] bb0_instrs --> bb0_terminal(["If (read props$1.b)"]) end subgraph bb2 bb2_instrs[" - [3] Call mutate a$2_@0.push(read props$1.c) + [4] Call mutate a$2_@0.push(read props$1.c) "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [4] Call mutate a$2_@0.push(read props$1.d) + [6] Call mutate a$2_@0.push(read props$1.d) "] bb1_instrs --> bb1_terminal(["Return freeze a$2_@0"]) 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 740eaaabdc..df08c10b89 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 @@ -67,24 +67,24 @@ function mayMutate() {} ``` bb0: - [1] Const mutate a$2_@0[1:4] = Array [] - [2] Const mutate b$3_@1[2:5] = Array [] - If (read b$3_@1) then:bb2 else:bb1 + [1] Const mutate a$2_@0[1:5] = Array [] + [2] Const mutate b$3_@1[2:8] = Array [] + [3] If (read b$3_@1) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [3] Call mutate a$2_@0.push(read props$1.p0) - Goto bb1 + [4] Call mutate a$2_@0.push(read props$1.p0) + [5] Goto bb1 bb1: predecessor blocks: bb2 bb0 - If (read props$1.p1) then:bb4 else:bb3 + [6] If (read props$1.p1) then:bb4 else:bb3 bb4: predecessor blocks: bb1 - [4] Call mutate b$3_@1.push(read props$1.p2) - Goto bb3 + [7] Call mutate b$3_@1.push(read props$1.p2) + [8] Goto bb3 bb3: predecessor blocks: bb4 bb1 - [5] Const mutate $5_@2 = JSX - Return read $5_@2 + [9] Const mutate $5_@2 = JSX + [10] Return read $5_@2 ``` ### CFG @@ -94,14 +94,14 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:4] = Array [] - [2] Const mutate b$3_@1[2:5] = Array [] + [1] Const mutate a$2_@0[1:5] = Array [] + [2] Const mutate b$3_@1[2:8] = Array [] "] bb0_instrs --> bb0_terminal(["If (read b$3_@1)"]) end subgraph bb2 bb2_instrs[" - [3] Call mutate a$2_@0.push(read props$1.p0) + [4] Call mutate a$2_@0.push(read props$1.p0) "] bb2_instrs --> bb2_terminal(["Goto"]) end @@ -110,13 +110,13 @@ flowchart TB end subgraph bb4 bb4_instrs[" - [4] Call mutate b$3_@1.push(read props$1.p2) + [7] Call mutate b$3_@1.push(read props$1.p2) "] bb4_instrs --> bb4_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [5] Const mutate $5_@2 = JSX + [9] Const mutate $5_@2 = JSX "] bb3_instrs --> bb3_terminal(["Return read $5_@2"]) end @@ -153,25 +153,25 @@ function Component$0(props$1) { ``` bb0: - [1] Const mutate a$2_@0[1:5] = Array [] - [2] Const mutate b$3_@1[0:6] = Array [] - [3] Const mutate $5_@1[0:6] = Call mutate mayMutate$4_@1(mutate b$3_@1) - If (read $5_@1) then:bb2 else:bb1 + [1] Const mutate a$2_@0[1:6] = Array [] + [2] Const mutate b$3_@1[0:9] = Array [] + [3] Const mutate $5_@1[0:9] = Call mutate mayMutate$4_@1(mutate b$3_@1) + [4] If (read $5_@1) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [4] Call mutate a$2_@0.push(read props$1.p0) - Goto bb1 + [5] Call mutate a$2_@0.push(read props$1.p0) + [6] Goto bb1 bb1: predecessor blocks: bb2 bb0 - If (read props$1.p1) then:bb4 else:bb3 + [7] If (read props$1.p1) then:bb4 else:bb3 bb4: predecessor blocks: bb1 - [5] Call mutate b$3_@1.push(read props$1.p2) - Goto bb3 + [8] Call mutate b$3_@1.push(read props$1.p2) + [9] Goto bb3 bb3: predecessor blocks: bb4 bb1 - [6] Const mutate $7_@2 = JSX - Return read $7_@2 + [10] Const mutate $7_@2 = JSX + [11] Return read $7_@2 ``` ### CFG @@ -181,15 +181,15 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[1:5] = Array [] - [2] Const mutate b$3_@1[0:6] = Array [] - [3] Const mutate $5_@1[0:6] = Call mutate mayMutate$4_@1(mutate b$3_@1) + [1] Const mutate a$2_@0[1:6] = Array [] + [2] Const mutate b$3_@1[0:9] = Array [] + [3] Const mutate $5_@1[0:9] = Call mutate mayMutate$4_@1(mutate b$3_@1) "] bb0_instrs --> bb0_terminal(["If (read $5_@1)"]) end subgraph bb2 bb2_instrs[" - [4] Call mutate a$2_@0.push(read props$1.p0) + [5] Call mutate a$2_@0.push(read props$1.p0) "] bb2_instrs --> bb2_terminal(["Goto"]) end @@ -198,13 +198,13 @@ flowchart TB end subgraph bb4 bb4_instrs[" - [5] Call mutate b$3_@1.push(read props$1.p2) + [8] Call mutate b$3_@1.push(read props$1.p2) "] bb4_instrs --> bb4_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [6] Const mutate $7_@2 = JSX + [10] Const mutate $7_@2 = JSX "] bb3_instrs --> bb3_terminal(["Return read $7_@2"]) end @@ -241,7 +241,7 @@ function Component$0(props$1) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -269,7 +269,7 @@ function Foo$0() { ``` bb0: - Return + [1] Return ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md b/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md index 4467730a6a..41488368b6 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md @@ -19,7 +19,7 @@ function Component(props) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -55,7 +55,7 @@ bb0: [6] New mutate Foo$4_@0(mutate b$3_@0) [7] Const mutate $7_@3 = "div" [8] Const mutate $8_@4 = JSX - Return read $8_@4 + [9] Return read $8_@4 ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md b/compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md index 43a28d14cd..0bf2f38fb3 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md @@ -22,7 +22,7 @@ bb0: [2] Const mutate b$2_@0[1:3] = read a$1_@0 [3] Call read useFreeze$3(freeze a$1_@0) [4] Call mutate foo$4_@1(read b$2_@0) - Return + [5] Return ``` ### CFG @@ -60,7 +60,7 @@ function Component$0() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -88,7 +88,7 @@ function useFreeze$0() { ``` bb0: - Return + [1] Return ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md b/compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md index dc414ede46..1715e03f4d 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md @@ -23,7 +23,7 @@ function Component(props) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -51,7 +51,7 @@ function useFreeze$0() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -86,7 +86,7 @@ bb0: [5] Const mutate $7_@4 = "\n " [6] Const mutate $8_@5 = "\n " [7] Const mutate $9_@6 = JSX {read $6_@3}{read x$2_@0}{read $7_@4}{read y$3_@1}{read $8_@5} - Return read $9_@6 + [8] Return read $9_@6 ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md b/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md index 1b8f615dcf..130f0a8d47 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md @@ -23,7 +23,7 @@ bb0: [2] Call read useFreeze$2(freeze a$1_@0) [3] Call read useFreeze$2(read a$1_@0) [4] Call mutate call$3_@1(read a$1_@0) - Return read a$1_@0 + [5] Return read a$1_@0 ``` ### CFG @@ -61,7 +61,7 @@ function Component$0() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -89,7 +89,7 @@ function useFreeze$0(x$1) { ``` bb0: - Return + [1] Return ``` ### CFG 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 084e23c528..df8c80b461 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 @@ -27,23 +27,23 @@ function call(x) {} ``` bb0: [1] Const mutate cond$2_@0 = read props$1.cond - [2] Const mutate x$3_@1[2:6] = read props$1.x + [2] Const mutate x$3_@1[2:8] = read props$1.x [3] Let mutate a$4_@2 = undefined - If (read cond$2_@0) then:bb2 else:bb3 + [4] If (read cond$2_@0) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [4] Reassign mutate a$4_@1[2:6] = read x$3_@1 - Goto bb1 + [5] Reassign mutate a$4_@1[2:8] = read x$3_@1 + [6] Goto bb1 bb3: predecessor blocks: bb0 - [5] Reassign mutate a$4_@1[2:6] = Array [] - Goto bb1 + [7] Reassign mutate a$4_@1[2:8] = Array [] + [8] Goto bb1 bb1: predecessor blocks: bb2 bb3 - [6] Call read useFreeze$5(freeze a$4_@1) - [7] Call read useFreeze$5(read a$4_@1) - [8] Call mutate call$6_@3(read a$4_@1) - Return read a$4_@1 + [9] Call read useFreeze$5(freeze a$4_@1) + [10] Call read useFreeze$5(read a$4_@1) + [11] Call mutate call$6_@3(read a$4_@1) + [12] Return read a$4_@1 ``` ### CFG @@ -54,28 +54,28 @@ flowchart TB subgraph bb0 bb0_instrs[" [1] Const mutate cond$2_@0 = read props$1.cond - [2] Const mutate x$3_@1[2:6] = read props$1.x + [2] Const mutate x$3_@1[2:8] = read props$1.x [3] Let mutate a$4_@2 = undefined "] bb0_instrs --> bb0_terminal(["If (read cond$2_@0)"]) end subgraph bb2 bb2_instrs[" - [4] Reassign mutate a$4_@1[2:6] = read x$3_@1 + [5] Reassign mutate a$4_@1[2:8] = read x$3_@1 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [5] Reassign mutate a$4_@1[2:6] = Array [] + [7] Reassign mutate a$4_@1[2:8] = Array [] "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [6] Call read useFreeze$5(freeze a$4_@1) - [7] Call read useFreeze$5(read a$4_@1) - [8] Call mutate call$6_@3(read a$4_@1) + [9] Call read useFreeze$5(freeze a$4_@1) + [10] Call read useFreeze$5(read a$4_@1) + [11] Call mutate call$6_@3(read a$4_@1) "] bb1_instrs --> bb1_terminal(["Return read a$4_@1"]) end @@ -113,7 +113,7 @@ function Component$0(props$1) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -141,7 +141,7 @@ function useFreeze$0(x$1) { ``` bb0: - Return + [1] Return ``` ### CFG 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 45421f6082..4f6d38e9d0 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 @@ -37,7 +37,7 @@ function Component(props) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -65,7 +65,7 @@ function compute$0() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -93,7 +93,7 @@ function mutate$0() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -121,7 +121,7 @@ function foo$0() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -149,18 +149,18 @@ function Foo$0() { ``` bb0: - [1] Const mutate a$2_@0[0:5] = Call mutate compute$3_@0(read props$1.a) - [2] Const mutate b$4_@0[0:5] = Call mutate compute$3_@0(read props$1.b) - If (read props$1.c) then:bb2 else:bb1 + [1] Const mutate a$2_@0[0:6] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:6] = Call mutate compute$3_@0(read props$1.b) + [3] If (read props$1.c) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [3] Call mutate mutate$5_@0(mutate a$2_@0) - [4] Call mutate mutate$5_@0(mutate b$4_@0) - Goto bb1 + [4] Call mutate mutate$5_@0(mutate a$2_@0) + [5] Call mutate mutate$5_@0(mutate b$4_@0) + [6] Goto bb1 bb1: predecessor blocks: bb2 bb0 - [5] Const mutate $7_@1 = JSX - Return read $7_@1 + [7] Const mutate $7_@1 = JSX + [8] Return read $7_@1 ``` ### CFG @@ -170,21 +170,21 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[0:5] = Call mutate compute$3_@0(read props$1.a) - [2] Const mutate b$4_@0[0:5] = Call mutate compute$3_@0(read props$1.b) + [1] Const mutate a$2_@0[0:6] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:6] = Call mutate compute$3_@0(read props$1.b) "] bb0_instrs --> bb0_terminal(["If (read props$1.c)"]) end subgraph bb2 bb2_instrs[" - [3] Call mutate mutate$5_@0(mutate a$2_@0) - [4] Call mutate mutate$5_@0(mutate b$4_@0) + [4] Call mutate mutate$5_@0(mutate a$2_@0) + [5] Call mutate mutate$5_@0(mutate b$4_@0) "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [5] Const mutate $7_@1 = JSX + [7] Const mutate $7_@1 = JSX "] bb1_instrs --> bb1_terminal(["Return read $7_@1"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md b/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md index 6bc9b61932..b4fdedcbdb 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/independent.expect.md @@ -31,7 +31,7 @@ bb0: [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] Const mutate $6_@1 = JSX - Return read $6_@1 + [4] Return read $6_@1 ``` ### CFG @@ -66,7 +66,7 @@ function Component$0(props$1) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -94,7 +94,7 @@ function compute$0() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -122,7 +122,7 @@ function foo$0() { ``` bb0: - Return + [1] Return ``` ### CFG 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 70b49172e6..59cb6ee5bc 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 @@ -31,7 +31,7 @@ function Component(props) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -59,7 +59,7 @@ function compute$0() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -87,7 +87,7 @@ function foo$0() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -115,17 +115,17 @@ function Foo$0() { ``` bb0: - [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 + [1] Const mutate a$2_@0[0:5] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:5] = Call mutate compute$3_@0(read props$1.b) + [3] If (read props$1.c) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [3] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0) - Goto bb1 + [4] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0) + [5] Goto bb1 bb1: predecessor blocks: bb2 bb0 - [4] Const mutate $7_@1 = JSX - Return read $7_@1 + [6] Const mutate $7_@1 = JSX + [7] Return read $7_@1 ``` ### CFG @@ -135,20 +135,20 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [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) + [1] Const mutate a$2_@0[0:5] = Call mutate compute$3_@0(read props$1.a) + [2] Const mutate b$4_@0[0:5] = Call mutate compute$3_@0(read props$1.b) "] bb0_instrs --> bb0_terminal(["If (read props$1.c)"]) end subgraph bb2 bb2_instrs[" - [3] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0) + [4] Call mutate foo$5_@0(mutate a$2_@0, mutate b$4_@0) "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [4] Const mutate $7_@1 = JSX + [6] Const mutate $7_@1 = JSX "] bb1_instrs --> bb1_terminal(["Return read $7_@1"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md b/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md index d4bc2bc7c6..4e883e0572 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/interdependent.expect.md @@ -32,7 +32,7 @@ bb0: [2] Const mutate b$4_@0[0:4] = 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 + [5] Return read $7_@1 ``` ### CFG @@ -69,7 +69,7 @@ function Component$0(props$1) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -97,7 +97,7 @@ function compute$0() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -125,7 +125,7 @@ function foo$0() { ``` bb0: - Return + [1] Return ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/jsx-fragment.expect.md b/compiler/forget/src/__tests__/fixtures/hir/jsx-fragment.expect.md index e13d450eb3..5c2a404163 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/jsx-fragment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/jsx-fragment.expect.md @@ -30,7 +30,7 @@ bb0: [9] Const mutate $10_@8 = JSX {read $6_@4}{read $8_@6}{read $9_@7} [10] Const mutate $11_@9 = "\n " [11] Const mutate $12_@10 = JsxFragment [read $2_@0, read props$1.greeting, read $3_@1, read $4_@2, read $10_@8, read $11_@9] - Return read $12_@10 + [12] Return read $12_@10 ``` ### CFG 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 86785b1c31..f43c094ce9 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md @@ -23,19 +23,19 @@ function g() {} ``` bb0: - [1] Const mutate $2_@0[0:4] = Call mutate f$1_@0() - If (read $2_@0) then:bb2 else:bb3 + [1] Const mutate $2_@0[0:6] = Call mutate f$1_@0() + [2] If (read $2_@0) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [2] Const mutate $3_@0[0:4] = Call mutate g$4_@0() - Goto bb1 + [3] Const mutate $3_@0[0:6] = Call mutate g$4_@0() + [4] Goto bb1 bb3: predecessor blocks: bb0 - [3] Const mutate $3_@0[0:4] = read $2_@0 - Goto bb1 + [5] Const mutate $3_@0[0:6] = read $2_@0 + [6] Goto bb1 bb1: predecessor blocks: bb2 bb3 - Return freeze $3_@0 + [7] Return freeze $3_@0 ``` ### CFG @@ -45,19 +45,19 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate $2_@0[0:4] = Call mutate f$1_@0() + [1] Const mutate $2_@0[0:6] = Call mutate f$1_@0() "] bb0_instrs --> bb0_terminal(["If (read $2_@0)"]) end subgraph bb2 bb2_instrs[" - [2] Const mutate $3_@0[0:4] = Call mutate g$4_@0() + [3] Const mutate $3_@0[0:6] = Call mutate g$4_@0() "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [3] Const mutate $3_@0[0:4] = read $2_@0 + [5] Const mutate $3_@0[0:6] = read $2_@0 "] bb3_instrs --> bb3_terminal(["Goto"]) end @@ -89,19 +89,19 @@ function And$0() { ``` bb0: - [1] Const mutate $2_@0[0:4] = Call mutate f$1_@0() - If (read $2_@0) then:bb2 else:bb3 + [1] Const mutate $2_@0[0:6] = Call mutate f$1_@0() + [2] If (read $2_@0) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [2] Const mutate $3_@0[0:4] = read $2_@0 - Goto bb1 + [3] Const mutate $3_@0[0:6] = read $2_@0 + [4] Goto bb1 bb3: predecessor blocks: bb0 - [3] Const mutate $3_@0[0:4] = Call mutate g$4_@0() - Goto bb1 + [5] Const mutate $3_@0[0:6] = Call mutate g$4_@0() + [6] Goto bb1 bb1: predecessor blocks: bb2 bb3 - Return freeze $3_@0 + [7] Return freeze $3_@0 ``` ### CFG @@ -111,19 +111,19 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate $2_@0[0:4] = Call mutate f$1_@0() + [1] Const mutate $2_@0[0:6] = Call mutate f$1_@0() "] bb0_instrs --> bb0_terminal(["If (read $2_@0)"]) end subgraph bb2 bb2_instrs[" - [2] Const mutate $3_@0[0:4] = read $2_@0 + [3] Const mutate $3_@0[0:6] = read $2_@0 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [3] Const mutate $3_@0[0:4] = Call mutate g$4_@0() + [5] Const mutate $3_@0[0:6] = Call mutate g$4_@0() "] bb3_instrs --> bb3_terminal(["Goto"]) end @@ -155,21 +155,21 @@ function Or$0() { ``` bb0: - [1] Const mutate $3_@0[0:6] = Call mutate f$2_@0() + [1] Const mutate $3_@0[0:8] = Call mutate f$2_@0() [2] Const mutate $4_@1 = null - [3] Const mutate $5_@0[0:6] = Binary read $3_@0 != read $4_@1 - If (read $5_@0) then:bb2 else:bb3 + [3] Const mutate $5_@0[0:8] = Binary read $3_@0 != read $4_@1 + [4] If (read $5_@0) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [4] Const mutate $6_@0[0:6] = read $3_@0 - Goto bb1 + [5] Const mutate $6_@0[0:8] = read $3_@0 + [6] Goto bb1 bb3: predecessor blocks: bb0 - [5] Const mutate $6_@0[0:6] = Call mutate g$7_@0() - Goto bb1 + [7] Const mutate $6_@0[0:8] = Call mutate g$7_@0() + [8] Goto bb1 bb1: predecessor blocks: bb2 bb3 - Return freeze $6_@0 + [9] Return freeze $6_@0 ``` ### CFG @@ -179,21 +179,21 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate $3_@0[0:6] = Call mutate f$2_@0() + [1] Const mutate $3_@0[0:8] = Call mutate f$2_@0() [2] Const mutate $4_@1 = null - [3] Const mutate $5_@0[0:6] = Binary read $3_@0 != read $4_@1 + [3] Const mutate $5_@0[0:8] = Binary read $3_@0 != read $4_@1 "] bb0_instrs --> bb0_terminal(["If (read $5_@0)"]) end subgraph bb2 bb2_instrs[" - [4] Const mutate $6_@0[0:6] = read $3_@0 + [5] Const mutate $6_@0[0:8] = read $3_@0 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [5] Const mutate $6_@0[0:6] = Call mutate g$7_@0() + [7] Const mutate $6_@0[0:8] = Call mutate g$7_@0() "] bb3_instrs --> bb3_terminal(["Goto"]) end @@ -225,7 +225,7 @@ function QuestionQuestion$0(props$1) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -253,7 +253,7 @@ function f$0() { ``` bb0: - Return + [1] Return ``` ### CFG 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 699467b00f..0c33327565 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 @@ -43,7 +43,7 @@ function Component(props) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -71,7 +71,7 @@ function mutate$0(x$1, y$2) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -99,45 +99,45 @@ function cond$0(x$1) { ``` bb0: - [1] Let mutate a$2_@0[0:15] = Object { } - [2] Let mutate b$3_@0[0:15] = Object { } - [3] Let mutate c$4_@0[0:15] = Object { } - [4] Let mutate d$5_@0[0:15] = Object { } - While test=bb1 loop=bb3 fallthrough=bb2 + [1] Let mutate a$2_@0[0:23] = Object { } + [2] Let mutate b$3_@0[0:23] = Object { } + [3] Let mutate c$4_@0[0:23] = Object { } + [4] Let mutate d$5_@0[0:23] = Object { } + [5] While test=bb1 loop=bb3 fallthrough=bb2 bb1: predecessor blocks: bb0 bb4 - [5] Const mutate $10_@1 = true - If (read $10_@1) then:bb3 else:bb2 + [6] Const mutate $10_@1 = true + [7] If (read $10_@1) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - [6] Let mutate z$6_@0[0:15] = read a$2_@0 - [7] Reassign mutate a$2_@0[0:15] = read b$3_@0 - [8] Reassign mutate b$3_@0[0:15] = read c$4_@0 - [9] Reassign mutate c$4_@0[0:15] = read d$5_@0 - [10] Reassign mutate d$5_@0[0:15] = read z$6_@0 - [11] Call mutate mutate$7_@0(mutate a$2_@0, mutate b$3_@0) - [12] Const mutate $9_@0[0:15] = Call mutate cond$8_@0(mutate a$2_@0) - If (read $9_@0) then:bb2 else:bb4 + [8] Let mutate z$6_@0[0:23] = read a$2_@0 + [9] Reassign mutate a$2_@0[0:23] = read b$3_@0 + [10] Reassign mutate b$3_@0[0:23] = read c$4_@0 + [11] Reassign mutate c$4_@0[0:23] = read d$5_@0 + [12] Reassign mutate d$5_@0[0:23] = read z$6_@0 + [13] Call mutate mutate$7_@0(mutate a$2_@0, mutate b$3_@0) + [14] Const mutate $9_@0[0:23] = Call mutate cond$8_@0(mutate a$2_@0) + [15] If (read $9_@0) then:bb2 else:bb4 bb4: predecessor blocks: bb3 - Goto(Continue) bb1 + [16] Goto(Continue) bb1 bb2: predecessor blocks: bb3 bb1 - If (read a$2_@0) then:bb7 else:bb7 + [17] If (read a$2_@0) then:bb7 else:bb7 bb7: predecessor blocks: bb2 - If (read b$3_@0) then:bb9 else:bb9 + [18] If (read b$3_@0) then:bb9 else:bb9 bb9: predecessor blocks: bb7 - If (read c$4_@0) then:bb11 else:bb11 + [19] If (read c$4_@0) then:bb11 else:bb11 bb11: predecessor blocks: bb9 - If (read d$5_@0) then:bb13 else:bb13 + [20] If (read d$5_@0) then:bb13 else:bb13 bb13: predecessor blocks: bb11 - [13] Const mutate $11_@2 = null - [14] Call mutate mutate$7_@0(mutate d$5_@0, read $11_@2) - Return + [21] Const mutate $11_@2 = null + [22] Call mutate mutate$7_@0(mutate d$5_@0, read $11_@2) + [23] Return ``` ### CFG @@ -147,28 +147,28 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate a$2_@0[0:15] = Object { } - [2] Let mutate b$3_@0[0:15] = Object { } - [3] Let mutate c$4_@0[0:15] = Object { } - [4] Let mutate d$5_@0[0:15] = Object { } + [1] Let mutate a$2_@0[0:23] = Object { } + [2] Let mutate b$3_@0[0:23] = Object { } + [3] Let mutate c$4_@0[0:23] = Object { } + [4] Let mutate d$5_@0[0:23] = Object { } "] bb0_instrs --> bb0_terminal(["While"]) end subgraph bb1 bb1_instrs[" - [5] Const mutate $10_@1 = true + [6] Const mutate $10_@1 = true "] bb1_instrs --> bb1_terminal(["If (read $10_@1)"]) end subgraph bb3 bb3_instrs[" - [6] Let mutate z$6_@0[0:15] = read a$2_@0 - [7] Reassign mutate a$2_@0[0:15] = read b$3_@0 - [8] Reassign mutate b$3_@0[0:15] = read c$4_@0 - [9] Reassign mutate c$4_@0[0:15] = read d$5_@0 - [10] Reassign mutate d$5_@0[0:15] = read z$6_@0 - [11] Call mutate mutate$7_@0(mutate a$2_@0, mutate b$3_@0) - [12] Const mutate $9_@0[0:15] = Call mutate cond$8_@0(mutate a$2_@0) + [8] Let mutate z$6_@0[0:23] = read a$2_@0 + [9] Reassign mutate a$2_@0[0:23] = read b$3_@0 + [10] Reassign mutate b$3_@0[0:23] = read c$4_@0 + [11] Reassign mutate c$4_@0[0:23] = read d$5_@0 + [12] Reassign mutate d$5_@0[0:23] = read z$6_@0 + [13] Call mutate mutate$7_@0(mutate a$2_@0, mutate b$3_@0) + [14] Const mutate $9_@0[0:23] = Call mutate cond$8_@0(mutate a$2_@0) "] bb3_instrs --> bb3_terminal(["If (read $9_@0)"]) end @@ -189,8 +189,8 @@ flowchart TB end subgraph bb13 bb13_instrs[" - [13] Const mutate $11_@2 = null - [14] Call mutate mutate$7_@0(mutate d$5_@0, read $11_@2) + [21] Const mutate $11_@2 = null + [22] Call mutate mutate$7_@0(mutate d$5_@0, read $11_@2) "] bb13_instrs --> bb13_terminal(["Return"]) 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 c167274a8f..2b7ba17595 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 @@ -39,7 +39,7 @@ function Component(props) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -70,28 +70,28 @@ 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[0:10] = Object { c: read c$4_@2 } - [5] Const mutate x$6_@3[0:10] = Object { } - [6] Reassign mutate x$6_@3.b[0:10] = read b$3_@1 - [7] Const mutate y$7_@3[0:10] = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3) - If (read a$2_@0) then:bb1 else:bb1 + [4] Const mutate d$5_@3[0:15] = Object { c: read c$4_@2 } + [5] Const mutate x$6_@3[0:15] = Object { } + [6] Reassign mutate x$6_@3.b[0:15] = read b$3_@1 + [7] Const mutate y$7_@3[0:15] = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3) + [8] If (read a$2_@0) then:bb1 else:bb1 bb1: predecessor blocks: bb0 - If (read b$3_@1) then:bb3 else:bb3 + [9] If (read b$3_@1) then:bb3 else:bb3 bb3: predecessor blocks: bb1 - If (read c$4_@2) then:bb5 else:bb5 + [10] If (read c$4_@2) then:bb5 else:bb5 bb5: predecessor blocks: bb3 - If (read d$5_@3) then:bb7 else:bb7 + [11] If (read d$5_@3) then:bb7 else:bb7 bb7: predecessor blocks: bb5 - If (read y$7_@3) then:bb9 else:bb9 + [12] If (read y$7_@3) then:bb9 else:bb9 bb9: predecessor blocks: bb7 - [8] Const mutate $9_@4 = null - [9] Call mutate mutate$8_@3(mutate x$6_@3, read $9_@4) - Return + [13] Const mutate $9_@4 = null + [14] Call mutate mutate$8_@3(mutate x$6_@3, read $9_@4) + [15] Return ``` ### CFG @@ -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[0:10] = Object { c: read c$4_@2 } - [5] Const mutate x$6_@3[0:10] = Object { } - [6] Reassign mutate x$6_@3.b[0:10] = read b$3_@1 - [7] Const mutate y$7_@3[0:10] = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3) + [4] Const mutate d$5_@3[0:15] = Object { c: read c$4_@2 } + [5] Const mutate x$6_@3[0:15] = Object { } + [6] Reassign mutate x$6_@3.b[0:15] = read b$3_@1 + [7] Const mutate y$7_@3[0:15] = Call mutate mutate$8_@3(mutate x$6_@3, mutate d$5_@3) "] bb0_instrs --> bb0_terminal(["If (read a$2_@0)"]) end @@ -125,8 +125,8 @@ flowchart TB end subgraph bb9 bb9_instrs[" - [8] Const mutate $9_@4 = null - [9] Call mutate mutate$8_@3(mutate x$6_@3, read $9_@4) + [13] Const mutate $9_@4 = null + [14] Call mutate mutate$8_@3(mutate x$6_@3, read $9_@4) "] bb9_instrs --> bb9_terminal(["Return"]) 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 b9cae73259..ff07c18c13 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 @@ -38,7 +38,7 @@ function Component(props) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -66,7 +66,7 @@ function mutate$0() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -94,40 +94,40 @@ function cond$0() { ``` bb0: - [1] Let mutate a$2_@0[0:10] = Object { } - [2] Let mutate b$3_@0[0:10] = Object { } + [1] Let mutate a$2_@0[0:18] = Object { } + [2] Let mutate b$3_@0[0:18] = Object { } [3] Let mutate c$4_@1 = Object { } - [4] Let mutate d$5_@0[0:10] = Object { } - While test=bb1 loop=bb3 fallthrough=bb2 + [4] Let mutate d$5_@0[0:18] = Object { } + [5] While test=bb1 loop=bb3 fallthrough=bb2 bb1: predecessor blocks: bb0 bb4 - [5] Const mutate $9_@2 = true - If (read $9_@2) then:bb3 else:bb2 + [6] Const mutate $9_@2 = true + [7] If (read $9_@2) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - [6] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0) - [7] Const mutate $8_@0[0:10] = Call mutate cond$7_@0(mutate a$2_@0) - If (read $8_@0) then:bb2 else:bb4 + [8] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0) + [9] Const mutate $8_@0[0:18] = Call mutate cond$7_@0(mutate a$2_@0) + [10] If (read $8_@0) then:bb2 else:bb4 bb4: predecessor blocks: bb3 - Goto(Continue) bb1 + [11] Goto(Continue) bb1 bb2: predecessor blocks: bb3 bb1 - If (read a$2_@0) then:bb7 else:bb7 + [12] If (read a$2_@0) then:bb7 else:bb7 bb7: predecessor blocks: bb2 - If (read b$3_@0) then:bb9 else:bb9 + [13] If (read b$3_@0) then:bb9 else:bb9 bb9: predecessor blocks: bb7 - If (read c$4_@1) then:bb11 else:bb11 + [14] If (read c$4_@1) then:bb11 else:bb11 bb11: predecessor blocks: bb9 - If (read d$5_@0) then:bb13 else:bb13 + [15] If (read d$5_@0) then:bb13 else:bb13 bb13: predecessor blocks: bb11 - [8] Const mutate $10_@3 = null - [9] Call mutate mutate$6_@0(mutate d$5_@0, read $10_@3) - Return + [16] Const mutate $10_@3 = null + [17] Call mutate mutate$6_@0(mutate d$5_@0, read $10_@3) + [18] Return ``` ### CFG @@ -137,23 +137,23 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate a$2_@0[0:10] = Object { } - [2] Let mutate b$3_@0[0:10] = Object { } + [1] Let mutate a$2_@0[0:18] = Object { } + [2] Let mutate b$3_@0[0:18] = Object { } [3] Let mutate c$4_@1 = Object { } - [4] Let mutate d$5_@0[0:10] = Object { } + [4] Let mutate d$5_@0[0:18] = Object { } "] bb0_instrs --> bb0_terminal(["While"]) end subgraph bb1 bb1_instrs[" - [5] Const mutate $9_@2 = true + [6] Const mutate $9_@2 = true "] bb1_instrs --> bb1_terminal(["If (read $9_@2)"]) end subgraph bb3 bb3_instrs[" - [6] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0) - [7] Const mutate $8_@0[0:10] = Call mutate cond$7_@0(mutate a$2_@0) + [8] Call mutate mutate$6_@0(mutate a$2_@0, mutate b$3_@0) + [9] Const mutate $8_@0[0:18] = Call mutate cond$7_@0(mutate a$2_@0) "] bb3_instrs --> bb3_terminal(["If (read $8_@0)"]) end @@ -174,8 +174,8 @@ flowchart TB end subgraph bb13 bb13_instrs[" - [8] Const mutate $10_@3 = null - [9] Call mutate mutate$6_@0(mutate d$5_@0, read $10_@3) + [16] Const mutate $10_@3 = null + [17] Call mutate mutate$6_@0(mutate d$5_@0, read $10_@3) "] bb13_instrs --> bb13_terminal(["Return"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md b/compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md index 5d88311655..e031847531 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md @@ -23,7 +23,7 @@ bb0: [4] Const mutate child$4_@2 = JSX [5] Call mutate x$2_@0.y.push(read props$1.p0) [6] Const mutate $5_@3 = JSX {read child$4_@2} - Return read $5_@3 + [7] Return read $5_@3 ``` ### CFG 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 8389b0cfb9..19fa3f39a3 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 @@ -23,7 +23,7 @@ bb0: [3] Let mutate z$3_@1[2:5] = Object { } [4] Call mutate y$2_@1.push(mutate z$3_@1) [5] Reassign mutate x$1_@0.y[1:6] = read y$2_@1 - Return freeze x$1_@0 + [6] Return freeze x$1_@0 ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md index 4aebcf1e91..5e0025493b 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md @@ -19,22 +19,22 @@ function f(a, b) { ``` bb0: - [1] Let mutate x$3_@0[1:5] = Array [] + [1] Let mutate x$3_@0[1:7] = Array [] [2] Const mutate $4_@1 = 1 [3] Const mutate $5_@2 = Binary read a$1.length === read $4_@1 - If (read $5_@2) then:bb2 else:bb1 + [4] If (read $5_@2) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - If (read b$2) then:bb4 else:bb1 + [5] If (read b$2) then:bb4 else:bb1 bb4: predecessor blocks: bb2 - [4] Call mutate x$3_@0.push(read b$2) - Goto bb1 + [6] Call mutate x$3_@0.push(read b$2) + [7] Goto bb1 bb1: predecessor blocks: bb4 bb2 bb0 - [5] Const mutate $6_@3 = "div" - [6] Const mutate $7_@4 = JSX {freeze x$3_@0} - Return read $7_@4 + [8] Const mutate $6_@3 = "div" + [9] Const mutate $7_@4 = JSX {freeze x$3_@0} + [10] Return read $7_@4 ``` ### CFG @@ -44,7 +44,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$3_@0[1:5] = Array [] + [1] Let mutate x$3_@0[1:7] = Array [] [2] Const mutate $4_@1 = 1 [3] Const mutate $5_@2 = Binary read a$1.length === read $4_@1 "] @@ -55,14 +55,14 @@ flowchart TB end subgraph bb4 bb4_instrs[" - [4] Call mutate x$3_@0.push(read b$2) + [6] Call mutate x$3_@0.push(read b$2) "] bb4_instrs --> bb4_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [5] Const mutate $6_@3 = 'div' - [6] Const mutate $7_@4 = JSX {freeze x$3_@0} + [8] Const mutate $6_@3 = 'div' + [9] Const mutate $7_@4 = JSX {freeze x$3_@0} "] bb1_instrs --> bb1_terminal(["Return read $7_@4"]) 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 6a5a5e635f..9d2c474b08 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md @@ -23,20 +23,20 @@ function Component(props) { ``` bb0: - [1] Let mutate x$2_@0[1:5] = Array [] + [1] Let mutate x$2_@0[1:6] = Array [] [2] Call mutate x$2_@0.push(read props$1.p0) - [3] Let mutate y$3_@0[1:5] = read x$2_@0 - If (read props$1.p1) then:bb2 else:bb1 + [3] Let mutate y$3_@0[1:6] = read x$2_@0 + [4] If (read props$1.p1) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [4] Reassign mutate x$2_@0[1:5] = Array [] - Goto bb1 + [5] Reassign mutate x$2_@0[1:6] = Array [] + [6] Goto bb1 bb1: predecessor blocks: bb2 bb0 - [5] Let mutate _$4_@1 = JSX - [6] Call read y$3_@0.push(read props$1.p2) - [7] Const mutate $5_@2 = JSX - Return read $5_@2 + [7] Let mutate _$4_@1 = JSX + [8] Call read y$3_@0.push(read props$1.p2) + [9] Const mutate $5_@2 = JSX + [10] Return read $5_@2 ``` ### CFG @@ -46,23 +46,23 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$2_@0[1:5] = Array [] + [1] Let mutate x$2_@0[1:6] = Array [] [2] Call mutate x$2_@0.push(read props$1.p0) - [3] Let mutate y$3_@0[1:5] = read x$2_@0 + [3] Let mutate y$3_@0[1:6] = read x$2_@0 "] bb0_instrs --> bb0_terminal(["If (read props$1.p1)"]) end subgraph bb2 bb2_instrs[" - [4] Reassign mutate x$2_@0[1:5] = Array [] + [5] Reassign mutate x$2_@0[1:6] = Array [] "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [5] Let mutate _$4_@1 = JSX - [6] Call read y$3_@0.push(read props$1.p2) - [7] Const mutate $5_@2 = JSX + [7] Let mutate _$4_@1 = JSX + [8] Call read y$3_@0.push(read props$1.p2) + [9] Const mutate $5_@2 = JSX "] bb1_instrs --> bb1_terminal(["Return read $5_@2"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md index 78db5eb2ae..81e0930c9e 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md @@ -28,7 +28,7 @@ bb0: [5] Let mutate _$4_@2 = JSX [6] Call mutate y$3_@0.push(read props$1.p1) [7] Const mutate $5_@3 = JSX - Return read $5_@3 + [8] Return read $5_@3 ``` ### CFG 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 8e7abb64b8..1472a45216 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md @@ -37,44 +37,44 @@ function Component(props) { ``` bb0: [1] Let mutate x$2_@0 = undefined - If (read props$1.cond) then:bb2 else:bb10 + [2] If (read props$1.cond) then:bb2 else:bb10 bb2: predecessor blocks: bb0 - [2] Const mutate $3_@1 = 2 - [3] Const mutate $4_@2 = 1 - [4] Const mutate $5_@3 = 0 - Switch (read props$1.test) + [3] Const mutate $3_@1 = 2 + [4] Const mutate $4_@2 = 1 + [5] Const mutate $5_@3 = 0 + [6] Switch (read props$1.test) Case read $5_@3: bb8 Case read $4_@2: bb6 Case read $3_@1: bb4 Default: bb4 bb8: predecessor blocks: bb2 - [5] Reassign mutate x$2_@4[5:10] = read props$1.v0 - Goto bb1 + [7] Reassign mutate x$2_@4[7:17] = read props$1.v0 + [8] Goto bb1 bb6: predecessor blocks: bb2 - [6] Reassign mutate x$2_@4[5:10] = read props$1.v1 - Goto bb1 + [9] Reassign mutate x$2_@4[7:17] = read props$1.v1 + [10] Goto bb1 bb4: predecessor blocks: bb2 - [7] Reassign mutate x$2_@4[5:10] = read props$1.v2 - Goto bb1 + [11] Reassign mutate x$2_@4[7:17] = read props$1.v2 + [12] Goto bb1 bb10: predecessor blocks: bb0 - If (read props$1.cond2) then:bb12 else:bb13 + [13] If (read props$1.cond2) then:bb12 else:bb13 bb12: predecessor blocks: bb10 - [8] Reassign mutate x$2_@4[5:10] = read props$1.b - Goto bb1 + [14] Reassign mutate x$2_@4[7:17] = read props$1.b + [15] Goto bb1 bb13: predecessor blocks: bb10 - [9] Reassign mutate x$2_@4[5:10] = read props$1.c - Goto bb1 + [16] Reassign mutate x$2_@4[7:17] = read props$1.c + [17] Goto bb1 bb1: predecessor blocks: bb8 bb6 bb4 bb12 bb13 - [10] read x$2_@4 - Return + [18] read x$2_@4 + [19] Return ``` ### CFG @@ -90,27 +90,27 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [2] Const mutate $3_@1 = 2 - [3] Const mutate $4_@2 = 1 - [4] Const mutate $5_@3 = 0 + [3] Const mutate $3_@1 = 2 + [4] Const mutate $4_@2 = 1 + [5] Const mutate $5_@3 = 0 "] bb2_instrs --> bb2_terminal(["Switch (read props$1.test)"]) end subgraph bb8 bb8_instrs[" - [5] Reassign mutate x$2_@4[5:10] = read props$1.v0 + [7] Reassign mutate x$2_@4[7:17] = read props$1.v0 "] bb8_instrs --> bb8_terminal(["Goto"]) end subgraph bb6 bb6_instrs[" - [6] Reassign mutate x$2_@4[5:10] = read props$1.v1 + [9] Reassign mutate x$2_@4[7:17] = read props$1.v1 "] bb6_instrs --> bb6_terminal(["Goto"]) end subgraph bb4 bb4_instrs[" - [7] Reassign mutate x$2_@4[5:10] = read props$1.v2 + [11] Reassign mutate x$2_@4[7:17] = 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_@4[5:10] = read props$1.b + [14] Reassign mutate x$2_@4[7:17] = read props$1.b "] bb12_instrs --> bb12_terminal(["Goto"]) end subgraph bb13 bb13_instrs[" - [9] Reassign mutate x$2_@4[5:10] = read props$1.c + [16] Reassign mutate x$2_@4[7:17] = read props$1.c "] bb13_instrs --> bb13_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [10] read x$2_@4 + [18] read x$2_@4 "] bb1_instrs --> bb1_terminal(["Return"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/simple-alias.expect.md b/compiler/forget/src/__tests__/fixtures/hir/simple-alias.expect.md index 8f9acd8388..fd7bf6164a 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/simple-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/simple-alias.expect.md @@ -20,7 +20,7 @@ function foo() { ``` bb0: - Return + [1] Return ``` ### CFG @@ -55,7 +55,7 @@ bb0: [5] Reassign mutate b$2_@1[0:8] = read c$3_@1 [6] Reassign mutate c$3_@1[0:8] = read a$1_@1 [7] Call mutate mutate$4_@1(mutate a$1_@1, mutate b$2_@1) - Return freeze c$3_@1 + [8] Return freeze c$3_@1 ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md b/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md index 69312a536a..bb3ad65ec5 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md @@ -15,18 +15,18 @@ function foo(x, y) { ``` bb0: - If (read x$1) then:bb2 else:bb1 + [1] If (read x$1) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [1] Const mutate $3_@0 = false - [2] Const mutate $4_@1 = Call read foo$0(read $3_@0, read y$2) - Return freeze $4_@1 + [2] Const mutate $3_@0 = false + [3] Const mutate $4_@1 = Call read foo$0(read $3_@0, read y$2) + [4] Return freeze $4_@1 bb1: predecessor blocks: bb0 - [3] Const mutate $5_@2 = 10 - [4] Const mutate $6_@3 = Binary read y$2 * read $5_@2 - [5] Const mutate $7_@4 = Array [read $6_@3] - Return freeze $7_@4 + [5] Const mutate $5_@2 = 10 + [6] Const mutate $6_@3 = Binary read y$2 * read $5_@2 + [7] Const mutate $7_@4 = Array [read $6_@3] + [8] Return freeze $7_@4 ``` ### CFG @@ -39,16 +39,16 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [1] Const mutate $3_@0 = false - [2] Const mutate $4_@1 = Call read foo$0(read $3_@0, read y$2) + [2] Const mutate $3_@0 = false + [3] Const mutate $4_@1 = Call read foo$0(read $3_@0, read y$2) "] bb2_instrs --> bb2_terminal(["Return freeze $4_@1"]) end subgraph bb1 bb1_instrs[" - [3] Const mutate $5_@2 = 10 - [4] Const mutate $6_@3 = Binary read y$2 * read $5_@2 - [5] Const mutate $7_@4 = Array [read $6_@3] + [5] Const mutate $5_@2 = 10 + [6] Const mutate $6_@3 = Binary read y$2 * read $5_@2 + [7] Const mutate $7_@4 = Array [read $6_@3] "] bb1_instrs --> bb1_terminal(["Return freeze $7_@4"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md index 99312b133f..a6eec519ed 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md @@ -18,7 +18,7 @@ bb0: [1] Const mutate a$2_@0 = 1 [2] Const mutate b$3_@1 = 2 [3] Const mutate x$4_@2 = Array [read a$2_@0, read b$3_@1] - Return freeze x$4_@2 + [4] Return freeze x$4_@2 ``` ### CFG 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 b1b98a51f7..9aa475d850 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 @@ -22,7 +22,7 @@ function Component(props) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -50,22 +50,22 @@ function foo$0() { ``` bb0: - [1] Const mutate a$2_@0[0:8] = Array [] - [2] Const mutate b$3_@0[0:8] = Object { } + [1] Const mutate a$2_@0[0:10] = Array [] + [2] Const mutate b$3_@0[0:10] = Object { } [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0) - [4] Const mutate $7_@0[0:8] = Call mutate foo$4_@0() - If (read $7_@0) then:bb2 else:bb1 + [4] Const mutate $7_@0[0:10] = Call mutate foo$4_@0() + [5] If (read $7_@0) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [5] Const mutate $6_@1 = "div" - [6] Let mutate _$5_@2 = JSX - Goto bb1 + [6] Const mutate $6_@1 = "div" + [7] Let mutate _$5_@2 = JSX + [8] Goto bb1 bb1: predecessor blocks: bb2 bb0 - [7] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0) - [8] Const mutate $8_@3 = "div" - [9] Const mutate $9_@4 = JSX - Return read $9_@4 + [9] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0) + [10] Const mutate $8_@3 = "div" + [11] Const mutate $9_@4 = JSX + [12] Return read $9_@4 ``` ### CFG @@ -75,25 +75,25 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Const mutate a$2_@0[0:8] = Array [] - [2] Const mutate b$3_@0[0:8] = Object { } + [1] Const mutate a$2_@0[0:10] = Array [] + [2] Const mutate b$3_@0[0:10] = Object { } [3] Call mutate foo$4_@0(mutate a$2_@0, mutate b$3_@0) - [4] Const mutate $7_@0[0:8] = Call mutate foo$4_@0() + [4] Const mutate $7_@0[0:10] = Call mutate foo$4_@0() "] bb0_instrs --> bb0_terminal(["If (read $7_@0)"]) end subgraph bb2 bb2_instrs[" - [5] Const mutate $6_@1 = 'div' - [6] Let mutate _$5_@2 = JSX + [6] Const mutate $6_@1 = 'div' + [7] Let mutate _$5_@2 = JSX "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [7] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0) - [8] Const mutate $8_@3 = 'div' - [9] Const mutate $9_@4 = JSX + [9] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0) + [10] Const mutate $8_@3 = 'div' + [11] Const mutate $9_@4 = JSX "] bb1_instrs --> bb1_terminal(["Return read $9_@4"]) 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 f5477614f4..d0e082fb0d 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 @@ -19,7 +19,7 @@ function Component(props) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -55,7 +55,7 @@ bb0: [6] Call mutate foo$4_@0(read a$2_@0, mutate b$3_@0) [7] Const mutate $7_@3 = "div" [8] Const mutate $8_@4 = JSX - Return read $8_@4 + [9] Return read $8_@4 ``` ### CFG 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 d7e856639a..ce6ba4d3e7 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,28 +21,28 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0[1:10] = 1 + [1] Let mutate x$1_@0[1:14] = 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 + [5] If (read $4_@3) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [5] Reassign mutate x$1_@0[1:10] = 3 - Goto bb1 + [6] Reassign mutate x$1_@0[1:14] = 3 + [7] Goto bb1 bb1: predecessor blocks: bb2 bb0 - [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 + [8] Const mutate $5_@4 = 3 + [9] Const mutate $6_@5 = Binary read y$2_@1 === read $5_@4 + [10] If (read $6_@5) then:bb4 else:bb3 bb4: predecessor blocks: bb1 - [8] Reassign mutate x$1_@0[1:10] = 5 - Goto bb3 + [11] Reassign mutate x$1_@0[1:14] = 5 + [12] Goto bb3 bb3: predecessor blocks: bb4 bb1 - [9] Reassign mutate y$2_@0[1:10] = read x$1_@0 - Return + [13] Reassign mutate y$2_@0[1:14] = read x$1_@0 + [14] Return ``` ### CFG @@ -52,7 +52,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0[1:10] = 1 + [1] Let mutate x$1_@0[1:14] = 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,26 +61,26 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [5] Reassign mutate x$1_@0[1:10] = 3 + [6] Reassign mutate x$1_@0[1:14] = 3 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [6] Const mutate $5_@4 = 3 - [7] Const mutate $6_@5 = Binary read y$2_@1 === read $5_@4 + [8] Const mutate $5_@4 = 3 + [9] Const mutate $6_@5 = Binary read y$2_@1 === read $5_@4 "] bb1_instrs --> bb1_terminal(["If (read $6_@5)"]) end subgraph bb4 bb4_instrs[" - [8] Reassign mutate x$1_@0[1:10] = 5 + [11] Reassign mutate x$1_@0[1:14] = 5 "] bb4_instrs --> bb4_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [9] Reassign mutate y$2_@0[1:10] = read x$1_@0 + [13] Reassign mutate y$2_@0[1:14] = 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 8f2dd4a38f..d1e93fa453 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,19 +18,19 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0[1:7] = 1 + [1] Let mutate x$1_@0[1:9] = 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 + [5] If (read $4_@3) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [5] Reassign mutate x$1_@0[1:7] = 3 - Goto bb1 + [6] Reassign mutate x$1_@0[1:9] = 3 + [7] Goto bb1 bb1: predecessor blocks: bb2 bb0 - [6] Reassign mutate y$2_@0[1:7] = read x$1_@0 - Return + [8] Reassign mutate y$2_@0[1:9] = read x$1_@0 + [9] Return ``` ### CFG @@ -40,7 +40,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0[1:7] = 1 + [1] Let mutate x$1_@0[1:9] = 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,13 +49,13 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [5] Reassign mutate x$1_@0[1:7] = 3 + [6] Reassign mutate x$1_@0[1:9] = 3 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [6] Reassign mutate y$2_@0[1:7] = read x$1_@0 + [8] Reassign mutate y$2_@0[1:9] = read x$1_@0 "] bb1_instrs --> bb1_terminal(["Return"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md index 2507800766..c88d948b68 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md @@ -20,24 +20,24 @@ function foo(cond) { ``` bb0: [1] Let mutate items$2_@0 = Array [] - Goto bb1 + [2] Goto bb1 bb1: predecessor blocks: bb0 bb4 - If (read items$2_@0) then:bb3 else:bb2 + [3] If (read items$2_@0) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - [2] Let mutate y$3_@1 = 0 - If (read cond$1) then:bb5 else:bb4 + [4] Let mutate y$3_@1 = 0 + [5] If (read cond$1) then:bb5 else:bb4 bb5: predecessor blocks: bb3 - [3] Reassign mutate y$3_@2 = 1 - Goto bb4 + [6] Reassign mutate y$3_@2 = 1 + [7] Goto bb4 bb4: predecessor blocks: bb5 bb3 - Goto(Continue) bb1 + [8] Goto(Continue) bb1 bb2: predecessor blocks: bb1 - Return freeze items$2_@0 + [9] Return freeze items$2_@0 ``` ### CFG @@ -56,13 +56,13 @@ flowchart TB end subgraph bb3 bb3_instrs[" - [2] Let mutate y$3_@1 = 0 + [4] Let mutate y$3_@1 = 0 "] bb3_instrs --> bb3_terminal(["If (read cond$1)"]) end subgraph bb5 bb5_instrs[" - [3] Reassign mutate y$3_@2 = 1 + [6] Reassign mutate y$3_@2 = 1 "] bb5_instrs --> bb5_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 7440221c1d..cd31c69c2d 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md @@ -16,21 +16,21 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0[0:6] = 0 - Goto bb1 + [1] Let mutate x$1_@0[0:8] = 0 + [2] Goto bb1 bb1: predecessor blocks: bb0 bb4 - [2] Const mutate $3_@1 = 10 - [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 - If (read $4_@2) then:bb4 else:bb2 + [3] Const mutate $3_@1 = 10 + [4] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 + [5] If (read $4_@2) then:bb4 else:bb2 bb4: predecessor blocks: bb1 - [4] Const mutate $2_@3 = 1 - [5] Reassign mutate x$1_@0[0:6] = Binary read x$1_@0 + read $2_@3 - Goto(Continue) bb1 + [6] Const mutate $2_@3 = 1 + [7] Reassign mutate x$1_@0[0:8] = Binary read x$1_@0 + read $2_@3 + [8] Goto(Continue) bb1 bb2: predecessor blocks: bb1 - Return read x$1_@0 + [9] Return read x$1_@0 ``` ### CFG @@ -40,21 +40,21 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0[0:6] = 0 + [1] Let mutate x$1_@0[0:8] = 0 "] bb0_instrs --> bb0_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [2] Const mutate $3_@1 = 10 - [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 + [3] Const mutate $3_@1 = 10 + [4] 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_@0[0:6] = Binary read x$1_@0 + read $2_@3 + [6] Const mutate $2_@3 = 1 + [7] Reassign mutate x$1_@0[0:8] = Binary read x$1_@0 + read $2_@3 "] bb4_instrs --> bb4_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md index 00688d144f..32c02aeaef 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md @@ -19,20 +19,20 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0[1:5] = 1 + [1] Let mutate x$1_@0[1:7] = 1 [2] Let mutate y$2_@1 = 2 - If (read y$2_@1) then:bb2 else:bb3 + [3] If (read y$2_@1) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [3] Let mutate z$3_@0[1:5] = Binary read x$1_@0 + read y$2_@1 - Goto bb1 + [4] Let mutate z$3_@0[1:7] = Binary read x$1_@0 + read y$2_@1 + [5] Goto bb1 bb3: predecessor blocks: bb0 - [4] Let mutate z$4_@0[1:5] = read x$1_@0 - Goto bb1 + [6] Let mutate z$4_@0[1:7] = read x$1_@0 + [7] Goto bb1 bb1: predecessor blocks: bb2 bb3 - Return + [8] Return ``` ### CFG @@ -42,20 +42,20 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0[1:5] = 1 + [1] Let mutate x$1_@0[1:7] = 1 [2] Let mutate y$2_@1 = 2 "] bb0_instrs --> bb0_terminal(["If (read y$2_@1)"]) end subgraph bb2 bb2_instrs[" - [3] Let mutate z$3_@0[1:5] = Binary read x$1_@0 + read y$2_@1 + [4] Let mutate z$3_@0[1:7] = Binary read x$1_@0 + read y$2_@1 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [4] Let mutate z$4_@0[1:5] = read x$1_@0 + [6] Let mutate z$4_@0[1:7] = read x$1_@0 "] bb3_instrs --> bb3_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-loops-no-reassign.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-loops-no-reassign.expect.md index 71547e40d8..31c89eb3cc 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-loops-no-reassign.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-loops-no-reassign.expect.md @@ -22,36 +22,36 @@ function foo(a, b, c) { ``` bb0: [1] Let mutate x$4_@0 = 0 - While test=bb1 loop=bb3 fallthrough=bb2 + [2] While test=bb1 loop=bb3 fallthrough=bb2 bb1: predecessor blocks: bb0 bb5 - If (read a$1) then:bb3 else:bb2 + [3] If (read a$1) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - While test=bb4 loop=bb6 fallthrough=bb5 + [4] While test=bb4 loop=bb6 fallthrough=bb5 bb4: predecessor blocks: bb3 bb8 - If (read b$2) then:bb6 else:bb5 + [5] If (read b$2) then:bb6 else:bb5 bb6: predecessor blocks: bb4 - While test=bb7 loop=bb9 fallthrough=bb8 + [6] While test=bb7 loop=bb9 fallthrough=bb8 bb7: predecessor blocks: bb6 bb9 - If (read c$3) then:bb9 else:bb8 + [7] If (read c$3) then:bb9 else:bb8 bb9: predecessor blocks: bb7 - [2] Const mutate $5_@1 = 1 - [3] Binary read x$4_@0 + read $5_@1 - Goto(Continue) bb7 + [8] Const mutate $5_@1 = 1 + [9] Binary read x$4_@0 + read $5_@1 + [10] Goto(Continue) bb7 bb8: predecessor blocks: bb7 - Goto(Continue) bb4 + [11] Goto(Continue) bb4 bb5: predecessor blocks: bb4 - Goto(Continue) bb1 + [12] Goto(Continue) bb1 bb2: predecessor blocks: bb1 - Return read x$4_@0 + [13] Return read x$4_@0 ``` ### CFG @@ -82,8 +82,8 @@ flowchart TB end subgraph bb9 bb9_instrs[" - [2] Const mutate $5_@1 = 1 - [3] Binary read x$4_@0 + read $5_@1 + [8] Const mutate $5_@1 = 1 + [9] Binary read x$4_@0 + read $5_@1 "] bb9_instrs --> bb9_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 19ad34f4ee..60a8a93034 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md @@ -17,7 +17,7 @@ function Component(props) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -48,7 +48,7 @@ bb0: [1] Const mutate a$2_@0[0:4] = Array [] [2] Const mutate b$3_@0[0:4] = Object { } [3] Let mutate c$4_@0[0:4] = New mutate Foo$5_@0(mutate a$2_@0, mutate b$3_@0) - Return freeze c$4_@0 + [4] Return freeze c$4_@0 ``` ### CFG 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 2a846d7a0e..70afd267b5 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,23 +22,23 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0[1:6] = 1 - [2] Let mutate y$2_@1[2:7] = 2 + [1] Let mutate x$1_@0[1:7] = 1 + [2] Let mutate y$2_@1[2:9] = 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 + [5] If (read $4_@3) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [5] Reassign mutate x$1_@0[1:6] = 2 - Goto bb1 + [6] Reassign mutate x$1_@0[1:7] = 2 + [7] Goto bb1 bb3: predecessor blocks: bb0 - [6] Reassign mutate y$2_@1[2:7] = 3 - Goto bb1 + [8] Reassign mutate y$2_@1[2:9] = 3 + [9] Goto bb1 bb1: predecessor blocks: bb2 bb3 - [7] Let mutate t$5_@4 = Object { x: read x$1_@0, y: read y$2_@1 } - Return freeze t$5_@4 + [10] Let mutate t$5_@4 = Object { x: read x$1_@0, y: read y$2_@1 } + [11] Return freeze t$5_@4 ``` ### CFG @@ -48,8 +48,8 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0[1:6] = 1 - [2] Let mutate y$2_@1[2:7] = 2 + [1] Let mutate x$1_@0[1:7] = 1 + [2] Let mutate y$2_@1[2:9] = 2 [3] Const mutate $3_@2 = 1 [4] Const mutate $4_@3 = Binary read x$1_@0 > read $3_@2 "] @@ -57,19 +57,19 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [5] Reassign mutate x$1_@0[1:6] = 2 + [6] Reassign mutate x$1_@0[1:7] = 2 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [6] Reassign mutate y$2_@1[2:7] = 3 + [8] Reassign mutate y$2_@1[2:9] = 3 "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [7] Let mutate t$5_@4 = Object { x: read x$1_@0, y: read y$2_@1 } + [10] Let mutate t$5_@4 = Object { x: read x$1_@0, y: read y$2_@1 } "] bb1_instrs --> bb1_terminal(["Return freeze t$5_@4"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md index 2517930984..deb27b9598 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md @@ -18,7 +18,7 @@ bb0: [1] Const mutate a$2_@0 = 1 [2] Const mutate b$3_@1 = 2 [3] Const mutate x$4_@2 = Object { a: read a$2_@0, b: read b$3_@1 } - Return freeze x$4_@2 + [4] Return freeze x$4_@2 ``` ### CFG 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 15ae6da94b..dccb3b3ee7 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 @@ -19,7 +19,7 @@ bb0: [2] Const mutate y$2_@1[2:5] = Object { x: read x$1_@0 } [3] Const mutate $3_@1[2:5] = Array [] [4] Call mutate y$2_@1.x.push(mutate $3_@1) - Return freeze y$2_@1 + [5] Return freeze y$2_@1 ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md index 5ac77c2a8f..70abb55ed0 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md @@ -18,7 +18,7 @@ bb0: [1] Const mutate x$1_@0 = Array [] [2] Const mutate y$2_@1[2:4] = Object { } [3] Reassign mutate y$2_@1.x[2:4] = read x$1_@0 - Return freeze y$2_@1 + [4] Return freeze y$2_@1 ``` ### CFG 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 73985795ae..bc98518b21 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md @@ -17,17 +17,17 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0[1:5] = 1 + [1] Let mutate x$1_@0[1:6] = 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 + [4] If (read $3_@2) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [4] Reassign mutate x$1_@0[1:5] = 2 - Goto bb1 + [5] Reassign mutate x$1_@0[1:6] = 2 + [6] Goto bb1 bb1: predecessor blocks: bb2 bb0 - Return read x$1_@0 + [7] Return read x$1_@0 ``` ### CFG @@ -37,7 +37,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0[1:5] = 1 + [1] Let mutate x$1_@0[1:6] = 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[1:5] = 2 + [5] Reassign mutate x$1_@0[1:6] = 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 d473a25c5b..99e74cf121 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md @@ -21,7 +21,7 @@ function Foo(cond) { ``` bb0: - Return + [1] Return ``` ### CFG @@ -49,21 +49,21 @@ function log$0() { ``` bb0: - [1] Let mutate str$2_@0[1:5] = "" - If (read cond$1) then:bb2 else:bb3 + [1] Let mutate str$2_@0[1:7] = "" + [2] If (read cond$1) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [2] Let mutate str$3_@1 = "other test" - [3] Call mutate log$4_@2(read str$3_@1) - Goto bb1 + [3] Let mutate str$3_@1 = "other test" + [4] Call mutate log$4_@2(read str$3_@1) + [5] Goto bb1 bb3: predecessor blocks: bb0 - [4] Reassign mutate str$2_@0[1:5] = "fallthrough test" - Goto bb1 + [6] Reassign mutate str$2_@0[1:7] = "fallthrough test" + [7] Goto bb1 bb1: predecessor blocks: bb2 bb3 - [5] Call mutate log$4_@2(read str$2_@0) - Return + [8] Call mutate log$4_@2(read str$2_@0) + [9] Return ``` ### CFG @@ -73,26 +73,26 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate str$2_@0[1:5] = '' + [1] Let mutate str$2_@0[1:7] = '' "] bb0_instrs --> bb0_terminal(["If (read cond$1)"]) end subgraph bb2 bb2_instrs[" - [2] Let mutate str$3_@1 = 'other test' - [3] Call mutate log$4_@2(read str$3_@1) + [3] Let mutate str$3_@1 = 'other test' + [4] Call mutate log$4_@2(read str$3_@1) "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [4] Reassign mutate str$2_@0[1:5] = 'fallthrough test' + [6] Reassign mutate str$2_@0[1:7] = 'fallthrough test' "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [5] Call mutate log$4_@2(read str$2_@0) + [8] 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 e03c54d741..e260f6aa7f 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 @@ -23,19 +23,19 @@ bb0: [1] Let mutate y$1_@0 = 2 [2] Const mutate $2_@1 = 1 [3] Const mutate $3_@2 = Binary read y$1_@0 > read $2_@1 - If (read $3_@2) then:bb2 else:bb3 + [4] If (read $3_@2) then:bb2 else:bb3 bb2: predecessor blocks: bb0 - [4] Reassign mutate y$1_@3[4:7] = 1 - Goto bb1 + [5] Reassign mutate y$1_@3[5:10] = 1 + [6] Goto bb1 bb3: predecessor blocks: bb0 - [5] Reassign mutate y$1_@3[4:7] = 2 - Goto bb1 + [7] Reassign mutate y$1_@3[5:10] = 2 + [8] Goto bb1 bb1: predecessor blocks: bb2 bb3 - [6] Let mutate x$4_@3[4:7] = read y$1_@3 - Return + [9] Let mutate x$4_@3[5:10] = read y$1_@3 + [10] Return ``` ### CFG @@ -53,19 +53,19 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [4] Reassign mutate y$1_@3[4:7] = 1 + [5] Reassign mutate y$1_@3[5:10] = 1 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [5] Reassign mutate y$1_@3[4:7] = 2 + [7] Reassign mutate y$1_@3[5:10] = 2 "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [6] Let mutate x$4_@3[4:7] = read y$1_@3 + [9] Let mutate x$4_@3[5:10] = read y$1_@3 "] bb1_instrs --> bb1_terminal(["Return"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md index 1d96b42baf..8c4774e683 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md @@ -15,7 +15,7 @@ function foo() { bb0: [1] Let mutate x$1_@0 = 1 [2] Let mutate y$2_@1 = 2 - Return + [3] Return ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md index 00c8bd334b..690151d5cb 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md @@ -19,14 +19,14 @@ function foo() { bb0: [1] Let mutate x$1_@0 = 1 [2] Let mutate y$2_@1 = 2 - If (read y$2_@1) then:bb2 else:bb1 + [3] If (read y$2_@1) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [3] Let mutate z$3_@2 = Binary read x$1_@0 + read y$2_@1 - Goto bb1 + [4] Let mutate z$3_@2 = Binary read x$1_@0 + read y$2_@1 + [5] Goto bb1 bb1: predecessor blocks: bb2 bb0 - Return + [6] Return ``` ### CFG @@ -43,7 +43,7 @@ flowchart TB end subgraph bb2 bb2_instrs[" - [3] Let mutate z$3_@2 = Binary read x$1_@0 + read y$2_@1 + [4] Let mutate z$3_@2 = Binary read x$1_@0 + read y$2_@1 "] bb2_instrs --> bb2_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 a257abe4f4..1a8807f923 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md @@ -33,29 +33,29 @@ bb0: [3] Const mutate $5_@2 = Binary read x$1_@0 === read $4_@1 [4] Const mutate $7_@3 = 1 [5] Const mutate $8_@4 = Binary read x$1_@0 === read $7_@3 - Switch (read x$1_@0) + [6] Switch (read x$1_@0) Case read $8_@4: bb5 Case read $5_@2: bb3 Default: bb2 bb5: predecessor blocks: bb0 - [6] Const mutate $6_@5 = 1 - [7] Reassign mutate x$1_@6[7:13] = Binary read x$1_@0 + read $6_@5 - Goto bb1 + [7] Const mutate $6_@5 = 1 + [8] Reassign mutate x$1_@6[8:17] = Binary read x$1_@0 + read $6_@5 + [9] Goto bb1 bb3: predecessor blocks: bb0 - [8] Const mutate $3_@7 = 2 - [9] Reassign mutate x$1_@6[7:13] = Binary read x$1_@0 + read $3_@7 - Goto bb1 + [10] Const mutate $3_@7 = 2 + [11] Reassign mutate x$1_@6[8:17] = Binary read x$1_@0 + read $3_@7 + [12] Goto bb1 bb2: predecessor blocks: bb0 - [10] Const mutate $2_@8 = 3 - [11] Reassign mutate x$1_@6[7:13] = Binary read x$1_@0 + read $2_@8 - Goto bb1 + [13] Const mutate $2_@8 = 3 + [14] Reassign mutate x$1_@6[8:17] = Binary read x$1_@0 + read $2_@8 + [15] Goto bb1 bb1: predecessor blocks: bb5 bb3 bb2 - [12] Let mutate y$9_@6[7:13] = read x$1_@6 - Return + [16] Let mutate y$9_@6[8:17] = read x$1_@6 + [17] Return ``` ### CFG @@ -75,28 +75,28 @@ flowchart TB end subgraph bb5 bb5_instrs[" - [6] Const mutate $6_@5 = 1 - [7] Reassign mutate x$1_@6[7:13] = Binary read x$1_@0 + read $6_@5 + [7] Const mutate $6_@5 = 1 + [8] Reassign mutate x$1_@6[8:17] = 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[7:13] = Binary read x$1_@0 + read $3_@7 + [10] Const mutate $3_@7 = 2 + [11] Reassign mutate x$1_@6[8:17] = 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[7:13] = Binary read x$1_@0 + read $2_@8 + [13] Const mutate $2_@8 = 3 + [14] Reassign mutate x$1_@6[8:17] = Binary read x$1_@0 + read $2_@8 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [12] Let mutate y$9_@6[7:13] = read x$1_@6 + [16] Let mutate y$9_@6[8:17] = 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 d3caf1fcf4..28fdbcea11 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md @@ -16,17 +16,17 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0[1:5] = 1 + [1] Let mutate x$1_@0[1:6] = 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 + [4] If (read $3_@2) then:bb2 else:bb1 bb2: predecessor blocks: bb0 - [4] Reassign mutate x$1_@0[1:5] = 2 - Goto bb1 + [5] Reassign mutate x$1_@0[1:6] = 2 + [6] Goto bb1 bb1: predecessor blocks: bb2 bb0 - Throw read x$1_@0 + [7] Throw read x$1_@0 ``` ### CFG @@ -36,7 +36,7 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0[1:5] = 1 + [1] Let mutate x$1_@0[1:6] = 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[1:5] = 2 + [5] Reassign mutate x$1_@0[1:6] = 2 "] bb2_instrs --> bb2_terminal(["Goto"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-while-no-reassign.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-while-no-reassign.expect.md index 362557f562..68f4182551 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-while-no-reassign.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-while-no-reassign.expect.md @@ -18,20 +18,20 @@ function foo() { ``` bb0: [1] Let mutate x$1_@0 = 1 - While test=bb1 loop=bb3 fallthrough=bb2 + [2] While test=bb1 loop=bb3 fallthrough=bb2 bb1: predecessor blocks: bb0 bb3 - [2] Const mutate $3_@1 = 10 - [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 - If (read $4_@2) then:bb3 else:bb2 + [3] Const mutate $3_@1 = 10 + [4] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 + [5] If (read $4_@2) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - [4] Const mutate $2_@3 = 1 - [5] Binary read x$1_@0 + read $2_@3 - Goto(Continue) bb1 + [6] Const mutate $2_@3 = 1 + [7] Binary read x$1_@0 + read $2_@3 + [8] Goto(Continue) bb1 bb2: predecessor blocks: bb1 - Return read x$1_@0 + [9] Return read x$1_@0 ``` ### CFG @@ -47,15 +47,15 @@ flowchart TB end subgraph bb1 bb1_instrs[" - [2] Const mutate $3_@1 = 10 - [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 + [3] Const mutate $3_@1 = 10 + [4] 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] Binary read x$1_@0 + read $2_@3 + [6] Const mutate $2_@3 = 1 + [7] Binary read x$1_@0 + read $2_@3 "] bb3_instrs --> bb3_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 88441315d2..c6e6c5033f 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md @@ -17,21 +17,21 @@ function foo() { ``` bb0: - [1] Let mutate x$1_@0[0:6] = 1 - While test=bb1 loop=bb3 fallthrough=bb2 + [1] Let mutate x$1_@0[0:8] = 1 + [2] While test=bb1 loop=bb3 fallthrough=bb2 bb1: predecessor blocks: bb0 bb3 - [2] Const mutate $3_@1 = 10 - [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 - If (read $4_@2) then:bb3 else:bb2 + [3] Const mutate $3_@1 = 10 + [4] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 + [5] If (read $4_@2) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - [4] Const mutate $2_@3 = 1 - [5] Reassign mutate x$1_@0[0:6] = Binary read x$1_@0 + read $2_@3 - Goto(Continue) bb1 + [6] Const mutate $2_@3 = 1 + [7] Reassign mutate x$1_@0[0:8] = Binary read x$1_@0 + read $2_@3 + [8] Goto(Continue) bb1 bb2: predecessor blocks: bb1 - Return read x$1_@0 + [9] Return read x$1_@0 ``` ### CFG @@ -41,21 +41,21 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$1_@0[0:6] = 1 + [1] Let mutate x$1_@0[0:8] = 1 "] bb0_instrs --> bb0_terminal(["While"]) end subgraph bb1 bb1_instrs[" - [2] Const mutate $3_@1 = 10 - [3] Const mutate $4_@2 = Binary read x$1_@0 < read $3_@1 + [3] Const mutate $3_@1 = 10 + [4] 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_@0[0:6] = Binary read x$1_@0 + read $2_@3 + [6] Const mutate $2_@3 = 1 + [7] Reassign mutate x$1_@0[0:8] = 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 f6b479e94e..f644aeb660 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 @@ -32,31 +32,31 @@ function Component(props) { ``` bb0: - [1] Let mutate x$2_@0[1:9] = Array [] - [2] Let mutate y$3_@0[1:9] = undefined + [1] Let mutate x$2_@0[1:11] = Array [] + [2] Let mutate y$3_@0[1:11] = undefined [3] Const mutate $4_@1 = false [4] Const mutate $5_@2 = true [5] Const mutate $6_@3 = 1 - Switch (read props$1.p0) + [6] Switch (read props$1.p0) Case read $6_@3: bb1 Case read $5_@2: bb6 Default: bb1 Case read $4_@1: bb2 bb6: predecessor blocks: bb0 - [6] Call mutate x$2_@0.push(read props$1.p2) - [7] Reassign mutate y$3_@0[1:9] = Array [] - Goto bb1 + [7] Call mutate x$2_@0.push(read props$1.p2) + [8] Reassign mutate y$3_@0[1:11] = Array [] + [9] Goto bb1 bb2: predecessor blocks: bb0 - [8] Reassign mutate y$3_@0[1:9] = read x$2_@0 - Goto bb1 + [10] Reassign mutate y$3_@0[1:11] = read x$2_@0 + [11] Goto bb1 bb1: predecessor blocks: bb0 bb6 bb2 - [9] Const mutate child$7_@4 = JSX - [10] Call read y$3_@0.push(read props$1.p4) - [11] Const mutate $8_@5 = JSX {read child$7_@4} - Return read $8_@5 + [12] Const mutate child$7_@4 = JSX + [13] Call read y$3_@0.push(read props$1.p4) + [14] Const mutate $8_@5 = JSX {read child$7_@4} + [15] Return read $8_@5 ``` ### CFG @@ -66,8 +66,8 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$2_@0[1:9] = Array [] - [2] Let mutate y$3_@0[1:9] = undefined + [1] Let mutate x$2_@0[1:11] = Array [] + [2] Let mutate y$3_@0[1:11] = undefined [3] Const mutate $4_@1 = false [4] Const mutate $5_@2 = true [5] Const mutate $6_@3 = 1 @@ -76,22 +76,22 @@ flowchart TB end subgraph bb6 bb6_instrs[" - [6] Call mutate x$2_@0.push(read props$1.p2) - [7] Reassign mutate y$3_@0[1:9] = Array [] + [7] Call mutate x$2_@0.push(read props$1.p2) + [8] Reassign mutate y$3_@0[1:11] = Array [] "] bb6_instrs --> bb6_terminal(["Goto"]) end subgraph bb2 bb2_instrs[" - [8] Reassign mutate y$3_@0[1:9] = read x$2_@0 + [10] Reassign mutate y$3_@0[1:11] = read x$2_@0 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [9] Const mutate child$7_@4 = JSX - [10] Call read y$3_@0.push(read props$1.p4) - [11] Const mutate $8_@5 = JSX {read child$7_@4} + [12] Const mutate child$7_@4 = JSX + [13] Call read y$3_@0.push(read props$1.p4) + [14] Const mutate $8_@5 = JSX {read child$7_@4} "] bb1_instrs --> bb1_terminal(["Return read $8_@5"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/switch-with-fallthrough.expect.md b/compiler/forget/src/__tests__/fixtures/hir/switch-with-fallthrough.expect.md index 45cdda5fa3..91c3e8ef0e 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/switch-with-fallthrough.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/switch-with-fallthrough.expect.md @@ -43,7 +43,7 @@ bb0: [5] Const mutate $6_@4 = 2 [6] Const mutate $7_@5 = 1 [7] Const mutate $8_@6 = 0 - Switch (read x$1) + [8] Switch (read x$1) Case read $8_@6: bb10 Case read $7_@5: bb9 Case read $6_@4: bb1 @@ -53,31 +53,31 @@ bb0: Default: bb2 bb10: predecessor blocks: bb0 - [8] Reassign mutate y$2_@7 = 0 - Goto bb9 + [9] Reassign mutate y$2_@7 = 0 + [10] Goto bb9 bb9: predecessor blocks: bb10 bb0 - [9] Reassign mutate y$2_@8 = 1 - Goto bb1 + [11] Reassign mutate y$2_@8 = 1 + [12] Goto bb1 bb5: predecessor blocks: bb0 - [10] Reassign mutate y$2_@9 = 3 - Goto bb1 + [13] Reassign mutate y$2_@9 = 3 + [14] Goto bb1 bb4: predecessor blocks: bb0 - [11] Reassign mutate y$2_@10 = 4 - Goto bb3 + [15] Reassign mutate y$2_@10 = 4 + [16] Goto bb3 bb3: predecessor blocks: bb4 bb0 - [12] Reassign mutate y$2_@11 = 5 - Goto bb2 + [17] Reassign mutate y$2_@11 = 5 + [18] Goto bb2 bb2: predecessor blocks: bb3 bb0 - [13] Reassign mutate y$2_@12 = 0 - Goto bb1 + [19] Reassign mutate y$2_@12 = 0 + [20] Goto bb1 bb1: predecessor blocks: bb9 bb0 bb5 bb2 - Return + [21] Return ``` ### CFG @@ -99,37 +99,37 @@ flowchart TB end subgraph bb10 bb10_instrs[" - [8] Reassign mutate y$2_@7 = 0 + [9] Reassign mutate y$2_@7 = 0 "] bb10_instrs --> bb10_terminal(["Goto"]) end subgraph bb9 bb9_instrs[" - [9] Reassign mutate y$2_@8 = 1 + [11] Reassign mutate y$2_@8 = 1 "] bb9_instrs --> bb9_terminal(["Goto"]) end subgraph bb5 bb5_instrs[" - [10] Reassign mutate y$2_@9 = 3 + [13] Reassign mutate y$2_@9 = 3 "] bb5_instrs --> bb5_terminal(["Goto"]) end subgraph bb4 bb4_instrs[" - [11] Reassign mutate y$2_@10 = 4 + [15] Reassign mutate y$2_@10 = 4 "] bb4_instrs --> bb4_terminal(["Goto"]) end subgraph bb3 bb3_instrs[" - [12] Reassign mutate y$2_@11 = 5 + [17] Reassign mutate y$2_@11 = 5 "] bb3_instrs --> bb3_terminal(["Goto"]) end subgraph bb2 bb2_instrs[" - [13] Reassign mutate y$2_@12 = 0 + [19] Reassign mutate y$2_@12 = 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 f4beeeaa50..fa28b73ccf 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md @@ -28,30 +28,30 @@ function Component(props) { ``` bb0: - [1] Let mutate x$2_@0[1:9] = Array [] - [2] Let mutate y$3_@0[1:9] = undefined + [1] Let mutate x$2_@0[1:11] = Array [] + [2] Let mutate y$3_@0[1:11] = undefined [3] Const mutate $4_@1 = false [4] Const mutate $5_@2 = true - Switch (read props$1.p0) + [5] Switch (read props$1.p0) Case read $5_@2: bb4 Case read $4_@1: bb2 Default: bb1 bb4: predecessor blocks: bb0 - [5] Call mutate x$2_@0.push(read props$1.p2) - [6] Call mutate x$2_@0.push(read props$1.p3) - [7] Reassign mutate y$3_@3 = Array [] - Goto bb2 + [6] Call mutate x$2_@0.push(read props$1.p2) + [7] Call mutate x$2_@0.push(read props$1.p3) + [8] Reassign mutate y$3_@3 = Array [] + [9] Goto bb2 bb2: predecessor blocks: bb4 bb0 - [8] Reassign mutate y$3_@0[1:9] = read x$2_@0 - Goto bb1 + [10] Reassign mutate y$3_@0[1:11] = read x$2_@0 + [11] Goto bb1 bb1: predecessor blocks: bb2 bb0 - [9] Const mutate child$6_@4 = JSX - [10] Call read y$3_@0.push(read props$1.p4) - [11] Const mutate $7_@5 = JSX {read child$6_@4} - Return read $7_@5 + [12] Const mutate child$6_@4 = JSX + [13] Call read y$3_@0.push(read props$1.p4) + [14] Const mutate $7_@5 = JSX {read child$6_@4} + [15] Return read $7_@5 ``` ### CFG @@ -61,8 +61,8 @@ flowchart TB %% Basic Blocks subgraph bb0 bb0_instrs[" - [1] Let mutate x$2_@0[1:9] = Array [] - [2] Let mutate y$3_@0[1:9] = undefined + [1] Let mutate x$2_@0[1:11] = Array [] + [2] Let mutate y$3_@0[1:11] = undefined [3] Const mutate $4_@1 = false [4] Const mutate $5_@2 = true "] @@ -70,23 +70,23 @@ flowchart TB end subgraph bb4 bb4_instrs[" - [5] Call mutate x$2_@0.push(read props$1.p2) - [6] Call mutate x$2_@0.push(read props$1.p3) - [7] Reassign mutate y$3_@3 = Array [] + [6] Call mutate x$2_@0.push(read props$1.p2) + [7] Call mutate x$2_@0.push(read props$1.p3) + [8] Reassign mutate y$3_@3 = Array [] "] bb4_instrs --> bb4_terminal(["Goto"]) end subgraph bb2 bb2_instrs[" - [8] Reassign mutate y$3_@0[1:9] = read x$2_@0 + [10] Reassign mutate y$3_@0[1:11] = read x$2_@0 "] bb2_instrs --> bb2_terminal(["Goto"]) end subgraph bb1 bb1_instrs[" - [9] Const mutate child$6_@4 = JSX - [10] Call read y$3_@0.push(read props$1.p4) - [11] Const mutate $7_@5 = JSX {read child$6_@4} + [12] Const mutate child$6_@4 = JSX + [13] Call read y$3_@0.push(read props$1.p4) + [14] Const mutate $7_@5 = JSX {read child$6_@4} "] bb1_instrs --> bb1_terminal(["Return read $7_@5"]) end diff --git a/compiler/forget/src/__tests__/fixtures/hir/while-break.expect.md b/compiler/forget/src/__tests__/fixtures/hir/while-break.expect.md index c46cdd3fc3..19bd05573b 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/while-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/while-break.expect.md @@ -15,13 +15,13 @@ function foo(a, b) { ``` bb0: - While test=bb1 loop=bb2 fallthrough=bb2 + [1] While test=bb1 loop=bb2 fallthrough=bb2 bb1: predecessor blocks: bb0 - If (read a$1) then:bb2 else:bb2 + [2] If (read a$1) then:bb2 else:bb2 bb2: predecessor blocks: bb1 - Return read b$2 + [3] Return read b$2 ``` ### CFG diff --git a/compiler/forget/src/__tests__/fixtures/hir/while-conditional-continue.expect.md b/compiler/forget/src/__tests__/fixtures/hir/while-conditional-continue.expect.md index 9d1cb79376..94abf9e763 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/while-conditional-continue.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/while-conditional-continue.expect.md @@ -19,24 +19,24 @@ function foo(a, b, c, d) { ``` bb0: - While test=bb1 loop=bb3 fallthrough=bb2 + [1] While test=bb1 loop=bb3 fallthrough=bb2 bb1: predecessor blocks: bb0 bb5 bb4 - If (read a$1) then:bb3 else:bb2 + [2] If (read a$1) then:bb3 else:bb2 bb3: predecessor blocks: bb1 - If (read b$2) then:bb5 else:bb4 + [3] If (read b$2) then:bb5 else:bb4 bb5: predecessor blocks: bb3 - Goto(Continue) bb1 + [4] Goto(Continue) bb1 bb4: predecessor blocks: bb3 - [1] Call read c$3() - Goto(Continue) bb1 + [5] Call read c$3() + [6] Goto(Continue) bb1 bb2: predecessor blocks: bb1 - [2] Call read d$4() - Return + [7] Call read d$4() + [8] Return ``` ### CFG @@ -58,13 +58,13 @@ flowchart TB end subgraph bb4 bb4_instrs[" - [1] Call read c$3() + [5] Call read c$3() "] bb4_instrs --> bb4_terminal(["Goto"]) end subgraph bb2 bb2_instrs[" - [2] Call read d$4() + [7] Call read d$4() "] bb2_instrs --> bb2_terminal(["Return"]) end