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

Merged
merged 2 commits into from
Dec 16, 2024
Merged

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

merged 2 commits into from
Dec 16, 2024

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.

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 Dec 16, 2024 8:22pm

@facebook-github-bot facebook-github-bot added the React Core Team Opened by a member of the React Core Team label Nov 19, 2024
mofeiZ added a commit that referenced this pull request Dec 16, 2024
Clean up duplicate checks for when to skip processing values as
dependencies / hoistable temporaries.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31581).
* #31583
* #31582
* __->__ #31581
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
mofeiZ added a commit that referenced this pull request Dec 16, 2024
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} />
}
```
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31582).
* #31583
* __->__ #31582
@mofeiZ mofeiZ merged commit 8a7b306 into main Dec 16, 2024
19 of 28 checks passed
davesnx added a commit to davesnx/react that referenced this pull request Dec 18, 2024
…act into issue-31578-setter-arity-gcc

* 'issue-31578-setter-arity-gcc' of github.com:/davesnx/react:
  [flags] Clean up scheduler flags (facebook#31814)
  Enable debugRenderPhaseSideEffectsForStrictMode in test renderers (facebook#31761)
  Enable disableDefaultPropsExceptForClasses (facebook#31804)
  Turn on useModernStrictMode in test renderers (facebook#31769)
  [compiler][ez] Add shape for global Object.keys (facebook#31583)
  [compiler] Context variables as dependencies (facebook#31582)
  [compiler] Add fire to known React APIs (facebook#31795)
  [compiler] Add option for firing effect functions (facebook#31794)
  [compiler][be] Logger based debug printing in test runner (facebook#31809)
  [compiler][ez] Clean up duplicate code in propagateScopeDeps (facebook#31581)
  [compiler] Repro for aliased captures within inner function expressions (facebook#31770)
  [compiler][be] Playground now compiles entire program (facebook#31774)
  [Flight] Color and badge non-primary environments (facebook#31738)
  [Flight] Emit Deduped Server Components Marker (facebook#31737)
  [Flight] Sort Server Components Track Group ahead of Client Scheduler/Components Tracks (facebook#31736)
  Clean up context access profiling experiment (facebook#31806)
  [Flight] Stack Parallel Components in Separate Tracks (facebook#31735)
  Flag for requestPaint (facebook#31805)
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