dillon1000/react

Commit

[hir] Don't alias fields unless a mutation occurs after aliasing

A wise Joe once said, "We only care about observed aliasing". 

Instead of performing aliasing for fields and non fields together, split the 
analysis to happen over separate passes. Similarly split inferring mutable 
lifetimes pass for fields and non fields. 

Now, we can identify the aliases of fields that are *not* mutated and only alias 
the ones that do mutate. 

The algorithm is roughly as follows: 

1. Build the set of aliases for non fields 

2. Infer mutable ranges for all instructions except aliasing fields 

3. Infer mutable ranges for all aliased instructions based on the alias set 
calculated in step 1 (this doesn't include aliasing fields) 

4. Extend the set of aliases (calculated in step 1)  to include fields only if 
the field or the receiver is mutated after the aliasing, ie, if _mutability is 
observed_. 

5. Run infer mutable ranges again for all instructions including the fields that 
were aliased in the previous step. 

6. Run infer mutable ranges for all aliased instructions including the fields 
that were aliased.
Browse files
Changed paths28 files
First-parent comparison
R compiler/forget/src/HIR/BuildAliasSets.ts →compiler/forget/src/HIR/InferAlias.ts RenamedA compiler/forget/src/HIR/InferAliasForFields.ts AddedM compiler/forget/src/HIR/InferMutableLifetimes.ts ModifiedA compiler/forget/src/HIR/InferMutableRanges.ts AddedA compiler/forget/src/HIR/InferMutableRangesForAlias.ts AddedM compiler/forget/src/HIR/Pipeline.ts ModifiedM compiler/forget/src/HIR/PrintHIR.ts ModifiedM compiler/forget/src/__tests__/fixtures/hir/reactive-scope-grouping.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md ModifiedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-alias-mutate-if.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-alias-mutate-if.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-if.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-if.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-mutate-if.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-mutate-if.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-mutate-inside-if.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-mutate-inside-if.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-mutate.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-alias-mutate.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-mutate-2.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-mutate-2.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-mutate-alias.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-mutate-alias.js AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-mutate.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/ssa-property-mutate.js AddedM compiler/forget/src/__tests__/fixtures/hir/ssa-property.expect.md ModifiedM compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md ModifiedM compiler/forget/src/index.ts Modified
Patch

Files changed

Rendering syntax-highlighted changes…