Skip to content

Run non-actor-isolated async functions on the generic executor #40910

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

Merged
merged 1 commit into from
Jan 28, 2022

Conversation

rjmccall
Copy link
Contributor

@rjmccall rjmccall commented Jan 19, 2022

Fixes rdar://79284465

@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - d3f9cea45b475379645112bb48dfd6b7ab4e9d46

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d3f9cea45b475379645112bb48dfd6b7ab4e9d46

@rjmccall rjmccall force-pushed the hop-to-generic-executor branch from d3f9cea to bbd4752 Compare January 20, 2022 03:41
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@rjmccall rjmccall changed the title Implement half of SE-0338: hop to the generic executor SE-0338: async functions run on the generic executor Jan 20, 2022
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - bbd47520c47ffebb954b7b4c6d863a02586534be

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - bbd47520c47ffebb954b7b4c6d863a02586534be

@rjmccall rjmccall force-pushed the hop-to-generic-executor branch from bbd4752 to 668d16c Compare January 26, 2022 09:45
@rjmccall rjmccall changed the title SE-0338: async functions run on the generic executor Run non-actor-isolated async functions on the generic executor Jan 26, 2022
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 668d16c547a49d451fc1cf73d3b534da2f19b787

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 668d16c547a49d451fc1cf73d3b534da2f19b787

@rjmccall rjmccall force-pushed the hop-to-generic-executor branch from 668d16c to d0bdd03 Compare January 27, 2022 03:26
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

Async functions are now expected to set ExpectedExecutor in their
prologue (and, generally, immediately hop to it).  I updated the
prologue code for a bunch of function emission, most of which was
uninteresting.  Top-level code was not returning to the main
executor, which is now fixed; fortunately, we weren't assuming
that we were on the main executor yet.

We had some code that only kicked in when an ExpectedExecutor
wasn't set which made us capture the current executor before
a hop and then return to it later.  This code has been removed;
there's no situation in which save-and-return is the semantically
correct thing to do given the possibility of hop optimization.
I suspect it could also have led to crashes if the current
executor is being kept alive only because it's currently running
code.  If we ever add async functions that are supposed to inherit
their caller's executor, we should have the caller pass the right
executor down to it.

This is the first half of SE-0338; the second, sendability
enforcement, is much more complicated, and Doug has volunteered
to do it.

Fixes rdar://79284465, as well as some tests that were XFAILed
on Windows.
@rjmccall rjmccall force-pushed the hop-to-generic-executor branch from d0bdd03 to 716f4b9 Compare January 27, 2022 06:54
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 716f4b9

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 716f4b9

@rjmccall
Copy link
Contributor Author

@swift-ci Please test Linux

@rjmccall
Copy link
Contributor Author

Please test with following pull request:
swiftlang/llvm-project#3851

@swift-ci Please test macOS

@rjmccall rjmccall merged commit 9eb9df8 into swiftlang:main Jan 28, 2022
@rjmccall rjmccall deleted the hop-to-generic-executor branch January 28, 2022 06:04
Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants