-
Notifications
You must be signed in to change notification settings - Fork 50.4k
compiler: More precise escape analysis #29782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,26 +68,20 @@ import { CONST_TRUE, identity, shallowCopy } from "shared-runtime"; | |
| * should be merged. | ||
| */ | ||
| function useFoo(t0) { | ||
| const $ = _c(3); | ||
| const $ = _c(2); | ||
| const { input } = t0; | ||
| const arr = shallowCopy(input); | ||
|
|
||
| const cond = identity(false); | ||
| let t1; | ||
| if ($[0] === Symbol.for("react.memo_cache_sentinel")) { | ||
| t1 = identity(false); | ||
| $[0] = t1; | ||
| } else { | ||
| t1 = $[0]; | ||
| } | ||
| const cond = t1; | ||
| let t2; | ||
| if ($[1] !== arr) { | ||
| t2 = cond ? { val: CONST_TRUE } : mutate(arr); | ||
| $[1] = arr; | ||
| $[2] = t2; | ||
| if ($[0] !== arr) { | ||
| t1 = cond ? { val: CONST_TRUE } : mutate(arr); | ||
|
Comment on lines
+75
to
+78
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This output is invalid — note that |
||
| $[0] = arr; | ||
| $[1] = t1; | ||
| } else { | ||
| t2 = $[2]; | ||
| t1 = $[1]; | ||
| } | ||
| return t2; | ||
| return t1; | ||
| } | ||
|
|
||
| export const FIXTURE_ENTRYPOINT = { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a perfect example of how this PR makes escape analysis more precise. The dependency is on
y.method, which we only use where a primitive is expected (inx[y.method]). We don't have to memoize themakeObject(a)call if we're only going to extract a primitive from it.