From dd1ff4dc302b1cdcfd0df7494a6abbb9b9f73006 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Wed, 14 Dec 2022 08:42:39 -0800 Subject: [PATCH] Combine dependency collection and propagation, more precise collection I realized that properly propagating scope dependencies requires reusing the same logic as dependency collection itself: a dependency of an inner scope should only be propagated upward if the dependency was declared before the outer scope, for example. So this PR reimplements dependency collection in the propagation pass. At the same time I made a few other improvements: * Don't report dependencies that are "constant". This is a bit simplistic for now, we can use a more advanced analysis later. * Try to avoid creating duplicate dependencies. This addresses the todo from the previous PR (flattening scopes in loops) since now we don't need to compute deps until after that runs. As a follow-up i'll remove the existing dependency collection. --- .../src/HIR/InferReactiveScopeDependencies.ts | 56 ++++ .../src/HIR/PropagateScopeDependencies.ts | 269 +++++++++++++++++- .../_bug_conditional-break-labeled.expect.md | 2 +- .../src/__tests__/fixtures/hir/call.expect.md | 8 +- .../fixtures/hir/component.expect.md | 11 +- .../fixtures/hir/conditional-break.expect.md | 8 +- .../hir/conditional-on-mutable.expect.md | 4 +- .../fixtures/hir/constructor.expect.md | 8 +- .../hir/dependencies-outputs.expect.md | 2 +- .../fixtures/hir/dependencies.expect.md | 6 +- .../fixtures/hir/extend-scopes-if.expect.md | 2 +- .../fixtures/hir/hook-call.expect.md | 2 +- ...reeze-possibly-mutable-arguments.expect.md | 2 +- .../hir/independent-across-if.expect.md | 2 +- .../fixtures/hir/inverted-if.expect.md | 2 +- .../fixtures/hir/jsx-fragment.expect.md | 6 +- .../fixtures/hir/logical-expression.expect.md | 6 +- .../mutable-lifetime-with-aliasing.expect.md | 2 +- ...g-scopes-interleaved-by-terminal.expect.md | 2 +- .../overlapping-scopes-interleaved.expect.md | 2 +- .../hir/overlapping-scopes-shadowed.expect.md | 3 +- ...ng-scopes-shadowing-within-block.expect.md | 10 +- .../hir/overlapping-scopes-while.expect.md | 2 +- .../overlapping-scopes-within-block.expect.md | 2 +- .../hir/property-assignment.expect.md | 4 +- .../fixtures/hir/reactive-scopes-if.expect.md | 7 +- .../fixtures/hir/reactive-scopes.expect.md | 4 +- .../hir/reassignment-conditional.expect.md | 4 +- .../reassignment-separate-scopes.expect.md | 8 +- .../fixtures/hir/reassignment.expect.md | 8 +- .../fixtures/hir/reverse-postorder.expect.md | 2 +- .../__tests__/fixtures/hir/simple.expect.md | 4 +- .../hir/ssa-arrayexpression.expect.md | 2 +- .../fixtures/hir/ssa-call-jsx-2.expect.md | 8 +- .../fixtures/hir/ssa-call-jsx.expect.md | 8 +- .../fixtures/hir/ssa-multiple-phis.expect.md | 2 +- .../hir/ssa-nested-partial-phi.expect.md | 2 +- .../ssa-nested-partial-reassignment.expect.md | 2 +- .../hir/ssa-objectexpression-phi.expect.md | 2 +- .../hir/ssa-objectexpression.expect.md | 2 +- .../fixtures/hir/ssa-sibling-phis.expect.md | 4 +- .../fixtures/hir/ssa-simple-phi.expect.md | 2 +- .../fixtures/hir/ssa-switch.expect.md | 2 +- .../hir/switch-non-final-default.expect.md | 6 +- .../__tests__/fixtures/hir/switch.expect.md | 7 +- .../src/__tests__/fixtures/hir/switch.js | 1 - .../fixtures/hir/type-field-load.expect.md | 2 +- 47 files changed, 392 insertions(+), 120 deletions(-) diff --git a/compiler/forget/src/HIR/InferReactiveScopeDependencies.ts b/compiler/forget/src/HIR/InferReactiveScopeDependencies.ts index a5385a52e1..9846ac9b6f 100644 --- a/compiler/forget/src/HIR/InferReactiveScopeDependencies.ts +++ b/compiler/forget/src/HIR/InferReactiveScopeDependencies.ts @@ -37,6 +37,7 @@ export function instructionInScope( class ScopeDependenciesVisitor implements Visitor { + #kinds: Map = new Map(); #identifiers: Map = new Map(); // Scopes that are currently active at this point in the traversal #activeScopes: Set = new Set(); @@ -49,9 +50,11 @@ class ScopeDependenciesVisitor constructor(fn: HIRFunction) { if (fn.id !== null) { this.#identifiers.set(fn.id, makeInstructionId(0)); + this.#kinds.set(fn.id, DeclKind.Const); } for (const param of fn.params) { this.#identifiers.set(param.identifier, makeInstructionId(0)); + this.#kinds.set(param.identifier, DeclKind.Dynamic); } } @@ -190,3 +193,56 @@ class ScopeDependenciesVisitor } leaveInitBlock(block: void): void {} } + +enum DeclKind { + Const = "Const", + Dynamic = "Dynamic", +} + +function visitOperand( + operand: Place, + dependencies: Set, + declarations: Map +): void { + const kind = declarations.get(operand.identifier); + if (kind === undefined) { + // TODO: global, ignore + return; + } else if (kind === DeclKind.Const) { + // constant, dont need to add a dep + return; + } else { + for (const dep of dependencies) { + // not the same identifier + if (dep.identifier !== operand.identifier) { + continue; + } + const depPath = dep.memberPath; + // existing dep covers all paths + if (depPath === null) { + return; + } + const operandPath = operand.memberPath; + // existing dep is for a path, this operand covers all paths so swap them + if (operandPath === null) { + dependencies.delete(dep); + dependencies.add(operand); + return; + } + // both the operand and dep have paths, determine if the existing path + // is a subset of the new path + let commonPathIndex = 0; + while ( + commonPathIndex < operandPath.length && + commonPathIndex < depPath.length && + operandPath[commonPathIndex] === depPath[commonPathIndex] + ) { + commonPathIndex++; + } + if (commonPathIndex === depPath.length) { + return; + } + } + dependencies.add(operand); + } +} diff --git a/compiler/forget/src/HIR/PropagateScopeDependencies.ts b/compiler/forget/src/HIR/PropagateScopeDependencies.ts index c51028cfb9..8f114bec3e 100644 --- a/compiler/forget/src/HIR/PropagateScopeDependencies.ts +++ b/compiler/forget/src/HIR/PropagateScopeDependencies.ts @@ -6,57 +6,160 @@ */ import { assertExhaustive } from "../Common/utils"; -import { Place, ReactiveBasicBlock, ReactiveFunction } from "./HIR"; +import { + Identifier, + Instruction, + InstructionId, + InstructionKind, + InstructionValue, + makeInstructionId, + Place, + ReactiveBasicBlock, + ReactiveFunction, + ReactiveValueBlock, +} from "./HIR"; +import { eachInstructionValueOperand } from "./visitors"; /** - * Propagates the dependencies of each scope to its parent scope(s). + * Infers the dependencies of each scope to include variables whose values + * are non-stable and created prior to the start of the scope. Also propagates + * dependencies upwards, so that parent scope dependencies are the union of + * their direct dependencies and those of their child scopes. */ export function propagateScopeDependencies(fn: ReactiveFunction): void { const dependencies: Set = new Set(); - visit(fn.body, dependencies); + const declarations: DeclMap = new Map(); + if (fn.id !== null) { + declarations.set(fn.id, { kind: DeclKind.Const, id: makeInstructionId(0) }); + } + for (const param of fn.params) { + declarations.set(param.identifier, { + kind: DeclKind.Dynamic, + id: makeInstructionId(0), + }); + } + visit(fn.body, dependencies, declarations, null); } -function visit(block: ReactiveBasicBlock, dependencies: Set): void { +enum DeclKind { + Const = "Const", + Dynamic = "Dynamic", +} + +type DeclMap = Map; + +function visit( + block: ReactiveBasicBlock, + dependencies: Set, + declarations: DeclMap, + scopeStart: InstructionId | null +): void { for (const item of block) { switch (item.kind) { case "block": { - visit(item.instructions, item.dependencies); - for (const dep of item.dependencies) { - dependencies.add(dep); + const scopeDependencies: Set = new Set(); + // TODO: it would be sufficient to use a single mapping of declarations + const scopeDeclarations: DeclMap = new Map(declarations); + visit( + item.instructions, + scopeDependencies, + scopeDeclarations, + item.range.start + ); + item.dependencies = scopeDependencies; + for (const dep of scopeDependencies) { + // propagate dependencies upward using the same rules as + // normal dependency collection. child scopes may have dependencies + // on values created within the outer scope, which necessarily cannot + // be dependencies of the outer scope + visitOperand(dep, dependencies, declarations, scopeStart); + } + for (const [ident, kind] of scopeDeclarations) { + declarations.set(ident, kind); } break; } case "instruction": { + visitInstruction( + item.instruction, + dependencies, + declarations, + scopeStart + ); break; } case "terminal": { const terminal = item.terminal; switch (terminal.kind) { case "break": - case "continue": - case "return": + case "continue": { + break; + } + case "return": { + if (terminal.value !== null) { + visitOperand( + terminal.value, + dependencies, + declarations, + scopeStart + ); + } + break; + } case "throw": { + visitOperand( + terminal.value, + dependencies, + declarations, + scopeStart + ); break; } case "for": { - visit(terminal.loop, dependencies); + visitValueBlock( + terminal.init, + dependencies, + declarations, + scopeStart + ); + visitValueBlock( + terminal.test, + dependencies, + declarations, + scopeStart + ); + visitValueBlock( + terminal.update, + dependencies, + declarations, + scopeStart + ); + visit(terminal.loop, dependencies, declarations, scopeStart); break; } case "while": { - visit(terminal.loop, dependencies); + visitValueBlock( + terminal.test, + dependencies, + declarations, + scopeStart + ); + visit(terminal.loop, dependencies, declarations, scopeStart); break; } case "if": { - visit(terminal.consequent, dependencies); + visitOperand(terminal.test, dependencies, declarations, scopeStart); + visit(terminal.consequent, dependencies, declarations, scopeStart); if (terminal.alternate !== null) { - visit(terminal.alternate, dependencies); + visit(terminal.alternate, dependencies, declarations, scopeStart); } break; } case "switch": { + visitOperand(terminal.test, dependencies, declarations, scopeStart); for (const case_ of terminal.cases) { if (case_.block !== undefined) { - visit(case_.block, dependencies); + visit(case_.block, dependencies, declarations, scopeStart); } } break; @@ -76,3 +179,141 @@ function visit(block: ReactiveBasicBlock, dependencies: Set): void { } } } + +function visitValueBlock( + block: ReactiveValueBlock, + dependencies: Set, + declarations: DeclMap, + scopeStart: InstructionId | null +): void { + for (const initItem of block.instructions) { + if (initItem.kind === "instruction") { + visitInstruction( + initItem.instruction, + dependencies, + declarations, + scopeStart + ); + } + } + if (block.value !== null) { + visitInstructionValue(block.value, dependencies, declarations, scopeStart); + } +} + +function visitOperand( + operand: Place, + dependencies: Set, + declarations: DeclMap, + scopeStart: InstructionId | null +): void { + const decl = declarations.get(operand.identifier); + if (decl === undefined) { + // Probably a global, ignore for now + // TODO @josephsavona: improve handling of globals + return; + } else if (decl.kind === DeclKind.Const) { + // constant, dont need to add a dep + return; + } else if (scopeStart !== null && decl.id < scopeStart) { + // Check if there is an existing dependency that describes this operand + for (const dep of dependencies) { + // not the same identifier + if (dep.identifier !== operand.identifier) { + continue; + } + const depPath = dep.memberPath; + // existing dep covers all paths + if (depPath === null) { + return; + } + const operandPath = operand.memberPath; + // existing dep is for a path, this operand covers all paths so swap them + if (operandPath === null) { + dependencies.delete(dep); + dependencies.add(operand); + return; + } + // both the operand and dep have paths, determine if the existing path + // is a subset of the new path + let commonPathIndex = 0; + while ( + commonPathIndex < operandPath.length && + commonPathIndex < depPath.length && + operandPath[commonPathIndex] === depPath[commonPathIndex] + ) { + commonPathIndex++; + } + if (commonPathIndex === depPath.length) { + return; + } + } + dependencies.add(operand); + } +} + +function visitInstructionValue( + value: InstructionValue, + dependencies: Set, + declarations: DeclMap, + scopeStart: InstructionId | null +): void { + for (const operand of eachInstructionValueOperand(value)) { + // check for method invocation, we want to depend on the callee, not the method + if ( + value.kind === "CallExpression" && + operand === value.callee && + operand.memberPath !== null + ) { + const callee = { + ...operand, + memberPath: operand.memberPath.slice(0, -1), + }; + visitOperand(callee, dependencies, declarations, scopeStart); + } else { + visitOperand(operand, dependencies, declarations, scopeStart); + } + } +} + +function visitInstruction( + instr: Instruction, + dependencies: Set, + declarations: DeclMap, + scopeStart: InstructionId | null +): void { + visitInstructionValue(instr.value, dependencies, declarations, scopeStart); + const { lvalue } = instr; + if ( + lvalue !== null && + lvalue.kind !== InstructionKind.Reassign && + lvalue.place.memberPath === null + ) { + const kind = valueKind(instr.value); + declarations.set(lvalue.place.identifier, { kind, id: instr.id }); + } +} + +function valueKind(value: InstructionValue): DeclKind { + switch (value.kind) { + case "BinaryExpression": + case "JSXText": + case "Primitive": { + return DeclKind.Const; + } + case "Identifier": + case "ArrayExpression": + case "CallExpression": + case "JsxExpression": + case "JsxFragment": + case "NewExpression": + case "ObjectExpression": + case "OtherStatement": + case "UnaryExpression": { + return DeclKind.Dynamic; + } + default: { + assertExhaustive(value, `Unexpected value kind '${(value as any).kind}'`); + } + } +} diff --git a/compiler/forget/src/__tests__/fixtures/hir/_bug_conditional-break-labeled.expect.md b/compiler/forget/src/__tests__/fixtures/hir/_bug_conditional-break-labeled.expect.md index 10ae2c92c2..ba03c8f3f1 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/_bug_conditional-break-labeled.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/_bug_conditional-break-labeled.expect.md @@ -47,7 +47,7 @@ scope0 [1:7]: function Component( props, ) { - scope @0 [1:7] deps=[read props$3.a, read props$3.d, read props$3.c] { + scope @0 [1:7] deps=[read props$3.a, read props$3.b, read props$3.d, read props$3.c] { [1] Const mutate a$4_@0:TFunction[1:7] = Array [] [2] Call mutate a$4_@0.push(read props$3.a) if (read props$3.b) { diff --git a/compiler/forget/src/__tests__/fixtures/hir/call.expect.md b/compiler/forget/src/__tests__/fixtures/hir/call.expect.md index 493f22d46a..a37231dc6a 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/call.expect.md @@ -52,8 +52,6 @@ bb0: [7] Const mutate $14:TPrimitive = "div" [8] Const mutate $15_@2 = JSX [9] Return read $15_@2 -scope0 [1:7]: - - dependency: read $12:TPrimitive scope1 [5:6]: - dependency: read $12:TPrimitive scope2 [8:9]: @@ -68,18 +66,18 @@ scope2 [8:9]: function Component( props, ) { - scope @0 [1:7] deps=[read $12:TPrimitive] { + scope @0 [1:7] deps=[] { [1] Const mutate a$10_@0:TObject[1:7] = Array [] [2] Const mutate b$11_@0:TObject[1:7] = Object { } [3] Call mutate foo$4:TFunction(mutate a$10_@0:TObject, mutate b$11_@0:TObject) [4] Const mutate $12:TPrimitive = "div" - scope @1 [5:6] deps=[read $12:TPrimitive] { + scope @1 [5:6] deps=[freeze a$10_@0:TObject] { [5] Const mutate _$13_@1 = JSX } [6] Call mutate foo$4:TFunction(mutate b$11_@0:TObject) } [7] Const mutate $14:TPrimitive = "div" - scope @2 [8:9] deps=[read $14:TPrimitive, read a$10_@0:TObject, freeze b$11_@0:TObject] { + scope @2 [8:9] deps=[read a$10_@0:TObject, freeze b$11_@0:TObject] { [8] Const mutate $15_@2 = JSX } return read $15_@2 diff --git a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md index 8315adb173..c7568eb220 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/component.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/component.expect.md @@ -100,9 +100,6 @@ bb2: [40] Const mutate $73 = "\n " [41] Const mutate $74_@5 = JSX {read $68}{read $71_@4}{read $72}{freeze renderedItems$32_@0:TFunction}{read $73} [42] Return read $74_@5 -scope0 [3:33]: - - dependency: read $34:TPrimitive - - dependency: read maxItems$31:TProp scope2 [6:7]: - dependency: read $34:TPrimitive - dependency: read maxItems$31:TProp @@ -129,11 +126,11 @@ function Component( ) { [1] Const mutate items$30:TProp = read props$29.items [2] Const mutate maxItems$31:TProp = read props$29.maxItems - scope @0 [3:33] deps=[read $34:TPrimitive, read maxItems$31:TProp] { + scope @0 [3:33] deps=[read maxItems$31:TProp, read items$30.length, read items$30] { [3] Const mutate renderedItems$32_@0:TFunction[3:33] = Array [] [4] Const mutate seen$33_@0:TFunction[3:33] = New mutate Set$6() [5] Const mutate $34:TPrimitive = 0 - scope @2 [6:7] deps=[read $34:TPrimitive, read maxItems$31:TProp] { + scope @2 [6:7] deps=[read maxItems$31:TProp] { [6] Const mutate max$35_@2:TPrimitive = Call mutate Math$8.max(read $34:TPrimitive, read maxItems$31:TProp) } for ( @@ -173,12 +170,12 @@ function Component( [35] Const mutate $68 = "\n " [36] Const mutate $69:TPrimitive = "h1" [37] Const mutate $70 = " Items" - scope @4 [38:39] deps=[read $69:TPrimitive, freeze count$66:TProp, read $70] { + scope @4 [38:39] deps=[freeze count$66:TProp] { [38] Const mutate $71_@4 = JSX {freeze count$66:TProp}{read $70} } [39] Const mutate $72 = "\n " [40] Const mutate $73 = "\n " - scope @5 [41:42] deps=[read $67:TPrimitive, read $68, read $71_@4, read $72, freeze renderedItems$32_@0:TFunction, read $73] { + scope @5 [41:42] deps=[read $71_@4, freeze renderedItems$32_@0:TFunction] { [41] Const mutate $74_@5 = JSX {read $68}{read $71_@4}{read $72}{freeze renderedItems$32_@0:TFunction}{read $73} } return read $74_@5 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 807b932e05..a8ed7d690e 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md @@ -158,7 +158,7 @@ scope0 [1:7]: function Component( props, ) { - scope @0 [1:7] deps=[read props$3.a, read props$3.c, read props$3.b, read props$3.d] { + scope @0 [1:7] deps=[read props$3.a, read props$3.b, read props$3.c, read props$3.d] { [1] Const mutate a$4_@0:TFunction[1:7] = Array [] [2] Call mutate a$4_@0.push(read props$3.a) if (read props$3.b) { @@ -215,7 +215,7 @@ scope0 [1:8]: function Component( props, ) { - scope @0 [1:8] deps=[read props$4.a, read props$4.c, read props$4.b, read props$4.d] { + scope @0 [1:8] deps=[read props$4.a, read props$4.b, read props$4.c, read props$4.d] { [1] Const mutate a$5_@0:TFunction[1:8] = Array [] [2] Call mutate a$5_@0.push(read props$4.a) if (read props$4.b) { @@ -274,7 +274,7 @@ scope0 [1:7]: function Component( props, ) { - scope @0 [1:7] deps=[read props$3.a, read props$3.c, read props$3.b, read props$3.d] { + scope @0 [1:7] deps=[read props$3.a, read props$3.b, read props$3.c, read props$3.d] { [1] Const mutate a$4_@0:TFunction[1:7] = Array [] [2] Call mutate a$4_@0.push(read props$3.a) if (read props$3.b) { @@ -331,7 +331,7 @@ scope0 [1:7]: function Component( props, ) { - scope @0 [1:7] deps=[read props$3.a, read props$3.d, read props$3.c] { + scope @0 [1:7] deps=[read props$3.a, read props$3.b, read props$3.d, read props$3.c] { [1] Const mutate a$4_@0:TFunction[1:7] = Array [] [2] Call mutate a$4_@0.push(read props$3.a) if (read props$3.b) { 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 d62be063f2..08c567918f 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 @@ -64,7 +64,7 @@ scope2 [9:10]: function Component( props, ) { - scope @0 [1:9] deps=[] { + scope @0 [1:9] deps=[read props$6.p0, read props$6.p1, read props$6.p2] { [1] Const mutate a$7_@0:TFunction[1:9] = Array [] [2] Const mutate b$8_@0:TFunction[1:9] = Array [] if (read b$8_@0:TFunction) { @@ -134,7 +134,7 @@ scope2 [10:11]: function Component( props, ) { - scope @0 [1:10] deps=[] { + scope @0 [1:10] deps=[read props$8.p0, read props$8.p1, read props$8.p2] { [1] Const mutate a$9_@0:TFunction[1:10] = Array [] [2] Const mutate b$10_@0:TFunction[1:10] = Array [] [3] Const mutate $11_@0[1:10] = Call mutate mayMutate$4:TFunction(mutate b$10_@0:TFunction) diff --git a/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md b/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md index 856ce3e2fe..ea7af28626 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md @@ -52,8 +52,6 @@ bb0: [7] Const mutate $14:TPrimitive = "div" [8] Const mutate $15_@2 = JSX [9] Return read $15_@2 -scope0 [1:7]: - - dependency: read $12:TPrimitive scope1 [5:6]: - dependency: read $12:TPrimitive scope2 [8:9]: @@ -68,18 +66,18 @@ scope2 [8:9]: function Component( props, ) { - scope @0 [1:7] deps=[read $12:TPrimitive] { + scope @0 [1:7] deps=[] { [1] Const mutate a$10_@0[1:7] = Array [] [2] Const mutate b$11_@0:TObject[1:7] = Object { } [3] New mutate Foo$4(mutate a$10_@0, mutate b$11_@0:TObject) [4] Const mutate $12:TPrimitive = "div" - scope @1 [5:6] deps=[read $12:TPrimitive] { + scope @1 [5:6] deps=[freeze a$10_@0] { [5] Const mutate _$13_@1 = JSX } [6] New mutate Foo$4(mutate b$11_@0:TObject) } [7] Const mutate $14:TPrimitive = "div" - scope @2 [8:9] deps=[read $14:TPrimitive, read a$10_@0, freeze b$11_@0:TObject] { + scope @2 [8:9] deps=[read a$10_@0, freeze b$11_@0:TObject] { [8] Const mutate $15_@2 = JSX } return read $15_@2 diff --git a/compiler/forget/src/__tests__/fixtures/hir/dependencies-outputs.expect.md b/compiler/forget/src/__tests__/fixtures/hir/dependencies-outputs.expect.md index 566b16a496..90f2791ab5 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/dependencies-outputs.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/dependencies-outputs.expect.md @@ -64,7 +64,7 @@ function foo( } [3] Const mutate $9:TPrimitive = "div" [4] JSX {freeze x$8_@0:TFunction} - scope @1 [5:12] deps=[read x$8_@0:TFunction, read x$8_@0.length, read b$7:TFunction, read b$7:TFunction] { + scope @1 [5:12] deps=[read x$8_@0:TFunction, read b$7:TFunction] { [5] Const mutate y$10_@1:TFunction[5:12] = Array [] if (read x$8_@0.length) { [7] Call mutate y$10_@1.push(read x$8_@0:TFunction) diff --git a/compiler/forget/src/__tests__/fixtures/hir/dependencies.expect.md b/compiler/forget/src/__tests__/fixtures/hir/dependencies.expect.md index f94b06f7cb..df680a2a74 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/dependencies.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/dependencies.expect.md @@ -47,8 +47,6 @@ scope0 [1:10]: - dependency: read x$6 - dependency: read x$6 - dependency: read y$7 - - dependency: read y$7 - - dependency: read x$6 scope1 [3:7]: - dependency: read y$7 - dependency: read x$6 @@ -62,10 +60,10 @@ function foo( y, z, ) { - scope @0 [1:10] deps=[read z$8, read x$6, read x$6, read y$7, read y$7, read x$6] { + scope @0 [1:10] deps=[read z$8, read x$6, read y$7] { [1] Const mutate items$9_@0:TFunction[1:10] = Array [read z$8] [2] Call mutate items$9_@0.push(read x$6) - scope @1 [3:7] deps=[read y$7, read x$6] { + scope @1 [3:7] deps=[read x$6, read y$7] { [3] Const mutate items2$10_@1:TFunction[3:7] = Array [] if (read x$6) { [5] Call mutate items2$10_@1.push(read y$7) diff --git a/compiler/forget/src/__tests__/fixtures/hir/extend-scopes-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/extend-scopes-if.expect.md index 3e17fe959c..58add3a300 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/extend-scopes-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/extend-scopes-if.expect.md @@ -60,7 +60,7 @@ function foo( b, c, ) { - scope @0 [1:8] deps=[read c$9, read b$8, read a$7] { + scope @0 [1:8] deps=[read a$7, read b$8, read c$9] { [1] Const mutate x$10_@0:TFunction[1:8] = Array [] if (read a$7) { if (read b$8) { 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 5172e0398d..6134ef4660 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md @@ -106,7 +106,7 @@ function Component( [4] Const mutate $13 = "\n " [5] Const mutate $14 = "\n " [6] Const mutate $15 = "\n " - scope @2 [7:8] deps=[read Component$0, read $13, read x$11_@0, read $14, read y$12_@1, read $15] { + scope @2 [7:8] deps=[read x$11_@0, read y$12_@1] { [7] Const mutate $16_@2 = JSX {read $13}{read x$11_@0}{read $14}{read y$12_@1}{read $15} } return read $16_@2 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 8996bc3a21..8c18c197e2 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 @@ -59,7 +59,7 @@ function Component( [1] Const mutate cond$8:TProp = read props$7.cond [2] Const mutate x$9:TProp = read props$7.x [3] Const mutate a$10:TPrimitive = undefined - scope @0 [4:9] deps=[read x$9:TProp, read cond$8:TProp] { + scope @0 [4:9] deps=[read cond$8:TProp, read x$9:TProp] { [4] Let mutate a$11_@0:TProp[4:9] = undefined if (read cond$8:TProp) { [5] Reassign mutate a$11_@0:TProp[4:9] = read x$9:TProp 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 a7401bbb8f..14f664b97c 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 @@ -158,7 +158,7 @@ scope2 [7:8]: function Component( props, ) { - scope @1 [1:7] deps=[read props$8.a] { + scope @1 [1:7] deps=[read props$8.a, read props$8.b, read props$8.c] { [1] Const mutate a$9_@1[1:7] = Call mutate compute$3:TFunction(read props$8.a) [2] Const mutate b$10_@1[1:7] = Call mutate compute$3:TFunction(read props$8.b) if (read props$8.c) { diff --git a/compiler/forget/src/__tests__/fixtures/hir/inverted-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/inverted-if.expect.md index 4cf9bf6b8e..35e8bcd044 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/inverted-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/inverted-if.expect.md @@ -44,7 +44,7 @@ function foo( b, c, ) { - scope @0 [1:6] deps=[read c$7, read b$6, read a$5] { + scope @0 [1:6] deps=[read a$5, read b$6, read c$7] { [1] Const mutate y$8_@0:TFunction[1:6] = Array [] if (read a$5) { if (read b$6) { 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 091f873506..9bd0394e9d 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/jsx-fragment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/jsx-fragment.expect.md @@ -59,15 +59,15 @@ function Foo( [4] Const mutate $17:TPrimitive = "div" [5] Const mutate $18 = "\n " [6] Const mutate $19 = "Text" - scope @0 [7:8] deps=[read $19] { + scope @0 [7:8] deps=[] { [7] Const mutate $20_@0 = JsxFragment [read $19] } [8] Const mutate $21 = "\n " - scope @1 [9:10] deps=[read $17:TPrimitive, read $18, read $20_@0, read $21] { + scope @1 [9:10] deps=[read $20_@0] { [9] Const mutate $22_@1 = JSX {read $18}{read $20_@0}{read $21} } [10] Const mutate $23 = "\n " - scope @2 [11:12] deps=[read $14, read props$13.greeting, read $15:TPrimitive, read $16, read $22_@1, read $23] { + scope @2 [11:12] deps=[read props$13.greeting, read $22_@1] { [11] Const mutate $24_@2 = JsxFragment [read $14, read props$13.greeting, read $15:TPrimitive, read $16, read $22_@1, read $23] } return read $24_@2 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 8510da9d12..c06cdf04fd 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md @@ -50,7 +50,7 @@ function And( scope @0 [1:2] deps=[] { [1] Const mutate $5_@0 = Call mutate f$1:TFunction() } - scope @1 [2:7] deps=[read $5_@0, read $5_@0] { + scope @1 [2:7] deps=[read $5_@0] { [2] Let mutate $6_@1[2:7] = undefined if (read $5_@0) { [3] Const mutate $6_@1[2:7] = Call mutate g$4:TFunction() @@ -105,7 +105,7 @@ function Or( scope @0 [1:2] deps=[] { [1] Const mutate $5_@0 = Call mutate f$1:TFunction() } - scope @1 [2:7] deps=[read $5_@0, read $5_@0] { + scope @1 [2:7] deps=[read $5_@0] { [2] Let mutate $6_@1[2:7] = undefined if (read $5_@0) { [3] Const mutate $6_@1[2:7] = read $5_@0 @@ -165,7 +165,7 @@ function QuestionQuestion( } [2] Const mutate $10:TPrimitive = null [3] Const mutate $11:TPrimitive = Binary read $9_@0:TPrimitive != read $10:TPrimitive - scope @1 [4:9] deps=[read $9_@0:TPrimitive, read $11:TPrimitive] { + scope @1 [4:9] deps=[read $9_@0:TPrimitive] { [4] Let mutate $12_@1:TPrimitive[4:9] = undefined if (read $11:TPrimitive) { [5] Const mutate $12_@1:TPrimitive[4:9] = read $9_@0:TPrimitive 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 c87e59f543..a4083f709b 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 @@ -104,7 +104,7 @@ function Component( scope @0 [1:2] deps=[] { [1] Const mutate a$11_@0:TObject = Object { } } - scope @1 [2:15] deps=[read a$11_@0:TObject, read a$11_@0:TObject] { + scope @1 [2:15] deps=[read a$11_@0:TObject] { [2] Const mutate b$12_@1[2:15] = Array [read a$11_@0:TObject] scope @2 [3:4] deps=[] { [3] Const mutate c$13_@2:TObject = Object { } diff --git a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved-by-terminal.expect.md b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved-by-terminal.expect.md index 49787d933d..6a636bf552 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved-by-terminal.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved-by-terminal.expect.md @@ -38,7 +38,7 @@ function foo( b, c, ) { - scope @0 [1:6] deps=[] { + scope @0 [1:6] deps=[read a$6, read b$7] { [1] Const mutate x$9_@0:TFunction[1:6] = Array [] [2] Const mutate y$10_@0:TFunction[1:6] = Array [] if (read x$9_@0:TFunction) { diff --git a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved.expect.md b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved.expect.md index 36bd62b591..b549160000 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-interleaved.expect.md @@ -30,7 +30,7 @@ function foo( a, b, ) { - scope @0 [1:5] deps=[] { + scope @0 [1:5] deps=[read a$5, read b$6] { [1] Const mutate x$7_@0:TFunction[1:5] = Array [] [2] Const mutate y$8_@0:TFunction[1:5] = Array [] [3] Call mutate x$7_@0.push(read a$5) diff --git a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowed.expect.md b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowed.expect.md index caa5606488..a9830926d2 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowed.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowed.expect.md @@ -22,7 +22,6 @@ bb0: [5] Return scope0 [1:5]: - dependency: read a$5 - - dependency: read b$6 scope1 [2:4]: - dependency: read b$6 ``` @@ -34,7 +33,7 @@ function foo( a, b, ) { - scope @0 [1:5] deps=[read a$5, read b$6] { + scope @0 [1:5] deps=[read b$6, read a$5] { [1] Const mutate x$7_@0:TFunction[1:5] = Array [] scope @1 [2:4] deps=[read b$6] { [2] Const mutate y$8_@1:TFunction[2:4] = Array [] diff --git a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowing-within-block.expect.md b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowing-within-block.expect.md index e627aad4dc..71af081138 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowing-within-block.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowing-within-block.expect.md @@ -42,10 +42,6 @@ bb1: [11] Return freeze x$11_@0:TFunction scope0 [1:11]: - dependency: read a$8 - - dependency: read c$10 - - dependency: read b$9 - - dependency: read $13:TPrimitive - - dependency: freeze y$12_@1:TFunction scope1 [3:7]: - dependency: read c$10 - dependency: read b$9 @@ -62,17 +58,17 @@ function foo( b, c, ) { - scope @0 [1:11] deps=[read a$8, read c$10, read b$9, read $13:TPrimitive, freeze y$12_@1:TFunction] { + scope @0 [1:11] deps=[read a$8, read b$9, read c$10] { [1] Const mutate x$11_@0:TFunction[1:11] = Array [] if (read a$8) { - scope @1 [3:7] deps=[read c$10, read b$9] { + scope @1 [3:7] deps=[read b$9, read c$10] { [3] Const mutate y$12_@1:TFunction[3:7] = Array [] if (read b$9) { [5] Call mutate y$12_@1.push(read c$10) } } [7] Const mutate $13:TPrimitive = "div" - scope @2 [8:9] deps=[read $13:TPrimitive, freeze y$12_@1:TFunction] { + scope @2 [8:9] deps=[freeze y$12_@1:TFunction] { [8] Const mutate $15_@2 = JSX {freeze y$12_@1:TFunction} } [9] Call mutate x$11_@0.push(read $15_@2) diff --git a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-while.expect.md b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-while.expect.md index 6ead8c1c8e..f677abaa32 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-while.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-while.expect.md @@ -42,7 +42,7 @@ function foo( b, c, ) { - scope @0 [1:8] deps=[] { + scope @0 [1:8] deps=[read c$8, read b$7, read a$6] { [1] Const mutate x$9_@0:TFunction[1:8] = Array [] [2] Const mutate y$10_@0:TFunction[1:8] = Array [] while ( diff --git a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-within-block.expect.md b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-within-block.expect.md index 58449c4b19..faae7e4ac9 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-within-block.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-within-block.expect.md @@ -52,7 +52,7 @@ function foo( b, c, ) { - scope @0 [1:9] deps=[read c$8, read b$7, read a$6] { + scope @0 [1:9] deps=[read a$6, read b$7, read c$8] { [1] Const mutate x$9_@0:TFunction[1:9] = Array [] if (read a$6) { [3] Const mutate y$10_@0:TFunction[1:9] = Array [] 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 5a0d26ec17..266342afa0 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/property-assignment.expect.md @@ -39,14 +39,14 @@ scope1 [6:7]: function Component( props, ) { - scope @0 [1:6] deps=[read Component$0, read props$6.p0] { + scope @0 [1:6] deps=[read props$6.p0] { [1] Const mutate x$7_@0:TObject[1:6] = Object { } [2] Const mutate y$8_@0[1:6] = Array [] [3] Reassign mutate x$7_@0.y[1:6] = read y$8_@0 [4] Const mutate child$9_@0[1:6] = JSX [5] Call mutate x$7_@0.y.push(read props$6.p0) } - scope @1 [6:7] deps=[read Component$0, freeze x$7_@0:TObject, read child$9_@0] { + scope @1 [6:7] deps=[freeze x$7_@0:TObject, read child$9_@0] { [6] Const mutate $10_@1 = JSX {read child$9_@0} } return read $10_@1 diff --git a/compiler/forget/src/__tests__/fixtures/hir/reactive-scopes-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reactive-scopes-if.expect.md index f22fd0098f..100dcbfd2e 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reactive-scopes-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reactive-scopes-if.expect.md @@ -40,9 +40,6 @@ bb1: scope0 [1:11]: - dependency: read c$10 - dependency: read a$8 - - dependency: read b$9 - - dependency: read $13:TPrimitive - - dependency: freeze y$12_@1:TFunction scope1 [3:5]: - dependency: read b$9 scope2 [6:7]: @@ -58,7 +55,7 @@ function foo( b, c, ) { - scope @0 [1:11] deps=[read c$10, read a$8, read b$9, read $13:TPrimitive, freeze y$12_@1:TFunction] { + scope @0 [1:11] deps=[read a$8, read b$9, read c$10] { [1] Const mutate x$11_@0:TFunction[1:11] = Array [] if (read a$8) { scope @1 [3:5] deps=[read b$9] { @@ -66,7 +63,7 @@ function foo( [4] Call mutate y$12_@1.push(read b$9) } [5] Const mutate $13:TPrimitive = "div" - scope @2 [6:7] deps=[read $13:TPrimitive, freeze y$12_@1:TFunction] { + scope @2 [6:7] deps=[freeze y$12_@1:TFunction] { [6] Const mutate $14_@2 = JSX {freeze y$12_@1:TFunction} } [7] Call mutate x$11_@0.push(read $14_@2) 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 44b004ca2b..8e589e4ce0 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md @@ -51,7 +51,7 @@ function f( a, b, ) { - scope @0 [1:8] deps=[read a$8.length, read b$9, read b$9] { + scope @0 [1:8] deps=[read a$8.length, read b$9] { [1] Const mutate x$10_@0:TFunction[1:8] = Array [] [2] Const mutate $11:TPrimitive = 1 [3] Const mutate $12:TPrimitive = Binary read a$8.length === read $11:TPrimitive @@ -62,7 +62,7 @@ function f( } } [8] Const mutate $13:TPrimitive = "div" - scope @1 [9:10] deps=[read $13:TPrimitive, freeze x$10_@0:TFunction] { + scope @1 [9:10] deps=[freeze x$10_@0:TFunction] { [9] Const mutate $15_@1 = JSX {freeze x$10_@0:TFunction} } return read $15_@1 diff --git a/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md index dc16c3fa9f..977477868f 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md @@ -63,11 +63,11 @@ function Component( [5] Reassign mutate x$7_@0:TFunction[1:7] = Array [] } } - scope @1 [7:8] deps=[read Component$0, freeze x$7_@0:TFunction] { + scope @1 [7:8] deps=[freeze x$7_@0:TFunction] { [7] Const mutate _$12_@1 = JSX } [8] Call read y$8.push(read props$6.p2) - scope @2 [9:10] deps=[read Component$0, read x$7_@0:TFunction, read y$8:TFunction] { + scope @2 [9:10] deps=[read x$7_@0:TFunction, read y$8:TFunction] { [9] Const mutate $15_@2 = JSX } return read $15_@2 diff --git a/compiler/forget/src/__tests__/fixtures/hir/reassignment-separate-scopes.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reassignment-separate-scopes.expect.md index 065cd28e88..6a27394d8b 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment-separate-scopes.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment-separate-scopes.expect.md @@ -95,18 +95,18 @@ function foo( b, c, ) { - scope @0 [1:5] deps=[read a$13, read a$13] { + scope @0 [1:5] deps=[read a$13] { [1] Const mutate x$16_@0:TFunction[1:5] = Array [] if (read a$13) { [3] Call mutate x$16_@0.push(read a$13) } } [5] Const mutate $17:TPrimitive = "div" - scope @1 [6:7] deps=[read $17:TPrimitive, freeze x$16_@0:TFunction] { + scope @1 [6:7] deps=[freeze x$16_@0:TFunction] { [6] Const mutate y$19_@1 = JSX {freeze x$16_@0:TFunction} } [7] Const mutate $20:TPrimitive = 0 - scope @2 [8:15] deps=[read c$15, read b$14, read b$14] { + scope @2 [8:15] deps=[read b$14, read c$15] { [8] Let mutate x$22_@2:TFunction[8:15] = undefined switch (read b$14) { case read $20:TPrimitive: { @@ -124,7 +124,7 @@ function foo( [16] Const mutate $26 = "\n " [17] Const mutate $27 = "\n " [18] Const mutate $28 = "\n " - scope @3 [19:20] deps=[read $25:TPrimitive, read $26, read y$19_@1, read $27, freeze x$22_@2:TFunction, read $28] { + scope @3 [19:20] deps=[read y$19_@1] { [19] Const mutate $31_@3 = JSX {read $26}{read y$19_@1}{read $27}{freeze x$22_@2:TFunction}{read $28} } return read $31_@3 diff --git a/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md index 320c519184..0a0e90d9a8 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md @@ -32,8 +32,6 @@ bb0: scope0 [1:7]: - dependency: read props$6.p0 - dependency: read props$6.p1 - - dependency: read Component$0 - - dependency: freeze x$9_@1 scope2 [5:6]: - dependency: read Component$0 - dependency: freeze x$9_@1 @@ -49,19 +47,19 @@ scope3 [7:8]: function Component( props, ) { - scope @0 [1:7] deps=[read props$6.p0, read props$6.p1, read Component$0, freeze x$9_@1] { + scope @0 [1:7] deps=[read props$6.p0, read props$6.p1] { [1] Const mutate x$7_@0:TFunction[1:7] = Array [] [2] Call mutate x$7_@0.push(read props$6.p0) [3] Const mutate y$8_@0:TFunction[1:7] = read x$7_@0:TFunction scope @1 [4:5] deps=[] { [4] Const mutate x$9_@1 = Array [] } - scope @2 [5:6] deps=[read Component$0, freeze x$9_@1] { + scope @2 [5:6] deps=[freeze x$9_@1] { [5] Const mutate _$10_@2 = JSX } [6] Call mutate y$8_@0.push(read props$6.p1) } - scope @3 [7:8] deps=[read Component$0, read x$9_@1, freeze y$8_@0:TFunction] { + scope @3 [7:8] deps=[read x$9_@1, freeze y$8_@0:TFunction] { [7] Const mutate $11_@3 = JSX } return read $11_@3 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 aa4b10d9f0..c0f566534c 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md @@ -95,7 +95,7 @@ function Component( props, ) { [1] Const mutate x$7:TPrimitive = undefined - scope @0 [2:18] deps=[read props$6.v2, read props$6.v1, read props$6.v0, read props$6.test, read props$6.b, read props$6.c, read props$6.cond2, read props$6.cond] { + scope @0 [2:18] deps=[read props$6.cond, read props$6.test, read props$6.v0, read props$6.v1, read props$6.v2, read props$6.cond2, read props$6.b, read props$6.c] { [2] Let mutate x$11_@0:TProp[2:18] = undefined if (read props$6.cond) { [3] Const mutate $8:TPrimitive = 2 diff --git a/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md b/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md index 05ba69032c..6a3ef8a9ca 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/simple.expect.md @@ -44,14 +44,14 @@ function foo( ) { if (read x$8) { [2] Const mutate $10:TPrimitive = false - scope @0 [3:4] deps=[read foo$0:TFunction, read $10:TPrimitive, read y$9:TPrimitive] { + scope @0 [3:4] deps=[read y$9:TPrimitive] { [3] Const mutate $11_@0 = Call read foo$0:TFunction(read $10:TPrimitive, read y$9:TPrimitive) } return freeze $11_@0 } [5] Const mutate $12:TPrimitive = 10 [6] Const mutate $13:TPrimitive = Binary read y$9:TPrimitive * read $12:TPrimitive - scope @1 [7:8] deps=[read $13:TPrimitive] { + scope @1 [7:8] deps=[] { [7] Const mutate $14_@1 = Array [read $13:TPrimitive] } return freeze $14_@1 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 5920523afd..1345b155bb 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md @@ -32,7 +32,7 @@ function Component( ) { [1] Const mutate a$6:TPrimitive = 1 [2] Const mutate b$7:TPrimitive = 2 - scope @0 [3:4] deps=[read a$6:TPrimitive, read b$7:TPrimitive] { + scope @0 [3:4] deps=[] { [3] Const mutate x$8_@0 = Array [read a$6:TPrimitive, read b$7:TPrimitive] } return freeze x$8_@0 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 5f21a03946..d4af38d48e 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 @@ -62,8 +62,6 @@ bb1: [10] Const mutate $19:TPrimitive = "div" [11] Const mutate $20_@3 = JSX [12] Return read $20_@3 -scope0 [1:10]: - - dependency: read $14:TPrimitive scope2 [7:8]: - dependency: read $14:TPrimitive scope3 [11:12]: @@ -78,7 +76,7 @@ scope3 [11:12]: function Component( props, ) { - scope @0 [1:10] deps=[read $14:TPrimitive] { + scope @0 [1:10] deps=[] { [1] Const mutate a$11_@0[1:10] = Array [] [2] Const mutate b$12_@0:TObject[1:10] = Object { } [3] Call mutate foo$4:TFunction(mutate a$11_@0, mutate b$12_@0:TObject) @@ -87,14 +85,14 @@ function Component( } if (read $13_@1) { [6] Const mutate $14:TPrimitive = "div" - scope @2 [7:8] deps=[read $14:TPrimitive] { + scope @2 [7:8] deps=[freeze a$11_@0] { [7] Const mutate _$15_@2 = JSX } } [9] Call mutate foo$4:TFunction(read a$11_@0, mutate b$12_@0:TObject) } [10] Const mutate $19:TPrimitive = "div" - scope @3 [11:12] deps=[read $19:TPrimitive, freeze a$11_@0, freeze b$12_@0:TObject] { + scope @3 [11:12] deps=[freeze a$11_@0, freeze b$12_@0:TObject] { [11] Const mutate $20_@3 = JSX } return read $20_@3 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 54d7127f27..5351013265 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 @@ -52,8 +52,6 @@ bb0: [7] Const mutate $14:TPrimitive = "div" [8] Const mutate $15_@2 = JSX [9] Return read $15_@2 -scope0 [1:7]: - - dependency: read $12:TPrimitive scope1 [5:6]: - dependency: read $12:TPrimitive scope2 [8:9]: @@ -68,18 +66,18 @@ scope2 [8:9]: function Component( props, ) { - scope @0 [1:7] deps=[read $12:TPrimitive] { + scope @0 [1:7] deps=[] { [1] Const mutate a$10_@0[1:7] = Array [] [2] Const mutate b$11_@0:TObject[1:7] = Object { } [3] Call mutate foo$4:TFunction(mutate a$10_@0, mutate b$11_@0:TObject) [4] Const mutate $12:TPrimitive = "div" - scope @1 [5:6] deps=[read $12:TPrimitive] { + scope @1 [5:6] deps=[freeze a$10_@0] { [5] Const mutate _$13_@1 = JSX } [6] Call mutate foo$4:TFunction(read a$10_@0, mutate b$11_@0:TObject) } [7] Const mutate $14:TPrimitive = "div" - scope @2 [8:9] deps=[read $14:TPrimitive, read a$10_@0, freeze b$11_@0:TObject] { + scope @2 [8:9] deps=[read a$10_@0, freeze b$11_@0:TObject] { [8] Const mutate $15_@2 = JSX } return read $15_@2 diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-multiple-phis.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-multiple-phis.expect.md index 545d505544..36cb702aba 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-multiple-phis.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-multiple-phis.expect.md @@ -87,7 +87,7 @@ function foo( ) { [1] Const mutate x$13:TPrimitive = 0 [2] Const mutate $14:TPrimitive = true - scope @0 [3:20] deps=[read a$9, read b$10, read c$11, read d$12, read $14:TPrimitive] { + scope @0 [3:20] deps=[read a$9, read b$10, read c$11, read d$12] { [3] Let mutate x$18_@0[3:20] = undefined if (read $14:TPrimitive) { [4] Const mutate $15:TPrimitive = true diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-partial-phi.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-partial-phi.expect.md index 701321562f..0cfe9bfcfa 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-partial-phi.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-partial-phi.expect.md @@ -49,7 +49,7 @@ function foo( b, c, ) { - scope @0 [1:8] deps=[read a$5, read c$7, read c$7, read b$6] { + scope @0 [1:8] deps=[read a$5, read b$6, read c$7] { [1] Const mutate x$8_@0[1:8] = read a$5 if (read b$6) { if (read c$7) { diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-partial-reassignment.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-partial-reassignment.expect.md index 173e37ab04..474baa8466 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-partial-reassignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-nested-partial-reassignment.expect.md @@ -53,7 +53,7 @@ function foo( d, e, ) { - scope @0 [1:8] deps=[read b$8, read d$10, read c$9, read a$7] { + scope @0 [1:8] deps=[read a$7, read b$8, read c$9, read d$10] { [1] Let mutate x$12_@0:TPrimitive[1:8] = null if (read a$7) { [3] Reassign mutate x$12_@0:TPrimitive[1:8] = read b$8 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 4441b3e80c..cc6716106f 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 @@ -60,7 +60,7 @@ function foo( [8] Reassign mutate y$7_@0:TPrimitive[1:10] = 3 } } - scope @2 [10:11] deps=[read x$6_@0:TPrimitive, read y$7_@0:TPrimitive] { + scope @2 [10:11] deps=[] { [10] Const mutate t$14_@2:TObject = Object { x: read x$6_@0:TPrimitive, y: read y$7_@0:TPrimitive } } return freeze t$14_@2:TObject 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 0fe29b6457..b9f187f479 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md @@ -32,7 +32,7 @@ function Component( ) { [1] Const mutate a$6:TPrimitive = 1 [2] Const mutate b$7:TPrimitive = 2 - scope @0 [3:4] deps=[read a$6:TPrimitive, read b$7:TPrimitive] { + scope @0 [3:4] deps=[] { [3] Const mutate x$8_@0:TObject = Object { a: read a$6:TPrimitive, b: read b$7:TPrimitive } } return freeze x$8_@0:TObject diff --git a/compiler/forget/src/__tests__/fixtures/hir/ssa-sibling-phis.expect.md b/compiler/forget/src/__tests__/fixtures/hir/ssa-sibling-phis.expect.md index 5a382ce8ac..6ce23eba87 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-sibling-phis.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-sibling-phis.expect.md @@ -91,7 +91,7 @@ function foo( [2] Const mutate $14:TPrimitive = true if (read $14:TPrimitive) { [4] Const mutate $15:TPrimitive = true - scope @0 [5:10] deps=[read a$9, read b$10, read $15:TPrimitive] { + scope @0 [5:10] deps=[read a$9, read b$10] { [5] Let mutate x$16_@0[5:10] = undefined if (read $15:TPrimitive) { [6] Reassign mutate x$16_@0[5:10] = read a$9 @@ -102,7 +102,7 @@ function foo( [10] read x$16_@0 } else { [12] Const mutate $19:TPrimitive = true - scope @1 [13:18] deps=[read c$11, read d$12, read $19:TPrimitive] { + scope @1 [13:18] deps=[read c$11, read d$12] { [13] Let mutate x$20_@1[13:18] = undefined if (read $19:TPrimitive) { [14] Reassign mutate x$20_@1[13:18] = read c$11 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 4daecb836f..8e3c94e612 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 @@ -49,7 +49,7 @@ function foo( [1] Const mutate y$5:TPrimitive = 2 [2] Const mutate $6:TPrimitive = 1 [3] Const mutate $7:TPrimitive = Binary read y$5:TPrimitive > read $6:TPrimitive - scope @0 [4:9] deps=[read $7:TPrimitive] { + scope @0 [4:9] deps=[] { [4] Let mutate y$8_@0:TPrimitive[4:9] = undefined if (read $7:TPrimitive) { [5] Reassign mutate y$8_@0:TPrimitive[4:9] = 1 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 e6e2ee7895..aa6d35b406 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md @@ -75,7 +75,7 @@ function foo( [3] Const mutate $12:TPrimitive = Binary read x$10:TPrimitive === read $11:TPrimitive [4] Const mutate $13:TPrimitive = 1 [5] Const mutate $14:TPrimitive = Binary read x$10:TPrimitive === read $13:TPrimitive - scope @0 [6:16] deps=[read x$10:TPrimitive, read x$10:TPrimitive, read x$10:TPrimitive, read x$10:TPrimitive] { + scope @0 [6:16] deps=[] { [6] Let mutate x$16_@0:TPrimitive[6:16] = undefined switch (read x$10:TPrimitive) { case read $14:TPrimitive: { 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 737625cfc0..5d260ba95b 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 @@ -73,7 +73,7 @@ scope3 [14:15]: function Component( props, ) { - scope @1 [1:12] deps=[] { + scope @1 [1:12] deps=[read props$9.p0, read props$9.p2] { [1] Const mutate x$10_@1:TFunction[1:12] = Array [] [2] Let mutate y$11_@1:TPrimitive[1:12] = undefined [3] Const mutate $12:TPrimitive = false @@ -96,11 +96,11 @@ function Component( } } } - scope @2 [12:13] deps=[read Component$0, freeze x$10_@1:TFunction] { + scope @2 [12:13] deps=[freeze x$10_@1:TFunction] { [12] Const mutate child$19_@2 = JSX } [13] Call read y$11_@1.push(read props$9.p4) - scope @3 [14:15] deps=[read Component$0, freeze y$11_@1:TPrimitive, read child$19_@2] { + scope @3 [14:15] deps=[read child$19_@2] { [14] Const mutate $22_@3 = JSX {read child$19_@2} } return read $22_@3 diff --git a/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md b/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md index a37c1a59fc..d33e7f9289 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md @@ -2,7 +2,6 @@ ## Input ```javascript -// @Out DefUseGraph function Component(props) { let x = []; let y; @@ -68,7 +67,7 @@ scope4 [14:15]: function Component( props, ) { - scope @1 [1:12] deps=[] { + scope @1 [1:12] deps=[read props$8.p0, read props$8.p2, read props$8.p3] { [1] Const mutate x$9_@1:TFunction[1:12] = Array [] [2] Let mutate y$10_@1:TPrimitive[1:12] = undefined [3] Const mutate $11:TPrimitive = false @@ -86,11 +85,11 @@ function Component( } } } - scope @3 [12:13] deps=[read Component$0, freeze x$9_@1:TFunction] { + scope @3 [12:13] deps=[freeze x$9_@1:TFunction] { [12] Const mutate child$19_@3 = JSX } [13] Call read y$10_@1.push(read props$8.p4) - scope @4 [14:15] deps=[read Component$0, read y$10_@1:TPrimitive, read child$19_@3] { + scope @4 [14:15] deps=[read child$19_@3] { [14] Const mutate $23_@4 = JSX {read child$19_@3} } return read $23_@4 diff --git a/compiler/forget/src/__tests__/fixtures/hir/switch.js b/compiler/forget/src/__tests__/fixtures/hir/switch.js index 3069714d84..2ff19a4c76 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/switch.js +++ b/compiler/forget/src/__tests__/fixtures/hir/switch.js @@ -1,4 +1,3 @@ -// @Out DefUseGraph function Component(props) { let x = []; let y; diff --git a/compiler/forget/src/__tests__/fixtures/hir/type-field-load.expect.md b/compiler/forget/src/__tests__/fixtures/hir/type-field-load.expect.md index c3934356e9..e5fd0afcda 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/type-field-load.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/type-field-load.expect.md @@ -27,7 +27,7 @@ scope0 [2:3]: function component( ) { [1] Const mutate $4:TPrimitive = 1 - scope @0 [2:3] deps=[read $4:TPrimitive] { + scope @0 [2:3] deps=[] { [2] Const mutate x$5_@0:TObject = Object { t: read $4:TPrimitive } } [3] Const mutate p$6:TPrimitive = read x$5_@0.t