-
Notifications
You must be signed in to change notification settings - Fork 47k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compiler: Use types to decide which scopes are eligible for merging
In MergeReactiveScopesThatInvalidateTogether when deciding which scopes were eligible for mergin at all, we looked specifically at the instructions whose lvalue produces the declaration. So if a scope declaration was `t0`, we'd love for the instruction where `t0` was the lvalue and look at the instruction type to decide if it is eligible for merging. Here, we use the inferred type instead (now that the inferred types support the same set of types of instructions we looked at before). This allows us to find more cases where scopes can be merged. ghstack-source-id: 07d02d8d182b7fca75345a4f59f8a5b812868bcf Pull Request resolved: #29157
- Loading branch information
1 parent
36160af
commit 486150c
Showing
25 changed files
with
523 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 20 additions & 2 deletions
22
...eact-compiler/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
// bar(props.b) is an allocating expression that produces a primitive, which means | ||
// that Forget should memoize it. | ||
// Correctness: | ||
|
||
import { identity, mutate, setProperty } from "shared-runtime"; | ||
|
||
// - y depends on either bar(props.b) or bar(props.b) + 1 | ||
function AllocatingPrimitiveAsDepNested(props) { | ||
let x = {}; | ||
mutate(x); | ||
let y = foo(bar(props.b) + 1); | ||
mutate(x, props.a); | ||
let y = identity(identity(props.b) + 1); | ||
setProperty(x, props.a); | ||
return [x, y]; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: AllocatingPrimitiveAsDepNested, | ||
params: [{ a: 1, b: 2 }], | ||
sequentialRenders: [ | ||
// change b | ||
{ a: 1, b: 3 }, | ||
// change b | ||
{ a: 1, b: 4 }, | ||
// change a | ||
{ a: 2, b: 4 }, | ||
// change a | ||
{ a: 3, b: 4 }, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.