Skip to content

[compiler][hir-rewrite] Infer non-null props, destructure source#31033

Merged
mofeiZ merged 3 commits into
gh/mofeiZ/18/basefrom
gh/mofeiZ/18/head
Sep 30, 2024
Merged

[compiler][hir-rewrite] Infer non-null props, destructure source#31033
mofeiZ merged 3 commits into
gh/mofeiZ/18/basefrom
gh/mofeiZ/18/head

Conversation

@mofeiZ

@mofeiZ mofeiZ commented Sep 23, 2024

Copy link
Copy Markdown
Contributor

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]
@vercel

vercel Bot commented Sep 23, 2024

Copy link
Copy Markdown

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
Copy Markdown
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.

@josephsavona josephsavona left a comment

Copy link
Copy Markdown
Contributor

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

mofeiZ commented Sep 27, 2024

Copy link
Copy Markdown
Contributor Author

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
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: 32f3bb7
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