Skip to content
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][hir-rewrite] Infer non-null props, destructure source #31033

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

mofeiZ
Copy link
Contributor

@mofeiZ mofeiZ commented Sep 23, 2024

Stack from ghstack (oldest at bottom):

Followup from #30894.
This adds a new flagged mode enablePropagateScopeDepsInHIR: "enabled_with_optimizations", under which we infer more hoistable loads:

  • it's always safe to evaluate loads from props (i.e. first parameter of a component)
  • destructuring sources are safe to evaluate loads from (e.g. given {x} = obj, we infer that it's safe to evaluate obj.y)
  • computed load sources are safe to evaluate loads from (e.g. given arr[0], we can infer that it's safe to evaluate arr.length)

[ghstack-poisoned]
Copy link

vercel bot commented Sep 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 30, 2024 4:34pm

[ghstack-poisoned]
@josephsavona
Copy link
Contributor

This optimization makes sense, but why not just make this part of enablePropagateScopeDepsInHIR? Given that we're already still testing this new mode, it's fine to include additional optimizations.

Copy link
Contributor

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep the optimization but make it the default for this flag, and revert the changes related to making the flag non-boolean

@mofeiZ
Copy link
Contributor Author

mofeiZ commented Sep 27, 2024

I would keep the optimization but make it the default for this flag, and revert the changes related to making the flag non-boolean

Makes sense! I was originally hoping that this flag would help us validate hir-rewrite of propagateScopeDeps by letting us diff enablePropagateScopeDepsInHIR: "enabled_baseline" with enablePropagateScopeDepsInHIR: "disabled". But it looks like the rewrite + hoisting logic changes snapshot output enough that this won't be helpful.

[ghstack-poisoned]
@mofeiZ mofeiZ merged commit b0a85c2 into gh/mofeiZ/18/base Sep 30, 2024
20 checks passed
mofeiZ added a commit that referenced this pull request Sep 30, 2024
Followup from #30894.
This adds a new flagged mode `enablePropagateScopeDepsInHIR: "enabled_with_optimizations"`, under which we infer more hoistable loads:
- it's always safe to evaluate loads from `props` (i.e. first parameter of a `component`)
- destructuring sources are safe to evaluate loads from (e.g. given `{x} = obj`, we infer that it's safe to evaluate obj.y)
- computed load sources are safe to evaluate loads from (e.g. given `arr[0]`, we can infer that it's safe to evaluate arr.length)

ghstack-source-id: 32f3bb72e9f85922825579bd785d636f4ccf724d
Pull Request resolved: #31033
@mofeiZ mofeiZ deleted the gh/mofeiZ/18/head branch September 30, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants