Skip to content

Clean up the TaskGroup ABI #36838

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
Apr 10, 2021
Merged

Conversation

rjmccall
Copy link
Contributor

@rjmccall rjmccall commented Apr 9, 2021

  • stop storing the parent task in the TaskGroup at the .swift level
  • make sure that swift_taskGroup_isCancelled is implied by the parent task being cancelled
  • make the TaskGroup structs @frozen
  • make the withTaskGroup functions @inlinable
  • remove swift_taskGroup_create
  • teach IRGen to allocate memory for the task group
  • don't deallocate the task group in swift_taskGroup_destroy

To achieve the allocation change, introduce paired create/destroy builtins.

Furthermore, remove the _swiftRetain and _swiftRelease functions and several calls to them. Replace them with uses of the appropriate builtins. I should probably change the builtins to return retained, since they're working with a managed type, but I'll do that in a separate commit.

- stop storing the parent task in the TaskGroup at the .swift level
- make sure that swift_taskGroup_isCancelled is implied by the parent
  task being cancelled
- make the TaskGroup structs frozen
- make the withTaskGroup functions inlinable
- remove swift_taskGroup_create
- teach IRGen to allocate memory for the task group
- don't deallocate the task group in swift_taskGroup_destroy

To achieve the allocation change, introduce paired create/destroy builtins.

Furthermore, remove the _swiftRetain and _swiftRelease functions and
several calls to them.  Replace them with uses of the appropriate builtins.
I should probably change the builtins to return retained, since they're
working with a managed type, but I'll do that in a separate commit.
@rjmccall rjmccall requested a review from ktoso April 9, 2021 07:07
@@ -591,7 +591,7 @@ public func withUnsafeCurrentTask<T>(body: (UnsafeCurrentTask?) throws -> T) ret
// FIXME: This retain seems pretty wrong, however if we don't we WILL crash
// with "destroying a task that never completed" in the task's destroy.
// How do we solve this properly?
_swiftRetain(_task)
Builtin.retain(_task)
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh i see, thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The remaining need for these is just that Builtin.currentAsyncTask() is returning an unretained pointer. It probably simply shouldn't, but I wanted to leave that for a different PR.

Copy link
Contributor

@ktoso ktoso Apr 9, 2021

Choose a reason for hiding this comment

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

Yeah that probably makes sense 👍 All uses of the task will then fall into place properly I think

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.

Thanks a lot for the cleanup! It's actually very clear what's going on, thanks! :-)
This'll help me a lot with the spawn lets final polish too 👍

@rjmccall
Copy link
Contributor Author

rjmccall commented Apr 9, 2021

@swift-ci Please test

1 similar comment
@rjmccall
Copy link
Contributor Author

rjmccall commented Apr 9, 2021

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Apr 9, 2021

Build failed
Swift Test Linux Platform
Git Sha - efeb818

@swift-ci
Copy link
Contributor

swift-ci commented Apr 9, 2021

Build failed
Swift Test OS X Platform
Git Sha - efeb818

@rjmccall
Copy link
Contributor Author

rjmccall commented Apr 9, 2021

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Apr 9, 2021

Build failed
Swift Test Linux Platform
Git Sha - efeb818

@rjmccall
Copy link
Contributor Author

rjmccall commented Apr 9, 2021

@swift-ci Please smoke test Linux

@rjmccall rjmccall merged commit 2e8a19c into swiftlang:main Apr 10, 2021
@rjmccall rjmccall deleted the task-group-abi-cleanup branch April 10, 2021 00:15
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