GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [compiler] Add fallthrough to branch terminal by josephsavona · Pull Request #30814 · react/react

Conversation

@josephsavona

@josephsavona josephsavona commented Aug 26, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

  • [compiler] Inferred deps must match exact optionality of manual deps #30840
  • [compiler] Enable optional dependencies by default #30838
  • [compiler] Handle optional where innermost property access is non-optional #30836
  • [compiler] Infer optional dependencies (behind feature flag) #30819
  • [compiler] Allow inferred non-optional paths when manual deps were optional #30816
  • -> [compiler] Add fallthrough to branch terminal #30814
  • [compiler] Add DependencyPath optional property #30813
  • [compiler] Wrap ReactiveScopeDep path tokens in object #30812
  • [compiler] Stop reusing ScopeDep type in AnalyzeFunctions #30811

Branch terminals didn't have a fallthrough because they correspond to an outer terminal (optional, logical, etc) that has the "real" fallthrough. But understanding how branch terminals correspond to these outer terminals requires knowing the branch fallthrough. For example, foo?.bar?.baz creates terminals along the lines of:

bb0:
  optional fallthrough=bb4
bb1:
  optional fallthrough=bb3
bb2:
  ...
  branch ... (fallthrough=bb3)

...

bb3:
  ...
  branch ... (fallthrough=bb4)

...

bb4:
  ...

Without a fallthrough on branch terminals, it's unclear that the optional from bb0 has its branch node in bb3. With the fallthroughs, we can see look for a branch with the same fallthrough as the outer optional terminal to match them up.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@josephsavona
[compiler] Add fallthrough to branch terminal
1846220
Branch terminals didn't have a fallthrough because they correspond to an outer terminal (optional, logical, etc) that has the "real" fallthrough. But understanding how branch terminals correspond to these outer terminals requires knowing the branch fallthrough. For example, `foo?.bar?.baz` creates terminals along the lines of:

```
bb0:
  optional fallthrough=bb4
bb1:
  optional fallthrough=bb3
bb2:
  ...
  branch ... (fallthrough=bb3)

...

bb3:
  ...
  branch ... (fallthrough=bb4)

...

bb4:
  ...
```

Without a fallthrough on `branch` terminals, it's unclear that the optional from bb0 has its branch node in bb3. With the fallthroughs, we can see look for a branch with the same fallthrough as the outer optional terminal to match them up.

[ghstack-poisoned]
@vercel

vercel Bot commented Aug 26, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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 Aug 28, 2024 6:12pm
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Aug 26, 2024
[compiler] Stop reusing ScopeDep type in AnalyzeFunctions #30811
Merged
[compiler] Wrap ReactiveScopeDep path tokens in object #30812
Merged
[compiler] Add DependencyPath optional property #30813
Merged
[compiler] Infer optional manual memo deps #30815
Closed
[compiler] Allow inferred non-optional paths when manual deps were optional #30816
Merged
@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Aug 26, 2024
@vercel
vercel Bot deployed to Preview August 26, 2024 19:25
View deployment
@josephsavona josephsavona mentioned this pull request Aug 26, 2024
[compiler] Infer optional dependencies (behind feature flag) #30819
Merged
@josephsavona
Update on "[compiler] Add fallthrough to branch terminal"
01b9791
Branch terminals didn't have a fallthrough because they correspond to an outer terminal (optional, logical, etc) that has the "real" fallthrough. But understanding how branch terminals correspond to these outer terminals requires knowing the branch fallthrough. For example, `foo?.bar?.baz` creates terminals along the lines of:

```
bb0:
  optional fallthrough=bb4
bb1:
  optional fallthrough=bb3
bb2:
  ...
  branch ... (fallthrough=bb3)

...

bb3:
  ...
  branch ... (fallthrough=bb4)

...

bb4:
  ...
```

Without a fallthrough on `branch` terminals, it's unclear that the optional from bb0 has its branch node in bb3. With the fallthroughs, we can see look for a branch with the same fallthrough as the outer optional terminal to match them up.

[ghstack-poisoned]
@vercel
vercel Bot deployed to Preview August 27, 2024 05:43
View deployment
@josephsavona josephsavona mentioned this pull request Aug 28, 2024
[compiler] Handle optional where innermost property access is non-optional #30836
Merged
josephsavona added 2 commits August 28, 2024 10:44
@josephsavona
Update on "[compiler] Add fallthrough to branch terminal"
fed48b4
Branch terminals didn't have a fallthrough because they correspond to an outer terminal (optional, logical, etc) that has the "real" fallthrough. But understanding how branch terminals correspond to these outer terminals requires knowing the branch fallthrough. For example, `foo?.bar?.baz` creates terminals along the lines of:

```
bb0:
  optional fallthrough=bb4
bb1:
  optional fallthrough=bb3
bb2:
  ...
  branch ... (fallthrough=bb3)

...

bb3:
  ...
  branch ... (fallthrough=bb4)

...

bb4:
  ...
```

