-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[concurrency] SILGen: emit hop_to_executor instructions #34540
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
Conversation
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.
I think we also need to emit hop_to_executor after an apply instruction, don't we? I was thinking it would be better to do this in a mandatory SIL pass, since SILGen emits applies in various places that would all need this handling, such as protocol witness thunks. The only bit of plumbing required then would be storing the actor isolation kind in the SILFunction instead of pulling it out of the Decl.
lib/SILGen/SILGenProlog.cpp
Outdated
@@ -449,6 +449,24 @@ void SILGenFunction::emitProlog(CaptureInfo captureInfo, | |||
} | |||
} | |||
} | |||
|
|||
if (auto *funcDecl = dyn_cast_or_null<AbstractFunctionDecl>(FunctionDC->getAsDecl())) { |
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.
If you're going to keep doing this in SILGen, how about passing this down as a parameter to emitProlog()? The caller knows the function being emitted, and I'd like to remove FunctionDC eventually since it's used for various hacks that should go away.
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.
Can I leave this up to you? emitProlog is called from multiple places (which I'm not familiar with) and I don't want to introduce a bug with this refactoring.
657d3bf
to
523840a
Compare
That's a good point. Yes, we need hop_to_executor after each async apply (just async applies) - and only in functions, which actually need to be actor isolated, e.g. because they access an actor property. I assume that this is not the case for all the thunks we generate. |
@swift-ci test |
Build failed |
Emit hop_to_executor instruction in the prolog of actor-isolated async functions and after all async calls in such functions. rdar://problem/70299168
523840a
to
c5bbe51
Compare
@swift-ci smoke test |
Emit hop_to_executor instruction in the prolog of actor-isolated async functions and after all async calls in such functions.
rdar://problem/70299168