Skip to content

Add mandatory hop #37898

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 3 commits into from
Jun 14, 2021
Merged

Add mandatory hop #37898

merged 3 commits into from
Jun 14, 2021

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Jun 14, 2021

Add Builtin.hopToActor

SILGen this builtin to a mandatory hop_to_executor with an actor type
operand.

e.g.

    Task.detached {
      Builtin.hopToActor(MainActor.shared)
      await suspend()
    }

Required to fix a bug in _runAsyncMain.

atrick added 3 commits June 13, 2021 23:44
SILGen this builtin to a mandatory hop_to_executor with an actor type
operand.

e.g.

    Task.detached {
      Builtin.hopToActor(MainActor.shared)
      await suspend()
    }

Required to fix a bug in _runAsyncMain.
If the optimizer is doing it's job, then @mainactor can't be used to
force another actor-independent async callee onto the main actor.

Instead, explicitly hop, which communicates the actual intent and is robust.
@atrick
Copy link
Contributor Author

atrick commented Jun 14, 2021

@swift-ci test

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@etcwilde etcwilde left a comment

Choose a reason for hiding this comment

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

LGTM

@atrick
Copy link
Contributor Author

atrick commented Jun 14, 2021

Merging to unblock #37756

@rjmccall let me know if this is not what you had envisioned though and we can change it

@atrick atrick merged commit b001b0b into swiftlang:main Jun 14, 2021
@atrick atrick deleted the add-mandatory-hop branch June 14, 2021 17:44
@eeckstein
Copy link
Contributor

lgtm!

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.

4 participants