Without a fallthrough on `branch` terminals, it's unclear that the optional from bb0 has its branch node in bb3. With the fallthroughs, we can see look for a branch with the same fallthrough as the outer optional terminal to match them up.

[ghstack-poisoned]
@josephsavona
Update on "[compiler] Add fallthrough to branch terminal"
00d44be
Branch terminals didn't have a fallthrough because they correspond to an outer terminal (optional, logical, etc) that has the "real" fallthrough. But understanding how branch terminals correspond to these outer terminals requires knowing the branch fallthrough. For example, `foo?.bar?.baz` creates terminals along the lines of:

```
bb0:
  optional fallthrough=bb4
bb1:
  optional fallthrough=bb3
bb2:
  ...
  branch ... (fallthrough=bb3)

...

bb3:
  ...
  branch ... (fallthrough=bb4)

...

bb4:
  ...
```

Without a fallthrough on `branch` terminals, it's unclear that the optional from bb0 has its branch node in bb3. With the fallthroughs, we can see look for a branch with the same fallthrough as the outer optional terminal to match them up.

[ghstack-poisoned]
@vercel
vercel Bot deployed to Preview August 28, 2024 18:12
View deployment
@josephsavona josephsavona mentioned this pull request Aug 28, 2024
[compiler] Enable optional dependencies by default #30838
Merged
mofeiZ
mofeiZ reviewed Aug 28, 2024
View reviewed changes
Comment thread compiler/packages/babel-plugin-react-compiler/src/Inference/DropManualMemoization.ts
Comment on lines +512 to +514
case 'logical':
case 'sequence':
case 'ternary': {

@mofeiZ mofeiZ Aug 28, 2024

Copy link
Copy Markdown
Contributor

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.

Ah I see, I'm guessing that this is to support something like useMemo(..., [(a ?? b)?.c]). Not technically necessary for DropManualMemo as we're only tracking named variables, but this makes sense to have in a utility function

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

josephsavona reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@josephsavona josephsavona Aug 28, 2024

Copy link
Copy Markdown
Contributor Author

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.

yup exactly

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mofeiZ
mofeiZ reviewed Aug 28, 2024
View reviewed changes
Comment thread compiler/packages/babel-plugin-react-compiler/src/Inference/DropManualMemoization.ts
Comment on lines +502 to +504
if (last !== undefined && last.value.kind === 'StoreLocal') {
optionals.add(last.value.value.identifier.id);
}

@mofeiZ mofeiZ Aug 28, 2024

Copy link
Copy Markdown
Contributor

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 feels slightly weird since DropManualMemo runs before we enter ssa, so both consequent (the optional read) and alternate (undefined) write to the same identifier ID. There is also no phi join, so reads to the OptionalExpression rvalue is also guaranteed to use the same identifier ID (and this works)

(I'm guessing that passes after SSA will need to track phis as well -- reading the rest of the stack now)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@josephsavona josephsavona Aug 28, 2024

Copy link
Copy Markdown
Contributor Author

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.

Yeah I looked at using the phi to figure out which values is optional. First, as you noted we aren't in SSA so we don't have phis yet. Second, the phis end up in weird places for nested optionals, because with nested optionals the alternate actually goes to the outermost fallthrough. So we just look at where the consequent assigns to in order to figure out what the optional value was.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mofeiZ
mofeiZ approved these changes Aug 28, 2024
View reviewed changes
@josephsavona josephsavona mentioned this pull request Aug 28, 2024
[compiler] Inferred deps must match exact optionality of manual deps #30840
Merged
@josephsavona
josephsavona merged commit 00d44be into gh/josephsavona/50/base Aug 28, 2024
josephsavona added a commit that referenced this pull request Aug 28, 2024
@josephsavona
[compiler] Add fallthrough to branch terminal
925c20a
Branch terminals didn't have a fallthrough because they correspond to an outer terminal (optional, logical, etc) that has the "real" fallthrough. But understanding how branch terminals correspond to these outer terminals requires knowing the branch fallthrough. For example, `foo?.bar?.baz` creates terminals along the lines of:

```
bb0:
  optional fallthrough=bb4
bb1:
  optional fallthrough=bb3
bb2:
  ...
  branch ... (fallthrough=bb3)

...

bb3:
  ...
  branch ... (fallthrough=bb4)

...

bb4:
  ...
```

Without a fallthrough on `branch` terminals, it's unclear that the optional from bb0 has its branch node in bb3. With the fallthroughs, we can see look for a branch with the same fallthrough as the outer optional terminal to match them up.

ghstack-source-id: d48c623
Pull Request resolved: #30814
@josephsavona
josephsavona deleted the gh/josephsavona/50/head branch August 28, 2024 22:59
This was referenced Aug 29, 2024
Upgrade React from 7771d3a7-20240827 to a19a8ab4-20240829 vercel/next.js#69461
Closed
Upgrade React from 7771d3a7-20240827 to e56f4ae3-20240830 vercel/next.js#69500
Closed
Upgrade React from 7771d3a7-20240827 to 4f604941-20240830 vercel/next.js#69578
Closed
Upgrade React from 7771d3a7-20240827 to d1afcb43-20240903 vercel/next.js#69687
Closed
nivemula pushed a commit to nivemula/Java that referenced this pull request Sep 5, 2024
@josephsavona
[compiler] Add fallthrough to branch terminal
49ab600
Branch terminals didn't have a fallthrough because they correspond to an outer terminal (optional, logical, etc) that has the "real" fallthrough. But understanding how branch terminals correspond to these outer terminals requires knowing the branch fallthrough. For example, `foo?.bar?.baz` creates terminals along the lines of:

```
bb0:
  optional fallthrough=bb4
bb1:
  optional fallthrough=bb3
bb2:
  ...
  branch ... (fallthrough=bb3)

...

bb3:
  ...
  branch ... (fallthrough=bb4)

...

bb4:
  ...
```

Without a fallthrough on `branch` terminals, it's unclear that the optional from bb0 has its branch node in bb3. With the fallthroughs, we can see look for a branch with the same fallthrough as the outer optional terminal to match them up.

ghstack-source-id: 064178d
Pull Request resolved: react/react#30814
This was referenced Sep 5, 2024
Upgrade React from 7771d3a7-20240827 to 4c58fce7-20240904 vercel/next.js#69743
Closed
Upgrade React from 7771d3a7-20240827 to a03254bc-20240905 vercel/next.js#69794
Closed
Upgrade React from 7771d3a7-20240827 to e210d081-20240909 vercel/next.js#69885
Closed
Upgrade React from 7771d3a7-20240827 to 3dfd5d9e-20240910 vercel/next.js#69928
Closed
Upgrade React from 7771d3a7-20240827 to d6cb4e77-20240911 vercel/next.js#69980
Closed
This was referenced Sep 12, 2024
Upgrade React from 7771d3a7-20240827 to 47352209-20240912 vercel/next.js#70035
Closed
Upgrade React from 7771d3a7-20240827 to 94e652d5-20240912 vercel/next.js#70037
Merged
gnoff pushed a commit to vercel/next.js that referenced this pull request Sep 12, 2024
@vercel-release-bot
Upgrade React from 7771d3a7-20240827 to 94e652d5-20240912 (#70037)
f2cf2e0
**breaking change for canary users: Bumps peer dependency of React from
`19.0.0-rc-7771d3a7-20240827` to `19.0.0-rc-94e652d5-20240912`**

[diff
react/react@7771d3a7...94e652d5](react/react@7771d3a...94e652d)

<details>
<summary>React upstream changes</summary>

- react/react#30952
- react/react#30950
- react/react#30946
- react/react#30934
- react/react#30947
- react/react#30945
- react/react#30938
- react/react#30936
- react/react#30879
- react/react#30888
- react/react#30931
- react/react#30930
- react/react#30832
- react/react#30929
- react/react#30926
- react/react#30925
- react/react#30905
- react/react#30900
- react/react#30910
- react/react#30906
- react/react#30899
- react/react#30919
- react/react#30708
- react/react#30907
- react/react#30897
- react/react#30896
- react/react#30895
- react/react#30887
- react/react#30889
- react/react#30893
- react/react#30892
- react/react#30891
- react/react#30882
- react/react#30881
- react/react#30870
- react/react#30849
- react/react#30878
- react/react#30865
- react/react#30869
- react/react#30875
- react/react#30800
- react/react#30762
- react/react#30831
- react/react#30866
- react/react#30853
- react/react#30850
- react/react#30847
- react/react#30842
- react/react#30837
- react/react#30848
- react/react#30844
- react/react#30839
- react/react#30802
- react/react#30841
- react/react#30827
- react/react#30826
- react/react#30825
- react/react#30824
- react/react#30840
- react/react#30838
- react/react#30836
- react/react#30819
- react/react#30816
- react/react#30814
- react/react#30813
- react/react#30812
- react/react#30811

</details>

---------

Co-authored-by: vercel-release-bot <[email protected]>
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@josephsavona
[compiler] Add fallthrough to branch terminal
f5d0d7c
Branch terminals didn't have a fallthrough because they correspond to an outer terminal (optional, logical, etc) that has the "real" fallthrough. But understanding how branch terminals correspond to these outer terminals requires knowing the branch fallthrough. For example, `foo?.bar?.baz` creates terminals along the lines of:

```
bb0:
  optional fallthrough=bb4
bb1:
  optional fallthrough=bb3
bb2:
  ...
  branch ... (fallthrough=bb3)

...

bb3:
  ...
  branch ... (fallthrough=bb4)

...

bb4:
  ...
```

Without a fallthrough on `branch` terminals, it's unclear that the optional from bb0 has its branch node in bb3. With the fallthroughs, we can see look for a branch with the same fallthrough as the outer optional terminal to match them up.

ghstack-source-id: d48c623
Pull Request resolved: react#30814

This branch was successfully deployed

1 active deployment
Preview — 00d44bef Deployed Aug 28, 2024 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@mofeiZ mofeiZ mofeiZ approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@josephsavona @mofeiZ @facebook-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.