dillon1000/react

Commit

StoreLocal instruction

Adds a new `StoreLocal <kind> <place> = <value>` instruction which stores 
<value> into <place>. With this change, Instruction.lvalue is _always_ a `const` 
temporary, and never a named identifier (there's a new validation pass to assert 
this). StoreLocal is the only way to declare or update a named identifier: the 
instructionKind property says whether it's a const/let declaration or a 
reassignment. Naturally a _lot_ of passes had to be updated to make this work, 
but the existing Effect.Store variant that @gsathya added made this overall 
straightforward. 

Note that as of this PR several passes still have code to handle the possibility 
of an instruction lvalue being something other than a temporary. When we clean 
that up in a follow-up, there will be a lot less of the duplication that appears 
here. For example, CodegenReactiveFunction has two places to handle variable 
declarations in this PR. However, one of them is to handle lvalues, which should 
now _always_ be temporaries and never emit a regular variable declaration. 
Similarly, several passes have to build up a table of identifier -> identifier 
(because of LoadLocal). Longer-term, we should update the Place abstraction so 
that it directly specifies the instruction which created that temporary, so we 
can look it up on demand instead of needing an extra mapping.
Browse files
Changed paths90 files
First-parent comparison
M compiler/forget/src/CompilerPipeline.ts ModifiedM compiler/forget/src/HIR/BuildHIR.ts ModifiedM compiler/forget/src/HIR/HIR.ts ModifiedM compiler/forget/src/HIR/PrintHIR.ts ModifiedA compiler/forget/src/HIR/ValidateConsistentIdentifiers.ts AddedM compiler/forget/src/HIR/visitors.ts ModifiedM compiler/forget/src/Inference/InferAlias.ts ModifiedM compiler/forget/src/Inference/InferAliasForStores.ts ModifiedM compiler/forget/src/Inference/InferMutableLifetimes.ts ModifiedM compiler/forget/src/Inference/InferReferenceEffects.ts ModifiedM compiler/forget/src/Optimization/ConstantPropagation.ts ModifiedM compiler/forget/src/Optimization/DeadCodeElimination.ts ModifiedM compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts ModifiedM compiler/forget/src/ReactiveScopes/InferReactiveIdentifiers.ts ModifiedM compiler/forget/src/ReactiveScopes/InferReactiveScopeVariables.ts ModifiedM compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts ModifiedM compiler/forget/src/SSA/EnterSSA.ts ModifiedM compiler/forget/src/SSA/LeaveSSA.ts ModifiedM compiler/forget/src/TypeInference/InferTypes.ts ModifiedM compiler/forget/src/__tests__/fixtures/hir/_bug.capturing-func-simple-alias.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/alias-nested-member-path.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/allocating-primitive-as-dep.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/array-access-assignment.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/assignment-in-nested-if.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/assignment-variations.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/bug_object-pattern.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capture-func-passed-to-jsx.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-arrow-function-1.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-func-mutate-2.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-func-mutate-3.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-func-mutate.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-function-1.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-function-member-expr-call.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-function-within-block.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-member-expr.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-nested-member-call.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-nested-member-expr-in-nested-func.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-nested-member-expr.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-variable-in-nested-block.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/capturing-variable-in-nested-function.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/component.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/concise-arrow-expr.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/controlled-input.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/destructure-capture-global.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/for-logical.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-arguments.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/independent.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/method-call-computed.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/method-call-fn-call.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/method-call.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/obj-literal-cached-in-if-else.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/obj-mutated-after-if-else-with-alias.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/obj-mutated-after-if-else.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/obj-mutated-after-nested-if-else-with-alias.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/object-pattern-params.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/primitive-as-dep.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/prop-capturing-function-1.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/reassignment-separate-scopes.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/reduce-reactive-deps-cond-scope.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/same-variable-as-dep-and-redeclare-maybe-frozen.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/same-variable-as-dep-and-redeclare.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/simple-function-1.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/simple-scope.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-newexpression.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-non-empty-initializer.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-if.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-mutate-inside-if.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/switch.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/tagged-template-literal.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/timers.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/type-binary-operator.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/type-field-load.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/type-test-field-load-binary-op.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/type-test-field-store.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/type-test-polymorphic.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/type-test-return-type-inference.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/unary-expr.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/useMemo-simple.expect.md ModifiedM compiler/forget/yarn.lock Modified
Patch

Files changed

Rendering syntax-highlighted changes…