-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
compiler: Known hooks/nonescaping scopes dont count as pruned #29820
Merged
josephsavona
merged 3 commits into
gh/josephsavona/29/base
from
gh/josephsavona/29/head
Jun 10, 2024
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
c59c335
compiler: Known hooks/nonescaping scopes dont count as pruned
josephsavona 21724a5
Update on "compiler: Known hooks/nonescaping scopes dont count as pru…
josephsavona 8241eec
Update on "compiler: Known hooks/nonescaping scopes dont count as pru…
josephsavona File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
46 changes: 46 additions & 0 deletions
46
...ler/nonreactive-noescaping-dependency-can-inline-into-consuming-scope.expect.md
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
// @flow | ||
function Component() { | ||
return ( | ||
<div | ||
className={stylex( | ||
// this value is a) in its own scope, b) non-reactive, and c) non-escaping | ||
// its scope gets pruned bc it's non-escaping, but this doesn't mean we need to | ||
// create a temporary for it | ||
flags.feature("feature-name") ? styles.featureNameStyle : null | ||
)} | ||
></div> | ||
); | ||
} | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
import { c as _c } from "react/compiler-runtime"; | ||
function Component() { | ||
const $ = _c(1); | ||
let t0; | ||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) { | ||
t0 = ( | ||
<div | ||
className={stylex( | ||
flags.feature("feature-name") ? styles.featureNameStyle : null, | ||
)} | ||
/> | ||
); | ||
$[0] = t0; | ||
} else { | ||
t0 = $[0]; | ||
} | ||
return t0; | ||
} | ||
|
||
``` | ||
|
||
### Eval output | ||
(kind: exception) Fixture not implemented |
13 changes: 13 additions & 0 deletions
13
...__/fixtures/compiler/nonreactive-noescaping-dependency-can-inline-into-consuming-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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @flow | ||
function Component() { | ||
return ( | ||
<div | ||
className={stylex( | ||
// this value is a) in its own scope, b) non-reactive, and c) non-escaping | ||
// its scope gets pruned bc it's non-escaping, but this doesn't mean we need to | ||
// create a temporary for it | ||
flags.feature("feature-name") ? styles.featureNameStyle : null | ||
)} | ||
></div> | ||
); | ||
} |
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 |
---|---|---|
|
@@ -39,7 +39,7 @@ export const FIXTURE_ENTRYPOINT = { | |
```javascript | ||
import { c as _c } from "react/compiler-runtime"; | ||
function Component(props) { | ||
const $ = _c(2); | ||
const $ = _c(1); | ||
|
||
const a = []; | ||
const b = []; | ||
|
@@ -53,12 +53,11 @@ function Component(props) { | |
x = 1; | ||
} | ||
let t0; | ||
if ($[0] !== x) { | ||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) { | ||
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.
|
||
t0 = [x]; | ||
$[0] = x; | ||
$[1] = t0; | ||
$[0] = t0; | ||
} else { | ||
t0 = $[1]; | ||
t0 = $[0]; | ||
} | ||
return t0; | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 output matches what we have on main today. Whereas with the previous PR in the stack the output was:
Way more code and 4 cache slots instead of 1.