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][ez] Add shape for global Object.keys #31583

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

[compiler][ez] Add shape for global Object.keys #31583

wants to merge 3 commits into from

Conversation

mofeiZ
Copy link
Contributor

@mofeiZ mofeiZ commented Nov 19, 2024

Add shape / type for global Object.keys. This is useful because

  • it has an Effect.Read (not an Effect.Capture) as it cannot alias its argument.
  • Object.keys return an array

Stack created with Sapling. Best reviewed with ReviewStack.

Clean up duplicate checks for when to skip processing values as dependencies / hoistable temporaries.
We previously didn't track context variables in the hoistable values sidemap of `propagateScopeDependencies`. This was overly conservative as we *do*  track the mutable range of context variables, and it is safe to hoist accesses to context variables after their last direct / aliased maybe-assignment.

```js
function Component({value}) {
  // start of mutable range for `x`
  let x = DEFAULT;
  const setX = () => x = value;
  const aliasedSet = maybeAlias(setX);
  maybeCall(aliasedSet);
  // end of mutable range for `x`

  // here, we should be able to take x (and property reads
  // off of x) as dependencies
  return <Jsx value={x} />
}
```
Add shape / type for global Object.keys. This is useful because
- it has an Effect.Read (not an Effect.Capture) as it cannot alias its argument.
- Object.keys return an array
Copy link

vercel bot commented Nov 19, 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 Nov 19, 2024 2:54pm

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.

2 participants